feat(lanes): record which CLI tool drives a lane
This commit is contained in:
@@ -25,11 +25,11 @@ const insertStmt = db.prepare(`
|
||||
INSERT OR REPLACE INTO dashboard_runs (
|
||||
id, session_id, mode, cwd, model, permission_mode, effort,
|
||||
resume_session_id, prompt_preview, status, exit_code, started_at, ended_at,
|
||||
lane_id
|
||||
lane_id, tool
|
||||
) VALUES (
|
||||
@id, @session_id, @mode, @cwd, @model, @permission_mode, @effort,
|
||||
@resume_session_id, @prompt_preview, @status, @exit_code, @started_at, @ended_at,
|
||||
@lane_id
|
||||
@lane_id, @tool
|
||||
)
|
||||
`);
|
||||
|
||||
@@ -44,7 +44,7 @@ const updateStmt = db.prepare(`
|
||||
|
||||
const RUN_COLUMNS = `id, session_id, mode, cwd, model, permission_mode, effort,
|
||||
resume_session_id, prompt_preview, status, exit_code,
|
||||
started_at, ended_at, lane_id`;
|
||||
started_at, ended_at, lane_id, tool`;
|
||||
|
||||
const listStmt = db.prepare(`
|
||||
SELECT ${RUN_COLUMNS}
|
||||
@@ -89,6 +89,7 @@ function recordRun(handle) {
|
||||
started_at: startedAt,
|
||||
ended_at: endedAt,
|
||||
lane_id: typeof handle.laneId === "number" ? handle.laneId : null,
|
||||
tool: handle.tool === "codex" ? "codex" : "claude",
|
||||
});
|
||||
} catch {
|
||||
/* persistence is best-effort */
|
||||
|
||||
+13
-1
@@ -95,6 +95,14 @@ function validateKind(kind) {
|
||||
}
|
||||
}
|
||||
|
||||
const VALID_TOOLS = new Set(["claude", "codex"]);
|
||||
|
||||
function validateTool(tool) {
|
||||
if (!VALID_TOOLS.has(tool)) {
|
||||
throw Object.assign(new Error(`unknown tool: ${tool}`), { code: "EBADTOOL" });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* `getPipeline` falls back to the default template for an unknown id — correct
|
||||
* when READING (a lane must always render something), wrong when WRITING: a
|
||||
@@ -139,15 +147,17 @@ function createLane({
|
||||
source_repo = null,
|
||||
base_branch = null,
|
||||
slug = null,
|
||||
tool = "claude",
|
||||
} = {}) {
|
||||
if (!cwd || typeof cwd !== "string" || !cwd.startsWith("/")) {
|
||||
throw Object.assign(new Error("cwd must be an absolute path"), { code: "EBADCWD" });
|
||||
}
|
||||
validateKind(kind);
|
||||
validatePipeline(pipeline);
|
||||
validateTool(tool);
|
||||
const info = db
|
||||
.prepare(
|
||||
"INSERT INTO lanes (title, cwd, branch, pipeline, kind, source_repo, base_branch, slug, stage_since) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"
|
||||
"INSERT INTO lanes (title, cwd, branch, pipeline, kind, source_repo, base_branch, slug, tool, stage_since) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
|
||||
)
|
||||
.run(
|
||||
title,
|
||||
@@ -158,6 +168,7 @@ function createLane({
|
||||
source_repo,
|
||||
base_branch,
|
||||
slug,
|
||||
tool,
|
||||
nowIso()
|
||||
);
|
||||
return getLane(info.lastInsertRowid);
|
||||
@@ -599,6 +610,7 @@ function purgeLaneSessions(laneId) {
|
||||
|
||||
module.exports = {
|
||||
DEAD_SEC,
|
||||
VALID_TOOLS,
|
||||
createLane,
|
||||
listLanes,
|
||||
getLane,
|
||||
|
||||
Reference in New Issue
Block a user