Python
fix(observability): the default coworker is Coworker everywhere (T3-15 e)
Devika Verma9146125a5e54
diff --git a/surfaces/gui/src/components/PersonasTab.test.tsx b/surfaces/gui/src/components/PersonasTab.test.tsxindex f7c31eae..3a7d472f 100644--- a/surfaces/gui/src/components/PersonasTab.test.tsx+++ b/surfaces/gui/src/components/PersonasTab.test.tsx@@ -26,6 +26,10 @@ describe("PersonasTab", () => {render(<PersonasTab onOpenPersona={open} />);await waitFor(() => expect(screen.getByTestId("persona-open-cowork")).toBeTruthy());expect(screen.getByTestId("persona-default-tag")).toBeTruthy();+ // T3-15 (e): the default coworker is "Coworker (default)" here, not the backend's "OpenWorker"+ expect(screen.getByTestId("persona-open-cowork").textContent).toContain("Coworker (default)");+ expect(screen.getByTestId("persona-open-cowork").textContent).not.toContain("OpenWorker");+ expect(screen.getByTestId("persona-open-sec").textContent).toContain("Security Coworker");fireEvent.click(screen.getByTestId("persona-open-cowork"));expect(open).toHaveBeenCalledWith("cowork");fireEvent.click(screen.getByTestId("persona-open-sec"));diff --git a/surfaces/gui/src/components/PersonasTab.tsx b/surfaces/gui/src/components/PersonasTab.tsxindex 34bc614a..120e9046 100644--- a/surfaces/gui/src/components/PersonasTab.tsx+++ b/surfaces/gui/src/components/PersonasTab.tsx@@ -16,6 +16,7 @@ import { chooseFolder } from "../tauri";import type { SessionInfo } from "../types";import { Icon } from "./Icon";import { Toggle } from "./Toggle";+import { listPersonaName } from "../personaScope";// Personas management (UX-035): grouped General/Security lists with ONE toggle per row// (enable implies picker); in-picker nuance, set-default, export and delete live on the@@ -172,16 +173,16 @@ export function PersonasTab({{onOpenPersona ? (<buttonclassName="min-w-0 flex-1 text-left cursor-pointer group"- title={t("personas.open_title", { name: p.name })}+ title={t("personas.open_title", { name: listPersonaName(p.name, p.id, t) })}data-testid={`persona-open-${p.id}`}onClick={() => onOpenPersona(p.id)}>- <div className="text-body font-medium truncate group-hover:underline">{p.name}</div>+ <div className="text-body font-medium truncate group-hover:underline">{listPersonaName(p.name, p.id, t)}</div><div className="text-meta text-faint truncate mt-0.5">{p.tagline}</div></button>) : (<div className="min-w-0 flex-1">- <div className="text-body font-medium truncate">{p.name}</div>+ <div className="text-body font-medium truncate">{listPersonaName(p.name, p.id, t)}</div><div className="text-meta text-faint truncate mt-0.5">{p.tagline}</div></div>)}diff --git a/surfaces/gui/src/components/UsagePage.test.tsx b/surfaces/gui/src/components/UsagePage.test.tsxindex 514341ec..84c5ac18 100644--- a/surfaces/gui/src/components/UsagePage.test.tsx+++ b/surfaces/gui/src/components/UsagePage.test.tsx@@ -106,6 +106,14 @@ describe("UsageBody", () => {expect(screen.queryByTestId("usage-coworkers-all")).toBeNull();});+ it("names the default coworker Coworker (default) in By coworker and Heaviest turns (T3-15 e)", () => {+ const d = data({ total: { ...data().total, names: { cowork: "OpenWorker" } } });+ render(<UsageBody data={{ ...d, coworkers: { ...d.coworkers, names: { cowork: "OpenWorker" } } }} period="7d" t={t} />);+ expect(screen.getByTestId("usage-coworkers").textContent).toContain("Coworker (default)");+ expect(screen.getByTestId("usage-coworkers").textContent).not.toContain("OpenWorker");+ expect(screen.getByTestId("usage-heaviest").textContent).toContain("Coworker (default)");+ });+it("with a coworker picked, says By coworker still lists them all (T3-11)", () => {render(<UsageBody data={data()} period="7d" t={t} picked />);expect(screen.getByTestId("usage-coworkers-all").textContent).toBe("All coworkers, for comparison");@@ -175,7 +183,8 @@ describe("one coworker", () => {const r = rollup([group({ persona_id: "sec", task_id: null }, 5), group({ persona_id: "sec", task_id: "t1" }, 1),group({ persona_id: "cowork", task_id: null }, 3), group({ persona_id: null, task_id: null }, 1)],{ names: { sec: "Security Coworker", cowork: "OpenWorker" } });- expect(coworkerChoices(r)).toEqual([{ id: "cowork", name: "OpenWorker" }, { id: "sec", name: "Security Coworker" }]);+ // T3-15 (e): the default coworker is "Coworker (default)" in the picker+ expect(coworkerChoices(r, t)).toEqual([{ id: "cowork", name: "Coworker (default)" }, { id: "sec", name: "Security Coworker" }]);});it("narrows every call but the coworker list to the picked coworker", async () => {diff --git a/surfaces/gui/src/components/UsagePage.tsx b/surfaces/gui/src/components/UsagePage.tsxindex 43ebc0f2..f8ea0220 100644--- a/surfaces/gui/src/components/UsagePage.tsx+++ b/surfaces/gui/src/components/UsagePage.tsx@@ -18,6 +18,7 @@ import {type UsageRollup,} from "../api";import { formatTokens } from "../usage";+import { listPersonaName } from "../personaScope";import { formatDuration } from "./StepsPanel";import {approverPart,@@ -58,9 +59,18 @@ export interface UsageData {ratings?: RatingsSummary | null;}+/** The coworker names as shown on the page: the server's names, the default coworker's as+ * "Coworker (default)" (T3-15 e). The default coworker has an entry even without a name. */+export function shownNames(names: Record<string, string>, t: T): Record<string, string> {+ const out: Record<string, string> = {};+ for (const [id, name] of Object.entries(names)) out[id] = listPersonaName(name, id, t);+ out.cowork = listPersonaName(names.cowork, "cowork", t);+ return out;+}+/** The coworkers of the period for the picker: each id once, by its name (M3-R1), A to Z. */-export function coworkerChoices(r: UsageRollup | null | undefined): { id: string; name: string }[] {- const names = r?.names || {};+export function coworkerChoices(r: UsageRollup | null | undefined, t: T): { id: string; name: string }[] {+ const names = shownNames(r?.names || {}, t);const ids = new Set<string>();for (const g of r?.groups || []) {const id = g.key.persona_id as string | null;@@ -134,7 +144,7 @@ export function UsagePage({ onOpenTurn, onOpenPersona }: {live = false;};}, [period, persona]);- const choices = data ? coworkerChoices(data.coworkers) : [];+ const choices = data ? coworkerChoices(data.coworkers, t) : [];return (<div data-testid="usage-page">@@ -185,7 +195,8 @@ export function UsageBody({ data, period, t, onOpenTurn, onOpenPersona, picked =const pct = canCompare && prev ? changePct(all?.total ?? 0, prev.total) : null;const chart = purposeByDay(days, data.dayPurpose.groups);const overhead = overheadByDay(chart);- const names = data.total.names || data.coworkers.names || {};+ // T3-15 (e): the default coworker is "Coworker (default)" in every list on the page+ const names = shownNames({ ...(data.coworkers.names || {}), ...(data.total.names || {}) }, t);const turns = all?.turns ?? 0;const checked = all?.checked ?? 0;const withWarn = all?.with_warn ?? 0;diff --git a/surfaces/gui/src/locales/en.json b/surfaces/gui/src/locales/en.jsonindex 79b6c711..3ab43d8c 100644--- a/surfaces/gui/src/locales/en.json+++ b/surfaces/gui/src/locales/en.json@@ -1570,6 +1570,7 @@"builtin": "· built-in","configure_title": "Configure {{name}}","open_title": "Open {{name}}: its settings and how it's been doing",+ "default_in_list": "Coworker (default)","connectors_tag": "connectors","default_for_new": "Default for new sessions","delete": "Delete",diff --git a/surfaces/gui/src/locales/zh.json b/surfaces/gui/src/locales/zh.jsonindex 9db06940..8e41876d 100644--- a/surfaces/gui/src/locales/zh.json+++ b/surfaces/gui/src/locales/zh.json@@ -1549,6 +1549,7 @@"builtin": "· 内置","configure_title": "配置 {{name}}","open_title": "打开 {{name}}:设置和表现如何",+ "default_in_list": "Coworker(默认)","connectors_tag": "连接器","default_for_new": "新会话默认角色","delete": "删除",diff --git a/surfaces/gui/src/personaScope.ts b/surfaces/gui/src/personaScope.tsindex ba83f9a6..07f3abaf 100644--- a/surfaces/gui/src/personaScope.ts+++ b/surfaces/gui/src/personaScope.ts@@ -11,6 +11,18 @@ export function isProjectScoped(p?: { requires_folder?: boolean }): boolean {// Ops); the persona detail page uses the FULL family name. Backend names are left untouched (the// API + tests keep "OpenWorker" / "Ops Coworker"); this is purely the display layer.+/** The default coworker's id. Its backend name is "OpenWorker"; on screen it is "Coworker". */+export const DEFAULT_PERSONA_ID = "cowork";++/** A coworker's name where coworkers are listed side by side (Settings ▸ Coworkers, Usage's+ * tables, its picker, Ratings): the default one is "Coworker (default)", as "Coworker" alone+ * reads like the column's heading there; every other coworker keeps its own name (T3-15 e). */+export function listPersonaName(name: string | null | undefined, id: string | null | undefined,+ t: (k: string) => string): string {+ if (id === DEFAULT_PERSONA_ID) return t("personas.default_in_list");+ return (name || id || "").trim();+}+// Short label for the sidebar + top bar: "Coworker" / "Code" / "Ops" / "Chat".export function shortPersonaName(name?: string, id?: string): string {if (id === "cowork") return "Coworker";