fix(workspace): a new session shows in its workspace

This commit is contained in:
2026-10-02 16:18:00 +07:00
parent f35bf2043f
commit da1b17778c
6 changed files with 118 additions and 8 deletions
+24 -1
View File
@@ -181,6 +181,21 @@ function routerForSession(sessionId) {
}
}
const sessionLaneStmt = db.prepare(`
SELECT lane_id FROM dashboard_runs
WHERE session_id = @sessionId AND lane_id IS NOT NULL
ORDER BY started_at DESC LIMIT 1
`);
/** The lane of the newest run that holds `sessionId`, or null. */
function laneForSession(sessionId) {
try {
return sessionLaneStmt.get({ sessionId })?.lane_id ?? null;
} catch {
return null;
}
}
const runningStmt = db.prepare(
"SELECT id FROM dashboard_runs WHERE status IN ('running', 'spawning')"
);
@@ -212,4 +227,12 @@ function reconcileOrphans(isAlive = () => false) {
}
}
module.exports = { recordRun, patchRun, listRuns, getRun, reconcileOrphans, routerForSession };
module.exports = {
recordRun,
patchRun,
listRuns,
getRun,
reconcileOrphans,
routerForSession,
laneForSession,
};