diff --git a/config/scripts/ci/sharding/ci-shard-timings.json b/config/scripts/ci/sharding/ci-shard-timings.json
index 92c446d6a5e..6b3ddeb7e5c 100644
--- a/config/scripts/ci/sharding/ci-shard-timings.json
+++ b/config/scripts/ci/sharding/ci-shard-timings.json
@@ -7650,7 +7650,6 @@
"src/renderer/src/components/right-sidebar/ai-vault/scope/ai-vault-session-projects.test.ts": 117,
"src/renderer/src/components/right-sidebar/ai-vault/scanning/ai-vault-session-publication-gate.test.ts": 196,
"src/renderer/src/components/right-sidebar/ai-vault/scanning/ai-vault-session-refresh.test.ts": 2034,
- "src/renderer/src/components/right-sidebar/ai-vault/session-actions/ai-vault-session-resume-in-chat-launch.test.ts": 1260,
"src/renderer/src/components/right-sidebar/ai-vault/session-actions/ai-vault-session-resume-in-chat-workspace.test.ts": 746,
"src/renderer/src/components/right-sidebar/ai-vault/session-actions/ai-vault-session-resume.test.ts": 1753,
"src/renderer/src/components/right-sidebar/ai-vault/session-list/ai-vault-session-worktree-map.test.tsx": 2000,
diff --git a/src/renderer/src/components/native-chat/AddToChatMenu.test.tsx b/src/renderer/src/components/native-chat/AddToChatMenu.test.tsx
deleted file mode 100644
index 93db0623b16..00000000000
--- a/src/renderer/src/components/native-chat/AddToChatMenu.test.tsx
+++ /dev/null
@@ -1,32 +0,0 @@
-// @vitest-environment happy-dom
-import { act, cleanup, fireEvent, render, screen } from '@testing-library/react'
-import { afterEach, expect, it, vi } from 'vitest'
-import { AddToChatPointMenuHost } from './AddToChatMenu'
-import { openAddToChatMenuAt } from './add-to-chat-point-menu'
-
-vi.mock('@/components/editor/review-note-delivery/ReviewNotesSendMenuContent', () => ({
- ReviewNotesSendMenuContent: () =>
Chat A
-}))
-
-afterEach(cleanup)
-
-// The menu opens from a hidden anchor; cancelling it must hand focus back to the selection's editor.
-it('returns focus to where the selection was when the menu is dismissed with Escape', async () => {
- render(
- <>
-
-
- >
- )
- const editor = screen.getByLabelText('editor')
- editor.focus()
- act(() =>
- openAddToChatMenuAt({ worktreeId: 'wt', quote: '> q', launchSource: 'native_chat', x: 1, y: 1 })
- )
- expect(screen.getByText('Chat A')).toBeTruthy()
- fireEvent.keyDown(document.activeElement ?? document.body, { key: 'Escape' })
- expect(screen.queryByText('Chat A')).toBeNull()
- // Radix hands focus back a task after the menu unmounts.
- await act(() => new Promise((resolve) => setTimeout(resolve, 0)))
- expect(document.activeElement).toBe(editor)
-})
diff --git a/src/renderer/src/components/native-chat/native-chat-workspace-selection.test.ts b/src/renderer/src/components/native-chat/native-chat-workspace-selection.test.ts
index 238528e8f84..2f18b2d0fa5 100644
--- a/src/renderer/src/components/native-chat/native-chat-workspace-selection.test.ts
+++ b/src/renderer/src/components/native-chat/native-chat-workspace-selection.test.ts
@@ -1,6 +1,6 @@
import { describe, expect, it, vi } from 'vitest'
import type { Tab } from '../../../../shared/tab-types'
-import { addQuoteToAgent, workspaceChatTargetFor } from './native-chat-workspace-selection'
+import { workspaceChatTargetFor } from './native-chat-workspace-selection'
const sendMessageToAgent = vi.hoisted(() => vi.fn())
vi.mock('@/lib/agent-message-send', () => ({ sendMessageToAgent }))
@@ -75,17 +75,4 @@ describe('workspaceChatTargetFor', () => {
})
).toBeNull()
})
-
- // A plain terminal agent has no composer: it gets the notes send's paste, without the Enter.
- it('pastes into a plain terminal agent without submitting', async () => {
- sendMessageToAgent.mockResolvedValue({ status: 'sent' })
- const target = { kind: 'terminal' as const, tabId: 'term-plain', leafId: CHAT_LEAF }
- await expect(addQuoteToAgent('wt-1', target, '> quote')).resolves.toEqual({ status: 'sent' })
- expect(sendMessageToAgent).toHaveBeenCalledWith({
- worktreeId: 'wt-1',
- target,
- prompt: '> quote',
- submit: false
- })
- })
})
diff --git a/src/renderer/src/components/right-sidebar/ai-vault/session-actions/ai-vault-session-resume-in-chat-launch.test.ts b/src/renderer/src/components/right-sidebar/ai-vault/session-actions/ai-vault-session-resume-in-chat-launch.test.ts
deleted file mode 100644
index b789fd1307e..00000000000
--- a/src/renderer/src/components/right-sidebar/ai-vault/session-actions/ai-vault-session-resume-in-chat-launch.test.ts
+++ /dev/null
@@ -1,309 +0,0 @@
-import { beforeEach, describe, expect, it, vi } from 'vitest'
-import type { StructuredAgentLaunchSettlement } from '@/lib/structured-agent-launch-settlement'
-import type { ExecutionHostId } from '../../../../../../shared/execution-host'
-import type { AiVaultSession } from '../../../../../../shared/ai-vault/contracts/ai-vault-types'
-
-type BeginArgs = { beforeOpen?: (sessionId: string) => boolean | void }
-type Launch = {
- sessionId: string
- settlement: Promise
- tab: { id: string }
-}
-
-const mocks = vi.hoisted(() => {
- const state: { owner: ExecutionHostId | null } = { owner: 'local' }
- return {
- beginStructuredAgentSessionProvisionalLaunch: vi.fn<(args: BeginArgs) => Launch | null>(),
- prepareAiVaultSessionForResume: vi.fn<() => Promise<{ sessionId: string }>>(),
- activateAndRevealWorkspace: vi.fn<(workspaceId: string) => unknown>(),
- toastError: vi.fn<(message: string) => void>(),
- admitStructuredLaunchOnHost:
- vi.fn<(target: unknown, worktree: string, agent: string) => Promise<{ kind: string }>>(),
- ...state,
- sleeping: false,
- navigationIndex: 0,
- activeWorktreeId: 'other-worktree'
- }
-})
-
-vi.mock('@/lib/agent-session/structured-agent-session-provisional-tab', () => ({
- beginStructuredAgentSessionProvisionalLaunch: mocks.beginStructuredAgentSessionProvisionalLaunch,
- structuredLaunchOwner: (plan: { executionHostId?: ExecutionHostId }) => {
- const executionHostId = plan.executionHostId ?? mocks.owner
- return executionHostId
- ? {
- executionHostId,
- target:
- executionHostId === 'local'
- ? { kind: 'local' }
- : { kind: 'environment', environmentId: executionHostId.slice('runtime:'.length) }
- }
- : null
- }
-}))
-vi.mock('@/lib/agent-session/launch/structured-agent-session-host-admission', () => ({
- admitStructuredLaunchOnHost: mocks.admitStructuredLaunchOnHost
-}))
-vi.mock('@/lib/ai-vault-session-resume-preparation', () => ({
- prepareAiVaultSessionForResume: mocks.prepareAiVaultSessionForResume
-}))
-vi.mock('@/lib/worktree-activation', () => ({
- activateAndRevealWorkspace: mocks.activateAndRevealWorkspace
-}))
-vi.mock('sonner', () => ({ toast: { error: mocks.toastError } }))
-vi.mock('@/store/index', () => ({
- useAppStore: {
- getState: () => ({
- activeWorktreeId: mocks.activeWorktreeId,
- worktreeNavHistoryIndex: mocks.navigationIndex,
- sleepingAgentSessionsByPaneKey: mocks.sleeping ? { source: { worktreeId: 'worktree-1' } } : {}
- })
- }
-}))
-
-import { resumeAiVaultSessionInNewChat } from './ai-vault-session-resume-in-chat-launch'
-
-const session: AiVaultSession = {
- id: 'vault-1',
- executionHostId: 'local',
- agent: 'codex',
- sessionId: 'vault-1',
- title: 'Vault session',
- cwd: '/x',
- branch: null,
- model: null,
- filePath: '/x',
- codexHome: null,
- createdAt: null,
- updatedAt: null,
- modifiedAt: '2025-01-01T00:00:00.000Z',
- messageCount: 1,
- totalTokens: 1,
- previewMessages: [],
- queuedMessageCount: 0,
- subagentTranscriptCount: 0,
- resumeCommand: 'resume',
- subagent: null
-}
-
-describe('resumeAiVaultSessionInNewChat', () => {
- beforeEach(() => {
- vi.clearAllMocks()
- mocks.owner = 'local'
- mocks.sleeping = false
- mocks.navigationIndex = 0
- mocks.activeWorktreeId = 'other-worktree'
- mocks.prepareAiVaultSessionForResume.mockResolvedValue({ sessionId: 'provider-1' })
- mocks.activateAndRevealWorkspace.mockReturnValue({ primaryTabId: null })
- mocks.beginStructuredAgentSessionProvisionalLaunch.mockImplementation((args) => {
- args.beforeOpen?.('session-1')
- return {
- sessionId: 'session-1',
- tab: { id: 'agent-session:session-1' },
- settlement: Promise.resolve({ kind: 'structured', sessionId: 'session-1' })
- }
- })
- })
-
- it('keeps the recording server when workspace selection changes during preparation', async () => {
- mocks.owner = 'runtime:server-1'
- let finish!: (value: { sessionId: string }) => void
- mocks.prepareAiVaultSessionForResume.mockReturnValue(
- new Promise((resolve) => {
- finish = resolve
- })
- )
- mocks.admitStructuredLaunchOnHost.mockResolvedValue({ kind: 'admitted' })
- const launched = resumeAiVaultSessionInNewChat(
- { ...session, executionHostId: 'runtime:server-1' },
- 'opencode2',
- 'worktree-1',
- 'resume-click'
- )
- mocks.owner = 'runtime:server-2'
- mocks.activeWorktreeId = 'worktree-1'
- finish({ sessionId: 'provider-1' })
- await launched
- expect(mocks.activateAndRevealWorkspace).toHaveBeenCalledWith('worktree-1', {
- executionHostId: 'runtime:server-1'
- })
- expect(mocks.admitStructuredLaunchOnHost).toHaveBeenCalledWith(
- { kind: 'environment', environmentId: 'server-1' },
- 'id:worktree-1',
- 'opencode2'
- )
- expect(mocks.beginStructuredAgentSessionProvisionalLaunch).toHaveBeenCalledWith(
- expect.objectContaining({
- plan: expect.objectContaining({ executionHostId: 'runtime:server-1' })
- })
- )
- })
-
- it.each(['local', 'runtime:server-2', null] as const)(
- 'refuses a recording-host mismatch before preparing history: %s',
- async (owner) => {
- mocks.owner = owner
- await resumeAiVaultSessionInNewChat(
- { ...session, executionHostId: 'runtime:server-1' },
- 'codex',
- 'worktree-1',
- 'resume-click'
- )
- expect(mocks.prepareAiVaultSessionForResume).not.toHaveBeenCalled()
- expect(mocks.beginStructuredAgentSessionProvisionalLaunch).not.toHaveBeenCalled()
- expect(mocks.toastError).toHaveBeenCalledOnce()
- }
- )
-
- it.each(['ssh:relay', 'runtime:unresolved-owner'] as const)(
- 'does not prepare a conversation from a non-runtime owner: %s',
- async (executionHostId) => {
- mocks.owner = executionHostId
- await resumeAiVaultSessionInNewChat(
- { ...session, executionHostId },
- 'codex',
- 'worktree-1',
- 'resume-click'
- )
- expect(mocks.prepareAiVaultSessionForResume).not.toHaveBeenCalled()
- expect(mocks.beginStructuredAgentSessionProvisionalLaunch).not.toHaveBeenCalled()
- }
- )
-
- it.each([false, true])(
- 'reveals the workspace and opens chat before provider settlement (aliases: %s)',
- async (aliases) => {
- const source = {
- ...session,
- cwd: '/private/var/example',
- ...(aliases ? { cwdAliases: ['/var/example'], sessionId: 'provider-1' } : {})
- }
- let settle!: (value: StructuredAgentLaunchSettlement) => void
- const settlement = new Promise((resolve) => {
- settle = resolve
- })
- mocks.beginStructuredAgentSessionProvisionalLaunch.mockImplementation((args) => {
- args.beforeOpen?.('session-1')
- return { sessionId: 'session-1', tab: { id: 'agent-session:session-1' }, settlement }
- })
-
- await resumeAiVaultSessionInNewChat(source, 'codex', 'worktree-1', 'resume-click')
-
- expect(mocks.prepareAiVaultSessionForResume).toHaveBeenCalledWith(source)
- expect(mocks.beginStructuredAgentSessionProvisionalLaunch).toHaveBeenCalledWith(
- expect.objectContaining({
- plan: expect.objectContaining({ resumeFrom: { providerSessionId: 'provider-1' } }),
- hooks: {}
- })
- )
- expect(mocks.activateAndRevealWorkspace).toHaveBeenCalledWith('worktree-1', {
- executionHostId: 'local'
- })
- expect(mocks.toastError).not.toHaveBeenCalled()
- expect(source.cwd).toBe('/private/var/example')
- expect(source.sessionId).toBe(aliases ? 'provider-1' : session.sessionId)
- settle({ kind: 'structured', sessionId: 'session-1' })
- }
- )
-
- // Where `opencode` is 1.x, only the OpenCode 2 chat can load a 2.x conversation.
- it.each([
- ['admitted', 'opencode2'],
- ['declined', 'opencode'],
- // Not a refusal: switching would start `opencode`, which may be 1.x.
- ['unreachable', 'opencode2'],
- ['workspace-unresolved', 'opencode2']
- ])(
- 'opens an OpenCode 2 row in the OpenCode 2 chat, else an OpenCode chat (%s)',
- async (kind, agent) => {
- mocks.admitStructuredLaunchOnHost.mockResolvedValue({ kind })
- await resumeAiVaultSessionInNewChat(session, 'opencode2', 'worktree-1', 'resume-click')
-
- expect(mocks.admitStructuredLaunchOnHost).toHaveBeenCalledExactlyOnceWith(
- { kind: 'local' },
- 'id:worktree-1',
- 'opencode2'
- )
- expect(mocks.beginStructuredAgentSessionProvisionalLaunch).toHaveBeenCalledWith(
- expect.objectContaining({ plan: expect.objectContaining({ agent }) })
- )
- }
- )
-
- it('asks the host nothing for a row only one chat takes over', async () => {
- await resumeAiVaultSessionInNewChat(session, 'codex', 'worktree-1', 'resume-click')
- expect(mocks.admitStructuredLaunchOnHost).not.toHaveBeenCalled()
- })
-
- it.each(['refusal', 'success', 'newer-navigation'] as const)(
- 'keeps sleeping History cold until actual creation: %s',
- async (outcome) => {
- mocks.sleeping = true
- let settle!: (value: StructuredAgentLaunchSettlement) => void
- const settlement = new Promise((resolve) => {
- settle = resolve
- })
- mocks.beginStructuredAgentSessionProvisionalLaunch.mockImplementation((args) => {
- args.beforeOpen?.('session-1')
- return { sessionId: 'session-1', tab: { id: 'agent-session:session-1' }, settlement }
- })
- await resumeAiVaultSessionInNewChat(session, 'codex', 'worktree-1', 'resume-click')
- expect(mocks.activateAndRevealWorkspace).not.toHaveBeenCalled()
- if (outcome === 'newer-navigation') {
- mocks.navigationIndex += 1
- }
- settle(
- outcome === 'refusal'
- ? { kind: 'failed', error: new Error('refused') }
- : { kind: 'structured', sessionId: 'session-1' }
- )
- await settlement
- expect(mocks.activateAndRevealWorkspace).toHaveBeenCalledTimes(outcome === 'success' ? 1 : 0)
- expect(mocks.toastError).toHaveBeenCalledTimes(outcome === 'refusal' ? 1 : 0)
- }
- )
-
- it.each([
- ['agent_session_conflict', undefined, 'Another chat is already holding this conversation.'],
- [
- 'agent_session_conflict',
- 'conversationHeldElsewhere',
- 'Codex is running this conversation in another terminal. Quit it there or close that terminal, then try again.'
- ],
- [
- 'agent_session_identity_required',
- 'transcriptNotFound',
- "Codex hasn't saved this conversation yet. Try again after it replies."
- ],
- [
- 'agent_session_identity_required',
- 'transcriptUnreadable',
- "This conversation's history could not be loaded, so it cannot be resumed in chat."
- ]
- ])('toasts the eventual %s refusal', async (code, reason, message) => {
- const error = Object.assign(new Error('Host diagnostic'), {
- code,
- ...(reason ? { refusal: { code, details: { reason } } } : {})
- })
- mocks.beginStructuredAgentSessionProvisionalLaunch.mockReturnValue({
- sessionId: 'session-1',
- tab: { id: 'agent-session:session-1' },
- settlement: Promise.resolve({ kind: 'failed', error })
- })
-
- await resumeAiVaultSessionInNewChat(session, 'codex', 'worktree-1', 'resume-click')
- await vi.waitFor(() => expect(mocks.toastError).toHaveBeenCalledExactlyOnceWith(message))
- })
-
- it('keeps unknown outcomes silent for reconciliation', async () => {
- mocks.beginStructuredAgentSessionProvisionalLaunch.mockReturnValue({
- sessionId: 'session-1',
- tab: { id: 'agent-session:session-1' },
- settlement: Promise.resolve({ kind: 'visibility-unknown', sessionId: 'session-1' })
- })
-
- await resumeAiVaultSessionInNewChat(session, 'codex', 'worktree-1', 'resume-click')
- await Promise.resolve()
- expect(mocks.toastError).not.toHaveBeenCalled()
- })
-})
diff --git a/src/renderer/src/components/right-sidebar/ai-vault/session-actions/ai-vault-session-resume.test.ts b/src/renderer/src/components/right-sidebar/ai-vault/session-actions/ai-vault-session-resume.test.ts
index 4e4d506d229..14f3ba6ce8c 100644
--- a/src/renderer/src/components/right-sidebar/ai-vault/session-actions/ai-vault-session-resume.test.ts
+++ b/src/renderer/src/components/right-sidebar/ai-vault/session-actions/ai-vault-session-resume.test.ts
@@ -2,15 +2,8 @@ import { describe, expect, it } from 'vitest'
import type { Repo } from '../../../../../../shared/repo-types'
import type { Worktree } from '../../../../../../shared/worktree/types'
import type { AiVaultSessionWorktreeInfo } from '../../../../../../shared/ai-vault/session-display/ai-vault-session-worktree'
-import { folderWorkspaceKey } from '../../../../../../shared/workspace-scope'
-import { resolveAiVaultSessionLaunchTarget } from './ai-vault-session-launch-target'
-import {
- aiVaultSessionResumeLabel,
- aiVaultSessionRowResumeGating,
- type AiVaultSessionResumeTargetState,
- resolveAiVaultSessionResumeActions,
- resolveAiVaultSessionResumeState
-} from './ai-vault-session-resume'
+
+import { resolveAiVaultSessionResumeState } from './ai-vault-session-resume'
function makeWorktree(overrides: Partial = {}): Worktree {
return {
@@ -46,57 +39,6 @@ function makeRepo(overrides: Partial = {}): Repo {
}
}
-function makeTargetState(
- overrides: Partial = {}
-): AiVaultSessionResumeTargetState {
- return {
- folderWorkspaces: [],
- projectGroups: [],
- repos: [],
- worktreesByRepo: {},
- ...overrides
- }
-}
-
-function makeFolderTargetState(
- projectGroup: Partial
-): AiVaultSessionResumeTargetState {
- return makeTargetState({
- folderWorkspaces: [
- {
- id: 'folder-1',
- projectGroupId: 'group-1',
- name: 'Platform',
- folderPath: '/repo/platform',
- linkedTask: null,
- comment: '',
- isArchived: false,
- isUnread: false,
- isPinned: false,
- sortOrder: 0,
- lastActivityAt: 1,
- createdAt: 1,
- updatedAt: 1
- }
- ],
- projectGroups: [
- {
- id: 'group-1',
- name: 'Platform',
- parentPath: null,
- parentGroupId: null,
- createdFrom: 'manual',
- tabOrder: 0,
- isCollapsed: false,
- color: null,
- createdAt: 1,
- updatedAt: 1,
- ...projectGroup
- }
- ]
- })
-}
-
function makeWorktreeInfo(
status: AiVaultSessionWorktreeInfo['status']
): AiVaultSessionWorktreeInfo {
@@ -109,8 +51,6 @@ function makeWorktreeInfo(
}
const HOST_SESSION_FILE = '/Users/ada/.claude/projects/-repo-orca/session-1.jsonl'
-const WSL_SESSION_FILE =
- '\\\\wsl$\\Ubuntu\\home\\ada\\.claude\\projects\\-repo-orca\\session-1.jsonl'
describe('resolveAiVaultSessionResumeState', () => {
it('prefers the session worktree over the active workspace', () => {
@@ -132,154 +72,6 @@ describe('resolveAiVaultSessionResumeState', () => {
})
})
- it('falls back to the active workspace when the session worktree is unavailable', () => {
- expect(
- resolveAiVaultSessionResumeState({
- sessionFilePath: HOST_SESSION_FILE,
- worktreeInfo: makeWorktreeInfo('archived'),
- activeWorktreeId: 'repo-1::/repo/orca',
- worktrees: [makeWorktree()],
- repos: [{ id: 'repo-1' } as Repo]
- })
- ).toEqual({
- blocked: false,
- worktreeId: 'repo-1::/repo/orca',
- usesSessionWorktree: false
- })
- })
-
- it('blocks missing worktrees even when the repo is SSH-owned', () => {
- expect(
- resolveAiVaultSessionResumeState({
- sessionFilePath: HOST_SESSION_FILE,
- worktreeInfo: makeWorktreeInfo('active'),
- activeWorktreeId: null,
- worktrees: [],
- repos: [{ id: 'repo-1', connectionId: 'ssh-1' } as Repo]
- })
- ).toEqual({
- blocked: true,
- worktreeId: null,
- usesSessionWorktree: false
- })
- })
-
- it('allows SSH-owned session worktrees', () => {
- expect(
- resolveAiVaultSessionResumeState({
- sessionFilePath: WSL_SESSION_FILE,
- worktreeInfo: makeWorktreeInfo('active'),
- activeWorktreeId: null,
- worktrees: [makeWorktree()],
- repos: [makeRepo({ connectionId: 'ssh-1' })]
- })
- ).toEqual({
- blocked: false,
- worktreeId: 'repo-1::/repo/orca',
- usesSessionWorktree: true
- })
- })
-
- it('allows SSH-stamped worktrees even when the repo owner is runtime', () => {
- expect(
- resolveAiVaultSessionResumeState({
- sessionFilePath: WSL_SESSION_FILE,
- worktreeInfo: makeWorktreeInfo('active'),
- activeWorktreeId: null,
- worktrees: [makeWorktree({ hostId: 'ssh:ssh-1' })],
- repos: [makeRepo({ connectionId: null, executionHostId: 'runtime:env-1' })]
- })
- ).toEqual({
- blocked: false,
- worktreeId: 'repo-1::/repo/orca',
- usesSessionWorktree: true
- })
- })
-
- it('allows runtime-owned targets for matching runtime sessions', () => {
- expect(
- resolveAiVaultSessionResumeState({
- sessionFilePath: HOST_SESSION_FILE,
- sessionExecutionHostId: 'runtime:env-1',
- worktreeInfo: makeWorktreeInfo('active'),
- activeWorktreeId: null,
- worktrees: [makeWorktree()],
- repos: [
- makeRepo({
- connectionId: null,
- executionHostId: 'runtime:env-1'
- })
- ]
- })
- ).toEqual({
- blocked: false,
- worktreeId: 'repo-1::/repo/orca',
- usesSessionWorktree: true
- })
- })
-
- it('blocks runtime-owned targets for sessions from another host', () => {
- expect(
- resolveAiVaultSessionResumeState({
- sessionFilePath: HOST_SESSION_FILE,
- sessionExecutionHostId: 'local',
- worktreeInfo: makeWorktreeInfo('active'),
- activeWorktreeId: null,
- worktrees: [makeWorktree()],
- repos: [
- makeRepo({
- connectionId: null,
- executionHostId: 'runtime:env-1'
- })
- ]
- })
- ).toEqual({
- blocked: true,
- worktreeId: null,
- usesSessionWorktree: false
- })
- })
-
- it('allows runtime-stamped worktrees even when the repo owner is local', () => {
- expect(
- resolveAiVaultSessionResumeState({
- sessionFilePath: HOST_SESSION_FILE,
- sessionExecutionHostId: 'runtime:env-1',
- worktreeInfo: makeWorktreeInfo('active'),
- activeWorktreeId: null,
- worktrees: [makeWorktree({ hostId: 'runtime:env-1' })],
- repos: [makeRepo({ connectionId: null, executionHostId: 'local' })]
- })
- ).toEqual({
- blocked: false,
- worktreeId: 'repo-1::/repo/orca',
- usesSessionWorktree: true
- })
- })
-
- it('prefers the session worktree when the active workspace is SSH-owned', () => {
- expect(
- resolveAiVaultSessionResumeState({
- sessionFilePath: HOST_SESSION_FILE,
- worktreeInfo: makeWorktreeInfo('active'),
- activeWorktreeId: 'repo-2::/remote/orca',
- worktrees: [
- makeWorktree(),
- makeWorktree({
- id: 'repo-2::/remote/orca',
- repoId: 'repo-2',
- path: '/remote/orca'
- })
- ],
- repos: [{ id: 'repo-1' } as Repo, { id: 'repo-2', connectionId: 'ssh-1' } as Repo]
- })
- ).toEqual({
- blocked: false,
- worktreeId: 'repo-1::/repo/orca',
- usesSessionWorktree: true
- })
- })
-
it('falls back to the active workspace when the session worktree is runtime-owned', () => {
expect(
resolveAiVaultSessionResumeState({
@@ -310,319 +102,4 @@ describe('resolveAiVaultSessionResumeState', () => {
usesSessionWorktree: false
})
})
-
- it('falls back to an active SSH folder workspace', () => {
- expect(
- resolveAiVaultSessionResumeState({
- sessionFilePath: WSL_SESSION_FILE,
- worktreeInfo: makeWorktreeInfo('archived'),
- activeWorktreeId: folderWorkspaceKey('folder-1'),
- worktrees: [],
- repos: [],
- targetState: makeFolderTargetState({ id: 'group-1', connectionId: 'ssh-1' })
- })
- ).toEqual({
- blocked: false,
- worktreeId: folderWorkspaceKey('folder-1'),
- usesSessionWorktree: false
- })
- })
-
- it('blocks host-stored sessions when only an SSH workspace is open', () => {
- expect(
- resolveAiVaultSessionResumeState({
- sessionFilePath: HOST_SESSION_FILE,
- worktreeInfo: makeWorktreeInfo('archived'),
- activeWorktreeId: folderWorkspaceKey('folder-1'),
- worktrees: [],
- repos: [],
- targetState: makeFolderTargetState({ id: 'group-1', connectionId: 'ssh-1' })
- })
- ).toEqual({
- blocked: true,
- worktreeId: null,
- usesSessionWorktree: false
- })
- })
-
- it('allows an active runtime folder workspace for matching runtime sessions', () => {
- expect(
- resolveAiVaultSessionResumeState({
- sessionFilePath: HOST_SESSION_FILE,
- sessionExecutionHostId: 'runtime:env-1',
- worktreeInfo: makeWorktreeInfo('archived'),
- activeWorktreeId: folderWorkspaceKey('folder-1'),
- worktrees: [],
- repos: [],
- targetState: makeFolderTargetState({ id: 'group-1', executionHostId: 'runtime:env-1' })
- })
- ).toEqual({
- blocked: false,
- worktreeId: folderWorkspaceKey('folder-1'),
- usesSessionWorktree: false
- })
- })
-})
-
-describe('resolveAiVaultSessionResumeActions', () => {
- it('exposes separate session-worktree and active-workspace targets', () => {
- expect(
- resolveAiVaultSessionResumeActions({
- sessionFilePath: HOST_SESSION_FILE,
- worktreeInfo: makeWorktreeInfo('active'),
- activeWorktreeId: 'repo-1::/repo/other',
- worktrees: [
- makeWorktree(),
- makeWorktree({ id: 'repo-1::/repo/other', path: '/repo/other' })
- ],
- repos: [{ id: 'repo-1' } as Repo]
- })
- ).toEqual({
- worktree: { worktreeId: 'repo-1::/repo/orca', disabled: false },
- newTab: { worktreeId: 'repo-1::/repo/other', disabled: false }
- })
- })
-
- it('enables an SSH active-workspace action when the session worktree is local', () => {
- expect(
- resolveAiVaultSessionResumeActions({
- sessionFilePath: WSL_SESSION_FILE,
- worktreeInfo: makeWorktreeInfo('active'),
- activeWorktreeId: 'repo-2::/remote/orca',
- worktrees: [
- // A WSL-stored session's own worktree lives in that distro.
- makeWorktree({ path: '\\\\wsl$\\Ubuntu\\repo\\orca' }),
- makeWorktree({
- id: 'repo-2::/remote/orca',
- repoId: 'repo-2',
- path: '/remote/orca'
- })
- ],
- repos: [{ id: 'repo-1' } as Repo, { id: 'repo-2', connectionId: 'ssh-1' } as Repo]
- })
- ).toEqual({
- worktree: { worktreeId: 'repo-1::/repo/orca', disabled: false },
- newTab: { worktreeId: 'repo-2::/remote/orca', disabled: false }
- })
- })
-
- it('disables the SSH active-workspace action for host-stored sessions', () => {
- expect(
- resolveAiVaultSessionResumeActions({
- sessionFilePath: HOST_SESSION_FILE,
- worktreeInfo: makeWorktreeInfo('active'),
- activeWorktreeId: 'repo-2::/remote/orca',
- worktrees: [
- makeWorktree(),
- makeWorktree({
- id: 'repo-2::/remote/orca',
- repoId: 'repo-2',
- path: '/remote/orca'
- })
- ],
- repos: [{ id: 'repo-1' } as Repo, { id: 'repo-2', connectionId: 'ssh-1' } as Repo]
- })
- ).toEqual({
- worktree: { worktreeId: 'repo-1::/repo/orca', disabled: false },
- newTab: { worktreeId: 'repo-2::/remote/orca', disabled: true }
- })
- })
-
- it('disables runtime-owned targets without disabling local targets', () => {
- expect(
- resolveAiVaultSessionResumeActions({
- sessionFilePath: HOST_SESSION_FILE,
- worktreeInfo: makeWorktreeInfo('active'),
- activeWorktreeId: 'repo-2::/repo/other',
- worktrees: [
- makeWorktree(),
- makeWorktree({
- id: 'repo-2::/repo/other',
- repoId: 'repo-2',
- path: '/repo/other'
- })
- ],
- repos: [
- makeRepo({ connectionId: null, executionHostId: 'runtime:env-1' }),
- makeRepo({
- id: 'repo-2',
- path: '/repo/other',
- connectionId: null,
- executionHostId: 'local'
- })
- ]
- })
- ).toEqual({
- worktree: { worktreeId: 'repo-1::/repo/orca', disabled: true },
- newTab: { worktreeId: 'repo-2::/repo/other', disabled: false }
- })
- })
-
- it('does not expose the active workspace as a duplicate new-tab target', () => {
- expect(
- resolveAiVaultSessionResumeActions({
- sessionFilePath: HOST_SESSION_FILE,
- worktreeInfo: makeWorktreeInfo('current'),
- activeWorktreeId: 'repo-1::/repo/orca',
- worktrees: [makeWorktree()],
- repos: [{ id: 'repo-1' } as Repo]
- })
- ).toEqual({
- worktree: { worktreeId: 'repo-1::/repo/orca', disabled: false },
- newTab: { worktreeId: null, disabled: true }
- })
- })
-
- it('enables the active folder workspace action when it is local or SSH-owned', () => {
- expect(
- resolveAiVaultSessionResumeActions({
- sessionFilePath: WSL_SESSION_FILE,
- worktreeInfo: makeWorktreeInfo('archived'),
- activeWorktreeId: folderWorkspaceKey('folder-1'),
- worktrees: [],
- repos: [],
- targetState: makeFolderTargetState({ id: 'group-1', connectionId: 'ssh-1' })
- })
- ).toEqual({
- worktree: { worktreeId: null, disabled: true },
- newTab: { worktreeId: folderWorkspaceKey('folder-1'), disabled: false }
- })
- })
-
- it('enables the active folder workspace action when it is a matching runtime host', () => {
- expect(
- resolveAiVaultSessionResumeActions({
- sessionFilePath: HOST_SESSION_FILE,
- sessionExecutionHostId: 'runtime:env-1',
- worktreeInfo: makeWorktreeInfo('archived'),
- activeWorktreeId: folderWorkspaceKey('folder-1'),
- worktrees: [],
- repos: [],
- targetState: makeFolderTargetState({ id: 'group-1', executionHostId: 'runtime:env-1' })
- })
- ).toEqual({
- worktree: { worktreeId: null, disabled: true },
- newTab: { worktreeId: folderWorkspaceKey('folder-1'), disabled: false }
- })
- })
-})
-
-describe('resolveAiVaultSessionLaunchTarget', () => {
- it('allows direct resume into an active SSH folder workspace', () => {
- expect(
- resolveAiVaultSessionLaunchTarget({
- sessionFilePath: WSL_SESSION_FILE,
- activeWorktreeId: folderWorkspaceKey('folder-1'),
- targetState: makeFolderTargetState({ id: 'group-1', connectionId: 'ssh-1' })
- })
- ).toEqual({
- status: 'ready',
- worktreeId: folderWorkspaceKey('folder-1')
- })
- })
-
- it('blocks direct resume of a host-stored session into an SSH folder workspace', () => {
- expect(
- resolveAiVaultSessionLaunchTarget({
- sessionFilePath: HOST_SESSION_FILE,
- activeWorktreeId: folderWorkspaceKey('folder-1'),
- targetState: makeFolderTargetState({ id: 'group-1', connectionId: 'ssh-1' })
- })
- ).toEqual({
- status: 'unsupported',
- targetStatus: 'ssh'
- })
- })
-
- it('allows direct resume into a matching runtime folder workspace', () => {
- expect(
- resolveAiVaultSessionLaunchTarget({
- sessionFilePath: WSL_SESSION_FILE,
- sessionExecutionHostId: 'runtime:env-1',
- activeWorktreeId: folderWorkspaceKey('folder-1'),
- targetState: makeFolderTargetState({ id: 'group-1', executionHostId: 'runtime:env-1' })
- })
- ).toEqual({
- status: 'ready',
- worktreeId: folderWorkspaceKey('folder-1')
- })
- })
-
- it('blocks direct resume into a mismatched runtime folder workspace', () => {
- expect(
- resolveAiVaultSessionLaunchTarget({
- sessionFilePath: WSL_SESSION_FILE,
- sessionExecutionHostId: 'runtime:env-2',
- activeWorktreeId: folderWorkspaceKey('folder-1'),
- targetState: makeFolderTargetState({ id: 'group-1', executionHostId: 'runtime:env-1' })
- })
- ).toEqual({
- status: 'unsupported',
- targetStatus: 'runtime'
- })
- })
-})
-
-describe('aiVaultSessionResumeLabel', () => {
- it('names the session worktree action distinctly from the active-workspace fallback', () => {
- expect(aiVaultSessionResumeLabel({ usesSessionWorktree: true })).toBe('Resume in Worktree')
- expect(aiVaultSessionResumeLabel({ usesSessionWorktree: false })).toBe('Resume in New Tab')
- })
-})
-
-describe('aiVaultSessionRowResumeGating', () => {
- const zeroTurnSession = { messageCount: 0, previewMessages: [] }
- const sessionWithTurns = { messageCount: 3, previewMessages: [] }
- const unblocked = { blocked: false }
-
- it('withholds every resume affordance for a zero-turn session', () => {
- expect(aiVaultSessionRowResumeGating(zeroTurnSession, unblocked)).toEqual({
- resumeDisabled: true,
- canCopyResumeCommand: false
- })
- })
-
- it('keeps copy-resume available when only the workspace target is blocked', () => {
- expect(aiVaultSessionRowResumeGating(sessionWithTurns, { blocked: true })).toEqual({
- resumeDisabled: true,
- canCopyResumeCommand: true
- })
- expect(aiVaultSessionRowResumeGating(sessionWithTurns, null)).toEqual({
- resumeDisabled: true,
- canCopyResumeCommand: true
- })
- })
-
- it('withholds copy-resume from a native structured session', () => {
- expect(
- aiVaultSessionRowResumeGating(
- {
- ...sessionWithTurns,
- structuredSession: { sessionId: 'session-1', workspaceId: 'worktree-1' }
- },
- unblocked
- )
- ).toEqual({
- resumeDisabled: false,
- canCopyResumeCommand: false
- })
- })
-
- it('treats user/assistant previews as resumable content when the turn count is unknown', () => {
- const previewOnlySession = {
- messageCount: 0,
- previewMessages: [{ role: 'user' as const, text: 'hello', timestamp: null }]
- }
- expect(aiVaultSessionRowResumeGating(previewOnlySession, unblocked)).toEqual({
- resumeDisabled: false,
- canCopyResumeCommand: true
- })
- })
-
- it('enables resume for an unblocked session with turns', () => {
- expect(aiVaultSessionRowResumeGating(sessionWithTurns, unblocked)).toEqual({
- resumeDisabled: false,
- canCopyResumeCommand: true
- })
- })
})
diff --git a/src/renderer/src/components/right-sidebar/ai-vault/session-list/AiVaultSessionHistoryDialog.test.tsx b/src/renderer/src/components/right-sidebar/ai-vault/session-list/AiVaultSessionHistoryDialog.test.tsx
index 163a55c705c..5d6120e7dcb 100644
--- a/src/renderer/src/components/right-sidebar/ai-vault/session-list/AiVaultSessionHistoryDialog.test.tsx
+++ b/src/renderer/src/components/right-sidebar/ai-vault/session-list/AiVaultSessionHistoryDialog.test.tsx
@@ -7,13 +7,12 @@ import { ConfirmationDialogProvider } from '@/components/confirmation-dialog'
import { useAppStore } from '@/store/index'
import { makeRepo, makeWorktree } from '../../../worktree-jump/worktree-jump-palette-test-fixtures'
import { openAgentSessionHistoryModal } from '../panel/agent-session-history-modal'
-import { resolveAiVaultPanelSessionListRequest } from '../scanning/ai-vault-panel-session-list-request'
+
import type {
AiVaultAgent,
AiVaultSession
} from '../../../../../../shared/ai-vault/contracts/ai-vault-types'
import type { AiVaultSessionListGroup } from './ai-vault-session-filters'
-import { AI_VAULT_VIEW_OPTIONS_STORAGE_KEY } from '../scope/ai-vault-view-options-persistence'
const mocks = vi.hoisted(() => ({
scopePaths: new Array(),
@@ -97,31 +96,6 @@ function openHistory(initialQuery = '', agent?: AiVaultAgent) {
)
}
-function chatSession(agent: AiVaultAgent): AiVaultSession {
- return {
- id: `${agent}-chat`,
- executionHostId: 'local',
- agent,
- sessionId: agent,
- title: agent,
- cwd: '/repo/chat',
- branch: null,
- model: null,
- filePath: `/tmp/${agent}.jsonl`,
- codexHome: null,
- createdAt: null,
- updatedAt: null,
- modifiedAt: '2026-10-13T00:00:00.000Z',
- messageCount: 2,
- totalTokens: 0,
- previewMessages: [],
- queuedMessageCount: 0,
- subagentTranscriptCount: 0,
- resumeCommand: '',
- subagent: null
- }
-}
-
function dialogSearch(): HTMLInputElement {
return within(screen.getByRole('dialog')).getByLabelText('Search sessions')
}
@@ -176,23 +150,6 @@ describe('Session History dialog', () => {
expect(composer).not.toHaveFocus()
})
- it("opens on the chat's workspace with the search filled; Escape clears, then closes", async () => {
- render()
- const composer = screen.getByLabelText('Composer')
- composer.focus()
- openHistory('auth')
- await waitFor(() => expect(dialogSearch()).toHaveFocus())
- expect(dialogSearch().value).toBe('auth')
- const chatRequest = resolveAiVaultPanelSessionListRequest(useAppStore.getState(), CHAT_WORKTREE)
- expect(mocks.scopePaths.at(-1)).toEqual(chatRequest.scopePaths)
-
- fireEvent.keyDown(dialogSearch(), { key: 'Escape' })
- expect(dialogSearch().value).toBe('')
- fireEvent.keyDown(dialogSearch(), { key: 'Escape' })
- expect(useAppStore.getState().activeModal).toBe('none')
- await waitFor(() => expect(composer).toHaveFocus())
- })
-
it("keeps its search apart from the sidebar's and leaves Settings' request to the sidebar", async () => {
render()
const sidebarSearch = within(screen.getByTestId('sidebar')).getByLabelText(
@@ -210,16 +167,4 @@ describe('Session History dialog', () => {
).toBeInTheDocument()
expect(useAppStore.getState().aiVaultSearchFocusRequested).toBe(false)
})
-
- it("starts on the chat's agent without touching the sidebar's saved filter", () => {
- mocks.sessions = [chatSession('claude'), chatSession('codex')]
- window.localStorage.removeItem(AI_VAULT_VIEW_OPTIONS_STORAGE_KEY)
- render()
- openHistory('', 'claude')
-
- const dialog = within(screen.getByRole('dialog'))
- expect(dialog.getByText('claude-chat')).toBeInTheDocument()
- expect(dialog.queryByText('codex-chat')).toBeNull()
- expect(window.localStorage.getItem(AI_VAULT_VIEW_OPTIONS_STORAGE_KEY)).toBeNull()
- })
})
diff --git a/src/renderer/src/components/right-sidebar/ai-vault/session-list/AiVaultSessionRow.structured-title.test.tsx b/src/renderer/src/components/right-sidebar/ai-vault/session-list/AiVaultSessionRow.structured-title.test.tsx
index ba1b3fc4358..27e913796b2 100644
--- a/src/renderer/src/components/right-sidebar/ai-vault/session-list/AiVaultSessionRow.structured-title.test.tsx
+++ b/src/renderer/src/components/right-sidebar/ai-vault/session-list/AiVaultSessionRow.structured-title.test.tsx
@@ -4,11 +4,9 @@ import { act, cleanup, render, screen } from '@testing-library/react'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import type { AgentSessionStatusEvent } from '../../../../../../shared/agent-session/agent-session-wire'
import type { AiVaultSession } from '../../../../../../shared/ai-vault/contracts/ai-vault-types'
-import type { AiVaultSearchHit } from '../../../../../../shared/ai-vault/search/ai-vault-search-types'
+
import type { ExecutionHostId } from '../../../../../../shared/execution-host'
import type { Tab } from '../../../../../../shared/tab-types'
-import { AGENT_SESSION_WORKSPACE_SLEEP_MARK_RUNTIME_CAPABILITY } from '../../../../../../shared/agent-session/agent-session-workspace-sleep'
-import { AGENT_SESSION_STATUS_FEED_RUNTIME_CAPABILITY } from '../../../../../../shared/agent-session/agent-session-attention-capabilities'
const mocks = vi.hoisted(() => ({ subscribe: vi.fn(), supports: vi.fn() }))
vi.mock('@/runtime/structured-agent-session-client', () => ({
@@ -26,7 +24,6 @@ import {
resetStructuredAgentSessionStatusFeedsForTests
} from '@/runtime/structured-agent-session-status-feed'
import { VaultSessionRow } from './AiVaultSessionRow'
-import { aiVaultSearchHitToSession } from '../search/ai-vault-search-session'
const initialState = useAppStore.getInitialState()
const emitters = new Map void>()
@@ -60,29 +57,6 @@ function row(host: ExecutionHostId = 'local', title = 'Codex Chat'): AiVaultSess
}
}
-function searchRow(): AiVaultSession {
- const hit: AiVaultSearchHit = {
- agent: 'codex',
- sessionId: 'provider-session',
- title: 'Codex Chat',
- cwd: '/folder',
- branch: null,
- updatedAt: null,
- messageCount: 1,
- score: 1,
- source: {
- presence: 'present',
- filePath: '/sessions/provider-session.jsonl'
- },
- evidence: null,
- structuredSession: {
- workspaceId: 'folder-workspace',
- sessionId: 'native-session'
- }
- }
- return aiVaultSearchHitToSession(hit, 'local')
-}
-
function tab(customLabel: string | null = null): Tab {
return {
id: 'native-tab',
@@ -189,50 +163,6 @@ describe('native chat names in Vault rows', () => {
expect(screen.queryByText('Codex Chat')).toBeNull()
})
- it.each([
- ['list', row],
- ['search', searchRow]
- ])(
- 'lets a manual tab rename win in a %s row, and returns to the name once cleared',
- async (_kind, make) => {
- useAppStore.setState({
- unifiedTabsByWorktree: { 'folder-workspace': [tab('Manual name')] }
- })
- await renderRow(make())
- publish('local', 'Explain the parser')
- expect(screen.getByText('Manual name')).toBeTruthy()
- act(() =>
- useAppStore.setState({
- unifiedTabsByWorktree: { 'folder-workspace': [tab()] }
- })
- )
- expect(screen.getByText('Explain the parser')).toBeTruthy()
- }
- )
-
- it.each(['constructor', '__proto__'])(
- 'renders a paired row whose workspace id names an object member (%s)',
- async (workspaceId) => {
- await renderRow({
- ...row('local', 'Host row title'),
- structuredSession: { workspaceId, sessionId: 'native-session' }
- })
- expect(screen.getByText('Host row title')).toBeTruthy()
- }
- )
-
- it('ignores a published name no record store would hold', async () => {
- await renderRow(row('local', 'Host row title'))
- publish('local', 'x'.repeat(201))
- expect(screen.getByText('Host row title')).toBeTruthy()
- })
-
- it('keeps the host row title for a chat the feed has not named, as after a restart', async () => {
- await renderRow(row('local', 'Named before restart'))
- publish('local')
- expect(screen.getByText('Named before restart')).toBeTruthy()
- })
-
it('never shows a name another host published for the same session id', async () => {
mocks.supports.mockResolvedValue(true)
const releaseLocal = getStructuredAgentSessionStatusFeed({
@@ -246,19 +176,4 @@ describe('native chat names in Vault rows', () => {
expect(screen.queryByText('Local chat name')).toBeNull()
releaseLocal()
})
-
- it('keeps the host row title from an older paired host without probing it again', async () => {
- mocks.supports.mockResolvedValue(false)
- vi.spyOn(console, 'warn').mockImplementation(() => {})
- await renderRow(row('runtime:older', 'Saved by older host'))
- await act(async () => {
- await vi.advanceTimersByTimeAsync(60_000)
- })
- expect(screen.getByText('Saved by older host')).toBeTruthy()
- expect(mocks.supports.mock.calls).toEqual([
- ['older', AGENT_SESSION_STATUS_FEED_RUNTIME_CAPABILITY],
- ['older', AGENT_SESSION_WORKSPACE_SLEEP_MARK_RUNTIME_CAPABILITY]
- ])
- expect(mocks.subscribe).not.toHaveBeenCalled()
- })
})
diff --git a/src/renderer/src/components/right-sidebar/ai-vault/session-list/AiVaultSessionRow.test.tsx b/src/renderer/src/components/right-sidebar/ai-vault/session-list/AiVaultSessionRow.test.tsx
index 5c34fc626a9..a0378d9bfcc 100644
--- a/src/renderer/src/components/right-sidebar/ai-vault/session-list/AiVaultSessionRow.test.tsx
+++ b/src/renderer/src/components/right-sidebar/ai-vault/session-list/AiVaultSessionRow.test.tsx
@@ -1,23 +1,17 @@
// @vitest-environment happy-dom
-import { act, cleanup, fireEvent, render, screen, within } from '@testing-library/react'
+import { cleanup, fireEvent, render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { TooltipProvider } from '@/components/ui/tooltip'
import type { AiVaultSession } from '../../../../../../shared/ai-vault/contracts/ai-vault-types'
import type { AiVaultSessionWorktreeInfo } from '../../../../../../shared/ai-vault/session-display/ai-vault-session-worktree'
-import { searchHit } from '../../../../../../shared/ai-vault/search/ai-vault-search-test-fixture'
import type { AiVaultSearchHit } from '../../../../../../shared/ai-vault/search/ai-vault-search-types'
import type { AiVaultSubagentResumeActions } from './AiVaultSessionSubagents'
-import { findAiVaultSessionLiveState } from '../session-actions/ai-vault-original-pane'
+
import { VaultSessionRow } from './AiVaultSessionRow'
import type { AgentDotState } from '@/components/AgentStateDot'
-import type { AgentStatusEntry } from '../../../../../../shared/agent-status/contracts/agent-status-types'
-import {
- buildAiVaultOriginalPaneIndex,
- findAiVaultSessionLiveStateInIndex
-} from '../session-actions/ai-vault-original-pane-index'
const session = {
id: 'local:gemini:sess-1:/home/a/.gemini/s.json',
@@ -42,12 +36,6 @@ const session = {
subagent: null
} as unknown as AiVaultSession
-const worktreeInfo: AiVaultSessionWorktreeInfo = {
- status: 'active',
- label: 'feature-branch',
- path: '/home/a/worktrees/feature-branch'
-}
-
beforeEach(() => {
// Expanded details read first-prompt/subagent APIs during render/mount.
;(window as unknown as { api: unknown }).api = {
@@ -115,79 +103,6 @@ function renderRow(
)
}
-it.each([true, false])(
- 'renders the selected pane status through the %s provider lookup',
- (direct) => {
- const selectedSession = { ...session, title: 'Monitor the background job until it finishes' }
- const selected: AgentStatusEntry = {
- paneKey: 'tab:leaf',
- state: 'working',
- workingMode: 'monitoring',
- agentType: session.agent,
- prompt: selectedSession.title,
- updatedAt: 100,
- stateStartedAt: 100,
- stateHistory: [],
- ...(direct ? { providerSession: { key: 'session_id', id: session.sessionId } } : {})
- }
- const lookup = (entries: AgentStatusEntry[]) => {
- const state = {
- agentStatusByPaneKey: Object.fromEntries(entries.map((entry, i) => [String(i), entry])),
- retainedAgentsByPaneKey: {},
- sleepingAgentSessionsByPaneKey: {},
- tabsByWorktree: {},
- terminalLayoutsByTabId: {}
- }
- const indexed = findAiVaultSessionLiveStateInIndex(
- buildAiVaultOriginalPaneIndex(state),
- selectedSession
- )
- expect(findAiVaultSessionLiveState(state, selectedSession)).toBe(indexed)
- return indexed
- }
- renderRow({ liveState: lookup([selected]) })
- expect(screen.getByLabelText('Monitoring background tasks')).toBeTruthy()
- cleanup()
- renderRow({ liveState: lookup([{ ...selected, workingMode: undefined }]) })
- expect(screen.getByLabelText('Working')).toBeTruthy()
- cleanup()
- renderRow({
- liveState: lookup([{ ...selected, state: 'done', workingMode: undefined, interrupted: true }])
- })
- expect(screen.getByLabelText('Interrupted')).toBeTruthy()
- for (const [outcome, label] of [
- ['failure', 'Failed'],
- ['unconfirmed', 'Couldn’t confirm']
- ] as const) {
- cleanup()
- renderRow({
- liveState: lookup([
- {
- ...selected,
- state: 'done',
- workingMode: undefined,
- mainAgent: { state: 'done', outcome, stateStartedAt: 100 }
- }
- ])
- })
- expect(screen.getByLabelText(label)).toBeTruthy()
- }
- cleanup()
- renderRow({ liveState: lookup([{ ...selected, state: 'done', workingMode: undefined }]) })
- expect(screen.queryByLabelText('Done')).toBeNull()
- if (!direct) {
- expect(lookup([selected, selected])).toBeNull()
- }
- }
-)
-
-function expectAgentIdentity(): void {
- const metadata = screen.getByTestId('ai-vault-session-metadata')
- expect(metadata.querySelector('svg, img')).toBeTruthy()
- expect(within(metadata).getByText('Gemini')).toBeTruthy()
- expect(within(metadata).getByText('2 msgs')).toBeTruthy()
-}
-
describe('VaultSessionRow details toggle', () => {
it('does not expand the row when a menu action is chosen', async () => {
// Portaled menu clicks still bubble through React; Delete must not expand the row behind its dialog.
@@ -202,19 +117,6 @@ describe('VaultSessionRow details toggle', () => {
expect(onRequestDelete).toHaveBeenCalledTimes(1)
expect(onToggleDetails).not.toHaveBeenCalled()
})
-
- it('still expands when the row itself is clicked', async () => {
- const onToggleDetails = vi.fn()
- const { container } = renderRow({ onToggleDetails })
- const user = userEvent.setup()
-
- // Pick the first title because Radix asChild repeats the subtree; its click must reach the row body.
- const title = container.querySelector('[title="Drag to resume in a new tab"]')
- expect(title).not.toBeNull()
- await user.click(title as Element)
-
- expect(onToggleDetails).toHaveBeenCalledTimes(1)
- })
})
describe('VaultSessionRow in the /resume picker', () => {
@@ -260,101 +162,3 @@ describe('VaultSessionRow in the /resume picker', () => {
expect(onToggleDetails).toHaveBeenCalledOnce()
})
})
-
-describe('VaultSessionRow native session actions', () => {
- it('shows the jump action instead of Resume for an open structured session', async () => {
- const onJumpToOriginalPane = vi.fn()
- const onResume = vi.fn()
- renderRow({ resumeHidden: true, onJumpToOriginalPane, onResume })
-
- expect(screen.queryByTestId('ai-vault-session-resume')).toBeNull()
- fireEvent.click(screen.getByTestId('ai-vault-session-jump-original-pane'))
-
- expect(onJumpToOriginalPane).toHaveBeenCalledOnce()
- expect(onResume).not.toHaveBeenCalled()
-
- const user = userEvent.setup()
- await user.click(screen.getByTestId('ai-vault-session-more-actions'))
- expect(await screen.findByRole('menuitem', { name: 'Jump to Original Pane' })).toBeTruthy()
- expect(screen.queryByRole('menuitem', { name: 'Resume in New Tab' })).toBeNull()
- })
-
- it('hides Delete for structured native sessions', async () => {
- const nativeSession = {
- ...session,
- structuredSession: { sessionId: 'native-1', workspaceId: 'workspace-1' }
- }
-
- renderRow({ session: nativeSession })
- const user = userEvent.setup()
- await user.click(screen.getByTestId('ai-vault-session-more-actions'))
-
- expect(screen.queryByRole('menuitem', { name: 'Delete' })).toBeNull()
- })
-})
-
-describe('VaultSessionRow agent metadata line', () => {
- it('shows the agent identity when the row is collapsed', () => {
- renderRow()
-
- expectAgentIdentity()
- expect(screen.getByText(': Ready when you are')).toBeTruthy()
- })
-
- it('keeps the agent identity visible while the row is expanded', () => {
- renderRow({ detailsExpanded: true })
-
- expectAgentIdentity()
- expect(screen.getByText('Latest turns')).toBeTruthy()
- expect(screen.queryByText(': Ready when you are')).toBeNull()
- })
-
- it('renders the worktree badge once when expanded', () => {
- const { container } = renderRow({ detailsExpanded: true, worktreeInfo })
-
- expect(container.querySelectorAll(`[title="${worktreeInfo.label}"]`)).toHaveLength(1)
- })
-})
-
-it('keeps matching evidence visible in expanded search rows', () => {
- const { container } = renderRow({ detailsExpanded: true, searchHit: searchHit() })
- expect(container.querySelector('mark')?.textContent).toBe('needle')
-})
-
-it('threads child resume through expanded parent details without resuming the parent', async () => {
- const child: AiVaultSession = {
- ...session,
- agent: 'omp',
- sessionId: 'child',
- filePath: '/tmp/parent/worker.jsonl',
- title: 'OMP worker',
- subagent: { parentSessionId: 'parent', agentType: 'worker', status: 'completed' }
- }
- vi.mocked(window.api.aiVault.listSubagentSessions).mockResolvedValue({
- sessions: [child],
- issues: []
- })
- const resume = {
- getState: vi.fn(() => ({
- blocked: false,
- worktreeId: 'folder:target',
- usesSessionWorktree: false
- })),
- onResume: vi.fn()
- }
- renderRow({
- session: {
- ...session,
- agent: 'omp',
- sessionId: 'parent',
- messageCount: 0,
- previewMessages: [],
- subagentTranscriptCount: 1
- },
- detailsExpanded: true,
- subagentResume: resume
- })
- await act(async () => {})
- fireEvent.click(screen.getByTitle('Resume in New Tab'))
- expect(resume.onResume).toHaveBeenCalledExactlyOnceWith(child, 'folder:target')
-})
diff --git a/src/renderer/src/components/right-sidebar/ai-vault/session-list/AiVaultSessionSubagents.test.tsx b/src/renderer/src/components/right-sidebar/ai-vault/session-list/AiVaultSessionSubagents.test.tsx
index 5bd4ab837bf..1a4e0f96511 100644
--- a/src/renderer/src/components/right-sidebar/ai-vault/session-list/AiVaultSessionSubagents.test.tsx
+++ b/src/renderer/src/components/right-sidebar/ai-vault/session-list/AiVaultSessionSubagents.test.tsx
@@ -3,9 +3,7 @@
import type { ComponentProps, JSX } from 'react'
import { act, cleanup, fireEvent, render } from '@testing-library/react'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
-import { SubagentExpansionProvider } from './ai-vault-subagent-expansion'
-import { useAppStore } from '@/store/index'
-import { createEditorStore } from '@/store/slices/editor-slice-test-harness'
+
import { TooltipProvider } from '@/components/ui/tooltip'
import type {
AiVaultSession,
@@ -76,27 +74,6 @@ function makeSubagent(title: string): AiVaultSession {
}
describe('SessionSubagentsSection', () => {
- it('opens the selected child through its View Log button', async () => {
- const child = { ...makeSubagent('Worker'), agent: 'omp' as const }
- const store = createEditorStore()
- vi.spyOn(useAppStore, 'getState').mockImplementation(store.getState)
- listSubagentSessions.mockResolvedValueOnce({ sessions: [child], issues: [] })
- const view = render()
- await act(async () => {})
-
- fireEvent.click(view.getByTitle('View Log'))
-
- expect(store.getState().openFiles).toEqual([
- expect.objectContaining({
- filePath: child.filePath,
- relativePath: child.filePath,
- readOnly: true,
- liveTail: true,
- runtimeEnvironmentId: null
- })
- ])
- })
-
it('keeps the loaded list visible while a rescan-triggered refetch is in flight', async () => {
listSubagentSessions.mockResolvedValueOnce({
sessions: [makeSubagent('First pass')],
@@ -124,92 +101,6 @@ describe('SessionSubagentsSection', () => {
expect(queryByText('Second pass')).not.toBeNull()
expect(queryByText('First pass')).toBeNull()
})
-
- it('labels the subagent run state exactly once, on the dot itself', async () => {
- listSubagentSessions.mockResolvedValueOnce({
- sessions: [makeSubagent('Running task')],
- issues: []
- })
- const { container } = render()
- await act(async () => {})
-
- const titles = [...container.querySelectorAll('[title]')].map((element) =>
- element.getAttribute('title')
- )
-
- expect(titles).toEqual(['Running task', 'View Log'])
- expect(container.querySelector('[data-slot="tooltip-trigger"]')).not.toBeNull()
- })
-
- it('does not fetch for remote sessions even when the scan counted transcripts', async () => {
- const { container } = render(
-
- )
- await act(async () => {})
- expect(listSubagentSessions).not.toHaveBeenCalled()
- expect(container.firstChild).toBeNull()
- })
-})
-
-describe('independent child resume', () => {
- const child = makeSession({
- agent: 'omp',
- sessionId: 'child-id',
- filePath: '/repo/session/tasks/worker.jsonl',
- subagent: { parentSessionId: 'parent-session', agentType: 'worker', status: 'completed' },
- subagentTranscriptCount: 0
- })
- it('passes the complete child and its resolved folder target to resume', async () => {
- listSubagentSessions.mockResolvedValue({ sessions: [child], issues: [] })
- const resume = {
- getState: vi.fn(() => ({
- blocked: false,
- worktreeId: 'folder:repo',
- usesSessionWorktree: true
- })),
- onResume: vi.fn()
- }
- const { getByRole } = render(
-
- )
- await act(async () => {})
- fireEvent.click(getByRole('button', { name: 'Resume in Folder' }))
- expect(resume.getState).toHaveBeenCalledWith(child)
- expect(resume.onResume).toHaveBeenCalledExactlyOnceWith(child, 'folder:repo')
- })
- it.each([
- { agent: 'claude' as const },
- { sessionId: 'parent-session' },
- { sessionId: '' },
- { filePath: '' },
- { messageCount: 0, previewMessages: [] }
- ])('withholds resume for a non-independent or empty child %j', async (overrides) => {
- listSubagentSessions.mockResolvedValue({ sessions: [{ ...child, ...overrides }], issues: [] })
- const resume = { getState: vi.fn(), onResume: vi.fn() }
- const { queryByRole } = render(
-
- )
- await act(async () => {})
- expect(queryByRole('button', { name: /Resume/ })).toBeNull()
- expect(resume.getState).not.toHaveBeenCalled()
- })
- it('disables resume when the existing target resolver blocks the child host', async () => {
- listSubagentSessions.mockResolvedValue({ sessions: [child], issues: [] })
- const resume = {
- getState: vi.fn(() => ({ blocked: true, worktreeId: null, usesSessionWorktree: false })),
- onResume: vi.fn()
- }
- const { getByRole } = render(
-
- )
- await act(async () => {})
- const button = getByRole('button', { name: 'Resume in New Tab' })
- expect(button.hasAttribute('disabled')).toBe(true)
- fireEvent.click(button)
- expect(resume.onResume).not.toHaveBeenCalled()
- })
})
describe('nested OMP history', () => {
@@ -222,46 +113,6 @@ describe('nested OMP history', () => {
}
const grandchild = { ...makeSubagent('Research'), agent: 'omp' as const, sessionId: 'research' }
- it('loads only opened branches and targets the grandchild when resuming', async () => {
- listSubagentSessions
- .mockResolvedValueOnce({ sessions: [child, makeSubagent('Sibling')], issues: [] })
- .mockResolvedValueOnce({ sessions: [grandchild], issues: [] })
- const resume = {
- getState: vi.fn(() => ({
- blocked: false,
- worktreeId: 'folder:repo',
- usesSessionWorktree: true
- })),
- onResume: vi.fn()
- }
- const view = render()
- await act(async () => {})
- expect(listSubagentSessions).toHaveBeenCalledTimes(1)
- expect(view.queryByText('Research')).toBeNull()
- fireEvent.click(view.getByRole('button', { name: 'Subagents (1)' }))
- await act(async () => {})
- expect(listSubagentSessions).toHaveBeenLastCalledWith({
- agent: 'omp',
- executionHostId: 'local',
- parentFilePath: child.filePath
- })
- expect(view.queryByText('Research')).not.toBeNull()
- fireEvent.click(view.getAllByRole('button', { name: 'Resume in Folder' })[1])
- expect(resume.onResume).toHaveBeenCalledExactlyOnceWith(grandchild, 'folder:repo')
- })
-
- it('does not show another parent’s rows while its listing is pending', async () => {
- listSubagentSessions
- .mockResolvedValueOnce({ sessions: [child], issues: [] })
- .mockImplementationOnce(() => new Promise(() => {}))
- const view = render()
- await act(async () => {})
- view.rerender(
-
- )
- expect(view.queryByText('Worker')).toBeNull()
- })
-
it('ignores late nested results after collapse and refetches on reopen', async () => {
let resolveChild: (value: AiVaultSubagentListResult) => void = () => {}
listSubagentSessions
@@ -288,79 +139,6 @@ describe('nested OMP history', () => {
expect(listSubagentSessions).toHaveBeenCalledTimes(3)
})
- it('keeps cyclic and remote children from offering a disclosure', async () => {
- listSubagentSessions.mockResolvedValueOnce({
- sessions: [
- { ...child, filePath: parent.filePath },
- { ...child, id: 'remote', executionHostId: 'ssh:box' }
- ],
- issues: []
- })
- const view = render()
- await act(async () => {})
- expect(view.queryByRole('button', { name: 'Subagents (1)' })).toBeNull()
- expect(listSubagentSessions).toHaveBeenCalledTimes(1)
- })
-
- it('offers retry for a failed branch listing', async () => {
- listSubagentSessions
- .mockResolvedValueOnce({ sessions: [child], issues: [] })
- .mockRejectedValueOnce(new Error('offline'))
- .mockResolvedValueOnce({ sessions: [grandchild], issues: [] })
- const view = render()
- await act(async () => {})
- fireEvent.click(view.getByRole('button', { name: 'Subagents (1)' }))
- await act(async () => {})
- fireEvent.click(view.getByRole('button', { name: 'Retry' }))
- await act(async () => {})
- expect(view.queryByText('Research')).not.toBeNull()
- })
- it('retains expanded branches across a virtual row unmount and same-parent rescan', async () => {
- listSubagentSessions.mockImplementation(async (args) => ({
- sessions:
- typeof args === 'object' &&
- args !== null &&
- 'parentFilePath' in args &&
- args.parentFilePath === parent.filePath
- ? [child]
- : [grandchild],
- issues: []
- }))
- const fixture = (visible: boolean, modifiedAt = parent.modifiedAt) => (
-
- {visible ? : null}
-
- )
- const view = render(fixture(true))
- await act(async () => {})
- fireEvent.click(view.getByRole('button', { name: 'Subagents (1)' }))
- await act(async () => {})
- view.rerender(fixture(true, '2026-09-14T12:00:00Z'))
- await act(async () => {})
- expect(view.queryByText('Research')).not.toBeNull()
- view.rerender(fixture(false))
- view.rerender(fixture(true))
- await act(async () => {})
- expect(view.queryByText('Research')).not.toBeNull()
- })
-
- it('preserves readable rows when the WSL gate reports partial listing issues and allows retry', async () => {
- listSubagentSessions
- .mockResolvedValueOnce({
- sessions: [child],
- issues: [{ agent: 'omp', path: parent.filePath, message: 'WSL unavailable' }]
- })
- .mockResolvedValueOnce({ sessions: [], issues: [] })
- const view = render()
- await act(async () => {})
- expect(view.queryByText('Worker')).not.toBeNull()
- expect(view.queryByText('Could not load all subagents.')).not.toBeNull()
- fireEvent.click(view.getByRole('button', { name: 'Retry' }))
- await act(async () => {})
- expect(view.queryByText('No subagents found.')).not.toBeNull()
- expect(view.queryByText('Worker')).toBeNull()
- })
-
it('never accepts a late response from a replaced parent', async () => {
let finish: (value: AiVaultSubagentListResult) => void = () => {}
listSubagentSessions