fix: dashboard hints how to populate an empty session #83

Merged
jesse merged 2 commits from fix/dashboard-empty-thoughts-hint into main 2026-05-18 20:41:32 +02:00
Owner

Summary

  • Empty sessions now show a hint with the selected session_id, a copy-pasteable think() example, and a note explaining that calls without session_id land in the default session (the silent-fallback that users kept reporting as "my thoughts disappeared").
  • Added Playwright coverage in e2e/dashboard/dashboard.spec.ts that asserts the rendered hint text, the exact example formatting, and the get_thoughts RPC was invoked against the selected session.
  • Followed up with a self-review pass (see commit 0139fe8): re-nested renderEmptyThoughtsHint inside initSessions (un-exported), dropped a CSS class that had no rules, and removed a dynamic-import test that was exercising an unreachable branch.

Phase

N/A — UX fix.

Test Plan

  • cargo build -p cognix-server
  • npx playwright test dashboard.spec.ts — 33 passed, 0 failed
  • Spot-checked sessions.js to confirm renderEmptyThoughtsHint is still reachable from renderThoughtCards via closure after the un-export.

Self-Review Checklist

  • No hardcoded secrets
  • No unwrap() in library code (no Rust changes)
  • No println!/dbg!
  • Fail-open degradation preserved (UI path unchanged outside the empty-state branch)
  • Tests cover happy path (with session_id) and assert RPC contract

Notes

The no-session_id branch in renderEmptyThoughtsHint is kept as a defensive guard with a comment — schema.js:assertSessionShape throws schema-drift when both id and session_id are missing, so production callers always pass a populated session.

## Summary - Empty sessions now show a hint with the selected `session_id`, a copy-pasteable `think()` example, and a note explaining that calls without `session_id` land in the default session (the silent-fallback that users kept reporting as "my thoughts disappeared"). - Added Playwright coverage in `e2e/dashboard/dashboard.spec.ts` that asserts the rendered hint text, the exact example formatting, and the `get_thoughts` RPC was invoked against the selected session. - Followed up with a self-review pass (see commit `0139fe8`): re-nested `renderEmptyThoughtsHint` inside `initSessions` (un-exported), dropped a CSS class that had no rules, and removed a dynamic-import test that was exercising an unreachable branch. ## Phase N/A — UX fix. ## Test Plan - [x] `cargo build -p cognix-server` - [x] `npx playwright test dashboard.spec.ts` — 33 passed, 0 failed - [x] Spot-checked `sessions.js` to confirm `renderEmptyThoughtsHint` is still reachable from `renderThoughtCards` via closure after the un-export. ## Self-Review Checklist - [x] No hardcoded secrets - [x] No `unwrap()` in library code (no Rust changes) - [x] No `println!`/`dbg!` - [x] Fail-open degradation preserved (UI path unchanged outside the empty-state branch) - [x] Tests cover happy path (with `session_id`) and assert RPC contract ## Notes The no-`session_id` branch in `renderEmptyThoughtsHint` is kept as a defensive guard with a comment — `schema.js:assertSessionShape` throws schema-drift when both `id` and `session_id` are missing, so production callers always pass a populated session.
Pre-fix, a freshly created session rendered a flat "No thoughts have
been recorded yet." with no guidance, leaving users to guess why their
think() calls hadn't attached. The cause is almost always the scoping
rule: think() without session_id stores under the caller's default
session, not the one they just created via create_session.

Replace the flat marker with a copy-ready
think({ session_id: "<id>", thought: "..." }) example and a one-line
note explaining the scoping. Threads `session` into renderThoughtCards
so the example can render the actual id.
refactor: tighten empty-thoughts hint tests and re-nest helper
All checks were successful
CI / Detect Changes (pull_request) Successful in 14s
CI / Format (pull_request) Has been skipped
CI / Benchmarks (pull_request) Has been skipped
CI / Check (linux-aarch64 compile-validation) (pull_request) Has been skipped
CI / Integration Tests (pull_request) Has been skipped
CI / Dashboard UI Build (pull_request) Has been skipped
CI / Check file lengths (pull_request) Has been skipped
CI / Deny (pull_request) Has been skipped
CI / Security Scan (pull_request) Has been skipped
CI / Dashboard Browser (pull_request) Has been skipped
CI / Test (pull_request) Has been skipped
CI / Clippy (pull_request) Has been skipped
CI / Coverage (80% gate) (pull_request) Has been skipped
CI / Documentation (pull_request) Has been skipped
CI / Audit (CVEs) (pull_request) Has been skipped
CI / D-02 Clean Build Gate (pull_request) Has been skipped
CI / RSS gate (P-15) (pull_request) Has been skipped
CI / Build (release) (pull_request) Has been skipped
CI / PR Size Check (pull_request) Successful in 13s
CI / Conventional Validation (pull_request) Successful in 1m12s
CI / Clean Build Sample 1 (pull_request) Has been skipped
CI / Clean Build Sample 2 (pull_request) Has been skipped
CI / Clean Build Sample 3 (pull_request) Has been skipped
CI / Clean Build Summary (pull_request) Has been skipped
CI / CI Report (pull_request) Successful in 7s
0139fe8e02
Re-nest renderEmptyThoughtsHint inside initSessions (un-exported) since
it is only called from renderThoughtCards. Drop the unused
thought-empty-headline class. Delete the dynamic-import test that
exercised the no-session-id branch via fake ES import — that branch is
unreachable via the real UI flow (assertSessionShape rejects empty IDs),
so the guard stays as defensive code with an explanatory comment.

Tighten the remaining empty-state test: wait for the sessions list to
populate before clicking, drop the redundant 5s timeout, collapse the
four example-text checks into one toHaveText that locks the exact
formatting, and assert the get_thoughts RPC was actually invoked with
sess-A. Reword the comment to capture the user-facing failure mode
(silent default-session fallback) rather than restating what the test
asserts.
jesse merged commit 7257ddf776 into main 2026-05-18 20:41:32 +02:00
jesse deleted branch fix/dashboard-empty-thoughts-hint 2026-05-18 20:41:32 +02:00
Sign in to join this conversation.
No reviewers
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!83
No description provided.