Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.
TypeScript adeagent-ideai-agentsautomationbotclaude-codecodexghosttygrok-bothermes-agentmobile-appmuseopenclawopencodeorchestrationpiruntimeterminalworktreesyc-backed
import { describe, expect, it } from 'vitest'
import { LOCAL_EXECUTION_HOST_ID, type ExecutionHostId } from '../execution-host'
import type { WorkspaceSessionState } from '../workspace-session-state-types'
import { loadWorkspaceLayout } from './workspace-layout-load'
import { saveWorkspaceLayout } from './workspace-layout-save'
import { editorFileKey } from './workspace-layout-editor-tab-file'
import {
localDesktopSession,
WORKSPACE_LAYOUT_PROFILES
} from './workspace-layout-profile.test-fixture'
import { leaf } from './workspace-layout-session.test-fixture'
/** What reaches disk: the profile documents are JSON, so an undefined field is a missing one. */
const onDisk = (session: WorkspaceSessionState): unknown => JSON.parse(JSON.stringify(session))
function mintLeafIds(): () => string {
let next = 0
return () => `00000000-0000-4000-8000-${String(++next).padStart(12, '0')}`
}
function mintIds(): () => string {
let next = 0
return () => `minted-${++next}`
}
function roundTrip(hostId: ExecutionHostId, session: WorkspaceSessionState) {
const loaded = loadWorkspaceLayout(hostId, session, {
mintId: mintIds(),
mintLeafId: mintLeafIds()
})
return { loaded, saved: saveWorkspaceLayout(loaded) }
}
const PROFILES = WORKSPACE_LAYOUT_PROFILES.map(
(profile) => [profile.name, profile.hostId, profile.build] as const
)
describe('workspace layout Loader and Serializer', () => {
it.each(PROFILES)(
'%s: save(load(stored)) writes exactly what was stored',
(_name, hostId, build) => {
const stored = build()
const before = structuredClone(stored)
const { loaded, saved } = roundTrip(hostId, stored)
expect(loaded.changes).toEqual([])
expect(onDisk(saved)).toEqual(onDisk(stored))
// The Loader never edits the Store's object.
expect(stored).toEqual(before)
}
)
it('keeps one record per tab and per-view state out of the model', () => {
const { loaded } = roundTrip(LOCAL_EXECUTION_HOST_ID, localDesktopSession())
const layoutJson = JSON.stringify(loaded.layout)
for (const perView of [
'activeTabId',
'recentTabIds',
'activeLeafId',
'expandedLeafId',
'lastFocusedAt',
'dirtyDraftContent',
'sortOrder'
]) {
expect(layoutJson).not.toContain(`"${perView}"`)
}
const workspace = loaded.layout.workspaces['repo-1::/Users/dev/orca']!
expect(workspace.tabs.map((tab) => [tab.id, tab.kind])).toEqual([
['tab-shell', 'terminal'],
['tab-agent', 'terminal'],
['editor:src/app.ts', 'editor'],
['browser-1', 'browser'],
['agent-session-1', 'agent-session'],
['tab-unbound', 'terminal']
])
// Pane records use the terminal entity ID term-agent rather than tab-agent; in-memory data is keyed by leaf.
expect(workspace.leaves?.[leaf(3)]).toMatchObject({
incarnationId: 'inc-3',
// The fixture's record is a quit capture: a running agent's resume record, not a sleep.
resume: { agent: 'claude' }
})
expect(workspace.groups.map((group) => group.tabOrder)).toEqual([
['tab-shell', 'tab-agent', 'editor:src/app.ts'],
['browser-1', 'agent-session-1', 'tab-unbound']
])
expect(loaded.desktopView.groups['repo-1::/Users/dev/orca']!['group-a']).toEqual({
activeTabId: 'tab-agent',
recentTabIds: ['tab-shell', 'tab-agent']
})
// Keyed as editorFileKey keys it: a layout-owner build keys by owned file id.
expect(loaded.desktopView.editorDrafts['repo-1::/Users/dev/orca']).toEqual({
[editorFileKey({ filePath: '/Users/dev/orca/src/app.ts' })]: {
dirtyDraftContent: 'export {}\n',
lastKnownDiskSignature: 'sig-1'
}
})
})
})