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
+10 -1
View File
@@ -1310,10 +1310,19 @@ const HOOK_TOOLS = { codex: codexHookInput, antigravity: antigravityHookInput };
* The session the pane holds is also stamped with the pane's lane
* (`sessions.lane_id`, first writer wins) — that is what makes it the
* workspace's own session rather than one that merely ran in the same folder.
* A new Claude pane is started with `--session-id` (pty-run.js), so its run
* names the session before any hook: a hook without `run_id` is stamped from
* that run instead.
*/
function bindRunSession(runId, sessionId, hookType, source, tool) {
if (typeof runId !== "string" || !/^agenthub-lane-\d+(-[1-3])?$/.test(runId)) return;
if (typeof sessionId !== "string" || !sessionId) return;
if (typeof runId !== "string" || !/^agenthub-lane-\d+(-[1-3])?$/.test(runId)) {
// No pane named (a hook handler that predates AGENTHUB_RUN_ID): a run
// that was started holding this very session id still owns it.
const laneId = dashboardRuns.laneForSession(sessionId);
if (laneId != null) stmts.claimSessionLane.run(laneId, sessionId);
return;
}
const row = dashboardRuns.getRun(runId);
if (!row) return;
if (row.session_id !== sessionId) {