Phase 10: restore session state on session_tree for branch switch — SPEC §6.3, §11.
Extract restoreSessionState for reload/resume/startup and reuse on session_tree so /tree branch navigation reloads persisted state or rescans like session_start. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+16
-8
@@ -64,6 +64,17 @@ export default function skillReinject(pi: ExtensionAPI): void {
|
||||
});
|
||||
}
|
||||
|
||||
function restoreSessionState(ctx: ExtensionContext): void {
|
||||
detectAndCachePiAutoCompact(pi, runtime);
|
||||
const settings = readSettings(ctx);
|
||||
const branch = ctx.sessionManager.getBranch();
|
||||
const loaded = loadStateFromBranch(branch);
|
||||
applyExtensionState(state, loaded ?? createInitialState());
|
||||
if (!loaded) {
|
||||
rescanSkillsFromBranch(state, branch, ctx.cwd, registeredSkills, settings.trackReadPaths);
|
||||
}
|
||||
}
|
||||
|
||||
function handleSessionCompact(event: SessionCompactEvent, ctx: ExtensionContext): void {
|
||||
const settings = readSettings(ctx);
|
||||
const shouldReinject = consumeCompactionOnSessionCompact(
|
||||
@@ -99,14 +110,11 @@ export default function skillReinject(pi: ExtensionAPI): void {
|
||||
}
|
||||
|
||||
pi.on("session_start", async (_event, ctx) => {
|
||||
detectAndCachePiAutoCompact(pi, runtime);
|
||||
const settings = readSettings(ctx);
|
||||
const branch = ctx.sessionManager.getBranch();
|
||||
const loaded = loadStateFromBranch(branch);
|
||||
applyExtensionState(state, loaded ?? createInitialState());
|
||||
if (!loaded) {
|
||||
rescanSkillsFromBranch(state, branch, ctx.cwd, registeredSkills, settings.trackReadPaths);
|
||||
}
|
||||
restoreSessionState(ctx);
|
||||
});
|
||||
|
||||
pi.on("session_tree", async (_event, ctx) => {
|
||||
restoreSessionState(ctx);
|
||||
});
|
||||
|
||||
pi.on("session_before_compact", async () => {
|
||||
|
||||
Reference in New Issue
Block a user