SY-4174: Make windowKey Optional in Nav Drawer Actions#2313
Merged
emilbon99 merged 5 commits intoMay 13, 2026
Conversation
Make `windowKey` optional on `setNavDrawerVisible`. A new layout middleware fills it in from drift state when the call site omits it, so consumers no longer need to call `useSelectWindowKey()` and thread it through `useCallback` deps. Drops the boilerplate from Editor, LinePlot, Log, Schematic, and Table. The reducer still throws if a windowKey isn't present at the time it runs.
Codecov Report❌ Patch coverage is ❌ Your patch check has failed because the patch coverage (21.42%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## rc #2313 +/- ##
==========================================
+ Coverage 64.97% 65.07% +0.10%
==========================================
Files 2603 2603
Lines 113946 113826 -120
Branches 8399 8374 -25
==========================================
+ Hits 74035 74073 +38
+ Misses 33774 33640 -134
+ Partials 6137 6113 -24
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
pjdotson
approved these changes
May 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue Pull Request
Linear Issue
SY-4174
Description
Removes the boilerplate of selecting
windowKeyat every call site that dispatchessetNavDrawerVisible. A newinjectNavDrawerWindowKeylayout middleware reads the current window key from drift state and injects it into the action payload when the caller omits one. The reducer still throws if awindowKeyis missing by the time it runs, so the invariant is preserved.Cleans up the
useSelectWindowKey()lookup, theas stringcast, and the correspondinguseCallbackdep at five consumers:arc/editor/graph/Editor.tsx,lineplot/LinePlot.tsx,log/Log.tsx,schematic/Schematic.tsx, andtable/Table.tsx. Call sites that intentionally target a non-current window (e.g.useNavDrawer.ts,nav/useTriggers.ts,layouts/nav/Menu.tsx) keep their explicitwindowKeyand are unaffected.Basic Readiness
Greptile Summary
This PR eliminates repetitive
useSelectWindowKey()boilerplate from five layout renderers by introducing aninjectNavDrawerWindowKeyRedux middleware that reads the current window key from Drift state and injects it intosetNavDrawerVisibleactions that omit one. The reducer retains its guard and throws if awindowKeystill arrives missing.console/src/layout/middleware.ts: NewinjectNavDrawerWindowKeymiddleware added as the first entry inMIDDLEWARE; it short-circuits on matching actions that already carry awindowKey.console/src/layout/slice.ts:SetNavDrawerVisiblePayload.windowKeymade optional (?); reducer throwsUnexpectedErrorif the key is absent after middleware runs.console/src/layout/slice.spec.ts: Comprehensive new test file covering the reducer, nav drawer actions, mosaic operations, and workspace management (no middleware integration test included).Confidence Score: 5/5
Safe to merge; the middleware correctly injects window key for the five consumers and call sites that already carry an explicit windowKey are untouched.
The change is well-scoped: a single middleware intercepts one action type, the reducer retains its invariant guard, and five consumers are simplified in a uniform way. Call sites that intentionally target non-current windows keep their explicit windowKey and are unaffected.
No files require special attention beyond the optional middleware integration test gap noted in slice.spec.ts.
Important Files Changed
Sequence Diagram
sequenceDiagram participant C as Component (e.g. LinePlot) participant M as injectNavDrawerWindowKey Middleware participant D as Drift State participant R as Layout Reducer C->>M: dispatch setNavDrawerVisible without windowKey M->>M: Check if windowKey is absent M->>D: selectWindowKey from store state D-->>M: returns current windowKey M->>R: forward action with injected windowKey R->>R: Update nav drawer state note over M,R: If Drift returns null, the unmodified action is forwarded and the reducer throws UnexpectedErrorReviews (5): Last reviewed commit: "Use exported action creators directly in..." | Re-trigger Greptile