fix(workspace): a new session shows in its workspace
This commit is contained in:
@@ -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,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user