fix(coding-agent): handle stale extension contexts

fixes #3606
This commit is contained in:
Mario Zechner
2026-04-23 22:06:55 +02:00
parent 0cb8ff3843
commit f0cf8a59d2
9 changed files with 77 additions and 17 deletions

View File

@@ -135,19 +135,20 @@ export default function (pi: ExtensionAPI) {
return;
}
// Create new session with parent tracking
// Create new session with parent tracking. Use the replacement-session
// context for post-switch UI work; the original ctx is stale after a
// successful session replacement.
const newSessionResult = await ctx.newSession({
parentSession: currentSessionFile,
withSession: async (replacementCtx) => {
replacementCtx.ui.setEditorText(editedPrompt);
replacementCtx.ui.notify("Handoff ready. Submit when ready.", "info");
},
});
if (newSessionResult.cancelled) {
ctx.ui.notify("New session cancelled", "info");
return;
}
// Set the edited prompt in the main editor for submission
ctx.ui.setEditorText(editedPrompt);
ctx.ui.notify("Handoff ready. Submit when ready.", "info");
},
});
}