File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ import {
3939 releaseDraftAttachments,
4040 startAttachmentUpload,
4141} from "../../lib/attachmentUploadQueue";
42+ import { collectInlineContextIds } from "../../lib/composerContextReferences";
4243import { buildMessageContext } from "../../lib/composerContextRecords";
4344import { readFileAsDataUrl } from "../../lib/imageCompression";
4445import 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(
Original file line number Diff line number Diff 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(
You can’t perform that action at this time.
0 commit comments