From a15929b63fe6ef3f40aed8d28adcfb402374ad2a Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Mon, 16 Nov 2026 01:30:14 -0800 Subject: [PATCH] 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. --- .../lib/agent-session/messaging/running-agent-targets.ts | 7 +++++-- .../messaging/terminal/active-agent-note-send.ts | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/renderer/src/lib/agent-session/messaging/running-agent-targets.ts b/src/renderer/src/lib/agent-session/messaging/running-agent-targets.ts index 1f77a3ed664..d85448da0b2 100644 --- a/src/renderer/src/lib/agent-session/messaging/running-agent-targets.ts +++ b/src/renderer/src/lib/agent-session/messaging/running-agent-targets.ts @@ -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' } diff --git a/src/renderer/src/lib/agent-session/messaging/terminal/active-agent-note-send.ts b/src/renderer/src/lib/agent-session/messaging/terminal/active-agent-note-send.ts index 9a42de06ce3..8fc2a331439 100644 --- a/src/renderer/src/lib/agent-session/messaging/terminal/active-agent-note-send.ts +++ b/src/renderer/src/lib/agent-session/messaging/terminal/active-agent-note-send.ts @@ -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) )