Python
fix(observability): How it's been doing reads for a person (T3-15)
Devika Vermae609534dedf5
diff --git a/coworker/observability/store.py b/coworker/observability/store.pyindex 6826d93c..aa9f85ba 100644--- a/coworker/observability/store.py+++ b/coworker/observability/store.py@@ -872,6 +872,9 @@ class RecordingStore:d = out[r["turn_id"]] = {k: r[k] for k in r.keys() if k not in ("purpose", "model", "first")}d["warn_checks"] = json.loads(d["warn_checks"] or "[]")d["total"], d["models"], d["by_purpose"] = 0, [], {}+ # T3-15: the models of the coworker's own work (main and helpers), without the+ # auto-approver's, the title's or the summary's+ d["own_models"] = []for k in self._SUMMED:d[k] = 0for k in self._SUMMED:@@ -882,6 +885,9 @@ class RecordingStore:d["by_purpose"][r["purpose"]] = d["by_purpose"].get(r["purpose"], 0) + totif r["model"] and r["model"] not in d["models"] and (r["calls"] or r["unreported"]):d["models"].append(r["model"])+ if (r["model"] and r["purpose"] in ("main", "helper") and r["model"] not in d["own_models"]+ and (r["calls"] or r["unreported"])):+ d["own_models"].append(r["model"])for d in out.values():d["at_least"] = d["unreported"] > 0d["active_ms"] = None if d["duration_ms"] is None else d["duration_ms"] - (d["waiting_ms"] or 0)diff --git a/coworker/observability/usage_api.py b/coworker/observability/usage_api.pyindex 6add2259..44de79de 100644--- a/coworker/observability/usage_api.py+++ b/coworker/observability/usage_api.py@@ -177,7 +177,7 @@ def persona_doing(store: Any, persona_id: str, *, start: int, end: int, current_Usage page. Fewer than `min_runs` runs: no medians, "too few runs to compare"."""turns = store.usage_turns(start, end, where={"persona_id": persona_id})kept_from = store.usage_kept_from()- models_of_turn = {t["turn_id"]: t["models"] for t in turns}+ models_of_turn = {t["turn_id"]: t.get("own_models", t["models"]) for t in turns}runs: dict[tuple, dict[str, Any]] = {}for t in turns:k = (t["persona_fp"], t["session_id"])@@ -220,12 +220,19 @@ def persona_doing(store: Any, persona_id: str, *, start: int, end: int, current_changes = {}for prev, cur in zip(ordered, ordered[1:]):changes[cur["fp"]] = {"from": prev["fp"], **diff_versions(prev, cur, store)}+ number = {v["fp"]: i + 1 for i, v in enumerate(ordered)}for row in out:row["changed"] = changes.get(row["fp"])+ # T3-15: "v1 · current": versions numbered oldest first, by first sighting+ row["version_n"] = number.get(row["fp"])# model line: "model unchanged", "model changed: a -> b", or several modelsfor i, row in enumerate(out):older = out[i + 1] if i + 1 < len(out) else None- if len(row["models"]) > 1:+ # T3-15: a first version has nothing to compare a model with (it says only that it is+ # the first); the models are listed on their own line either way+ if not row.get("changed"):+ row["model_line"] = {"kind": "first", "models": row["models"]}+ elif len(row["models"]) > 1:row["model_line"] = {"kind": "several", "models": row["models"]}elif older is not None and row["models"] and older["models"] and row["models"] != older["models"]:row["model_line"] = {"kind": "changed", "from": older["models"][-1], "to": row["models"][0]}diff --git a/coworker/server/manager.py b/coworker/server/manager.pyindex 0418cd2a..87f725cf 100644--- a/coworker/server/manager.py+++ b/coworker/server/manager.py@@ -7043,12 +7043,15 @@ class SessionManager:def current_persona_fp(self, persona_id: str) -> Optional[str]:"""The coworker's fingerprint now, worked out as the session build does (E16)."""entry = self.personas.get(persona_id)- manifest = entry.manifest if entry else None- if manifest is None:+ if entry is None:return Nonetry:+ # T3-15 (d): from the built agent, as the session does (agent.py). A coworker built+ # in code (the default, OpenWorker) has no manifest, so reading the manifest's+ # prompt gave it no current version at all.+ agent = entry.agent()skill_dir = self.persona_skill_scope(persona_id)[0]- return _obs_stamps.persona_fingerprint(persona_id, manifest.system_prompt,+ return _obs_stamps.persona_fingerprint(agent.name, agent.system_prompt,[skill_dir] if skill_dir is not None else [])except Exception: # noqa: BLE001return Nonediff --git a/surfaces/gui/src/api.ts b/surfaces/gui/src/api.tsindex 342bea90..07bcabd9 100644--- a/surfaces/gui/src/api.ts+++ b/surfaces/gui/src/api.ts@@ -4830,7 +4830,9 @@ export interface DoingRow {too_few: boolean;models: string[];changed: { from: string; files: VersionFileChange[] } | null;- model_line?: { kind: "unchanged" | "changed" | "several"; models?: string[]; from?: string; to?: string };+ model_line?: { kind: "first" | "unchanged" | "changed" | "several"; models?: string[]; from?: string; to?: string };+ /** T3-15: the version's number, oldest first ("v1") */+ version_n?: number | null;}export interface PersonaDoing {persona_id: string;diff --git a/surfaces/gui/src/components/PersonaDoing.test.tsx b/surfaces/gui/src/components/PersonaDoing.test.tsxindex f23f1cbf..b112d7c9 100644--- a/surfaces/gui/src/components/PersonaDoing.test.tsx+++ b/surfaces/gui/src/components/PersonaDoing.test.tsx@@ -1,8 +1,11 @@-// OB-15: "How it's been doing" on the coworker page (technical-design.md §9).+// OB-15: "How it's been doing" on the coworker page (technical-design.md §9), in the words of+// T3-15: versions numbered, sessions, typical numbers, one note across both, and the models used+// on their own line.import { afterEach, describe, expect, it, vi } from "vitest";import { cleanup, render, screen, waitFor } from "@testing-library/react";import i18n from "i18next";import type { DoingRow } from "../api";+import { inUseSpan } from "../obs3";vi.mock("../api", () => ({getPersonaDoing: vi.fn(),@@ -17,16 +20,17 @@ afterEach(() => {vi.clearAllMocks();});const t = i18n.t.bind(i18n) as any;+const day = (ms: number) => new Date(ms).toLocaleDateString(undefined, { month: "short", day: "numeric" });const row = (over: Partial<DoingRow> = {}): DoingRow => ({- fp: "9f3a21", current: true, unknown_version: false, first_seen: Date.UTC(2026, 9, 21), last_seen: Date.UTC(2026, 10, 4),+ fp: "9f3a21", current: true, unknown_version: false, first_seen: Date.UTC(2026, 9, 21, 12), last_seen: Date.UTC(2026, 10, 4, 12),before_kept: false, runs: 15, automation_runs: 0, turns: 30, checked: 27, with_warn: 7, not_checked: 3,median_tokens: 192_000, at_least: false, approvals_per_run: 0, up: 0, down: 0, too_few: false, models: ["model-x"],- changed: null, model_line: { kind: "unchanged", models: ["model-x"] }, ...over,+ changed: null, model_line: { kind: "first", models: ["model-x"] }, version_n: 2, ...over,});describe("changedLine", () => {- it("names a skill's version change and the instructions' line change, and the model", () => {+ it("names a skill's version change, the instructions' line change and a model change", () => {const r = row({changed: { from: "7c10e4", files: [{ path: "manifest.md", kind: "edited", lines: 4 },@@ -35,28 +39,70 @@ describe("changedLine", () => {model_line: { kind: "changed", from: "model-x", to: "model-y" },});expect(changedLine(r, t)).toBe("instructions edited (+4 lines) · skill semgrep-scan 1.1 → 1.2 · model changed: model-x → model-y");- expect(changedLine(row(), t)).toBe("the first version seen on this machine · model unchanged");+ });++ it("a first version says only that, never 'model unchanged' (T3-15 b, f)", () => {+ expect(changedLine(row(), t)).toBe("First version seen on this machine.");+ });+});++describe("in use (T3-15 c, g)", () => {+ const now = new Date(2026, 10, 5, 15);+ it("one day is one date; today says today; the oldest kept day says 'or earlier'", () => {+ const nov2 = new Date(2026, 10, 2, 9).getTime();+ expect(inUseSpan(nov2, new Date(2026, 10, 2, 18).getTime(), false, t, now)).toBe(day(nov2));+ const nov3 = new Date(2026, 10, 3, 9).getTime();+ expect(inUseSpan(nov3, now.getTime(), false, t, now)).toBe(`${day(nov3)} – today`);+ expect(inUseSpan(nov3, now.getTime(), true, t, now)).toBe(`${day(nov3)} or earlier – today`);+ expect(inUseSpan(null, null, false, t, now)).toBe("—");});});describe("PersonaDoing", () => {- it("one row per version: 'too few runs', 'before' the oldest kept day, and no ratings as — / —", async () => {+ it("names versions v1 · current, says sessions, and one 'too few' note across both typical columns", async () => {(getPersonaDoing as any).mockResolvedValue({persona_id: "security", kept_from: Date.UTC(2026, 9, 6), min_runs: 10, total: 1, runs: 18,- rows: [row(), row({ fp: "7c10e4", current: false, runs: 3, too_few: true, median_tokens: null, before_kept: true, up: 2, down: 1 })],+ rows: [+ row({ changed: { from: "7c10e4", files: [] }, model_line: { kind: "unchanged", models: ["model-x"] } }),+ row({ fp: "7c10e4", current: false, runs: 3, too_few: true, median_tokens: null, before_kept: true, up: 2, down: 1, version_n: 1 }),+ ],});render(<PersonaDoing personaId="security" />);await waitFor(() => expect(screen.getAllByTestId("persona-doing-row")).toHaveLength(2));- const [a, b] = screen.getAllByTestId("persona-doing-row").map((r) => r.textContent || "");- expect(a).toContain("ⓕ9f3a21");- expect(a).toContain("current");- expect(a).toContain("192k");- expect(a).toContain("26%");- expect(a).toContain("— / —");- expect(b).toContain("too few runs to compare");- expect(b).toContain("before");- expect(b).toContain("2 / 1");- expect((screen.getByTestId("persona-doing-diff") as HTMLButtonElement).disabled).toBe(true);+ const head = screen.getByRole("table").querySelector("thead")!.textContent || "";+ for (const h of ["Sessions", "Typical tokens per session", "Approvals asked per session", "Turns with issues", "Ratings 👍 / 👎"]) expect(head).toContain(h);+ const [a, b] = screen.getAllByTestId("persona-doing-row");+ const [va, vb] = screen.getAllByTestId("persona-doing-version");+ expect(va.textContent).toBe("v2 · current");+ expect(va.getAttribute("title")).toBe("Fingerprint ⓕ9f3a21");+ expect(vb.textContent).toBe("v1");+ expect(a.textContent).toContain("192k");+ expect(a.textContent).toContain("26%");+ expect(a.textContent).toContain("— / —");+ const tooFew = screen.getByTestId("persona-doing-too-few");+ expect(tooFew.textContent).toBe("too few sessions to compare");+ expect(tooFew.getAttribute("colspan")).toBe("2");+ expect(b.textContent).toContain("or earlier");+ expect(b.textContent).toContain("2 / 1");+ // a later version can be compared+ expect(screen.getByTestId("persona-doing-diff").textContent).toBe("Show diff");+ });++ it("a first version: no Show diff, 'Nothing to compare yet', and the models used on their own line", async () => {+ const models = ["gpt-5.6-sol", "model-a", "model-b"];+ (getPersonaDoing as any).mockResolvedValue({+ persona_id: "cowork", kept_from: null, min_runs: 10, total: 1, runs: 1,+ rows: [row({ version_n: 1, model_line: { kind: "first", models }, models })],+ });+ render(<PersonaDoing personaId="cowork" />);+ await waitFor(() => expect(screen.getByTestId("persona-doing-changed")).toBeTruthy());+ expect(screen.queryByTestId("persona-doing-diff")).toBeNull();+ expect(screen.getByTestId("persona-doing-nothing-to-compare").textContent).toBe("Nothing to compare yet");+ expect(screen.getByTestId("persona-doing-changed").textContent).toContain("First version seen on this machine.");+ expect(screen.getByTestId("persona-doing-changed").textContent).not.toContain("unchanged");+ const line = screen.getByTestId("persona-doing-models");+ expect(line.textContent).toBe("Models used: gpt-5.6-sol and 2 more");+ expect(line.getAttribute("title")).toBe("gpt-5.6-sol, model-a, model-b");});it("renders nothing when the engine has no such endpoint", async () => {diff --git a/surfaces/gui/src/components/PersonaDoing.tsx b/surfaces/gui/src/components/PersonaDoing.tsxindex dc9304be..31794ade 100644--- a/surfaces/gui/src/components/PersonaDoing.tsx+++ b/surfaces/gui/src/components/PersonaDoing.tsx@@ -8,7 +8,7 @@ import { useEffect, useState } from "react";import { useTranslation } from "react-i18next";import { getPersonaDoing, getPersonaVersionDiff, type DoingRow, type PersonaDoing as Doing, type VersionFileChange } from "../api";import { formatTokens } from "../usage";-import { shortDate } from "../obs3";+import { inUseSpan } from "../obs3";type T = (k: string, o?: any) => string;@@ -33,6 +33,7 @@ export function PersonaDoing({ personaId, machineId, secClass, scrollIntoView }:if (el && scrollIntoView && typeof el.scrollIntoView === "function") el.scrollIntoView({ block: "start" });};const newest = doing.rows[0];+ const models = newest?.model_line?.models || newest?.models || [];return (<section data-testid="persona-doing" ref={reveal}><div className={`${secClass || ""} mb-1.5`}>{t("p3.doing.title")}</div>@@ -45,11 +46,11 @@ export function PersonaDoing({ personaId, machineId, secClass, scrollIntoView }:<tr><th>{t("p3.doing.version")}</th><th>{t("p3.doing.in_use")}</th>- <th className="n">{t("p3.doing.runs")}</th>- <th className="n">{t("p3.doing.median_tokens")}</th>- <th className="n">{t("p3.doing.with_issues")}</th>+ <th className="n">{t("p3.doing.sessions")}</th>+ <th className="n" title={t("p3.doing.typical_tokens_title")}>{t("p3.doing.typical_tokens")}</th><th className="n">{t("p3.doing.approvals")}</th>- <th className="n">👍 / 👎</th>+ <th className="n">{t("p3.doing.with_issues")}</th>+ <th className="n">{t("p3.doing.ratings")}</th></tr></thead><tbody>@@ -64,20 +65,32 @@ export function PersonaDoing({ personaId, machineId, secClass, scrollIntoView }:<div className="flex-1 min-w-0"><b className="font-medium">{t("p3.doing.what_changed", { fp: newest.fp ?? "—" })}</b>{" "}<span className="text-muted">{changedLine(newest, t)}</span>+ {models.length > 0 && (+ <div className="text-muted mt-0.5" title={models.join(", ")} data-testid="persona-doing-models">+ {models.length === 1+ ? t("p3.doing.models_used_one", { model: models[0] })+ : t("p3.doing.models_used_more", { model: models[0], count: models.length - 1 })}+ </div>+ )}</div>- <button- className="text-meta px-2.5 py-1 rounded-lg border border-line"- disabled={!newest.changed || !newest.fp}- data-testid="persona-doing-diff"- onClick={async () => {- if (!newest.changed || !newest.fp) return;- if (diff?.fp === newest.fp) return setDiff(null);- const d = await getPersonaVersionDiff(personaId, newest.changed.from, newest.fp, machineId).catch(() => null);- if (d && !d.error) setDiff({ fp: newest.fp, files: d.files || [] });- }}- >- {diff ? t("p3.doing.hide_diff") : t("p3.doing.show_diff")}- </button>+ {/* T3-15 (a): a first version has nothing to compare with, so no button that looks+ clickable and does nothing */}+ {newest.changed && newest.fp ? (+ <button+ className="text-meta px-2.5 py-1 rounded-lg border border-line"+ data-testid="persona-doing-diff"+ onClick={async () => {+ if (!newest.changed || !newest.fp) return;+ if (diff?.fp === newest.fp) return setDiff(null);+ const d = await getPersonaVersionDiff(personaId, newest.changed.from, newest.fp, machineId).catch(() => null);+ if (d && !d.error) setDiff({ fp: newest.fp, files: d.files || [] });+ }}+ >+ {diff ? t("p3.doing.hide_diff") : t("p3.doing.show_diff")}+ </button>+ ) : (+ <span className="text-faint" data-testid="persona-doing-nothing-to-compare">{t("p3.doing.nothing_to_compare")}</span>+ )}</div>)}{diff && (@@ -97,32 +110,38 @@ export function PersonaDoing({ personaId, machineId, secClass, scrollIntoView }:}function DoingTr({ r, t }: { r: DoingRow; t: T }) {- const from = r.first_seen != null ? shortDate(r.first_seen) : "—";- const to = r.last_seen != null ? shortDate(r.last_seen) : "—";+ const version = r.unknown_version ? t("p3.doing.unknown_version")+ : r.version_n ? t("p3.doing.version_n", { n: r.version_n }) : `ⓕ${r.fp}`;return (<tr data-testid="persona-doing-row"><td>- <span className="font-mono">{r.unknown_version ? t("p3.doing.unknown_version") : `ⓕ${r.fp}`}</span>- {r.current && <span className="p3-chip ok ml-1.5">{t("p3.doing.current")}</span>}+ <span title={r.fp ? t("p3.doing.fingerprint", { fp: r.fp }) : undefined} data-testid="persona-doing-version">+ {version}+ {r.current && <span className="text-ok"> · {t("p3.doing.current")}</span>}+ </span></td>- <td>{r.before_kept ? t("p3.doing.before", { date: to }) : `${from} – ${to}`}</td>+ <td className="whitespace-nowrap">{inUseSpan(r.first_seen, r.last_seen, r.before_kept, t)}</td><td className="n">{r.runs}{r.automation_runs > 0 && <span className="text-faint"> {t("p3.doing.automation_runs", { count: r.automation_runs })}</span>}</td>{r.too_few ? (- <td className="n text-faint" colSpan={1}>{t("p3.doing.too_few")}</td>+ // T3-15 (h): one note across both typical-number columns+ <td className="n text-faint" colSpan={2} data-testid="persona-doing-too-few">{t("p3.doing.too_few")}</td>) : (- <td className="n">{(r.at_least ? "≥ " : "") + formatTokens(r.median_tokens ?? 0)}</td>+ <>+ <td className="n">{(r.at_least ? "≥ " : "") + formatTokens(r.median_tokens ?? 0)}</td>+ <td className="n">{r.approvals_per_run == null ? "—" : r.approvals_per_run.toFixed(1)}</td>+ </>)}<td className="n">{r.checked ? `${Math.round((r.with_warn / r.checked) * 100)}%` : "—"}</td>- <td className="n">{r.approvals_per_run == null ? "—" : r.approvals_per_run.toFixed(1)}</td><td className="n">{r.up || r.down ? `${r.up} / ${r.down}` : "— / —"}</td></tr>);}-/** "skill semgrep-scan 1.1 → 1.2 · instructions edited (+4 lines) · model unchanged". */+/** "skill semgrep-scan 1.1 → 1.2 · instructions edited (+4 lines) · model unchanged"; a first+ * version: "First version seen on this machine." The models used have their own line. */export function changedLine(r: DoingRow, t: T): string {const parts: string[] = [];if (!r.changed) parts.push(t("p3.doing.first_version"));@@ -154,9 +173,9 @@ export function changedLine(r: DoingRow, t: T): string {}if (!r.changed.files.length) parts.push(t("p3.doing.no_file_change"));}+ if (!r.changed) return parts.join(" · "); // T3-15: a first version says only thatconst m = r.model_line;if (m?.kind === "changed") parts.push(t("p3.doing.model_changed", { from: m.from, to: m.to }));- else if (m?.kind === "several") parts.push(t("p3.doing.models", { models: (m.models || []).join(", ") }));- else parts.push(t("p3.doing.model_unchanged"));+ else if (m?.kind === "unchanged" && (m.models || []).length) parts.push(t("p3.doing.model_unchanged"));return parts.join(" · ");}diff --git a/surfaces/gui/src/locales/en.json b/surfaces/gui/src/locales/en.jsonindex 983b4b09..9a9ff329 100644--- a/surfaces/gui/src/locales/en.json+++ b/surfaces/gui/src/locales/en.json@@ -4066,18 +4066,15 @@"none": "No runs of this coworker in the last 30 days.","version": "Version","in_use": "In use",- "runs": "Runs",- "median_tokens": "Median tokens per run","with_issues": "Turns with issues",- "approvals": "Approvals per run",+ "approvals": "Approvals asked per session","current": "current","unknown_version": "unknown version",- "before": "before {{date}}","automation_runs_one": "(incl. {{count}} automation)","automation_runs_other": "(incl. {{count}} automations)",- "too_few": "too few runs to compare",+ "too_few": "too few sessions to compare","what_changed": "What changed in ⓕ{{fp}}",- "first_version": "the first version seen on this machine",+ "first_version": "First version seen on this machine.","instructions_edited": "instructions edited ({{lines}} lines)","instructions_added": "instructions added","instructions_removed": "instructions removed",@@ -4091,11 +4088,21 @@"no_file_change": "no file changed","model_unchanged": "model unchanged","model_changed": "model changed: {{from}} → {{to}}",- "models": "models: {{models}}","show_diff": "Show diff","hide_diff": "Hide diff","no_text_diff": "(no text difference)",- "note": "A run is the turns of one session under one version. Fewer than {{n}} runs: “too few runs” instead of a median."+ "note": "Each session counts once per version. With fewer than {{n}} sessions, a version says “too few sessions to compare” instead of typical numbers.",+ "version_n": "v{{n}}",+ "fingerprint": "Fingerprint ⓕ{{fp}}",+ "sessions": "Sessions",+ "typical_tokens": "Typical tokens per session",+ "typical_tokens_title": "The middle session's tokens",+ "ratings": "Ratings 👍 / 👎",+ "today": "today",+ "or_earlier": "{{date}} or earlier",+ "models_used_one": "Models used: {{model}}",+ "models_used_more": "Models used: {{model}} and {{count}} more",+ "nothing_to_compare": "Nothing to compare yet"},"wake": {"woke": "woke: {{reason}}",diff --git a/surfaces/gui/src/locales/zh.json b/surfaces/gui/src/locales/zh.jsonindex 5bb23e15..ace75af7 100644--- a/surfaces/gui/src/locales/zh.json+++ b/surfaces/gui/src/locales/zh.json@@ -4000,17 +4000,14 @@"none": "最近 30 天这个同事没有运行。","version": "版本","in_use": "使用期间",- "runs": "运行次数",- "median_tokens": "每次运行令牌中位数","with_issues": "有问题的轮次",- "approvals": "每次运行的审批",+ "approvals": "每个会话请求的批准","current": "当前","unknown_version": "未知版本",- "before": "{{date}} 之前","automation_runs_other": "(含 {{count}} 个自动化)",- "too_few": "运行太少,无法比较",+ "too_few": "会话太少,无法比较","what_changed": "ⓕ{{fp}} 改了什么",- "first_version": "这台机器上看到的第一个版本",+ "first_version": "这台机器上看到的第一个版本。","instructions_edited": "指令已修改({{lines}} 行)","instructions_added": "指令已添加","instructions_removed": "指令已删除",@@ -4024,11 +4021,21 @@"no_file_change": "没有文件改动","model_unchanged": "模型未变","model_changed": "模型已变:{{from}} → {{to}}",- "models": "模型:{{models}}","show_diff": "显示差异","hide_diff": "隐藏差异","no_text_diff": "(没有文本差异)",- "note": "一次运行指一个会话在同一版本下的所有轮次。少于 {{n}} 次运行时显示“运行太少”,不显示中位数。"+ "note": "每个会话在每个版本下算一次。会话少于 {{n}} 个时,该版本显示“会话太少,无法比较”,不显示典型数值。",+ "version_n": "v{{n}}",+ "fingerprint": "指纹 ⓕ{{fp}}",+ "sessions": "会话",+ "typical_tokens": "每个会话的典型令牌数",+ "typical_tokens_title": "位于中间的那个会话的令牌数",+ "ratings": "评价 👍 / 👎",+ "today": "今天",+ "or_earlier": "{{date}} 或更早",+ "models_used_one": "使用的模型:{{model}}",+ "models_used_more": "使用的模型:{{model}} 等另外 {{count}} 个",+ "nothing_to_compare": "还没有可比较的版本"},"wake": {"woke": "唤醒原因:{{reason}}",diff --git a/surfaces/gui/src/obs3.ts b/surfaces/gui/src/obs3.tsindex dd2ea606..2fd763c6 100644--- a/surfaces/gui/src/obs3.ts+++ b/surfaces/gui/src/obs3.ts@@ -242,6 +242,24 @@ export function shortDate(ms: number): string {return new Date(ms).toLocaleDateString(undefined, { day: "2-digit", month: "short" });}+/** T3-15: when a coworker version was in use, as a person says it: "Nov 2" for one day,+ * "Nov 3 – today", "Nov 3 or earlier – today" when the ledger keeps nothing older. */+export function inUseSpan(+ first: number | null, last: number | null, beforeKept: boolean,+ t: (k: string, o?: any) => string, now = new Date(),+): string {+ if (first == null || last == null) return "—";+ const day = (ms: number) => {+ const d = new Date(ms);+ return d.toDateString() === now.toDateString()+ ? t("p3.doing.today")+ : d.toLocaleDateString(undefined, { month: "short", day: "numeric" });+ };+ const from = beforeKept ? t("p3.doing.or_earlier", { date: day(first) }) : day(first);+ const sameDay = new Date(first).toDateString() === new Date(last).toDateString();+ return sameDay && !beforeKept ? from : `${from} – ${day(last)}`;+}+// -- moving between turns in the Trace panel (T3-14) ------------------------------------------/** A turn's part of the conversation the GUI already holds: what you asked, its answer, and* the tools and files its steps touched. Nothing here is fetched or sent anywhere. */diff --git a/tests/test_observability_phase3_manual_fixes.py b/tests/test_observability_phase3_manual_fixes.pyindex c0f0b89a..bba2709f 100644--- a/tests/test_observability_phase3_manual_fixes.py+++ b/tests/test_observability_phase3_manual_fixes.py@@ -107,6 +107,12 @@ def test_the_default_coworkers_page_and_history_answer(tmp_path, monkeypatch):body = doing.json()assert body["persona_id"] == DEFAULT_PERSONA_ID and body["runs"] == 1, bodyassert sum(r["turns"] for r in body["rows"]) == 1+ # T3-15 (d): the default coworker is built in code, not from a manifest; its only version+ # is still the current one. (b, f): a first version, numbered v1, with only its own models.+ [only] = body["rows"]+ assert only["current"] is True and only["version_n"] == 1+ assert only["changed"] is None and only["model_line"]["kind"] == "first"+ assert only["models"] == only["model_line"]["models"] # the session's own model(s), listed once# T3-10's route answers with the card's fieldsnow = int(time.time() * 1000)got = client.get("/v1/observability/ratings", params={"from": now - 86_400_000, "to": now + 60_000}).json()@@ -181,3 +187,24 @@ def test_stopping_the_app_drops_queued_scope_checks_and_stops_the_start_up_checkloaded = []monkeypatch.setattr(manager.recordings_store, "load_recording", lambda sid: loaded.append(sid))assert manager.recheck_issues() == 2 and loaded == []+++# -- T3-15 (b) ------------------------------------------------------------------------------------+def test_a_versions_models_are_its_own_work_only(tmp_path):+ from coworker.observability import signals++ store = RecordingStore(tmp_path / "recordings.db", background=False)+ t = _turn("T1", "s1", 1, RECENT)+ t["stamp"].update({"persona_id": "cowork", "persona_fp": "fp1"})+ store.write_turn(t)+ usage = {"reported": True, "input_fresh": 10, "cache_read": 0, "cache_write": 0, "output": 1}+ for n, (purpose, model) in enumerate([("main", "model-x"), ("helper", "model-h"), ("auto_approver", "reviewer-model"),+ ("title", "title-model"), ("summary", "summary-model")], start=1):+ store.write_step(_step("T1", "s1", n, RECENT + n, "model", {"purpose": purpose, "model": model, "usage": usage}))+ store.write_issues("T1", {"signals_version": signals.version(), "warn": 0, "info": 0, "issues": [], "fine": []}, seen=True)+ store.flush()+ got = usage_api.persona_doing(store, "cowork", start=RECENT - 1, end=RECENT + 60_000)+ [row] = got["rows"]+ assert row["models"] == ["model-h", "model-x"]+ assert row["model_line"] == {"kind": "first", "models": ["model-h", "model-x"]}+ store.close()