Skip to content

fix(web): stopped or expired questions return their attached files to the composer - #38005

Merged
juliusmarminge merged 4 commits into
mainfrom
factory/issue-36581-a36582
Nov 17, 2026
Merged

juliusmarminge merged 4 commits into
mainfrom
factory/issue-36581-a36582

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

No review items were assigned this round; this pass watched PR #38005. Macroscope's high finding (apps/web/src/questionAttachments.ts:191) was right: the web composer draft store serializes images only from persistedAttachments, which only a mounted ChatComposer refreshes. Images moved into the thread draft while its composer was unmounted (the question resolves from another device or while another thread is shown) were therefore lost on reload once the question draft was cleared. Commit 9b53245 copies the persistedAttachments records of the images that moved from the question drafts into the thread draft with syncPersistedAttachments before the question drafts are cleared, skipping ids the thread draft already persists. The existing cancelled/expired test now adds a persisted image; it fails without the change (persistedAttachments []) and passes with it. Macroscope then approved at 9b53245. CodeRabbit's single line comment (mobile test should assert the recovered draft rather than the mocked append call) is rated Trivial and was left as is. All 8 required checks passed on 9b53245 with nothing failing or pending; the watch has been removed.

Fixes #36581

Reproduction on main

Commit: origin/main cd9c39f. Main's only Replay question ('question', acp_elicitation) is enum-only and its composer is not editable, so I temporarily added the free-text Replay recording from the closed PR #36582 (text_question_transcript.ndjson plus a 'text-question' entry in dev-replay-agent.ts, not committed). Then I ran a scratch e2e scenario against the real server and web client: create a project, start a thread on model text-question (it waits on the free-text question 'What should this replay know before it continues?'), open the thread, type 'Use my notes' in the composer, attach notes.txt through the file input (the chip appears above the answer), click 'Stop generation'. Result: the timeline shows 'Run interrupted · Stopped by user', the question closes, and the thread composer contains 'Use my notes' but no notes.txt chip. The scenario's final assertion getByText('notes.txt') failed with match count 0. Captures: before https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/68b2276540fd546c/issue-36581-before-stop.png, after https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/a6873ca84a4377de/issue-36581-after-stop.png. Unit level: I added a notes.txt file to the existing cancelled/expired case in apps/web/src/questionAttachments.test.ts; both statuses fail on main with expected files [notes.txt], received [], while the text and thread-context assertions pass.

Evidence

In the real web client (Chromium, 1280×800, light theme), create a fresh project and free-text Replay question, type Use my notes, attach notes.txt, then click Stop generation. Both runs used identical synthetic data and the same temporary Replay fixture.

Proven: base loses the attachment while retaining the text; head preserves both. scenarios:prove exited 0.

Before After
Commit cd9c39fe3c 9b53245d13
Pending answer Before: pending answer contains notes.txt After: pending answer contains notes.txt
After stopping Before: text returns but notes.txt disappears After: text and notes.txt return together
Recording Before interaction After interaction

Scenario source · Temporary Replay fixture setup · Runner proof

Not shown:

  • Expiration was not exercised; the captured reproduction stops the pending question through Stop generation.
  • Image attachments, attachment-only answers, thread chips, and reload recovery were not exercised; this scenario covers typed text plus notes.txt.
  • Desktop and mobile clients were not exercised; proof covers the real web client.

Tests

apps/web: vp test run src/questionAttachments.test.ts passed 6/6 with the change; with the source change stashed the 2 cancelled/expired cases fail on persistedAttachments. vp run check:changed passed format, lint, knip, typecheck (3 packages), tests (2 files) and react compiler. On the PR, all 8 required checks passed on 9b53245.

Not in this change

  • The request-scoped question draft key prefix is now built both here and in resolvedQuestionDraftKeys (packages/client-runtime); a shared helper could remove the duplication.
  • Mobile does not return a stopped or expired question's typed answer text to the thread composer at all (web does, via carryDisplacedCustomAnswerIntoPrompt); that is a separate pre-existing gap, not the attachment loss this issue reports.
  • The web fix builds the request-scoped question draft key prefix inline, duplicating resolvedQuestionDraftKeys in client-runtime; the mobile fix reuses the helper instead.
  • CodeRabbit (Trivial): the mobile test in thread-task-permissions.test.ts asserts the mocked appendComposerDraftAttachments call rather than the resulting draft state.
  • Mobile does not return a stopped or expired question's typed answer text to the thread composer (web does); that is a separate pre-existing gap.
  • The web fix builds the request-scoped question draft key prefix inline, duplicating resolvedQuestionDraftKeys in client-runtime.

Who did the work

  • Written by Claude Opus 5.5, in Claude Code
  • Reviewed by GPT-6.1 Sol, in Codex, and by Claude Opus 5.5, each on its own
  • Proof captured by GPT-6.1 Sol and checked by Claude Opus 5.5

Run by the t3code factory in T3 Code.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Stopping or expiring a question discards its unsent attachments

1 participant