Skip to content

fix(sidebar): default the desktop sidebar to collapsed - #1637

Merged
BigSimmo merged 27 commits into
mainfrom
claude/sidebar-closed-default-i6n2fk
Aug 7, 2026
Merged

fix(sidebar): default the desktop sidebar to collapsed#1637
BigSimmo merged 27 commits into
mainfrom
claude/sidebar-closed-default-i6n2fk

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Aug 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • The desktop sidebar (useSidebarCollapsed) previously defaulted new users to the labelled (expanded) state, with collapse only sticking once a user toggled it. Flip the default to collapsed so the sidebar starts closed for new users, matching the mobile drawer's existing closed-by-default behavior (mobileSidebarOpen already starts false) — the sidebar is now closed by default on all devices.
  • Updated the SSR fallback snapshot in client-store-factory usage to true so the server-rendered markup matches the new client default and avoids a hydration flash.
  • Updated three Playwright specs (ui-smoke.spec.ts, ui-tools.spec.ts, ui-tools-collapse.spec.ts) whose comments/seeded localStorage values and assertions encoded the old expanded-by-default behavior.

Verification

  • npm run test:focused -- --files src/components/clinical-dashboard/use-sidebar-collapsed.ts,src/lib/client-store-factory.tsTest Files 10 passed (10), Tests 88 passed (88)
  • npx tsc --noEmit -p tsconfig.json — clean, no output
  • npx eslint on touched files — clean, no output
  • npm run verify:ui not run — this is a text-only default-value change already covered by the focused unit suite and the specs I updated to match the new default; the full Chromium browser gate touches many unrelated journeys and wasn't run in this session (VERIFICATION NOT RUN: broader browser gate out of scope for a single default-value flip; the updated specs will exercise this behavior when CI's Chromium job runs on the PR).

Risk and rollout

  • Risk: Low — a single boolean default flip in a client-persisted preference store, gated by existing localStorage/hydration tests.
  • Rollback: Revert this commit; the persisted clinical-kb-sidebar-collapsed localStorage key is unaffected for existing users who already have a stored preference.
  • Provider or production effects: None.

Notes

  • Does not touch ingestion, answer generation, search/ranking, source rendering, document access, privacy, or production env, so the Clinical Governance Preflight section is not applicable.

Generated by Claude Code

Summary by CodeRabbit

  • New Features

    • New users now start with the sidebar collapsed for a more compact initial view.
    • Existing sidebar preferences continue to be remembered and restored.
  • Bug Fixes

    • Invalid, missing, or unreadable sidebar preferences now safely default to the collapsed state.
  • Tests

    • Updated accessibility and interface checks for collapsed and expanded sidebar states.
    • Expanded coverage for desktop, tablet, hydration, and account-related sidebar behavior.

New users previously got the labelled (expanded) sidebar with collapse
as a remembered choice. Flip the default to collapsed, matching the
existing already-closed mobile drawer default, so the sidebar starts
closed on all devices until a user explicitly expands it.
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The sidebar now defaults to collapsed for new users and storage errors. Explicit stored preferences remain supported. Unit, accessibility, smoke, tools, and hydration tests now reflect the updated state handling.

Changes

Sidebar default state

Layer / File(s) Summary
Set collapsed default
src/components/clinical-dashboard/use-sidebar-collapsed.ts
The hook exports the storage key and preference parser. Missing or unreadable preferences resolve to collapsed, and persistence uses the shared key.
Validate preference parsing
tests/sidebar-collapsed.test.ts
Tests cover missing, explicit, stale, and invalid values and verify the storage key.
Align UI state coverage
tests/ui-smoke.spec.ts, tests/ui-accessibility.spec.ts, tests/ui-tools-collapse.spec.ts, tests/ui-tools.spec.ts, tests/ui-hydration.spec.ts
Tests verify the collapsed desktop default, seed expanded state where required, scope sidebar controls, and document the hydration preference mismatch.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: making the desktop sidebar collapsed by default.
Description check ✅ Passed The description includes the required summary, verification results, risk, rollback, production effects, and a reason for skipping UI verification.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/sidebar-closed-default-i6n2fk

Comment @coderabbitai help to get the list of available commands.

@supabase

supabase Bot commented Aug 6, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project sjrfecxgysukkwxsowpy because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

CI triage

CI failed on this PR. Automated classification of the 2 failed job(s):

  • Production UI (3)needs investigation: inspect the failing step and uploaded diagnostics; rerun only after classifying the cause.
  • PR requiredneeds investigation: inspect the failing step and uploaded diagnostics; rerun only after classifying the cause.

Compared with main CI run #8427 (cancelled).

Classification is evidence routing, not permission to ignore a failure. Exact quarantined Playwright identities remain governed by the flake ledger.

