Skip to content

fix(patch-db,marketplace): keep unchanged subtrees across updates; open the service preview immediately - #4945

Merged
helix-red merged 4 commits into
masterfrom
fix/marketplace-preview-opens-immediately
Nov 26, 2026
Merged

helix-red merged 4 commits into
masterfrom
fix/marketplace-preview-opens-immediately

Conversation

@helix-red

@helix-red helix-red commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Clicking a service in the Marketplace now opens its side drawer within a frame. The drawer immediately shows what the registry listing already holds: icon, title, version, release date, git hash, signers, release notes and other flavors. Skeletons stand in for the SDK version, license, description and install button until the full release arrives.

The underlying fix is in the patch-db TypeScript client, so it applies to every StartOS screen, not just the marketplace. Updates now keep the identity of every subtree they leave unchanged, and a watch is notified only when its value is actually a new object.

Implementation diff: +325 / −115 lines in 9 files (excludes lockfiles, tests, docs, release notes, and changelog).

Cause. Opening a preview subscribes to a PatchDB projection of that package's full release (a projection is a filtered view of part of the document). SubtreePatchDB then synchronously re-projected the entire local replica and re-read every watched node, before the drawer could paint. It did this even though the selection only grew, and it re-emitted all ~100 listings, so every tile re-rendered. A CPU profile on a master VM with the Start9 registry put about 156ms of a 185ms click task there.

The client repeated the same mistake in several other places:

  • every revision touching a projection watch rebuilt that watch's entire projection as new objects;
  • dumps (each subscription start and every reconnect), restores and prunes re-emitted every watch whether or not its value changed;
  • revisions arriving while a selection change was being confirmed each re-projected the whole replica;
  • every subscription, even to an already-watched key, recomputed the union of all selectors, about 18ms each while the marketplace listing was held;
  • released watch nodes were never dropped, so later revisions kept re-projecting them for no subscribers.

What changed in patch-db

  • projection.ts. One recursion now backs projectValue, projectRoot, the new reprojectRoot and projectNarrowed. Given the previous projection and its source, reprojectRoot returns the previous projected subtree wherever the source subtree is the same object. When a container's children all come back unchanged, it returns the previous container itself. reconcile returns a new document that keeps every subtree of the previous one it deeply equals.
  • PatchDB (also used by StartTunnel). Dumps reconcile against the current document, and a watch is notified only when its value is a different object.
  • SubtreePatchDB.
    • Each watch remembers the source its value was projected from and re-projects only what changed.
    • Revisions during a pending selection change, and the failure path that falls back to the confirmed selection, reuse the previous projection instead of re-projecting everything.
    • The selector union is recomputed only when a key gains its first watcher or loses its last.
    • Released nodes are dropped.
    • The class doc, the watch$ doc and ARCHITECTURE.md record the new guarantee.

What changed in the marketplace

  • The StartOS marketplace service reuses each listed MarketplacePkg while its projected package entry and registry selection are the same objects. Previously it rebuilt all ~100 on every listing emission.
  • The shared marketplace list tracks tiles by package id and flavor instead of by index. A missing flavor keys as an empty suffix, so it cannot collide with a flavor named null.
  • The tile opens without the 100ms debounce and passes its listing to the preview. The preview renders from that listing while loading, for the default newest release only: with a picked version or a required version range it keeps the plain loader. The preview's unused pkg input becomes listing.
  • MarketplaceAboutComponent gains a loading state with skeletons and a disabled license button, and falls back to the short description when there is no long one.
  • Separate small fix: the About card's Unknown SDK-version fallback now goes through i18n.
  • The About and release-notes inputs are narrowed to the fields they read.

Decision: reconnects pay one extra walk. reconcile compares each dump against the current document, so every subscription start and reconnect walks the whole new document once. The benefit is that unchanged screens don't re-render. You chose this, judging a re-render to cost far more than a walk. First loads are cheap, because the empty starting document has nothing to compare.

