← Back to PRs

#21544: Gateway: include diagnostics state in sessions.list

by sey-agent open 2026-02-20 02:44 View on GitHub →
docs app: web-ui gateway size: S
Closes #21537. ### What - Extends `sessions.list` rows with best-effort diagnostics-derived fields: - `diagnosticsState`: `idle|waiting|processing` - `diagnosticsStateTs`: epoch ms - `processingConfirmed`: boolean convenience (`diagnosticsState === "processing"`) - `diagnosticsQueueDepth` + `diagnosticsReason` when available - Does **not** create diagnostic entries as a side-effect of listing sessions. ### Tests - `OPENCLAW_PROFILE= OPENCLAW_GATEWAY_TOKEN= pnpm vitest run --config vitest.gateway.config.ts <!-- greptile_comment --> <h3>Greptile Summary</h3> Extended `sessions.list` to include diagnostics-derived fields (`diagnosticsState`, `diagnosticsStateTs`, `processingConfirmed`, `diagnosticsQueueDepth`, `diagnosticsReason`) by introducing `peekDiagnosticSessionState` which reads existing diagnostic state without creating new entries. - Added `peekDiagnosticSessionState` function in `src/logging/diagnostic-session-state.ts:80` that looks up existing diagnostic state without side-effect creation - Modified `listSessionsFromStore` in `src/gateway/session-utils.ts:792-818` to call `peekDiagnosticSessionState` and populate new fields - Updated type definitions in both `src/gateway/session-utils.types.ts:28-37` and `ui/src/ui/types.ts:395-399` with matching field types - Added `lastReason` tracking to `SessionState` type and `logSessionStateChange` function - Included comprehensive test coverage for all scenarios (state present, absent, sessionId-only lookup) - Updated documentation to describe the new best-effort fields <h3>Confidence Score: 5/5</h3> - This PR is safe to merge with minimal risk - The implementation is clean, well-tested, and follows the stated goal of not creating diagnostic entries as a side-effect. The new `peekDiagnosticSessionState` function correctly returns undefined for non-existent states rather than creating them. Type definitions are consistently updated across both gateway and UI. Comprehensive tests cover all key scenarios including the critical behavior of not creating entries when none exist. - No files require special attention <sub>Last reviewed commit: de25216</sub> <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> <!-- /greptile_comment -->

Most Similar PRs