Skip to content

Commit 7522ecb

Browse files
committed
fix: populate chunk.doc_items on rechunk so bbox↔chunk linking works
After clicking a chunk card in the Chunk view, the matching bboxes were not highlighted on the preview. Root cause: the rechunk path in `ChunkService.rechunk_document` created the new `Chunk` rows with `doc_items=[]`, on a stale comment that claimed `ChunkResult` had no `doc_items`. `ChunkResult` actually carries `doc_items: list[ChunkDocItem]` (see `domain/value_objects.py`), populated by `LocalChunker` from `chunk.meta.doc_items`. Dropping that list at rechunk time meant the frontend's `elementRefsForChunk` helper had no `self_ref` entries to drive the canvas highlight (#264), so the bbox stayed in its default style regardless of the selected chunk. Fix: pass `list(r.doc_items)` through. Affects every chunk produced via the Strategy popover (#268) and every chunk produced by the workspace-level "Generate chunks" button (#266) — both go through `rechunk_document`. The promote-from-analysis path already populated `doc_items` correctly (see `_analysis_chunk_to_canonical`). 48 chunk-service / API tests passing.
1 parent e78758b commit 7522ecb

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

document-parser/services/chunk_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ async def rechunk_document(self, document_id: str, options: dict | None = None)
451451
headings=list(r.headings),
452452
source_page=r.source_page,
453453
bboxes=list(r.bboxes),
454-
doc_items=[], # ChunkResult has no doc_items currently
454+
doc_items=list(r.doc_items),
455455
token_count=r.token_count or None,
456456
)
457457
for seq, r in enumerate(new_results)

0 commit comments

Comments
 (0)