feat: session-first workspace activity and installable daemon

Workspaces page:
- list the newest sessions across workspaces in the activity column; the
  daemon exposes GET /api/v1/sessions/recent as a disk projection and the
  browser enriches live rows from the per-workspace session relay
- put recent activity first below 1100px and fix the mobile page-header
  flex-basis gap

Smoke:
- pin PI2_HOST=127.0.0.1 in both smoke scripts and make the startup-line
  assertion follow the configured host; the daemon default stays 0.0.0.0

Install:
- standalone binary build/install scripts, packaging templates, CI/release
  hooks, CLI-first install docs and the supporting config/doctor changes
This commit is contained in:
yuez committed 2026-10-28 10:53:48 +08:00
1 parent fc51c3be37
commit d2e20d428a
50 files changed
+5104 -188

No files matched your search

+30
View File
@@ -227,6 +227,36 @@ describe("workspace disk discovery", () => {
}
});
it("defaults the root to PI2_CODING_AGENT_DIR/sessions, taking precedence over PI_CODING_AGENT_DIR", () => {
const pi2Agent = join(sandbox, "pi2-agent");
const pi2Sessions = join(pi2Agent, "sessions");
mkdirSync(pi2Sessions, { recursive: true });
writeSessionDir(pi2Sessions, encodedDirName(sandbox), [
{ name: "2026-10-10T06-40-33-032Z_pi2.jsonl", cwd: sandbox, id: "pi2" },
]);
const piAgent = join(sandbox, "pi-agent");
const piSessions = join(piAgent, "sessions");
mkdirSync(piSessions, { recursive: true });
writeSessionDir(piSessions, encodedDirName(sandbox), [
{ name: "2026-10-10T06-40-33-032Z_pi.jsonl", cwd: sandbox, id: "pi" },
]);
const prevPi2 = process.env.PI2_CODING_AGENT_DIR;
const prevPi = process.env.PI_CODING_AGENT_DIR;
process.env.PI2_CODING_AGENT_DIR = pi2Agent;
process.env.PI_CODING_AGENT_DIR = piAgent;
try {
const discovered = createDiscovery().discover();
expect(discovered).toHaveLength(1);
expect(discovered[0]?.dir).toBe(join(pi2Sessions, encodedDirName(sandbox)));
} finally {
if (prevPi2 === undefined) delete process.env.PI2_CODING_AGENT_DIR;
else process.env.PI2_CODING_AGENT_DIR = prevPi2;
if (prevPi === undefined) delete process.env.PI_CODING_AGENT_DIR;
else process.env.PI_CODING_AGENT_DIR = prevPi;
}
});
it("ignores a vanished directory gracefully", () => {
const dir = writeSessionDir(root, encodedDirName(sandbox), [
{ name: "2026-10-10T06-40-33-032Z_a.jsonl", cwd: sandbox, id: "a" },
+51 -4
View File
@@ -53,14 +53,38 @@ describe("workspace store", () => {
for (const dir of [sessions, allowRoot, projectA, projectB, projectGhost]) mkdirSync(dir, { recursive: true });
writeSessionDir(sessions, encodedDirName(projectA), [
{ name: "2026-10-10T06-40-33-032Z_a1.jsonl", cwd: projectA, id: "a1" },
{ name: "2026-10-11T06-40-33-032Z_a2.jsonl", cwd: projectA, id: "a2" },
{
name: "2026-10-10T06-40-33-032Z_a1.jsonl",
cwd: projectA,
id: "a1",
timestamp: "2026-10-10T06:40:33.032Z",
mtime: new Date("2026-10-10T06:40:33.032Z"),
},
{
name: "2026-10-11T06-40-33-032Z_a2.jsonl",
cwd: projectA,
id: "a2",
timestamp: "2026-10-11T06:40:33.032Z",
mtime: new Date("2026-10-11T06:40:33.032Z"),
},
]);
writeSessionDir(sessions, encodedDirName(projectB), [
{ name: "2026-10-12T06-40-33-032Z_b1.jsonl", cwd: projectB, id: "b1" },
{
name: "2026-10-12T06-40-33-032Z_b1.jsonl",
cwd: projectB,
id: "b1",
timestamp: "2026-10-12T06:40:33.032Z",
mtime: new Date("2026-10-12T06:40:33.032Z"),
},
]);
writeSessionDir(sessions, encodedDirName(projectGhost), [
{ name: "2026-10-13T06-40-33-032Z_g1.jsonl", cwd: projectGhost, id: "g1" },
{
name: "2026-10-13T06-40-33-032Z_g1.jsonl",
cwd: projectGhost,
id: "g1",
timestamp: "2026-10-13T06:40:33.032Z",
mtime: new Date("2026-10-13T06:40:33.032Z"),
},
]);
rmSync(projectGhost, { recursive: true, force: true });
});
@@ -116,6 +140,29 @@ describe("workspace store", () => {
expect(ghost).toMatchObject({ exists: false, sessionCount: 1, lastActiveAt: expect.any(Number) });
});
it("lists the newest session files across workspaces for the activity feed", () => {
const { store } = setup();
const rows = store.recentSessions(3);
expect(rows.map((row) => row.sessionId)).toEqual(["g1", "b1", "a2"]);
expect(rows.map((row) => row.workspaceId)).toEqual([
workspaceIdForCwd(projectGhost),
workspaceIdForCwd(projectB),
workspaceIdForCwd(projectA),
]);
expect(rows[0]).toMatchObject({
workspaceName: "ghost",
cwd: projectGhost,
timestamp: Date.parse("2026-10-13T06:40:33.032Z"),
modified: Date.parse("2026-10-13T06:40:33.032Z"),
sessionFile: expect.stringContaining("g1"),
});
// The default (no limit) still returns every discovered session, and an
// out-of-range limit is clamped instead of exploding the header scan.
expect(store.recentSessions()).toHaveLength(4);
expect(store.recentSessions(0)).toHaveLength(4);
});
it("keeps hidden entries in list(); the UI decides ordering", async () => {
const { store } = setup();
const bId = workspaceIdForCwd(projectB);