@@ -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");
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user