Skip to content

feat(sessions): by-id fetch (/:id + ?ids=) + Tasks stops full-list polling (v0.294.0) - #539

Merged
vikasprogrammer merged 1 commit into
mainfrom
feat/sessions-pagination
Aug 3, 2026
Merged

feat(sessions): by-id fetch (/:id + ?ids=) + Tasks stops full-list polling (v0.294.0)#539
vikasprogrammer merged 1 commit into
mainfrom
feat/sessions-pagination

Conversation

@vikasprogrammer

Copy link
Copy Markdown
Owner

Sessions-pagination Phase 1. Plan: docs/sessions-pagination-plan.md (added here).

Why

GET /api/sessions returns all ~950 sessions and the console had no single-session read — every by-id lookup (notification→open, SessionFacts, the Tasks board's lastSessionId → isLive) came from the full list the 1.5 s poll ships. That's the blocker to ever slimming the poll (Phase 2). This lands the missing by-id surface + removes the first duplicate full fetch.

Change

  • GET /api/sessions/:id and GET /api/sessions?ids=a,b,c — same derived-row shape as the list (clipped task, blocked/alive/labels). Reuse listSessions' canViewRow scoping (an id the caller can't see → 404 / omitted — no existence leak), and match by id regardless of archived_at so a notification-open resolves an archived run. listSessions gained an optional ids filter.
  • Tasks board fetches only the sessions its visible tasks reference (via sessionsByIds) instead of re-pulling all ~950 rows on its 5 s timer.

The global 1.5 s poll still ships the full list — that's Phase 2 (a cheap /api/sessions/summary). This phase is purely additive + the Tasks fetch swap.

Verification (live instawp snapshot, 950 rows)

  • batch ?ids= / single /:id / unknown→404 / empty→[] / archived-by-id / plain-list-unaffected / task clipped ≤241 — 9/9.
  • Viewer-scoping holds: a plain member (no assignments) sees 0 of 950 in the list and gets 404 / [] for an unowned session id — no leak.
  • Typecheck + web build + npm run test:governance (29/29) green.

Next

Phase 2 (the actual perf win — poll stops shipping ~950 rows) and Phase 3 (list-view server pagination). See the plan doc.

🤖 Generated with Claude Code

…lling (v0.294.0)

Sessions-pagination Phase 1 (plan: docs/sessions-pagination-plan.md). The console had
no single-session read — every by-id lookup came from the full ~950-row list the 1.5s
poll ships, so the poll can't be slimmed without breaking lookups. Adds:

- GET /api/sessions/:id and GET /api/sessions?ids=a,b,c — same derived-row shape as the
  list (clipped task, blocked/alive/labels), viewer-scoped via listSessions' canViewRow
  (unseeable id → 404 / omitted, no existence leak), matched by id regardless of
  archived_at (so a notification-open resolves an archived run). listSessions gained an
  optional `ids` filter.
- The Tasks board now fetches only the sessions its visible tasks reference
  (lastSessionId, for liveOf) via sessionsByIds, instead of re-pulling all ~950 rows on
  its 5s timer.

The global 1.5s poll still ships the full list until Phase 2 (a cheap summary feed).

Verified against a live instawp snapshot (950 rows): batch/single/404/empty/archived-by-id
all correct, task clipped ≤241, plain list unaffected; and viewer-scoping holds — a plain
member sees 0 of 950 and gets 404/[] for an unowned id. Typecheck + web build +
test:governance (29/29) green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vikasprogrammer
vikasprogrammer merged commit 969e5f3 into main Aug 3, 2026
1 check passed
vikasprogrammer added a commit that referenced this pull request Aug 3, 2026
…rtualize now, paginate later) (#544)

Adds a "Console performance" section to TODO.md tracking the shipped console-perf
arc (Phases 1+2, #539/#542) and the Phase 3 decision: do client row virtualization
first (3a, low-risk render fix), defer server-side pagination (3b) until a tenant's
session count clears ~3-5k. Updates docs/sessions-pagination-plan.md Status to match.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant