Skip to content

Claude Code. Any Model. The most powerful AI coding agent now speaks every language.

fix(tui): render the route probe from explainRoute

Jack Rudenkoe71aafb371cf
diff --git a/packages/cli/src/tui/App.tsx b/packages/cli/src/tui/App.tsx
index 19a71bf5..831ff927 100644
--- a/packages/cli/src/tui/App.tsx
+++ b/packages/cli/src/tui/App.tsx
@@ -549,10 +549,12 @@ export function App({ requestLogin }: AppProps = {}) {
});
}, []);
- // Route probe wizard — owns probeMode/probeModel/probeResults internally.
- // The keyboard handler delegates to verb methods (startInput, submit, etc.).
- const probe = useRouteProbe(config);
- const { probeMode, probeModel, probeResults } = probe;
+ // Route probe wizard — owns probeMode/probeModel/probeResults/probeSummary
+ // internally. The keyboard handler delegates to verb methods (startInput,
+ // submit, etc.). It reads the rules and the default provider through
+ // explainRoute, from disk, as a request would.
+ const probe = useRouteProbe();
+ const { probeMode, probeModel, probeResults, probeSummary } = probe;
// Profile editor wizard — owns editProfileName/Value, profileScope,
// suggestions/suggestionIndex, providerPickerIndex, and the
@@ -2757,6 +2759,7 @@ export function App({ requestLogin }: AppProps = {}) {
probeMode={probeMode}
probeModel={probeModel}
probeResults={probeResults}
+ probeSummary={probeSummary}
mode={mode}
routingPattern={routingPattern}
chainSelected={chainSelected}
diff --git a/packages/cli/src/tui/components/RoutingContent.tsx b/packages/cli/src/tui/components/RoutingContent.tsx
index 49fdac3f..6159f3de 100644
--- a/packages/cli/src/tui/components/RoutingContent.tsx
+++ b/packages/cli/src/tui/components/RoutingContent.tsx
@@ -7,7 +7,69 @@ import { DETAIL_H, getChainProviders } from "../constants.js";
import { deriveProbeOutcome } from "../probe-outcome.js";
import { providerIsReady } from "../providers.js";
import { A, C } from "../theme.js";
-import type { MergedRule, Mode, ProbeEntry, ProbeMode } from "../types.js";
+import type {
+ DroppedOutcome,
+ MergedRule,
+ Mode,
+ ProbeEntry,
+ ProbeMode,
+ ProbeSummary,
+} from "../types.js";
+
+/**
+ * What a dropped row says removed it. Total over the dropped outcomes, so a new
+ * outcome cannot render as nothing.
+ */
+const DROPPED_TEXT: Record<DroppedOutcome, string> = {
+ "no-credential": "no credential",
+ "credential-unreadable": "credential could not be read",
+ "not-served": "the account does not serve it",
+ "excluded-by-membership": "not in the plan's membership",
+};
+
+/**
+ * How a probe row's status reads: its glyph, its text, and its colour, read from
+ * `C` at render time (the palette changes when the theme is detected).
+ */
+function rowStatusView(entry: ProbeEntry): { icon: string; color: string; text: string } {
+ switch (entry.status) {
+ case "unverified":
+ return { icon: "◐", color: C.cyan, text: "native — not probed" };
+ case "success":
+ return {
+ icon: "●",
+ color: C.green,
+ text: entry.ms !== undefined ? `${entry.ms}ms` : "success",
+ };
+ case "failed":
+ return { icon: "✗", color: C.red, text: entry.error ?? "failed" };
+ case "testing":
+ return { icon: "◌", color: C.yellow, text: "testing..." };
+ case "dropped":
+ return {
+ icon: "○",
+ // A subscription the user holds whose key could not be read is a
+ // warning: the request lands on a different hop.
+ color: entry.outcome === "credential-unreadable" ? C.yellow : C.dim,
+ text: entry.outcome ? `dropped · ${DROPPED_TEXT[entry.outcome]}` : "dropped",
+ };
+ case "skipped":
+ return { icon: "·", color: C.dim, text: "not reached" };
+ case "no_key":
+ return { icon: "○", color: C.dim, text: "not configured, skipping" };
+ case "pending":
+ return { icon: "○", color: C.dim, text: "waiting" };
+ }
+}
+
+/** A no-route hint, one line per row; the hint is multi-line text. */
+function hintLines(hint: string | undefined): { id: string; text: string }[] {
+ if (!hint) return [];
+ return hint
+ .split("\n")
+ .filter((text) => text.trim().length > 0)
+ .map((text, n) => ({ id: `hint-${n}`, text }));
+}
// Format a chain as inline text: "kimi → openrouter"
function chainStr(chain: string[]): string {
@@ -52,6 +114,8 @@ interface RoutingContentProps {
probeMode: ProbeMode;
probeModel: string;
probeResults: ProbeEntry[];
+ /** The decision as a whole, from the same explainRoute call as the rows. */
+ probeSummary: ProbeSummary | null;
mode: Mode;
routingPattern: string;
chainSelected: Set<string>;
@@ -79,6 +143,7 @@ export function RoutingContent({
probeMode,
probeModel,
probeResults,
+ probeSummary,
mode,
routingPattern,
chainSelected,
@@ -168,11 +233,16 @@ export function RoutingContent({
<text> </text>
<text>
<span fg={C.fgMuted}>
- {"The probe resolves the fallback chain and tests each provider's"}
+ {"The probe shows the routing chain a request would use, then tests"}
+ </span>
+ </text>
+ <text>
+ <span fg={C.fgMuted}>
+ {"each kept hop in order, stopping at the first success. Dropped"}
</span>
</text>
<text>
- <span fg={C.fgMuted}>{"API key in order, stopping at the first success."}</span>
+ <span fg={C.fgMuted}>{"candidates are listed with the reason, never tested."}</span>
</text>
</box>
);
@@ -225,79 +295,44 @@ export function RoutingContent({
</text>
</box>
<text> </text>
- {/* Route source */}
+ {/* Where the chain came from: describeRouteExplanation, the line
+ --probe prints for the same decision. */}
<text>
- <span fg={C.fgMuted}>
- {probeResults[0]?.reason ?? `Chain (${probeResults.length} providers):`}
- </span>
+ <span fg={C.fgMuted}>{probeSummary?.line ?? ""}</span>
</text>
+ {probeSummary?.warnings.map((warning) => (
+ <text key={`warning:${warning}`}>
+ <span fg={C.yellow}>{`! ${warning}`}</span>
+ </text>
+ ))}
+ {probeSummary?.notes.map((note) => (
+ <text key={`note:${note}`}>
+ <span fg={C.dim}>{note}</span>
+ </text>
+ ))}
<text> </text>
- {/* Chain entries — 2 lines each */}
+ {/* Chain entries — 2 lines each, dropped candidates in place */}
{probeResults.map((entry, idx) => {
- const isNoKey = entry.status === "no_key";
+ const isDropped = entry.status === "dropped";
const isNotReached = entry.status === "skipped";
const isSelected = entry.status === "success" && probeMode === "done";
-
- const statusIcon =
- entry.status === "unverified"
- ? "◐"
- : entry.status === "success"
- ? "●"
- : entry.status === "failed"
- ? "✗"
- : entry.status === "testing"
- ? "◌"
- : isNoKey
- ? "○"
- : isNotReached
- ? "·"
- : "○";
-
- const statusColor =
- entry.status === "unverified"
- ? C.cyan
- : entry.status === "success"
- ? C.green
- : entry.status === "failed"
- ? C.red
- : entry.status === "testing"
- ? C.yellow
- : C.dim;
-
+ const status = rowStatusView(entry);
const nameCol = entry.displayName.padEnd(18).substring(0, 18);
-
- const statusText =
- entry.status === "unverified"
- ? "native — not probed"
- : entry.status === "success"
- ? entry.ms !== undefined
- ? `${entry.ms}ms`
- : "success"
- : entry.status === "failed"
- ? (entry.error ?? "failed")
- : entry.status === "testing"
- ? "testing..."
- : isNoKey
- ? "not configured, skipping"
- : isNotReached
- ? "not reached"
- : "waiting";
-
const reason = PROVIDER_REASONS[entry.provider] ?? entry.provider;
return (
- <box key={entry.provider} flexDirection="column">
+ <box key={`${idx}:${entry.provider}`} flexDirection="column">
<text>
<span fg={C.dim}>{`${idx + 1}. `}</span>
<span
- fg={isNoKey ? C.dim : isSelected ? C.strong : isNotReached ? C.dim : C.fgMuted}
+ fg={isDropped || isNotReached ? C.dim : isSelected ? C.strong : C.fgMuted}
attributes={A.boldIf(isSelected)}
>
{nameCol}
</span>
<span fg={C.dim}>{" "}</span>
- <span fg={statusColor} attributes={A.boldIf(entry.status === "success")}>
- {statusIcon} {statusText}
+ <span fg={status.color} attributes={A.boldIf(entry.status === "success")}>
+ {status.icon} {status.text}
</span>
{isSelected && (
<span fg={C.green} attributes={A.bold}>
@@ -307,7 +342,7 @@ export function RoutingContent({
</text>
<text>
<span fg={C.dim}>{" ↳ "}</span>
- <span fg={isNoKey ? C.dim : C.fgMuted}>{reason}</span>
+ <span fg={isDropped ? C.dim : C.fgMuted}>{reason}</span>
</text>
</box>
);
@@ -317,7 +352,14 @@ export function RoutingContent({
<>
<text> </text>
<text>
- {allFailed ? (
+ {probeSummary?.noRoute ? (
+ <>
+ <span fg={C.red} attributes={A.bold}>
+ {"Result: "}
+ </span>
+ <span fg={C.red}>{`✗ No route — ${probeSummary.noRoute.reason}`}</span>
+ </>
+ ) : allFailed ? (
<>
<span fg={C.red} attributes={A.bold}>
{"Result: "}
@@ -346,6 +388,11 @@ export function RoutingContent({
</>
)}
</text>
+ {hintLines(probeSummary?.noRoute?.hint).map((line) => (
+ <text key={line.id}>
+ <span fg={C.dim}>{` ${line.text}`}</span>
+ </text>
+ ))}
</>
)}
</box>
diff --git a/packages/cli/src/tui/hooks/useRouteProbe.ts b/packages/cli/src/tui/hooks/useRouteProbe.ts
index 38714e80..4939deb4 100644
--- a/packages/cli/src/tui/hooks/useRouteProbe.ts
+++ b/packages/cli/src/tui/hooks/useRouteProbe.ts
@@ -1,38 +1,146 @@
import { useCallback, useState } from "react";
-import type { ClaudishProfileConfig } from "../../profile-config.js";
-import { nativeRouteFor } from "../../providers/native-route.js";
+import { describeProbeState } from "../../providers/probe-live.js";
+import { INTERACTIVE_PROBE_TIMEOUT_MS, probeProviderRoute } from "../../providers/probe-runner.js";
+import {
+ type FallbackWithheld,
+ type RouteExplanation,
+ describeRouteExplanation,
+ explainRoute,
+} from "../../providers/routing-rules.js";
+import { ensureProbeProxy } from "../probe-proxy.js";
+import type { ProbeEntry, ProbeMode, ProbeSummary } from "../types.js";
/**
* Why a native row is never probed here: the native handler authenticates with
* the inbound Claude Code header, which this probe cannot supply, so a request
* would fail for a healthy model and a typo alike (see providers/native-route.ts).
*/
-const REASON_NATIVE =
- "Native Claude Code auth — not probed — served on Claude Code's own auth, which this process cannot forward";
-import { describeProbeState } from "../../providers/probe-live.js";
-import { INTERACTIVE_PROBE_TIMEOUT_MS, probeProviderRoute } from "../../providers/probe-runner.js";
-import { type Route, type RoutePlan, route } from "../../providers/routing-rules.js";
-import { ensureProbeProxy } from "../probe-proxy.js";
-import { getProviderDefs, providerIsReady } from "../providers.js";
-import type { ProbeEntry, ProbeMode } from "../types.js";
+const NATIVE_NOT_PROBED_NOTE =
+ "Not probed: served on Claude Code's own auth, which this process cannot forward.";
+
+/**
+ * Why a catalog-gathered chain has no fallback hop, when the catalog HAS the
+ * model. (When it does not, `describeRouteExplanation` already says so.)
+ */
+const FALLBACK_WITHHELD_NOTE: Record<FallbackWithheld, string> = {
+ disabled: 'No fallback hop: the default provider is set to "".',
+ "catalog-unreadable": "No fallback hop: there is no cloud models catalog to check it against.",
+ "already-gathered": "No separate fallback hop: that provider is already a catalog candidate.",
+ "catalog-denies": "No fallback hop: the catalog maps that provider no connection to this model.",
+};
+
+/** The probe panel's content for one decision: its summary and its rows. */
+export interface ProbeView {
+ summary: ProbeSummary;
+ rows: ProbeEntry[];
+}
+
+/**
+ * The probe panel for one `explainRoute` decision. Pure, so the panel's content
+ * is testable without a renderer, a proxy or a network.
+ *
+ * - The summary line is `describeRouteExplanation`, so a user rule reads with its
+ * scope and the key `route()` actually matched (project over global, the
+ * longest glob), and the panel words every decision exactly as `--probe` does.
+ * - One row per candidate, in chain order. A kept candidate is `pending`: the
+ * probe tests it. A dropped one is `dropped`, carrying the outcome that removed
+ * it, and is never tested.
+ * - A native target has no candidates; its one row is the native passthrough,
+ * `unverified`, because this process cannot supply the auth it forwards.
+ */
+export function probeRowsFrom(explanation: RouteExplanation): ProbeView {
+ const summary: ProbeSummary = {
+ line: describeRouteExplanation(explanation),
+ warnings: explanation.warnings.map((warning) => warning.message),
+ notes: [],
+ };
+
+ if (explanation.source === "native") {
+ summary.notes.push(NATIVE_NOT_PROBED_NOTE);
+ const native = explanation.native;
+ const rows: ProbeEntry[] = native
+ ? [
+ {
+ provider: native.provider,
+ displayName: native.displayName,
+ modelSpec: native.modelSpec,
+ status: "unverified",
+ },
+ ]
+ : [];
+ return { summary, rows };
+ }
+
+ if (explanation.catalog === "found" && explanation.fallbackWithheld) {
+ summary.notes.push(FALLBACK_WITHHELD_NOTE[explanation.fallbackWithheld]);
+ }
+ if (explanation.outcome.kind === "no-route") {
+ const { reason, hint } = explanation.outcome;
+ summary.noRoute = hint !== undefined ? { reason, hint } : { reason };
+ }
+
+ const rows = explanation.candidates.map((candidate): ProbeEntry => {
+ const row: ProbeEntry = {
+ provider: candidate.provider,
+ displayName: candidate.displayName,
+ modelSpec: candidate.modelSpec,
+ position: candidate.position,
+ ...(candidate.tier !== undefined ? { tier: candidate.tier } : {}),
+ status: "pending",
+ };
+ if (candidate.outcome !== "kept") {
+ row.status = "dropped";
+ row.outcome = candidate.outcome;
+ }
+ return row;
+ });
+ return { summary, rows };
+}
+
+/** One hop the probe tests: its row, and the spec a request would send. */
+export interface ProbeQueueItem {
+ index: number;
+ provider: string;
+ modelSpec: string;
+}
/**
- * `route()`, with its one throwing case folded into the plan it already renders.
+ * The hops the probe tests, in chain order: the kept ones, and nothing else. A
+ * dropped candidate or the native passthrough never enters `testing`.
+ */
+export function probeQueue(rows: ProbeEntry[]): ProbeQueueItem[] {
+ return rows.flatMap((row, index) =>
+ row.status === "pending" && row.modelSpec !== undefined
+ ? [{ index, provider: row.provider, modelSpec: row.modelSpec }]
+ : []
+ );
+}
+
+/**
+ * `explainRoute`, with its one throwing case folded into a view it can render.
*
- * A bare name makes `route()` THROW when the catalog contract is one this build
+ * A bare name makes routing THROW when the catalog contract is one this build
* cannot read (providers/routing-rules.ts) — deliberately, so no caller mistakes
* "claudish cannot look" for "claudish looked and found nothing". The probe is
* the caller that wants exactly that flattening, though: it is a diagnostic
* panel, its whole job is to display why a model will not route, and an
- * unhandled rejection inside an Ink render tree would take the config UI down
- * instead of answering the question. The message survives verbatim into the
- * panel's error column via `plan.reason`.
+ * unhandled rejection inside the render tree would take the config UI down
+ * instead of answering the question. The message survives verbatim as the
+ * no-route reason.
*/
-async function routeForProbe(model: string): Promise<RoutePlan> {
+async function probeViewFor(model: string): Promise<ProbeView> {
try {
- return await route(model);
+ return probeRowsFrom(await explainRoute(model));
} catch (err) {
- return { kind: "no-route", reason: err instanceof Error ? err.message : String(err) };
+ return {
+ summary: {
+ line: "the route could not be calculated",
+ warnings: [],
+ notes: [],
+ noRoute: { reason: err instanceof Error ? err.message : String(err) },
+ },
+ rows: [],
+ };
}
}
@@ -58,8 +166,10 @@ export interface UseRouteProbeReturn {
probeMode: ProbeMode;
/** Current input or submitted model name (empty string when idle). */
probeModel: string;
- /** Per-provider probe results (empty when idle/input). */
+ /** Per-candidate probe rows (empty when idle/input). */
probeResults: ProbeEntry[];
+ /** The decision as a whole: its explanation line, warnings and no-route reason. */
+ probeSummary: ProbeSummary | null;
/** Switch to input mode with a blank model + cleared results. */
startInput: () => void;
/** Append a single character to the input. No-op outside input. */
@@ -67,8 +177,9 @@ export interface UseRouteProbeReturn {
/** Trim one character. No-op outside input. */
backspace: () => void;
/**
- * Submit the current input. Empty input → idle; unroutable model → done with
- * single failed entry; otherwise → running, kicks off the async test loop.
+ * Submit the current input. Empty input → idle; a decision with nothing to
+ * test (no route, every candidate dropped, native) → done; otherwise →
+ * running, kicks off the async test loop over the kept hops.
*
* The async loop is INTENTIONALLY not abort-aware. See the type comment.
*/
@@ -82,14 +193,16 @@ export interface UseRouteProbeReturn {
enterFromDone: () => void;
}
-export function useRouteProbe(config: ClaudishProfileConfig): UseRouteProbeReturn {
+export function useRouteProbe(): UseRouteProbeReturn {
const [probeMode, setProbeMode] = useState<ProbeMode>("idle");
const [probeModel, setProbeModel] = useState("");
const [probeResults, setProbeResults] = useState<ProbeEntry[]>([]);
+ const [probeSummary, setProbeSummary] = useState<ProbeSummary | null>(null);
const startInput = useCallback(() => {
setProbeModel("");
setProbeResults([]);
+ setProbeSummary(null);
setProbeMode("input");
}, []);
@@ -106,12 +219,14 @@ export function useRouteProbe(config: ClaudishProfileConfig): UseRouteProbeRetur
// type comment. Preserves baseline behavior.
setProbeModel("");
setProbeResults([]);
+ setProbeSummary(null);
setProbeMode("idle");
}, []);
const enterFromDone = useCallback(() => {
setProbeModel("");
setProbeResults([]);
+ setProbeSummary(null);
setProbeMode("input");
}, []);
@@ -122,65 +237,27 @@ export function useRouteProbe(config: ClaudishProfileConfig): UseRouteProbeRetur
setProbeMode("idle");
return;
}
- // route() is async (credential resolution may pull from 1Password); the rest
- // of submit is already async, so the whole flow runs in one IIFE.
+ // explainRoute is async (credential resolution may pull from 1Password); the
+ // rest of submit is already async, so the whole flow runs in one IIFE.
(async () => {
- // Same guard the proxy applies before routing: a bare Claude name is native
- // passthrough, and route() would misreport it (see providers/native-route.ts).
- // The native link joins the chain so the panel shows it, but it is skipped
- // in the loop below: this probe cannot supply the Claude Code auth the
- // native handler forwards, so any request would fail regardless of model.
- const native = nativeRouteFor(model);
- let chain: Route[];
- if (native) {
- chain = [native];
- } else {
- const plan = await routeForProbe(model);
- if (plan.kind !== "ok") {
- setProbeResults([
- {
- provider: "none",
- displayName: "No routes found",
- status: "failed",
- error: plan.hint ?? plan.reason,
- },
- ]);
- setProbeMode("done");
- return;
- }
- chain = [plan.primary, ...plan.fallbacks];
- }
- // Check which routing rule matched. Case-INSENSITIVE — must mirror the
- // matching logic in matchRoutingRule (routing-rules.ts) so the probe panel
- // doesn't lie about which rule the engine actually picked.
- const ruleEntries = Object.entries(config.routing ?? {});
- const modelLower = model.toLowerCase();
- const matchedRule = ruleEntries.find(([pat]) => {
- if (pat.toLowerCase() === modelLower) return true;
- if (pat.includes("*")) {
- const regex = new RegExp(`^${pat.replace(/\*/g, ".*")}$`, "i");
- return regex.test(model);
- }
- return false;
- });
+ // The decision a request for this name would get, made by the function the
+ // proxy's routing runs: the native gate, the user's rules (both scopes), the
+ // catalog, the fallback hop, and the credential and availability filters.
+ const { summary, rows } = await probeViewFor(model);
+ setProbeSummary(summary);
+ setProbeResults(rows);
- const initial: ProbeEntry[] = chain.map((r) => {
- return {
- provider: r.provider,
- displayName: r.displayName,
- status: "pending",
- hasKey: true,
- reason: native
- ? "Native Claude Code auth — served by the proxy, never routed"
- : matchedRule
- ? `Custom rule: ${matchedRule[0]}`
- : "Default fallback chain",
- };
- });
- setProbeResults(initial);
+ // Only kept hops are tested. With none — a no-route, every candidate
+ // dropped, or the native passthrough — there is nothing to probe, and the
+ // proxy is never started: its startup failure would repaint rows `failed`.
+ const queue = probeQueue(rows);
+ if (queue.length === 0) {
+ setProbeMode("done");
+ return;
+ }
setProbeMode("running");
- // Run tests sequentially — skip providers without credentials.
+ // Run tests sequentially over the kept hops, in chain order.
// INTENTIONAL: the loop is NOT abort-aware. Even after the user presses
// Esc to cancel and the state flips to idle, this loop keeps running and
// can transition the state back to "done" via setProbeMode("done").
@@ -190,42 +267,25 @@ export function useRouteProbe(config: ClaudishProfileConfig): UseRouteProbeRetur
// OAuth providers (e.g. antigravity after `claudish login antigravity`)
// are tested for real instead of being misreported as missing.
(async () => {
- // A native chain has nothing to probe — settle it BEFORE the proxy is
- // touched. Proxy startup failure below repaints every row `failed`,
- // which would turn the native row back into a red "no route".
- if (native) {
- setProbeResults((prev) =>
- prev.map((e) => ({ ...e, status: "unverified" as const, reason: REASON_NATIVE }))
- );
- setProbeMode("done");
- return;
- }
- // Best-effort proxy startup. If it fails we mark everything as failed
- // with a clear error.
+ // Best-effort proxy startup. If it fails we mark every hop we would have
+ // tested as failed, with a clear error. Dropped rows keep their outcome.
let proxyUrl: string;
try {
proxyUrl = await ensureProbeProxy();
} catch (err) {
const msg = err instanceof Error ? err.message : String(err);
+ const queued = new Set(queue.map((item) => item.index));
setProbeResults((prev) =>
- prev.map((e) => ({ ...e, status: "failed", error: `probe proxy: ${msg}` }))
+ prev.map((e, idx) =>
+ queued.has(idx) ? { ...e, status: "failed", error: `probe proxy: ${msg}` } : e
+ )
);
setProbeMode("done");
return;
}
- for (let i = 0; i < chain.length; i++) {
- const link = chain[i]!;
- // Mirror the static credential check from hasCredentialsForProvider —
- // covers env, config, OAuth files. Local providers are always ready.
- const provDef = getProviderDefs().find((p) => p.catalogName === link.provider);
- const ready = provDef ? providerIsReady(provDef, config) : true;
- if (!ready) {
- setProbeResults((prev) =>
- prev.map((e, idx) => (idx === i ? { ...e, status: "no_key" } : e))
- );
- continue;
- }
+ for (const link of queue) {
+ const i = link.index;
// Mark current as testing
setProbeResults((prev) =>
prev.map((e, idx) => (idx === i ? { ...e, status: "testing" } : e))
@@ -236,8 +296,8 @@ export function useRouteProbe(config: ClaudishProfileConfig): UseRouteProbeRetur
{
provider: link.provider,
modelSpec: link.modelSpec,
- // Let the proxy do the real credential resolution. The static
- // ready-check above just gates the noisy "no key" rows.
+ // A kept hop passed explainRoute's credential filter, the only
+ // credential check; the proxy resolves the key itself.
hasCredentials: true,
},
INTERACTIVE_PROBE_TIMEOUT_MS
@@ -257,9 +317,9 @@ export function useRouteProbe(config: ClaudishProfileConfig): UseRouteProbeRetur
error: ok ? undefined : describeProbeState(result),
ms,
};
- // After success: remaining providers with keys become "not reached",
- // without keys stay "no_key"
- if (idx > i && ok && e.status !== "no_key")
+ // After a success, every later kept hop is "not reached". Dropped
+ // rows keep their outcome.
+ if (idx > i && ok && e.status === "pending")
return { ...e, status: "skipped" as const };
return e;
})
@@ -269,7 +329,7 @@ export function useRouteProbe(config: ClaudishProfileConfig): UseRouteProbeRetur
setProbeMode("done");
})();
})();
- }, [config, probeModel]);
+ }, [probeModel]);
// Build the DU view from the underlying state atoms.
let state: ProbeState;
@@ -284,6 +344,7 @@ export function useRouteProbe(config: ClaudishProfileConfig): UseRouteProbeRetur
probeMode,
probeModel,
probeResults,
+ probeSummary,
startInput,
typeChar,
backspace,
diff --git a/packages/cli/src/tui/types.ts b/packages/cli/src/tui/types.ts
index 16d7bdb7..05922c43 100644
--- a/packages/cli/src/tui/types.ts
+++ b/packages/cli/src/tui/types.ts
@@ -3,6 +3,9 @@
* avoid circular imports back into the root component.
*/
+import type { RouteTier } from "../providers/provider-definitions.js";
+import type { CandidateOutcome } from "../providers/routing-rules.js";
+
export type Tab = "providers" | "profiles" | "routing" | "privacy" | "onepassword";
export type Mode =
@@ -64,19 +67,63 @@ export interface MergedRule {
export type ProbeMode = "idle" | "input" | "running" | "done";
+/** What removed a route candidate: every `CandidateOutcome` except `kept`. */
+export type DroppedOutcome = Exclude<CandidateOutcome, "kept">;
+
+/**
+ * One row of the route probe: one candidate of the chain `explainRoute`
+ * calculated, in chain order, or the native passthrough.
+ */
export interface ProbeEntry {
provider: string;
displayName: string;
/**
- * `unverified`: the route is real but this process cannot probe it — the
- * native Claude passthrough, whose auth is the inbound Claude Code header.
- * Neither a success nor a failure; the panel must not fold it into either.
+ * - `pending` → `testing` → `success` | `failed`, or `skipped` (not reached
+ * because an earlier hop answered): a KEPT hop, which the probe tests.
+ * - `dropped`: `explainRoute` removed this candidate; `outcome` names the
+ * filter. Never tested: the credential and availability verdicts are
+ * `explainRoute`'s, and the probe keeps no second opinion.
+ * - `unverified`: the route is real but this process cannot probe it — the
+ * native Claude passthrough, whose auth is the inbound Claude Code header.
+ * Neither a success nor a failure; the panel must not fold it into either.
+ * - `no_key`: no longer produced. A missing credential is `dropped` with
+ * outcome `no-credential`. It stays in the union only because
+ * `probe-outcome.test.ts` names it; remove the two together.
*/
- status: "pending" | "testing" | "success" | "failed" | "skipped" | "no_key" | "unverified";
+ status:
+ | "pending"
+ | "testing"
+ | "success"
+ | "failed"
+ | "skipped"
+ | "dropped"
+ | "no_key"
+ | "unverified";
+ /** `dropped` only: the filter that removed the candidate. */
+ outcome?: DroppedOutcome;
+ /** The spec a kept hop is probed with: exactly the `Route.modelSpec` a request uses. */
+ modelSpec?: string;
+ /** The definition's tier; absent for a provider no definition carries. */
+ tier?: RouteTier;
+ /** `fallback`: the fallback hop's position, whichever provider holds it. */
+ position?: "candidate" | "fallback";
error?: string;
ms?: number;
- hasKey?: boolean;
- reason?: string;
+}
+
+/**
+ * What the route probe says about the decision as a whole, beside its rows. All
+ * of it comes from one `explainRoute` call.
+ */
+export interface ProbeSummary {
+ /** `describeRouteExplanation`: where the chain came from, worded as `--probe` words it. */
+ line: string;
+ /** The explanation's warnings (billing notices, rule problems), one line each. */
+ warnings: string[];
+ /** Facts about the decision that are not warnings (a withheld fallback hop, native auth). */
+ notes: string[];
+ /** A no-route decision: the reason and hint `route()` would return, verbatim. */
+ noRoute?: { reason: string; hint?: string };
}
export interface TestResult {