Merge origin/main into project grouping rule

This commit is contained in:
Brennan Benson
2026-11-09 04:45:55 -08:00
575 changed files with 3487 additions and 2535 deletions
File diff suppressed because one or more lines are too long
@@ -6377,8 +6377,8 @@
"src/renderer/src/lib/activate-ai-vault-structured-session-host.test.ts": 589,
"src/renderer/src/lib/activate-ai-vault-structured-session-reveal.test.ts": 2099,
"src/renderer/src/lib/workspace/tabs/activate-tab-and-focus-pane.test.ts": 54,
"src/renderer/src/lib/active-agent-note-send-explicit-target.test.ts": 980,
"src/renderer/src/lib/active-agent-note-send-focused-session.test.ts": 536,
"src/renderer/src/lib/agent-session/messaging/terminal/active-agent-note-send-explicit-target.test.ts": 980,
"src/renderer/src/lib/agent-session/messaging/terminal/active-agent-note-send-focused-session.test.ts": 536,
"src/renderer/src/lib/activity-thread-display.test.ts": 134,
"src/renderer/src/lib/agent-account-restart-startup.test.ts": 1780,
"src/renderer/src/lib/agent-session/launch/background/agent-background-session-launch-host.test.ts": 1910,
@@ -6395,10 +6395,10 @@
"src/renderer/src/lib/agent-session/launch/pane/agent-launch-tab-main-written.test.ts": 2084,
"src/renderer/src/lib/agent-session/launch/pane/agent-launch-tab-publication.test.ts": 1855,
"src/renderer/src/lib/agent-session/launch/pane/agent-launch-through-host.test.ts": 1975,
"src/renderer/src/lib/agent-message-send.test.ts": 182,
"src/renderer/src/lib/agent-paste-draft-submit-retry.test.ts": 315,
"src/renderer/src/lib/agent-paste-draft.test.ts": 445,
"src/renderer/src/lib/agent-resume-launch-target.test.ts": 3911,
"src/renderer/src/lib/agent-session/messaging/agent-message-send.test.ts": 182,
"src/renderer/src/lib/agent-session/messaging/paste/agent-paste-draft-submit-retry.test.ts": 315,
"src/renderer/src/lib/agent-session/messaging/paste/agent-paste-draft.test.ts": 445,
"src/renderer/src/lib/agent-session/resume/agent-resume-launch-target.test.ts": 3911,
"src/renderer/src/lib/agent-session/launch/structured-agent-session-launch-after-failure.test.ts": 870,
"src/renderer/src/lib/agent-session/launch/structured-agent-session-launch-close-race.test.ts": 983,
"src/renderer/src/lib/agent-session/launch/structured-agent-session-launch-create-message.test.ts": 2521,
@@ -6417,10 +6417,10 @@
"src/renderer/src/lib/agent-session/structured-agent-session-draft-position-lifetime.test.tsx": 3166,
"src/renderer/src/lib/agent-session/structured-agent-session-ordinary-draft.test.tsx": 9907,
"src/renderer/src/lib/agent-session/structured-agent-session-provisional-tab.test.ts": 3672,
"src/renderer/src/lib/agent-skill-cli-prerequisite.test.ts": 219,
"src/renderer/src/lib/agent-startup-delayed-delivery-perf.test.ts": 1708,
"src/renderer/src/lib/agent-status-evidence-clock.test.ts": 88,
"src/renderer/src/lib/agent-status.test.ts": 172,
"src/renderer/src/lib/skills/installation/agent-skill-cli-prerequisite.test.ts": 219,
"src/renderer/src/lib/agent-session/launch/startup/agent-startup-delayed-delivery-perf.test.ts": 1708,
"src/shared/agent-status/contracts/agent-status-evidence-clock.test.ts": 88,
"src/shared/agent-status/title/agent-title-tracker.test.ts": 172,
"src/renderer/src/lib/agent-session/resume/history/ai-vault-antigravity-reference-host.test.ts": 678,
"src/renderer/src/lib/agent-session/resume/history/ai-vault-resume-command.drop-repin.test.ts": 541,
"src/renderer/src/lib/agent-session/resume/history/ai-vault-resume-command.test.ts": 665,
@@ -1,87 +0,0 @@
import assert from 'node:assert/strict'
import { mkdir, mkdtemp, rename, rm } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { basename, join } from 'node:path'
import { isolatedScanRoots } from '../../../../src/main/ai-vault/session-scanner-test-fixtures'
import { resetSessionParseCacheForTests } from '../../../../src/main/ai-vault/parse-cache/session-parse-cache-store'
import { resetTranscriptConsumersForTests } from '../../../../src/main/ai-vault/transcripts/session-transcript-consumers'
import { SessionSearchIndexer } from '../../../../src/main/ai-vault-search/session-search-indexer'
import { writeSyntheticTranscriptCorpus } from '../../../../src/main/ai-vault-search/session-search-synthetic-corpus'
// Bundle with esbuild --bundle --platform=node and run on target host over synthetic corpus only; never use real transcripts.
// Price warm stat-only cycle/sweep used to choose reconcile interval, without setting it or reading already-current content.
const SESSIONS = 5_000
const TURNS_PER_SESSION = 4
const PROJECTS = 40
const corpus = await writeSyntheticTranscriptCorpus({
sessions: SESSIONS,
turnsPerSession: TURNS_PER_SESSION
})
const root = await mkdtemp(join(tmpdir(), 'orca-search-pass-'))
const roots = isolatedScanRoots(root)
const databasePath = join(root, 'index', 'session-search.sqlite')
try {
// Spread synthetic corpus over project dirs to model discovery’s readdir cost instead of one flat listing.
for (let index = 0; index < PROJECTS; index++) {
await mkdir(join(roots.claudeProjectsDir, `project-${index}`), { recursive: true })
}
await Promise.all(
corpus.files.map((path, index) =>
rename(path, join(roots.claudeProjectsDir, `project-${index % PROJECTS}`, basename(path)))
)
)
resetSessionParseCacheForTests()
resetTranscriptConsumersForTests()
const errors: unknown[] = []
const indexer = new SessionSearchIndexer({
databasePath,
roots,
historyDays: null,
// Finish cold indexing before warm measurement; deadline would contaminate timings with backlog.
passDeadlineMs: Number.MAX_SAFE_INTEGER,
onError: (error) => errors.push(error)
})
try {
const coldStarted = performance.now()
await indexer.start()
const coldMs = performance.now() - coldStarted
assert.deepEqual(errors, [])
assert.equal(indexer.status().filesIndexed, SESSIONS, 'indexed file count')
const sweepStarted = performance.now()
await indexer.reconcile({ full: true })
const sweepMs = performance.now() - sweepStarted
const cycleStarted = performance.now()
await indexer.reconcile({ full: false })
const cycleMs = performance.now() - cycleStarted
assert.deepEqual(errors, [])
assert.equal(indexer.status().filesDue, 0, 'nothing owed after a warm sweep')
console.log(
JSON.stringify(
{
transcripts: SESSIONS,
projectDirectories: PROJECTS,
transcriptMb: Math.round((corpus.transcriptBytes / (1024 * 1024)) * 100) / 100,
coldBuildMs: Math.round(coldMs),
warmSweepMs: Math.round(sweepMs),
warmCycleMs: Math.round(cycleMs)
},
null,
2
)
)
} finally {
indexer.close()
resetTranscriptConsumersForTests()
resetSessionParseCacheForTests()
}
} finally {
await rm(corpus.root, { recursive: true, force: true })
await rm(root, { recursive: true, force: true })
}
@@ -1,143 +0,0 @@
import assert from 'node:assert/strict'
import { mkdtemp, rm, stat } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { setImmediate as yieldToEventLoop } from 'node:timers/promises'
import {
syntheticCandidate,
syntheticSession,
userMessages
} from '../../../../src/main/ai-vault-search/session-search-index-test-fixture'
import { SessionSearchStore } from '../../../../src/main/ai-vault-search/session-search-store'
import SyncDatabase from '../../../../src/main/sqlite/sync-database'
// Bundle with esbuild --bundle --platform=node and run on target host. All arms seed through store; only whole-file baseline bypasses shipped purge.
const ROWS = 60_000
/** The purge yields with `setImmediate` between chunks, so a peer chain samples each gap. */
async function sampleLoopStalls(running: () => boolean, intervals: number[]): Promise<void> {
let previous = performance.now()
while (running()) {
await yieldToEventLoop()
const now = performance.now()
intervals.push(now - previous)
previous = now
}
}
/** What a search would still return: rows whose session row is still there. */
function visibleRows(db: SyncDatabase): number {
return (
db
.prepare(`SELECT count(*) AS n FROM messages m JOIN sessions s ON s.id = m.session_row_id`)
.get() as { n: number }
).n
}
const root = await mkdtemp(join(tmpdir(), 'orca-search-retention-bench-'))
try {
for (const mode of ['whole-file', 'batched', 'batched-pinned-reader']) {
const path = join(root, `${mode}.sqlite`)
const errors: unknown[] = []
const store = new SessionSearchStore(path, (error) => errors.push(error))
let reader: SyncDatabase | null = null
try {
const write = store.beginWrite(syntheticCandidate(), 'replace', 0)!
for (const message of userMessages(
'synthetic benchmark needle repeated context for a representative coding conversation with commands and paths src/example.ts',
ROWS
)) {
write.add(message)
}
assert.equal(
write.commit({
session: syntheticSession(),
byteOffset: 4096,
incomplete: false
}),
true
)
assert.deepEqual(errors, [])
// Truncating first is what makes walBytes below the purge's own growth.
const checkpoint = new SyncDatabase(path)
checkpoint.pragma('wal_checkpoint(TRUNCATE)')
checkpoint.close()
if (mode === 'batched-pinned-reader') {
reader = new SyncDatabase(path, { readonly: true })
reader.exec('BEGIN')
reader.prepare('SELECT count(*) FROM messages').get()
}
const probe = new SyncDatabase(path, { readonly: true })
const intervals: number[] = []
const started = performance.now()
if (mode === 'whole-file') {
const raw = new SyncDatabase(path)
try {
raw.exec('BEGIN IMMEDIATE')
const ids = raw.prepare('SELECT id FROM messages').all() as {
id: number
}[]
for (const { id } of ids) {
raw.prepare('DELETE FROM messages_fts WHERE rowid=?').run(id)
}
raw.exec('DELETE FROM messages; DELETE FROM sessions; DELETE FROM files; COMMIT')
} finally {
raw.close()
}
intervals.push(performance.now() - started)
} else {
let purging = true
const purge = store.purgeOlderThan(Date.now() + 60_000)
// First transaction cuts session from file, hiding search results immediately before chunked deletion finishes.
const hiddenEarly = yieldToEventLoop().then(() => visibleRows(probe))
const sampler = sampleLoopStalls(() => purging, intervals)
await purge
purging = false
await sampler
assert.equal(await hiddenEarly, 0)
assert.deepEqual(errors, [])
}
const wallMs = performance.now() - started
probe.close()
reader?.exec('COMMIT')
reader?.close()
reader = null
const after = new SyncDatabase(path, { readonly: true })
try {
for (const table of ['messages_fts']) {
assert.equal(
(
after.prepare(`SELECT count(*) AS n FROM ${table}`).get() as {
n: number
}
).n,
0
)
}
} finally {
after.close()
}
const walBytes = (await stat(`${path}-wal`)).size
intervals.sort((a, b) => a - b)
console.log(
JSON.stringify({
mode,
platform: process.platform,
node: process.version,
rows: ROWS,
wallMs: Math.round(wallMs),
samples: intervals.length,
maxStepMs: Math.round(intervals.at(-1) ?? 0),
p95StepMs: Math.round(intervals[Math.floor(intervals.length * 0.95)] ?? 0),
walBytes
})
)
} finally {
reader?.close()
store.close()
}
}
} finally {
await rm(root, { recursive: true, force: true })
}
+4 -4
View File
@@ -1,5 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" width="113" height="20" role="img" aria-label="downloads: 160m">
<title>downloads: 160m</title>
<svg xmlns="http://www.w3.org/2000/svg" width="113" height="20" role="img" aria-label="downloads: 161m">
<title>downloads: 161m</title>
<linearGradient id="s" x2="0" y2="100%">
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
<stop offset="1" stop-opacity=".1"/>
@@ -15,7 +15,7 @@
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="11">
<text x="37" y="15" fill="#010101" fill-opacity=".3">downloads</text>
<text x="37" y="14">downloads</text>
<text x="93.5" y="15" fill="#010101" fill-opacity=".3">160m</text>
<text x="93.5" y="14">160m</text>
<text x="93.5" y="15" fill="#010101" fill-opacity=".3">161m</text>
<text x="93.5" y="14">161m</text>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 943 B

After

Width:  |  Height:  |  Size: 943 B

