fix(tui): repoint agent-detail runtime fallback to daemon-consistent 'unknown' — dead-arm cleanup (LEG-7 LOW 2)

Fold-wave qitem 79159e6f LOW 2. The icon-fix QA (5a70e200, review50-r1) found the agent-detail
runtime field's `?? "— (not served)"` placeholder unreachable via the production API: the daemon
coerces a null runtime to the string "unknown" before the wire, so render.ts never sees null.
Repoint the defensive fallback to "unknown" to match that coercion — honest (what actually
renders), kills the misleading dead arm, and PINS the previously-unpinned null case (the icon-fix
guard's standing advisory). The sibling cwd field keeps its own "— (not served)" (a legitimately
servable value). RED-first: agent-detail-runtime-unknown.test.ts RED before the repoint (renders
'— (not served)'), GREEN after; render/icon/topology integration 51/51, tui tsc 0.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
v-openrig-buildandClaude Opus 4.8 committed 2026-08-05 03:52:03 +00:00
1 parent 584740b422
commit bdc304122f
2 files changed
+42 -1

No files matched your search

+5 -1
View File
@@ -222,7 +222,11 @@ function contentLines(state: ViewState, snap: FleetSnapshot, contentWidth: numbe
// the seg channel (ROUND-4: colors/background survive stylization) but only
// ACCOMPANY the name decoratively, never substitute. Topology cards remain
// mark-only by space (layout.ts/hatchet.ts) — the ruling is bounded, not reversed.
const rtName = agent.runtime ?? "— (not served)";
// LEG-7 LOW 2 (dead-arm cleanup, wave qitem 79159e6f): the daemon coerces a null runtime to the
// string "unknown" BEFORE the wire (the icon-fix QA at 5a70e200 proved the old "— (not served)"
// arm unreachable), so the defensive fallback matches that coercion — honest, never a misleading
// placeholder. (The cwd field below keeps its own "— (not served)" — a legitimately-servable value.)
const rtName = agent.runtime ?? "unknown";
const rtSegs = [
{ text: " " },
{ text: "runtime:", token: "dim" as const },
@@ -0,0 +1,37 @@
// LEG-7 LOW 2 — dead-arm cleanup (fold-wave qitem 79159e6f). The icon-fix QA (5a70e200, review50-r1)
// found the agent-detail runtime field's `?? "— (not served)"` placeholder is UNREACHABLE via the
// production API: the daemon coerces a null runtime to the string "unknown" BEFORE it crosses the wire
// (whoami-service.ts and siblings), so render.ts never sees a null runtime. Repoint the defensive
// fallback to "unknown" to MATCH that coercion — honest (what actually renders), kills the misleading
// dead "— (not served)" arm, and PINS the previously-unpinned null-runtime case (the icon-fix guard's
// standing advisory).
import { describe, expect, it } from "vitest";
import { demoSnapshot } from "../src/demo-data.js";
import { renderScreen } from "../src/render.js";
import { createViewState } from "../src/state.js";
import type { FleetSnapshot } from "../src/types.js";
describe("agent-detail runtime fallback = daemon-consistent `unknown`, never the dead `— (not served)` (LEG-7 LOW 2)", () => {
it("an agent whose runtime is absent renders `runtime: unknown` — never `— (not served)`", () => {
const snap = structuredClone(demoSnapshot()) as FleetSnapshot;
// Force the absent-runtime case the type forbids but the defensive arm handles (the daemon would
// have already coerced it to "unknown"; here we drive the render layer directly).
const agent = snap.hosts[0]!.rigs[0]!.pods[0]!.agents[0]!;
(agent as { runtime?: string }).runtime = undefined;
const view = createViewState({ instanceId: "t", getSnapshot: () => snap });
view.dispatch({
type: "drill",
resource: "agent",
name: agent.name,
target: { host: "vm-host", rig: "openrig-build", pod: "dev50" },
});
const lines = renderScreen(view.get(), snap, { cols: 140, rows: 34 }).lines;
// Scope to the RUNTIME line only — the sibling `cwd:` field legitimately renders "— (not served)"
// for an absent working directory (a different, honest use of the placeholder we do NOT touch).
const runtimeLine = lines.find((l) => l.includes("runtime:"))!;
expect(runtimeLine).toMatch(/runtime:\s+unknown/); // matches the daemon's null→"unknown" coercion
expect(runtimeLine).not.toContain("— (not served)"); // the misleading dead RUNTIME placeholder is gone
});
});