From d84041c52aa1cccb5493687ec2ce1f507b6eab2c Mon Sep 17 00:00:00 2001 From: Jinwoo-H Date: Mon, 6 Jul 2026 18:48:28 -0400 Subject: [PATCH] test: lock composer agent-detection host precedence for runtime repos (#7082) Regression guard for the runtime-agent-list fix: asserts the composer's detectedAgentList selector and detection effect resolve SSH -> runtime -> local in that order, so a runtime-owned repo shows the paired runtime's agents instead of the local machine's. Co-authored-by: Orca --- ...poserState-host-context-boundaries.test.ts | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/renderer/src/hooks/useComposerState-host-context-boundaries.test.ts b/src/renderer/src/hooks/useComposerState-host-context-boundaries.test.ts index 00aa3fe4f..51b552f34 100644 --- a/src/renderer/src/hooks/useComposerState-host-context-boundaries.test.ts +++ b/src/renderer/src/hooks/useComposerState-host-context-boundaries.test.ts @@ -159,6 +159,40 @@ describe('useComposerState host-context boundaries', () => { expect(submitSection).toContain('runtimeEnvironmentId: folderTargetRuntimeEnvironmentId') }) + it('detects composer agents against the repo host: SSH, then runtime, then local (#7082)', () => { + // Why: a repo owned by a paired runtime must show the runtime's agents, not + // the local machine's. SSH stays first priority; runtime falls through before + // local so an SSH repo never double-detects. Regression guard for #7082. + const selectorSection = sourceBetween( + HOOK_SOURCE, + 'const detectedAgentList = useAppStore', + 'const ensureDetectedAgents = useAppStore' + ) + expect(selectorSection).toContain('if (isRemote) {') + expect(selectorSection).toContain('s.remoteDetectedAgentIds[connectionId]') + expect(selectorSection).toContain('if (runtimeEnvironmentId) {') + expect(selectorSection).toContain('s.runtimeDetectedAgentIds[runtimeEnvironmentId]') + expect(selectorSection).toContain('return s.detectedAgentIds') + // SSH branch is checked before the runtime branch. + expect(selectorSection.indexOf('if (isRemote) {')).toBeLessThan( + selectorSection.indexOf('if (runtimeEnvironmentId) {') + ) + + expect(HOOK_SOURCE).toContain( + 'const runtimeEnvironmentId = selectedRepoSettings?.activeRuntimeEnvironmentId?.trim() || null' + ) + + // Detection effect fans out to the same three hosts in the same order and + // re-runs when the runtime environment changes. + const detectSection = sourceBetween(HOOK_SOURCE, 'const detect = isRemote', 'void detect.then') + expect(detectSection).toContain('ensureRemoteDetectedAgents(connectionId)') + expect(detectSection).toContain('ensureRuntimeDetectedAgents(runtimeEnvironmentId)') + expect(detectSection).toContain('ensureDetectedAgents()') + expect(HOOK_SOURCE).toContain( + '}, [connectionId, runtimeEnvironmentId, isRemote, selectedRepoSshStatus, disabledTuiAgents])' + ) + }) + it('seeds initial workspace run target from the task source context', () => { expect( resolveInitialWorkspaceRunSeed({