refactor: route Best fit proposals to personas only
The executor router could propose Claude Code, Codex or Hermes and dispatch the task as a Waggle Room run through POST /api/tools/run, which is gone with the collaboration runtime. Confirming such a proposal could only fail. - ExecutorRegistry offers the five v1 personas; it no longer detects external tools. - Route proposals dispatch persona chat turns only. The memory brief and its egress disclosure existed only for external executors, so executor-brief.ts, the egress fields and removeFrameIds go too. - RouteProposalCard drops the memory disclosure, "Run without memory" and the link to an external run in the Room.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import {
|
||||
Route, Loader2, CheckCircle2, XCircle, X, ChevronDown, ShieldAlert, ExternalLink,
|
||||
Route, Loader2, CheckCircle2, XCircle,
|
||||
} from 'lucide-react';
|
||||
import { adapter } from '@/lib/adapter';
|
||||
import type {
|
||||
@@ -38,8 +38,6 @@ function revalidationReason(err: unknown): string | null {
|
||||
*/
|
||||
export default function RouteProposalCard({ proposal, onDispatched, onRePropose }: RouteProposalCardProps) {
|
||||
const [phase, setPhase] = useState<Phase>('proposed');
|
||||
const [egressOpen, setEgressOpen] = useState(false);
|
||||
const [removedFrameIds, setRemovedFrameIds] = useState<string[]>([]);
|
||||
const [executorId, setExecutorId] = useState<string>(proposal.selected?.id ?? '');
|
||||
const [dispatchResult, setDispatchResult] = useState<RouteProposalConfirmResponse | null>(null);
|
||||
const [errorReason, setErrorReason] = useState<string | null>(null);
|
||||
@@ -48,32 +46,16 @@ export default function RouteProposalCard({ proposal, onDispatched, onRePropose
|
||||
// inherit the previous card's phase or stale executor selection.
|
||||
useEffect(() => {
|
||||
setPhase('proposed');
|
||||
setEgressOpen(false);
|
||||
setRemovedFrameIds([]);
|
||||
setExecutorId(proposal.selected?.id ?? '');
|
||||
setDispatchResult(null);
|
||||
setErrorReason(null);
|
||||
}, [proposal.routeDecisionId, proposal.selected?.id]);
|
||||
|
||||
const blocked = proposal.egress === null && proposal.briefBlocked === true;
|
||||
const egressItems = proposal.egress?.items ?? [];
|
||||
const remainingItems = egressItems.filter(i => !removedFrameIds.includes(i.frameId));
|
||||
|
||||
const removeFrame = (frameId: string) => {
|
||||
setRemovedFrameIds(prev => (prev.includes(frameId) ? prev : [...prev, frameId]));
|
||||
};
|
||||
|
||||
const removeAllFrames = () => {
|
||||
setRemovedFrameIds(egressItems.map(i => i.frameId));
|
||||
};
|
||||
|
||||
const confirm = async (opts?: { withoutMemory?: boolean }) => {
|
||||
const confirm = async () => {
|
||||
setPhase('dispatching');
|
||||
setErrorReason(null);
|
||||
const removeIds = opts?.withoutMemory ? egressItems.map(i => i.frameId) : removedFrameIds;
|
||||
const body: RouteProposalConfirmBody = {
|
||||
...(executorId && executorId !== proposal.selected?.id ? { executorId } : {}),
|
||||
...(removeIds.length > 0 ? { removeFrameIds: removeIds } : {}),
|
||||
};
|
||||
try {
|
||||
const result = await adapter.routeProposals.confirm(proposal.routeDecisionId, body);
|
||||
@@ -134,73 +116,8 @@ export default function RouteProposalCard({ proposal, onDispatched, onRePropose
|
||||
</p>
|
||||
)}
|
||||
|
||||
{/* Blocked brief — B1 injection gate: run-without-memory only */}
|
||||
{blocked && phase !== 'dispatched' && (
|
||||
<div
|
||||
className="flex items-start gap-1.5 mt-2 text-[11px] text-amber-400"
|
||||
data-testid="route-proposal-blocked"
|
||||
>
|
||||
<ShieldAlert className="w-3.5 h-3.5 shrink-0 mt-px" />
|
||||
<span>
|
||||
Memory context was blocked by the safety scan
|
||||
{proposal.briefBlockedReason ? ` (${proposal.briefBlockedReason})` : ''}. This task can
|
||||
only run without memory.
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Egress disclosure — only when a brief accompanies the dispatch */}
|
||||
{!blocked && proposal.egress && phase !== 'dispatched' && (
|
||||
<div className="mt-2" data-testid="route-proposal-egress">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setEgressOpen(o => !o)}
|
||||
aria-expanded={egressOpen}
|
||||
data-testid="route-proposal-egress-toggle"
|
||||
className="flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground transition-colors"
|
||||
>
|
||||
<ChevronDown className={`w-3 h-3 transition-transform ${egressOpen ? 'rotate-180' : ''}`} />
|
||||
Will send {remainingItems.length} workspace {remainingItems.length === 1 ? 'memory' : 'memories'} to{' '}
|
||||
<span className="text-foreground">{proposal.egress.destination}</span>
|
||||
</button>
|
||||
{egressOpen && (
|
||||
<ul className="mt-1.5 space-y-1">
|
||||
{remainingItems.map(item => (
|
||||
<li
|
||||
key={item.frameId}
|
||||
data-testid="route-proposal-egress-item"
|
||||
className="flex items-start gap-1.5 rounded-lg bg-[var(--surface-2)] px-2 py-1 text-[11px]"
|
||||
>
|
||||
<span className="text-muted-foreground shrink-0">{item.date} · {item.source}</span>
|
||||
<span className="text-foreground truncate flex-1">{item.preview}</span>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => removeFrame(item.frameId)}
|
||||
aria-label={`Remove memory ${item.frameId}`}
|
||||
data-testid={`route-proposal-remove-${item.frameId}`}
|
||||
className="shrink-0 text-muted-foreground/60 hover:text-destructive transition-colors"
|
||||
>
|
||||
<X className="w-3 h-3" />
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
{remainingItems.length > 0 && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={removeAllFrames}
|
||||
data-testid="route-proposal-run-without-memory"
|
||||
className="mt-1 text-[11px] text-muted-foreground underline underline-offset-2 hover:text-foreground transition-colors"
|
||||
>
|
||||
Run without memory
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Alternatives override — rejected greyed with reason tooltip */}
|
||||
{!blocked && phase === 'proposed' && proposal.selected
|
||||
{phase === 'proposed' && proposal.selected
|
||||
&& (proposal.alternatives.length > 0 || proposal.rejected.length > 0) && (
|
||||
<div className="mt-2">
|
||||
<label htmlFor={`route-executor-${proposal.routeDecisionId}`} className="sr-only">
|
||||
@@ -237,27 +154,15 @@ export default function RouteProposalCard({ proposal, onDispatched, onRePropose
|
||||
<div className="flex items-center gap-2 mt-2.5">
|
||||
{phase === 'proposed' && (
|
||||
<>
|
||||
{blocked ? (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => void confirm({ withoutMemory: true })}
|
||||
disabled={!proposal.selected}
|
||||
data-testid="route-proposal-run-without-memory"
|
||||
className="flex items-center gap-1.5 px-2.5 py-1 text-xs rounded-lg bg-primary text-primary-foreground hover:bg-primary/80 font-display transition-colors disabled:opacity-50"
|
||||
>
|
||||
Run without memory
|
||||
</button>
|
||||
) : (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => void confirm()}
|
||||
disabled={!proposal.selected}
|
||||
data-testid="route-proposal-confirm"
|
||||
className="flex items-center gap-1.5 px-2.5 py-1 text-xs rounded-lg bg-primary text-primary-foreground hover:bg-primary/80 font-display transition-colors disabled:opacity-50"
|
||||
>
|
||||
Confirm
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => void confirm()}
|
||||
disabled={!proposal.selected}
|
||||
data-testid="route-proposal-confirm"
|
||||
className="flex items-center gap-1.5 px-2.5 py-1 text-xs rounded-lg bg-primary text-primary-foreground hover:bg-primary/80 font-display transition-colors disabled:opacity-50"
|
||||
>
|
||||
Confirm
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => void cancel()}
|
||||
@@ -276,18 +181,7 @@ export default function RouteProposalCard({ proposal, onDispatched, onRePropose
|
||||
{phase === 'dispatched' && dispatchResult && (
|
||||
<span className="flex items-center gap-1.5 text-xs text-emerald-400 font-display" data-testid="route-proposal-dispatched">
|
||||
<CheckCircle2 className="w-3.5 h-3.5" />
|
||||
{dispatchResult.mode === 'external' && dispatchResult.roomId ? (
|
||||
<a
|
||||
href={`/room?room=${encodeURIComponent(dispatchResult.roomId)}${dispatchResult.runId ? `&run=${encodeURIComponent(dispatchResult.runId)}` : ''}`}
|
||||
data-testid="route-proposal-run-link"
|
||||
className="inline-flex items-center gap-1 underline underline-offset-2 hover:text-emerald-300 transition-colors"
|
||||
>
|
||||
Dispatched. View the run
|
||||
<ExternalLink className="w-3 h-3" />
|
||||
</a>
|
||||
) : (
|
||||
<span>{dispatchResult.resultText ? 'Completed in this chat' : 'Running in this chat'}</span>
|
||||
)}
|
||||
<span>{dispatchResult.resultText ? 'Completed in this chat' : 'Running in this chat'}</span>
|
||||
</span>
|
||||
)}
|
||||
{phase === 'dispatched' && dispatchResult?.resultText && (
|
||||
|
||||
@@ -6,22 +6,6 @@
|
||||
* shapes, never against an ad-hoc parse.
|
||||
*/
|
||||
|
||||
/** One workspace memory the brief would send out (propose → egress.items[]). */
|
||||
export interface RouteProposalEgressItem {
|
||||
frameId: string;
|
||||
date: string;
|
||||
source: string;
|
||||
/** First 120 chars of the frame content. */
|
||||
preview: string;
|
||||
}
|
||||
|
||||
/** Egress disclosure when a memory brief accompanies an external dispatch. */
|
||||
export interface RouteProposalEgress {
|
||||
destination: string;
|
||||
items: RouteProposalEgressItem[];
|
||||
briefChars: number;
|
||||
}
|
||||
|
||||
export interface RouteProposalSelected {
|
||||
id: string;
|
||||
displayName: string;
|
||||
@@ -60,23 +44,15 @@ export interface RouteProposalPayload {
|
||||
alternatives: RouteProposalAlternative[];
|
||||
rejected: RouteProposalRejection[];
|
||||
scores: RouteProposalScore[];
|
||||
/** null when no memory brief accompanies the dispatch (persona run, or brief blocked). */
|
||||
egress: RouteProposalEgress | null;
|
||||
/** Verbatim from the API — render as-is, never reworded. No dollar figures. */
|
||||
/** Null when no eligible executor was selected. */
|
||||
costLine: string | null;
|
||||
/** B1 injection gate tripped: egress is null and only "Run without memory" is offered. */
|
||||
briefBlocked?: boolean;
|
||||
briefBlockedReason?: string;
|
||||
}
|
||||
|
||||
/** POST /api/route-proposals/:id/confirm success response (SPEC A4 step 5). */
|
||||
export interface RouteProposalConfirmResponse {
|
||||
status: 'dispatched';
|
||||
mode: 'external' | 'internal';
|
||||
roomId?: string;
|
||||
runId?: string;
|
||||
/** Internal (persona) dispatch: the completed turn's answer text. */
|
||||
/** The completed persona turn's answer text. */
|
||||
resultText?: string;
|
||||
}
|
||||
|
||||
@@ -90,8 +66,7 @@ export interface RouteProposalProposeBody {
|
||||
preferredExecutorId?: string;
|
||||
}
|
||||
|
||||
/** Confirm request body (SPEC A4): override + per-frame egress removals. */
|
||||
/** Confirm request body (SPEC A4): an optional executor override. */
|
||||
export interface RouteProposalConfirmBody {
|
||||
executorId?: string;
|
||||
removeFrameIds?: string[];
|
||||
}
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
/**
|
||||
* Router arc P1-B (B2) — RouteProposalCard + BlockRenderer route_proposal branch.
|
||||
* - renders the propose payload (header, selected executor, reason, verbatim
|
||||
* cost line, egress summary)
|
||||
* - per-frame remove (×) and "Run without memory" shape the confirm body
|
||||
* - renders the propose payload (header, selected persona, reason, verbatim
|
||||
* cost line)
|
||||
* - alternatives select overrides the executor; rejected options are greyed
|
||||
* with a reason tooltip
|
||||
* - dispatched state links the external run / says "running in this chat"
|
||||
* - blocked brief (egress null + briefBlocked) renders run-without-memory only
|
||||
* - dispatched state says "running in this chat"
|
||||
* - cancel rejects and collapses; revalidation_failed shows reason + re-propose
|
||||
*/
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
||||
@@ -27,27 +25,18 @@ import { BlockRenderer } from '@/components/os/apps/chat-blocks';
|
||||
|
||||
const basePayload: RouteProposalPayload = {
|
||||
routeDecisionId: 'rd-1',
|
||||
selected: { id: 'external:codex', displayName: 'Codex CLI', reason: 'best coding fit, available now' },
|
||||
selected: { id: 'persona:coder', displayName: 'Coder', reason: 'best coding fit, available now' },
|
||||
alternatives: [
|
||||
{ id: 'external:claude-code', displayName: 'Claude Code' },
|
||||
{ id: 'persona:coder', displayName: 'Coder' },
|
||||
{ id: 'persona:general-purpose', displayName: 'General Purpose' },
|
||||
{ id: 'persona:analyst', displayName: 'Analyst' },
|
||||
],
|
||||
rejected: [{ id: 'external:hermes', reason: 'not installed' }],
|
||||
rejected: [{ id: 'persona:researcher', reason: 'rate limit exhausted' }],
|
||||
scores: [],
|
||||
egress: {
|
||||
destination: 'OpenAI',
|
||||
items: [
|
||||
{ frameId: 'f1', date: '2026-07-01', source: 'user_stated', preview: 'Prefers pnpm over npm' },
|
||||
{ frameId: 'f2', date: '2026-07-02', source: 'tool_verified', preview: 'CI runs on node 20' },
|
||||
{ frameId: 'f3', date: '2026-07-03', source: 'agent_inferred', preview: 'Repo tests use vitest' },
|
||||
],
|
||||
briefChars: 4200,
|
||||
},
|
||||
costLine: 'uses your existing Codex allowance',
|
||||
costLine: 'runs on your configured API key',
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
mocks.routeProposals.confirm.mockResolvedValue({ status: 'dispatched', mode: 'internal' });
|
||||
mocks.routeProposals.confirm.mockResolvedValue({ status: 'dispatched' });
|
||||
mocks.routeProposals.reject.mockResolvedValue(undefined);
|
||||
});
|
||||
afterEach(() => {
|
||||
@@ -56,56 +45,25 @@ afterEach(() => {
|
||||
});
|
||||
|
||||
describe('RouteProposalCard (router arc B2)', () => {
|
||||
it('renders the proposal payload — header, executor, reason, verbatim cost line, egress summary', () => {
|
||||
it('renders the proposal payload — header, executor, reason, verbatim cost line', () => {
|
||||
render(<RouteProposalCard proposal={basePayload} />);
|
||||
expect(screen.getByText('Where should this run?')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('route-proposal-selected')).toHaveTextContent('Codex CLI');
|
||||
expect(screen.getByTestId('route-proposal-selected')).toHaveTextContent('Coder');
|
||||
expect(screen.getByTestId('route-proposal-reason')).toHaveTextContent('best coding fit, available now');
|
||||
expect(screen.getByTestId('route-proposal-cost-line')).toHaveTextContent('uses your existing Codex allowance');
|
||||
expect(screen.getByTestId('route-proposal-egress-toggle')).toHaveTextContent(
|
||||
'Will send 3 workspace memories to OpenAI',
|
||||
);
|
||||
});
|
||||
|
||||
it('per-item remove (×) drops the frame from the list and the confirm body', async () => {
|
||||
render(<RouteProposalCard proposal={basePayload} />);
|
||||
fireEvent.click(screen.getByTestId('route-proposal-egress-toggle'));
|
||||
expect(screen.getAllByTestId('route-proposal-egress-item')).toHaveLength(3);
|
||||
|
||||
fireEvent.click(screen.getByTestId('route-proposal-remove-f2'));
|
||||
expect(screen.getAllByTestId('route-proposal-egress-item')).toHaveLength(2);
|
||||
expect(screen.getByTestId('route-proposal-egress-toggle')).toHaveTextContent(
|
||||
'Will send 2 workspace memories to OpenAI',
|
||||
);
|
||||
|
||||
fireEvent.click(screen.getByTestId('route-proposal-confirm'));
|
||||
await waitFor(() =>
|
||||
expect(mocks.routeProposals.confirm).toHaveBeenCalledWith('rd-1', { removeFrameIds: ['f2'] }),
|
||||
);
|
||||
});
|
||||
|
||||
it('"Run without memory" removes every frame from the confirm body', async () => {
|
||||
render(<RouteProposalCard proposal={basePayload} />);
|
||||
fireEvent.click(screen.getByTestId('route-proposal-run-without-memory'));
|
||||
fireEvent.click(screen.getByTestId('route-proposal-confirm'));
|
||||
await waitFor(() =>
|
||||
expect(mocks.routeProposals.confirm).toHaveBeenCalledWith('rd-1', {
|
||||
removeFrameIds: ['f1', 'f2', 'f3'],
|
||||
}),
|
||||
);
|
||||
expect(screen.getByTestId('route-proposal-cost-line')).toHaveTextContent('runs on your configured API key');
|
||||
});
|
||||
|
||||
it('overriding via the alternatives select sends executorId; rejected options are greyed with a reason tooltip', async () => {
|
||||
render(<RouteProposalCard proposal={basePayload} />);
|
||||
const select = screen.getByTestId('route-proposal-executor-select');
|
||||
const rejectedOption = screen.getByRole('option', { name: /external:hermes \(unavailable\)/ }) as HTMLOptionElement;
|
||||
const rejectedOption = screen.getByRole('option', { name: /persona:researcher \(unavailable\)/ }) as HTMLOptionElement;
|
||||
expect(rejectedOption.disabled).toBe(true);
|
||||
expect(rejectedOption).toHaveAttribute('title', 'not installed');
|
||||
expect(rejectedOption).toHaveAttribute('title', 'rate limit exhausted');
|
||||
|
||||
fireEvent.change(select, { target: { value: 'persona:coder' } });
|
||||
fireEvent.change(select, { target: { value: 'persona:analyst' } });
|
||||
fireEvent.click(screen.getByTestId('route-proposal-confirm'));
|
||||
await waitFor(() =>
|
||||
expect(mocks.routeProposals.confirm).toHaveBeenCalledWith('rd-1', { executorId: 'persona:coder' }),
|
||||
expect(mocks.routeProposals.confirm).toHaveBeenCalledWith('rd-1', { executorId: 'persona:analyst' }),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -115,39 +73,12 @@ describe('RouteProposalCard (router arc B2)', () => {
|
||||
await waitFor(() => expect(mocks.routeProposals.confirm).toHaveBeenCalledWith('rd-1', {}));
|
||||
});
|
||||
|
||||
it('dispatched external run renders a /room link with room + run ids', async () => {
|
||||
mocks.routeProposals.confirm.mockResolvedValue({
|
||||
status: 'dispatched', mode: 'external', roomId: 'room-9', runId: 'run-3',
|
||||
});
|
||||
render(<RouteProposalCard proposal={basePayload} />);
|
||||
fireEvent.click(screen.getByTestId('route-proposal-confirm'));
|
||||
const link = await screen.findByTestId('route-proposal-run-link');
|
||||
expect(link).toHaveAttribute('href', '/room?room=room-9&run=run-3');
|
||||
});
|
||||
|
||||
it('dispatched internal run says "Running in this chat" and fires onDispatched', async () => {
|
||||
it('dispatched run says "Running in this chat" and fires onDispatched', async () => {
|
||||
const onDispatched = vi.fn();
|
||||
render(<RouteProposalCard proposal={basePayload} onDispatched={onDispatched} />);
|
||||
fireEvent.click(screen.getByTestId('route-proposal-confirm'));
|
||||
await screen.findByText('Running in this chat');
|
||||
expect(screen.queryByTestId('route-proposal-run-link')).not.toBeInTheDocument();
|
||||
expect(onDispatched).toHaveBeenCalledWith({ status: 'dispatched', mode: 'internal' });
|
||||
});
|
||||
|
||||
it('blocked brief (egress null + briefBlocked) renders run-without-memory only', async () => {
|
||||
const blocked: RouteProposalPayload = {
|
||||
...basePayload,
|
||||
egress: null,
|
||||
briefBlocked: true,
|
||||
briefBlockedReason: 'injection patterns detected',
|
||||
};
|
||||
render(<RouteProposalCard proposal={blocked} />);
|
||||
expect(screen.getByTestId('route-proposal-blocked')).toHaveTextContent('injection patterns detected');
|
||||
// No egress list, no per-item remove, no plain Confirm — only run-without-memory.
|
||||
expect(screen.queryByTestId('route-proposal-egress')).not.toBeInTheDocument();
|
||||
expect(screen.queryByTestId('route-proposal-confirm')).not.toBeInTheDocument();
|
||||
fireEvent.click(screen.getByTestId('route-proposal-run-without-memory'));
|
||||
await waitFor(() => expect(mocks.routeProposals.confirm).toHaveBeenCalledWith('rd-1', {}));
|
||||
expect(onDispatched).toHaveBeenCalledWith({ status: 'dispatched' });
|
||||
});
|
||||
|
||||
it('cancel POSTs reject and collapses the card', async () => {
|
||||
@@ -161,20 +92,20 @@ describe('RouteProposalCard (router arc B2)', () => {
|
||||
it('revalidation_failed confirm shows the reason and a re-propose button', async () => {
|
||||
const err = Object.assign(new Error('revalidation_failed'), {
|
||||
status: 409,
|
||||
body: { error: 'revalidation_failed', reason: 'Codex CLI was uninstalled' },
|
||||
body: { error: 'revalidation_failed', reason: 'Coder hit its rate limit' },
|
||||
});
|
||||
mocks.routeProposals.confirm.mockRejectedValue(err);
|
||||
const onRePropose = vi.fn();
|
||||
render(<RouteProposalCard proposal={basePayload} onRePropose={onRePropose} />);
|
||||
fireEvent.click(screen.getByTestId('route-proposal-confirm'));
|
||||
const error = await screen.findByTestId('route-proposal-error');
|
||||
expect(error).toHaveTextContent('Codex CLI was uninstalled');
|
||||
expect(error).toHaveTextContent('Coder hit its rate limit');
|
||||
fireEvent.click(screen.getByTestId('route-proposal-re-propose'));
|
||||
expect(onRePropose).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('no eligible executor (selected null) disables Confirm', () => {
|
||||
render(<RouteProposalCard proposal={{ ...basePayload, selected: null, egress: null }} />);
|
||||
render(<RouteProposalCard proposal={{ ...basePayload, selected: null }} />);
|
||||
expect(screen.getByText('No eligible executor is available right now.')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('route-proposal-confirm')).toBeDisabled();
|
||||
});
|
||||
@@ -201,7 +132,7 @@ describe('BlockRenderer route_proposal branch', () => {
|
||||
);
|
||||
fireEvent.click(screen.getByTestId('route-proposal-confirm'));
|
||||
await waitFor(() =>
|
||||
expect(onDispatched).toHaveBeenCalledWith('route-rd-1', { status: 'dispatched', mode: 'internal' }),
|
||||
expect(onDispatched).toHaveBeenCalledWith('route-rd-1', { status: 'dispatched' }),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -10,16 +10,11 @@ import type { RouteProposalPayload } from '@/lib/route-proposals';
|
||||
|
||||
const payload: RouteProposalPayload = {
|
||||
routeDecisionId: 'rd-42',
|
||||
selected: { id: 'external:claude-code', displayName: 'Claude Code', reason: 'best coding fit' },
|
||||
alternatives: [{ id: 'persona:coder', displayName: 'Coder' }],
|
||||
selected: { id: 'persona:coder', displayName: 'Coder', reason: 'best coding fit' },
|
||||
alternatives: [{ id: 'persona:general-purpose', displayName: 'General Purpose' }],
|
||||
rejected: [],
|
||||
scores: [],
|
||||
egress: {
|
||||
destination: 'Anthropic',
|
||||
items: [{ frameId: 'f1', date: '2026-07-10', source: 'user_stated', preview: 'p' }],
|
||||
briefChars: 1200,
|
||||
},
|
||||
costLine: 'uses your existing Claude Code allowance',
|
||||
costLine: 'runs on your configured API key',
|
||||
};
|
||||
|
||||
const jsonResponse = (body: unknown, status = 200) =>
|
||||
@@ -52,20 +47,19 @@ describe('adapter.routeProposals (router arc B2)', () => {
|
||||
expect(JSON.parse(String(init.body))).toEqual({ workspaceId: 'ws-1', prompt: 'fix the flaky test' });
|
||||
});
|
||||
|
||||
it('confirm POSTs executorId + removeFrameIds to /api/route-proposals/:id/confirm', async () => {
|
||||
it('confirm POSTs executorId to /api/route-proposals/:id/confirm', async () => {
|
||||
vi.mocked(global.fetch).mockResolvedValue(
|
||||
jsonResponse({ status: 'dispatched', mode: 'external', roomId: 'room-1', runId: 'run-1' }),
|
||||
jsonResponse({ status: 'dispatched', resultText: 'Done' }),
|
||||
);
|
||||
const result = await adapter.routeProposals.confirm('rd-42', {
|
||||
executorId: 'persona:coder',
|
||||
removeFrameIds: ['f1'],
|
||||
executorId: 'persona:general-purpose',
|
||||
});
|
||||
|
||||
expect(result).toEqual({ status: 'dispatched', mode: 'external', roomId: 'room-1', runId: 'run-1' });
|
||||
expect(result).toEqual({ status: 'dispatched', resultText: 'Done' });
|
||||
const { url, init } = routeCall();
|
||||
expect(url.endsWith('/api/route-proposals/rd-42/confirm')).toBe(true);
|
||||
expect(init.method).toBe('POST');
|
||||
expect(JSON.parse(String(init.body))).toEqual({ executorId: 'persona:coder', removeFrameIds: ['f1'] });
|
||||
expect(JSON.parse(String(init.body))).toEqual({ executorId: 'persona:general-purpose' });
|
||||
});
|
||||
|
||||
it('confirm surfaces the 409 revalidation_failed body on the thrown AdapterHttpError', async () => {
|
||||
|
||||
Reference in New Issue
Block a user