feat: Claude Code Monitor — lanes, pipelines and a merged workspace

Internal SmartGift build of a Claude Code monitoring dashboard.

Lanes: a durable unit of parallel agent work, one per working directory,
tracked across session restarts. Managed lanes are git worktrees the
dashboard provisions and can reset or remove behind a three-check destroy
guard and a counted preflight; adopted lanes are directories you already
own and are never destroyable.

Pipelines: a lane moves through pipeline stages. A stage the agent declares
with evidence renders green; a stage inferred from the tool-event stream
renders dashed amber and never counts as done. Detection is forward-only
within a 30-minute window, and never writes the declared stage.

Workspace: one page at /run with a lane grid, the selected lane's pipeline,
and a full Claude console behind a disclosure.
This commit is contained in:
2026-07-29 17:07:45 +07:00
commit 57dc91585d
783 changed files with 221743 additions and 0 deletions
@@ -0,0 +1,53 @@
/**
* @file Pins the URL and method `api.lanes.git` hits. The card renders whatever
* this returns, so a wrong path would surface as a permanently missing git row
* rather than as a visible failure — worth a test even though it is one line.
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
*/
import { describe, it, expect, vi, afterEach } from "vitest";
import { api } from "../api";
afterEach(() => {
vi.unstubAllGlobals();
});
function stubFetch(body: unknown) {
const spy = vi.fn().mockResolvedValue({
ok: true,
status: 200,
headers: { get: () => "application/json" },
json: async () => body,
text: async () => JSON.stringify(body),
});
vi.stubGlobal("fetch", spy);
return spy;
}
describe("api.lanes.git", () => {
it("requests /api/lanes/<id>/git and returns the parsed facts", async () => {
const facts = {
available: true,
branch: "feat/x",
head: "abc1234",
subject: "do a thing",
dirty: 2,
untracked: 1,
};
const spy = stubFetch(facts);
const result = await api.lanes.git(3);
expect(spy).toHaveBeenCalledTimes(1);
const call = spy.mock.calls[0] as [string, RequestInit | undefined];
// endsWith, not toContain: `/gitt` contains `/git` and would slip through.
expect(String(call[0]).endsWith("/api/lanes/3/git")).toBe(true);
expect(call[1]?.method ?? "GET").toBe("GET");
expect(result).toEqual(facts);
});
it("passes an available:false body straight through", async () => {
stubFetch({ available: false });
expect(await api.lanes.git(9)).toEqual({ available: false });
});
});