Skip to content

Preserve SessionsList filters across screen switches#107

Merged
murrayju merged 2 commits intomainfrom
ox/preserve-session-filters
Mar 16, 2026
Merged

Preserve SessionsList filters across screen switches#107
murrayju merged 2 commits intomainfrom
ox/preserve-session-filters

Conversation

@murrayju
Copy link
Member

Summary

  • move SessionsList filter text, filter mode, and scope mode into the Zustand session store
  • keep repo-aware scope initialization so switching screens does not reset the current filter state
  • add store tests covering the new filter and scope behavior

Testing

  • ./bun run check

Copilot AI review requested due to automatic review settings March 16, 2026 18:38
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


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.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, scopeMode state and their setters to the Zustand session store, along with a syncScopeModeWithRepo helper
  • Replaced local useState calls in SessionsList with the store equivalents and added a useEffect for 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.

Comment on lines +660 to +667
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);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@murrayju murrayju merged commit 1fe6f59 into main Mar 16, 2026
1 check passed
@murrayju murrayju deleted the ox/preserve-session-filters branch March 16, 2026 18:55
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