fix(workspace): a new session shows in its workspace
This commit is contained in:
@@ -107,6 +107,7 @@ function buildClaudeArgv({
|
||||
effort,
|
||||
resumeSessionId,
|
||||
forkSession = false,
|
||||
newSessionId = null,
|
||||
worktreeName = null,
|
||||
initialPrompt,
|
||||
addDirs = [],
|
||||
@@ -139,6 +140,7 @@ function buildClaudeArgv({
|
||||
if (model) argv.push("--model", model);
|
||||
if (effort && EFFORT_LEVELS.has(effort)) argv.push("--effort", effort);
|
||||
if (resumeSessionId) argv.push("--resume", resumeSessionId);
|
||||
else if (newSessionId) argv.push("--session-id", newSessionId);
|
||||
// A fork resumes the history into a NEW session id; the original is left as
|
||||
// it was.
|
||||
if (resumeSessionId && forkSession) argv.push("--fork-session");
|
||||
@@ -357,6 +359,11 @@ function spawnRun(args) {
|
||||
tool
|
||||
);
|
||||
const routerSpawn = routerForSpawn(tool, routerProfile);
|
||||
// A new Claude session gets its id from us, so the run knows the session it
|
||||
// holds from the start — a hook that lost AGENTHUB_RUN_ID (an older hook
|
||||
// handler) still finds its pane by it (routes/hooks.js → bindRunSession).
|
||||
const newSessionId =
|
||||
entry.launcher === "claude" && !resumeSessionId ? require("crypto").randomUUID() : null;
|
||||
const argv = buildArgv(
|
||||
{
|
||||
addDirs,
|
||||
@@ -370,6 +377,7 @@ function spawnRun(args) {
|
||||
approval,
|
||||
resumeSessionId,
|
||||
forkSession: forkSession === true,
|
||||
newSessionId,
|
||||
worktreeName: worktree === true ? `ah-${laneId}-${Date.now().toString(36)}` : null,
|
||||
resumeLast,
|
||||
bypass: bypass === true,
|
||||
@@ -385,7 +393,7 @@ function spawnRun(args) {
|
||||
dashboardRuns.recordRun({
|
||||
id,
|
||||
// A fork's own id arrives with its first hook (bindRunSession).
|
||||
sessionId: (forkSession !== true && resumeSessionId) || null,
|
||||
sessionId: newSessionId || (forkSession !== true && resumeSessionId) || null,
|
||||
// `dashboard_runs.mode` is NOT NULL. Passing null made every insert throw
|
||||
// inside recordRun's best-effort catch, so no tmux-backed run was ever
|
||||
// persisted: publicRun then read its cwd/model/prompt/startedAt off a row
|
||||
|
||||
Reference in New Issue
Block a user