Skip to content

The title bar stops loading the whole builder - #58

Merged
AllTerrainDeveloper merged 1 commit into
AllTerrainDeveloper:mainfrom
juanlentino:perf/57-titlebar-script
Sep 26, 2026
Merged

AllTerrainDeveloper merged 1 commit into
AllTerrainDeveloper:mainfrom
juanlentino:perf/57-titlebar-script

Conversation

@juanlentino

Copy link
Copy Markdown
Contributor

Summary

OpenStation runs every title-bar provider script at boot so buttons can paint on restored windows. includes/openstation.php registered allterrain-forms-builder as that provider, so every station load ran the full builder bundle (builder.min.js, 505 KB) even when no Forms window was ever opened.

The preview eye now has its own entry:

  • src/titlebar.ts calls registerPreviewButton() and nothing else. It imports only src/preview-button.ts, which has no runtime imports.
  • Built to assets/js/titlebar.js / titlebar.min.js by a new titlebar Vite target (npm run build:titlebar, included in build:bundles), registered in includes/assets.php as allterrain-forms-titlebar, and passed to register_titlebar_button_script in place of the builder. Still gated on $has_builder.
  • The builder no longer registers the button, so it is registered once. It calls providePreviewSource() with the same view onto its open form (current, isDirty, save). The click previews the most recently loaded builder's form, saving first when dirty, which is what the single button registration did before. Before any builder has loaded, the click does nothing.
  • The button's id, label, icon, placement, order and match predicate are unchanged. owner is now allterrain-forms-titlebar.
  • bin/package.mjs and bin/deploy.mjs require titlebar.min.js.

Size

Bundle Bytes
builder.min.js (previous provider) 516,315 (505 KB)
titlebar.min.js (new provider) 1,008 (564 gzipped)

Both assets/js bundles were rebuilt with npm run build:bundles, and a second run left the tree unchanged, so the CI "Committed bundles match source" check holds. The builder.js diff is only the moved registration code.

Tests

tests/vitest/titlebar.test.ts:

  • the only register_titlebar_button_script handle in includes/openstation.php is allterrain-forms-titlebar;
  • titlebar.min.js is under 10 KB and carries no builder markup;
  • with a stubbed shell, the registered button does nothing before a builder provides a source, opens allterrain-forms-preview-7 once one does, and does nothing again after it is withdrawn.

All three fail against main (handle is allterrain-forms-builder, bundle missing, providePreviewSource not a function) and pass on this branch. Full suite: 472 passed, 2 skipped. tsc --noEmit clean, PHPCS clean on the changed PHP files.

Fixes #57

🤖 Generated with Claude Code

…builder

OpenStation runs title-bar provider scripts at every boot, so registering
allterrain-forms-builder made each station load the 505 KB builder bundle
even when no Forms window was opened. The preview eye now lives in
src/titlebar.ts (assets/js/titlebar.min.js, 1,008 bytes), registered as
allterrain-forms-titlebar. The builder no longer registers the button; it
publishes a view onto its open form through providePreviewSource(), and
the button previews the most recently loaded builder's form, as before.

Fixes AllTerrainDeveloper#57.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@AllTerrainDeveloper AllTerrainDeveloper left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks, Juan. I verified this against OpenStation’s title-bar script loader and tested the PR merged with current main. The preview behavior and packaged bundle checks pass, and the provider now loads about 1 KB instead of the full builder at boot. Nice performance improvement.

@AllTerrainDeveloper
AllTerrainDeveloper merged commit 0ad6011 into AllTerrainDeveloper:main Sep 26, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The 505 KB builder bundle runs on every OpenStation page load because it is the title-bar button provider

2 participants