#clinical-tools-sidebar only mounts when the sidebar is expanded, so
after flipping the default to collapsed the "defaults to collapsed"
test must assert the collapsed rail is visible and the expanded
panel is absent, not that the expanded panel is visible.
@BigSimmo
BigSimmo marked this pull request as ready for review August 6, 2026 13:02
devin-ai-integration[bot]

This comment was marked as resolved.

BigSimmo and others added 6 commits August 6, 2026 21:45
Tablet smoke must seed expanded so #clinical-tools-sidebar mounts and
toBeHidden() covers the display:none-below-lg path. Forced-colors a11y
must target the solid --command New chat in the expanded panel, not the
collapsed rail icon. Refresh the stale "default to labelled" comment.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
@cursor

cursor Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Review feedback dispositions (PR #1637)

Treating the sidebar-default PR (the earlier #1367 reference was a transposed number).

Finding Disposition Notes
Tablet #clinical-tools-sidebar toBeHidden() vacuous under collapsed default Fixed Seed clinical-kb-sidebar-collapsed="0" so the panel mounts and the lg:flex-only rule is actually exercised.
Forced-colors “New chat” sampled icon rail instead of solid --command button Fixed Seed expanded + scope locator to #clinical-tools-sidebar.
Settings helper already tolerates either sidebar state No change Correct observation; explains why only a few specs needed updates.
Stale “default to labelled” comment in account-setup journey Fixed Comment rewritten; explicit collapsed seed kept for journey clarity.
Server/client snapshots stay aligned (no hydration mismatch) No change Confirmed intentional; both sides flipped to true together.
Existing users with null preference silently flip to collapsed Accepted / documented Deliberate product choice for “closed by default on all devices.” Explicit "0"/"1" still win. Clarified in use-sidebar-collapsed.ts that never-toggled returning browsers also land on collapsed — there is no migration writing "0" for the old implicit expanded default. A migration would partially undo this PR’s goal.
Devin: verify:ui skipped before handoff Already resolved Prior Chromium Production UI green; test-hardening commits keep those journeys meaningful.
CI Production UI (3) / PR required red Infra flake Prior failure was GitHub Actions “Failed to resolve action download info / Service Unavailable” (Set up job), not a product assertion. Fresh CI re-triggered on the fix head.

cursoragent and others added 5 commits August 6, 2026 15:33
The storage key is only written after an explicit toggle, so absent means
collapsed for new users and never-toggled returning browsers alike.
Document that so the rollout note stays honest about who is unaffected.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Previous Production UI / Semgrep ingestion gate failures were Set up job
Service Unavailable / Bad Gateway while resolving action download info,
not product assertions. Empty commit to get a clean required check run.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Scope reduced-motion New chat clicks to the collapsed rail, seed the
hydration mismatch path with an expanded preference, and pin the
readSidebarCollapsedPreference default with a focused unit test.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
@BigSimmo

BigSimmo commented Aug 6, 2026

Copy link
Copy Markdown
Owner Author

Review feedback dispositions (follow-up)

Addressed the remaining coverage gaps after the earlier Bugbot/test-hardening pass, and synced the branch with origin/main (merge-tree clean).

Finding Disposition Notes
Reduced-motion a11y .first() New chat hazard Fixed (493b4f3f) Scoped clicks to getByLabel("Clinical Guide collapsed sidebar").getByRole("button", { name: "New chat" }) so the journey no longer depends on .first().
Hydration spec no longer exercised preference mismatch Fixed (493b4f3f) Seeded clinical-kb-sidebar-collapsed: "0" so the client preference differs from the collapsed SSR snapshot.
No unit coverage for the new default snapshot Fixed (493b4f3f) Extracted readSidebarCollapsedPreference and pinned absent / "0" / "1" / unexpected values in tests/sidebar-collapsed.test.ts.
Forced-colors solid-button sampling rail Already fixed Expanded seed + #clinical-tools-sidebar scope.
Stale “default to labelled” comment Already fixed Comment rewritten.
Settings helper tolerates either state No change Correct observation.
Tablet seed required for non-vacuous toBeHidden Already fixed Seed "0".
Server/client snapshots stay aligned No change Intentional.
Never-toggled users flip to collapsed Accepted / documented Deliberate product choice; no migration writing "0".
verify:ui skipped / Chromium risk Already resolved via CI Prior Production UI green; later reds were Actions “Failed to resolve action download info / Service Unavailable”, not product assertions.
Merge conflicts Cleared Merged origin/main at bf2159b6; merge-tree clean.

Validation: npx vitest run tests/sidebar-collapsed.test.ts — 5/5 passed; npm run testTest Files 514 passed (514), Tests 5434 passed | 4 skipped (5438); tsc --noEmit and eslint on touched files clean.

@cursor

cursor Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

CI status note

GitHub Actions is currently in a partial outage (status): recent reds on this PR (Production UI (3), Semgrep ingestion gate, PR Policy) failed at Set up job with Failed to resolve action download info / Service Unavailable — not product assertions.

Latest head bf2159b6 is re-queued. PR Policy already recovered green on retry. Waiting on the main CI aggregate to clear once Actions capacity returns.

GitHub Actions cancel returned 502 while Change scope stayed cancelled and
PR required queued indefinitely; push a tip bump so concurrency replaces it.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
@BigSimmo

BigSimmo commented Aug 6, 2026

Copy link
Copy Markdown
Owner Author

CI status note

Hosted Actions is currently degraded for this head:

  • Repeated Failed to resolve action download info / Service Unavailable on SAST / PR Policy set-up (not product assertions).
  • An earlier CI tip got stuck with Change scope cancelled and PR required queued indefinitely; actions/runs/.../cancel returned HTTP 502.
  • Tip bump 8fd65e80 was pushed to force concurrency replacement; Secret Scan / PR Policy / mergeability / CI are re-queued.

Product validation already green locally (npm run test → 5434 passed). No further code changes pending on the review findings.

@cursor

cursor Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Closeout status (head 8fd65e80)

Review findings

All actionable review items for the collapsed-default flip are addressed on this branch:

  • Tablet #clinical-tools-sidebar guard now seeds expanded so toBeHidden() is meaningful
  • Forced-colors + reduced-motion “New chat” locators scoped correctly (solid button / collapsed rail)
  • Stale “default to labelled” comment fixed
  • Null-preference silent flip accepted as intentional product behavior and documented in use-sidebar-collapsed.ts (+ unit coverage via readSidebarCollapsedPreference)
  • No unresolved review threads remain

CI

Blocked on a GitHub Actions major outage (Actions + Pages). Current queued/pending runs are not starting jobs; earlier reds were Set up job Service Unavailable / Bad Gateway, not product failures. Last known green Chromium Production UI on this PR was run 31107642228 against an earlier tip that already included the default flip.

Once Actions recovers, the pending CI on 8fd65e80 should be allowed to finish (or re-triggered with an empty commit / gh run rerun). No further product code changes needed for the review feedback.

@BigSimmo

BigSimmo commented Aug 6, 2026

Copy link
Copy Markdown
Owner Author

Babysit status (PR #1637)

Code / review: No remaining actionable work on the tip (8fd65e80).

  • Unresolved review threads: 0 (Devin verify:ui thread already replied + resolved).
  • Merge conflicts: none (mergeable: true, 0 commits behind main).
  • Prior product UI failure (#clinical-tools-sidebar still asserted visible for new users) was fixed earlier in f101a40c; later reds were Actions infra.

Local proof (this session):

  • npm run testTest Files 516 passed (516), Tests 5448 passed | 4 skipped (5452)
  • Focused Chromium journeys (collapsed default + seeds + a11y/hydration/tools): 9 passed
    • desktop sidebar defaults collapsed
    • mode sync / tablet rail / account setup
    • forced-colors New chat scoped to expanded panel
    • reduced-motion New chat scoped to collapsed rail
    • hydration mismatch seed ("0")
    • services home Expand sidebar

Hosted CI: blocked by GitHub Actions major outage (status). Current tip checks are stuck pending/queued; Secret Scan failure on this tip was Failed to resolve action download info / HTTP timeout at Set up job — not a leak finding. Will clear once Actions recovers and the queued CI/SAST/Policy runs finish (or are re-run).

No guardrailed merge/auto-merge/force-push performed.

@BigSimmo

BigSimmo commented Aug 6, 2026

Copy link
Copy Markdown
Owner Author

Babysit update

Partial Actions recovery on tip 8fd65e80:

  • ✅ PR Policy
  • ✅ PR mergeability
  • ✅ Secret Scan (retry after earlier Set-up-job timeout)
  • ⏳ CI + SAST still queued under GitHub Actions major outage

Still no unresolved review threads and no merge conflicts (0 behind main). Local unit + focused Chromium sidebar journeys remain green from the prior comment. No further code changes needed until hosted CI actually runs.

@BigSimmo
BigSimmo enabled auto-merge (squash) August 6, 2026 17:25
cursoragent and others added 2 commits August 6, 2026 19:34
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
@BigSimmo
BigSimmo merged commit 2f881ab into main Aug 7, 2026
25 checks passed
@BigSimmo
BigSimmo deleted the claude/sidebar-closed-default-i6n2fk branch August 7, 2026 02:37
cursor Bot pushed a commit that referenced this pull request Aug 7, 2026
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.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.

3 participants