Repository navigation
UN-4506 [DEV] Show text and images in the v1 DocumentViewer, with a switcher slot - #2409
muhammad-ali-e wants to merge 24 commits into
Conversation
…switcher slot
- DocumentViewer takes any DocumentSource: a PDF (URL or bytes), an
image ({kind: "image", url}) or text ({kind: "text", text}).
- TextView shows text line by line with line numbers, keeping the
layout's spacing, and highlights whole lines (0-based, as LLMWhisperer
numbers them) in default, active and low-confidence tones; highlighted
lines report clicks and can be scrolled to.
- ImageView shows an image as a one-page document: the toolbar's zoom
and fits apply (zoom 1 is its natural size), page highlights draw over
it, and a failed load offers Retry.
- The toolbar gains a leading slot for the document switcher, shown in
every state so a failed document can be switched away from; paging
shows only for PDFs and zoom only for PDFs and images.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01R7trgcAzu6jxDnit3eeozm
|
The failing hook is There's no fix to port yet. The fix is a one-line change on #2399: Generated by Claude Code |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01R7trgcAzu6jxDnit3eeozm
# Conflicts: # frontend/src/v1/components/patterns/document-viewer/DocumentViewer.test.tsx # frontend/src/v1/components/patterns/document-viewer/ViewerToolbar.tsx
# Conflicts: # frontend/src/v1/components/patterns/document-viewer/ViewerToolbar.tsx
…ages - Paging keys on text and images keep the browser's own scrolling; they used to be swallowed and jump to the top. Text ignores zoom keys. - Scroll requests wait until an image has loaded, not just until its view has mounted, so an early highlight scroll lands once the image is sized. - Returning to an image shown earlier waits for its reload instead of reusing the old size. - The image view draws only page 0's highlights. - Text rows are memoised, so moving the active highlight re-renders only the lines involved. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01R7trgcAzu6jxDnit3eeozm
…r source Brings in the layout-based current page and the source-bound scroll requests from UN-4505, and extends them to text and images: a waiting scroll is dropped when another text or image is shown, including one parked on an empty text. A new text gets a fresh view at the top, as a new PDF or image already did. readyRef is set at commit, not in render. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01R7trgcAzu6jxDnit3eeozm
… and images Waiting scroll requests now carry the source they were made for, with a key per kind (the text itself for text, the URL for an image), in place of the passive clear effect, which dropped requests made at commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01R7trgcAzu6jxDnit3eeozm
[Medium impact] The PR appears safe to merge; no new actionable issues were established.
|
Each row sized its own number column, so line 10 started further right than line 9 and the text lost its columns. The gutter is now as wide as the longest line number, shared through a custom property. Raised by Greptile on #2409. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01R7trgcAzu6jxDnit3eeozm
Only a box highlight moves the image view across, as on a PDF page; a line spans the image and keeps the reader's horizontal scroll. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01R7trgcAzu6jxDnit3eeozm
Dismissed because a newer commit was pushed; Greptile will re-review the current head.
praveen-formido
left a comment
There was a problem hiding this comment.
Text and image views plus the switcher slot. Two items I would fix first: a text content change is treated as a new document, so a live-edited text (the HITL case) remounts, scrolls to the top and re-centres the highlight on every keystroke; and zoom keys pressed while an image is still loading switch to custom mode, so the image never fits once it arrives. The rest are smaller.
One more that sits on a line outside this diff: in scrollTo (DocumentViewer.tsx:247) a highlight on a page other than 0 of an image source never resolves, because ImageView only has one page, so scrollToHighlight returns false and the request stays in pendingRef forever. Dropping the request when the source is an image and highlight.page !== 0 (or clamping to page 0) clears it.
# Conflicts: # frontend/src/v1/components/patterns/document-viewer/DocumentViewer.tsx
…one source key, empty text - A text source can carry an id; the view keeps its place while the id stays the same, so a live-edited text no longer remounts per keystroke. - One sourceKey drives every per-source reset (image size, page index) and keys the text and image views, replacing three separate mechanisms. - Zoom keys are ignored until an image has a size, so it still opens in its fit mode. - A scroll to a highlight on another page of an image is dropped instead of waiting for ever. - ImageView resets when its URL changes, reports a highlight scroll as not yet possible until it has loaded, and keeps the centre spot when zooming. - The image region is named Image viewer, so it no longer repeats the image's alt text. - Blank text says no text was found rather than no document. - Text lines use content-visibility, so the browser skips layout and paint for lines off screen while every line stays in the DOM. - One NO_HIGHLIGHTS constant and one page frame class are shared. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01R7trgcAzu6jxDnit3eeozm
Dismissed because a newer commit was pushed; Greptile will re-review the current head.
|
Thanks @praveen-formido. On the review note about Generated by Claude Code |
# Conflicts: # frontend/src/v1/components/patterns/document-viewer/DocumentViewer.test.tsx # frontend/src/v1/components/patterns/document-viewer/DocumentViewer.tsx
Dismissed because a newer commit was pushed; Greptile will re-review the current head.
… the first image zoom on the view - A text kept by its id changes in place, so a scroll waiting on it is retried when the text changes, not only when the highlights do. - ImageView reads its anchor from the view once the image is first laid out, instead of starting from the image's centre. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01R7trgcAzu6jxDnit3eeozm
|



What
New and changed files in
components/patterns/document-viewer/:TextView.tsx: text with line highlights, used for Raw Text (V21), HITL text and LLMWhisperer results.ImageView.tsx: an image shown as a one-page document.DocumentViewernow accepts aDocumentSource: a PDF, an image or text.ViewerToolbargains a leading slot for the document switcher (C10).Part of the v1 DocumentViewer (P1-T21, UN-4390).
Why
The consumer pages show more than PDFs:
One viewer handles all of these, so each page doesn't need its own.
How
Sources.
DocumentSourceis a union of three shapes:PdfSource(URL or bytes){kind: "image", url, alt?}{kind: "text", text}usePdfDocumentonly runs for PDFs.TextView:<li>per line, with a line number.whitespace-pre-wrap, so LLMWhisperer's column layout survives.monotype role and Geist Mono, which the README reserves for model output.{id, line, tone?}, 0-based, matching LLMWhisperer'sline_metadatakeys) in the default, active and low-confidence tones.onTextHighlightClick, each highlighted line is a button.scrollToHighlightcentres the line.ImageView:<img>.Toolbar:
switcherslot sits at the toolbar's leading edge and shows in every state, including loading and failed, so you can always switch away from a broken document.Keyboard: + and − do nothing in text.
Not checked against Figma: I couldn't open frame C10 from here. The slot is placed by the plan's description, so please compare it with C10 before this merges. The switcher itself is page-owned (P5-T04); this PR only reserves its place.
Can this PR break any existing features. If yes, please list possible items. If no, please explain why. (PS: Admins do not merge the PR without this section filled)
src/v1/and nothing imports it yet. The only change for existing callers is thatsourcenow also accepts image and text sources; PDF sources work as before.Database Migrations
Env Config
Relevant Docs
Related Issues or PRs
Dependencies Versions
Notes on Testing
bun run typecheck:v1,lint:v1andtest:v1pass (137 unit tests, 56 boundary fixtures).biome ci src/reports no errors.Screenshots
Checklist
I have read and understood the Contribution Guidelines.
Generated by Claude Code