Repository navigation
🎛️ refactor: Pass the New-Chat Panel Preference Into the Sidebar - #16605
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
130a1d8 to
153e766
Compare
Both new-chat controls, the desktop rail's and the mobile drawer's, read newChatSwitchToHistory straight from the store. It is an app-global preference the sidebar only consumes, so the host (Root) reads it and passes it down, and the sidebar no longer reaches into the store for it.
153e766 to
9edd05f
Compare
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The refactor satisfies the state-ownership requirement and provides focused coverage without changing observable behavior.
Review effort: Balanced
Findings: None
What changed in this PR
Moves the new-chat panel preference to the sidebar’s host-owned interface, removing direct store access while preserving behavior.
Changes:
- Passes
switchToHistoryfromRootthrough desktop and mobile sidebar paths. - Removes Recoil preference reads from both new-chat controls.
- Adds unit and end-to-end coverage for enabled and disabled states.
| File | Description |
|---|---|
e2e/​specs/​mock/​scenarios/​new-chat-panel-preference.spec.ts |
Tests preference behavior on desktop and mobile. |
client/​src/​routes/​Root.tsx |
Reads and supplies the global preference. |
client/​src/​components/​UnifiedSidebar/​UnifiedSidebar.tsx |
Exposes and routes the preference prop. |
client/​src/​components/​UnifiedSidebar/​Sidebar.tsx |
Forwards the preference to the desktop panel. |
client/​src/​components/​UnifiedSidebar/​ExpandedPanel.tsx |
Uses the supplied preference for desktop new chat. |
client/​src/​components/​UnifiedSidebar/​mobile/​Header.tsx |
Forwards the preference to mobile new chat. |
client/​src/​components/​UnifiedSidebar/​mobile/​NewChat.tsx |
Uses the supplied preference instead of Recoil. |
client/​src/​components/​UnifiedSidebar/​__tests__/​ExpandedPanel.spec.tsx |
Updates desktop preference tests. |
client/​src/​components/​UnifiedSidebar/​__tests__/​drawerPaint.spec.tsx |
Updates sidebar test setup for the required prop. |
client/​src/​components/​UnifiedSidebar/​mobile/​__tests__/​Header.spec.tsx |
Updates mobile header test setup. |
client/​src/​components/​UnifiedSidebar/​mobile/​__tests__/​NewChat.spec.tsx |
Tests both mobile preference states. |
đź’ˇ Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Pull Request
Summary
The sidebar's two new-chat controls, the desktop rail's button and the mobile drawer's, each read the app-global "new chat returns to the chat list" preference (
newChatSwitchToHistory) straight from~/store. The sidebar only consumes that preference, so under the client state ownership rule it should be handed in by the host rather than reached for.Rootnow reads the preference and passes it toUnifiedSidebarasswitchToHistory, which hands it to the desktopExpandedPaneland the mobile drawer header. Neither new-chat control imports Recoil or the store any more. Behavior is unchanged: with the preference on, starting a chat from another panel brings the chat list back, and with it off the current panel stays.Fixes berry-13#214. Stacked on #16248, which adds the mobile drawer's new-chat control this changes.
Type of change
Testing
Tested environments/configuration:
Automated tests:
e2e/specs/mock/scenarios/new-chat-panel-preference.spec.ts: on desktop and in the mobile drawer, New chat from another panel returns to the chat list with the preference on and keeps the panel with it offnpx jest src/components/UnifiedSidebar(client): 10 suites, 56 tests pass, including the mobile control following the passed-in preference both waysnpx tsc --noEmit -p client/tsconfig.json: cleanScreenshots / recordings
No user-facing change.
Risk / compatibility
None. The stored preference, its default and its settings toggle are unchanged; only where the sidebar gets the value from changes.
Checklist