Dashboard UX: preserve Stats tab selection across session switches #77

Open
opened 2026-05-13 00:05:07 +02:00 by jesse · 0 comments
Owner

Background

When the user switches the active session while viewing the Stats tab, handleActiveSessionChange in app.js unconditionally clears statsActiveSessionId, hides the stats section, and drops the user back to the Thoughts view. The user must re-click the Stats tab to see the new session's stats.

Source: PR5 multi-agent code review (Concurrency dimension)
File: crates/cognix-server/assets/app.jshandleActiveSessionChange
Branch: phase-8/dashboard-ui-pr5-stats

Motivation

Switching sessions while inspecting any tab is a frequent flow. The Thoughts tab persists across switches (the click handler repaints with the new session), but the Stats tab does not. The asymmetry is undocumented and reads as a UI bug to anyone watching their chosen tab vanish.

Why deferred from PR5

The change requires a product decision: should Stats persist symmetrically with Thoughts (preferred, matches user expectation), or should it remain scoped to the click-arm flow (the current invalidation model, which guarantees stale renders from session A cannot repaint into session B's view). The latter is the safer default; the former is the better UX. Picking between them is out of scope for a tech-debt PR.

Proposed work

  • Decide the intended UX — either "preserve Stats across session switches and re-arm the controller for the new session" or "explicit user re-click required after session switch (documented)".
  • If preserving: update handleActiveSessionChange to set statsActiveSessionId = newSession, call invalidateStatsRender(), then runStatsRender('all') plus startStatsPolling() when statsPanelVisible. Verify the stale-render guard still holds across the transition.
  • If documenting current behavior: add a code comment at handleActiveSessionChange explaining the intentional drop-to-thoughts, and add an E2E test asserting the Stats tab hides on session switch.

Acceptance

  • One option is selected and implemented end-to-end.
  • An E2E test in e2e/dashboard/stats.spec.ts covers the chosen behavior.
  • No regression in the existing PR5 stale-render guard tests (test_pr5_* in transport/ui/tests/assets.rs).

References

  • PR5 review (Concurrency §5)
  • crates/cognix-server/assets/app.js::handleActiveSessionChange
## Background When the user switches the active session while viewing the Stats tab, `handleActiveSessionChange` in `app.js` unconditionally clears `statsActiveSessionId`, hides the stats section, and drops the user back to the Thoughts view. The user must re-click the Stats tab to see the new session's stats. **Source:** PR5 multi-agent code review (Concurrency dimension) **File:** `crates/cognix-server/assets/app.js` — `handleActiveSessionChange` **Branch:** `phase-8/dashboard-ui-pr5-stats` ## Motivation Switching sessions while inspecting any tab is a frequent flow. The Thoughts tab persists across switches (the click handler repaints with the new session), but the Stats tab does not. The asymmetry is undocumented and reads as a UI bug to anyone watching their chosen tab vanish. ## Why deferred from PR5 The change requires a product decision: should Stats persist symmetrically with Thoughts (preferred, matches user expectation), or should it remain scoped to the click-arm flow (the current invalidation model, which guarantees stale renders from session A cannot repaint into session B's view). The latter is the safer default; the former is the better UX. Picking between them is out of scope for a tech-debt PR. ## Proposed work - [ ] Decide the intended UX — either "preserve Stats across session switches and re-arm the controller for the new session" or "explicit user re-click required after session switch (documented)". - [ ] If preserving: update `handleActiveSessionChange` to set `statsActiveSessionId = newSession`, call `invalidateStatsRender()`, then `runStatsRender('all')` plus `startStatsPolling()` when `statsPanelVisible`. Verify the stale-render guard still holds across the transition. - [ ] If documenting current behavior: add a code comment at `handleActiveSessionChange` explaining the intentional drop-to-thoughts, and add an E2E test asserting the Stats tab hides on session switch. ## Acceptance - One option is selected and implemented end-to-end. - An E2E test in `e2e/dashboard/stats.spec.ts` covers the chosen behavior. - No regression in the existing PR5 stale-render guard tests (`test_pr5_*` in `transport/ui/tests/assets.rs`). ## References - PR5 review (Concurrency §5) - `crates/cognix-server/assets/app.js::handleActiveSessionChange`
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
jesse/cognix#77
No description provided.