feat(FN-1148): add AI session keep-alive pings for SSE streams

- Add AiSessionStore.ping() and expose POST /api/ai-sessions/:id/ping for lightweight heartbeat updates without emitting high-frequency session events
- Add pingSession() client API and integrate 25s keep-alive timers into planning, subtask, and mission interview resilient SSE connections
- Ensure keep-alive timers stop on stream completion, fatal errors, and explicit close while treating ping failures as best-effort non-fatal behavior
- Expand API/store/routes coverage with targeted tests for ping endpoint behavior, ping store semantics, and SSE keep-alive lifecycle handling
- Stabilize MissionStore latest-error lookup ordering with a rowid tiebreaker when timestamps are equal
This commit is contained in:
gsxdsm
2026-04-08 09:15:25 -07:00
parent c07c9f4aba
commit ebb8e63274
7 changed files with 274 additions and 7 deletions

View File

@@ -479,7 +479,7 @@ export class MissionStore extends EventEmitter<MissionStoreEvents> {
SELECT timestamp, description
FROM mission_events
WHERE missionId = ? AND eventType = 'error'
ORDER BY timestamp DESC
ORDER BY timestamp DESC, rowid DESC
LIMIT 1
`).get(missionId) as { timestamp: string; description: string } | undefined;