Preserve SessionsList filters across screen switches#107
Conversation
|
Ox Agent seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
There was a problem hiding this comment.
Pull request overview
Moves SessionsList filter state (text, mode, scope) from local React useState into the Zustand session store so that filters persist when navigating away from and back to the sessions screen.
Changes:
- Added
filterText,filterMode,scopeModestate and their setters to the Zustand session store, along with asyncScopeModeWithRepohelper - Replaced local
useStatecalls inSessionsListwith the store equivalents and added auseEffectfor repo-aware scope syncing - Added store-level tests for the new filter and scope behavior
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/stores/sessionStore.ts | Added filter/scope state, types, and actions to Zustand store |
| src/stores/sessionStore.test.ts | Added tests for filter text, filter mode, and scope sync logic |
| src/components/SessionsList.tsx | Migrated from local state to store; added scope sync effect |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
src/components/SessionsList.tsx
Outdated
| setFilterText(filterText.slice(0, -1)); | ||
| // Don't reset selection when changing filter text - preserve selection if possible | ||
| return; | ||
| } | ||
|
|
||
| // Printable characters for filter | ||
| if (key.raw && key.raw.length === 1 && key.raw.match(/[a-zA-Z0-9-_./]/)) { | ||
| setFilterText((prev) => prev + key.raw); | ||
| setFilterText(filterText + key.raw); |
There was a problem hiding this comment.
I think this is a race condition that might lead to weird behavior if the event handlers run more frequently than the renders. We should preserve the callback function form, where the state provides the most recent prev value, rather than rely what the render closed over.
Summary
Testing