From f771d26e7af008e0f661fd8b3fab48b7abc78b17 Mon Sep 17 00:00:00 2001 From: redshift <213178690+sh1ftred@users.noreply.github.com> Date: Thu, 20 Aug 2026 12:18:56 +0000 Subject: [PATCH] feat(tui): show daemon URL in system status box (#83) Co-authored-by: redshift <213178690+1ftredsh@users.noreply.github.com> --- src/tui/usage/data.ts | 15 +++++++++++++-- src/tui/usage/render.ts | 8 ++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/tui/usage/data.ts b/src/tui/usage/data.ts index e58412a..e479cf5 100644 --- a/src/tui/usage/data.ts +++ b/src/tui/usage/data.ts @@ -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 { 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 { daemon: output?.daemon || "unknown", wallet: output?.wallet || "unknown", mode: output?.mode || "apikeys", + url: getDaemonBaseUrl(config), error: output?.error, }; } catch { diff --git a/src/tui/usage/render.ts b/src/tui/usage/render.ts index 36a0c0a..aebfcf8 100644 --- a/src/tui/usage/render.ts +++ b/src/tui/usage/render.ts @@ -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) {