mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
test: remove low-value permission status and WSL fixtures (#43394)
Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
This commit is contained in:
@@ -328,7 +328,6 @@
|
||||
2 test-no-wall-clock:src/main/agent-hooks/installation/scripts/managed-hook-timeout.test.ts
|
||||
1 test-no-wall-clock:src/main/agent-hooks/server/testing/http/server-endpoint-file-lifecycle.test.ts
|
||||
3 test-no-wall-clock:src/main/agent-hooks/server/testing/replay/spool.test.ts
|
||||
3 test-no-wall-clock:src/main/agent-hooks/server/testing/structured-ingress/server-ingest-structured-status.test.ts
|
||||
2 test-no-wall-clock:src/main/ai-vault/scanners/cursor/session-scanner-cursor-chat-meta.test.ts
|
||||
1 test-no-wall-clock:src/main/ai-vault/scanners/devin/session-scanner-devin-db.test.ts
|
||||
1 test-no-wall-clock:src/main/ai-vault/scanners/opencode/reader-transport/session-scanner-opencode-sqlite-process.test.ts
|
||||
|
||||
@@ -416,7 +416,6 @@
|
||||
"src/main/agent-hooks/server/testing/authority/server-pane-authority.test.ts": 762,
|
||||
"src/main/agent-hooks/server/testing/telemetry/server-prompt-sent-telemetry.test.ts": 701,
|
||||
"src/main/agent-hooks/server/testing/interruptions/server-relayed-claude-cancel.test.ts": 901,
|
||||
"src/main/agent-hooks/server/testing/replay/server-relayed-claude-permission-replay.test.ts": 758,
|
||||
"src/main/agent-hooks/server/testing/authority/server-removed-worktree-foreign-authority.test.ts": 764,
|
||||
"src/main/agent-hooks/server/testing/http/server-startup-lifecycle.test.ts": 718,
|
||||
"src/main/agent-hooks/server/testing/http/server-startup-prompt-control.test.ts": 697,
|
||||
@@ -435,7 +434,6 @@
|
||||
"src/main/agent-hooks/installation/commands/windows-powershell-hook-launcher.test.ts": 44,
|
||||
"src/main/agent-hooks/wsl-relay/testing/wsl-hook-relay-live.integration.test.ts": 2231,
|
||||
"src/main/agent-hooks/wsl-relay/wsl-hook-relay-sentinel.test.ts": 62,
|
||||
"src/main/agent-hooks/wsl-relay/wsl-opencode-settings-lifetime.test.ts": 1951,
|
||||
"src/main/agent-launch/agent-launch-executor-cancel.test.ts": 1455,
|
||||
"src/main/agent-launch/agent-launch-mode-settings.test.ts": 4041,
|
||||
"src/main/codex/configuration/agent-state-file-reader.test.ts": 93,
|
||||
|
||||
-126
@@ -89,132 +89,6 @@ describe('Claude permission wait that Claude denies itself', () => {
|
||||
expect(states.at(-1)).toBe('PostToolBatch:waiting')
|
||||
})
|
||||
|
||||
it("keeps the pane waiting when one subagent's request ends while another's prompt is open", async () => {
|
||||
const childA = { agent_id: 'agent-a', agent_type: 'general-purpose' }
|
||||
const childB = { agent_id: 'agent-b', agent_type: 'general-purpose' }
|
||||
const commandA = { command: 'touch /private/tmp/orca-permcap-a' }
|
||||
const commandB = { command: 'touch /private/tmp/orca-permcap-b' }
|
||||
const states = await replay([
|
||||
{ hook_event_name: 'UserPromptSubmit', prompt: 'work' },
|
||||
{ hook_event_name: 'SubagentStart', ...childA },
|
||||
{ hook_event_name: 'SubagentStart', ...childB },
|
||||
{
|
||||
hook_event_name: 'PreToolUse',
|
||||
tool_name: 'Bash',
|
||||
tool_input: commandA,
|
||||
tool_use_id: 'toolu-a',
|
||||
...childA
|
||||
},
|
||||
{ hook_event_name: 'PermissionRequest', tool_name: 'Bash', tool_input: commandA, ...childA },
|
||||
{
|
||||
hook_event_name: 'PreToolUse',
|
||||
tool_name: 'Bash',
|
||||
tool_input: commandB,
|
||||
tool_use_id: 'toolu-b',
|
||||
...childB
|
||||
},
|
||||
{ hook_event_name: 'PermissionRequest', tool_name: 'Bash', tool_input: commandB, ...childB },
|
||||
{
|
||||
hook_event_name: 'PostToolBatch',
|
||||
tool_calls: [{ tool_name: 'Bash', tool_input: commandB, tool_use_id: 'toolu-b' }],
|
||||
...childB
|
||||
}
|
||||
])
|
||||
expect(states.at(-1)).toBe('PostToolBatch:waiting')
|
||||
})
|
||||
|
||||
it("keeps the pane waiting on the lead's unanswered question when a subagent's request ends", async () => {
|
||||
const child = { agent_id: 'agent-child', agent_type: 'general-purpose' }
|
||||
const command = { command: 'touch /private/tmp/orca-permcap-q' }
|
||||
const question = { questions: [{ question: 'Which file?', options: [{ label: 'a' }] }] }
|
||||
const states = await replay([
|
||||
{ hook_event_name: 'UserPromptSubmit', prompt: 'work' },
|
||||
{
|
||||
hook_event_name: 'PreToolUse',
|
||||
tool_name: 'AskUserQuestion',
|
||||
tool_input: question,
|
||||
tool_use_id: 'toolu-q'
|
||||
},
|
||||
{
|
||||
hook_event_name: 'PreToolUse',
|
||||
tool_name: 'Bash',
|
||||
tool_input: command,
|
||||
tool_use_id: 'toolu-b',
|
||||
...child
|
||||
},
|
||||
{ hook_event_name: 'PermissionRequest', tool_name: 'Bash', tool_input: command, ...child },
|
||||
{
|
||||
hook_event_name: 'PostToolBatch',
|
||||
tool_calls: [{ tool_name: 'Bash', tool_input: command, tool_use_id: 'toolu-b' }],
|
||||
...child
|
||||
}
|
||||
])
|
||||
// The card shows the newest prompt, as on main; showing each open prompt's card is the follow-up.
|
||||
expect(states.at(-1)).toBe('PostToolBatch:waiting')
|
||||
})
|
||||
|
||||
it("keeps an open MCP dialog when a subagent's self-denied request ends", async () => {
|
||||
const child = { agent_id: 'agent-a', agent_type: 'general-purpose' }
|
||||
const command = { command: 'touch /private/tmp/orca-permcap-mcp' }
|
||||
const dialog = { mcp_server_name: 'srv', elicitation_id: 'elicit-1' }
|
||||
const childRequest = [
|
||||
{
|
||||
hook_event_name: 'PreToolUse',
|
||||
tool_name: 'Bash',
|
||||
tool_input: command,
|
||||
tool_use_id: 'toolu-a',
|
||||
...child
|
||||
},
|
||||
{ hook_event_name: 'PermissionRequest', tool_name: 'Bash', tool_input: command, ...child },
|
||||
{
|
||||
hook_event_name: 'PostToolBatch',
|
||||
tool_calls: [{ tool_name: 'Bash', tool_input: command, tool_use_id: 'toolu-a' }],
|
||||
...child
|
||||
}
|
||||
]
|
||||
const states = await replay([
|
||||
{ hook_event_name: 'UserPromptSubmit', prompt: 'work' },
|
||||
{ hook_event_name: 'SubagentStart', ...child },
|
||||
{ hook_event_name: 'Elicitation', mode: 'form', ...dialog },
|
||||
...childRequest,
|
||||
{
|
||||
hook_event_name: 'PreToolUse',
|
||||
tool_name: 'Bash',
|
||||
tool_input: { command: 'ls' },
|
||||
tool_use_id: 'toolu-ls'
|
||||
}
|
||||
])
|
||||
expect(states.slice(-2)).toEqual(['PostToolBatch:waiting', 'PreToolUse:waiting'])
|
||||
})
|
||||
|
||||
it("keeps a request whose call was never seen when another subagent's request ends", async () => {
|
||||
const childA = { agent_id: 'agent-a', agent_type: 'general-purpose' }
|
||||
const childB = { agent_id: 'agent-b', agent_type: 'general-purpose' }
|
||||
const commandB = { command: 'touch /private/tmp/orca-permcap-b' }
|
||||
const states = await replay([
|
||||
{
|
||||
hook_event_name: 'PermissionRequest',
|
||||
tool_name: 'Bash',
|
||||
tool_input: { command: 'touch /private/tmp/orca-permcap-a' },
|
||||
...childA
|
||||
},
|
||||
{
|
||||
hook_event_name: 'PreToolUse',
|
||||
tool_name: 'Bash',
|
||||
tool_input: commandB,
|
||||
tool_use_id: 'toolu-b',
|
||||
...childB
|
||||
},
|
||||
{ hook_event_name: 'PermissionRequest', tool_name: 'Bash', tool_input: commandB, ...childB },
|
||||
{
|
||||
hook_event_name: 'PostToolBatch',
|
||||
tool_calls: [{ tool_name: 'Bash', tool_input: commandB, tool_use_id: 'toolu-b' }],
|
||||
...childB
|
||||
}
|
||||
])
|
||||
expect(states.at(-1)).toBe('PostToolBatch:waiting')
|
||||
})
|
||||
|
||||
it('keeps a newer prompt when an earlier batch from the same agent arrives late', async () => {
|
||||
const command = { command: 'touch /private/tmp/orca-permcap-newer' }
|
||||
const states = await replay([
|
||||
|
||||
-192
@@ -1,192 +0,0 @@
|
||||
// Replay captured SSH permission hooks; single-row relay caching can hide the resolving event during disconnect.
|
||||
import { mkdtempSync, rmSync } from 'node:fs'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { RelayAgentHookServer } from '../../../../../wsl-guest/agent-hooks/server/agent-hook-server'
|
||||
import type { AgentHookRelayEnvelope } from '../../../../../shared/agent-hook-listener/transport/agent-hook-relay'
|
||||
import { AgentHookServer, _internals } from '../../agent-hook-server'
|
||||
import { buildBody, PANE } from '../server.test-fixtures'
|
||||
import { hookAt, loadCapture } from '../interruptions/claude-cancel-capture.test-fixture'
|
||||
import selfDenied from '../../../../claude/__fixtures__/claude-self-denied-permission-hooks.json'
|
||||
|
||||
const { getCohortAtEmitMock, trackMock } = vi.hoisted(() => ({
|
||||
getCohortAtEmitMock: vi.fn(),
|
||||
trackMock: vi.fn()
|
||||
}))
|
||||
|
||||
vi.mock('../../../../telemetry/client', () => ({ track: trackMock }))
|
||||
vi.mock('../../../../telemetry/cohort-classifier', () => ({ getCohortAtEmit: getCohortAtEmitMock }))
|
||||
|
||||
const records = loadCapture('claude-permission-approve-deny-hooks')
|
||||
const prompt = hookAt(records, 0).payload
|
||||
const firstTool = hookAt(records, 1).payload
|
||||
const firstPermission = hookAt(records, 2).payload
|
||||
const firstNotification = hookAt(records, 3).payload
|
||||
const firstToolDone = hookAt(records, 4).payload
|
||||
const secondTool = hookAt(records, 5).payload
|
||||
|
||||
const temporaryPaths: string[] = []
|
||||
const running: { stop: () => void }[] = []
|
||||
|
||||
beforeEach(() => {
|
||||
_internals.resetCachesForTests()
|
||||
trackMock.mockReset()
|
||||
getCohortAtEmitMock.mockReset()
|
||||
getCohortAtEmitMock.mockReturnValue({ nth_repo_added: 2 })
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
for (const server of running.splice(0)) {
|
||||
server.stop()
|
||||
}
|
||||
for (const path of temporaryPaths.splice(0)) {
|
||||
rmSync(path, { recursive: true, force: true })
|
||||
}
|
||||
vi.restoreAllMocks()
|
||||
})
|
||||
|
||||
type SshPane = {
|
||||
relay: RelayAgentHookServer
|
||||
desktop: AgentHookServer
|
||||
connected: boolean
|
||||
forwarded: AgentHookRelayEnvelope[]
|
||||
post: (payload: Record<string, unknown>) => Promise<void>
|
||||
}
|
||||
|
||||
async function startSshPane(): Promise<SshPane> {
|
||||
const endpointDir = mkdtempSync(join(tmpdir(), 'orca-relayed-permission-'))
|
||||
temporaryPaths.push(endpointDir)
|
||||
const pane: SshPane = {
|
||||
desktop: new AgentHookServer(),
|
||||
connected: true,
|
||||
forwarded: [],
|
||||
relay: new RelayAgentHookServer({
|
||||
endpointDir,
|
||||
token: 'relayed-permission-token',
|
||||
forward: (envelope) => {
|
||||
pane.forwarded.push(envelope)
|
||||
if (pane.connected) {
|
||||
pane.desktop.ingestRemote(envelope, 'conn-1')
|
||||
}
|
||||
}
|
||||
}),
|
||||
post: async (payload) => {
|
||||
const { port, token } = pane.relay.getCoordinates()
|
||||
const response = await fetch(`http://127.0.0.1:${port}/hook/claude`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', 'X-Orca-Agent-Hook-Token': token },
|
||||
body: JSON.stringify(buildBody(payload))
|
||||
})
|
||||
expect(response.status).toBe(204)
|
||||
}
|
||||
}
|
||||
running.push(pane.relay, pane.desktop)
|
||||
await pane.relay.start({ publishEndpoint: false })
|
||||
return pane
|
||||
}
|
||||
|
||||
async function postAll(pane: SshPane, payloads: Record<string, unknown>[]): Promise<void> {
|
||||
for (const payload of payloads) {
|
||||
await pane.post(payload)
|
||||
}
|
||||
}
|
||||
|
||||
function row(server: AgentHookServer) {
|
||||
const entry = server.getStatusSnapshotForPane(PANE)[0]
|
||||
if (!entry) {
|
||||
throw new Error('the pane has no row')
|
||||
}
|
||||
return entry
|
||||
}
|
||||
|
||||
async function waitingOnFirstRequest(): Promise<SshPane> {
|
||||
const pane = await startSshPane()
|
||||
await postAll(pane, [prompt, firstTool, firstPermission, firstNotification])
|
||||
expect(row(pane.desktop)).toMatchObject({ state: 'waiting', toolName: 'Bash' })
|
||||
return pane
|
||||
}
|
||||
|
||||
function reconnect(pane: SshPane): void {
|
||||
pane.connected = true
|
||||
pane.relay.replayCachedPayloadsForPanes()
|
||||
}
|
||||
|
||||
describe('a relayed Claude permission wait across a reconnect (captured)', () => {
|
||||
it('clears on reconnect when the request ended while the desktop was away', async () => {
|
||||
const pane = await waitingOnFirstRequest()
|
||||
pane.connected = false
|
||||
await postAll(pane, [firstToolDone, secondTool])
|
||||
reconnect(pane)
|
||||
|
||||
expect(row(pane.desktop)).toMatchObject({ state: 'working', toolName: 'Bash' })
|
||||
expect(row(pane.desktop).toolInput).toContain('second-file.txt')
|
||||
const replay = pane.forwarded.at(-1)
|
||||
expect(replay).toMatchObject({
|
||||
isReplay: true,
|
||||
hookEventName: 'PreToolUse',
|
||||
claudeSettledRequests: [{ toolUseId: firstToolDone.tool_use_id }]
|
||||
})
|
||||
})
|
||||
|
||||
it('keeps the wait when the request the desktop shows has not ended', async () => {
|
||||
const pane = await waitingOnFirstRequest()
|
||||
pane.connected = false
|
||||
// A different tool's activity is not evidence that the pending request was answered.
|
||||
await postAll(pane, [
|
||||
{ ...firstToolDone, tool_use_id: 'toolu_other' },
|
||||
{ ...secondTool, tool_use_id: 'toolu_next' }
|
||||
])
|
||||
reconnect(pane)
|
||||
|
||||
expect(row(pane.desktop)).toMatchObject({ state: 'waiting' })
|
||||
expect(row(pane.desktop).toolInput).toContain('first-file.txt')
|
||||
})
|
||||
|
||||
it('ignores settled requests on a live (non-replay) envelope', async () => {
|
||||
const pane = await waitingOnFirstRequest()
|
||||
pane.connected = false
|
||||
await pane.post(secondTool)
|
||||
const live = pane.forwarded.at(-1)
|
||||
expect(live).toMatchObject({ hookEventName: 'PreToolUse' })
|
||||
expect(live?.isReplay).toBeUndefined()
|
||||
pane.connected = true
|
||||
pane.desktop.ingestRemote(
|
||||
{
|
||||
...live,
|
||||
paneKey: PANE,
|
||||
payload: live?.payload,
|
||||
claudeSettledRequests: [{ toolUseId: String(firstTool.tool_use_id) }]
|
||||
},
|
||||
'conn-1'
|
||||
)
|
||||
expect(row(pane.desktop)).toMatchObject({ state: 'waiting' })
|
||||
})
|
||||
})
|
||||
|
||||
describe.each([
|
||||
['lead', selfDenied.leadDenied],
|
||||
['subagent', selfDenied.childDenied]
|
||||
])('a relayed %s permission wait that Claude denies itself (captured)', (_owner, events) => {
|
||||
const permissionIndex = events.findIndex((event) => event.hook_event_name === 'PermissionRequest')
|
||||
const batchIndex = events.findIndex((event) => event.hook_event_name === 'PostToolBatch')
|
||||
const untilWait = events.slice(0, permissionIndex + 1)
|
||||
const untilBatch = events.slice(permissionIndex + 1, batchIndex + 1)
|
||||
|
||||
it('clears when its batch end arrives live', async () => {
|
||||
const pane = await startSshPane()
|
||||
await postAll(pane, untilWait)
|
||||
expect(row(pane.desktop)).toMatchObject({ state: 'waiting' })
|
||||
await postAll(pane, untilBatch)
|
||||
expect(row(pane.desktop)).toMatchObject({ state: 'working' })
|
||||
})
|
||||
|
||||
it('clears on reconnect when the batch ended it while the desktop was away', async () => {
|
||||
const pane = await startSshPane()
|
||||
await postAll(pane, untilWait)
|
||||
pane.connected = false
|
||||
await postAll(pane, [...untilBatch, events[batchIndex + 1]])
|
||||
reconnect(pane)
|
||||
expect(row(pane.desktop)).toMatchObject({ state: 'working' })
|
||||
})
|
||||
})
|
||||
@@ -4,11 +4,9 @@ import {
|
||||
mkdirSync,
|
||||
mkdtempSync,
|
||||
readFileSync,
|
||||
readdirSync,
|
||||
statSync,
|
||||
writeFileSync
|
||||
} from 'node:fs'
|
||||
import { execFileSync } from 'node:child_process'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import {
|
||||
@@ -19,7 +17,6 @@ import {
|
||||
} from '../../../../../shared/agent-hook-listener/transport/agent-hook-spool'
|
||||
import { AgentHookServer } from '../../agent-hook-server'
|
||||
|
||||
import { getManagedScript as getClaudeManagedScript } from '../../../../claude/hooks/hook-script'
|
||||
import { makePaneKey } from '../../../../../shared/workspace-layout/stable-pane-id'
|
||||
|
||||
describe('agent hook spool', () => {
|
||||
@@ -139,66 +136,4 @@ describe('agent hook spool', () => {
|
||||
second.stop()
|
||||
}
|
||||
})
|
||||
|
||||
it('keeps a Claude hook attributed when CLAUDE_CODE_SUBPROCESS_ENV_SCRUB drops the pane key', () => {
|
||||
const dir = mkdtempSync(join(tmpdir(), 'orca-spool-scrubbed-'))
|
||||
const endpointDir = join(dir, 'agent-hooks')
|
||||
mkdirSync(endpointDir, { recursive: true })
|
||||
const endpoint = join(endpointDir, 'endpoint.env')
|
||||
writeFileSync(endpoint, 'ORCA_AGENT_HOOK_PORT=9\nORCA_AGENT_HOOK_TOKEN=stale\n')
|
||||
const script = join(dir, 'claude-hook.sh')
|
||||
writeFileSync(script, getClaudeManagedScript('posix'))
|
||||
const env: NodeJS.ProcessEnv = {
|
||||
...process.env,
|
||||
ORCA_AGENT_HOOK_ENDPOINT: endpoint,
|
||||
ORCA_AGENT_PANE: 'tab-scrubbed:0',
|
||||
ORCA_AGENT_LAUNCH: 'generation-token'
|
||||
}
|
||||
// Claude's scrub removes every *KEY/*TOKEN name; only the scrub-safe aliases reach the hook.
|
||||
delete env.ORCA_PANE_KEY
|
||||
delete env.ORCA_AGENT_LAUNCH_TOKEN
|
||||
delete env.CLAUDE_JOB_DIR
|
||||
execFileSync('/bin/sh', [script], {
|
||||
input: '{"hook_event_name":"Stop","session_id":"claude-session"}\n',
|
||||
env,
|
||||
timeout: 5000
|
||||
})
|
||||
const spoolFiles = readdirSync(join(endpointDir, 'spool'))
|
||||
expect(spoolFiles).toHaveLength(1)
|
||||
const record: unknown = JSON.parse(
|
||||
readFileSync(join(endpointDir, 'spool', spoolFiles[0]!), 'utf8').trim()
|
||||
)
|
||||
expect(record).toMatchObject({ paneKey: 'tab-scrubbed:0', launchToken: 'generation-token' })
|
||||
})
|
||||
|
||||
it('never spools a Claude tool batch while the receiver is down, compact or spaced', () => {
|
||||
const dir = mkdtempSync(join(tmpdir(), 'orca-spool-batch-'))
|
||||
const endpointDir = join(dir, 'agent-hooks')
|
||||
mkdirSync(endpointDir, { recursive: true })
|
||||
const endpoint = join(endpointDir, 'endpoint.env')
|
||||
writeFileSync(endpoint, 'ORCA_AGENT_HOOK_PORT=9\nORCA_AGENT_HOOK_TOKEN=stale\n')
|
||||
const script = join(dir, 'claude-hook.sh')
|
||||
writeFileSync(script, getClaudeManagedScript('posix'))
|
||||
const run = (input: string) =>
|
||||
execFileSync('/bin/sh', [script], {
|
||||
input,
|
||||
env: {
|
||||
...process.env,
|
||||
ORCA_AGENT_HOOK_ENDPOINT: endpoint,
|
||||
ORCA_PANE_KEY: 'tab-batch:0',
|
||||
ORCA_AGENT_LAUNCH_TOKEN: 'generation-token',
|
||||
CLAUDE_JOB_DIR: ''
|
||||
},
|
||||
timeout: 5000
|
||||
})
|
||||
run('{"hook_event_name":"PostToolBatch","tool_calls":[{"tool_use_id":"toolu-a"}]}\n')
|
||||
run('{"hook_event_name": "PostToolBatch", "tool_calls": [{"tool_use_id": "toolu-b"}]}\n')
|
||||
run('{"hook_event_name":"Stop","session_id":"claude-session"}\n')
|
||||
const spoolDir = join(endpointDir, 'spool')
|
||||
const records = readdirSync(spoolDir).flatMap((file) =>
|
||||
readFileSync(join(spoolDir, file), 'utf8').trim().split('\n')
|
||||
)
|
||||
expect(records).toHaveLength(1)
|
||||
expect(records[0]).toContain('"Stop"')
|
||||
})
|
||||
})
|
||||
|
||||
+1
-128
@@ -1,12 +1,11 @@
|
||||
import { readSavedStatus } from '../persistence/last-status.test-fixtures'
|
||||
import { makeStructuredAgentStatusSubject } from '../../../../../shared/agent-status/contracts/agent-status-subject'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { mkdtempSync, rmSync, writeFileSync, mkdirSync } from 'node:fs'
|
||||
import { mkdtempSync, rmSync } from 'node:fs'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import type { AgentSessionStatusSummary } from '../../../../../shared/agent-session/agent-session-wire'
|
||||
import type { AgentChildWorkEvidence } from '../../../../../shared/agent-status/child-work/agent-status-child-work-evidence'
|
||||
import { isFreshNonDoneAgentStatus } from '../../../../../shared/agent-status/contracts/agent-status-freshness'
|
||||
import {
|
||||
structuredAgentSessionPaneKey,
|
||||
structuredAgentSessionTabId
|
||||
@@ -119,31 +118,6 @@ describe('AgentHookServer ingestStructuredStatus', () => {
|
||||
expect(server.getStatusSnapshot()).toEqual([])
|
||||
})
|
||||
|
||||
it("folds the host's live child records into an idle session the way the hook lane folds a roster", () => {
|
||||
const server = new AgentHookServer()
|
||||
server.ingestStructuredStatus(summary({ status: 'idle' }), SUBJECT)
|
||||
server.ingestStructuredChildWork(SUBJECT, [liveChild('child-1', 'agent')], 'codex')
|
||||
server.ingestStructuredStatus(summary({ status: 'idle', updatedAt: OBSERVED_AT + 1 }), SUBJECT)
|
||||
expect(server.getStatusSnapshot()[0]).toMatchObject({ state: 'working' })
|
||||
expect(server.getStatusSnapshot()[0]).not.toHaveProperty('workingMode')
|
||||
|
||||
server.ingestStructuredChildWork(
|
||||
SUBJECT,
|
||||
[endedChild('child-1'), liveChild('shell-1', 'command')],
|
||||
'codex'
|
||||
)
|
||||
server.ingestStructuredStatus(summary({ status: 'idle', updatedAt: OBSERVED_AT + 2 }), SUBJECT)
|
||||
expect(server.getStatusSnapshot()[0]).toMatchObject({
|
||||
state: 'working',
|
||||
workingMode: 'monitoring'
|
||||
})
|
||||
|
||||
server.ingestStructuredChildWork(SUBJECT, [endedChild('shell-1')], 'codex')
|
||||
server.ingestStructuredStatus(summary({ status: 'idle', updatedAt: OBSERVED_AT + 3 }), SUBJECT)
|
||||
expect(server.getStatusSnapshot()[0]).toMatchObject({ state: 'done' })
|
||||
expect(server.getStatusSnapshot()[0]).not.toHaveProperty('workingMode')
|
||||
})
|
||||
|
||||
it("reads child liveness from the host's records, never from the summary's task list", () => {
|
||||
const server = new AgentHookServer()
|
||||
server.ingestStructuredStatus(
|
||||
@@ -156,44 +130,6 @@ describe('AgentHookServer ingestStructuredStatus', () => {
|
||||
expect(server.getStatusSnapshot()[0]).toMatchObject({ state: 'done' })
|
||||
})
|
||||
|
||||
// Monitoring age must not become the age of a newly working turn.
|
||||
it('restarts the state clock when monitoring becomes a real turn', () => {
|
||||
const server = new AgentHookServer()
|
||||
server.ingestStructuredStatus(summary({ status: 'idle' }), SUBJECT)
|
||||
server.ingestStructuredChildWork(SUBJECT, [liveChild('shell-1', 'command')], 'codex')
|
||||
server.ingestStructuredStatus(summary({ status: 'idle' }), SUBJECT)
|
||||
expect(server.getStatusSnapshot()[0]).toMatchObject({
|
||||
state: 'working',
|
||||
workingMode: 'monitoring',
|
||||
stateStartedAt: OBSERVED_AT
|
||||
})
|
||||
|
||||
server.ingestStructuredStatus(
|
||||
summary({ status: 'working', updatedAt: OBSERVED_AT + 2_700_000 }),
|
||||
SUBJECT
|
||||
)
|
||||
expect(server.getStatusSnapshot()[0]).toMatchObject({
|
||||
state: 'working',
|
||||
stateStartedAt: OBSERVED_AT + 2_700_000
|
||||
})
|
||||
expect(server.getStatusSnapshot()[0]).not.toHaveProperty('workingMode')
|
||||
})
|
||||
|
||||
// Background edges do not advance journal activity; host receipt must keep live monitoring rows fresh.
|
||||
it('dates a task edge by when the host saw it, not by the journal clock', () => {
|
||||
const server = new AgentHookServer()
|
||||
const before = Date.now()
|
||||
server.ingestStructuredStatus(summary({ status: 'idle', updatedAt: OBSERVED_AT }), SUBJECT)
|
||||
server.ingestStructuredChildWork(SUBJECT, [liveChild('shell-1', 'command')], 'codex')
|
||||
server.ingestStructuredStatus(summary({ status: 'idle', updatedAt: OBSERVED_AT }), SUBJECT)
|
||||
const row = server.getStatusSnapshot()[0]
|
||||
expect(row).toMatchObject({ state: 'working', workingMode: 'monitoring' })
|
||||
expect(row?.evidenceObservedAt).toBeGreaterThanOrEqual(before)
|
||||
expect(isFreshNonDoneAgentStatus({ ...row!, updatedAt: row!.evidenceObservedAt! })).toBe(true)
|
||||
})
|
||||
|
||||
// Structured resume identity belongs to the record store; a PTY-style remnant here could never be cleared.
|
||||
|
||||
// The renderer feed owns structured panes, so host deletion must neither clear them nor rewrite hook persistence.
|
||||
it('drops the row without sending the renderer a clear for a pane it does not write', () => {
|
||||
const server = new AgentHookServer()
|
||||
@@ -255,67 +191,4 @@ describe('structured rows and last-status.json', () => {
|
||||
restored.stop()
|
||||
}
|
||||
})
|
||||
|
||||
it('are dropped on hydrate if some other writer put one on disk', async () => {
|
||||
mkdirSync(join(userDataPath, 'agent-hooks'), { recursive: true })
|
||||
writeFileSync(
|
||||
lastStatusPath(),
|
||||
JSON.stringify({
|
||||
version: 2,
|
||||
entries: {
|
||||
[STRUCTURED_PANE]: {
|
||||
paneKey: STRUCTURED_PANE,
|
||||
tabId: TAB,
|
||||
connectionId: null,
|
||||
receivedAt: Date.now(),
|
||||
stateStartedAt: Date.now(),
|
||||
structuredHost: 'owned',
|
||||
payload: { state: 'working', prompt: 'ship the thing', agentType: 'codex' }
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
const server = new AgentHookServer()
|
||||
await server.start({ env: 'production', userDataPath })
|
||||
try {
|
||||
expect(server.getStatusSnapshot()).toEqual([])
|
||||
} finally {
|
||||
server.stop()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('the main agent fact on a structured row', () => {
|
||||
it('publishes the main agent beside the folded state, on the journal clock with continuity', () => {
|
||||
const server = new AgentHookServer()
|
||||
server.ingestStructuredStatus(summary({ status: 'idle' }), SUBJECT)
|
||||
server.ingestStructuredChildWork(SUBJECT, [liveChild('c', 'agent')], 'codex')
|
||||
server.ingestStructuredStatus(summary({ status: 'idle' }), SUBJECT)
|
||||
expect(server.getStatusSnapshot()[0]).toMatchObject({
|
||||
state: 'working',
|
||||
mainAgent: { state: 'done', stateStartedAt: OBSERVED_AT }
|
||||
})
|
||||
expect(server.getStatusSnapshot()[0]?.mainAgent).not.toHaveProperty('outcome')
|
||||
|
||||
// Child drain does not change the settled main agent's clock.
|
||||
server.ingestStructuredChildWork(SUBJECT, [endedChild('c')], 'codex')
|
||||
server.ingestStructuredStatus(
|
||||
summary({ status: 'idle', updatedAt: OBSERVED_AT + 5, turnOutcome: 'failure' }),
|
||||
SUBJECT
|
||||
)
|
||||
expect(server.getStatusSnapshot()[0]).toMatchObject({
|
||||
state: 'done',
|
||||
stateStartedAt: OBSERVED_AT + 5,
|
||||
mainAgent: { state: 'done', outcome: 'failure', stateStartedAt: OBSERVED_AT }
|
||||
})
|
||||
|
||||
server.ingestStructuredStatus(
|
||||
summary({ status: 'working', updatedAt: OBSERVED_AT + 9 }),
|
||||
SUBJECT
|
||||
)
|
||||
expect(server.getStatusSnapshot()[0]?.mainAgent).toEqual({
|
||||
state: 'working',
|
||||
stateStartedAt: OBSERVED_AT + 9
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,244 +0,0 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { EventEmitter } from 'node:events'
|
||||
import type { ChildProcessWithoutNullStreams } from 'node:child_process'
|
||||
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import { RelayDispatcher } from '../../../wsl-guest/transport/publication/dispatcher'
|
||||
import { PluginOverlayManager } from '../../../wsl-guest/plugins/overlays/plugin-overlay'
|
||||
import { createInstallPluginsHandler } from '../../../wsl-guest/plugins/installation/wsl-install-plugins-handler'
|
||||
import { WslHookRelayManager } from './wsl-hook-relay-manager'
|
||||
import { REINSTALL_MIN_INTERVAL_MS } from './wsl-hook-relay-deps'
|
||||
import type { MultiplexerTransport } from '../../ssh/protocol/ssh-multiplexer-transport-writer'
|
||||
import type { TuiAgent } from '../../../shared/agent-launch/catalog/tui-agent'
|
||||
import {
|
||||
AGENT_HOOK_INSTALL_PLUGINS_METHOD,
|
||||
AGENT_HOOK_REQUEST_REPLAY_METHOD
|
||||
} from '../../../shared/agent-hook-listener/transport/agent-hook-relay'
|
||||
import { WSL_HOOK_FS_METHODS } from '../../../shared/agent-hook-listener/transport/wsl-hook-relay-contract'
|
||||
|
||||
function gate() {
|
||||
const reached = Promise.withResolvers<void>()
|
||||
const release = Promise.withResolvers<void>()
|
||||
return {
|
||||
reached: reached.promise,
|
||||
release: release.resolve,
|
||||
wait: async () => {
|
||||
reached.resolve()
|
||||
await release.promise
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function fakeChild(): ChildProcessWithoutNullStreams {
|
||||
const child = Object.assign(new EventEmitter(), {
|
||||
stdout: new EventEmitter(),
|
||||
stderr: new EventEmitter(),
|
||||
stdin: { write: () => true, end: () => {}, on: () => {} },
|
||||
kill: () => true
|
||||
})
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: The injected launcher and link only use these emitter, stream, and kill members; no process is spawned.
|
||||
return child as unknown as ChildProcessWithoutNullStreams
|
||||
}
|
||||
|
||||
// Guest materialization uses POSIX home semantics; native Windows needs the WSL rig.
|
||||
describe.skipIf(process.platform === 'win32')('WSL public-manager settings lifetime', () => {
|
||||
let root: string
|
||||
let manager: WslHookRelayManager
|
||||
let guests: ReturnType<typeof createGuest>[]
|
||||
let activeGuest: ReturnType<typeof createGuest>
|
||||
let settings: { disabledTuiAgents: TuiAgent[] }
|
||||
let requests: Record<string, unknown>[]
|
||||
let now: number
|
||||
let detectionCount: number
|
||||
let hookCount: number
|
||||
let pause: 'detect' | 'hooks' | 'plugin'
|
||||
let rejectRequest: boolean
|
||||
let rejectHooks: boolean
|
||||
let onPluginRequest: ((index: number) => Promise<void>) | undefined
|
||||
let beforeSources: ReturnType<typeof gate>
|
||||
let pendingRequest: ReturnType<typeof gate>
|
||||
const sources = {
|
||||
opencodePluginSource: '// independent v1',
|
||||
opencode2PluginSource: '// independent v2',
|
||||
piExtensionSource: '// pi',
|
||||
ompExtensionSource: '// omp'
|
||||
}
|
||||
|
||||
function createGuest(name: string): {
|
||||
home: string
|
||||
transport: MultiplexerTransport
|
||||
dispatcher: RelayDispatcher
|
||||
} {
|
||||
const home = join(root, name)
|
||||
mkdirSync(join(home, '.config', 'opencode'), { recursive: true })
|
||||
writeFileSync(join(home, '.config', 'opencode', 'opencode.json'), '{"model":"fixture"}')
|
||||
const callbacks: ((data: Buffer) => void)[] = []
|
||||
const transport: MultiplexerTransport = {
|
||||
write: (data) => dispatcher.feed(data),
|
||||
onData: (callback) => {
|
||||
callbacks.push(callback)
|
||||
},
|
||||
onClose: () => {}
|
||||
}
|
||||
const dispatcher = new RelayDispatcher((data) =>
|
||||
callbacks.forEach((callback) => callback(data))
|
||||
)
|
||||
dispatcher.onRequest(WSL_HOOK_FS_METHODS.home, async () => ({ ok: true, home }))
|
||||
dispatcher.onRequest(AGENT_HOOK_REQUEST_REPLAY_METHOD, async () => ({ replayed: 0 }))
|
||||
dispatcher.onRequest('preflight.detectAgents', async () => {
|
||||
if (++detectionCount === 2 && pause === 'detect') {
|
||||
await beforeSources.wait()
|
||||
}
|
||||
return { agents: ['claude'] }
|
||||
})
|
||||
const install = createInstallPluginsHandler(new PluginOverlayManager({ homeDir: home }), {
|
||||
HOME: home,
|
||||
XDG_CONFIG_HOME: join(home, '.config'),
|
||||
ORCA_WSL_HOOK_INSTANCE: 'independent-manager'
|
||||
})
|
||||
dispatcher.onRequest(AGENT_HOOK_INSTALL_PLUGINS_METHOD, async (params) => {
|
||||
requests.push(params)
|
||||
if (onPluginRequest) {
|
||||
await onPluginRequest(requests.length)
|
||||
} else if (requests.length === 2) {
|
||||
await pendingRequest.wait()
|
||||
if (rejectRequest) {
|
||||
throw new Error('fixture plugin request rejected')
|
||||
}
|
||||
}
|
||||
return install(params)
|
||||
})
|
||||
const guest = { home, transport, dispatcher }
|
||||
guests.push(guest)
|
||||
return guest
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
root = mkdtempSync(join(tmpdir(), 'orca-wsl-manager-boundary-'))
|
||||
settings = { disabledTuiAgents: [] }
|
||||
requests = []
|
||||
now = Date.now()
|
||||
vi.spyOn(Date, 'now').mockImplementation(() => now)
|
||||
rejectRequest = false
|
||||
rejectHooks = false
|
||||
onPluginRequest = undefined
|
||||
detectionCount = 0
|
||||
hookCount = 0
|
||||
beforeSources = gate()
|
||||
pendingRequest = gate()
|
||||
guests = []
|
||||
activeGuest = createGuest('first')
|
||||
manager = new WslHookRelayManager({
|
||||
platform: () => 'win32',
|
||||
remoteHooksEnabled: () => true,
|
||||
hookCoordsEnv: () => ({ ORCA_AGENT_HOOK_PORT: '43117', ORCA_AGENT_HOOK_TOKEN: 'fixture' }),
|
||||
instanceKey: () => 'independent',
|
||||
resolveBundle: () => ({ jsPath: join(root, 'relay.js'), version: 'fixture' }),
|
||||
readBundle: () => Buffer.from('// fixture'),
|
||||
listDistros: async () => ['fixture'],
|
||||
isDistroRunning: async () => true,
|
||||
spawnRelay: () => fakeChild(),
|
||||
runInstall: async () => ({ code: 0, stderr: '' }),
|
||||
waitForSentinel: async () => activeGuest.transport,
|
||||
ingest: () => {},
|
||||
installHooks: async () => {
|
||||
if (++hookCount === 2 && pause === 'hooks') {
|
||||
await beforeSources.wait()
|
||||
}
|
||||
if (rejectHooks) {
|
||||
throw new Error('fixture hook failure')
|
||||
}
|
||||
return []
|
||||
},
|
||||
installCodex: async () => null,
|
||||
managedHookSettings: () => settings,
|
||||
pluginSources: () => sources,
|
||||
warn: vi.fn(),
|
||||
transientRetryDelayMs: 1,
|
||||
// A bridge terminal stays open, so no relay idles out mid-test.
|
||||
bridgePtyPresence: { count: () => 1, onChange: () => () => {} },
|
||||
daemonBridgeSessions: async () => 'none' as const
|
||||
})
|
||||
})
|
||||
afterEach(() => {
|
||||
manager.disposeAll()
|
||||
for (const guest of guests) {
|
||||
guest.dispatcher.dispose()
|
||||
}
|
||||
vi.restoreAllMocks()
|
||||
rmSync(root, { recursive: true, force: true })
|
||||
})
|
||||
|
||||
const cases = [
|
||||
{ stage: 'plugin', initialEnabled: true, toggleBack: false },
|
||||
{ stage: 'plugin', initialEnabled: false, toggleBack: false }
|
||||
] as const
|
||||
|
||||
it.each(cases)(
|
||||
'manager settings across $stage: initially enabled $initialEnabled, toggle back $toggleBack',
|
||||
async ({ stage, initialEnabled, toggleBack }) => {
|
||||
pause = stage
|
||||
const setEnabled = (enabled: boolean) => {
|
||||
settings = { disabledTuiAgents: enabled ? [] : ['opencode', 'opencode2'] }
|
||||
}
|
||||
setEnabled(initialEnabled)
|
||||
await manager.ensureForDistro('fixture')
|
||||
expect(requests).toHaveLength(1)
|
||||
now += REINSTALL_MIN_INTERVAL_MS + 1
|
||||
const refresh = manager.ensureForDistro('fixture')
|
||||
const waiters: Promise<void>[] = [refresh]
|
||||
if (stage !== 'plugin') {
|
||||
await beforeSources.reached
|
||||
setEnabled(!initialEnabled)
|
||||
waiters.push(manager.ensureForDistro('fixture'))
|
||||
beforeSources.release()
|
||||
}
|
||||
await pendingRequest.reached
|
||||
const sentEnabled = stage === 'plugin' ? initialEnabled : !initialEnabled
|
||||
expect(requests[1]).toMatchObject(
|
||||
sentEnabled
|
||||
? sources
|
||||
: {
|
||||
opencodePluginSource: '',
|
||||
opencode2PluginSource: ''
|
||||
}
|
||||
)
|
||||
if (stage === 'plugin') {
|
||||
setEnabled(!initialEnabled)
|
||||
waiters.push(manager.ensureForDistro('fixture'))
|
||||
}
|
||||
const finalEnabled = toggleBack ? initialEnabled : !initialEnabled
|
||||
setEnabled(finalEnabled)
|
||||
waiters.push(...Array.from({ length: 4 }, () => manager.ensureForDistro('fixture')))
|
||||
pendingRequest.release()
|
||||
await Promise.all(waiters)
|
||||
expect(requests).toHaveLength(sentEnabled === finalEnabled ? 2 : 3)
|
||||
expect(requests.at(-1)).toMatchObject(
|
||||
finalEnabled
|
||||
? sources
|
||||
: {
|
||||
opencodePluginSource: '',
|
||||
opencode2PluginSource: ''
|
||||
}
|
||||
)
|
||||
for (const agent of ['opencode', 'opencode2'] as const) {
|
||||
const dir = manager.getOpenCodeOverlayDir('fixture', agent)
|
||||
if (finalEnabled) {
|
||||
expect(dir).toBeTruthy()
|
||||
if (!dir) {
|
||||
throw new Error('missing enabled overlay')
|
||||
}
|
||||
expect(readFileSync(join(dir, 'plugins', `orca-${agent}-status.js`), 'utf8')).toBe(
|
||||
agent === 'opencode' ? sources.opencodePluginSource : sources.opencode2PluginSource
|
||||
)
|
||||
} else {
|
||||
expect(dir).toBeNull()
|
||||
}
|
||||
}
|
||||
const settledCount = requests.length
|
||||
await manager.ensureForDistro('fixture')
|
||||
expect(requests).toHaveLength(settledCount)
|
||||
}
|
||||
)
|
||||
})
|
||||
@@ -1,128 +0,0 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
type ServiceFake = {
|
||||
hasServerFiles: () => boolean
|
||||
isKnownDistro: (distro: string) => Promise<boolean>
|
||||
}
|
||||
|
||||
const host = vi.hoisted(
|
||||
(): { acceptsNewWork: boolean; settingOn: boolean; service: ServiceFake | null } => ({
|
||||
acceptsNewWork: true,
|
||||
settingOn: false,
|
||||
service: null
|
||||
})
|
||||
)
|
||||
vi.mock('../wsl/host-lifecycle/wsl-host-gate', () => ({
|
||||
wslHostsAcceptNewWork: () => host.acceptsNewWork
|
||||
}))
|
||||
vi.mock('../wsl/host-lifecycle/wsl-host-service-instance', () => ({
|
||||
getWslHostService: () => host.service
|
||||
}))
|
||||
|
||||
import { resolveAgentLaunchModeOnHost } from './agent-launch-mode'
|
||||
import { AgentLaunchSurfaceUnavailableError } from './agent-launch-surface-refusal'
|
||||
import { wslHostChatRecovery } from './agent-launch-wsl-host-recovery'
|
||||
|
||||
const requestedChat = {
|
||||
mode: 'structured',
|
||||
preferred: 'structured',
|
||||
reason: 'requested',
|
||||
detail: 'Started a structured chat session, as requested.'
|
||||
} as const
|
||||
|
||||
const UBUNTU_REPO = '\\\\wsl.localhost\\Ubuntu-24.04\\home\\me\\repo'
|
||||
|
||||
async function refuse(reason: 'wsl' | 'remote', workspacePath: string): Promise<unknown> {
|
||||
const runtime = {
|
||||
getStructuredAgentSessionCreateSupport: async () => ({ supported: false, reason }),
|
||||
requireStore: () => ({ getSettings: () => ({ experimentalWslHosts: host.settingOn }) })
|
||||
}
|
||||
return resolveAgentLaunchModeOnHost(runtime, requestedChat, 'repo::path', 'claude', undefined, {
|
||||
phase: 'before-effects',
|
||||
agent: 'claude',
|
||||
workspacePath
|
||||
}).then(
|
||||
() => {
|
||||
throw new Error('expected a refusal')
|
||||
},
|
||||
(error: unknown) => error
|
||||
)
|
||||
}
|
||||
|
||||
function facts(settingOn: boolean, hostAdded: boolean) {
|
||||
return async () => ({ settingOn, hostAdded })
|
||||
}
|
||||
|
||||
describe('WSL chat refusal recovery', () => {
|
||||
beforeEach(() => {
|
||||
host.acceptsNewWork = true
|
||||
host.settingOn = false
|
||||
host.service = {
|
||||
hasServerFiles: () => true,
|
||||
isKnownDistro: async () => false
|
||||
}
|
||||
})
|
||||
|
||||
it('points a WSL folder at a WSL host for its distro when hosts can be added', async () => {
|
||||
const error = await refuse('wsl', UBUNTU_REPO)
|
||||
expect(error).toBeInstanceOf(AgentLaunchSurfaceUnavailableError)
|
||||
// Older clients match the code and message, so both stay as they were.
|
||||
expect(error).toMatchObject({
|
||||
code: 'agent_launch_surface_unavailable',
|
||||
message:
|
||||
"Claude can't open as a chat here because this workspace runs under WSL. Start it in a terminal instead.",
|
||||
data: {
|
||||
wslDistro: 'Ubuntu-24.04',
|
||||
nextSteps: [
|
||||
expect.stringMatching(
|
||||
/turn on Settings → Experimental → WSL hosts, then add Ubuntu-24\.04 as a host.*then choose “Move to Ubuntu-24\.04 host…”/
|
||||
),
|
||||
expect.stringContaining('--surface terminal')
|
||||
]
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('keeps the plain refusal while WSL hosts cannot take new work', async () => {
|
||||
host.acceptsNewWork = false
|
||||
expect(await refuse('wsl', UBUNTU_REPO)).toMatchObject({ data: undefined })
|
||||
host.acceptsNewWork = true
|
||||
host.service = {
|
||||
hasServerFiles: () => false,
|
||||
isKnownDistro: async () => false
|
||||
}
|
||||
expect(await refuse('wsl', UBUNTU_REPO)).toMatchObject({ data: undefined })
|
||||
host.service = null
|
||||
expect(await refuse('wsl', UBUNTU_REPO)).toMatchObject({ data: undefined })
|
||||
})
|
||||
|
||||
it('adds no WSL host steps to other refusals', async () => {
|
||||
expect(await refuse('remote', UBUNTU_REPO)).toMatchObject({ data: undefined })
|
||||
})
|
||||
|
||||
it('offers no move for a Windows drive reached through the distro', async () => {
|
||||
expect(await refuse('wsl', '\\\\wsl.localhost\\Ubuntu\\mnt\\c\\repo')).toMatchObject({
|
||||
data: undefined
|
||||
})
|
||||
})
|
||||
|
||||
it('says only the move once the distro is a host and the setting is on', async () => {
|
||||
host.settingOn = true
|
||||
host.service = { hasServerFiles: () => true, isKnownDistro: async () => true }
|
||||
const error = await refuse('wsl', UBUNTU_REPO)
|
||||
expect(error).toMatchObject({ data: { nextSteps: [expect.any(String), expect.any(String)] } })
|
||||
const recovery = await wslHostChatRecovery(UBUNTU_REPO, facts(true, true))
|
||||
expect(error).toMatchObject({ data: recovery })
|
||||
expect(recovery?.nextSteps[0]).toBe(
|
||||
'Chat works when the project runs on the Ubuntu-24.04 WSL host. In Orca, choose “Move to Ubuntu-24.04 host…” on the project in the sidebar, then launch the chat there.'
|
||||
)
|
||||
})
|
||||
|
||||
it('skips the add for a saved host while the setting is off', async () => {
|
||||
const recovery = await wslHostChatRecovery(UBUNTU_REPO, facts(false, true))
|
||||
expect(recovery?.nextSteps[0]).toContain(
|
||||
'turn on Settings → Experimental → WSL hosts, then choose'
|
||||
)
|
||||
expect(recovery?.nextSteps[0]).not.toContain('Add WSL distro')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user