@devries-cameron20 / t3code Mirror · read-only / commits / ceed427d79
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 02:00 UTC

fix(web): removing a queued message's attachment counts as an edit when its run starts (#29601)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <maria@kuuro.net>

Alex Southwell committed Nov 10, 2026 at 01:31 UTC ceed427d792c72b9c682e341c29ed17a8737680a
3 files changed +37 -3
apps/web/src/components/chat/queuedMessageEdit.test.ts
+25
@@ -86,6 +86,31 @@ describe("queued message file edits", () => {
86 expect(store.getComposerDraft(editTarget)).toBeNull();
87 });
88
89 + it("reports a removed queued attachment as an edit when the run leaves", () => {
90 + const store = useComposerDraftStore.getState();
91 + store.setPrompt(editTarget, "Original message");
92 + expect(
93 + recoverQueuedMessageEdit({
94 + editTarget,
95 + threadTarget,
96 + originalText: "Original message",
97 + removedExistingAttachment: true,
98 + }),
99 + ).toBe("kept");
100 + expect(store.getComposerDraft(threadTarget)?.prompt).toBe("Original message");
101 + store.clearComposerContent(threadTarget);
102 + // An attachment-only message leaves nothing to put back in the composer.
103 + expect(
104 + recoverQueuedMessageEdit({
105 + editTarget,
106 + threadTarget,
107 + originalText: "",
108 + removedExistingAttachment: true,
109 + }),
110 + ).toBe("discarded");
111 + expect(store.getComposerDraft(threadTarget)).toBeNull();
112 + });
113 +
114 it("does not overwrite a separate draft when the queued run leaves", () => {
115 const store = useComposerDraftStore.getState();
116 store.setPrompt(threadTarget, "Separate draft");
apps/web/src/components/chat/queuedMessageEdit.ts
+8 -3
@@ -12,14 +12,19 @@ export function recoverQueuedMessageEdit(input: {
12 readonly editTarget: ComposerThreadTarget;
13 readonly threadTarget: ComposerThreadTarget;
14 readonly originalText: string;
15 + readonly removedExistingAttachment?: boolean;
16 }): "kept" | "discarded" | "clean" {
17 const store = useComposerDraftStore.getState();
18 const draft = store.getComposerDraft(input.editTarget);
19 const recovery = resolveQueuedEditExit({
20 editChanged:
20 - draft !== null &&
21 - (draft.prompt !== input.originalText || draft.images.length > 0 || draft.files.length > 0),
22 - threadDraftEmpty: !composerDraftHasUserContent(store.getComposerDraft(input.threadTarget)),
21 + input.removedExistingAttachment === true ||
22 + (draft !== null &&
23 + (draft.prompt !== input.originalText || draft.images.length > 0 || draft.files.length > 0)),
24 + // A cleared edit has nothing to put back, so it can only be discarded.
25 + threadDraftEmpty:
26 + composerDraftHasUserContent(draft) &&
27 + !composerDraftHasUserContent(store.getComposerDraft(input.threadTarget)),
28 });
29 if (recovery === "kept") {
30 store.moveComposerPromptAndImages(input.editTarget, input.threadTarget);
apps/web/src/components/chat/useQueuedRunEdit.ts
+4
@@ -64,6 +64,8 @@ interface EditingQueuedRun {
64 readonly originalText: string;
65 readonly existingAttachments: ReadonlyArray<ChatAttachment>;
66 readonly context?: OrchestrationMessageContext | undefined;
67 + /** Removing a server attachment changes the message even when the draft looks untouched. */
68 + readonly removedExistingAttachment?: true;
69 }
70
71 // Keyed by the route thread, so an edit survives navigating away and back.
@@ -265,6 +267,7 @@ export function useQueuedRunEdit(input: {
267 editTarget: queuedEditDraftTarget(routeThreadRef, edit.runId),
268 threadTarget: threadDraftTarget,
269 originalText: edit.originalText,
270 + removedExistingAttachment: edit.removedExistingAttachment === true,
271 });
272 if (recovery === "clean") return;
273 const title = appAtomRegistry.get(
@@ -295,6 +298,7 @@ export function useQueuedRunEdit(input: {
298 const removeEditingAttachment = useStableCallback((attachmentId: string) => {
299 queuedRunEdits.update(editKey, (current) => ({
300 ...current,
301 + removedExistingAttachment: true,
302 existingAttachments: current.existingAttachments.filter(
303 (attachment) => attachment.id !== attachmentId,
304 ),