Fix left nav flashing open/shut with an artifact preview open - #514
Draft
clintoncodewell wants to merge 1 commit into
Draft
Fix left nav flashing open/shut with an artifact preview open#514clintoncodewell wants to merge 1 commit into
clintoncodewell wants to merge 1 commit into
Conversation
`onArtifactPreview` depended on `navCollapsed`, so its identity changed every time the nav did. RightRail lists that callback in the dependency array of the effect that reports whether a preview is open — so clicking expand changed the callback, re-ran the effect, and the effect called back with "the preview is still open", which collapsed the nav again. The nav flashed open and shut on every click and could not be opened at all while an artifact was previewed. Starting a new session cleared the preview and was the only way out, which is exactly the sequence reported. It reads through a ref now, so the callback identity is stable and the effect fires on the preview actually opening or closing rather than on an unrelated re-render. No test: the repo has no harness for App.tsx, and standing one up for a five-line change costs more than it protects. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J1uQkErvJK5uwUKDGpTFTe
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.
onArtifactPreviewdepended onnavCollapsed, so its identity changed everytime the nav did. The RightRail effect that reports whether a preview is
open lists that callback as a dependency, so expanding the nav changed the
callback, re-ran the effect, and the effect reported "preview is still
open" — which collapsed the nav again. The nav flashed open and shut on
every click and could not stay open while an artifact preview was up.
Starting a new session (which clears the preview) was the only workaround.
Fix: read
navCollapsedthrough a ref inside the callback instead ofdepending on it directly, so the callback's identity is stable across
re-renders and the effect only fires when the preview actually opens or
closes.
One file, 10 insertions / 2 deletions, no behavior change outside this path.
🤖 Generated with Claude Code