refactor(workspaces): keep reseed helper outside caller census

This commit is contained in:
Merge Sim
2026-09-11 21:07:08 -07:00
parent 54bca206d4
commit 2504cdd3d8
2 changed files with 14 additions and 6 deletions
@@ -3,7 +3,6 @@ import {
gateWorktreeAgentActivation,
type WorktreeAgentActivationOutcome
} from './worktree-agent-activation-gate'
import type { WorktreeActivationSurfaceSelection } from './worktree-activation-surface-selection'
import { reseedGatedEmptyWorkspace } from './worktree-initial-terminal-seeding'
type GatedEmptyWorkspaceReseedIntent = {
@@ -18,12 +17,13 @@ const latestReseedIntentByGate = new WeakMap<
export function gateAndReseedEmptyWorkspace(
workspaceKey: string,
selection?: WorktreeActivationSurfaceSelection & { executionHostId?: ExecutionHostId }
callerProvidesSurface: boolean,
executionHostId?: ExecutionHostId
): void {
const gate = gateWorktreeAgentActivation(workspaceKey)
const intent: GatedEmptyWorkspaceReseedIntent = {
callerProvidesSurface: selection?.providesInitialSurface === true,
...(selection?.executionHostId ? { executionHostId: selection.executionHostId } : {})
callerProvidesSurface,
...(executionHostId ? { executionHostId } : {})
}
latestReseedIntentByGate.set(gate, intent)
void gate.then((outcome) => {
+10 -2
View File
@@ -143,7 +143,11 @@ export function activateAndRevealFolderWorkspace(
resumeSleepingAgentSessionsForWorktree(workspaceKey)
}
if (shouldGateAgentActivation) {
gateAndReseedEmptyWorkspace(workspaceKey, opts)
gateAndReseedEmptyWorkspace(
workspaceKey,
opts?.providesInitialSurface === true,
opts?.executionHostId
)
}
const primaryTabId = shouldGateAgentActivation
? null
@@ -238,7 +242,11 @@ export function activateAndRevealWorktree(
resumeSleepingAgentSessionsForWorktree(worktreeId)
}
if (shouldGateAgentActivation) {
gateAndReseedEmptyWorkspace(worktreeId, opts)
gateAndReseedEmptyWorkspace(
worktreeId,
opts?.providesInitialSurface === true,
opts?.executionHostId
)
}
// 4. Ensure a focusable surface exists for externally-created worktrees