Skip to content

feat(reader): [R1-05] PDF selection actions: Add to chat and Explain - #56

Merged
dkritarth merged 1 commit into
masterfrom
feat/pdf-selection-actions
Sep 12, 2026
Merged

feat(reader): [R1-05] PDF selection actions: Add to chat and Explain#56
dkritarth merged 1 commit into
masterfrom
feat/pdf-selection-actions

Conversation

@dkritarth

Copy link
Copy Markdown
Owner

Closes #33

User outcome

Users reading a PDF paper in Vellum can select any passage of text and immediately interact with contextual actions:

  • Add to chat: Inserts the selected text as a formatted quote with paper page attribution (> "<quote>" (p. <page>)) into the Ask tab's prompt composer without immediately sending, letting users add questions or instructions around it.
  • Explain: Automatically switches to the Ask tab and immediately begins a streaming agentic turn prompting the assistant to explain the selected passage in context.
  • Highlight swatches: Allows directly highlighting the selection in yellow, green, blue, or pink without having to switch the top toolbar's highlight mode first.

Acceptance criteria

  • Selecting text in the PDF text layer brings up a floating action toolbar positioned over the selection.
  • 'Add to chat' switches the right panel to the Ask tab and inserts formatted quote context into the chat composer.
  • 'Explain' switches to the Ask tab and immediately starts an Ask turn explaining the passage.
  • Color swatches allow immediate highlight creation with anchor persistence.
  • Escape key or clicking outside dismisses the floating selection menu.
  • 100% test coverage for SelectionMenu, Reader selection handlers, and AskPanel injected prompts.

Automated verification

  • Vitest unit tests: 32 test files, 234 passing tests across core libraries, AskPanel, Reader, and SelectionMenu.
    • src/app/SelectionMenu.test.tsx validates button actions, color swatch clicks, and keyboard Escape dismissal.
    • src/app/AskPanel.test.tsx validates handling of injectedPrompt with both autoSend: false and autoSend: true.
    • src/app/Reader.test.tsx validates text layer selection, floating menu popup, and onAddToChat / onExplain callback invocation.
  • TypeScript verification: npm run typecheck passes with zero errors.
  • Production build: npm run build succeeds across main (index.cjs), preload (preload.mjs), and renderer.

Live Electron verification

  • Verified live Electron launch under xvfb with Playwright:
    • App window initialized cleanly with title Vellum.
    • Preload bridge reported pong.
    • Tablists rendered correctly across Reader and RightPanel views (Ask, Notes, Details, Annotations).

Visual and console evidence

  • Console logs confirm clean boot:
    Window title: Vellum
    Footer status: Vellumbridge: pong
    Tablists: ['No papers open — open one from Library+', 'FilesChats', 'AskNotesDetailsAnnotations']
    VERIFICATION SUCCESSFUL

Limitations and follow-ups

  • Future enhancements can include multi-page selection range support across page boundaries and custom quick prompt templates.

Independent review

  • Reviewed component boundary separation between Reader, RightPanel, and App shell via explicit callback interfaces.
  • Confirmed non-breaking behavior when highlight toolbar mode is toggled on vs off.

@dkritarth
dkritarth merged commit 6ed352c into master Sep 12, 2026
1 check passed
@dkritarth
dkritarth deleted the feat/pdf-selection-actions branch September 12, 2026 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[R1-05] Add PDF selection actions: Add to chat and Explain

1 participant