Skip to content

Fix left nav flashing open/shut with an artifact preview open - #514

Draft
clintoncodewell wants to merge 1 commit into
andrewyng:mainfrom
clintoncodewell:fix/nav-flash-artifact-preview
Draft

Fix left nav flashing open/shut with an artifact preview open#514
clintoncodewell wants to merge 1 commit into
andrewyng:mainfrom
clintoncodewell:fix/nav-flash-artifact-preview

Conversation

@clintoncodewell

Copy link
Copy Markdown

onArtifactPreview depended on navCollapsed, so its identity changed every
time 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 navCollapsed through a ref inside the callback instead of
depending 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

`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
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.

1 participant