Skip to content

Commit 3f25bfe

Browse files
WBWB
authored andcommitted
fix(tui): show connection host in footer
1 parent 3a64302 commit 3f25bfe

5 files changed

Lines changed: 29 additions & 3 deletions

File tree

docs/web/tui.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Notes:
5454
- Header: connection URL, current agent, current session.
5555
- Chat log: user messages, assistant replies, system notices, tool cards.
5656
- Status line: connection/run state (connecting, running, streaming, idle, error).
57-
- Footer: connection state + agent + session + model + goal state + think/fast/verbose/trace/reasoning + token counts + deliver.
57+
- Footer: connection host when available + agent + session + model + goal state + think/fast/verbose/trace/reasoning + token counts + deliver.
5858
- Input: text editor with autocomplete.
5959

6060
## Mental model: agents + sessions
@@ -67,7 +67,7 @@ Notes:
6767
- Session scope:
6868
- `per-sender` (default): each agent has many sessions.
6969
- `global`: the TUI always uses the `global` session (the picker may be empty).
70-
- The current agent + session are always visible in the footer.
70+
- For URL-backed connections, the footer includes the connection host alongside the current agent and session.
7171
- If the session has a [goal](/tools/goal), the footer shows its compact state
7272
such as `Pursuing goal`, `Goal paused (/goal resume)`, or
7373
`Goal achieved`.

src/tui/tui-formatters.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
extractContentFromMessage,
55
extractTextFromMessage,
66
extractThinkingFromMessage,
7+
formatConnectionHostFooter,
78
formatGoalFooter,
89
isCommandMessage,
910
sanitizeRenderableText,
@@ -44,6 +45,19 @@ describe("formatGoalFooter", () => {
4445
});
4546
});
4647

48+
describe("formatConnectionHostFooter", () => {
49+
it("renders only the connection hostname", () => {
50+
expect(formatConnectionHostFooter("ws://gateway-host:18789")).toBe("host gateway-host");
51+
expect(
52+
formatConnectionHostFooter("wss://user:secret@example.com:443/path?token=redacted"),
53+
).toBe("host example.com");
54+
});
55+
56+
it("skips non-url local connection labels", () => {
57+
expect(formatConnectionHostFooter("local embedded")).toBeNull();
58+
});
59+
});
60+
4761
describe("extractTextFromMessage", () => {
4862
it("prefers final_answer text over commentary text for assistant messages", () => {
4963
const text = extractTextFromMessage({

src/tui/tui-formatters.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,15 @@ export function formatTokens(total?: number | null, context?: number | null) {
442442
return `tokens ${totalLabel}/${formatTokenCount(context)}${pct !== null ? ` (${pct}%)` : ""}`;
443443
}
444444

445+
export function formatConnectionHostFooter(connectionUrl: string): string | null {
446+
try {
447+
const hostname = new URL(connectionUrl.trim()).hostname.trim();
448+
return hostname ? `host ${hostname}` : null;
449+
} catch {
450+
return null;
451+
}
452+
}
453+
445454
function formatGoalUsage(goal: SessionGoal): string | null {
446455
if (goal.tokenBudget === undefined) {
447456
return goal.tokensUsed > 0 ? formatTokenCount(goal.tokensUsed) : null;

src/tui/tui-pty-harness.e2e.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ describe.sequential("TUI PTY harness", () => {
363363

364364
it("renders local ready on startup", () => {
365365
expect(fixture.run.output()).toContain("local ready");
366+
expect(fixture.run.output()).toContain("host local");
366367
});
367368

368369
it(

src/tui/tui.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import { editorTheme, theme } from "./theme/theme.js";
3434
import type { TuiBackend } from "./tui-backend.js";
3535
import { createCommandHandlers } from "./tui-command-handlers.js";
3636
import { createEventHandlers } from "./tui-event-handlers.js";
37-
import { formatGoalFooter, formatTokens } from "./tui-formatters.js";
37+
import { formatConnectionHostFooter, formatGoalFooter, formatTokens } from "./tui-formatters.js";
3838
import {
3939
buildTuiLastSessionScopeKey,
4040
readTuiLastSessionKey,
@@ -1191,7 +1191,9 @@ export async function runTui(opts: RunTuiOptions): Promise<TuiResult> {
11911191
const reasoning = sessionInfo.reasoningLevel ?? "off";
11921192
const reasoningLabel =
11931193
reasoning === "on" ? "reasoning" : reasoning === "stream" ? "reasoning:stream" : null;
1194+
const hostLabel = formatConnectionHostFooter(client.connection.url);
11941195
const footerParts = [
1196+
hostLabel,
11951197
`agent ${agentLabel}`,
11961198
`session ${sessionLabel}`,
11971199
modelLabel,

0 commit comments

Comments
 (0)