march-cli 0.1.38 → 0.1.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import { join } from "node:path";
2
- import { loadPiSessionSidecar } from "../session/sidecar.mjs";
2
+ import { loadMarchSessionStateForPiBackend } from "../session/state/march-session-state.mjs";
3
3
 
4
4
  export function createWorkspaceSessionSupervisor({ initialRuntime, createProjectRuntime, viewSessionState = initialRuntime?.sessionState, onActivate = null }) {
5
5
  if (!initialRuntime?.project?.projectId) throw new Error("initial workspace runtime is missing project metadata");
@@ -85,7 +85,7 @@ export function createWorkspaceSessionSupervisor({ initialRuntime, createProject
85
85
  if (!result?.cancelled && result?.sessionId) syncSessionState(active, result.sessionId);
86
86
  rememberRuntime(active);
87
87
  mirrorSessionState(viewSessionState, active.sessionState);
88
- onActivate?.({ projectId: active.project.projectId, sessionId: getRuntimeSessionId(active), runtime: active });
88
+ onActivate?.({ projectId: active.project.projectId, sessionId: getRuntimeSessionId(active), runtime: active, restoreState: null });
89
89
  return { runtime: active, result };
90
90
  }
91
91
 
@@ -96,8 +96,9 @@ export function createWorkspaceSessionSupervisor({ initialRuntime, createProject
96
96
  let runtime = session?.id ? runtimes.get(runtimeKey(project.projectId, session.id)) : findIdleRuntime(project.projectId);
97
97
  if (!runtime) runtime = await createProjectRuntime(project);
98
98
 
99
+ let restoreState = null;
99
100
  if (session?.path && getRuntimeSessionId(runtime) !== session.id) {
100
- const restoreState = loadWorkspacePiSessionState({ runtime, session });
101
+ restoreState = loadWorkspaceMarchSessionState({ runtime, session });
101
102
  await runtime.runner.switchPiSession(session.path, restoreState);
102
103
  syncSessionState(runtime, session.id);
103
104
  }
@@ -105,7 +106,7 @@ export function createWorkspaceSessionSupervisor({ initialRuntime, createProject
105
106
  active = runtime;
106
107
  rememberRuntime(runtime);
107
108
  mirrorSessionState(viewSessionState, runtime.sessionState);
108
- onActivate?.({ projectId: runtime.project.projectId, sessionId: getRuntimeSessionId(runtime), runtime });
109
+ onActivate?.({ projectId: runtime.project.projectId, sessionId: getRuntimeSessionId(runtime), runtime, restoreState });
109
110
  return active;
110
111
  }
111
112
 
@@ -142,13 +143,18 @@ export function createWorkspaceSessionSupervisor({ initialRuntime, createProject
142
143
  }
143
144
  }
144
145
 
145
- function loadWorkspacePiSessionState({ runtime, session }) {
146
- const sidecar = loadPiSessionSidecar({ projectMarchDir: runtime.projectMarchDir, sessionRef: session.path });
147
- if (!sidecar) throw new Error(`pi session sidecar not found for ${session.id}; refusing partial resume`);
148
- if (sidecar.state.cwd && sidecar.state.cwd !== runtime.runner.engine.cwd) {
149
- throw new Error(`pi session sidecar cwd mismatch for ${session.id}: ${sidecar.state.cwd}`);
146
+ function loadWorkspaceMarchSessionState({ runtime, session }) {
147
+ const stored = loadMarchSessionStateForPiBackend({
148
+ projectMarchDir: runtime.projectMarchDir,
149
+ sessionId: session.id,
150
+ sessionRef: session.path,
151
+ });
152
+ if (!stored) throw new Error(`March session state not found for ${session.id}; refusing partial resume`);
153
+ if (stored.state.cwd && stored.state.cwd !== runtime.runner.engine.cwd) {
154
+ throw new Error(`March session state cwd mismatch for ${session.id}: ${stored.state.cwd}`);
150
155
  }
151
- return { ...sidecar.state };
156
+ const { renderTimeline: _renderTimeline, ...contextState } = stored.state;
157
+ return contextState;
152
158
  }
153
159
 
154
160
  function getRuntimeSessionId(runtime) {
@@ -1,10 +0,0 @@
1
- export async function createSidecarWriteFailure({ runtimeHost, sourceSessionFile, action, cause }) {
2
- const causeMessage = cause?.message ?? String(cause);
3
- const baseMessage = `failed to write pi session sidecar after ${action}: ${causeMessage}`;
4
- try {
5
- await runtimeHost.switchSession(sourceSessionFile);
6
- return new Error(`${baseMessage}; rolled back to source session`);
7
- } catch (rollbackErr) {
8
- return new Error(`${baseMessage}; rollback failed: ${rollbackErr.message}`);
9
- }
10
- }
@@ -1 +0,0 @@
1
- // Legacy session switch command removed. Use /session to restore previous pi sessions.
@@ -1 +0,0 @@
1
- // Legacy session persistence removed. All sessions use pi JSONL format.