-
Notifications
You must be signed in to change notification settings - Fork 3.8k
fix(studio): keep the preview alive when the window is tight #3091
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import { describe, expect, it } from "vitest"; | ||
| import { shouldOpenInspector } from "./StudioHeader"; | ||
|
|
||
| describe("shouldOpenInspector", () => { | ||
| it("opens when the panel is hidden", () => { | ||
| expect(shouldOpenInspector(true, false)).toBe(true); | ||
| }); | ||
|
|
||
| it("opens when a non-inspector tab is showing", () => { | ||
| expect(shouldOpenInspector(false, false)).toBe(true); | ||
| }); | ||
|
|
||
| it("closes when the inspector is genuinely on screen", () => { | ||
| expect(shouldOpenInspector(false, true)).toBe(false); | ||
| }); | ||
|
|
||
| it("opens when the window railed the panel away", () => { | ||
| // The regression this guards: the button used to branch on the raw | ||
| // rightCollapsed intent, which is still `false` while the window has the | ||
| // panel railed. That took the close branch, wrote rightCollapsed=true, and | ||
| // since that value is synced into the shareable Studio URL, a click that | ||
| // did nothing visible rewrote the link. | ||
| const userIntentIsOpen = false; | ||
| const windowRailedItAway = true; | ||
| expect(shouldOpenInspector(windowRailedItAway, true)).toBe(true); | ||
| expect(shouldOpenInspector(userIntentIsOpen, true)).toBe(false); | ||
| }); | ||
| }); |
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Concern — timeline height is asymmetric with panel widths: shrink-then-grow forgets the user's preferred height.
Widths are stored as
preferredWidthsstate,fitPanelWidthsreads them fresh on every render, and the fitted output is never persisted-back — so a temporary squeeze narrows the rendered value while the preferred survives, and the width returns when the window grows (asserted atusePanelLayout.test.ts:201). Heights don't have that:timelineHstate is the preferred value, and the ResizeObserver here overwritesprevwith the fitted result viasetTimelineH((prev) => fitTimelineHeight(containerH, prev)).Repro: user loads Studio at 760 tall, timeline preference 429. Drags window to 520 tall →
fitTimelineHeight(400, 429) = 200,timelineH = 200. Drags back to 760 →fitTimelineHeight(640, 200) = 200, timeline stays at 200. The user's real preference (429) is now unrecoverable within this session without manual drag. localStorage still says 429 (persistTimelineHisn't called fromreconcile, correct), so a reload restores it — but any within-session narrow trip loses it.The PR-body contract for widths — "a real preference survives a temporary squeeze and returns when the window grows" — doesn't hold for the height axis. Given how deliberately the width axis was structured to guarantee this, the divergence feels accidental rather than intended.
Suggested shape, mirroring the width axis:
Then
TimelineResizeDivider's drag/keyboard paths setpreferredTimelineH(rather thantimelineH), andpersistTimelineHwritespreferredTimelineH. Same idempotence guarantee asfitPanelWidths— the observer never triggers a state change unless the container height itself changes.Non-blocking; the current shape is a strict improvement over the mount-only clamp, and no user-visible break is worse than the pre-PR 47px preview. Naming it because the design contract diverges and it's a small refactor to close.
— Review by Rames D Jusso