import {
type AppMode,
type DaemonInteractiveSessionManagerDecision,
daemonServerDefaultSessionConfig,
findActiveDaemonSessionSummaryForInteractiveStartup,
findActiveDaemonSessionSummaryForSessionFile,
type InteractiveDaemonStartupDecision,
isClientOwnedDaemonSession,
parseAgentsViewCommand,
215 unmodified lines
Expand all
}),
).toBe(false);
});
test("falls back to local session lookup when daemon active-session probing fails", async () => {
await expect(
findActiveDaemonSessionSummaryForInteractiveStartup("/tmp/prime.sock", "saved-session-id", {
lookup: async () => {
throw new Error("Daemon returned an invalid active session summary");
},
}),
).resolves.toBeUndefined();
});
test("propagates active-session lookup failures for explicit attach", async () => {
await expect(
findActiveDaemonSessionSummaryForInteractiveStartup("/tmp/prime.sock", "active-1", {
fallbackOnError: false,
lookup: async () => {
throw new Error("protocol mismatch");
},
}),
).rejects.toThrow("protocol mismatch");
});
test("uses daemon active-session summary when probing succeeds", async () => {
await expect(
findActiveDaemonSessionSummaryForInteractiveStartup("/tmp/prime.sock", "active-1", {
lookup: async () => ({
id: "active-1",
activeSessionId: "active-1",
lifecycle: "draft",
activity: "idle",
isSessionActive: false,
sessionId: "session-1",
cwd: "/tmp/project",
isStreaming: false,
isCompacting: false,
attachedClients: 0,
messageCount: 0,
sessionActions: { queuedCount: 0, steering: [], followUps: [] },
}),
}),
).resolves.toMatchObject({ activeSessionId: "active-1" });
});
test("uses an ephemeral local session manager for fresh daemon-owned sessions", () => {
expect(shouldUseEphemeralSessionManagerForDaemonInteractive({})).toBe(true);
});
217 unmodified lines
Expand all