feat(work-status): add opt-in turn statistics (#3177)

Add optional completed-turn statistics without changing the existing panel layout. Separate final text delivery speed from whole-turn throughput, preserve scope and opt-in settings, and explain each metric with localized delayed tooltips.

Validated focused telemetry, lifecycle, sync and persistence tests, all-workspace type-check and lint, web builds, the 12-locale narrow layout, and full GitHub CI.
This commit is contained in:
alvins82
2026-09-06 22:56:27 +03:00
committed by GitHub
parent b0282b2720
commit d8215ef5b3
36 changed files with 1404 additions and 31 deletions
+17 -2
View File
@@ -3,11 +3,11 @@ import type { OpencodeClient, Project } from "@opencode-ai/sdk/v2/client"
import { bootstrapDirectory } from "./bootstrap"
import { INITIAL_STATE, type State } from "./types"
const createSdk = (options?: { commandList?: () => Promise<{ data: unknown[] }> }) => ({
const createSdk = (options?: { commandList?: () => Promise<{ data: unknown[] }>; sessionStatus?: () => Promise<{ data: State['session_status'] }> }) => ({
project: { current: async () => ({ data: { id: "project-a" } }) },
config: { get: async () => ({ data: {} }) },
path: { get: async () => ({ data: { state: "", config: "", worktree: "/repo", directory: "/repo", home: "/home" } }) },
session: { status: async () => ({ data: {} }) },
session: { status: options?.sessionStatus ?? (async () => ({ data: {} })) },
command: { list: options?.commandList ?? (async () => ({ data: [] })) },
mcp: { status: async () => ({ data: {} }) },
lsp: { status: async () => ({ data: [] }) },
@@ -65,6 +65,7 @@ describe("bootstrapDirectory", () => {
expect(await bootstrapping).toBe("complete")
expect(state.status).toBe("complete")
expect(state.sessionStatusReady).toBe(true)
expect(deferredStarted).toBe(false)
await new Promise((resolve) => setTimeout(resolve, 0))
expect(deferredStarted).toBe(true)
@@ -108,4 +109,18 @@ describe("bootstrapDirectory", () => {
expect(result).toBe("stale")
expect(commits).toBe(0)
})
test("a failed status request cannot grant idle authority even when bootstrap completes", async () => {
let state = createState()
const result = await bootstrapDirectory({
directory: '/repo',
sdk: createSdk({ sessionStatus: async () => { throw new Error('status unavailable') } }),
getState: () => state,
set: (patch) => { state = { ...state, ...patch } },
global: { config: {}, projects: [project] },
loadSessions: async () => undefined,
})
expect(result).toBe('complete')
expect(state.sessionStatusReady).toBe(undefined)
})
})