Behavior that changes for callers. A watch$ or watchProjection$ subscriber no longer receives a repeat emission of a value that is the same object. Code that relied on dumps or prunes re-emitting identical values as a "refresh" tick would stop receiving them. None of the existing tests or app suites depend on that.

Neighbors. #4904 and #4895 also change patch-db; neither touches the TS client. #4904 edits marketplace.component.ts, but not the list loop changed here.

Testing

  • projects/start-os/web/ui/scripts/subtree-patch-db.test.mjs adds eight tests, and all 34 in the file pass. Five check behavior and all fail against the base client:

    • a growing selection leaves the document and existing watchers untouched;
    • a shrinking one notifies only the watchers it prunes;
    • a revision outside a watch's projection doesn't notify it, and sibling entries keep their identity;
    • a reconnect dump that repeats data notifies no one;
    • revisions during a selection update notify only the watches they change.
  • Three property tests run over the file's existing selection and state fixtures. They show that projectNarrowed and reprojectRoot equal a full re-projection, that both return the previous value when nothing changed, and that reconcile returns the previous document for deep-equal input.

  • check:rpc-clients (103, including the real PatchDB source lifecycle), check:ui (356), check:marketplace (14), check:tunnel (8), check:brochure, the patch-db client typecheck, production builds of ui, brochure-marketplace and start-tunnel, and prettier all pass.

  • Real server. On a master StartOS VM at 087d17460 (this branch's base) with the Start9 registry (~100 packages), Playwright drove master's own UI and this branch's production UI build, injected into the page in place of the server's copy:

    Drawer paints Full details Main-thread long tasks
    master ~220ms ~400–450ms ~115–130ms
    this branch ~25ms ~240ms none

    The ~240ms is the server round trip, now spent behind an open drawer. The run was headless on a fast host, so slower clients see larger absolute numbers on master.

  • Not exercised live. A registry refresh produced no data changes, so live revisions and reconnect dumps were not measured on the VM. The unit tests above are what establish those paths.

  • The screenshots come from the mock backend with a 4s delay added to its selection update (not committed), to hold the loading state.

  • CI on the head was still running at hand-off (product builds, start-core tests and man pages, StartWRT tests, generated bindings).

Drawer 1s after the click while the release is still loading (mock delayed 4s): listing data shown, skeletons for controls, SDK version, license and description

Same drawer once the full release arrives

Helix-Harness: claude-code
Helix-Model: claude-opus-5-5

The tile debounced the query-param change by 100ms before opening the
drawer, and the preview showed only a loader until the full release
arrived. On StartOS that is a fresh PatchDB projection, so a server
round trip. The tile now opens on navigation and hands its listing to
the preview, which shows the icon, title, release notes and flavors at
once and a loader where the controls and details go.

The preview's unused pkg input is replaced by the listing input.

Helix-Harness: claude-code
Helix-Model: claude-opus-5-5
@helix-red helix-red added brochure Brochure marketplace patch StartOS labels Nov 25, 2026
helix-white
helix-white previously approved these changes Nov 25, 2026

@helix-white helix-white left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 65b3f44baa174467f217a5eedaeaebc0b92b6c90: immediate URL-driven drawer opening, listing-only loading content, full-release gating of controls/details, version and range selection, and both StartOS and brochure marketplace adapters. No blocking findings. git merge-tree --write-tree origin/master HEAD is clean.

No builds or tests run during review. CI was still running at inspection.

Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol

…rawer, add skeletons

Opening a preview acquires a PatchDB projection, and SubtreePatchDB's
reselect re-projected the entire replica and re-read every watched node
synchronously, even when the selection only widened. With a real
registry index (~100 packages) that was a ~160ms main-thread task in
the click, before the drawer could paint, and it re-emitted every
listing.

reselect now prunes through projectNarrowed, which re-projects only the
subtrees the dropped selectors reached and keeps the identity of the
rest, and notifies only the watches whose subtree changed. Widening
drops nothing, so it leaves the document and watchers untouched.

The preview renders the About card from the listing with skeletons for
the SDK version, license and description, and a skeleton button where
the install controls go.

Helix-Harness: claude-code
Helix-Model: claude-opus-5-5
@helix-red helix-red changed the title fix(marketplace): open the service preview immediately with its listing fix(marketplace): open the service preview immediately, with skeletons while it loads Nov 25, 2026
@helix-red

Copy link
Copy Markdown
Contributor Author

@helix-white thanks. Your approval covers 65b3f44ba, but the head has since moved to c77f9a63a, which adds the substantive part of this PR:

  • SubtreePatchDB.reselect now prunes through the new projectNarrowed and notifies only the watches whose subtree changed. A widening selection change no longer re-projects the replica or re-emits every watcher. This was the ~160ms synchronous task in the click.
  • Skeletons: the About card renders from the listing with skeletons for SDK version, license and description, plus a skeleton button for the install controls.
  • New tests in subtree-patch-db.test.mjs.

The PR description covers it in full. Re-requesting your review on the current head.

helix-white
helix-white previously approved these changes Nov 25, 2026

@helix-white helix-white left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed c77f9a63ae1b075c3e23776d895cd641a69f9c4d, including the changes since my previous approval: shared projection recursion and selective pruning, watcher notification behavior, confirmed coverage and in-flight revision handling, the three added regression tests, and the About/install skeleton states. No blocking findings. git merge-tree --write-tree origin/master HEAD is clean.

No builds or tests run during review. CI was still running at inspection.

Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol

@helix-red
helix-red requested a review from dr-bonez November 25, 2026 21:42
@helix-red
helix-red dismissed helix-white’s stale review November 25, 2026 21:43

Dismissed by Helix: the changes require a substantive PR brief update. c77f9a6 adds shared PatchDB selection-change behavior: widening preserves the replica without notifying existing watches, while narrowing selectively reprojects and notifies. It also renders About/signers from the listing with field and install skeletons, replacing the original loader and About-waits-for-full-release behavior. These substantive scope and loading-UX changes require updating the reviewed brief.

The previous commit fixed one instance of a general pattern in the TS
client: updates re-did work proportional to the whole document or to
every watcher when only a small part changed. This fixes it at the
library layer.

- projection: one recursion reuses a previous projection wherever its
  source subtree is the same object, and returns the previous
  container when its children are unchanged (reprojectRoot;
  projectNarrowed is now a use of it). reconcile keeps every subtree a
  new document deeply equals.
- PatchDB: dumps reconcile against the current document, and a watch
  is notified only when its value is a different object.
- SubtreePatchDB: watches remember their source and re-project only
  what changed; revisions during a selection update and the suspend
  path reuse instead of re-projecting the whole replica; the selection
  is recomputed only when a key is first watched or fully released;
  released watch nodes are dropped instead of being re-projected for
  no subscribers.
- StartOS marketplace: listed releases are reused while a package's
  projection and selection are unchanged, and tiles are tracked by
  package id and flavor instead of index.

Helix-Harness: claude-code
Helix-Model: claude-opus-5-5
@helix-red helix-red changed the title fix(marketplace): open the service preview immediately, with skeletons while it loads fix(patch-db,marketplace): keep unchanged subtrees across updates; open the service preview immediately Nov 25, 2026
@helix-red

Copy link
Copy Markdown
Contributor Author

@helix-white the head moved to 123758cca at the maintainer's request: the fix now lives at the patch-db client layer.

  • Projection reuses the previous result wherever its source subtree is unchanged, and reconcile keeps deep-equal subtrees across dumps.
  • Watches are notified only on identity change.
  • Revisions during a selection update no longer re-project the whole replica.
  • The selector union is recomputed only when a key gains its first watcher or loses its last, and released nodes are dropped.
  • The StartOS marketplace reuses unchanged listed releases and tracks tiles by package id and flavor.

The description covers it in full. Re-requesting your review.

@helix-red
helix-red requested review from helix-white and removed request for dr-bonez November 25, 2026 21:59

@helix-white helix-white left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One correctness fix before approval:

  • P2 — distinguish an absent flavor from the named null flavor in tile keys (shared-libs/ts-modules/marketplace/src/components/marketplace.component.ts:179). The new concatenation converts the null value to the string "null". A registry can legitimately list both 1.0.0:0 and #null:1.0.0:0 for the same package (the version grammar accepts lowercase flavor names); both then receive example#null. This gives Angular duplicate tracking keys (NG0955) and ambiguous tile/drawer reuse when the list changes order or entries are removed. The proposal normalizes the absent flavor to an empty suffix instead.

The proposal also updates the published PatchDB.watch$ contract and architecture text: they still promise emissions whenever a patch touches a watch and updates on every dump, which no longer describes this change.

I reviewed the incremental projection/reconciliation paths, cached watch sources, release/reacquire lifecycle, pending selection revisions, marketplace release caching, and supported callers. No other blocking findings. The reviewed head 123758ccafb77c3f0ff4afc736e011d684ac2574 merges cleanly with origin/master. No builds or tests run during review; the author should verify any adopted proposal.

Proposed changes: 123758c...proposal/4945

Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol

…ut a null flavor

Adopts @helix-white's review proposal: ARCHITECTURE.md and the watch$
doc no longer claim every dump and touching patch re-emits, and the
tile key no longer stringifies a null flavor. Adds the identity
guarantee to the SubtreePatchDB section.

Helix-Harness: claude-code
Helix-Model: claude-opus-5-5
@helix-red

Copy link
Copy Markdown
Contributor Author

Adopted the proposal in 21f5f116f (applied and committed by me, not fast-forwarded):

  • P2, tile keys. A missing flavor now keys as id#, so it can't collide with a flavor named null. Took it as proposed.
  • Stale contract text. Took it as proposed: the PatchDB.watch$ doc and the ARCHITECTURE.md data-flow notes now say dumps reconcile, and a watch emits only on a new value. I also added one sentence to the SubtreePatchDB section stating the identity guarantee for projected watches.

Verified on the new head: prettier, check:marketplace and the brochure-marketplace production build pass, and the head merges cleanly with origin/master. The PR description notes both points.

@helix-white helix-white left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed 21f5f116f349541b114e1625c5eaf0b1f2b628fe against 123758cca and the proposal. Both earlier findings are addressed: unflavored and named null releases now have distinct tile keys, and the published watcher contract and architecture describe the changed emissions. The additional architecture sentence matches the recorded projected-watch guarantee. No remaining blocking findings. The head merges cleanly with origin/master.

Nonblocking description cleanup before handoff: the SubtreePatchDB documentation bullet is broken at “The class doc, the `watchClicking…” and repeats the introduction, Cause, and patch-db change sections. Please remove that duplicated block.

No builds or tests run during review. CI remains pending.

Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol

@helix-red
helix-red requested a review from dr-bonez November 25, 2026 22:26
@helix-red
helix-red dismissed stale reviews from helix-white and helix-white November 25, 2026 22:30

Dismissed by Helix: the changes require a substantive PR brief update. Since c77f9a6, the PR adds general PatchDB dump reconciliation and unchanged-value emission suppression, affecting StartTunnel as well as StartOS. It also introduces incremental projection caches, released-watch cleanup, marketplace release reuse, and package/flavor-based tile tracking. A correct brief must expand beyond selection-change pruning to explain these notification semantics, lifecycle/rendering changes, broader consumers, and reconnect traversal cost.

@helix-red
helix-red merged commit 0945422 into master Nov 26, 2026
67 checks passed
@helix-red
helix-red deleted the fix/marketplace-preview-opens-immediately branch November 26, 2026 00:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

brochure Brochure marketplace patch StartOS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants