Title: chatd debug logs: deferred review items from PR stack · Issue #24137 · coder/coder · GitHub
Open Graph Title: chatd debug logs: deferred review items from PR stack · Issue #24137 · coder/coder
X Title: chatd debug logs: deferred review items from PR stack · Issue #24137 · coder/coder
Description: Tracking: chatd Debug Logs — Deferred Review Items This issue tracks deferred review items from the chatd debug logs PR stack (#23913–#23921) that mafredri flagged as needing a tracking artifact. PR #23914 — Types, Context, Model Normali...
Open Graph Description: Tracking: chatd Debug Logs — Deferred Review Items This issue tracks deferred review items from the chatd debug logs PR stack (#23913–#23921) that mafredri flagged as needing a tracking artifact. P...
X Description: Tracking: chatd Debug Logs — Deferred Review Items This issue tracks deferred review items from the chatd debug logs PR stack (#23913–#23921) that mafredri flagged as needing a tracking artifact. P...
Opengraph URL: https://github.com/coder/coder/issues/24137
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"chatd debug logs: deferred review items from PR stack","articleBody":"## Tracking: chatd Debug Logs — Deferred Review Items\n\nThis issue tracks deferred review items from the chatd debug logs PR stack (#23913–#23921) that mafredri flagged as needing a tracking artifact.\n\n### PR #23914 — Types, Context, Model Normalization\n\n- [ ] **`normalizeToolResultOutput` test coverage**: 7/8 type-switch arms untested including nil guards, error-to-string conversion, media placeholder formatting, and default JSON fallback\n- [ ] **`GenerateObject` test coverage**: unique paths (`normalizeObjectCall`, `normalizeObjectResponse`, nil guard, `structured_output` metadata) have 0% test coverage\n- [ ] **Unconsumed stream safety net**: an unconsumed stream wrapper never calls `finalize`, leaving step permanently `in_progress` once real recorder lands. Consider `context.AfterFunc` or `runtime.SetFinalizer`\n- [ ] **`stepHandle.finish` synchronization**: add `sync.Once` to `stepHandle.finish` itself or serialize through holder mutex to prevent data race when recorder inherits the pattern\n\n### PR #23915 — Recorder, Transport, Redaction\n\n- [x] **Transport test coverage**: additional test scenarios for fail-closed `RedactJSONSecrets`, non-JSON response body handling\n- [x] **Recorder test coverage**: additional test scenarios flagged in review (specific gaps addressed: TestNextStepNumber_Concurrent cleanup, step counter tests, nil-safety tests)\n\n### PR #23916 — Service, Summary, Aggregation\n\n- [x] **`FinalizeStale` uses `time.Now()` directly**: Resolved — `quartz.Clock` injected via `WithClock` option; `FinalizeStale`, heartbeat tickers, and `stepHandle.finish` all use `s.clock.Now()`\n- [x] **Reasoning tokens aggregation test**: Resolved — `ReasoningTokensSummedAcrossSteps` and `ZeroReasoningTokensOmitsField` tests added with `updateTestStepWithFullUsage` helper\n- [x] **`nullJSON` typed nils**: `nullJSON` maps both nil and typed nils to `NullRawMessage{Valid: false}` — intentional for write-once-finalize pattern, not a correctness issue\n- [x] **`for {}` loop iteration cap**: Resolved — `maxCreateStepRetries = 10` cap and `ctx.Err()` check between iterations\n- [x] **F25: `TouchStep` uses full `UpdateChatDebugRun`**: Resolved — added dedicated `TouchChatDebugRunUpdatedAt` SQL query that only bumps `updated_at`\n- [x] **F27: TOCTOU race in `CreateStep` finalization guard**: Resolved — added `AND run.finished_at IS NULL` to `InsertChatDebugStep` WHERE clause; `sql.ErrNoRows` mapped to `errRunFinalized`\n- [x] **F18: `stepHandle.generation` dead code**: Resolved — removed field and increment\n- [x] **F22: Priority guard blocks same-priority retries**: Resolved — changed `\u003c=` to `\u003c`\n- [x] **F24: `extractEndpointLabel` deserializes full `Attempt`**: Resolved — `attemptLabel` minimal projection struct\n- [x] **F26: Em-dash characters in comments**: Resolved — replaced with standard punctuation\n- [x] **F28: `errRunFinalized` guard test coverage**: Resolved — `TestService_CreateStep_RejectsFinalizedRun` added\n- [x] **F29: `time.Now()` in recorder.go**: Resolved — replaced with `h.svc.clock.Now()`\n- [x] **F30: `truncateRunes` duplicates `util/strings.Truncate`**: Resolved — replaced with `stringutil.Truncate`\n- [x] **`expectUpdateStep` shallow JSON assertions**: model tests check `.Valid` flags but not JSON content; needs provider-specific fixture data\n- [x] **Non-stream heartbeat for `Generate`/`GenerateObject`**: Resolved -- added `launchHeartbeat` calls in both `Generate` and `GenerateObject` to keep the step alive during blocking provider calls\n\n### PR #23917 — Chat Lifecycle Wiring\n\n- [x] **Unconditional `NewService` call**: Resolved — chatd now initializes the\n debug service lazily through a factory and only materializes it on demand\n- [x] **`processChat`/`finishActiveChat` interleaving**: Resolved — finish-time\n status publishing now re-reads the chat state and suppresses stale final\n updates after a newer write wins\n- [x] **`newDebugModel` nil guard**: Resolved — debug model wrapping now routes\n through guarded debug-service accessors instead of assuming the service is\n always present\n- [x] **quickgen debug model wrapping**: Resolved — quickgen now shares a helper\n that wraps the model before run creation and finalizes with a bounded,\n uncancelled context\n- [x] **`chatd.go:4215` deferred cleanup**: Resolved — edit/archive debug cleanup\n now uses retrying best-effort cleanup with bounded timeouts plus the existing\n stale-finalization safety net\n- [x] **`chatd.go:1311` deferred item**: Resolved — startup stale-finalization\n now reuses the existing debug service instead of eagerly constructing one\n- [x] **`chatd.go:1918` deferred item**: Resolved — active-chat finalization now\n avoids publishing stale terminal state after newer control-path updates\n- [x] **`quickgen.go:784` deferred item**: Resolved — quickgen debug lifecycle\n- [x] **Edit cleanup race (Codex P2)**: Resolved — `DeleteChatDebugDataAfterMessageID`\n now accepts a `started_before` timestamp so retried cleanup does not delete\n runs created by a replacement turn that raced ahead of the retry window\n- [x] **Startup stale-finalization gating (Codex P3)**: Resolved — startup now uses\n `debugService()` (forces lazy init) instead of `existingDebugService()` so\n stale debug rows from a previous crash are finalized even when no request\n has triggered initialization yet\n setup is centralized so title and push-summary generation share the same\n guarded create/finalize flow\n\n### PR #23918 — HTTP Handlers, API Docs\n\n- [x] **Handler test coverage**: `getChatDebugRuns`, `getChatDebugRun`, `getChatDebugLogging`/`putChatDebugLogging`, `getUserChatDebugLogging`/`putUserChatDebugLogging` are covered by `TestChatDebugRuns`, `TestChatDebugRun`, and `TestChatDebugLoggingSettings` (bad UUID, missing run, cross-chat 404, newest-first ordering, 100-row cap, empty-list shape, admin-allow/revoke/re-allow cycle, forced-by-deployment, unauthenticated read)\n- [x] **`ChatDebugEvent` zero consumers**: removed — no references remain in Go or TypeScript\n- [x] **Naming inconsistency**: the per-chat `debug_logs_enabled_override` override was dropped along with the tri-state model; remaining types use `debug_logging_enabled` consistently\n- [x] **`ChatDebugSettings` / `UpdateChatDebugLoggingRequest` type sharing**: split into dedicated admin/user types — `ChatDebugLoggingAdminSettings` + `UpdateChatDebugLoggingAllowUsersRequest` for the deployment endpoint, `UserChatDebugLoggingSettings` + `UpdateUserChatDebugLoggingRequest` for the per-user endpoint\n- [x] **`NullableBool.MarshalJSON` wire format**: the `NullableBool` type and its custom marshaling were removed entirely when the tri-state per-chat override was dropped\n- [ ] **Debug runs list pagination**: SQL `LIMIT 100` with no pagination or truncation signal. Deferred to v2 per DEREM-5 panel closure (5/5 accept) — cap is tested, endpoint is experimental, no UI approaches the limit today; revisit when the frontend needs pagination\n\n### PR #23919 — Frontend API, Panel Utils\n\n- [x] **`debugPanelUtils.test.ts` test coverage**: Resolved — suite expanded to 100 cases across all 14 exported helpers. Coverage now exercises `coerceStepResponse` (OpenAI-choice tool_calls fallback, top-level `tool_calls`, response-body `usage`/`warnings`/`model`, non-object defaults, JSON-string wrapping), `coerceRunSummary` and `coerceStepRequest` JSON-string unwrapping, tool-call/tool-result message-part metadata, nameless tool filtering, `normalizeAttempts` object-shaped errors and pre-built `raw_request`/`raw_response` pass-through, positional attempt-number fallback, `extractTokenCounts` empty-record path, and `clampContent` whitespace/boundary/ellipsis-trim behavior.\n\n### PR #23920 — Debug Panel Components, Settings\n\n- [ ] **Errored runs poll indefinitely**: `errored` status missing from `ERROR_STATUSES`, causing infinite 5s polling\n- [ ] **`state.data` typed as `unknown`**: `debugQueries.ts:35` should be properly typed\n- [ ] **`tool_choice` bare `String()` on `unknown`**: `DebugStepCard.tsx:178` uses unsafe cast\n- [ ] **Unbounded `response.content` rendering**: `DebugStepCard.tsx:346` has no content limit\n- [ ] **NaN-unsafe sort**: `DebugPanel.tsx:23` sort comparator\n- [ ] **Dead branch**: `DebugRunList.tsx:16` dead code\n- [ ] **Tab-ID duplication**: `AgentChatPageView.tsx:317`\n\n### PR #23913 — Database Schema, SDK Types\n\n- [ ] **Three-tier toggle integration test**: site/user/chat enablement resolution has no integration test\n- [ ] **`UpdateChatDebugStep` operation updatable**: defense was acknowledged, no ticket\n\n### PR #23921 — Storybook Stories\n\n- [ ] **Section comment cleanup**: \"Existing stories\" / \"New stories\" reflect development timeline, not semantic grouping\n\n","author":{"url":"https://github.com/ThomasK33","@type":"Person","name":"ThomasK33"},"datePublished":"2026-04-08T05:27:44Z","url":"https://github.com/coder/coder/issues/24137"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:45c34d9e-5395-3e72-b2d5-ee5c9399ab89 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 833A:65478:1D9DBBE:273D338:6B01652F |
| html-safe-nonce | e40ef13de66ce7044502d2adbe1b48471d49559ff0dd9da86abce973150c9fe5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MzNBOjY1NDc4OjFEOURCQkU6MjczRDMzODo2QjAxNjUyRiIsInZpc2l0b3JfaWQiOiI3OTEzNzI5MTY1OTgyMDAwNDMxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 016915358db3183b34abaec0704ca0c6361112fb14d64fcc4c0e9b11c9f3600d |
| hovercard-subject-tag | issue:4222332755 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/coder/coder/24137/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b284a780385cde832038244ec57d2d3359a211a827fa7ac4929840c845d151e5/coder/coder/issues/24137 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b284a780385cde832038244ec57d2d3359a211a827fa7ac4929840c845d151e5/coder/coder/issues/24137 |
| og:image:alt | Tracking: chatd Debug Logs — Deferred Review Items This issue tracks deferred review items from the chatd debug logs PR stack (#23913–#23921) that mafredri flagged as needing a tracking artifact. P... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ThomasK33 |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/coder/coder git https://github.com/coder/coder.git |
| octolytics-dimension-user_id | 95932066 |
| octolytics-dimension-user_login | coder |
| octolytics-dimension-repository_id | 440752086 |
| octolytics-dimension-repository_nwo | coder/coder |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 440752086 |
| octolytics-dimension-repository_network_root_nwo | coder/coder |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width