From f4f99af890c1713435da4093b3e6cdd25d856376 Mon Sep 17 00:00:00 2001 From: murashit Date: Wed, 24 Jun 2026 08:44:54 +0900 Subject: [PATCH] Refine copied debug details --- .../chat/panel/surface/toolbar-projection.tsx | 21 ++++++++++++++++--- src/features/chat/ui/toolbar.tsx | 4 ++-- .../chat/panel/surface/projection.test.ts | 16 ++++++++++++++ .../chat/ui/renderers/toolbar.test.ts | 4 ++-- 4 files changed, 38 insertions(+), 7 deletions(-) diff --git a/src/features/chat/panel/surface/toolbar-projection.tsx b/src/features/chat/panel/surface/toolbar-projection.tsx index 4d618edc..232c4d88 100644 --- a/src/features/chat/panel/surface/toolbar-projection.tsx +++ b/src/features/chat/panel/surface/toolbar-projection.tsx @@ -1,6 +1,7 @@ import type { ComponentChild as UiNode } from "preact"; import { h } from "preact"; +import { CLIENT_VERSION } from "../../../../constants"; import type { Thread } from "../../../../domain/threads/model"; import { threadRowCoreProjection } from "../../../threads/row-projection"; import { rateLimitSummary } from "../../presentation/runtime/status"; @@ -70,7 +71,7 @@ function chatPanelToolbarProjection(input: ToolbarViewModelInput): ToolbarViewMo historyOpen: projection.historyOpen, statusPanelOpen: projection.statusPanelOpen, rateLimit: limit, - debugDetails: runtimeDebugDetails(input), + debugDetails: () => runtimeDebugDetails(input), openPanel: projection.openPanel, threads: projection.threads, connectLabel: input.connected ? "Reconnect" : "Connect", @@ -84,13 +85,27 @@ function chatPanelToolbarProjection(input: ToolbarViewModelInput): ToolbarViewMo } function runtimeDebugDetails(input: ToolbarViewModelInput): string { + const connection = input.state.connection; return JSON.stringify( { + clientVersion: CLIENT_VERSION, vaultPath: input.vaultPath, configuredCommand: input.configuredCommand, - runtimeConfig: input.state.connection.runtimeConfig, + activeThreadId: input.state.activeThreadId, + connection: { + connected: input.connected, + phase: connection.phase, + statusText: connection.statusText, + initializeResponse: connection.initializeResponse, + rateLimit: connection.rateLimit, + serverDiagnostics: { + probes: connection.serverDiagnostics.probes, + mcpServers: connection.serverDiagnostics.mcpServers, + }, + }, + runtimeConfig: connection.runtimeConfig, runtime: input.state.runtime, - availableModels: input.state.connection.availableModels, + availableModels: connection.availableModels, }, null, 2, diff --git a/src/features/chat/ui/toolbar.tsx b/src/features/chat/ui/toolbar.tsx index e5339bd5..e9f6e893 100644 --- a/src/features/chat/ui/toolbar.tsx +++ b/src/features/chat/ui/toolbar.tsx @@ -38,7 +38,7 @@ export interface ToolbarViewModel { historyOpen: boolean; statusPanelOpen: boolean; rateLimit: RateLimitSummary | null; - debugDetails: string; + debugDetails: () => string; openPanel: "history" | "chat-actions" | "status" | null; threads: ToolbarThreadRow[]; connectLabel: string; @@ -167,7 +167,7 @@ function StatusPanel({ model, actions }: { model: ToolbarViewModel; actions: Too { - actions.copyDebugDetails(model.debugDetails); + actions.copyDebugDetails(model.debugDetails()); }} className="codex-panel__status-panel-item" role="menuitem" diff --git a/tests/features/chat/panel/surface/projection.test.ts b/tests/features/chat/panel/surface/projection.test.ts index 5e16a141..20a91d79 100644 --- a/tests/features/chat/panel/surface/projection.test.ts +++ b/tests/features/chat/panel/surface/projection.test.ts @@ -81,6 +81,22 @@ describe("chat panel surface projections", () => { expect(debugDetails["vaultPath"]).toBe("/vault"); expect(debugDetails["configuredCommand"]).toBe("codex"); + expect(debugDetails["clientVersion"]).toEqual(expect.any(String)); + expect(debugDetails["activeThreadId"]).toBeNull(); + expect(debugDetails["connection"]).toMatchObject({ + connected: true, + phase: { kind: "idle" }, + statusText: "Idle", + initializeResponse: null, + rateLimit: null, + serverDiagnostics: { + probes: expect.any(Object), + mcpServers: [], + }, + }); + expect( + (debugDetails["connection"] as { serverDiagnostics?: Record }).serverDiagnostics?.["toolInventory"], + ).toBeUndefined(); expect(debugDetails["runtimeConfig"]).toMatchObject({ model: "gpt-debug" }); expect(debugDetails["runtime"]).toMatchObject({ pending: { model: { kind: "set", value: "gpt-debug" } } }); expect(debugDetails["runtimeLayers"]).toBeUndefined(); diff --git a/tests/features/chat/ui/renderers/toolbar.test.ts b/tests/features/chat/ui/renderers/toolbar.test.ts index 943adc8e..050412fd 100644 --- a/tests/features/chat/ui/renderers/toolbar.test.ts +++ b/tests/features/chat/ui/renderers/toolbar.test.ts @@ -193,7 +193,7 @@ describe("Toolbar decisions", () => { toolbarModel({ statusPanelOpen: true, openPanel: "status", - debugDetails, + debugDetails: () => debugDetails, }), toolbarActions({ copyDebugDetails }), ); @@ -360,7 +360,7 @@ function toolbarModel(overrides: Partial = {}): ToolbarViewMod historyOpen: false, statusPanelOpen: false, rateLimit: null, - debugDetails: "{}", + debugDetails: () => "{}", openPanel: null, threads: [{ title: "Thread", threadId: "thread", selected: true, disabled: false, canArchive: true, rename: null }], connectLabel: "Reconnect",