Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,24 @@ afterEach(() => {
runtimeMock.runtimes = undefined;
});

const ALL_AVAILABLE: AgentRuntimes = {
'claude-code': { status: 'available', source: 'detected' },
codex: { status: 'available', source: 'detected' },
opencode: { status: 'available', source: 'detected' },
pi: { status: 'available', source: 'managed' },
'grok-build': { status: 'available', source: 'detected' },
};

describe('useAgentStartCatalogs', () => {
it('pauses only the Pi catalog while runtime availability is loading', () => {
it('pauses every catalog while runtime availability is loading', () => {
renderHook(() => useAgentStartCatalogs('/repo/app'));

expect(tayoriMock.params).toEqual([null, null, null, null, null]);
});

it('requests every catalog once the runtimes are available', () => {
runtimeMock.runtimes = ALL_AVAILABLE;

renderHook(() => useAgentStartCatalogs('/repo/app'));

// The cwd is what lets an adapter resolve the tier a session would really start under —
Expand All @@ -33,26 +49,23 @@ describe('useAgentStartCatalogs', () => {
{ agentKind: 'claude-code', cwd: '/repo/app' },
{ agentKind: 'codex', cwd: '/repo/app' },
{ agentKind: 'opencode', cwd: '/repo/app' },
null,
{ agentKind: 'pi', cwd: '/repo/app' },
{ agentKind: 'grok-build', cwd: '/repo/app' },
]);
});

it('keeps the Pi catalog paused while its managed runtime is missing', () => {
runtimeMock.runtimes = { pi: { status: 'missing' } };

renderHook(() => useAgentStartCatalogs('/repo/app'));

expect(tayoriMock.params[3]).toBeNull();
});

it('requests the Pi catalog once its runtime is available', () => {
runtimeMock.runtimes = { pi: { status: 'available', source: 'managed' } };
it('skips a missing runtime but keeps out-of-range and unevaluated kinds', () => {
// The dev mock host's onboarding fixture: one kind per runtime state.
runtimeMock.runtimes = {
'claude-code': { status: 'missing' },
codex: { status: 'out-of-range', source: 'detected', version: '0.99.0' },
pi: { status: 'available', source: 'builtin' },
};

renderHook(() => useAgentStartCatalogs('/repo/app'));

expect(tayoriMock.params).toEqual([
{ agentKind: 'claude-code', cwd: '/repo/app' },
null,
{ agentKind: 'codex', cwd: '/repo/app' },
{ agentKind: 'opencode', cwd: '/repo/app' },
{ agentKind: 'pi', cwd: '/repo/app' },
Expand All @@ -61,7 +74,7 @@ describe('useAgentStartCatalogs', () => {
});

it('follows a workspace switch rather than capturing the first cwd', () => {
runtimeMock.runtimes = { pi: { status: 'available', source: 'managed' } };
runtimeMock.runtimes = ALL_AVAILABLE;
const { rerender } = renderHook(({ cwd }: { cwd: string }) => useAgentStartCatalogs(cwd), {
initialProps: { cwd: '/repo/app' },
});
Expand Down
20 changes: 11 additions & 9 deletions packages/client/workbench/src/surface/use-agent-catalogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@ const SCOPED = { keepPreviousData: false } as const;

export function useAgentStartCatalogs(cwd?: string): Partial<Record<AgentKind, AgentStartCatalog>> {
const { data: runtimes } = useAgentRuntimes();
const claude = useData(getAgentCatalog, { agentKind: 'claude-code', cwd }, SCOPED);
const codex = useData(getAgentCatalog, { agentKind: 'codex', cwd }, SCOPED);
const opencode = useData(getAgentCatalog, { agentKind: 'opencode', cwd }, SCOPED);
const pi = useData(
getAgentCatalog,
runtimes?.pi?.status === 'available' ? { agentKind: 'pi', cwd } : null,
SCOPED,
);
const grok = useData(getAgentCatalog, { agentKind: 'grok-build', cwd }, SCOPED);
// A runtime the host cannot spawn has no catalog to serve — the adapter throws and SWR retries
// the failure indefinitely — so a `missing` kind is not requested (the harness picker already
// badges it "Not installed"). Loading pauses every request; a kind the host never evaluated is
// absent from the snapshot and stays fail-open, like `deriveAgentRuntimeCues`.
Comment thread
lucas77778 marked this conversation as resolved.
const request = (agentKind: AgentKind) =>
runtimes !== undefined && runtimes[agentKind]?.status !== 'missing' ? { agentKind, cwd } : null;
const claude = useData(getAgentCatalog, request('claude-code'), SCOPED);
const codex = useData(getAgentCatalog, request('codex'), SCOPED);
const opencode = useData(getAgentCatalog, request('opencode'), SCOPED);
const pi = useData(getAgentCatalog, request('pi'), SCOPED);
const grok = useData(getAgentCatalog, request('grok-build'), SCOPED);
return {
...(claude.data && { 'claude-code': claude.data }),
...(codex.data && { codex: codex.data }),
Expand Down
Loading