Combine pending PR #18886 for deflake CI validation

This commit is contained in:
Neil
2026-09-05 19:03:31 -07:00
5 changed files with 63 additions and 27 deletions
@@ -26,6 +26,27 @@ function seedClosedLastTerminal(worktreeId: string): void {
}
describe('activating a workspace whose last terminal was closed', () => {
it('re-seeds after the asynchronous agent inventory confirms the workspace is empty', async () => {
const worktree = makeWorktree()
seedEmptyActivatableWorktree(worktree)
seedClosedLastTerminal(worktree.id)
useAppStore.setState({
workspaceSessionReady: true,
terminalStartupRestorationReady: true
})
vi.stubGlobal('window', {
api: {
runtime: { call: vi.fn(async () => ({ ok: true, result: { snapshots: [] } })) },
pty: { listSessions: vi.fn(async () => []) }
}
})
activateAndRevealWorktree(worktree.id, { notifyHostRuntime: false })
await waitForWorktreeAgentActivationGateForTests(worktree.id)
expect(useAppStore.getState().tabsByWorktree[worktree.id]).toHaveLength(1)
})
it('re-seeds a terminal when the workspace is opened from elsewhere', () => {
const worktree = makeWorktree()
seedEmptyActivatableWorktree(worktree)
@@ -23,7 +23,10 @@ const SURFACE_PROVIDING_CALLERS = [
]
// The activation seam itself: declares the option and forwards it into the tombstone gate.
const SEAM_FILES = ['src/renderer/src/lib/worktree-activation.ts']
const SEAM_FILES = [
'src/renderer/src/lib/worktree-activation.ts',
'src/renderer/src/lib/worktree-initial-terminal-seeding.ts'
]
function listSourceFiles(dir: string): string[] {
return readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {
+13 -25
View File
@@ -1,4 +1,3 @@
import type { FolderWorkspace } from '../../../shared/folder-workspace-types'
import type {
WorktreeDefaultTabsLaunch,
WorktreeSetupLaunch
@@ -30,7 +29,10 @@ import type { ExecutionHostId } from '../../../shared/execution-host'
import { findFolderWorkspaceOwner } from './folder-workspace-runtime-owner'
import type { WorktreeStartupPayload } from '@/lib/worktree-startup-payload'
import type { IssueCommandLaunch } from '@/lib/worktree-setup-issue-command-queue'
import { ensureWorktreeHasInitialTerminal } from '@/lib/worktree-initial-terminal-seeding'
import {
ensureFolderWorkspaceInitialTerminal,
ensureWorktreeHasInitialTerminal
} from '@/lib/worktree-initial-terminal-seeding'
import { ensureWebRuntimeWorktreeTerminalAfterWake } from '@/lib/web-runtime-worktree-terminal-after-wake'
import { applyWorktreeNavViewEntry } from '@/lib/worktree-nav-view-history-replay'
@@ -45,28 +47,6 @@ export type ActivateAndRevealResult = {
primaryTabId: string | null
}
function ensureFolderWorkspaceInitialTerminal(
folderWorkspace: FolderWorkspace,
startup?: WorktreeStartupPayload,
providesInitialSurface?: boolean
): string | null {
if (providesInitialSurface === true && startup === undefined) {
return null
}
const state = useAppStore.getState()
const workspaceKey = folderWorkspaceKey(folderWorkspace.id)
const primaryTabId = ensureWorktreeHasInitialTerminal(
state,
workspaceKey,
startup,
undefined,
undefined,
undefined,
{ reseedEmptiedWorkspace: providesInitialSurface !== true }
)
return primaryTabId
}
function canInspectAgentActivationInventory(): boolean {
return (
typeof window !== 'undefined' &&
@@ -270,7 +250,15 @@ export function activateAndRevealWorktree(
opts?.providesInitialSurface !== true &&
currentState.activeWorktreeId === worktreeId
) {
ensureWorktreeHasInitialTerminal(currentState, worktreeId)
ensureWorktreeHasInitialTerminal(
currentState,
worktreeId,
undefined,
undefined,
undefined,
undefined,
{ reseedEmptiedWorkspace: true }
)
}
})
}
@@ -1,3 +1,5 @@
import type { FolderWorkspace } from '../../../shared/folder-workspace-types'
import { folderWorkspaceKey } from '../../../shared/workspace-scope'
import type {
WorktreeDefaultTabsLaunch,
WorktreeSetupLaunch
@@ -214,3 +216,25 @@ export function ensureWorktreeHasInitialTerminal(
return terminalTab.id
}
export function ensureFolderWorkspaceInitialTerminal(
folderWorkspace: FolderWorkspace,
startup?: WorktreeStartupPayload,
providesInitialSurface?: boolean
): string | null {
if (providesInitialSurface === true && startup === undefined) {
return null
}
const state = useAppStore.getState()
const workspaceKey = folderWorkspaceKey(folderWorkspace.id)
const primaryTabId = ensureWorktreeHasInitialTerminal(
state,
workspaceKey,
startup,
undefined,
undefined,
undefined,
{ reseedEmptiedWorkspace: providesInitialSurface !== true }
)
return primaryTabId
}
@@ -269,7 +269,7 @@ for (const closeMode of ['terminal-close-cli', 'worker-release'] as const) {
const expectedRecovery = {
origin: 'live',
state: 'working',
state: 'done',
providerSessionId: PROVIDER_SESSION_ID
}
await expect