feat(tui): show daemon URL in system status box (#83)

Co-authored-by: redshift <213178690+1ftredsh@users.noreply.github.com>
This commit is contained in:
redshift
2026-08-20 12:18:56 +00:00
committed by GitHub
co-authored by redshift
parent c259dfad20
commit f771d26e7a
2 changed files with 21 additions and 2 deletions
+13 -2
View File
@@ -1,5 +1,10 @@
import type { UsageTrackingEntry } from "../../daemon/types.ts";
import { callDaemon, isDaemonRunning } from "../../utils/daemon-client.ts";
import {
callDaemon,
getDaemonBaseUrl,
isDaemonRunning,
loadConfig,
} from "../../utils/daemon-client.ts";
import type { UsageStats, UsageSummary } from "./types.ts";
export { isDaemonRunning };
@@ -21,12 +26,17 @@ export interface StatusInfo {
daemon: string;
wallet: string;
mode: "xcashu" | "apikeys";
/** URL the TUI is connected through (local bind or remote daemonUrl). */
url?: string;
error?: string;
}
export async function fetchStatus(): Promise<StatusInfo | null> {
try {
const result = await callDaemon("/status");
const [result, config] = await Promise.all([
callDaemon("/status"),
loadConfig(),
]);
if (result.error) return null;
const output = result.output as {
@@ -40,6 +50,7 @@ export async function fetchStatus(): Promise<StatusInfo | null> {
daemon: output?.daemon || "unknown",
wallet: output?.wallet || "unknown",
mode: output?.mode || "apikeys",
url: getDaemonBaseUrl(config),
error: output?.error,
};
} catch {
+8
View File
@@ -162,6 +162,14 @@ export function renderOverview(stats: UsageStats, balance: BalanceInfo | null, s
const walletColor = status.wallet === "connected" ? COLORS.green : COLORS.red;
const modeColor = COLORS.cyan;
statusLines.push(`${COLORS.bold}Daemon:${COLORS.reset} ${daemonColor}${status.daemon}${COLORS.reset}`);
if (status.url) {
const label = "Running on: ";
const maxUrlLen = Math.max(8, halfWidth2 - 4 - label.length);
const url = status.url.length > maxUrlLen
? `${status.url.slice(0, Math.max(0, maxUrlLen - 1))}`
: status.url;
statusLines.push(`${COLORS.bold}${label}${COLORS.reset} ${COLORS.cyan}${url}${COLORS.reset}`);
}
statusLines.push(`${COLORS.bold}Wallet:${COLORS.reset} ${walletColor}${status.wallet}${COLORS.reset}`);
statusLines.push(`${COLORS.bold}Mode:${COLORS.reset} ${modeColor}${status.mode}${COLORS.reset}`);
if (status.error) {