Repository navigation
Keep a graph's opening view while a new scope is laid out - #131
Open
agorischek wants to merge 3 commits into
Open
agorischek wants to merge 3 commits into
agorischek wants to merge 3 commits into
Conversation
A host draws every item, then sends its Changes scope with a focus on the changes. The graph lays the scope out in the background and meanwhile draws the old layout with the new props, so it framed the new scope's changes within the old drawing and zoomed it past its stage until the new layout arrived. GraphCanvas now marks that layout stale, and LaidOutGraph opens it on no focus: it stays fitted. The stage gains filter(), sending the host's filter message, so a harness spec can apply the Changes scope after the first paint. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
Clearing area during relayout drops an already-applied focus and causes a visible zoom jump; the committed focus should be retained while stale and covered by a regression test.
1 open issue
What changed in this PR
This PR addresses transient graph overflow when a host applies the Changes scope while its new layout is still pending.
Changes:
- Marks retained layouts as stale and defers focus-area calculation until the replacement layout arrives.
- Exposes host filter messages through the Inspector stage and testing APIs.
- Adds a browser regression test that records intermediate graph widths and zoom levels.
| File | Description |
|---|---|
packages/renderers/testing/src/types.ts |
Adds filter to StageApi. |
packages/renderers/testing/playwright/index.ts |
Exposes filter through the Playwright stage handle. |
packages/renderers/kit/src/react/graph-canvas/laid-out-graph.tsx |
Suppresses focus-area calculation for stale layouts. |
packages/renderers/kit/src/react/graph-canvas/drawing.ts |
Defines the optional stale-layout prop. |
packages/renderers/kit/src/react/graph-canvas/canvas.tsx |
Tracks and forwards layout staleness. |
packages/renderers/harness/browser/scope-opening.spec.ts |
Tests opening zoom and width during scope changes. |
packages/host/inspector/src/fixtures/stage.ts |
Forwards filter payloads to the renderer frame. |
packages/host/inspector/src/fixtures/session.ts |
Connects the stage API’s filter method. |
Review effort: Balanced
Comment on lines
72
to
80
| // A layout drawn while the current props are laid out may hold items the focus no longer names, or more: framing the | ||
| // focus within it would zoom the old drawing past its fit. It stays fitted until its own layout arrives. | ||
| const stale = props.stale === true | ||
| const area = useMemo( | ||
| () => (stale ? undefined : focusArea(transition, diff, props.model, request, shown)), | ||
| [stale, transition, diff, props.model, request, shown], | ||
| ) | ||
| const drawn = nodes.map(node => ({x: node.x - node.width / 2, y: node.y - node.height / 2, width: node.width, height: node.height})) | ||
| const {zoom, scale, borders, keep} = useGraphZoom(scroller, framing, bounds, props.onAction, {area, request}, orientation, drawn, hold) |
This branch has not been deployed
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.

A graph zoomed past its stage for a moment as it opened in a host that applies the Changes scope, and a check that measured in that moment saw it scroll sideways. The hosted gallery's WebKit test caught it:
div.graph-scroll 975>748 (scale 0.923, zoom 1.317655, width 1022).Why it happened
filterwith the Changes scope. That brings a focus request on the changes ({on: 'changes'}).GraphCanvaslays the new scope out in the background, and meanwhile draws the old layout with the new props.LaidOutGraphtherefore computedfocusAreafor the new scope's changes inside the old drawing.focusOpeningthen framed them at full size: zoom = 0.923 / 0.700, and a 1022-unit drawing in a 748px stage.Fix
GraphCanvaspassesstalewhile it draws a layout made for earlier props.LaidOutGraphtakes no focus area while the layout is stale, so the old layout keeps its fitted opening. The focus applies once the scope's own layout is drawn.Test
filter(payload), which sends the host'sfiltermessage (StageApi,StageHandle, the Inspector's stage).harness/browser/scope-opening.spec.tsopensgraph/platform-workerin diff mode at 520px, where everything fits below full size. It records every view the frame commits, through a MutationObserver inside it, then sends the Changes scope.Verified locally
tools check --fast(typecheck included) andtools test packages/renderers/kitpass.