From 77c3de151dc63c2d5e5709a5e3d1d88c27fd5ada Mon Sep 17 00:00:00 2001 From: brennanb2025 Date: Thu, 9 Jul 2026 20:51:52 -0700 Subject: [PATCH] fix(test): seed runtime host id for remote-reopen guard test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The prior test set settings.activeRuntimeEnvironmentId by spreading the store's settings, which widened workspaceDir to string|undefined and broke `pnpm typecheck` (GlobalSettings requires string). Seed the worktree with a `runtime:` hostId instead — getRuntimeEnvironmentIdForWorktree reads it directly, so no settings spread is needed. --- .../store/slices/recently-closed-tabs.test.ts | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/renderer/src/store/slices/recently-closed-tabs.test.ts b/src/renderer/src/store/slices/recently-closed-tabs.test.ts index 7e56ad54a74..ac8352b57c4 100644 --- a/src/renderer/src/store/slices/recently-closed-tabs.test.ts +++ b/src/renderer/src/store/slices/recently-closed-tabs.test.ts @@ -133,17 +133,21 @@ describe('reopenClosedTerminalTab', () => { }) it('skips local reopen on a remote-runtime worktree (host owns the terminal)', () => { - const store = makeSeededStore() - const tab = store - .getState() - .createTab(WT, undefined, undefined, { startupCwd: '/path/wt1/api' }) - store.getState().closeTab(tab.id) - expect(store.getState().recentlyClosedTerminalTabsByWorktree[WT]).toHaveLength(1) - - // Why: an active runtime environment makes the worktree host-owned; a local - // createTab would leave an unbacked phantom tab, so reopen must bail. + // Why: a `runtime:` host id makes the worktree host-owned; a local createTab + // would leave an unbacked phantom tab, so reopen must bail and let the + // cross-type dispatcher fall through to browser/editor. + const store = createTestStore() + seedStore(store, { + worktreesByRepo: { + repo1: [ + makeWorktree({ id: WT, repoId: 'repo1', path: '/path/wt1', hostId: 'runtime:env-1' }) + ] + }, + activeWorktreeId: WT + }) store.setState({ - settings: { ...store.getState().settings, activeRuntimeEnvironmentId: 'runtime-env-1' } + recentlyClosedTerminalTabsByWorktree: { [WT]: [{ startupCwd: '/path/wt1/api' }] }, + recentlyClosedTabKindsByWorktree: { [WT]: ['terminal'] } }) expect(store.getState().reopenClosedTerminalTab(WT)).toBe(false)