Skip to content

Idle sessions should not pay the same poll/liveness cost as the active turn #2

Description

@15273

Symptom

Many sessions sit in the sidebar. The panel still does a full GET /sessions (and per-session get_session_state on the bridge) on every poll. When the active chat is working that poll is every 2.5s (SESSION_POLL_ACTIVE_MS in useSessionManager.ts). Idle chats should not keep the same request pattern.

This also shows up as bridge jank: the comment in useSessionManager.ts already says mass /transcript fetches starve WebSockets. Transcript sync was restricted to the active session; the list poll + liveness path was not fully tightened.

What already exists

  • Fast vs idle poll interval is based on the active session only (SESSION_POLL_ACTIVE_MS vs SESSION_POLL_IDLE_MS).
  • /transcript merge is active-session-only.
  • WS keepalive: collectWsKeepOpen in extension/src/shared/wsKeepalive.ts — active + turnRunning + persistent automation sessions.

What to change

Goal: only sessions that need it should trigger expensive work.

Concrete directions (pick one, measure, then the next):

  1. Cheap GET /sessions — listing metadata for idle chats should not call get_session_state / liveness for every name. Example: ?live=1 or skip liveness unless active / turn_running / recently used. See list_sessions in devscope_bridge/session_http.py (loops all stored sessions today).
  2. Do not open WS for idle user chats (already partly true; audit automation + background workers).
  3. Do not recoverPending / heal WS in a fan-out across every name on every poll.
  4. Document the invariant: active chat + in-flight turns (+ intentional automation) may poll/stream; everyone else is list-only until selected.

Done when

  • Idle sessions do not cause per-session process/liveness work on the 2.5s path (pytest on the list endpoint or get_session_state call count).
  • Switching to an idle session still shows correct turn_running / awaiting cards within one poll.
  • Active turn streaming is unchanged (no extra dropped WS frames).

Good first slice: add a query flag or skip _liveness_fields for sessions that are not active and not is_turn_running, with a test that a large idle list stays cheap.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions