Skip to content

fix(ui): sidebar sort selection is forgotten after a reload - #124277

Merged
vyctorbrzezowski merged 1 commit into
mainfrom
brzezowski/sidebar-sort-persist
Aug 15, 2026
Merged

vyctorbrzezowski merged 1 commit into
mainfrom
brzezowski/sidebar-sort-persist

Conversation

@vyctorbrzezowski

Copy link
Copy Markdown
Member

Fixes #124273

What Problem This Solves

Fixes an issue where users who pick a sessions-sidebar sort order would silently lose that choice on the next page load. Selecting "Last updated" (or People) in the sidebar's "Sort sessions" menu reorders rows immediately, but the selection is dropped on reload and the sidebar returns to "Created" ordering.

Every other preference in the same sidebar — grouping, Show cron, Show system, the archived/active filter, collapsed sections, and hidden catalogs — already survives a reload, so the sort control was the one odd surface that forgot what the user asked for. Because the revert is silent, the sidebar can look like it is ignoring recent activity when the user believes they already opted into activity-first ordering.

Why This Change Was Made

The sort mode is now stored under openclaw:sidebar:sessions:sort-mode and read back when the sidebar initializes, using the same localStorage load/store pair and openclaw:sidebar:sessions:* key namespace the sibling preferences already use. No new persistence path was introduced, and no migration is needed: the key is new, and its absence resolves to the existing default.

The default is deliberately unchanged. A fresh profile still starts on "Created", which remains the intended stable ordering; this change only makes an explicit user choice durable.

Two smaller decisions worth calling out for reviewers:

  • The "People" mode is only collapsed to "Created" when the gateway has authoritatively denied the capability. That rule previously existed twice, in slightly different forms, in the render path and the setter. It now lives in one shared resolveSidebarSessionSortMode helper, so a reconnect that temporarily hides the capability still cannot persist a downgrade the user never asked for.
  • The storage write is guarded once inside the store helper rather than at each call site, so a browser with storage disabled keeps the in-memory preference instead of throwing.

Consolidating that duplicated resolution is what kept app-sidebar-session-navigation.ts net-neutral in lines; it sits exactly at the 700-line lint ceiling, and no max-lines suppression was added.

Non-goal: this PR does not change how sessions are ordered, and does not touch the recency machinery. That path already works — updatedAt is stamped at turn admission in src/gateway/server-methods/agent-session-patch.ts, projected in src/gateway/session-utils-row.ts, carried on the live change event, and consumed by compareSessionRowsByUpdatedAt. When "Last updated" is selected, a session that receives a new turn already moves to the top. The only gap being closed here is that the user's choice did not survive a reload.

User Impact

Pick a sidebar sort order once and it stays. Users who prefer activity-first ordering can select "Last updated" and keep it across reloads and restarts instead of re-applying it every session.

Existing users are unaffected until they change the setting: with no stored value, the sidebar behaves exactly as it does today.

Evidence

Regression test fails before the fix and passes after. Verified by stashing only the two production files and re-running the same test:

# pre-fix (production changes stashed)
$ node scripts/run-vitest.mjs ui/src/components/app-sidebar.test.ts -t "restores the selected sort mode"
 - Expected: "updated"
 + Received: null
   Tests  1 failed | 261 skipped (262)

# post-fix
$ node scripts/run-vitest.mjs ui/src/components/app-sidebar.test.ts
   Tests  262 passed (262)

The component-level case mounts the sidebar, selects "Last updated", tears the element down, and remounts it — the remount is what a reload does to this element — then asserts the mode stuck. Store-layer coverage in app-sidebar-session-types.test.ts adds the default-on-unknown-value case and the gateway-denied People case:

$ node scripts/run-vitest.mjs ui/src/components/app-sidebar-session-types.test.ts
   Tests  8 passed (8)

Changed-files gate green, including UI typecheck, core test typecheck, lint, formatting, and the max-lines ratchet:

$ node scripts/check-changed.mjs -- <the four changed files>
exit=0

Pre-commit review (autoreview --mode uncommitted) reported no accepted or actionable findings.

LOC delta: production is +32 in app-sidebar-session-types.ts (storage key, load, resolve, and store helpers, including doc comments) and net 0 in app-sidebar-session-navigation.ts, where the deduplicated resolution paid for the new wiring. Tests are +47 across two files.

The sessions sidebar held its sort mode in component state only, so a
reload silently reverted the user's Created/Last updated/People choice
back to Created while every sibling sidebar preference persisted.

Store the mode under openclaw:sidebar:sessions:sort-mode alongside the
existing sidebar preference keys and read it back at init. Resolution of
a gateway-denied People sort now lives in one helper shared by the render
path and the setter, keeping the element net-neutral in lines.
@clawsweeper

clawsweeper Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: S maintainer Maintainer-authored PR labels Aug 15, 2026
@vyctorbrzezowski
vyctorbrzezowski marked this pull request as ready for review August 15, 2026 20:43
@vyctorbrzezowski vyctorbrzezowski self-assigned this Aug 15, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 15, 2026
@clawsweeper

clawsweeper Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 15, 2026, 4:50 PM ET / 20:50 UTC.

ClawSweeper review

What this changes

