The best way to control Claude Code, Codex and more from any computer or phone
fix(web): keep thread context when stashing prompts (#18843)
Co-authored-by: SAPHID <saphid@users.noreply.github.com> Co-authored-by: GPT-6.1 Sol <noreply@openai.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>
Alex Southwell committed
Oct 20, 2026 at 04:14 UTC
4bc6d0b52ecdf602b77dad7c1e687710413aaf6f
1 file changed
+10
-3
apps/web/src/components/chat/ChatComposer.tsx
+10
-3
@@ -3178,6 +3178,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
3178
const importContextRecords = (
3179
records: ReadonlyArray<ComposerContextRecord>,
3180
sourceEnvironmentId: EnvironmentId | null,
3181
+ threadDraftTarget = attachmentDraftTarget,
3182
): ReadonlyMap<string, string> => {
3183
const rewritten = new Map<string, string>();
3184
const dependentAttachmentLocalIds = new Map<string, string>();
@@ -3232,7 +3233,11 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
3233
: existing
3234
? (uploadedContextRecordFromDraft(existing) ?? undefined)
3235
: undefined;
3235
- if (existingRecord && isSameComposerContextPayload(existingRecord, record)) {
3236
+ if (
3237
+ existingRecord &&
3238
+ isSameComposerContextPayload(existingRecord, record) &&
3239
+ (record.kind !== "thread" || threadDraftTarget === attachmentDraftTarget)
3240
+ ) {
3241
if (record.kind === "preview-annotation" && record.screenshotContextId) {
3242
skippedDependentAttachmentIds.add(record.screenshotContextId);
3243
}
@@ -3279,7 +3284,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
3284
case "thread": {
3285
// The agent can only read threads on its own server; a pasted foreign one is dropped.
3286
if (record.environmentId !== environmentId) break;
3282
- addComposerDraftThreadContexts(attachmentDraftTarget, [record], {
3287
+ addComposerDraftThreadContexts(threadDraftTarget, [record], {
3288
appendReference: false,
3289
});
3290
rewritten.set(record.contextId, record.contextId);
@@ -4344,7 +4349,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
4349
}
4350
4351
const rewrittenContextIds = entry.records
4347
- ? importContextRecords(entry.records, null)
4352
+ ? importContextRecords(entry.records, null, composerDraftTarget)
4353
: new Map<string, string>();
4354
const restoredPrompt = replaceComposerContextReferences(entry.prompt, (reference) => {
4355
const contextId = rewrittenContextIds.get(reference.contextId);
@@ -4597,6 +4602,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
4602
const images = [...composerImagesRef.current];
4603
const files = [...composerFilesRef.current];
4604
const stashedRecords: ComposerContextRecord[] = [
4605
+ ...composerThreadContexts,
4606
...composerTerminalContextsRef.current.map(terminalContextRecord),
4607
...composerReviewComments.map(reviewCommentContextRecord),
4608
...composerPreviewAnnotations.map((annotation) =>
@@ -4702,6 +4708,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
4708
promptRef.current = "";
4709
clearComposerDraftPromptAndImages(stashTarget);
4710
clearComposerDraftTerminalContexts(stashTarget);
4711
+ setComposerDraftThreadContexts(stashTarget, []);
4712
for (const comment of composerReviewComments) {
4713
removeComposerDraftReviewComment(stashTarget, comment.id);
4714
}