Skip to content
Merged
Prev Previous commit
Next Next commit
feat(tui): startup status card + web search HUD indicator
Show a status overview on startup (GitHub login state, web search
readiness, worker, configured clients) and a live web ✓/✗ marker in the
HUD footer, which is now two lines so it doesn't crowd. GitHub shows a
login STATE (connected/expired/signed-out) rather than an expiry — the
device-flow OAuth token has no real expiry, so a countdown would be fake
data. When web search isn't configured the indicator and card both point
to /web-search-support.

Co-Authored-By: Claude <noreply@anthropic.com>
  • Loading branch information
wangcansunking and claude committed Jun 26, 2026
commit 701b6ba0162e6de5514300f712f782189f6edbd3
11 changes: 7 additions & 4 deletions e2e/RESULTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ and update this file (paste the summary).
them); a capped agentic loop in the Anthropic endpoint runs those tools internally against
Microsoft Web IQ (`api.microsoft.ai`) and feeds results back, so the client only ever sees the
final grounded answer (transparent). A new `/web-search-support` command stores the WebIQ key
(data dir or `WEBIQ_API_KEY`, read lazily — no worker restart). Verified live end-to-end (real
Copilot + real WebIQ): a `web_search` request returned `stop_reason: end_turn` with a fresh answer
and no tool_use block leaked to the client. Full suite green: `npm test` → **267 passed** (50
files), `npm run test:e2e` → **31 passed** (4 files), tsc build clean.
(data dir or `WEBIQ_API_KEY`, read lazily — no worker restart). Also added a startup status card
(GitHub login state — connected/expired/signed-out, since the device-flow token has no real
expiry — plus web search readiness, worker, and configured clients) and a live `web ✓/✗` indicator
in the now two-line HUD footer. Verified live end-to-end (real Copilot + real WebIQ): a
`web_search` request returned `stop_reason: end_turn` with a fresh answer and no tool_use block
leaked to the client. Full suite green: `npm test` → **281 passed** (51 files), `npm run test:e2e`
→ **31 passed** (4 files), tsc build clean.

