Skip to content

Add open documents to an Ask AI conversation - #97

Draft
Ganesh75-web wants to merge 7 commits into
Forward-Future:mainfrom
Ganesh75-web:ask-ai-open-tabs
Draft

Ganesh75-web wants to merge 7 commits into
Forward-Future:mainfrom
Ganesh75-web:ask-ai-open-tabs

Conversation

@Ganesh75-web

@Ganesh75-web Ganesh75-web commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Ask AI can only read the current PDF, even when several documents are open. Comparing resumes or cross-checking reports requires a way to choose which other documents belong in the conversation.

Change

Add a "+" picker above the composer for other open PDFs. Selected documents appear as removable chips and are sent with the current document to ChatGPT, Claude, OpenRouter, or a custom endpoint. Filename-and-page citations jump to the corresponding tab; same-name files receive distinct labels.

The picker also prepares tabs that have not been visited yet without switching away from the conversation. Closed, edited, or unreadable attachments are skipped with a note beside the question. Up to 20 attachments share the existing text budget, with cuts at page boundaries and explicit notices when text cannot fit. OpenRouter/custom endpoints keep their whole-document truncation guard.

Saved history contains attachment names and content identifiers. Adding a password-protected document makes that conversation session-only. New conversation and Clear chats handle those attachments and privacy state, including delayed extraction and persistence writes.

Issue or approval

Implements the proposal in #93. Maintainer approval of the idea and scope is still pending, so this PR is a draft for review. No approval comment is available to link yet.

How I checked it

Verified on Windows against this branch:

  • npx vitest run --reporter=verbose: 21 files, 301 tests passed, including attachment preparation, stale/closed documents, protected-document history, conversation clearing, citations, and shared budgets.
  • npx tsc --noEmit and npm run build: passed.
  • npm run smoke: passed the full hidden Windows run, including adding an unvisited tab without switching, multi-document requests, citation navigation, closed-document skips, and existing reader/printing regressions.
  • node scripts/test-reader-security.mjs: passed all 10 checks, including untrusted document prompts, IPC validation, and metadata-only history.
  • node scripts/test-chat-math.mjs: 18 checks passed; OpenRouter and custom endpoint suites passed 4 and 9 tests respectively.
  • git diff --check: passed.

Windows, macOS, and Linux CI all passed on commit 8276d50: CI run 43347848042. Each platform ran the full workflow, including the build and smoke checks. Provider payloads were checked with local fixtures; live provider responses have not been verified for this feature.

Before: several PDFs are open, but the conversation sees only the active document. Tab names in the example were anonymized.

Before: Ask AI sees only the current PDF

After: the implemented panel has an add-document button and a removable chip for selected context. This screenshot comes from the hidden smoke run with a local test endpoint.

After: another open PDF added to the conversation

AI-assisted implementation and review: GPT-6.1 Sol via the Codex harness in T3 Code, with delegated agents.

Readers expose their text, password state and page navigation, and the tab list can name, read and show other open documents by content id. The ask request type gains optional attachments.
… menu focus

Ask AI now leaves out an added document whose text can't be read instead of failing the question, and treats a document edited after it was added as no longer open. The picker stops at 20 documents, waits for saved history, and moves focus into and out of its menu. Citations of closed documents stay plain text.
Keep attachment aliases consistent in the picker, chips, provider payloads and file citations. Cover protected and unreadable attachments, saved metadata and the desktop multi-document flow. Initialize real pdf.js fixtures before test cases and stabilize hidden Windows rendering without changing normal app launches.

@mberman84 mberman84 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reproduced a citation opening the wrong PDF at 8276d50. Attach Report.pdf, get an answer citing page 2, remove that attachment, then attach a different file also named Report.pdf. Clicking the old answer’s citation now opens page 2 of the second file. A component regression check using two different content IDs reproduced this while the existing 12 attachment-panel tests passed.

AiPanel resolves citations for every answer using the current attachment list. If this proposal proceeds, bind each answer’s citations to the content IDs sent on that turn and keep a citation inactive when its original document is unavailable. The feature is still awaiting a scope decision in #93.

This branch has not been deployed

No deployments
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.

2 participants