review(p9-4): 회차 1 지적 반영
blocks / embeddings 섹션의 count 라인이 collapse 검사 *밖* 에서 push 되어 collapsed 상태에서 부분만 사라지던 일관성 깨짐. fix: count 를 section header 에 inline 으로 (`▾ blocks (N)`, `▾ embeddings (N)`), body 만 collapse 검사 안. 새 helper `push_section_header_with_count` 가 둘 다 통일. 회귀 테스트 보강: - doc_view_collapse_hides_section_body: collapsed 상태에서 \"blocks (2)\" inline count 표시 + \"Heading L1\" body 숨김 검증. - chunk_view_renders_text_and_block_ids: \"embeddings (2)\" inline count 검증. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -163,12 +163,15 @@ pub(crate) fn build_doc_lines<'a>(
|
||||
lines.push(blank());
|
||||
}
|
||||
|
||||
// blocks
|
||||
push_section_header(&mut lines, SECTION_BLOCKS, s);
|
||||
lines.push(Line::from(format!(
|
||||
" count = {}",
|
||||
doc.blocks.len()
|
||||
)));
|
||||
// blocks — section header carries the count inline so a
|
||||
// collapsed view still reports "how many" without leaking
|
||||
// body lines (R1 review: count must collapse with the rest).
|
||||
push_section_header_with_count(
|
||||
&mut lines,
|
||||
SECTION_BLOCKS,
|
||||
s,
|
||||
Some(doc.blocks.len()),
|
||||
);
|
||||
if !s.collapsed.contains(SECTION_BLOCKS) {
|
||||
let preview_n = 16.min(doc.blocks.len());
|
||||
for (i, b) in doc.blocks.iter().take(preview_n).enumerate() {
|
||||
@@ -242,20 +245,19 @@ pub(crate) fn build_chunk_lines<'a>(
|
||||
lines.push(blank());
|
||||
}
|
||||
|
||||
// embeddings (block_ids serve as the lightweight provenance —
|
||||
// full embedding records require an extra facade call out of v1
|
||||
// scope; spec § Out of scope: \"Embedding inspection beyond
|
||||
// listing model identity\")
|
||||
push_section_header(&mut lines, SECTION_EMBEDDINGS, s);
|
||||
// embeddings — section header carries the block_id count inline
|
||||
// (spec § Out of scope: full embedding records lookup is P+).
|
||||
push_section_header_with_count(
|
||||
&mut lines,
|
||||
SECTION_EMBEDDINGS,
|
||||
s,
|
||||
Some(chunk.block_ids.len()),
|
||||
);
|
||||
if !s.collapsed.contains(SECTION_EMBEDDINGS) {
|
||||
lines.push(Line::from(Span::styled(
|
||||
" (embedding records not loaded — out of v1 scope)",
|
||||
Style::default().add_modifier(Modifier::DIM),
|
||||
)));
|
||||
lines.push(Line::from(format!(
|
||||
" block_ids = {}",
|
||||
chunk.block_ids.len()
|
||||
)));
|
||||
for bid in &chunk.block_ids {
|
||||
lines.push(Line::from(format!(" {}", bid.0)));
|
||||
}
|
||||
@@ -288,10 +290,26 @@ fn blank() -> Line<'static> {
|
||||
}
|
||||
|
||||
fn push_section_header(lines: &mut Vec<Line<'static>>, name: &'static str, s: &InspectState) {
|
||||
push_section_header_with_count(lines, name, s, None);
|
||||
}
|
||||
|
||||
/// Section header + optional inline count. Inline-count form is used
|
||||
/// where a collapsed section should still report \"how many\" — see
|
||||
/// blocks / embeddings.
|
||||
fn push_section_header_with_count(
|
||||
lines: &mut Vec<Line<'static>>,
|
||||
name: &'static str,
|
||||
s: &InspectState,
|
||||
count: Option<usize>,
|
||||
) {
|
||||
let collapsed = s.collapsed.contains(name);
|
||||
let marker = if collapsed { "▸" } else { "▾" };
|
||||
let title = match count {
|
||||
Some(n) => format!("{marker} {name} ({n})"),
|
||||
None => format!("{marker} {name}"),
|
||||
};
|
||||
lines.push(Line::from(Span::styled(
|
||||
format!("{marker} {name}"),
|
||||
title,
|
||||
Style::default()
|
||||
.add_modifier(Modifier::BOLD)
|
||||
.fg(Color::Yellow),
|
||||
|
||||
@@ -264,16 +264,25 @@ fn doc_view_collapse_hides_section_body() {
|
||||
}
|
||||
let pre = render_to_string(&app, 100, 30);
|
||||
assert!(pre.contains("kb-source-fs"), "before collapse");
|
||||
assert!(pre.contains("Heading L1"), "blocks body before collapse");
|
||||
handle_key_inspect(
|
||||
&mut app,
|
||||
KeyEvent::new(KeyCode::Char('c'), KeyModifiers::NONE),
|
||||
);
|
||||
let post = render_to_string(&app, 100, 30);
|
||||
assert!(post.contains("metadata"), "section header still visible");
|
||||
assert!(
|
||||
post.contains("blocks (2)"),
|
||||
"blocks count visible inline on collapsed header: {post}"
|
||||
);
|
||||
assert!(
|
||||
!post.contains("kb-source-fs"),
|
||||
"provenance body hidden after collapse: {post}"
|
||||
);
|
||||
assert!(
|
||||
!post.contains("Heading L1"),
|
||||
"blocks body hidden after collapse (count must collapse with body): {post}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -290,8 +299,8 @@ fn chunk_view_renders_text_and_block_ids() {
|
||||
assert!(rendered.contains("Line 1-5"), "source span described");
|
||||
assert!(rendered.contains("chunk body line one"), "text body rendered");
|
||||
assert!(
|
||||
rendered.contains("block_ids = 2"),
|
||||
"block_id count rendered"
|
||||
rendered.contains("embeddings (2)"),
|
||||
"block_id count rendered inline on embeddings header"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user