fix(notes): don't let another agent's row vouch for a launched Kiro, Amp, Command Code or Cursor

Review pass 3: a newer client on an older host trusted a Claude row left on a pane that now runs a launch-owned hook-silent agent. The listing and the client's agent lookup now treat that pane as the launched agent.

Tracked in STA-15222.
This commit is contained in:
Brennan Benson
2026-11-16 01:30:14 -08:00
parent cc9953e24c
commit a15929b63f
2 changed files with 10 additions and 3 deletions
@@ -123,8 +123,11 @@ function deriveTerminalAgentSendTargets(
liveTitleStatus === 'permission'
) {
disabledReason = 'Agent needs permission'
} else if (entry.state !== 'done' && agentHidesApprovalsFromHooks(entry.agentType)) {
// Its hooks report working through an approval menu, which a pasted Enter would answer.
} else if (
(entry.state !== 'done' && agentHidesApprovalsFromHooks(entry.agentType)) ||
(tab.launchAgent !== entry.agentType && agentHidesApprovalsFromHooks(tab.launchAgent))
) {
// Its hooks report working through an approval menu, which a pasted Enter would answer; another agent's row can't vouch for it.
disabledReason = 'Agent may be waiting for approval'
}
@@ -1,9 +1,9 @@
import type { AgentType } from '../../../../../../shared/agent-status/contracts/agent-status-types'
import { resolveTerminalTitleAgentType } from '../../../../../../shared/agent-status/title/terminal-title-agent-type'
import { agentHidesApprovalsFromHooks } from '../../../../../../shared/agent-status/approval/hook-silent-approval-agents'
import { makePaneKey } from '../../../../../../shared/workspace-layout/stable-pane-id'
import type { RuntimeTerminalWait } from '../../../../../../shared/terminal/runtime/runtime-terminal-contracts'
import { runtimeTargetForOwnerEnvironment } from '@/runtime/rpc/targets/runtime-client-target'
import type { RuntimeClientTarget } from '../../../../../../shared/remote-runtime/host-catalog/runtime-client-target'
import { useAppStore } from '@/store/index'
import { callRuntimeRpc } from '@/runtime/rpc/calls/runtime-rpc-call'
import { runtimeEnvironmentIdOrLocalUnlessTwin } from '@/lib/workspace/ownership/worktree-runtime-owner'
@@ -191,6 +191,10 @@ function noteTargetAgentType(
const tab = state.tabsByWorktree[worktreeId]?.find(
(candidate) => candidate.id === noteTarget.tabId
)
// A launch-owned agent whose hooks hide approvals outranks a row another agent left behind.
if (tab?.launchAgent && agentHidesApprovalsFromHooks(tab.launchAgent)) {
return tab.launchAgent
}
return (
row?.agentType ?? tab?.launchAgent ?? (tab ? resolveTerminalTitleAgentType(tab.title) : null)
)