Skip to content

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

fix(tui): read the Muse Keychain login before testing a Muse Code row

Jack Rudenko0f459efd2cc4
diff --git a/packages/cli/src/providers/meta-muse/muse-credentials.ts b/packages/cli/src/providers/meta-muse/muse-credentials.ts
index 5e0c27e1..24b4ba3c 100644
--- a/packages/cli/src/providers/meta-muse/muse-credentials.ts
+++ b/packages/cli/src/providers/meta-muse/muse-credentials.ts
@@ -329,6 +329,17 @@ export async function withInteractiveCredential<T>(action: () => Promise<T>): Pr
return action();
}
+/**
+ * Resolve the Muse login in-process for a config-TUI action (Test, Test All,
+ * the Routing tab's probe) before it sends anything to the probe proxy. The
+ * action is the user's keypress, so the Keychain may be read here; the proxy's
+ * requests then find the key in memory. Never throws: the action reports what
+ * its own request finds.
+ */
+export async function prepareMuseLoginForTuiAction(): Promise<void> {
+ await withInteractiveCredential(async () => undefined);
+}
+
/**
* The one cached Muse Code credential status, for sync readers (Providers tab,
* `claudish providers --json`, `source.ts`). The two file checks are sync;
diff --git a/packages/cli/src/tui/App.tsx b/packages/cli/src/tui/App.tsx
index 30c94433..5ac84a2a 100644
--- a/packages/cli/src/tui/App.tsx
+++ b/packages/cli/src/tui/App.tsx
@@ -47,7 +47,10 @@ import {
pingLocalProvider,
pingLocalProviders,
} from "../providers/local-liveness.js";
-import { refreshMuseCredentialStatus } from "../providers/meta-muse/muse-credentials.js";
+import {
+ prepareMuseLoginForTuiAction,
+ refreshMuseCredentialStatus,
+} from "../providers/meta-muse/muse-credentials.js";
// 1Password CONFIG persistence (sync, no SDK). Reads/writes the global +
// project config files for the account / imports / environments fields.
import {
@@ -1336,6 +1339,12 @@ export function App({ requestLogin }: AppProps = {}) {
const startMs = Date.now();
try {
+ // Muse Code: the user's own action, so its login is resolved HERE,
+ // in-process, before any proxy request — the one TUI path allowed to read
+ // the Muse Code CLI's Keychain item (the access dialog, if any, belongs to
+ // this keypress). The probe proxy runs in this process and finds the key
+ // in memory; the request path itself never prompts.
+ if (prov.catalogName === "meta-muse-code") await prepareMuseLoginForTuiAction();
const proxyUrl = await ensureProbeProxy();
const catalogModel = getProbeModel(prov.catalogName);
// Models that already failed this round — passed to discovery so we
diff --git a/packages/cli/src/tui/hooks/useRouteProbe.ts b/packages/cli/src/tui/hooks/useRouteProbe.ts
index 21300d06..4ac886ad 100644
--- a/packages/cli/src/tui/hooks/useRouteProbe.ts
+++ b/packages/cli/src/tui/hooks/useRouteProbe.ts
@@ -1,4 +1,5 @@
import { useCallback, useState } from "react";
+import { prepareMuseLoginForTuiAction } from "../../providers/meta-muse/muse-credentials.js";
import { NATIVE_NOT_PROBED } from "../../providers/native-route.js";
import { describeProbeState } from "../../providers/probe-live.js";
import { INTERACTIVE_PROBE_TIMEOUT_MS, probeProviderRoute } from "../../providers/probe-runner.js";
@@ -266,6 +267,11 @@ export function useRouteProbe(): UseRouteProbeReturn {
// tested as failed, with a clear error. Dropped rows keep their outcome.
let proxyUrl: string;
try {
+ // A Muse Code hop: resolve its login in-process first, the one TUI
+ // path that may read the Muse Code CLI's Keychain item.
+ if (queue.some((item) => item.provider === "meta-muse-code")) {
+ await prepareMuseLoginForTuiAction();
+ }
proxyUrl = await ensureProbeProxy();
} catch (err) {
const msg = err instanceof Error ? err.message : String(err);