Skip to content

Client: Let a branch be switched from the client - #2300

Merged
marcoroth merged 2 commits into
mainfrom
dev-tools/slot-flash-css
Aug 19, 2026
Merged

Client: Let a branch be switched from the client#2300
marcoroth merged 2 commits into
mainfrom
dev-tools/slot-flash-css

Conversation

@marcoroth

Copy link
Copy Markdown
Owner

Follow up on #2299, which fixed the slot flash drawing nothing. With it drawing again, two things it was hiding became visible.

The first is that a branch swap never reports itself as one. #writeFragment is the only code that announces a branch operation, and its one caller is apply, so a server payload is the only thing that has ever reached it. materialize hands back a fragment and there was nothing public to install one, so a page that flips a branch on its own has to do the work by hand.

switchBranch is what #applyBranch does with the payload taken away.

The only code that reports a branch change is `#writeFragment`, and its one
caller is `apply`, so a server payload is the only thing that ever reached it.
`materialize` hands back a fragment and there was nothing public to install one,
so a page that flips a branch on its own has to do the work by hand, with
`update`, `rangeFor().insertNode` and `scan`. That works, and it reports a value
write, because `update` is what announced it. Anything watching slot updates,
the dev tools flash included, then paints a branch swap the same colour as a
number changing, and the `branch` colour it defines is unreachable.

`switchBranch` is what `#applyBranch` does with the payload taken away. It parks
what is on the page before replacing it, so going back the other way needs
nothing new, builds the branch it was asked for, and announces it as a branch. It
answers `false` without touching the page when the branch asked for is already
the one showing, or when it was never parked, which is the case that still has to
go to the server.
@marcoroth marcoroth added the reactivity Reactive ERB templates: diff and re-render only what changed label Aug 19, 2026
@github-actions github-actions Bot added typescript TypeScript source across the javascript/ packages dev-tools @herb-tools/dev-tools visual debugging for HTML+ERB templates client-runtime Browser runtime for the Herb slots. labels Aug 19, 2026
@nx-cloud

nx-cloud Bot commented Aug 19, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 3c473ee

Command Status Duration Result
nx run-many -t test --all --parallel --exclude=... ✅ Succeeded 3m 6s View ↗
nx run-many -t build --all --exclude=herb-langu... ✅ Succeeded 17s View ↗
nx build @herb-tools/tailwind-class-sorter ✅ Succeeded 1s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-08-19 19:21:48 UTC

@github-actions

github-actions Bot commented Aug 19, 2026

Copy link
Copy Markdown

🌿 Interactive Playground and Documentation Preview

A preview deployment has been built for this pull request. Try out the changes live in the interactive playground:


🌱 Grown from commit 3c473ee


✅ Preview deployment has been cleaned up.

@pkg-pr-new

pkg-pr-new Bot commented Aug 19, 2026

Copy link
Copy Markdown
@herb-tools/client

npx https://pkg.pr.new/@herb-tools/client@2300

@herb-tools/core

npx https://pkg.pr.new/@herb-tools/core@2300

@herb-tools/dev-tools

npx https://pkg.pr.new/@herb-tools/dev-tools@2300

@herb-tools/formatter

npx https://pkg.pr.new/@herb-tools/formatter@2300

@herb-tools/language-server

npx https://pkg.pr.new/@herb-tools/language-server@2300

@herb-tools/linter

npx https://pkg.pr.new/@herb-tools/linter@2300

commit: 3c473ee

@marcoroth
marcoroth merged commit 8be641c into main Aug 19, 2026
23 checks passed
@marcoroth
marcoroth deleted the dev-tools/slot-flash-css branch August 19, 2026 19:25
marcoroth added a commit that referenced this pull request Aug 19, 2026
Follow up on #2299 and #2300. With the flash drawing again, and telling
a branch swap apart from a value write, what it says about collections
is the part still worth fixing.

An `item-added` drew over the wrong row. `#buildItem` inserts a new item
in front of the first one already there and announces it from that
position, and the index puts it in its real place afterwards, so the
flash was drawing where the item was at that instant instead of where it
ended up. On the inline-edit table that is the first row every time,
whichever row was actually added.

Measuring on the next task reads the position after the whole batch has
settled, ordering included. A microtask is not enough, since the
reordering runs in the same task as the announcement.

An item on its way out is the one case that cannot wait. `#dropItem`
announces before it deletes the range, so a removal is still measured
while its markers are in the document. That is the only operation left
drawing synchronously.

This also gets a nested slot inside a freshly built row off measuring
zero by zero, since a slot in a row that has not been placed yet has no
box.

An item update now also outlines the collection it belongs to, dashed
and unfilled so it never competes with what is drawn inside it, in the
color of the operation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

client-runtime Browser runtime for the Herb slots. dev-tools @herb-tools/dev-tools visual debugging for HTML+ERB templates reactivity Reactive ERB templates: diff and re-render only what changed typescript TypeScript source across the javascript/ packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant