Skip to content

fix(web): queued-message edits keep the context you added when their run starts - #31128

Open
M0xoo wants to merge 1 commit into
pingdotgg:mainfrom
M0xoo:fix/queued-edit-keeps-context
Open

M0xoo wants to merge 1 commit into
pingdotgg:mainfrom
M0xoo:fix/queued-edit-keeps-context

Conversation

@M0xoo

@M0xoo M0xoo commented Nov 4, 2026

Copy link
Copy Markdown

Problem

If a queued message starts while you are editing it, because the turn ended or another client started it, T3 Code moves your unsaved edit into the composer and says "Your unsaved edit was kept in the composer."

On web and desktop, that move carried only the prompt, images and files. Thread mentions and other context stayed behind in an orphaned queued-edit: draft, and their chips were stripped from the text. If you then sent the message, the agent never got that context. Expected: the whole edit is kept, as on mobile, where exitQueuedRunEdit already moves context.

Steps: hold a turn on an approval, queue a message, click Edit queued message, add an @thread mention, then approve so the queued message starts mid-edit.

Change

moveComposerPromptAndImages becomes moveComposerContent (recoverQueuedMessageEdit is its only caller). It now moves every context type the prompt still references, and clears them from the source, so the edit draft goes away.

  • A mention you typed over stays out, matching referencedThreadContexts on the send path.
  • A chip with no record is stripped, so it can't come back as a dead chip.

Scope and approval

No prior issue or discussion. This is a small, focused fix for an obvious bug: the toast says the edit was kept while part of it is dropped, and mobile already keeps it. It solves that one problem in one web store action, with no contract, server or settings changes.

Related open PRs, which I left out of this one:

Verification

Real app with the Replay provider, using the steps above. Both builds show the "kept" toast; only the fixed one still has the mention.

Composer after a queued edit's run starts, before and after

main This PR
Composer text only, 0 chips text and mention chip
Thread draft threadContexts: 0 threadContexts: 1
Orphan queued-edit: draft stays in storage with threadContexts: 1 none

Two cases in queuedMessageEdit.test.ts, both failed before their fix:

keeps context added to an edit when another client starts the queued run
AssertionError: expected [] to deeply equal [ Array(1) ]

leaves out a mention typed over and a chip with no record when keeping an edit
AssertionError: expected [ Array(1) ] to deeply equal []

With the fix:

  • queuedMessageEdit.test.ts and composerDraftStore.test.ts: 83 passed
  • useQueuedRunEdit.browser.test.tsx: 7 passed
  • vp run check:changed: all steps pass

Not checked: the real run used @thread only, so the other context types go through the same code but were not each run in the app. Mobile is unchanged and was not run.

Model: Claude Opus 5.5, harness: Claude Code in wisp.

🤖 Generated with Claude Code

…run starts

When a queued message started while it was being edited, the edit moved
into the thread composer without its thread mentions and other context,
even though the toast said it was kept. The context stayed behind in an
orphaned queued-edit draft.

The move now carries all context the prompt still references. A mention
the user typed over stays out, and so do chips with no record.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Nov 4, 2026
@macroscopeapp

macroscopeapp Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at c0304cb

Macroscope's review found this PR approvable — Queued-message edits now retain their referenced context when recovered into an empty composer. The change remains within draft recovery, preserves attachment safeguards, and does not automatically submit the recovered content.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

When queued-edit recovery keeps an edit, it now moves all composer content. The store retains inline references only when their context records are eligible to move, then clears the source prompt and context records.

Changes: Queued edit content recovery

Layer / File(s) Summary
Filter and move composer content
apps/web/src/composerDraftStore.ts, apps/web/src/lib/composerContextReferences.ts
The store moves eligible content and matching context records. It filters inline references by transferable context IDs, then clears the source prompt and context arrays.
Use content transfer during queued-edit recovery
apps/web/src/components/chat/queuedMessageEdit.ts, apps/web/src/components/chat/queuedMessageEdit.test.ts
When recovery keeps an edit, it moves composer content. Tests cover retaining references with matching context records and excluding references without matching records.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related issues

  • pingdotgg/t3code#15611 — The pull request recovers unsaved edit content and its referenced context when a queued run starts during editing.

Suggested reviewers: macroscopeapp, maria-rcks

Merge Risk: Minimal · up to c0304

Referenced context is preserved during queued-edit recovery. No material merge-blocking issue was established.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title is concise, follows the repository’s conventional format, and clearly describes the main change: preserving context added to queued-message edits when the run starts.
Description check Passed The description includes all required sections. It explains the problem and reproduction steps, describes the implementation, documents scope and approval rationale, and provides detailed verification…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description includes all required sections. It explains the problem and reproduction steps, describes the implementation, documents scope and approval rationale, and provides detailed verification results, screenshots, test outcomes, and untested cases.

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Tip

🎯 Customize your risk assessments

Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.

✅ Automatic approvals, with your rules

Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 7f6f47b and c0304cb.

Files selected for processing: 4
  • apps/web/src/components/chat/queuedMessageEdit.test.ts
  • apps/web/src/components/chat/queuedMessageEdit.ts
  • apps/web/src/composerDraftStore.ts
  • apps/web/src/lib/composerContextReferences.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

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

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant