Summary
Add gateway startup recovery that resumes stuck chat sessions after restart, not just outbound delivery queue retries.
Problem
Current startup flow only calls recoverPendingDeliveries() in server.impl, which retries failed outbound queue items. Sessions can still be stuck when the latest turn never produced a user-visible reply (e.g., thinking-only assistant turn), leaving unanswered conversations until a user manually re-pings.
Requirements
- Add startup recovery module under
src/gateway/.
- Scan gateway session stores and detect stuck sessions by transcript tail:
- Last meaningful message is user (unanswered), or
- Last meaningful message is assistant with no visible text and no tool call.
- Replay by invoking
sessions.send via existing gateway handler/context pipeline.
- Safety:
- Skip non-chat/internal channels (
global, unknown, cron, internal).
- Process newest first with per-startup cap (e.g. 10).
- Log scanned/candidates/replayed/failed summary.
- Integrate into startup flow in
server.impl after request context and channel sidecars are ready.
- Reuse existing utilities (
session-utils, transcript readers, coreGatewayHandlers.sessions.send path) where possible.
- Add unit tests for detection/selection logic.
Validation
Run focused tests for added/changed files.
Summary
Add gateway startup recovery that resumes stuck chat sessions after restart, not just outbound delivery queue retries.
Problem
Current startup flow only calls
recoverPendingDeliveries()inserver.impl, which retries failed outbound queue items. Sessions can still be stuck when the latest turn never produced a user-visible reply (e.g., thinking-only assistant turn), leaving unanswered conversations until a user manually re-pings.Requirements
src/gateway/.sessions.sendvia existing gateway handler/context pipeline.global,unknown,cron, internal).server.implafter request context and channel sidecars are ready.session-utils, transcript readers,coreGatewayHandlers.sessions.sendpath) where possible.Validation
Run focused tests for added/changed files.