fix: finalize late closed-pane attachments

This commit is contained in:
Shakker
2026-08-10 13:01:47 +02:00
parent 6eded1bbce
commit c31ccaafa4
2 changed files with 16 additions and 7 deletions
@@ -107,9 +107,12 @@ describe("staged chat attachment pane handoff", () => {
);
closePaneStagedAttachments(pane.context, root, layout, pane.paneId);
const lateAttachment = storedAttachment("late-close-completion");
current.chatAttachments.push(lateAttachment);
pane.disconnectedCallback();
expect(getChatAttachmentDataUrl(fallback)).toBeNull();
expect(getChatAttachmentDataUrl(lateAttachment)).toBeNull();
expect(
pane.context.chatAttachmentHandoff.consume({
owner,
+13 -7
View File
@@ -670,13 +670,19 @@ export abstract class ChatPaneLifecycle extends ChatPaneBoard {
}
override disconnectedCallback() {
if (this.state && !this.suppressStagedAttachmentHandoffOnDisconnect) {
preparePaneStagedAttachments(
this.context,
this.paneId,
this.state,
this.stagedAttachmentGatewayOwner,
);
if (this.state) {
if (this.suppressStagedAttachmentHandoffOnDisconnect) {
// MCP app teardown can delay DOM removal after pane close. Finalize any
// attachment that completed during that delay instead of leaking it.
discardStateStagedAttachments(this.state);
} else {
preparePaneStagedAttachments(
this.context,
this.paneId,
this.state,
this.stagedAttachmentGatewayOwner,
);
}
}
this.stagedAttachmentGatewayOwner = null;
this.clearComposerPrefillAttention();