{t("p3.usage.by_coworker")}
+ {picked &&
{t("p3.usage.by_coworker_all")}
}
| {t("p3.usage.coworker")} | {t("p3.usage.tokens")} | {t("p3.usage.with_issues")} |
diff --git a/surfaces/gui/src/locales/en.json b/surfaces/gui/src/locales/en.json
index 44b11cfd..4e8c4769 100644
--- a/surfaces/gui/src/locales/en.json
+++ b/surfaces/gui/src/locales/en.json
@@ -3939,6 +3939,7 @@
"overhead_sub": "On its own scale: the tallest day is {{tokens}} tokens.",
"point_hint": "Point at a bar to see each part's tokens.",
"by_coworker": "By coworker",
+ "by_coworker_all": "All coworkers, for comparison",
"coworker": "Coworker",
"automation": "(automation)",
"unknown_coworker": "unknown coworker",
diff --git a/surfaces/gui/src/locales/zh.json b/surfaces/gui/src/locales/zh.json
index b1d24e1a..f0337eb5 100644
--- a/surfaces/gui/src/locales/zh.json
+++ b/surfaces/gui/src/locales/zh.json
@@ -3880,6 +3880,7 @@
"overhead_sub": "单独的刻度:最高的一天为 {{tokens}} 令牌。",
"point_hint": "指向柱形可查看每一部分的令牌数。",
"by_coworker": "按同事",
+ "by_coworker_all": "所有同事,供对比",
"coworker": "同事",
"automation": "(自动化)",
"unknown_coworker": "未知同事",
diff --git a/surfaces/gui/src/routes.activity.test.ts b/surfaces/gui/src/routes.activity.test.ts
new file mode 100644
index 00000000..8ff66e42
--- /dev/null
+++ b/surfaces/gui/src/routes.activity.test.ts
@@ -0,0 +1,41 @@
+// T3-11: Activity has its own address, so a reload stays on it (and on its tab).
+import { afterEach, describe, expect, it, vi } from "vitest";
+
+async function boot(hash: string) {
+ window.history.replaceState(null, "", "/" + hash);
+ vi.resetModules();
+ return import("./routes");
+}
+
+afterEach(() => window.history.replaceState(null, "", "/"));
+
+describe("#/activity", () => {
+ it("reads the tab a link asks for; a bare #/activity is the Log", async () => {
+ expect((await boot("#/activity/usage")).initialActivityTab).toBe("usage");
+ expect((await boot("#/activity/log")).initialActivityTab).toBe("log");
+ expect((await boot("#/activity")).initialActivityTab).toBe("log");
+ expect((await boot("#/settings/general")).initialActivityTab).toBe("");
+ });
+
+ it("keeps the link until Activity shows itself, then reflects the open tab", async () => {
+ const r = await boot("#/activity/usage");
+ r.reflectSession("s1"); // the app's mount still says "session": must not overwrite the link
+ expect(window.location.hash).toBe("#/activity/usage");
+ r.reflectActivity("usage");
+ expect(window.location.hash).toBe("#/activity/usage");
+ r.reflectActivity("log");
+ expect(window.location.hash).toBe("#/activity/log");
+ // leaving Activity for a session hands the address back
+ r.reflectSession("s1");
+ expect(window.location.hash).toBe("#/s/s1");
+ });
+
+ it("Settings after Activity takes the address", async () => {
+ const r = await boot("");
+ r.reflectActivity("usage");
+ r.reflectSettings("appearance");
+ expect(window.location.hash).toBe("#/settings/general");
+ r.reflectActivity("usage");
+ expect(window.location.hash).toBe("#/activity/usage");
+ });
+});
diff --git a/surfaces/gui/src/routes.ts b/surfaces/gui/src/routes.ts
index 324de93d..9101d668 100644
--- a/surfaces/gui/src/routes.ts
+++ b/surfaces/gui/src/routes.ts
@@ -8,6 +8,7 @@
// #/s/{sessionId} → land on that session (bookmark/refresh)
// #/settings/{page}?m={id} → open that Settings page; ?m= is the machine
// scope for machine-scoped pages (UX-046)
+// #/activity/{log|usage} → open Activity on that tab (T3-11: a reload stays there)
const initialHash = typeof window !== "undefined" ? window.location.hash : "";
@@ -53,6 +54,27 @@ export const initialSettingsTab = (() => {
// "session" at mount) and would overwrite the link before it is read.
let settingsLinkPending = initialSettingsTab !== "";
+/** The Activity tab a #/activity link asks for ("" = none); a bare #/activity is the Log. */
+export const initialActivityTab: "" | "log" | "usage" = (() => {
+ const m = initialHash.match(/^#\/activity(?:\/(log|usage))?/);
+ if (!m) return "";
+ return (m[1] as "log" | "usage" | undefined) ?? "log";
+})();
+// Same as a settings link: the session reflection at mount must not overwrite it.
+let activityLinkPending = initialActivityTab !== "";
+
+/** Reflect the open Activity tab in the URL (replaceState, like Settings and sessions). */
+export function reflectActivity(tab: "log" | "usage"): void {
+ if (hasPendingApproval()) return;
+ activityLinkPending = false;
+ settingsLinkPending = false;
+ try {
+ window.history.replaceState(null, "", `#/activity/${tab}`);
+ } catch {
+ /* file:// or restricted contexts — the URL is a convenience */
+ }
+}
+
/** The ?m= machine scope, read LIVE from the current hash (not the boot one):
* reflectSettings keeps it current, so a Settings remount re-reads the scope
* it was already showing instead of resetting to the default. */
@@ -71,6 +93,7 @@ export function settingsMachineParam(): string {
export function reflectSettings(tab: string, machineId?: string | null): void {
if (hasPendingApproval()) return;
settingsLinkPending = false;
+ activityLinkPending = false;
const slug = SLUG_BY_TAB[tab] ?? "general";
try {
window.history.replaceState(
@@ -113,7 +136,7 @@ export function hasPendingApproval(): boolean {
/** Reflect the active session in the URL so refresh and bookmarks return
* here. replaceState: session switching must not pile up history entries. */
export function reflectSession(sessionId: string): void {
- if (!sessionId || hasPendingApproval() || settingsLinkPending) return;
+ if (!sessionId || hasPendingApproval() || settingsLinkPending || activityLinkPending) return;
try {
window.history.replaceState(null, "", `#/s/${sessionId}`);
} catch {