Library Enter / Search 'i' 가 Inspect 진입. Doc 또는 Chunk 단일 view 로
metadata / provenance / blocks (doc) 또는 spans / text / embeddings (chunk)
6 section 을 collapsible 로 표시. Esc/q 로 originating pane 으로 복귀.
핵심:
- InspectTarget enum (`Doc(DocumentId) | Chunk(ChunkId)`).
- InspectState 본체 (`app.rs`) — target / doc / chunk / collapsed
HashSet / scroll / return_to / needs_fetch / loading.
- `src/inspect.rs`:
- `render_inspect` — target 종류별 render_doc / render_chunk 분기,
section header 가 collapse marker (▾/▸) 표시. metadata.user JSON
pretty-printed.
- `handle_key_inspect`: j/k / Down/Up scroll. PageDown/PageUp 10 row.
c = toggle all sections (v1 simplification). Esc/q = SwitchPane(return_to).
- `enter_inspect(state, target, return_to)` helper — Library 와 Search
공통 entry point.
- run-loop hook `refresh_inspect` — needs_fetch 면 lazy
inspect_doc_with_config / inspect_chunk_with_config.
- run.rs: Pane::Inspect arm 이 handle_key_inspect + render_inspect.
Idle tick 마다 refresh_inspect. SwitchPane(Inspect) lazy init.
- Library: Enter 가 enter_inspect(Doc(selected)) 호출 후 SwitchPane.
- Search: 'i' (plain modifier) 가 enter_inspect(Chunk(selected_hit))
호출 후 SwitchPane. typing 'i' (\"instance\") 와 충돌 가드.
테스트 12개 (`tests/inspect.rs`, TestBackend) — Esc 가 return_to 사용
/ q 도 동작 / j/k scroll bounds / PgUp PgDn ±10 / c 일괄 toggle / no
target hint / loading / doc view header+metadata+provenance+blocks /
collapse hides body / chunk view text+block_ids / no slot →
SwitchPane(Library) / enter_inspect helper sets fields.
Spec deviation (HOTFIXES `2026-05-02 P9-4`):
- `render_inspect<B: Backend>` generic 제거 (P9-1/2/3 와 동일).
- Search `i` 키 추가 (P9-2 spec 에 없었음, P9-4 retroactive 추가).
- `c` 일괄 collapse — spec 의 \"focus 기반 selective collapse\" 는 P+.
Docs (sync rule):
- README: TUI 행 \"4 패널\" + Quick start 코멘트.
- HANDOFF: 한 줄 요약 + Phase status (P9 3/5 → 4/5) + deviation 한 줄.
- HOTFIXES: P9-4 entry.
- tasks/p9/p9-4 status: completed.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4.9 KiB
4.9 KiB
phase, component, task_id, title, status, depends_on, unblocks, contract_source, contract_sections
| phase | component | task_id | title | status | depends_on | unblocks | contract_source | contract_sections | ||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| P9 | kebab-tui (inspect pane) | p9-4 | TUI Inspect pane: document & chunk detail render | completed |
|
../../docs/superpowers/specs/2026-04-27-kebab-final-form-design.md |
|
p9-4 — TUI Inspect pane
Goal
Render document and chunk inspection views (matching the wire schemas doc_summary.v1 and chunk_inspection.v1) with collapsible sections for metadata, provenance, blocks (doc) and embeddings (chunk).
Why now / why this size
Inspect is read-only and has no external interactions; smallest possible pane. Useful for debugging chunker output and citation provenance during P5+ tuning.
Allowed dependencies
kebab-corekebab-configkebab-appkebab-tui(extends p9-1)ratatui,crosstermtracingthiserror
Forbidden dependencies
kebab-source-fs,kebab-parse-*,kebab-normalize,kebab-chunk,kebab-store-*,kebab-embed*,kebab-search,kebab-llm*,kebab-rag(only viakebab-app),kebab-desktop
Inputs
| input | type | source |
|---|---|---|
kebab-app::inspect_doc(id) |
facade | runtime |
kebab-app::inspect_chunk(id) |
facade | runtime |
| keyboard events | crossterm |
terminal |
Outputs
| output | type | downstream |
|---|---|---|
| Ratatui Inspect pane render | terminal | user |
Public surface (signatures only — no new types)
pub enum InspectTarget { Doc(kebab_core::DocumentId), Chunk(kebab_core::ChunkId) }
pub fn render_inspect<B: ratatui::backend::Backend>(f: &mut ratatui::Frame, area: ratatui::layout::Rect, state: &App);
pub fn handle_key_inspect(state: &mut App, key: crossterm::event::KeyEvent) -> KeyOutcome;
This task fills the body of kebab_tui::InspectState (forward-declared in p9-1). App is NOT edited.
pub struct InspectState {
pub target: Option<InspectTarget>,
pub doc: Option<kebab_core::CanonicalDocument>,
pub chunk: Option<kebab_core::Chunk>,
pub collapsed: std::collections::HashSet<&'static str>,
pub scroll: u16,
}
render_inspect/handle_key_inspect read app.inspect.as_mut() exclusively. Parallel-safety contract from p9-1 holds.
Behavior contract
- Switching to Inspect from Library passes
Doc(selected.doc_id). From Search pressingi(new key on Search pane) passesChunk(selected_hit.chunk_id). - Doc view layout (top to bottom):
- Header (title, doc_path, doc_id, lang, source_type, trust_level)
- Metadata (aliases / tags / timestamps /
metadata.userJSON pretty-printed) - Provenance (events list)
- Blocks (count + first-N preview; on
btoggle to full list paginated)
- Chunk view layout:
- Header (chunk_id, doc_id, doc_path, heading_path, chunker_version)
- Source spans (rendered as W3C fragment URIs per design §0 Q3)
- Text (chunk full text in a scrollable area)
- Embeddings (model_id, dims, embedding_id list — empty if none yet)
- Key bindings:
j/k→ scrollc→ collapse / expand currently focused section (focus is implicit by current scroll position; v1 may simplify by toggling all sections)Esc→ return to previous pane (Library or Search)Enter→ no-op (Inspect is terminal — no editor jump here; users use Search pane for jump)
- Loading: while
kebab-app::inspect_docorinspect_chunkruns, show "loading…". On error, popup with hint. - Renders must conform to wire schemas
doc_summary.v1(subset for header) andchunk_inspection.v1.
Storage / wire effects
- Reads only.
Test plan
| kind | description | fixture / data |
|---|---|---|
| unit | switching to InspectTarget::Doc triggers kebab-app::inspect_doc once |
inline mock |
| unit | scroll bounded by content height | inline |
| unit | collapse toggle via c flips state |
inline |
| snapshot | doc-view rendered for fixture stable | TestBackend + fixture |
| snapshot | chunk-view rendered for fixture stable | TestBackend + fixture |
All tests under cargo test -p kebab-tui inspect.
Definition of Done
cargo check -p kebab-tuipassescargo test -p kebab-tui inspectpasses- No imports outside Allowed dependencies
- Manual smoke: inspect a doc with multiple chunks, scroll, return to library
- PR links design §3.5, §2.5, §2.6
Out of scope
- Editing documents.
- Re-ingestion buttons.
- Embedding inspection beyond listing model identity.
- Side-by-side diff with previous doc version.
Risks / notes
- Long chunk text (~10 KB) rendering can be slow if re-rendered every frame; cache wrapped lines and re-wrap only on resize.
- Pretty-printing
metadata.useras JSON: preferserde_json::to_string_pretty. Indentation = 2 spaces. - Korean text in metadata: ensure
unicode-width-aware wrapping.