The PR saves the Control UI sidebar session-sort choice in browser storage and restores it when the sidebar is mounted again.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep open: current main still resets the sidebar sort on remount, and the focused owner-boundary repair appears correct; required real Control UI proof is still absent. Likely related people: steipete (feature history, high confidence) and Ayaan Zaidi (current-line provenance, medium confidence).

Priority: P3
Reviewed head: c8c2a31a33d5f31106e2e339b0b2606d9965e5e6
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) PR readiness rating was derived from proof quality, review findings, security review, and reviewer confidence.
Proof confidence 🌊 off-meta tidepool Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.
Evidence reviewed 7 items Current-main defect: Current main initializes the sort to Created and its setter only changes component state, while adjacent sidebar preferences load from browser storage.
Caller and ordering boundary: The menu delegates sort selection to the setter, and the central comparator consumes the effective mode; the PR does not alter ordering semantics.
Proposed owner-boundary repair: The PR loads a validated stored mode at initialization and writes the resolved mode from the existing setter path, preserving the default when the key is absent.
Findings None None.
Security None None.

How this fits together

The Control UI sidebar receives session rows from the gateway, applies the selected sort mode, and renders the session list. This change makes that UI-only preference survive a reload without changing session ordering or gateway data.

flowchart LR
A[User chooses session sort] --> B[Sidebar menu]
B --> C[Sidebar navigation state]
C --> D[Browser preference storage]
D --> E[Sidebar remount]
E --> F[Sorted session list]
Loading

Decision needed

Question Recommendation
Should this maintainer-authored Control UI repair land after the required real reload proof is attached? Require reload proof: Attach a sanitized screenshot or short video showing a chosen sort mode before and after a Control UI reload, then complete normal exact-head review.

Why: The patch is source-correct, but the protected maintainer item and repository UI-proof policy require a human maintainer to assess the real running surface.

Before merge

  • Resolve merge risk (P1) - No sanitized screenshot or short video from a real Control UI reload is attached, despite repository policy requiring it for user-visible UI changes.
  • Resolve merge risk (P1) - The bug fix adds 32 production lines; the validated preference owner and shared capability resolver justify the growth, but real UI proof should confirm the added persistence path.
  • Complete next step (P2) - Attach the required real UI reload proof, then let a maintainer complete review of this protected maintainer item.
Agent review details

Security

None.

PR surface

Source +57, Tests +22. Total +79 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 3 63 6 +57
Tests 1 22 0 +22
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 85 6 +79

Review metrics

Metric Value Why it matters
Production vs test delta production +32, tests +47 The new preference load/store path adds production code while the navigation file remains net-neutral; tests cover storage normalization and remount restoration.

Stored data model

Persistent data-model change detected: serialized state: ui/src/components/app-sidebar-session-types.test.ts, serialized state: ui/src/test-helpers/app-sidebar-cases/sessions.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #124273
Summary: This PR is the linked candidate fix for the canonical report of the same remount-persistence defect.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep persistence in the existing sidebar preference owner, retain Created as the absent-key default, and land after a sanitized real Control UI selection-and-reload proof.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep persistence in the existing sidebar preference owner, retain Created as the absent-key default, and land after a sanitized real Control UI selection-and-reload proof.

Do we have a high-confidence way to reproduce the issue?

Yes—current main initializes the mode to Created and only mutates memory, while the menu delegates directly to that setter. The proposed remount regression test is source-reproducible but was not executed in this read-only review.

Is this the best way to solve the issue?

Yes—the patch uses the existing sidebar browser-preference boundary, validates stored values, keeps the current default, and centralizes the pre-existing People capability rule without changing ordering behavior.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 37763e4d7ef8.

Labels

Label changes:

  • add P3: This is a low-blast-radius Control UI preference persistence repair with no change to session ordering or gateway behavior.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.

Label justifications:

  • P3: This is a low-blast-radius Control UI preference persistence repair with no change to session ordering or gateway behavior.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.

Evidence

What I checked:

Likely related people:

  • steipete: Authored the merged People session-sorting feature that established the affected sidebar behavior. (role: feature author; confidence: high; commits: e0262e6aa4a6; files: ui/src/components/app-sidebar-session-navigation.ts, ui/src/components/app-sidebar-session-types.ts)
  • Ayaan Zaidi: Current-main blame assigns the sort initialization and capability-resolution lines to this snapshot commit; earlier detailed provenance is partially unavailable in the sparse checkout. (role: current-line provenance contributor; confidence: medium; commits: f7b809933d69; files: ui/src/components/app-sidebar-session-navigation.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@vyctorbrzezowski
vyctorbrzezowski merged commit 9455286 into main Aug 15, 2026
223 checks passed
@vyctorbrzezowski
vyctorbrzezowski deleted the brzezowski/sidebar-sort-persist branch August 15, 2026 22:57
@vyctorbrzezowski

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 16, 2026
The sessions sidebar held its sort mode in component state only, so a
reload silently reverted the user's Created/Last updated/People choice
back to Created while every sibling sidebar preference persisted.

Store the mode under openclaw:sidebar:sessions:sort-mode alongside the
existing sidebar preference keys and read it back at init. Resolution of
a gateway-denied People sort now lives in one helper shared by the render
path and the setter, keeping the element net-neutral in lines.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Control UI sidebar sort selection does not persist across reloads

1 participant