- **2026-06-25** — Fixed the `/login` deadlock: the slash command buffered the device code behind a
blocking token poll, so the Repl showed nothing and the user could never authorize. Split device
Expand Down
16 changes: 15 additions & 1 deletion src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ import { startSupervisor } from "../supervisor/index.js";
import { runAssistantTurn } from "../tui/assistant/runtime.js";
import { makeOnChat } from "../tui/assistant/on-chat.js";
import { readGhToken, clearGhToken } from "../shared/creds.js";
import { writeWebIqKey } from "../shared/webiq-key.js";
import { writeWebIqKey, readWebIqKey } from "../shared/webiq-key.js";
import { readClientSetup, writeClientSetup } from "../shared/client-setup.js";
import { readChatModel, writeChatModel } from "../shared/prefs.js";
import { CopilotTokenStore, isCopilotTokenValid } from "../providers/copilot/token.js";
import { fetchCopilotModels, fetchModelLimits } from "../providers/copilot/models.js";
import { applyClaude, applyCodex, resetClaude, resetCodex, CLAUDE_ENV_KEYS, CODEX_ENV_KEYS, type Scope } from "../tui/setup/apply.js";
import { readClientStatus } from "../tui/setup/status.js";
import { summarizeStatus } from "../tui/status-summary.js";
import { applyCodexToml } from "../tui/setup/codex-toml.js";
import type { SetupClient } from "../tui/setup/wizard.js";
import { claudeCopilotReverseEnv } from "../tui/setup/clients.js";
Expand Down Expand Up @@ -151,6 +152,17 @@ async function launchTui(): Promise<void> {

const persistedModel = readChatModel(dataDir());

// Startup overview. The token was already validated above (re-auth happens before we get here), so
// GitHub is connected; web search readiness and configured clients are read from disk.
const clientStatus = readClientStatus();
const startupStatus = summarizeStatus({
hasToken: Boolean(readGhToken(dataDir())),
tokenValid: true,
webSearchReady: Boolean(readWebIqKey(dataDir())),
worker: "ready",
clients: { claude: clientStatus.claude.user || clientStatus.claude.project, codex: clientStatus.codex.user || clientStatus.codex.project },
});

app = render(
React.createElement(App, {
registry,
Expand All @@ -173,6 +185,8 @@ async function launchTui(): Promise<void> {
pickModelOnStart: !persistedModel,
login: doLogin,
saveWebIqKey: (k: string) => writeWebIqKey(k, dataDir()),
webSearchReady: () => Boolean(readWebIqKey(dataDir())),
startupStatus,
}),
);
}
Expand Down
47 changes: 37 additions & 10 deletions src/tui/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { SetupWizard, type SetupClient } from "./setup/wizard.js";
import { ModelScreen } from "./screens/model.js";
import { ConfigScreen, type ConfigInfo } from "./screens/config.js";
import { WebIqKeyScreen } from "./screens/webiq-key.js";
import type { StatusSummary } from "./status-summary.js";
import type { Scope, ApplyResult } from "./setup/apply.js";
import type { ClientStatus } from "./setup/status.js";
import { theme } from "./theme.js";
Expand All @@ -28,6 +29,21 @@ const stateColor: Record<WorkerState, string> = {
const EMPTY_STATUS: ClientStatus = { claude: { user: false, project: false }, codex: { user: false, project: false } };
const SPINNER = ["✶", "✸", "✹", "✺", "✹", "✷"];

// Startup overview card. GitHub shows a login STATE (no real token expiry exists), web search shows
// whether a WebIQ key is configured with the command to fix it when not.
function statusCard(s: StatusSummary): Entry {
const gh = s.github === "connected" ? "✓ connected" : s.github === "expired" ? "✗ expired — run /login" : "✗ signed out — run /login";
const web = s.webSearch === "ready" ? "✓ ready" : "✗ not configured — run /web-search-support";
const clients = `claude ${s.clients.claude ? "✓" : "○"} codex ${s.clients.codex ? "✓" : "○"}`;
const tone: "ok" | "error" = s.github === "connected" ? "ok" : "error";
return { type: "card", title: "status", tone, lines: [
`GitHub login ${gh}`,
`web search ${web}`,
`worker ${s.worker}`,
`clients ${clients}`,
] };
}

const fmtElapsed = (ms: number): string => {
const s = Math.floor(ms / 1000);
return s >= 60 ? `${Math.floor(s / 60)}m ${s % 60}s` : `${s}s`;
Expand All @@ -54,6 +70,10 @@ export interface AppProps {
login?: (show: (lines: string[]) => void) => Promise<string[]>;
// Persist a WebIQ API key entered via /web-search-support (enables gateway web_search/web_fetch).
saveWebIqKey?: (key: string) => void;
// Whether web search is configured (a WebIQ key is present). Read live so the HUD reflects it.
webSearchReady?: () => boolean;
// One-time status overview shown as the first card on startup.
startupStatus?: StatusSummary;
}

function OutputCard({ title, lines, tone }: { title: string; lines: string[]; tone: "info" | "ok" | "error" }) {
Expand Down Expand Up @@ -108,21 +128,23 @@ function ClientBadge({ name, status }: { name: string; status: { user: boolean;
export function App({
registry, title, workerState = "starting", initialModel = "—",
statusSource, readStatus, modelLimits, onChat,
loadModels, setup, info, onModelChange, pickModelOnStart, login, saveWebIqKey,
loadModels, setup, info, onModelChange, pickModelOnStart, login, saveWebIqKey, webSearchReady, startupStatus,
}: AppProps) {
const cmds: CommandHint[] = registry.list().map((c) => ({ name: c.name, describe: c.describe }));
const [entries, setEntries] = useState<Entry[]>([
const [entries, setEntries] = useState<Entry[]>(() => [
...(startupStatus ? [statusCard(startupStatus)] : []),
{ type: "system", text: "Type a message to chat with the assistant, or /help for commands." },
]);
const [state, setState] = useState<WorkerState>(workerState);
const [status, setStatus] = useState<ClientStatus>(() => readStatus?.() ?? EMPTY_STATUS);
const [webReady, setWebReady] = useState<boolean>(() => webSearchReady?.() ?? false);
const [model, setModel] = useState(initialModel);
const [screen, setScreen] = useState<Screen>(pickModelOnStart && loadModels ? { kind: "model" } : null);
const [, setNow] = useState(0); // ticks the live loading line while the assistant streams
const abortRef = useRef<AbortController | null>(null); // current turn's interrupt handle
const loginInFlight = useRef(false); // guards against starting a second device-login flow
const add = (e: Entry) => setEntries((p) => [...p, e].slice(-100));
const refreshStatus = () => { if (readStatus) setStatus(readStatus()); };
const refreshStatus = () => { if (readStatus) setStatus(readStatus()); if (webSearchReady) setWebReady(webSearchReady()); };

// esc interrupts an in-flight assistant turn (the Repl doesn't use esc, so this is unambiguous).
useInput((_input, key) => { if (key.escape) abortRef.current?.abort(); });
Expand Down Expand Up @@ -247,7 +269,7 @@ export function App({
} else if (screen?.kind === "webiq-key" && saveWebIqKey) {
body = (
<WebIqKeyScreen
onSubmit={(k) => { saveWebIqKey(k); setScreen(null); add({ type: "card", title: "/web-search-support", tone: "ok", lines: ["✓ WebIQ key saved — web search is now enabled for connected clients"] }); }}
onSubmit={(k) => { saveWebIqKey(k); setWebReady(true); setScreen(null); add({ type: "card", title: "/web-search-support", tone: "ok", lines: ["✓ WebIQ key saved — web search is now enabled for connected clients"] }); }}
onCancel={() => { setScreen(null); add({ type: "system", text: "web-search-support cancelled" }); }}
/>
);
Expand Down Expand Up @@ -284,12 +306,17 @@ export function App({

{body}

<Box paddingX={1}>
<Text color={theme.muted}>model </Text><Text color={theme.accent}>{model}</Text>
<Text color={theme.muted}> · daemon </Text><Text color={stateColor[state]}>{state}</Text>
<Text color={theme.muted}> · </Text><ClientBadge name="claude" status={status.claude} />
<Text color={theme.muted}> </Text><ClientBadge name="codex" status={status.codex} />
<Text color={theme.muted}> · /help</Text>
<Box flexDirection="column" paddingX={1}>
<Box>
<Text color={theme.muted}>model </Text><Text color={theme.accent}>{model}</Text>
<Text color={theme.muted}> · daemon </Text><Text color={stateColor[state]}>{state}</Text>
<Text color={theme.muted}> · web </Text><Text color={webReady ? theme.ready : theme.muted}>{webReady ? "✓" : "✗ /web-search-support"}</Text>
</Box>
<Box>
<ClientBadge name="claude" status={status.claude} />
<Text color={theme.muted}> </Text><ClientBadge name="codex" status={status.codex} />
<Text color={theme.muted}> · /help</Text>
</Box>
</Box>
</Box>
);
Expand Down
37 changes: 37 additions & 0 deletions src/tui/status-summary.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import type { WorkerState } from "../shared/control-types.js";

// Status overview shown on startup and reflected in the HUD. GitHub's device-flow OAuth token has no
// real expiry (GitHub returns no expires_in for this app), so we report a LOGIN STATE, not a
// countdown: "connected" means the stored token still exchanges for a Copilot token, "expired" means
// it no longer does (revoked / re-auth needed), "signed-out" means there's no token at all.
export type GithubLoginState = "connected" | "expired" | "signed-out";
export type WebSearchState = "ready" | "not-configured";

export interface StatusInputs {
hasToken: boolean; // a GitHub token is stored
tokenValid: boolean; // that token still exchanges for a Copilot token (network-checked upstream)
webSearchReady: boolean; // a WebIQ key is configured (env or data dir)
worker: WorkerState;
clients: { claude: boolean; codex: boolean };
}

export interface StatusSummary {
github: GithubLoginState;
webSearch: WebSearchState;
worker: WorkerState;
clients: { claude: boolean; codex: boolean };
}

export function githubLoginState(hasToken: boolean, tokenValid: boolean): GithubLoginState {
if (!hasToken) return "signed-out";
return tokenValid ? "connected" : "expired";
}

export function summarizeStatus(i: StatusInputs): StatusSummary {
return {
github: githubLoginState(i.hasToken, i.tokenValid),
webSearch: i.webSearchReady ? "ready" : "not-configured",
worker: i.worker,
clients: i.clients,
};
}
26 changes: 26 additions & 0 deletions tests/tui/app-interaction.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,32 @@ describe("TUI: /web-search-support key entry", () => {
});
});

describe("TUI: startup status card", () => {
it("renders the GitHub/web-search/worker overview on startup", () => {
const startupStatus = { github: "connected" as const, webSearch: "not-configured" as const, worker: "ready" as const, clients: { claude: true, codex: false } };
const { lastFrame } = render(<App registry={reg()} title="m" startupStatus={startupStatus} />);
const f = lastFrame() ?? "";
expect(f).toMatch(/status/);
expect(f).toMatch(/GitHub login.*connected/);
expect(f).toMatch(/web search.*not configured.*\/web-search-support/);
expect(f).toMatch(/worker.*ready/);
});
});

describe("TUI: HUD web search indicator", () => {
it("shows web ✗ with the command hint when no WebIQ key is configured", () => {
const { lastFrame } = render(<App registry={reg()} title="m" webSearchReady={() => false} />);
const f = lastFrame() ?? "";
expect(f).toMatch(/web .*✗/);
expect(f).toContain("/web-search-support");
});
it("shows web ✓ when a WebIQ key is configured", () => {
const { lastFrame } = render(<App registry={reg()} title="m" webSearchReady={() => true} />);
const f = lastFrame() ?? "";
expect(f).toMatch(/web .*✓/);
});
});

describe("TUI: model picker", () => {
it("/model opens the picker and lists models with context windows", async () => {
const loadModels = async () => ["gpt-4o", "claude-opus-4.8"];
Expand Down
37 changes: 37 additions & 0 deletions tests/tui/status-summary.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { describe, it, expect } from "vitest";
import { githubLoginState, summarizeStatus, type StatusInputs } from "../../src/tui/status-summary.js";

describe("githubLoginState", () => {
it("signed-out when there is no token", () => {
expect(githubLoginState(false, false)).toBe("signed-out");
});
it("expired when a token exists but no longer exchanges", () => {
expect(githubLoginState(true, false)).toBe("expired");
});
it("connected when the token exchanges for a Copilot token", () => {
expect(githubLoginState(true, true)).toBe("connected");
});
});

describe("summarizeStatus", () => {
const base: StatusInputs = {
hasToken: true, tokenValid: true, webSearchReady: true,
worker: "ready", clients: { claude: true, codex: false },
};
it("maps a fully-configured environment", () => {
const s = summarizeStatus(base);
expect(s.github).toBe("connected");
expect(s.webSearch).toBe("ready");
expect(s.worker).toBe("ready");
expect(s.clients).toEqual({ claude: true, codex: false });
});
it("reports web search as not configured when no key is present", () => {
expect(summarizeStatus({ ...base, webSearchReady: false }).webSearch).toBe("not-configured");
});
it("reports github expired when token present but invalid", () => {
expect(summarizeStatus({ ...base, tokenValid: false }).github).toBe("expired");
});
it("reports github signed-out when no token", () => {
expect(summarizeStatus({ ...base, hasToken: false, tokenValid: false }).github).toBe("signed-out");
});
});
Loading