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

@@ -992,14 +992,19 @@ Options:
Fork from a specific entry, creating a new session file:
```typescript
const result = await ctx.fork("entry-id-123");
if (!result.cancelled) {
// Now in the forked session
const result = await ctx.fork("entry-id-123", {
withSession: async (ctx) => {
// Use only the replacement-session ctx here.
ctx.ui.notify("Now in the forked session", "info");
},
});
if (result.cancelled) {
// An extension cancelled the fork
}
const cloneResult = await ctx.fork("entry-id-456", { position: "at" });
if (!cloneResult.cancelled) {
// New session contains the active path through entry-id-456
if (cloneResult.cancelled) {
// An extension cancelled the clone
}
```
@@ -1060,7 +1065,11 @@ pi.registerCommand("switch", {
sessions.map(s => s.file),
);
if (choice) {
await ctx.switchSession(choice);
await ctx.switchSession(choice, {
withSession: async (ctx) => {
ctx.ui.notify("Switched session", "info");
},
});
}
},
});