Skip to content

Commit 166ee8b

Browse files
fix(web): drop removed Jira/Figma on queued edit and draft move
Filter kept queued-edit context to prompt-referenced chips, and rebuild the move-source prompt with retained Jira/Figma refs like clear does. Co-authored-by: Cursor <[email protected]>
1 parent c1f819b commit 166ee8b

2 files changed

Lines changed: 20 additions & 9 deletions

File tree

‎apps/web/src/components/chat/useQueuedRunEdit.ts‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import {
3939
releaseDraftAttachments,
4040
startAttachmentUpload,
4141
} from "../../lib/attachmentUploadQueue";
42+
import { collectInlineContextIds } from "../../lib/composerContextReferences";
4243
import { buildMessageContext } from "../../lib/composerContextRecords";
4344
import { readFileAsDataUrl } from "../../lib/imageCompression";
4445
import type { TerminalContextDraft } from "../../lib/terminalContext";
@@ -127,11 +128,16 @@ async function submitQueuedRunEdit(input: {
127128
readImage: readFileAsDataUrl,
128129
uploadFiles,
129130
});
130-
const keptRecords = (editing.context?.records ?? []).filter(
131-
(record) =>
132-
!("attachmentId" in record) ||
133-
editing.existingAttachments.some((attachment) => attachment.id === record.attachmentId),
134-
);
131+
const referencedIds = new Set(collectInlineContextIds(content.prompt));
132+
const keptRecords = (editing.context?.records ?? []).filter((record) => {
133+
if ("attachmentId" in record) {
134+
return editing.existingAttachments.some(
135+
(attachment) => attachment.id === record.attachmentId,
136+
);
137+
}
138+
// Drop chip contexts the edit removed from the prompt (e.g. deleted Jira/Figma).
139+
return referencedIds.has(record.contextId);
140+
});
135141
const newRecords =
136142
buildMessageContext({
137143
terminalContexts: content.terminalContexts.filter(

‎apps/web/src/composerDraftStore.ts‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4372,10 +4372,15 @@ const composerDraftStore = create<ComposerDraftStoreState>()(
43724372
// Moved images still use these blob URLs at the destination; do not revoke them.
43734373
const nextSource: ComposerThreadDraftState = {
43744374
...source,
4375-
prompt: ensureInlineContextReferences(
4376-
"",
4377-
source.terminalContexts.map(terminalContextReference),
4378-
),
4375+
prompt: ensureInlineContextReferences("", [
4376+
...source.terminalContexts.map(terminalContextReference),
4377+
...source.reviewComments.map(reviewCommentContextReference),
4378+
...source.threadContexts.map(threadContextReference),
4379+
...source.environmentContexts.map(environmentContextReference),
4380+
...source.jiraContexts.map(jiraContextReference),
4381+
...source.figmaContexts.map(figmaContextReference),
4382+
...source.previewAnnotations.map(previewAnnotationContextReference),
4383+
]),
43794384
images: retainedImages,
43804385
files: retainedFiles,
43814386
nonPersistedImageIds: source.nonPersistedImageIds.filter(

0 commit comments

Comments
 (0)