Repository navigation
Plan the VS Code UI's toolbar with the shared fit plan - #109
Merged
Merged
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Repeated region changes exhaust the replanning budget, potentially leaving the toolbar unnecessarily collapsed or overflowing even when a cached plan fits.
1 open issue
What changed in this PR
Moves the VS Code UI’s responsive toolbar onto host core’s shared useFitPlan, continuing #106’s consolidation while keeping UI-specific layout rules and measurements.
Changes:
- Extends the shared hook with cache shifting and carrying, width-dependent keys, pending-render measurement, and custom region and focus handling.
- Removes duplicated VS Code toolbar lifecycle logic while preserving its steps and 32px hysteresis.
- Updates unit tests and package documentation for the shared implementation.
| File | Description |
|---|---|
packages/host/vscode-ui/test/toolbar-steps.test.mjs |
Replaces carry-step tests with step-location coverage. |
packages/host/vscode-ui/src/layout/use-toolbar-layout.ts |
Delegates layout lifecycle to useFitPlan. |
packages/host/vscode-ui/src/layout/steps.ts |
Adds locateStep and removes duplicated choosing and carrying logic. |
packages/host/vscode-ui/src/layout/focus.ts |
Deletes the UI-specific focus-follow hook. |
packages/host/vscode-ui/README.md |
Documents shared toolbar planning. |
packages/host/core/test/fit-plan.test.mjs |
Tests measurement carrying and shifting. |
packages/host/core/src/fit-plan/needs.ts |
Adds shared measurement-cache helpers. |
packages/host/core/src/fit-plan/focus.ts |
Supports custom focus restoration. |
packages/host/core/src/fit-plan.ts |
Adds migration options and preserves plans for hidden bars. |
Review effort: Balanced
agorischek
force-pushed
the
review-f15-headless-fit-plan
branch
from
November 21, 2026 15:33
9cecdc4 to
3d438ed
Compare
agorischek
force-pushed
the
vscode-ui-shared-fit-plan
branch
from
November 21, 2026 15:33
d674cbf to
bae99c8
Compare
agorischek
force-pushed
the
review-f15-headless-fit-plan
branch
from
November 21, 2026 16:17
3d438ed to
b47beb3
Compare
agorischek
force-pushed
the
vscode-ui-shared-fit-plan
branch
from
November 21, 2026 16:17
bae99c8 to
822dba4
Compare
The VS Code UI's own measurement cache, step choice, resize observers and focus follow give way to the host core's `useFitPlan`. Its steps, measurement and 32px hysteresis stay its own; the shared hook gains the options its algorithm (and Primer's) needs: needs shifted alike on new content (`shiftNeeds`), needs carried to a new collapse order (`carry`), a need shared between plans (`need`), a width-dependent `key`, custom elements still rendering (`pending`), the observed `regions` and `focusControl`. A bar without width keeps its plan. Content that settles is a `rendered` event of `fitPlanLifecycle`: it measures again, unless a replan already waits for a press to be released. The VS Code UI's toolbar hook no longer starts a timer, so its lifecycle baseline drops to none. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Only switches between measured plans count towards the burst that bounds oscillation, not settles. A region that isn't as wide as when the bar settled, or content that finished rendering (`pending`), starts a new burst, so repeated notices at one width and content key can still replan; resize notifications from the plan the bar settled on leave the regions as wide as they were and keep the bound. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
agorischek
force-pushed
the
vscode-ui-shared-fit-plan
branch
from
November 21, 2026 17:38
822dba4 to
93e1215
Compare
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.

Stacked on #106 (base
review-f15-headless-fit-plan). Follow-up to code review, finding 15 ("Responsive toolbar machinery has forked across UI layers"): the public VS Code UI had a third copy of the toolbar layout machinery, so this moves it onto the shared fit plan.What moved
packages/host/vscode-ui/src/layout/kept its own copy of:use-toolbar-layout.tsnow callsuseFitPlanfrom@githubnext/projections-host.focus.tsis deleted, andchooseandcarryStepare gone fromsteps.ts. Neither was exported from the package.What stays UI-owned
toolbarSteps),rowForm, and the newlocateStep.locateStepreturns the step itself, else the first step with the same row 1 form, else the first step; that is the step half of the oldcarryStep.requiredWidth, with its centred-row and second-row needs).toolbarHysteresis.focusFallbackstable andfocusControl, which reaches through shadow roots.Options the shared hook gains
The VS Code UI and Primer share the same algorithm, so these options let either express it:
keymay be a function of the widthwidth < narrowToolbarWidth): the slider's minimum drops below 480pxshiftNeedsstaleflag: a new key, a resized region or a settledpendingkeeps the needs and moves them all by the shown plan's changecarry(plan)carryStep: a new set of plans takes the needs of the previous plans with the same carry key (rowForm); if the shown plan's key is gone, everything is measured againneed(plan, measured)rowNeed: two-row inline steps usemax(own, rowNeed), and an unknownrowNeedtries the steppending(element)updateCompletere-measureregions(selector, default[data-toolbar-region]):scope > .phv-toolbar-start)focusControlfocusControlin focus followPrimer can use
shiftNeeds,needand the width-dependentkeyfor its stale/narrow shifting and itsrowNeed. That closes the one difference called out in #106's follow-up.Behaviour
The steps chosen at rest are the same.
The shared lifecycle brings a few deliberate differences:
data-fit-settled.Two sub-pixel or transient differences:
The bound on oscillation now counts only switches between measured plans, not settles. A region whose width differs from what it was when the bar settled, or a settled
pending, starts a new burst, so repeated notices at one width can still replan (from review). This applies to every bar.The default UI passes none of the new options, so it behaves as in #106 apart from the zero-width rule.
Tests
packages/host/core/test/fit-plan.test.mjs: a new case covers needs carried by key (and not carried when the shown plan's form is gone), and needs shifted alike when the shown plan measures differently.packages/host/vscode-ui/test/toolbar-steps.test.mjs: thecarryStepcases now coverlocateStep. Playback coming or going keeps row 1's form and goes back again, a step stays itself in its own order, and the first step is used when the form is gone.tools check --fastpassed.tscpassed for host/core and vscode-ui, src and browser tsconfigs.node --testpassed: host/corefit-planandtoolbar-layout9/9, vscode-ui all 25/25.tools build, because it would build the engine's Rust/Wasm. The browser suites (vscode-ui'svscode.spec.tsfocus checks, Storybook smoke) run in CI.State machine
This is rebased on #106, which now runs the fit plan's lifecycle as
fitPlanLifecycle, built on@githubnext/projections-machine. The new options fit into it:pendingcontent that settles sends arenderedevent, which measures again (a new run). It is ignored while a replan already waits for a press to be released, since the release measures again anyway. Its staleness guard (keyor the plans changed) is unchanged.d674cbf's fresh burst compares against are recorded as the hook sendsfitted.use-toolbar-layout.tsno longer starts a timer, so its lifecycle baseline drops from 1 to none (check-machines.mjs --update).toolbar-steps.test.mjskeeps main'scentre: truefixtures with this PR'slocateStepassertions.Queue
#58, #65 and #77 have merged. This PR is rebased on #106, which is rebased on main, and merges after #106. It stays out of
packages/host/core/src/ui/toolbar-layout.tsanddocs/guides/host-core.md; the new options are documented in TSDoc only.