@@ -1,4 +1,3 @@
import type * as NodeFsModule from 'node:fs'
import { mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import type * as NodeOsModule from 'node:os'
@@ -6,28 +5,7 @@ import { join } from 'node:path'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { installFakeAppEnvironment } from '../../../../../config/scripts/test-runtime/environment/vitest-host-ports-setup'
const state = vi.hoisted((): { home: string; syncCalls: { name: string; target: string }[] } => ({
home: '',
syncCalls: []
}))
vi.mock('node:fs', async (importOriginal) => {
const actual = await importOriginal<typeof NodeFsModule>()
const wrapped: Record<string, unknown> = { ...actual }
for (const [name, value] of Object.entries(actual)) {
if (!name.endsWith('Sync') || typeof value !== 'function') {
continue
}
const original = value as ((...args: unknown[]) => unknown) & Record<string, unknown>
const recorder = (...args: unknown[]): unknown => {
state.syncCalls.push({ name, target: typeof args[0] === 'string' ? args[0] : '' })
return original(...args)
}
Object.assign(recorder, original)
wrapped[name] = recorder
}
return { ...wrapped, default: wrapped }
})
const state = vi.hoisted(() => ({ home: '' }))
vi.mock('node:os', async (importOriginal) => {
const actual = await importOriginal<typeof NodeOsModule>()
@@ -38,13 +16,7 @@ vi.mock('electron', () => ({ app: { getPath: () => '/tmp/orca-user-data' } }))
import { MANAGED_AGENT_HOOK_SCRIPT_REFRESHERS } from '../managed-agent-hook-registry'
function syncCallsUnderHome(): string[] {
return state.syncCalls
.filter((call) => call.target.startsWith(state.home))
.map((call) => `${call.name}(${call.target})`)
}
describe('managed hook script refresh stays off the main thread', () => {
describe('managed hook script refresh and owned profile cleanup', () => {
beforeEach(async () => {
state.home = await mkdtemp(join(tmpdir(), 'orca-hook-refresh-main-thread-'))
vi.stubEnv('CLAUDE_CONFIG_DIR', join(state.home, '.claude'))
@@ -53,7 +25,6 @@ describe('managed hook script refresh stays off the main thread', () => {
vi.stubEnv('GROK_HOME', undefined)
vi.stubEnv('KIMI_CODE_HOME', undefined)
vi.stubEnv('XDG_CONFIG_HOME', undefined)
state.syncCalls = []
})
afterEach(async () => {
@@ -61,7 +32,7 @@ describe('managed hook script refresh stays off the main thread', () => {
vi.unstubAllEnvs()
})
it('uses no synchronous HOME filesystem calls for missing or stale scripts', async () => {
it('refreshes stale scripts and removes owned profile plugins while preserving unowned files', async () => {
const hooksDir = join(state.home, '.orca', 'agent-hooks')
const claudeScript = join(
hooksDir,
@@ -107,13 +78,11 @@ describe('managed hook script refresh stays off the main thread', () => {
await mkdir(join(unowned, 'hooks'))
await writeFile(join(unowned, '.claude-plugin', 'orca-managed.json'), '{"owner":"someone"}')
await writeFile(join(unowned, 'hooks', 'register.js'), 'user-owned')
state.syncCalls = []
for (const [, refresh] of MANAGED_AGENT_HOOK_SCRIPT_REFRESHERS) {
await refresh()
}
expect(syncCallsUnderHome()).toEqual([])
const refreshed = await readFile(claudeScript, 'utf8')
expect(refreshed).not.toBe('stale')
expect(refreshed).toContain(
@@ -118,48 +118,6 @@ describe('AgentHookServer listener replay', () => {
}
})
it('does not apply Claude background evidence from a rejected local status', async () => {
const server = new AgentHookServer()
await server.start({ env: 'production' })
try {
const env = server.buildPtyEnv()
const postClaudeHook = async (payload: Record<string, unknown>): Promise<void> => {
const response = await fetch(`http://127.0.0.1:${env.ORCA_AGENT_HOOK_PORT}/hook/claude`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Orca-Agent-Hook-Token': env.ORCA_AGENT_HOOK_TOKEN
},
body: JSON.stringify(buildBody(payload))
})
expect(response.status).toBe(204)
}
await postClaudeHook({
hook_event_name: 'PermissionRequest',
prompt: 'approve shell',
tool_name: 'Bash',
background_tasks: [{ id: 'shell-1', type: 'shell', status: 'running' }],
session_crons: [{ id: 'cron-1', status: 'running' }]
})
const waiting = server.getStatusSnapshot()[0]
await postClaudeHook({
hook_event_name: 'PreToolUse',
prompt: 'approve shell',
tool_name: 'OtherTool',
background_tasks: [],
session_crons: []
})
expect(server.getStatusSnapshot()[0]).toEqual(waiting)
expect(server._getStateForTests().claudeRunningNonAgentTaskPaneKeys.has(PANE)).toBe(true)
expect(server._getStateForTests().claudeActiveSessionCronPaneKeys.has(PANE)).toBe(true)
} finally {
server.stop()
}
})
it('accepts form-encoded hook posts from Unix managed scripts', async () => {
const server = new AgentHookServer()
await server.start({ env: 'production' })
@@ -352,7 +352,7 @@ it('forwards a cold host comparison to the retained canonical binding without cr
expect(frame().paneOwner).toBeUndefined()
})
it('rejects before mutating provider folds and validates scoped IDs with the locator parser', () => {
it('rejects an inherited hook and malformed scoped session IDs', () => {
const now = 1_700_000_000_000
vi.spyOn(Date, 'now').mockReturnValue(now)
const state = createHookListenerState()
@@ -377,9 +377,6 @@ it('rejects before mutating provider folds and validates scoped IDs with the loc
user_message: 'poison'
})
expect(normalizeHookPayload(state, 'hermes', body, 'production')).toBeNull()
expect(state.lastPromptByPaneKey.size).toBe(0)
expect(state.lastToolByPaneKey.size).toBe(0)
expect(state.hermesTurnByPaneKey.size).toBe(0)
for (const session of ['x'.repeat(513), '-option', 'bad\nidentity']) {
expect(readAgentProcessPresence({ agent: 'hermes', session })?.session).toBeUndefined()
expect(readAgentProcessPresence({ agent: 'antigravity', session })?.session).toBeUndefined()
@@ -118,6 +118,32 @@ describe('readTerminalCursorLineContext', () => {
}
})
it.each([
{ typed: '', caret: 'T', dim: 'ry "how do I log an error?"', draft: null, typedText: '' },
{ typed: '', caret: 'f', dim: 'ix the login bug', draft: 'fix the login bug', typedText: '' },
{ typed: '', caret: 'a', dim: ' quick fix', draft: 'a quick fix', typedText: '' },
{ typed: '/mo', caret: 'd', dim: 'el', draft: '/model', typedText: '/mo' },
{ typed: '/commi', caret: 't', dim: ' [message]', draft: '/commit', typedText: '/commit' }
])(
"reads Claude's caret glyph $caret after '$typed' before dim '$dim'",
({ typed, caret, dim, draft, typedText }) => {
const cols = 80
const terminal = new Terminal({ cols, rows: 8, allowProposedApi: true })
try {
writeSync(
terminal,
`\x1b[?25l${'─'.repeat(cols)}\r\n❯ ${typed}\x1b7\x1b[7m${caret}\x1b[27m\x1b[2m${dim}\x1b[22m\r\n${'─'.repeat(cols)}\x1b8`
)
const context = readTerminalCursorLineContext(terminal, terminal.rows)
expect(context).toMatchObject({ cursorHidden: true, cursorInverse: true })
expect(detectTerminalComposerDraft(context)?.text ?? null).toBe(draft)
expect(readTerminalComposerTypedText(context)).toBe(typedText)
} finally {
terminal.dispose()
}
}
)
it.each([
{ cols: 19, cursorRowTail: 'proceed with the ', continuation: 'release' },
{ cols: 18, cursorRowTail: 'proceed with the', continuation: ' release' }
@@ -0,0 +1,105 @@
// Shared lifecycle contract every EnvironmentProviderDriver must pass; drivers call it from their test.
import { describe, expect, it } from 'vitest'
import {
getEphemeralVmRecipeResultConnection,
getEphemeralVmRecipeResultProjectRoot,
isAbsoluteRuntimePath
} from '../../shared/ephemeral-vm-recipes'
import {
ENVIRONMENT_PROVIDER_ERROR_CODES,
isEnvironmentProviderError,
type EnvironmentCreateSpec,
type EnvironmentProviderDriver,
type EnvironmentReady
} from './environment-provider-driver'
export type EnvironmentProviderDriverContractHarness = {
driver: EnvironmentProviderDriver
/** Ids the backing provider still holds; destroy must leave none behind. */
liveEnvironmentIds: () => Promise<readonly string[]>
/** A fresh driver over the same backing provider, as after an Orca restart. */
reopenDriver: () => EnvironmentProviderDriver
}
// Handles are persisted with the runtime record, so later calls only ever see the JSON form.
function reload<T>(handle: T): T {
return JSON.parse(JSON.stringify(handle))
}
export function runEnvironmentProviderDriverContract(
name: string,
makeHarness: () => Promise<EnvironmentProviderDriverContractHarness>,
spec: (workspaceId: string) => EnvironmentCreateSpec = (workspaceId) => ({ workspaceId })
): void {
describe(`${name} satisfies the environment provider driver contract`, () => {
function expectReady(driver: EnvironmentProviderDriver, ready: EnvironmentReady): void {
expect(ready.handle.driverId).toBe(driver.id)
expect(ready.handle.environmentId).not.toBe('')
expect(['orca-server', 'ssh']).toContain(
getEphemeralVmRecipeResultConnection(ready.result).type
)
expect(isAbsoluteRuntimePath(getEphemeralVmRecipeResultProjectRoot(ready.result))).toBe(true)
if (driver.capabilities.maxSessionMs !== null) {
expect(ready.session.deadlineAt).not.toBeNull()
expect(ready.session.deadlineAt! - ready.session.startedAt).toBeLessThanOrEqual(
driver.capabilities.maxSessionMs
)
}
}
it('creates, suspends, resumes and destroys one environment without leaking it', async () => {
const { driver, liveEnvironmentIds, reopenDriver } = await makeHarness()
const phases: string[] = []
const created = await driver.create(spec('ws-contract-1'), {
onProgress: ({ phase }) => phases.push(phase)
})
expectReady(driver, created)
expect(phases.length).toBeGreaterThan(0)
expect(await liveEnvironmentIds()).toContain(created.handle.environmentId)
expect((await driver.status(created.handle)).status).toBe('running')
const suspended = await driver.suspend(created.handle)
expect(suspended.status).toBe('suspended')
expect((await driver.status(created.handle)).status).toBe('suspended')
const resumed = await driver.resume(created.handle)
expectReady(driver, resumed)
expect(resumed.handle.environmentId).toBe(created.handle.environmentId)
expect((await driver.status(created.handle)).status).toBe('running')
await driver.destroy(created.handle)
expect(await liveEnvironmentIds()).not.toContain(created.handle.environmentId)
// Idempotent: cleanup retries after a lost response or a restart must not fail.
await reopenDriver().destroy(reload(created.handle))
})
it('refuses to bring back a destroyed environment, even after a restart', async () => {
const { driver, liveEnvironmentIds, reopenDriver } = await makeHarness()
const created = await driver.create(spec('ws-contract-2'))
await driver.destroy(created.handle)
const error = await reopenDriver()
.resume(reload(created.handle))
.then(
() => null,
(caught: unknown) => caught
)
expect(isEnvironmentProviderError(error)).toBe(true)
expect(await liveEnvironmentIds()).not.toContain(created.handle.environmentId)
})
it('rejects a cancelled create with a catalogued error and leaks nothing', async () => {
const { driver, liveEnvironmentIds } = await makeHarness()
const controller = new AbortController()
controller.abort()
const error = await driver.create(spec('ws-contract-3'), { signal: controller.signal }).then(
() => null,
(caught: unknown) => caught
)
expect(isEnvironmentProviderError(error)).toBe(true)
expect(ENVIRONMENT_PROVIDER_ERROR_CODES).toContain(
isEnvironmentProviderError(error) ? error.code : null
)
expect(await liveEnvironmentIds()).toEqual([])
})
})
}
@@ -0,0 +1,125 @@
// One lifecycle seam for VM-backed workspaces: every environment provider answers the same calls,
// and capability flags (not provider ids) decide what the UI offers.
import type { EphemeralVmRecipeResult, JsonValue } from '../../shared/ephemeral-vm-recipes'
export type EnvironmentProviderCapabilities = Readonly<{
/** Suspend keeps memory and processes; false means suspend/resume is a reboot from disk. */
memoryPause: boolean
/** Hard per-session cap enforced by the provider; null when sessions are unbounded. */
maxSessionMs: number | null
/** The filesystem (worktree, auth homes, orcad identity) survives suspend. */
fsPersistOnStop: boolean
/** Orca-owned idle stop; null when the provider has none. */
idleStopMs: number | null
}>
export type EnvironmentProviderPhase =
| 'provisioning'
| 'booting'
| 'connecting'
| 'suspending'
| 'resuming'
| 'destroying'
export type EnvironmentProviderCallContext = {
signal?: AbortSignal
onProgress?: (progress: { phase: EnvironmentProviderPhase; message?: string }) => void
}
export type EnvironmentCreateSpec = {
/** Orca's workspace id; one environment per workspace. */
workspaceId: string
workspaceName?: string
projectId?: string
machineSize?: string
region?: string
repo?: { url: string; ref?: string }
}
/** Persisted with the runtime record; `driverState` is opaque to everything but the driver. */
export type EnvironmentHandle = {
driverId: string
environmentId: string
driverState: Record<string, JsonValue>
}
export type EnvironmentSessionInfo = {
startedAt: number
/** When the provider will end this session regardless of activity. */
deadlineAt: number | null
}
export type EnvironmentStatus =
| 'provisioning'
| 'running'
| 'suspending'
| 'suspended'
| 'resuming'
| 'destroying'
| 'destroyed'
| 'failed'
export type EnvironmentStatusSnapshot = {
status: EnvironmentStatus
session: EnvironmentSessionInfo | null
}
export type EnvironmentReady = {
handle: EnvironmentHandle
/** Same document a shell recipe prints, so runtime records, pairing and resume keep one path. */
result: EphemeralVmRecipeResult
session: EnvironmentSessionInfo
}
export type EnvironmentProviderDriver = {
readonly id: string
readonly capabilities: EnvironmentProviderCapabilities
create(
spec: EnvironmentCreateSpec,
ctx?: EnvironmentProviderCallContext
): Promise<EnvironmentReady>
resume(handle: EnvironmentHandle, ctx?: EnvironmentProviderCallContext): Promise<EnvironmentReady>
suspend(
handle: EnvironmentHandle,
ctx?: EnvironmentProviderCallContext
): Promise<EnvironmentStatusSnapshot>
/** Idempotent: an environment that is already gone resolves. */
destroy(handle: EnvironmentHandle, ctx?: EnvironmentProviderCallContext): Promise<void>
status(
handle: EnvironmentHandle,
ctx?: EnvironmentProviderCallContext
): Promise<EnvironmentStatusSnapshot>
}
export const ENVIRONMENT_PROVIDER_ERROR_CODES = [
'unauthorized',
'not_found',
'conflict',
'invalid_request',
'unavailable',
'timeout',
'aborted',
'invalid_response'
] as const
export type EnvironmentProviderErrorCode = (typeof ENVIRONMENT_PROVIDER_ERROR_CODES)[number]
export class EnvironmentProviderError extends Error {
readonly code: EnvironmentProviderErrorCode
/** Machine-readable provider detail, e.g. the Orca failure-copy code behind the message. */
readonly reason: string | null
constructor(code: EnvironmentProviderErrorCode, message: string, reason: string | null = null) {
super(message)
this.name = 'EnvironmentProviderError'
this.code = code
this.reason = reason
}
}
export function isEnvironmentProviderError(
error: unknown,
code?: EnvironmentProviderErrorCode
): error is EnvironmentProviderError {
return error instanceof EnvironmentProviderError && (code === undefined || error.code === code)
}
@@ -0,0 +1,68 @@
import { mkdirSync, mkdtempSync, readdirSync, rmSync, writeFileSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { afterEach } from 'vitest'
import { encodePairingOffer } from '../../shared/remote-runtime/pairing/pairing'
import { PAIRING_OFFER_VERSION } from '../../shared/remote-runtime/pairing/mobile-relay-pairing-offer'
import type { OrcaVmRecipe } from '../../shared/orca-yaml-hook-types'
import { runEnvironmentProviderDriverContract } from './environment-provider-driver-contract.test-support'
import { ShellRecipeDriver } from './shell-recipe-driver'
const tmpRoots: string[] = []
afterEach(() => {
for (const root of tmpRoots.splice(0)) {
rmSync(root, { recursive: true, force: true })
}
})
// A recipe whose "VMs" are files in a state dir, so the contract can see what destroy left behind.
function makeFileBackedRecipe(): { repoPath: string; stateDir: string; recipe: OrcaVmRecipe } {
const repoPath = mkdtempSync(join(tmpdir(), 'orca-shell-recipe-driver-'))
tmpRoots.push(repoPath)
const stateDir = join(repoPath, 'vms')
mkdirSync(stateDir)
const pairingCode = encodePairingOffer({
v: PAIRING_OFFER_VERSION,
endpoint: 'wss://vm.example.com',
deviceToken: 'token',
publicKeyB64: 'public-key'
})
const vmFile = `require('node:path').join(${JSON.stringify(stateDir)}, process.env.ORCA_VM_INSTANCE_ID)`
const printResult = `console.log(JSON.stringify({ schemaVersion: 1, pairingCode: ${JSON.stringify(pairingCode)}, projectRoot: '/workspace/repo' }))`
const scripts = {
create: `require('node:fs').writeFileSync(${vmFile}, 'running'); ${printResult}`,
suspend: `require('node:fs').writeFileSync(${vmFile}, 'suspended')`,
// Like a real provider: a destroyed VM cannot be woken.
resume: `const fs = require('node:fs'); if (!fs.existsSync(${vmFile})) process.exit(1); fs.writeFileSync(${vmFile}, 'running'); ${printResult}`,
destroy: `require('node:fs').rmSync(${vmFile}, { force: true })`
}
const commands = Object.fromEntries(
Object.entries(scripts).map(([mode, source]) => {
const scriptPath = join(repoPath, `${mode}.js`)
writeFileSync(scriptPath, source)
return [mode, `"${process.execPath}" "${scriptPath}"`]
})
)
return {
repoPath,
stateDir,
recipe: {
id: 'file-backed',
name: 'File-backed VM',
create: commands.create,
suspend: commands.suspend,
resume: commands.resume,
destroy: commands.destroy
}
}
}
runEnvironmentProviderDriverContract('ShellRecipeDriver', async () => {
const { repoPath, stateDir, recipe } = makeFileBackedRecipe()
return {
driver: new ShellRecipeDriver(recipe, repoPath),
liveEnvironmentIds: async () => readdirSync(stateDir),
reopenDriver: () => new ShellRecipeDriver(recipe, repoPath)
}
})
@@ -0,0 +1,286 @@
// orca.yaml environment recipes and plugin VM recipes as an environment provider: each lifecycle
// call runs the recipe's shell step, exactly as the runtime service did before the driver seam.
import { z } from 'zod'
import type { OrcaVmRecipe } from '../../shared/orca-yaml-hook-types'
import {
EphemeralVmRecipeResultSchema,
type EphemeralVmRecipeResult,
type JsonValue
} from '../../shared/ephemeral-vm-recipes'
import {
runEphemeralVmRecipeCleanup,
runEphemeralVmRecipeResume,
runEphemeralVmRecipeStart,
runEphemeralVmRecipeSuspend,
type EphemeralVmRecipeCleanupArgs,
type EphemeralVmRecipeContext,
type EphemeralVmRecipeLifecycleArgs,
type EphemeralVmRecipeStartArgs
} from '../../shared/ephemeral-vm-recipe-runner'
import { EPHEMERAL_VM_FAILURE_COPY } from '../../shared/ephemeral-vm-failure-copy'
import { getProvisionedRootResumeIntegrityError } from '../ephemeral-vm/resume-integrity'
import {
EnvironmentProviderError,
isEnvironmentProviderError,
type EnvironmentCreateSpec,
type EnvironmentHandle,
type EnvironmentProviderCallContext,
type EnvironmentProviderCapabilities,
type EnvironmentProviderDriver,
type EnvironmentReady,
type EnvironmentStatus,
type EnvironmentStatusSnapshot
} from './environment-provider-driver'
export const SHELL_RECIPE_DRIVER_ID = 'shell-recipe'
type RecipeStepArgs<T> = Omit<T, 'recipe' | 'repoPath'>
type RecipeStepFailure = {
error?: string
errorCode?: string
exitCode: number | null
aborted?: true
timedOut?: true
}
const DriverStateSchema = z.object({
recipeResult: EphemeralVmRecipeResultSchema,
projectId: z.string().optional(),
workspaceId: z.string().optional(),
workspaceName: z.string().optional()
})
export class ShellRecipeDriver implements EnvironmentProviderDriver {
readonly id = SHELL_RECIPE_DRIVER_ID
readonly capabilities: EnvironmentProviderCapabilities
// Recipes have no status step, so status only covers calls this instance ran; the runtime
// record stays the persisted source of truth.
private readonly statuses = new Map<string, EnvironmentStatus>()
constructor(
private readonly recipe: OrcaVmRecipe,
private readonly repoPath: string
) {
this.capabilities = {
memoryPause: false,
maxSessionMs: null,
fsPersistOnStop: Boolean(recipe.suspend && recipe.resume),
idleStopMs: null
}
}
// Recipe-shaped steps keep stdout/stderr and failure copy for runtime records and diagnostics.
runCreate(args: RecipeStepArgs<EphemeralVmRecipeStartArgs>) {
return runEphemeralVmRecipeStart({ ...args, recipe: this.recipe, repoPath: this.repoPath })
}
runSuspend(args: RecipeStepArgs<EphemeralVmRecipeLifecycleArgs>) {
return runEphemeralVmRecipeSuspend({ ...args, recipe: this.recipe, repoPath: this.repoPath })
}
runResume(args: RecipeStepArgs<EphemeralVmRecipeLifecycleArgs>) {
return runEphemeralVmRecipeResume({ ...args, recipe: this.recipe, repoPath: this.repoPath })
}
runDestroy(args: RecipeStepArgs<EphemeralVmRecipeCleanupArgs>) {
return runEphemeralVmRecipeCleanup({ ...args, recipe: this.recipe, repoPath: this.repoPath })
}
create(spec: EnvironmentCreateSpec, ctx: EnvironmentProviderCallContext = {}) {
return catalogued(() => this.createOnce(spec, ctx))
}
suspend(handle: EnvironmentHandle, ctx: EnvironmentProviderCallContext = {}) {
return catalogued(() => this.suspendOnce(handle, ctx))
}
resume(handle: EnvironmentHandle, ctx: EnvironmentProviderCallContext = {}) {
return catalogued(() => this.resumeOnce(handle, ctx))
}
destroy(handle: EnvironmentHandle, ctx: EnvironmentProviderCallContext = {}) {
return catalogued(() => this.destroyOnce(handle, ctx))
}
private async createOnce(
spec: EnvironmentCreateSpec,
ctx: EnvironmentProviderCallContext
): Promise<EnvironmentReady> {
ctx.onProgress?.({ phase: 'provisioning' })
const start = await this.runCreate({
context: {
projectId: spec.projectId,
workspaceId: spec.workspaceId,
workspaceName: spec.workspaceName,
repoUrl: spec.repo?.url,
ref: spec.repo?.ref
},
signal: ctx.signal
})
if (!start.ok) {
const error = toProviderError(start)
if (start.recipeResult) {
// The VM exists even though Orca rejected its result; release it rather than leak it.
const cleanup = await this.runDestroy({
context: start.context,
recipeResult: start.recipeResult
})
if (!cleanup.ok || cleanup.skipped) {
const detail = cleanup.error ?? EPHEMERAL_VM_FAILURE_COPY.destroyDisabled
throw new EnvironmentProviderError(error.code, `${error.message} ${detail}`, error.reason)
}
}
throw error
}
const handle = toHandle(start.context, start.result)
this.statuses.set(handle.environmentId, 'running')
return toReady(handle, start.result)
}
private async suspendOnce(
handle: EnvironmentHandle,
ctx: EnvironmentProviderCallContext
): Promise<EnvironmentStatusSnapshot> {
const { context, recipeResult } = this.readHandle(handle)
ctx.onProgress?.({ phase: 'suspending' })
const suspend = await this.runSuspend({ context, recipeResult, signal: ctx.signal })
if (!suspend.ok) {
throw toProviderError(suspend)
}
// No suspend step: the VM keeps running.
const status = suspend.skipped ? 'running' : 'suspended'
this.statuses.set(handle.environmentId, status)
return { status, session: null }
}
private async resumeOnce(
handle: EnvironmentHandle,
ctx: EnvironmentProviderCallContext
): Promise<EnvironmentReady> {
const { context, recipeResult } = this.readHandle(handle)
ctx.onProgress?.({ phase: 'resuming' })
const resume = await this.runResume({ context, recipeResult, signal: ctx.signal })
if (!resume.ok) {
throw toProviderError(resume)
}
const result = resume.skipped ? recipeResult : resume.result
const integrityError = getProvisionedRootResumeIntegrityError(recipeResult, result)
if (integrityError) {
throw new EnvironmentProviderError('conflict', integrityError)
}
this.statuses.set(handle.environmentId, 'running')
return toReady(toHandle(context, result), result)
}
private async destroyOnce(
handle: EnvironmentHandle,
ctx: EnvironmentProviderCallContext
): Promise<void> {
if (this.statuses.get(handle.environmentId) === 'destroyed') {
return
}
const { context, recipeResult } = this.readHandle(handle)
ctx.onProgress?.({ phase: 'destroying' })
const cleanup = await this.runDestroy({ context, recipeResult, signal: ctx.signal })
if (!cleanup.ok) {
throw toProviderError(cleanup)
}
if (cleanup.skipped) {
throw new EnvironmentProviderError(
'invalid_request',
EPHEMERAL_VM_FAILURE_COPY.destroyDisabled,
'destroyDisabled'
)
}
this.statuses.set(handle.environmentId, 'destroyed')
}
async status(handle: EnvironmentHandle): Promise<EnvironmentStatusSnapshot> {
const status = this.statuses.get(handle.environmentId)
if (!status) {
throw new EnvironmentProviderError('not_found', 'This driver has not run that environment.')
}
return { status, session: null }
}
private readHandle(handle: EnvironmentHandle): {
context: EphemeralVmRecipeContext
recipeResult: EphemeralVmRecipeResult
} {
if (handle.driverId !== this.id) {
throw new EnvironmentProviderError('invalid_request', 'Handle belongs to another driver.')
}
if (this.statuses.get(handle.environmentId) === 'destroyed') {
throw new EnvironmentProviderError('not_found', 'Environment was destroyed.')
}
const state = DriverStateSchema.safeParse(handle.driverState)
if (!state.success) {
throw new EnvironmentProviderError('invalid_request', 'Handle has no recipe result.')
}
const { recipeResult, ...fields } = state.data
return {
context: {
...fields,
instanceId: handle.environmentId,
recipeId: this.recipe.id,
repoPath: this.repoPath
},
recipeResult
}
}
}
function toHandle(
context: EphemeralVmRecipeContext,
recipeResult: EphemeralVmRecipeResult
): EnvironmentHandle {
const { instanceId, projectId, workspaceId, workspaceName } = context
if (!instanceId) {
throw new EnvironmentProviderError('invalid_response', 'Recipe run has no instance id.')
}
// Round-trip through JSON so the persisted state is plain data (drops undefined fields).
const driverState: Record<string, JsonValue> = JSON.parse(
JSON.stringify({ recipeResult, projectId, workspaceId, workspaceName })
)
return {
driverId: SHELL_RECIPE_DRIVER_ID,
environmentId: instanceId,
driverState
}
}
function toReady(handle: EnvironmentHandle, result: EphemeralVmRecipeResult): EnvironmentReady {
return { handle, result, session: { startedAt: Date.now(), deadlineAt: null } }
}
// Spawn errors and a missing repo dir surface as plain errors; the contract promises catalogued ones.
async function catalogued<T>(run: () => Promise<T>): Promise<T> {
try {
return await run()
} catch (error) {
if (isEnvironmentProviderError(error)) {
throw error
}
throw new EnvironmentProviderError(
'unavailable',
error instanceof Error ? error.message : String(error)
)
}
}
function toProviderError(failure: RecipeStepFailure): EnvironmentProviderError {
const code = failure.aborted
? 'aborted'
: failure.timedOut
? 'timeout'
: // The step exited cleanly but Orca rejected what it printed.
failure.exitCode === 0
? 'invalid_response'
: 'unavailable'
return new EnvironmentProviderError(
code,
failure.error ?? 'Recipe step failed.',
failure.errorCode ?? null
)
}
@@ -16,10 +16,8 @@ import {
type EphemeralVmFailure
} from '../../shared/ephemeral-vm-failure-copy'
import type { ProvisionEphemeralVmRuntimeArgs } from './runtime-service'
import {
runEphemeralVmRecipeCleanup,
type EphemeralVmRecipeContext
} from '../../shared/ephemeral-vm-recipe-runner'
import type { EphemeralVmRecipeContext } from '../../shared/ephemeral-vm-recipe-runner'
import { ShellRecipeDriver } from '../environment-providers/shell-recipe-driver'
type FailedStart = {
context: EphemeralVmRecipeContext
@@ -74,9 +72,7 @@ async function getCleanupError(
start: FailedStart
): Promise<EphemeralVmFailure | null> {
try {
const cleanup = await runEphemeralVmRecipeCleanup({
repoPath: args.repoPath,
recipe: args.recipe,
const cleanup = await new ShellRecipeDriver(args.recipe, args.repoPath).runDestroy({
context: start.context,
recipeResult: start.recipeResult,
signal: args.signal,
+9 -20
View File
@@ -4,15 +4,12 @@ import {
updateEphemeralVmRuntimeStatus
} from '../../shared/ephemeral-vm-runtime-store'
import type { EphemeralVmRuntimeRecord } from '../../shared/ephemeral-vm-runtimes'
import {
runEphemeralVmRecipeCleanup,
runEphemeralVmRecipeResume,
runEphemeralVmRecipeSuspend,
runEphemeralVmRecipeStart,
type EphemeralVmRecipeContext,
type EphemeralVmRecipeStartFailure,
type EphemeralVmRecipeStartSuccess
import type {
EphemeralVmRecipeContext,
EphemeralVmRecipeStartFailure,
EphemeralVmRecipeStartSuccess
} from '../../shared/ephemeral-vm-recipe-runner'
import { ShellRecipeDriver } from '../environment-providers/shell-recipe-driver'
import {
beginEphemeralVmProvisioning,
endEphemeralVmProvisioning,
@@ -109,9 +106,7 @@ export async function provisionEphemeralVmRuntime(
): Promise<ProvisionEphemeralVmRuntimeResult> {
const writeAhead = beginEphemeralVmProvisioning(args)
try {
const start = await runEphemeralVmRecipeStart({
repoPath: args.repoPath,
recipe: args.recipe,
const start = await new ShellRecipeDriver(args.recipe, args.repoPath).runCreate({
context: {
projectId: args.projectId,
workspaceId: args.workspaceId,
@@ -183,9 +178,7 @@ async function cleanupEphemeralVmRuntimeOnce(
cleanupLastError: null,
updatedAt: now
})
const cleanup = await runEphemeralVmRecipeCleanup({
repoPath: args.repoPath,
recipe: args.recipe,
const cleanup = await new ShellRecipeDriver(args.recipe, args.repoPath).runDestroy({
context: contextFromRuntime(args.repoPath, running),
recipeResult: running.recipeResult,
signal: args.signal,
@@ -227,9 +220,7 @@ export async function suspendEphemeralVmRuntime(
if (!existing.recipeResult) {
throw new Error(`Ephemeral VM runtime never finished provisioning: ${args.runtimeId}`)
}
const suspend = await runEphemeralVmRecipeSuspend({
repoPath: args.repoPath,
recipe: args.recipe,
const suspend = await new ShellRecipeDriver(args.recipe, args.repoPath).runSuspend({
context: contextFromRuntime(args.repoPath, existing),
recipeResult: existing.recipeResult,
signal: args.signal,
@@ -264,9 +255,7 @@ export async function resumeEphemeralVmRuntime(
if (!existing.recipeResult) {
throw new Error(`Ephemeral VM runtime never finished provisioning: ${args.runtimeId}`)
}
const resume = await runEphemeralVmRecipeResume({
repoPath: args.repoPath,
recipe: args.recipe,
const resume = await new ShellRecipeDriver(args.recipe, args.repoPath).runResume({
context: contextFromRuntime(args.repoPath, existing),
recipeResult: existing.recipeResult,
signal: args.signal,
@@ -1,7 +1,7 @@
// Compare window startup from disk with the Loader round trip. Enumerate each divergence as a known defect or accepted difference with its reason.
import { describe, expect, it, vi } from 'vitest'
import type * as AgentStatusModule from '@/lib/agent-status'
import type * as AgentStatusModule from '@/lib/agent-status/aggregation/worktree-agent-status'
import type { ExecutionHostId } from '../../../shared/execution-host'
import type { WorkspaceSessionState } from '../../../shared/workspace-session/workspace-session-state-types'
import { LEGACY_WORKSPACE_LAYOUT_PROFILES } from '../../../shared/workspace-layout/workspace-layout-legacy-profile.test-fixture'
@@ -24,7 +24,7 @@ vi.mock('../../../shared/layout-owner-switch', () => ({
}
}))
vi.mock('sonner', () => ({ toast: { info: vi.fn(), success: vi.fn(), error: vi.fn() } }))
vi.mock('@/lib/agent-status', async (importOriginal) => {
vi.mock('@/lib/agent-status/aggregation/worktree-agent-status', async (importOriginal) => {
const actual = await importOriginal<typeof AgentStatusModule>()
return { ...actual, detectAgentStatusFromTitle: vi.fn().mockReturnValue(null) }
})
@@ -2,7 +2,7 @@ import { Fragment, useLayoutEffect, useRef, useState } from 'react'
import { Folder, GitBranch } from 'lucide-react'
import { translate } from '@/i18n/i18n'
import { useTranslate, type Translate } from '@/i18n/use-translate'
import { AgentIcon } from '@/lib/agent-catalog'
import { AgentIcon } from '@/components/agent/icons/AgentIcon'
import { formatAgentTypeLabel } from '../../../shared/agent-status/presentation/agent-type-label'
import type { ClaudeAccountSwitchPromptSessions } from '@/lib/provider-accounts/claude-account-switch-sessions'
import {
@@ -1,5 +1,5 @@
import { useContext } from 'react'
import { AgentIcon } from '@/lib/agent-catalog'
import { AgentIcon } from '@/components/agent/icons/AgentIcon'
import { agentTypeToIconAgent } from '../../../shared/agent-status/presentation/agent-type-icon-agent'
import { formatAgentTypeLabel } from '../../../shared/agent-status/presentation/agent-type-label'
import { formatShortTimeAgo } from '@/lib/short-time-ago'
@@ -4,7 +4,7 @@ import { useTranslation } from 'react-i18next'
import { toast } from 'sonner'
import { useAppStore } from '@/store'
import { cn } from '@/lib/utils'
import { getAgentCatalog } from '@/lib/agent-catalog'
import { getAgentCatalog } from '@/lib/agent-catalog/agent-catalog'
import { getScreenSubmitModifierLabel } from '@/lib/screen-submit-shortcut'
import { selectProjectCloneUrlPrefill } from '@/lib/project-clone-url-prefill'
import { useContextualTour } from '@/components/contextual-tours/use-contextual-tour'
@@ -1,5 +1,8 @@
import { isExplicitAgentStatusFresh } from '@/lib/pane-agent-evidence'
import { AGENT_STATUS_STALE_AFTER_MS } from '../../../../shared/agent-status/contracts/agent-status-freshness'
import {
isAgentStatusFresh,
AGENT_STATUS_STALE_AFTER_MS
} from '../../../../shared/agent-status/contracts/agent-status-freshness'
import type {
AgentStatusEntry,
AgentStatusState,
@@ -20,7 +23,7 @@ export function freshActivityLiveAgentState(
): ActivityLiveAgentState | null {
if (
!isActivityHookLiveAgentState(entry.state) ||
!isExplicitAgentStatusFresh(entry, now, AGENT_STATUS_STALE_AFTER_MS)
!isAgentStatusFresh(entry, now, AGENT_STATUS_STALE_AFTER_MS)
) {
return null
}
@@ -1,6 +1,6 @@
import React from 'react'
import { MessageSquareText, TerminalSquare } from 'lucide-react'
import { AgentTypeIcon } from '@/lib/agent-type-icon'
import { AgentTypeIcon } from '@/components/agent/icons/agent-type-icon'
import { cn } from '@/lib/utils'
import { useTranslate } from '@/i18n/use-translate'
import { EventRepoBadge, ThreadAgentStateIndicator } from './activity-thread-controls'
@@ -3,7 +3,7 @@ import { Cloud, Copy, FolderGit2, GitBranch, Laptop, LocateFixed, Server } from
import { toast } from 'sonner'
import { useAppStore } from '@/store'
import { RepoBadgeMark } from '@/components/repo/RepoBadgeLabel'
import { AgentTypeIcon } from '@/lib/agent-type-icon'
import { AgentTypeIcon } from '@/components/agent/icons/agent-type-icon'
import { formatAgentTypeLabel } from '../../../../shared/agent-status/presentation/agent-type-label'
import { getWorktreeGitIdentityDisplay } from '../../../../shared/worktree/git-identity-display'
import { jumpToWorktreeFromSidebar } from '@/lib/workspace/activation/worktree-jump-navigation'
@@ -1,7 +1,7 @@
import type { AgentDotState } from '@/components/AgentStateDot'
import { formatAgentTypeLabel } from '../../../../shared/agent-status/presentation/agent-type-label'
import { getAgentRowPrimaryText } from '../../../../shared/agent-status/presentation/agent-row-primary-text'
import { showsAgentToolPreview } from '@/lib/agent-row-tool-preview'
import { showsAgentToolPreview } from '@/lib/agent-status/presentation/agent-row-tool-preview'
import {
agentMainAgentVerdict,
agentVerdictDisplayMark
@@ -1,6 +1,6 @@
import React from 'react'
import { Bell, ExternalLink, X } from 'lucide-react'
import { AgentTypeIcon } from '@/lib/agent-type-icon'
import { AgentTypeIcon } from '@/components/agent/icons/agent-type-icon'
import { formatAgentTypeLabel } from '../../../../shared/agent-status/presentation/agent-type-label'
import { Button } from '@/components/ui/button'
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip'
@@ -2,7 +2,7 @@ import { useState } from 'react'
import { migrationUnsupportedToAgentStatusEntry } from '../../../../shared/migration-unsupported-agent-entry'
import { useAppStore } from '@/store'
import { createAgentStatusEpochSelector } from '@/lib/agent-status-epoch-selector'
import { createAgentStatusEpochSelector } from '@/lib/agent-status/evidence/agent-status-epoch-selector'
import type { AppState } from '@/store/types'
import type { AgentStatusEntry } from '../../../../shared/agent-status/contracts/agent-status-types'
@@ -29,13 +29,13 @@ import {
SelectValue
} from '@/components/ui/select'
import { useTranslate } from '@/i18n/use-translate'
import { getAgentCatalog, getAgentLabel } from '@/lib/agent-catalog'
import { getAgentCatalog, getAgentLabel } from '@/lib/agent-catalog/agent-catalog'
import {
buildAgentSessionContinuationPrompt,
hasFullAgentSessionContext,
type AgentSessionContinuationContextMode,
type AgentSessionContinuationRequest
} from '@/lib/agent-session-continuation'
} from '@/lib/agent-session/context/agent-session-continuation'
import { launchAgentSessionContinuation } from '@/lib/agent-session/launch/continuation/launch-agent-session-continuation'
import { useAppStore } from '@/store'
import { isTuiAgentEnabled } from '../../../../shared/agent-launch/catalog/tui-agent-selection'
@@ -4,12 +4,13 @@ import { Button } from '@/components/ui/button'
import { Command, CommandEmpty, CommandInput, CommandList } from '@/components/ui/command'
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover'
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
import { AgentIcon, type AgentCatalogEntry } from '@/lib/agent-catalog'
import type { AgentCatalogEntry } from '@/lib/agent-catalog/agent-catalog'
import { AgentIcon } from '@/components/agent/icons/AgentIcon'
import {
agentPickerBlankTerminalMatches,
getAgentPickerCommandValue,
searchAgentPickerEntries
} from '@/lib/agent-picker-search'
} from '@/lib/agent-catalog/agent-picker-search'
import { cn } from '@/lib/utils'
import type { TuiAgent } from '../../../../shared/agent-launch/catalog/tui-agent'
import * as state from './agent-combobox-command-state'
@@ -21,7 +21,8 @@ import {
DropdownMenuItem,
DropdownMenuTrigger
} from '@/components/ui/dropdown-menu'
import { AgentIcon, getAgentLabel } from '@/lib/agent-catalog'
import { getAgentLabel } from '@/lib/agent-catalog/agent-catalog'
import { AgentIcon } from '@/components/agent/icons/AgentIcon'
import { useTranslate } from '@/i18n/use-translate'
import { rowLabel } from '../tab-bar/tab-agent-row-presentation'
import type { NewTabAgentMenuModel } from '../tab-bar/use-new-tab-agent-menu-rows'
@@ -7,7 +7,7 @@ import { useAppStore } from '@/store/index'
import { parseExecutionHostId } from '../../../../shared/execution-host'
import { Input } from '@/components/ui/input'
import { Terminal } from 'lucide-react'
import { agentPickerBlankTerminalMatches } from '@/lib/agent-picker-search'
import { agentPickerBlankTerminalMatches } from '@/lib/agent-catalog/agent-picker-search'
import { AgentDefaultContextMenu } from './agent-combobox-items'
import { AgentPickerMenuRow, type AgentPickerMenuLaunch } from './AgentLaunchPickerMenuRow'
import { DropdownMenuItem } from '@/components/ui/dropdown-menu'
@@ -6,7 +6,7 @@ import {
DropdownMenuShortcut,
useDropdownMenuClose
} from '@/components/ui/dropdown-menu'
import { AgentIcon } from '@/lib/agent-catalog'
import { AgentIcon } from '@/components/agent/icons/AgentIcon'
import { useUiLanguageRevision } from '@/i18n/use-ui-language-revision'
import { AgentDefaultContextMenu } from './agent-combobox-items'
import { AgentLaunchSetupButton, type AgentPickerSetupIdentity } from './AgentLaunchSetupButton'
@@ -1,8 +1,9 @@
import { terminalPendingLabel, terminalPendingReason } from '../tab-bar/new-tab-agent-menu-model'
import React, { useState } from 'react'
import { CommandItem, CommandSeparator } from '@/components/ui/command'
import { AgentIcon, getAgentCatalog, type AgentCatalogEntry } from '@/lib/agent-catalog'
import { searchAgentPickerEntries } from '@/lib/agent-picker-search'
import { getAgentCatalog, type AgentCatalogEntry } from '@/lib/agent-catalog/agent-catalog'
import { AgentIcon } from '@/components/agent/icons/AgentIcon'
import { searchAgentPickerEntries } from '@/lib/agent-catalog/agent-picker-search'
import type { AgentLaunchSurface } from '@/lib/agent-session/launch/routing/agent-session-launch-plan'
import type { NewTabAgentMenuRow } from '../../../../shared/agent-launch/picker/agent-launch-picker-rows'
import type { NewTabAgentMenuModel } from '@/components/tab-bar/use-new-tab-agent-menu-rows'
@@ -16,7 +17,7 @@ import { cn } from '@/lib/utils'
import { translate } from '@/i18n/i18n'
import { useTranslate, type Translate } from '@/i18n/use-translate'
import type { TuiAgent } from '../../../../shared/agent-launch/catalog/tui-agent'
import type { resolveAgentMenuSelection } from '@/lib/agent-menu-selection'
import type { resolveAgentMenuSelection } from '@/lib/agent-session/launch/routing/agent-menu-selection'
import { renderAgentComboboxItem } from './agent-combobox-items'
import { AgentSurfaceLaunchButton } from './AgentSurfaceLaunchButton'
@@ -1,8 +1,7 @@
import type React from 'react'
import { getAgentCatalog, getAgentLabel } from '../../../lib/agent-catalog/agent-catalog'
import { ClaudeIcon, DroidIcon, OpenAIIcon } from '@/components/status-bar/icons'
import type { TuiAgent } from '../../../shared/agent-launch/catalog/tui-agent'
import type { TerminalAgent } from '../../../shared/agent-status/identity/terminal-agent'
import { formatAgentTypeLabel } from '../../../shared/agent-status/presentation/agent-type-label'
import type { TerminalAgent } from '../../../../../shared/agent-status/identity/terminal-agent'
import {
AgentLetterIcon,
AiderIcon,
@@ -12,32 +11,7 @@ import {
OpenCodeIcon,
PiIcon
} from './agent-icon-glyphs'
import { createLocalizedCatalog } from '@/i18n/localized-catalog'
import { AGENT_FAVICON_ASSETS } from './agent-favicon-assets'
import { buildAgentCatalogEntries } from './agent-catalog-entries'
export type AgentCatalogEntry = {
id: TuiAgent
label: string
/** Default CLI binary name used for PATH detection. */
cmd: string
searchAliases?: readonly string[]
/** Direct or bundled image URL for agents whose project identity is not represented by a favicon service. */
iconUrl?: string
/** Domain for Google's favicon service — used for agents without an SVG icon. */
faviconDomain?: string
/** Homepage/install docs URL, sourced from the README agent badge list. */
homepageUrl: string
}
export const getAgentCatalog = createLocalizedCatalog(buildAgentCatalogEntries)
// Why: tests and a few legacy call sites still import a catalog snapshot.
export const AGENT_CATALOG: AgentCatalogEntry[] = getAgentCatalog()
export function getAgentLabel(agent: TerminalAgent): string {
return getAgentCatalog().find((entry) => entry.id === agent)?.label ?? formatAgentTypeLabel(agent)
}
export function AgentIcon({
agent,
@@ -0,0 +1,70 @@
import qoderUrl from '../../../../../shared/agent-icons/qoder.png?url'
import type { TuiAgent } from '../../../../../shared/agent-launch/catalog/tui-agent'
import grokUrl from '../../../../../shared/agent-icons/grok.png?url'
import mimoCodeUrl from '../../../../../shared/agent-icons/mimo-code.png?url'
import anteUrl from '../../../../../shared/agent-icons/ante.png?url'
import traeUrl from '../../../../../shared/agent-icons/trae.png?url'
import primeAgentUrl from '../../../../../shared/agent-icons/prime-agent.png?url'
import geminiUrl from '../../../../../shared/agent-icons/gemini.png?url'
import antigravityUrl from '../../../../../shared/agent-icons/antigravity.png?url'
import gooseUrl from '../../../../../shared/agent-icons/goose.png?url'
import ampUrl from '../../../../../shared/agent-icons/amp.png?url'
import kiroUrl from '../../../../../shared/agent-icons/kiro.png?url'
import crushUrl from '../../../../../shared/agent-icons/crush.png?url'
import augUrl from '../../../../../shared/agent-icons/aug.png?url'
import autohandUrl from '../../../../../shared/agent-icons/autohand.png?url'
import clineUrl from '../../../../../shared/agent-icons/cline.png?url'
import freebuffUrl from '../../../../../shared/agent-icons/freebuff.png?url'
import codebuffUrl from '../../../../../shared/agent-icons/codebuff.png?url'
import commandCodeUrl from '../../../../../shared/agent-icons/command-code.png?url'
import continueUrl from '../../../../../shared/agent-icons/continue.png?url'
import cursorUrl from '../../../../../shared/agent-icons/cursor.png?url'
import kimiUrl from '../../../../../shared/agent-icons/kimi.png?url'
import mistralVibeUrl from '../../../../../shared/agent-icons/mistral-vibe.png?url'
import qwenCodeUrl from '../../../../../shared/agent-icons/qwen-code.png?url'
import rovoUrl from '../../../../../shared/agent-icons/rovo.png?url'
import hermesUrl from '../../../../../shared/agent-icons/hermes.png?url'
import devinUrl from '../../../../../shared/agent-icons/devin.png?url'
import museUrl from '../../../../../shared/agent-icons/muse.png?url'
import zcodeUrl from '../../../../../shared/agent-icons/zcode.png?url'
import openclawUrl from '../../../../../shared/agent-icons/openclaw.png?url'
import dshUrl from '../../../../../shared/agent-icons/dsh.png?url'
import jcodeUrl from '../../../../../shared/agent-icons/jcode.png?url'
import codebuddyUrl from '../../../../../shared/agent-icons/codebuddy.png?url'
// Bundle favicons for offline/Google-blocked regions (#8451); shared/agent-icons also supplies mobile-agent-icon-assets.ts.
export const AGENT_FAVICON_ASSETS: Partial<Record<TuiAgent, string>> = {
grok: grokUrl,
'mimo-code': mimoCodeUrl,
ante: anteUrl,
trae: traeUrl,
'prime-agent': primeAgentUrl,
qoder: qoderUrl,
'qoder-cn': qoderUrl,
gemini: geminiUrl,
antigravity: antigravityUrl,
goose: gooseUrl,
amp: ampUrl,
kiro: kiroUrl,
crush: crushUrl,
aug: augUrl,
autohand: autohandUrl,
cline: clineUrl,
codebuff: codebuffUrl,
freebuff: freebuffUrl,
'command-code': commandCodeUrl,
continue: continueUrl,
cursor: cursorUrl,
kimi: kimiUrl,
'mistral-vibe': mistralVibeUrl,
'qwen-code': qwenCodeUrl,
rovo: rovoUrl,
hermes: hermesUrl,
devin: devinUrl,
muse: museUrl,
dsh: dshUrl,
zcode: zcodeUrl,
openclaw: openclawUrl,
jcode: jcodeUrl,
codebuddy: codebuddyUrl
}
@@ -1,5 +1,5 @@
import React from 'react'
import { cn } from './utils'
import { cn } from '../../../lib/utils'
export function PiIcon({
size = 14,
@@ -1,8 +1,8 @@
import type React from 'react'
import type { AgentType } from '../../../shared/agent-status/contracts/agent-status-types'
import { AgentIcon } from './agent-catalog'
import type { AgentType } from '../../../../../shared/agent-status/contracts/agent-status-types'
import { AgentIcon } from './AgentIcon'
import { AgentLetterIcon } from './agent-icon-glyphs'
import { agentTypeToIconAgent } from '../../../shared/agent-status/presentation/agent-type-icon-agent'
import { agentTypeToIconAgent } from '../../../../../shared/agent-status/presentation/agent-type-icon-agent'
/** Status-row icon: known agents get their brand icon, any other OSC 7501 program its first letter. */
export function AgentTypeIcon({
@@ -16,7 +16,7 @@ import {
import { composeActiveTerminalTheme } from '@/components/terminal-pane/appearance/terminal-appearance'
import { useSystemPrefersDark } from '@/hooks/theme/use-system-prefers-dark'
import { useIntlLocale, useTranslate } from '@/i18n/use-translate'
import { AgentIcon } from '@/lib/agent-catalog'
import { AgentIcon } from '@/components/agent/icons/AgentIcon'
import { buildFontFamily } from '@/lib/monospace-font-family'
import { resolveEffectiveTerminalAppearance } from '@/lib/terminal-theme'
import { cn } from '@/lib/utils'
@@ -10,7 +10,7 @@ import {
resolveHostCapabilities,
type ProspectiveWorkspace
} from '@/lib/agent-session/launch/routing/agent-launch-route-input'
import type { AgentCatalogEntry } from '@/lib/agent-catalog'
import type { AgentCatalogEntry } from '@/lib/agent-catalog/agent-catalog'
import { parseExecutionHostId } from '../../../../shared/execution-host'
import { AUTOMATION_LAUNCH_SETUP_RUNTIME_CAPABILITY } from '../../../../shared/automations/automation-runtime-capabilities'
import { automationLegacyArguments } from '../../../../shared/automations/launch/automation-legacy-arguments'
@@ -3,7 +3,8 @@ import { Pencil, Pause, Play, Trash2 } from 'lucide-react'
import { Button } from '@/components/ui/button'
import { Badge } from '@/components/ui/badge'
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
import { getAgentCatalog, AgentIcon } from '@/lib/agent-catalog'
import { getAgentCatalog } from '@/lib/agent-catalog/agent-catalog'
import { AgentIcon } from '@/components/agent/icons/AgentIcon'
import type { Automation } from '../../../../shared/automations/automation-definition'
import type { AutomationRun } from '../../../../shared/automations/history/automation-run'
import { formatUiAutomationSchedule } from './automation-schedule-label'
@@ -9,7 +9,7 @@ import {
automationLaunchWorkspace
} from './automation-launch-surface'
import { Dialog, DialogContent } from '@/components/ui/dialog'
import { getAgentCatalog } from '@/lib/agent-catalog'
import { getAgentCatalog } from '@/lib/agent-catalog/agent-catalog'
import { filterEnabledTuiAgents } from '../../../../shared/agent-launch/catalog/tui-agent-selection'
import type {
AutomationLaunchPreferences,
@@ -3,7 +3,7 @@
import { act, cleanup, fireEvent, render, screen } from '@testing-library/react'
import { useState } from 'react'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { AGENT_CATALOG } from '@/lib/agent-catalog'
import { AGENT_CATALOG } from '@/lib/agent-catalog/agent-catalog'
import { TooltipProvider } from '@/components/ui/tooltip'
import { useAppStore } from '@/store'
import { createCompatibleRuntimeStatusResponse } from '@/runtime/rpc/testing/runtime-compatibility-test-fixture'
@@ -8,7 +8,7 @@ import type { OrcaHooks } from '../../../../shared/orca-yaml-hook-types'
import type { ProjectHostSetup } from '../../../../shared/project-types'
import type { Repo } from '../../../../shared/repo-types'
import type { Worktree } from '../../../../shared/worktree/types'
import type { AgentCatalogEntry } from '@/lib/agent-catalog'
import type { AgentCatalogEntry } from '@/lib/agent-catalog/agent-catalog'
import { AUTOMATION_EDITOR_SECTION_LABEL_CLASS, Field } from './automation-page-parts'
import { AutomationMissedRunGraceField } from './AutomationMissedRunGraceField'
import { AutomationPrecheckFields } from './AutomationPrecheckFields'
@@ -16,8 +16,9 @@ import {
DropdownMenuSubTrigger,
DropdownMenuTrigger
} from '@/components/ui/dropdown-menu'
import { AgentIcon, getAgentCatalog } from '@/lib/agent-catalog'
import { searchAgentPickerEntries } from '@/lib/agent-picker-search'
import { getAgentCatalog } from '@/lib/agent-catalog/agent-catalog'
import { AgentIcon } from '@/components/agent/icons/AgentIcon'
import { searchAgentPickerEntries } from '@/lib/agent-catalog/agent-picker-search'
import { useTranslate } from '@/i18n/use-translate'
import { useBoundedHostRows } from '@/components/host-picker/use-bounded-host-rows'
import { HostListSearchField } from '@/components/host-picker/HostListSearchField'
@@ -19,7 +19,7 @@ import {
} from '@/components/ui/dropdown-menu'
import { Button } from '@/components/ui/button'
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
import { AgentIcon } from '@/lib/agent-catalog'
import { AgentIcon } from '@/components/agent/icons/AgentIcon'
import { cn } from '@/lib/utils'
import type { AutomationRun } from '../../../../shared/automations/history/automation-run'
import { getAutomationRunRepoId } from '../../../../shared/automations/history/automation-run-identity'
@@ -1,6 +1,6 @@
import { buildAutomationRrule } from '../../../../shared/automations/scheduling/automation-schedule-occurrences'
import { automationLaunchInputs } from '../../../../shared/automations/launch/automation-launch-choices'
import { getAgentCatalog } from '@/lib/agent-catalog'
import { getAgentCatalog } from '@/lib/agent-catalog/agent-catalog'
import type { AutomationPrecheck } from '../../../../shared/automations/automation-definition'
import type { Worktree } from '../../../../shared/worktree/types'
import {
@@ -1,6 +1,6 @@
import { useCallback, useMemo } from 'react'
import { shallow } from 'zustand/shallow'
import type { AgentCatalogEntry } from '@/lib/agent-catalog'
import type { AgentCatalogEntry } from '@/lib/agent-catalog/agent-catalog'
import type {
AgentLaunchRouteStore,
ProspectiveWorkspace
@@ -5,7 +5,7 @@ import {
} from '../../../../shared/agent-launch/catalog/tui-agent-selection'
import type { Repo } from '../../../../shared/repo-types'
import type { Worktree } from '../../../../shared/worktree/types'
import { getAgentCatalog } from '@/lib/agent-catalog'
import { getAgentCatalog } from '@/lib/agent-catalog/agent-catalog'
import { useAppStore } from '@/store'
import { useRepoMap } from '@/store/repos/use-repository-catalog'
import { useWorktreeMap } from '@/store/slices/worktrees/listing/use-worktree-catalog'
@@ -11,7 +11,10 @@ import {
buildExplicitEntriesByTabId,
type TabPaneInputSources
} from '../../../../shared/sidebar-list/smart-attention'
import { isExplicitAgentStatusFresh } from '@/lib/pane-agent-evidence'
import {
isAgentStatusFresh,
AGENT_STATUS_STALE_AFTER_MS
} from '../../../../shared/agent-status/contracts/agent-status-freshness'
import {
getLiveAgentStatusByWorktreeId,
type LiveAgentWorktreeStatus
@@ -32,7 +35,6 @@ import {
} from '@/components/tab-bar/terminal-tab-activity-status'
import { useTranslate } from '@/i18n/use-translate'
import { AGENT_STATUS_STALE_AFTER_MS } from '../../../../shared/agent-status/contracts/agent-status-freshness'
import type { AgentStatusEntry } from '../../../../shared/agent-status/contracts/agent-status-types'
import { parsePaneKey } from '../../../../shared/workspace-layout/stable-pane-id'
import type { BrowserWorkspace } from '../../../../shared/browser-workspace-types'
@@ -162,7 +164,7 @@ function buildLiveAgentStatusPaneIdsByTabId(
}
if (
entry.restoredUnconfirmed !== true &&
!isExplicitAgentStatusFresh(entry, now, AGENT_STATUS_STALE_AFTER_MS)
!isAgentStatusFresh(entry, now, AGENT_STATUS_STALE_AFTER_MS)
) {
stalePaneIds.add(paneId)
continue
@@ -7,7 +7,7 @@ import {
GitPullRequestClosed,
GitPullRequestDraft
} from 'lucide-react'
import { AgentTypeIcon } from '@/lib/agent-type-icon'
import { AgentTypeIcon } from '@/components/agent/icons/agent-type-icon'
import { AgentQuestionIcon } from '@/components/AgentQuestionIcon'
import { AgentStateDot } from '@/components/AgentStateDot'
import { RepoIconGlyph } from '@/components/repo/repo-icon'
@@ -1,6 +1,6 @@
import { useEffect, useId, useRef } from 'react'
import { SquareArrowOutUpRight, XIcon } from 'lucide-react'
import { AgentTypeIcon } from '@/lib/agent-type-icon'
import { AgentTypeIcon } from '@/components/agent/icons/agent-type-icon'
import { formatAgentTypeLabel } from '../../../../shared/agent-status/presentation/agent-type-label'
import { agentStateLabel } from '@/components/AgentStateDot'
import { Dialog, DialogContent, DialogTitle } from '@/components/ui/dialog'
@@ -1,6 +1,9 @@
import React, { useState, useCallback } from 'react'
import { cn } from '@/lib/utils'
import { opensClaudeParentConversation, viewClaudeAgentFromRow } from '@/lib/claude-agent-row-view'
import {
opensClaudeParentConversation,
viewClaudeAgentFromRow
} from '@/lib/agent-session/navigation/claude-agent-row-view'
import { useClaudeAgentRowView } from './use-claude-agent-row-view'
import {
AgentStateDot,
@@ -8,26 +11,32 @@ import {
agentStateProgressLabel,
type AgentDotState
} from '@/components/AgentStateDot'
import { AgentTypeIcon } from '@/lib/agent-type-icon'
import { AgentTypeIcon } from '@/components/agent/icons/agent-type-icon'
import { formatAgentTypeLabel } from '../../../../shared/agent-status/presentation/agent-type-label'
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
import { DashboardAgentRowMessage } from './DashboardAgentRowMessage'
import { DashboardAgentRowTrailingControls } from './DashboardAgentRowTrailingControls'
import { DashboardAgentRowToolStep } from './DashboardAgentRowToolStep'
import { programStatusAttentionLine } from '../../../../shared/program-status/presentation'
import { agentRowToolInput, showsAgentToolPreview } from '@/lib/agent-row-tool-preview'
import {
agentRowToolInput,
showsAgentToolPreview
} from '@/lib/agent-status/presentation/agent-row-tool-preview'
import { resolveRowProgramStatus } from '@/lib/program-status/agent-row-presentation'
import { agentRowStoppingLabel } from '@/lib/agent-row-stopping-label'
import { agentRowStoppingLabel } from '@/lib/agent-status/presentation/agent-row-stopping-label'
import {
agentNoUpdateLabel,
formatCompactDuration
} from '../../../../shared/agent-status/presentation/agent-row-decay-state'
import { agentRowDisplayDotState, agentRowDotState as asDotState } from '@/lib/agent-row-dot-state'
import {
agentRowDisplayDotState,
agentRowDotState as asDotState
} from '@/lib/agent-status/presentation/agent-row-dot-state'
import {
agentMainAgentVerdict,
agentVerdictDisplayMark
} from '../../../../shared/agent-status/lifecycle/agent-main-agent-verdict'
import { agentVerdictStatusLine } from '@/lib/agent-verdict-status-line'
import { agentVerdictStatusLine } from '@/lib/agent-status/presentation/agent-verdict-status-line'
import type { DashboardAgentRow as DashboardAgentRowData } from './useDashboardData'
import { getAgentRowPrimaryText } from '../../../../shared/agent-status/presentation/agent-row-primary-text'
import { useAgentRowConversationName } from './use-agent-row-conversation-name'
@@ -2,7 +2,10 @@ import { agentEntrySessionStartedAt } from '../../../../shared/agent-session/lif
import { useEffect, useRef } from 'react'
import { useShallow } from 'zustand/react/shallow'
import { useAppStore } from '@/store'
import { isExplicitAgentStatusFresh } from '@/lib/pane-agent-evidence'
import {
isAgentStatusFresh,
AGENT_STATUS_STALE_AFTER_MS
} from '../../../../shared/agent-status/contracts/agent-status-freshness'
import type { DashboardAgentRow } from './useDashboardData'
import type { RetainedAgentEntry } from '@/store/slices/agent-status/agent-status-contract'
import type { FolderWorkspace } from '../../../../shared/folder-workspaces/folder-workspace-types'
@@ -11,7 +14,7 @@ import type { TerminalTab } from '../../../../shared/workspace-layout/terminal-t
import type { Worktree } from '../../../../shared/worktree/types'
import { folderWorkspaceKey } from '../../../../shared/workspace-scope'
import { resolveAgentPaneAuthorityKey } from '@/store/slices/agent-status/agent-pane-authority'
import { AGENT_STATUS_STALE_AFTER_MS } from '../../../../shared/agent-status/contracts/agent-status-freshness'
import type { AgentStatusEntry } from '../../../../shared/agent-status/contracts/agent-status-types'
import { parsePaneKey } from '../../../../shared/workspace-layout/stable-pane-id'
import { agentTurnEndedOnPurpose } from '../../../../shared/agent-status/lifecycle/agent-main-agent-verdict'
@@ -116,7 +119,7 @@ export function buildRetainedAgentsSyncSnapshot(args: RetainedAgentsSyncSnapshot
if (!owner) {
continue
}
const isFresh = isExplicitAgentStatusFresh(entry, args.now, AGENT_STATUS_STALE_AFTER_MS)
const isFresh = isAgentStatusFresh(entry, args.now, AGENT_STATUS_STALE_AFTER_MS)
const shouldDecay =
!isFresh &&
(entry.state === 'working' || entry.state === 'blocked' || entry.state === 'waiting')
@@ -22,24 +22,24 @@ import {
} from '@/runtime/native-chat/naming/structured-chat-name-observation'
import { QuickLaunchAgentMenuItems } from '@/components/tab-bar/QuickLaunchButton'
import { AgentStateDot, agentStateLabel } from '@/components/AgentStateDot'
import { AgentTypeIcon } from '@/lib/agent-type-icon'
import { AgentTypeIcon } from '@/components/agent/icons/agent-type-icon'
import {
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuSeparator
} from '@/components/ui/dropdown-menu'
import { focusTerminalTabSurface } from '@/lib/focus-terminal-tab-surface'
import '@/lib/active-agent-note-send'
import '@/lib/agent-session/messaging/terminal/active-agent-note-send'
import {
activeAgentNotesSendFailureMessage,
type ActiveAgentNotesSendResult
} from '@/lib/active-agent-note-send-result'
import { sendMessageToAgent } from '@/lib/agent-message-send'
} from '@/lib/agent-session/messaging/terminal/active-agent-note-send-result'
import { sendMessageToAgent } from '@/lib/agent-session/messaging/agent-message-send'
import {
deriveNotesSendAgentTargets,
type NotesSendAgentTarget
} from '@/lib/notes-send-agent-targets'
import { agentKindForAgentType } from '@/lib/agent-status'
} from '@/lib/agent-session/messaging/notes-send-agent-targets'
import { agentKindForAgentType } from '@/lib/agent-status/aggregation/worktree-agent-status'
import { formatAgentTypeLabel } from '../../../../../shared/agent-status/presentation/agent-type-label'
import { track } from '@/lib/telemetry'
import { useNow } from '@/hooks/use-now'
@@ -49,10 +49,10 @@ import { useWorktreeAgentRows } from '@/components/sidebar/workspace-card/activi
import { useAgentRowConversationName } from '@/components/dashboard/use-agent-row-conversation-name'
import { getAgentRowPrimaryText } from '../../../../../shared/agent-status/presentation/agent-row-primary-text'
import type { LaunchSource } from '../../../../../shared/telemetry-property-schemas'
import { agentRowDisplayDotState } from '@/lib/agent-row-dot-state'
import { agentRowDisplayDotState } from '@/lib/agent-status/presentation/agent-row-dot-state'
import { translate } from '@/i18n/i18n'
import { useTranslate, type Translate } from '@/i18n/use-translate'
import { agentSendDisabledReasonLabel } from '@/lib/agent-send-disabled-reason-label'
import { agentSendDisabledReasonLabel } from '@/lib/agent-session/messaging/agent-send-disabled-reason-label'
import { addQuoteToAgent } from '@/components/native-chat/selection-quotes/native-chat-workspace-selection'
import React, { useCallback, useMemo } from 'react'
import { orderSendTargetsByWorktreeAgentRows } from './review-notes-send-target-order'
@@ -1,5 +1,5 @@
import type { DashboardAgentRow as DashboardAgentRowData } from '@/components/dashboard/useDashboardData'
import type { NotesSendAgentTarget } from '@/lib/notes-send-agent-targets'
import type { NotesSendAgentTarget } from '@/lib/agent-session/messaging/notes-send-agent-targets'
export type OrderedSendTarget = {
target: NotesSendAgentTarget
@@ -1,5 +1,5 @@
import { useAppStore } from '@/store'
import { ORCA_CLI_SKILL_NAME } from '@/lib/agent-feature-skill-names'
import { ORCA_CLI_SKILL_NAME } from '@/lib/skills/installation/agent-feature-skill-names'
import { AgentSkillSetupPanel } from '../skills/setup/AgentSkillSetupPanel'
import type { useMobileEmulatorAgentSetupState } from './use-mobile-emulator-agent-setup-state'
import { useTranslate } from '@/i18n/use-translate'
@@ -1,7 +1,7 @@
import { useActiveProjectSkillRuntime } from '@/hooks/useActiveProjectSkillRuntime'
import { useCallback, useEffect, useState } from 'react'
import { toast } from 'sonner'
import { ORCA_CLI_SKILL_NAME } from '@/lib/agent-feature-skill-names'
import { ORCA_CLI_SKILL_NAME } from '@/lib/skills/installation/agent-feature-skill-names'
import {
GLOBAL_AGENT_SKILL_SOURCE_KINDS,
useInstalledAgentSkill
@@ -5,7 +5,7 @@ import { usePrefersReducedMotion } from '@/components/feature-wall/feature-wall-
import { nativeChatPermissionModeLabel } from '@/components/native-chat/session/options/controls/native-chat-permission-mode-labels'
import { nativeChatToolRowVerb } from '@/components/native-chat/tools/lines/native-chat-tool-line-label'
import { useIntlLocale, useTranslate } from '@/i18n/use-translate'
import { AgentIcon } from '@/lib/agent-catalog'
import { AgentIcon } from '@/components/agent/icons/AgentIcon'
import { cn } from '@/lib/utils'
import {
CHAT_DEMO_FILE,
@@ -1,6 +1,9 @@
import { CliSkillSetupTerminal } from './CliSkillSetupTerminal'
import { AgentSkillSetupPanel } from '@/components/skills/setup/AgentSkillSetupPanel'
import { ORCA_CLI_SKILL_NAME, ORCHESTRATION_SKILL_NAME } from '@/lib/agent-feature-skill-names'
import {
ORCA_CLI_SKILL_NAME,
ORCHESTRATION_SKILL_NAME
} from '@/lib/skills/installation/agent-feature-skill-names'
import { useActiveProjectSkillRuntime } from '@/hooks/useActiveProjectSkillRuntime'
import {
GLOBAL_AGENT_SKILL_SOURCE_KINDS,
@@ -8,7 +8,7 @@ import {
buildSkillCommandForRuntime,
buildSkillSetupTerminalCommand
} from '@/lib/skill-runtime-command'
import { ORCA_CLI_ORCHESTRATION_SKILL_INSTALL_COMMAND } from '@/lib/agent-feature-install-commands'
import { ORCA_CLI_ORCHESTRATION_SKILL_INSTALL_COMMAND } from '@/lib/skills/installation/agent-feature-install-commands'
import { useActiveProjectSkillRuntime } from '@/hooks/useActiveProjectSkillRuntime'
import { useTranslate } from '@/i18n/use-translate'
@@ -16,7 +16,7 @@ import {
DEFAULT_AI_VAULT_GROUP,
DEFAULT_AI_VAULT_HIDE_EMPTY_SESSIONS
} from '@/components/right-sidebar/ai-vault/scope/ai-vault-view-defaults'
import { AgentIcon } from '@/lib/agent-catalog'
import { AgentIcon } from '@/components/agent/icons/AgentIcon'
import { useTranslate } from '@/i18n/use-translate'
import type { SessionSearchDemoRow } from './session-search-feature-tip-demo'
@@ -5,7 +5,7 @@ import {
import { bundledSkillSetupActionLabel } from '../skills/setup/bundled-skill-setup-copy'
import { useOnboardingSkillRuntime } from '@/hooks/use-onboarding-skill-runtime'
import { FeatureSetupInlineTerminal } from '../onboarding/FeatureSetupInlineTerminal'
import { buildAgentFeatureSkillInstallCommand } from '@/lib/agent-feature-install-commands'
import { buildAgentFeatureSkillInstallCommand } from '@/lib/skills/installation/agent-feature-install-commands'
import { buildSkillCommandForRuntime } from '../../lib/skill-runtime-command'
import type { OnboardingFeatureSetupRuntimeContext } from '../onboarding/onboarding-feature-setup-runtime'
import { useCallback, useEffect, useRef, useState } from 'react'
@@ -1,5 +1,5 @@
import type { JSX } from 'react'
import { ORCA_CLI_SKILL_NAME } from '@/lib/agent-feature-skill-names'
import { ORCA_CLI_SKILL_NAME } from '@/lib/skills/installation/agent-feature-skill-names'
import { BROWSER_USE_ENABLED_STORAGE_KEY } from '@/lib/browser/browser-use-setup-state'
import type { InstalledAgentSkillState } from '@/hooks/useInstalledAgentSkills'
import { useActiveProjectSkillRuntime } from '@/hooks/useActiveProjectSkillRuntime'
@@ -1,9 +1,9 @@
import { useBundledSkillInstallAction } from '@/hooks/use-bundled-skill-install-action'
import { bundledSkillSetupActionLabel } from '../skills/setup/bundled-skill-setup-copy'
import { ORCA_CLI_SKILL_NAME } from '@/lib/agent-feature-skill-names'
import { ORCA_CLI_SKILL_NAME } from '@/lib/skills/installation/agent-feature-skill-names'
import { useOnboardingSkillRuntime } from '@/hooks/use-onboarding-skill-runtime'
import { FeatureSetupInlineTerminal } from '../onboarding/FeatureSetupInlineTerminal'
import { buildAgentFeatureSkillInstallCommand } from '@/lib/agent-feature-install-commands'
import { buildAgentFeatureSkillInstallCommand } from '@/lib/skills/installation/agent-feature-install-commands'
import { buildSkillCommandForRuntime } from '../../lib/skill-runtime-command'
import type { OnboardingFeatureSetupRuntimeContext } from '../onboarding/onboarding-feature-setup-runtime'
import { useCallback, useState } from 'react'
@@ -1,5 +1,5 @@
import type { JSX } from 'react'
import { ORCHESTRATION_SKILL_NAME } from '@/lib/agent-feature-skill-names'
import { ORCHESTRATION_SKILL_NAME } from '@/lib/skills/installation/agent-feature-skill-names'
import type { InstalledAgentSkillState } from '@/hooks/useInstalledAgentSkills'
import { useActiveProjectSkillRuntime } from '@/hooks/useActiveProjectSkillRuntime'
import { AgentSkillSetupPanel } from '../skills/setup/AgentSkillSetupPanel'
@@ -7,7 +7,7 @@ import {
COMPUTER_USE_SKILL_NAME,
ORCA_CLI_SKILL_NAME,
ORCHESTRATION_SKILL_NAME
} from '@/lib/agent-feature-skill-names'
} from '@/lib/skills/installation/agent-feature-skill-names'
import {
GLOBAL_AGENT_SKILL_SOURCE_KINDS,
useInstalledAgentSkill
@@ -2,7 +2,8 @@ import { useEffect, useRef, useState } from 'react'
import type { JSX, ReactNode } from 'react'
import { Wrench } from 'lucide-react'
import { AgentStateDot } from '@/components/AgentStateDot'
import { getAgentCatalog, AgentIcon, type AgentCatalogEntry } from '@/lib/agent-catalog'
import { getAgentCatalog, type AgentCatalogEntry } from '@/lib/agent-catalog/agent-catalog'
import { AgentIcon } from '@/components/agent/icons/AgentIcon'
import { ClaudeIcon, OpenAIIcon } from '../../status-bar/icons'
import { installWindowVisibilityInterval } from '@/lib/window-visibility-interval'
import { cn } from '@/lib/utils'
@@ -8,7 +8,7 @@ import {
type CommitMessageAgentChoice,
type CommitMessageModelCapability
} from '../../../../shared/source-control/ai/generation/commit-message-agent-spec'
import { getAgentCatalog } from '@/lib/agent-catalog'
import { getAgentCatalog } from '@/lib/agent-catalog/agent-catalog'
export const EMPTY_COMMIT_MESSAGE_AI_SETTINGS: CommitMessageAiSettings = {
enabled: false,
@@ -1,4 +1,7 @@
import { ORCA_CLI_SKILL_NAME, ORCHESTRATION_SKILL_NAME } from '@/lib/agent-feature-skill-names'
import {
ORCA_CLI_SKILL_NAME,
ORCHESTRATION_SKILL_NAME
} from '@/lib/skills/installation/agent-feature-skill-names'
import {
GLOBAL_AGENT_SKILL_SOURCE_KINDS,
useInstalledAgentSkill
@@ -11,7 +11,7 @@ import { LOCAL_COMMIT_MESSAGE_HOST_KEY } from '../../../../shared/source-control
import { getDefaultSourceControlAiSettings } from '../../../../shared/source-control/ai/settings/source-control-ai-settings'
import { getTextGenerationModels } from '../../../../shared/source-control/ai/settings/source-control-ai-model-selection'
import { isTuiAgent } from '../../../../shared/agent-launch/catalog/tui-agent-config'
import { getAgentCatalog } from '@/lib/agent-catalog'
import { getAgentCatalog } from '@/lib/agent-catalog/agent-catalog'
import { useAppStore } from '@/store/index'
import type {
AgentPickerDraft,
@@ -9,7 +9,7 @@ import {
import { AgentSkillSetupPanel } from '@/components/skills/setup/AgentSkillSetupPanel'
import { IntegrationStatusPill } from '@/components/integration-status-pill'
import { SkillFreshnessStatusPill } from '@/components/skills/SkillFreshnessStatusPill'
import { ORCHESTRATION_SKILL_NAME } from '@/lib/agent-feature-skill-names'
import { ORCHESTRATION_SKILL_NAME } from '@/lib/skills/installation/agent-feature-skill-names'
import {
GLOBAL_AGENT_SKILL_SOURCE_KINDS,
useInstalledAgentSkill
@@ -2,7 +2,8 @@ import { useCallback, useMemo } from 'react'
import { Maximize2, Minimize2, Minus } from 'lucide-react'
import { Button } from '@/components/ui/button'
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
import { getAgentCatalog, AgentIcon } from '@/lib/agent-catalog'
import { getAgentCatalog } from '@/lib/agent-catalog/agent-catalog'
import { AgentIcon } from '@/components/agent/icons/AgentIcon'
import { focusTerminalTabSurface } from '@/lib/focus-terminal-tab-surface'
import { launchAgentInNewTab } from '@/lib/agent-session/launch/new-tab/launch-agent-in-new-tab'
import { newAgentLaunchRequestId } from '@/lib/agent-session/launch/routing/agent-launch-request-id'
@@ -1,5 +1,5 @@
import { useCallback, useEffect } from 'react'
import { isOrcaCliAvailableOnPath } from '@/lib/agent-skill-cli-prerequisite'
import { isOrcaCliAvailableOnPath } from '@/lib/skills/installation/agent-skill-cli-prerequisite'
import {
ORCHESTRATION_SETUP_STATE_EVENT,
hasOrchestrationSetupMarker,
@@ -4,7 +4,7 @@ import {
captureNativeChatStagedInput
} from '../../drafts/native-chat-draft-attachment-staging'
import { mayHoldAgentReferences } from '../../../../../../shared/orchestration/mailbox/orchestration-agent-reference'
import { getAgentLabel } from '@/lib/agent-catalog'
import { getAgentLabel } from '@/lib/agent-catalog/agent-catalog'
import { formatAgentTypeLabel } from '../../../../../../shared/agent-status/presentation/agent-type-label'
import { isTuiAgent } from '../../../../../../shared/agent-launch/catalog/tui-agent-config'
import { MAX_SKILL_REFS } from '../../../../../../shared/rpc-contract/structured-agent-session-message-params'
@@ -1,5 +1,5 @@
import { TriangleAlert } from 'lucide-react'
import { AgentIcon } from '@/lib/agent-catalog'
import { AgentIcon } from '@/components/agent/icons/AgentIcon'
import { agentTypeToIconAgent } from '../../../../../shared/agent-status/presentation/agent-type-icon-agent'
import { cn } from '@/lib/utils'
import type { AgentType } from '../../../../../shared/agent-status/contracts/agent-status-types'
@@ -9,7 +9,7 @@ import {
import { createWorktreeAgentFreshnessSelector } from '@/components/sidebar/workspace-card/activity/worktree-agent-freshness-selector'
import '@/components/sidebar/workspace-card/activity/worktree-agent-row-selectors'
import { selectWorktreeAgentOrchestration as selectRuntimeAgentOrchestrationForWorktree } from '@/components/sidebar/workspace-card/activity/worktree-agent-orchestration-index'
import { agentRowDisplayDotState } from '@/lib/agent-row-dot-state'
import { agentRowDisplayDotState } from '@/lib/agent-status/presentation/agent-row-dot-state'
import { resolveRowProgramStatus } from '@/lib/program-status/agent-row-presentation'
import {
agentMessageSenderView,
@@ -1,7 +1,7 @@
import { useId } from 'react'
import { ChevronDown } from 'lucide-react'
import { AgentStateDot } from '@/components/AgentStateDot'
import { AgentTypeIcon } from '@/lib/agent-type-icon'
import { AgentTypeIcon } from '@/components/agent/icons/agent-type-icon'
import { translate } from '@/i18n/i18n'
import { useTranslate, type Translate } from '@/i18n/use-translate'
import { cn } from '@/lib/utils'
@@ -9,7 +9,7 @@ import { AgentSessionContinuationDialog } from '@/components/agent-session-conti
import {
buildAgentSessionContinuationPrompt,
type AgentSessionContinuationRequest
} from '@/lib/agent-session-continuation'
} from '@/lib/agent-session/context/agent-session-continuation'
import { isTuiAgent } from '../../../../../../shared/agent-launch/catalog/tui-agent-config'
import { callStructuredAgentSession } from '@/runtime/native-chat/requests/structured-agent-session-call'
import { supportsStructuredAgentSessionContinuationContext } from '@/runtime/native-chat/host-capabilities/structured-agent-session-host-support'
@@ -2,7 +2,7 @@ import { useCallback, useLayoutEffect, useRef, useState } from 'react'
import { executionHostIdForStructuredTarget } from '@/runtime/native-chat/session-ownership/structured-agent-session-owner'
import { useTranslate } from '@/i18n/use-translate'
import type { AgentType } from '../../../../../../shared/agent-status/contracts/agent-status-types'
import { copyAgentSessionContext } from '@/lib/copy-agent-session-context'
import { copyAgentSessionContext } from '@/lib/agent-session/context/copy-agent-session-context'
import {
resolveNativeChatSessionContext,
type NativeChatSessionContextSource
@@ -7,9 +7,9 @@ import {
} from '../../../../../shared/workspace-layout/stable-pane-id'
import type { AppState } from '@/store/types'
import { useAppStore } from '@/store'
import type { AgentMessageTarget } from '@/lib/agent-message-target'
import { sendMessageToAgent } from '@/lib/agent-message-send'
import type { ActiveAgentNotesSendResult } from '@/lib/active-agent-note-send-result'
import type { AgentMessageTarget } from '@/lib/agent-session/messaging/agent-message-target'
import { sendMessageToAgent } from '@/lib/agent-session/messaging/agent-message-send'
import type { ActiveAgentNotesSendResult } from '@/lib/agent-session/messaging/terminal/active-agent-note-send-result'
import { activateStructuredAgentSessionTab } from '@/lib/agent-session/structured-agent-session-tab-activation'
import { activateTabAndFocusPane } from '@/lib/workspace/tabs/activate-tab-and-focus-pane'
import { activateTerminalTabOnOwner } from '@/lib/workspace/tabs/terminal-tab-owner-activation'
@@ -3,7 +3,7 @@ import { describe, expect, it } from 'vitest'
import { Terminal } from '@xterm/headless'
import { SerializeAddon } from '@xterm/addon-serialize'
import { readClaudeSessionOptionsFromTerminalScreen } from './claude-terminal-session-options'
import { buildBoundedSessionTranscript } from '@/lib/agent-session-fork-context'
import { buildBoundedSessionTranscript } from '@/lib/agent-session/context/agent-session-fork-context'
const CLAUDE_FRAME = [
'╭─ Claude Code ───╮',
@@ -3,10 +3,13 @@ import {
agentChildRowContextForParent,
type AgentChildRowContext
} from '../../../../../../shared/agent-status/presentation/agent-child-row-model'
import { AGENT_STATUS_STALE_AFTER_MS } from '../../../../../../shared/agent-status/contracts/agent-status-freshness'
import {
AGENT_STATUS_STALE_AFTER_MS,
isAgentStatusFresh
} from '../../../../../../shared/agent-status/contracts/agent-status-freshness'
import type { AgentStatusEntry } from '../../../../../../shared/agent-status/contracts/agent-status-types'
import { useNow } from '@/hooks/use-now'
import { isExplicitAgentStatusFresh } from '@/lib/pane-agent-evidence'
import { useAppStore } from '@/store'
/** The verdict a session's status row gives its children, exactly as the sidebar derives it. */
@@ -16,7 +19,7 @@ export function structuredSessionChildRowContext(
): AgentChildRowContext {
return agentChildRowContextForParent(
parent,
isExplicitAgentStatusFresh(parent, now, AGENT_STATUS_STALE_AFTER_MS)
isAgentStatusFresh(parent, now, AGENT_STATUS_STALE_AFTER_MS)
)
}
@@ -18,7 +18,7 @@ import { AgentSessionContinuationDialog } from '@/components/agent-session-conti
import {
buildAgentSessionContinuationPrompt,
type AgentSessionContinuationRequest
} from '@/lib/agent-session-continuation'
} from '@/lib/agent-session/context/agent-session-continuation'
import { ClaudeSwitcherMenu } from '@/components/status-bar/ClaudeSwitcherMenu'
import { ProviderAccountChatButton } from '@/components/status-bar/ProviderAccountChatButton'
import { isTuiAgent } from '../../../../../shared/agent-launch/catalog/tui-agent-config'
@@ -1,5 +1,6 @@
import { Check } from 'lucide-react'
import { AgentIcon, type AgentCatalogEntry } from '@/lib/agent-catalog'
import type { AgentCatalogEntry } from '@/lib/agent-catalog/agent-catalog'
import { AgentIcon } from '@/components/agent/icons/AgentIcon'
import { cn } from '@/lib/utils'
export function AgentSectionHeader({
@@ -1,7 +1,7 @@
import { useState } from 'react'
import { ExternalLink } from 'lucide-react'
import { Trans } from 'react-i18next'
import { getAgentCatalog, type AgentCatalogEntry } from '@/lib/agent-catalog'
import { getAgentCatalog, type AgentCatalogEntry } from '@/lib/agent-catalog/agent-catalog'
import { Button } from '@/components/ui/button'
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible'
import type { TuiAgent } from '../../../../shared/agent-launch/catalog/tui-agent'
@@ -1,5 +1,6 @@
import { MessagesSquare, SquareTerminal } from 'lucide-react'
import { AgentIcon, getAgentLabel } from '@/lib/agent-catalog'
import { getAgentLabel } from '@/lib/agent-catalog/agent-catalog'
import { AgentIcon } from '@/components/agent/icons/AgentIcon'
import { useTranslate } from '@/i18n/use-translate'
// Shell text, not prose: what a terminal shows when the agent's CLI starts.
@@ -2,7 +2,7 @@ import { useId, useState } from 'react'
import { Button } from '@/components/ui/button'
import { Switch } from '@/components/ui/switch'
import { useTranslate } from '@/i18n/use-translate'
import { getAgentLabel } from '@/lib/agent-catalog'
import { getAgentLabel } from '@/lib/agent-catalog/agent-catalog'
import { useAppStore } from '@/store'
import {
applyAgentPermissionOverrides,
@@ -1,5 +1,5 @@
import { useAppStore } from '@/store'
import { resolveDefaultAgentForWorktree } from '@/lib/agent-tab-shortcuts'
import { resolveDefaultAgentForWorktree } from '@/lib/agent-session/launch/shortcuts/agent-tab-shortcuts'
import { agentTabLaunchStore } from '@/lib/agent-session/launch/new-tab/launch-agent-execution-context'
import type { TuiAgent } from '../../../../shared/agent-launch/catalog/tui-agent'
import type { ExecutionHostId } from '../../../../shared/execution-host'
@@ -3,7 +3,7 @@ import type {
ComputerUsePermissionSetupResult,
ComputerUsePermissionStatusResult
} from '../../../../shared/computer-use-permissions-types'
import { ORCHESTRATION_SKILL_NAME } from '@/lib/agent-feature-skill-names'
import { ORCHESTRATION_SKILL_NAME } from '@/lib/skills/installation/agent-feature-skill-names'
import { BROWSER_USE_ENABLED_STORAGE_KEY } from '@/lib/browser/browser-use-setup-state'
import { ORCHESTRATION_ENABLED_STORAGE_KEY } from '@/lib/orchestration-setup-state'
import {
@@ -7,7 +7,7 @@ import {
ORCA_LINEAR_SKILL_NAME,
ORCA_CLI_SKILL_NAME,
ORCHESTRATION_SKILL_NAME
} from '@/lib/agent-feature-skill-names'
} from '@/lib/skills/installation/agent-feature-skill-names'
import { BROWSER_USE_ENABLED_STORAGE_KEY } from '@/lib/browser/browser-use-setup-state'
import { e2eConfig } from '@/lib/e2e-config'
import {
@@ -3,7 +3,10 @@ import { LOCAL_EXECUTION_HOST_ID } from '../../../../shared/execution-host'
import type { GlobalSettings } from '../../../../shared/global-settings-types'
import type { TuiAgent } from '../../../../shared/agent-launch/catalog/tui-agent'
import { nativeChatPreferenceFor } from '../../../../shared/structured-native-chat-launch-route'
import { chatProviderAgents, useHostStructuredAgentsVersion } from '@/lib/chat-provider-agents'
import {
chatProviderAgents,
useHostStructuredAgentsVersion
} from '@/runtime/native-chat/agent-catalogs/chat-provider-agents'
import { recomputeOn } from '@/lib/recompute-on'
import type { ProspectiveWorkspace } from '@/lib/agent-session/launch/routing/agent-launch-route-input'
import { readChatProgram, resolveChatProgramContext } from '@/lib/host-chat-program'
@@ -54,7 +54,9 @@ vi.mock('@/components/agent-tab-launch-context', () => ({
captureAgentTabLaunchContext: () => ({ groupId: 'group', focusIntent })
}))
vi.mock('@/lib/telemetry', () => ({ track }))
vi.mock('@/lib/agent-detection-target-inventory', () => ({ loadDetectedAgentsForWorktree: detect }))
vi.mock('@/lib/agent-session/launch/inventory/agent-detection-target-inventory', () => ({
loadDetectedAgentsForWorktree: detect
}))
vi.mock('@/lib/host-chat-program-acquisition', () => ({
acquireAgentLaunchChoices: acquireChoices
}))
@@ -1,6 +1,6 @@
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { toast } from 'sonner'
import { getAgentCatalog } from '@/lib/agent-catalog'
import { getAgentCatalog } from '@/lib/agent-catalog/agent-catalog'
import { useAppStore } from '@/store'
import { selectOnboardingWorkspaceId } from './onboarding-workspace-selection'
import { applyDocumentTheme } from '@/lib/document-theme'
@@ -1,10 +1,10 @@
import { useMemo } from 'react'
import StatusIndicator from '@/components/sidebar/workspace-card/surface/StatusIndicator'
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
import { AgentTypeIcon } from '@/lib/agent-type-icon'
import { AgentTypeIcon } from '@/components/agent/icons/agent-type-icon'
import { cn } from '@/lib/utils'
import { getAgentLabel } from '@/lib/agent-catalog'
import { mapAgentStatusStateToVisualStatus } from '@/lib/agent-status'
import { getAgentLabel } from '@/lib/agent-catalog/agent-catalog'
import { mapAgentStatusStateToVisualStatus } from '@/lib/agent-status/aggregation/worktree-agent-status'
import { getWorktreeStatusLabel, type WorktreeStatus } from '@/lib/worktree-status'
import {
useAgentMessageSenderViews,
@@ -4,7 +4,7 @@ import { usePetUrl } from './usePetUrl'
import type { DetectedSpriteCacheEntry } from './pet-blob-cache'
import type { CustomPet } from '../../../../shared/pet-types'
import { useAppStore } from '../../store'
import { getAgentStatusEpochNow } from '@/lib/agent-status-epoch-clock'
import { getAgentStatusEpochNow } from '@/lib/agent-status/evidence/agent-status-epoch-clock'
import { AGENT_STATUS_STALE_AFTER_MS } from '../../../../shared/agent-status/contracts/agent-status-freshness'
import {
selectPetAnimationName,
@@ -1,5 +1,5 @@
import type { AgentStatusEntry } from '../../../../shared/agent-status/contracts/agent-status-types'
import { isExplicitAgentStatusFresh } from '@/lib/pane-agent-evidence'
import { isAgentStatusFresh } from '../../../../shared/agent-status/contracts/agent-status-freshness'
export type PetAnimationName =
| 'idle'
@@ -46,7 +46,7 @@ function agentStateAnimation(
let hasDone = false
for (const entry of entries) {
if (!isExplicitAgentStatusFresh(entry, now, staleAfterMs)) {
if (!isAgentStatusFresh(entry, now, staleAfterMs)) {
continue
}
if (entry.state === 'blocked' || entry.state === 'waiting') {
@@ -1,4 +1,7 @@
import { agentLaunchRecoveryMessage, notifyAgentLaunchFailure } from '@/lib/agent-launch-failure'
import {
agentLaunchRecoveryMessage,
notifyAgentLaunchFailure
} from '@/lib/agent-session/launch/failure/agent-launch-failure'
import type { DirectWorkItemLaunchResult } from '@/lib/workspace/creation/work-item/direct-work-item-setup'
import { toast } from 'sonner'
import { useAppStore } from '@/store'
@@ -21,7 +21,7 @@ import {
DropdownMenuTrigger
} from '@/components/ui/dropdown-menu'
import { ToggleGroup, ToggleGroupItem } from '@/components/ui/toggle-group'
import { AgentIcon } from '@/lib/agent-catalog'
import { AgentIcon } from '@/components/agent/icons/AgentIcon'
import { cn } from '@/lib/utils'
import {
AI_VAULT_AGENTS,
@@ -6,7 +6,7 @@ import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/component
import { useNow } from '@/hooks/use-now'
import { getIntlLocale, translate } from '@/i18n/i18n'
import { useIntlLocale, useTranslate, type Translate } from '@/i18n/use-translate'
import { AgentIcon } from '@/lib/agent-catalog'
import { AgentIcon } from '@/components/agent/icons/AgentIcon'
import { cn } from '@/lib/utils'
import type {
AiVaultScanAgentProgress,
@@ -1,4 +1,4 @@
import { agentRowDisplayDotState } from '@/lib/agent-row-dot-state'
import { agentRowDisplayDotState } from '@/lib/agent-status/presentation/agent-row-dot-state'
import type { AgentDotState } from '@/components/AgentStateDot'
import type { AiVaultSession } from '../../../../../../shared/ai-vault/contracts/ai-vault-types'
import {
@@ -1,4 +1,4 @@
import { agentRowDisplayDotState } from '@/lib/agent-row-dot-state'
import { agentRowDisplayDotState } from '@/lib/agent-status/presentation/agent-row-dot-state'
import type { AppState } from '@/store/types'
import { resolveRuntimePaneTitleLeafId } from '../../../../../../shared/runtime-pane-title-leaf-id'
import type { AgentDotState } from '@/components/AgentStateDot'
@@ -1,4 +1,4 @@
import type { AgentSessionContinuationRequest } from '@/lib/agent-session-continuation'
import type { AgentSessionContinuationRequest } from '@/lib/agent-session/context/agent-session-continuation'
import type { AiVaultSession } from '../../../../../../shared/ai-vault/contracts/ai-vault-types'
export function canContinueAiVaultSessionInNewSession(

Some files were not shown because too many files have changed in this diff Show More