Python
fix(observability): Heaviest turns stays inside its card (T3-5)
Devika Verma3c4407cd0821
diff --git a/surfaces/gui/src/components/UsagePage.test.tsx b/surfaces/gui/src/components/UsagePage.test.tsxindex 09ed2527..f77aa23b 100644--- a/surfaces/gui/src/components/UsagePage.test.tsx+++ b/surfaces/gui/src/components/UsagePage.test.tsx@@ -69,6 +69,21 @@ describe("UsageBody", () => {expect(open).toHaveBeenCalledWith("s1", "t5");});+ it("keeps the heaviest turns inside the card: fixed columns, +N for more badges, full names on hover (T3-5)", () => {+ const long = "openrouter:some-lab/a-very-long-model-name-v4-pro";+ const heavy = [{ ...data().heavy[0], model_ids: [long], checks: ["bad_tool_call", "tool_failed", "slow_tool"] }];+ render(<UsageBody data={data({ heavy })} period="7d" t={t} onOpenTurn={() => {}} />);+ const table = screen.getByTestId("usage-heaviest");+ expect(table.className).toContain("p3-heavy");+ expect(table.querySelectorAll("col")).toHaveLength(7);+ expect(screen.getByTestId("usage-heavy-model").getAttribute("title")).toBe(long);+ const issues = screen.getByTestId("usage-heavy-issues");+ expect(issues.querySelectorAll(".steps-badge")).toHaveLength(2);+ expect(issues.textContent).toContain("+2");+ expect(issues.getAttribute("title")).toContain("A tool failed");+ expect(screen.getByTestId("usage-open-steps").textContent).toBe("Trace");+ });+it("lists machines, an offline one by its cached answer's time", () => {render(<UsageBody data={data()} period="7d" t={t} />);const m = screen.getByTestId("usage-machines").textContent || "";diff --git a/surfaces/gui/src/components/UsagePage.tsx b/surfaces/gui/src/components/UsagePage.tsxindex c6fd3a9d..e00daf01 100644--- a/surfaces/gui/src/components/UsagePage.tsx+++ b/surfaces/gui/src/components/UsagePage.tsx@@ -248,24 +248,43 @@ export function UsageBody({ data, period, t, onOpenTurn }: { data: UsageData; pe{data.heavy.length === 0 ? (<div className="text-meta text-faint mt-1">{t("p3.usage.no_turns")}</div>) : (- <table className="p3-t" data-testid="usage-heaviest">+ // T3-5: fixed column widths, so long titles, model names and badges are cut inside+ // their cell (full text on hover) and the table never grows past its card.+ <table className="p3-t p3-heavy" data-testid="usage-heaviest">+ <colgroup>+ <col style={{ width: "27%" }} /><col style={{ width: "14%" }} /><col style={{ width: "18%" }} />+ <col style={{ width: "9%" }} /><col style={{ width: "9%" }} /><col style={{ width: "16%" }} /><col style={{ width: "7%" }} />+ </colgroup><thead><tr><th>{t("p3.usage.session")}</th><th>{t("p3.usage.coworker")}</th><th>{t("p3.usage.model")}</th><th className="n">{t("p3.usage.tokens")}</th><th className="n">{t("p3.usage.active_time")}</th><th>{t("p3.usage.issues")}</th><th></th></tr></thead><tbody>- {data.heavy.map((h) => (+ {data.heavy.map((h) => {+ const title = h.session_deleted ? t("p3.usage.deleted_session") : (h.title || h.session_id);+ const turn = h.seq != null ? t("p3.usage.turn_n", { n: h.seq }) : "";+ const who = (h.persona_id && names[h.persona_id]) || h.persona_id || "—";+ const models = h.model_ids.join(", ") || "—";+ const issues = h.checks.map((c) => t(`steps.issues.title.${c}`, { defaultValue: c }));+ return (<tr key={h.turn_id}>- <td className="p3-trunc">{h.session_deleted ? <span className="text-faint">{t("p3.usage.deleted_session")}</span> : (h.title || h.session_id)}- {h.seq != null && <span className="text-faint"> · {t("p3.usage.turn_n", { n: h.seq })}</span>}</td>- <td>{(h.persona_id && names[h.persona_id]) || h.persona_id || "—"}</td>- <td className="font-mono">{h.model_ids.join(", ") || "—"}</td>+ <td><span className="p3-cut" title={turn ? `${title} · ${turn}` : title}>+ {h.session_deleted ? <span className="text-faint">{title}</span> : title}+ {turn && <span className="text-faint"> · {turn}</span>}</span></td>+ <td><span className="p3-cut" title={who}>{who}</span></td>+ <td><span className="p3-cut font-mono" title={models} data-testid="usage-heavy-model">{models}</span></td><td className="n">{(h.at_least ? "≥ " : "") + formatTokens(h.total)}</td><td className="n">{h.found_open ? <span className="text-faint">{t("p3.usage.found_open")}</span> : formatDuration(h.active_ms)}</td>- <td>{h.checks.map((c) => <span key={c} className="steps-badge warn mr-1">{t(`steps.issues.title.${c}`, { defaultValue: c })}</span>)}</td>+ <td>{issues.length > 0 && (+ <span className="p3-badges" title={issues.join(", ")} data-testid="usage-heavy-issues">+ <span className="steps-badge warn">{issues[0]}</span>+ {issues.length > 1 && <span className="steps-badge warn">+{issues.length - 1}</span>}+ </span>+ )}</td><td>{!h.session_deleted && onOpenTurn && (<button className="p3-link" data-testid="usage-open-steps" onClick={() => onOpenTurn(h.session_id, h.turn_id)}>{t("steps.open")}</button>)}</td></tr>- ))}+ );+ })}</tbody></table>)}diff --git a/surfaces/gui/src/styles.css b/surfaces/gui/src/styles.cssindex 7c032c75..7381c4aa 100644--- a/surfaces/gui/src/styles.css+++ b/surfaces/gui/src/styles.css@@ -2638,6 +2638,13 @@ html[data-theme="dark"] { --bar-model:#4c8dff; --bar-tool:#3fb8ad; --bar-wait:#3.p3-t td { padding:5px 6px; border-bottom:1px solid var(--line); color:var(--ink); vertical-align:top; }.p3-t tr:last-child td { border-bottom:0; }.p3-t .n { text-align:right; font-variant-numeric:tabular-nums; white-space:nowrap; }+/* T3-5: Heaviest turns stays inside its card: fixed columns, text cut with the full text on hover */+.p3-heavy { table-layout:fixed; }+.p3-heavy td { overflow:hidden; }+.p3-cut { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }+.p3-badges { display:flex; flex-wrap:nowrap; gap:3px; min-width:0; }+.p3-badges .steps-badge:first-child { flex:0 1 auto; }+.p3-badges .steps-badge + .steps-badge { flex:0 0 auto; }.p3-trunc { max-width:260px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }.p3-link { color:var(--accent); background:none; border:0; padding:0; cursor:pointer; font-size:inherit; }.p3-link:hover { text-decoration:underline; }