(MOT-4518) feat(console): replay workspace writes made before hydration - #861
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
skill-check — worker0 verified, 62 skipped (no docs/).
Four for four. Nicely done. |
e984169 to
9c45b7b
Compare
9290133 to
783be0f
Compare
* feat(console): deep-link opens a screen beside chat, not a bare tab * (MOT-4518) feat(console): replay workspace writes made before hydration (#861) * (MOT-4517) test(console): pin replay-vs-deep-link write ordering The review's race was real on the pre-merge branch, where the pending layout replay went through an unserialized whole-configuration write and could interleave with a deep link's openScreen. The merge already routes both through the serialized writer as transforms; this pins that contract: both orders keep both intents, and several pre-hydration writes compose instead of last-snapshot-wins. The workspace transform seam is exported for the test.
Why
useWorkspaceTabshands out the localStorage copy of the layout before the first server answer arrives, then swaps to the server layout. A mutation in that window — aworkspace.createkeyboard shortcut, a worker's panel-open, a tab click — writes against the local copy and is discarded when the server value lands. #843 guarded the two hash effects with alayoutSourceflag, but the hook still let every other consumer mutate the soon-to-be-replaced copy.What
The hook now holds a pre-hydration write and replays it. While
layoutSource === 'pending',persistrecords the intended{ tabs, activeTabId }and updates the local view for immediate paint, but does not commit. When the source leavespending(server hydrated, or known unavailable), an effect flushes the held write through the normalpersistpath — a server read-modify-write when the configuration worker is reachable, localStorage otherwise. The flush decision is a pureshouldFlushPendingWrite(source, hasPending)with its own test.The per-effect
layoutSourceguards inApp.tsxare left in place; this change is additive and covers the consumers those guards do not (shortcuts, panel-open, TabStrip), without touching the hash state machine.Verification
tsc -b, biome, vitest 1470 (new:shouldFlushPendingWritetruth table).Stacked on #860 → #843. Merge those first.
Linear: MOT-4518