mirror of
https://github.com/Routstr/routstrd.git
synced 2026-09-14 02:55:07 +00:00
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:
+13
-2
@@ -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 {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user