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:
@@ -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)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user