Skip to content

Vue migration 4/4: replace the Alpine runtime with Vue - #137

Merged
JuroOravec merged 775 commits into
mainfrom
promotion/vue-runtime-migration
Oct 19, 2026
Merged

JuroOravec merged 775 commits into
mainfrom
promotion/vue-runtime-migration

Conversation

@JuroOravec

@JuroOravec JuroOravec commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

Split for review. The migration is in four PRs that merge in this order: #161 (Citry UI), #162 (examples), #163 (docs site), then this PR. This PR holds everything else: the Rust crates, citry, citry_lsp, the JS client, the protocols, the editor extension, the design docs, scripts and CI. It must pass every check; the first three are expected to fail until it merges. Until #161 to #163 merge, this PR's diff still includes their changes.

Citry's browser behavior moves from Alpine to Vue. The server compiles each interactive component to a Vue component, sends the page's content in the served HTML, and Vue takes over that HTML in the browser instead of building the page again. Rendering needs no Node.js and no frontend build: the Vue compiler is written in Rust and runs inside citry_core. Only the optional type check (citry check --types) uses Node.js and TypeScript.

This PR releases as citry 0.6.0, citry-core 1.8.0, citry-ui 0.3.0, citry-lsp 0.2.0 and the VS Code extension 0.2.0. Upgrading from 0.5.x is covered by docs_site/content/guides/upgrading-to-0-6-0.md, and each package's CHANGELOG.md lists what changed for its users. The changelogs get their version headings at release time.

What changes for a Citry user

  • Component templates accept Vue syntax. Directives, bindings, props, events, slots, keyed lists and custom directives work, and $component({...}) takes a Vue Options API object. Citry.vue gives access to Vue's Composition API, and Citry.vue.use() installs a Vue plugin on every Vue app Citry creates. The templates do not support v-once, v-memo, <Teleport>, <Transition>, <Suspense> or <KeepAlive>.
  • Search engines see the content by default. Interactive pages send their rendered HTML, and Vue reuses it. Citry(ssr=False) turns this off, and Citry(ssr_element_threshold=...) skips it for small pages.
  • Server events can update part of a page. An Events handler can render a <c-mark name="..."> region again or update one component occurrence, and one response can update several targets.
  • simple = "vue" components keep their own Vue state and assets without a Python component instance.
  • Type checking reaches across Python and the browser. In the editor and in citry check --types:
    • TypeScript checks component JavaScript and Vue template expressions, and ty checks Python template expressions.
    • this in component JavaScript knows the component's js_data() keys, methods, $el, $emit and declared emits payloads. Python types such as str carry over to the browser code that reads those values.
    • Each c-* value on a component tag is checked against the child component's Kwargs.
    • Bound HTML attributes are checked against Vue's attribute types, and a new warning reports invalid values of HTML attributes that accept a fixed set of keywords, such as draggable="treu".

What is removed

This PR removes the Alpine runtime and the code Citry built around it: the citry_ownership crate, which tracked which component owned each element; the client-graph protocol, which described components to the browser; and the planner that merged server updates into the page while keeping component state. Vue's own component instances now keep that state.

Performance

Measured with the benchmark app in a separate repository, on pages that render 140 and 1,400 outputs, including the layout. Each cell is first load / second load; lower is better. "Target" is what earlier experiments predicted.

Outputs Target This PR
140 162.0 / 79.1 ms 117.9 / 75.7 ms
1,400 368.2 / 342.9 ms 359.2 / 304.1 ms

Experiments that did not hold up on the real code path were removed and are recorded in #144.

Merge order

  1. Our patches to Vize, the Rust Vue compiler that Citry uses, went in their own PR first (Fix statement and comment handling in the patched Vize event handlers #159, merged; upstream work tracked in Upstream the patched Vize compiler fixes and remove local source copies #138). This PR already contains the same change, so after that PR merges, its part of this diff disappears.
  2. Merge Vue migration 1/4: Citry UI #161, Vue migration 2/4: examples #162 and Vue migration 3/4: docs site #163, then squash-merge this PR. Three intermediate commits in its history import code that only arrives in a later commit, so they fail to import citry_lsp. Squashing keeps them off main.
  3. After publishing, regenerate the example projects' lockfiles, because a lockfile can only point to a published release.

How this was tested

  • Full repository gate (scripts/check.py --profile full): all 20 phases passed. Python coverage is 89.02%, above the 88.5% minimum. mypy also passes with --platform linux.
  • Browser tests:
    • Citry and Citry UI: 1,036 passed.
    • Docs site: 113 passed and 6 were skipped on purpose.
  • Server HTML parity: for every page the non-browser tests prepare, the HTML that Citry's Rust renderer writes for hydration matches Vue's renderToString, element by element and attribute by attribute. Pages the renderer hands to the browser are not compared, and neither is the content inside elements it leaves for the browser to fill (scripts/vue_render_parity).
  • Type-check guards: citry check --types reports no TypeScript or ty findings on Citry UI, with and without i18n configured, and a test keeps it that way. Citry's own template checks still report errors on Citry UI (citry check reports ~1,600 errors on any app that registers citry_ui #149).
  • Independent reviews: a separate agent reviewed each feature batch, and every finding was either fixed or recorded as a follow-up issue.

Follow-up work is tracked in #144, #146, #148, #149, #150, #151, #152, #153, #154 and #155.

🤖 Generated with Claude Code

JuroOravec added a commit that referenced this pull request Oct 1, 2026
Copy the files that only the uncommitted work on branch
docs/benchmark-evaluation-design (benchmark-design below) changed since
181416a; PR #137 (branch promotion/vue-runtime-migration) left those
files unchanged: hydration and static HTML modules, server render
programs, simple Vue mode, render parity tooling, the native build guard
and the performance design docs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
JuroOravec added a commit that referenced this pull request Oct 1, 2026
Three-way merge per file with the promotion snapshot 40da8ee as base,
after folding main's 0.5.1 changes into the benchmark-design copy. Only
files that merged without conflict and without a conflict between main
and benchmark-design.

benchmark-design: the uncommitted Vue performance work from branch
docs/benchmark-evaluation-design.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
JuroOravec added a commit that referenced this pull request Oct 1, 2026
The benchmark-design component-directive validation rejected v-on="..."
on a component tag, but PR #137 commit 7e67410 ships that form
(events-object bindings compiled with toHandlers). Keep the PR #137
contract and drop the two rejection cases that encoded the older rule.

benchmark-design: the uncommitted Vue performance work from branch
docs/benchmark-evaluation-design.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
JuroOravec added a commit that referenced this pull request Oct 1, 2026
Mirror the parser change: the render-time directive check keeps PR #137
commit 7e67410's events-object binding and uses the same hint wording.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
JuroOravec added a commit that referenced this pull request Oct 1, 2026
Keeps the benchmark-design Vue rewrite and the PR #137 fixes made after
its promotion snapshot (34f6f22, 4fa5f54, 8cc6745, feabd4f,
ffbef06, 10f982f); cgrid takes the benchmark-design Vue directive
rejection plus ffbef06.

benchmark-design: the uncommitted Vue performance work from branch
docs/benchmark-evaluation-design.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
JuroOravec added a commit that referenced this pull request Oct 1, 2026
Keeps the benchmark-design Vue rewrite, ports PR #137's self-contained
quality pages to the benchmark-design page format, keeps PR #137 tests
from 073fbd4 and 8cc6745, and adds main's citry-ui 0.2.2 changelog
section.

benchmark-design: the uncommitted Vue performance work from branch
docs/benchmark-evaluation-design.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
JuroOravec added a commit that referenced this pull request Oct 1, 2026
Keep the benchmark-design tests, keep and adapt PR #137's later tests
(7e67410, e3a05be, ec384f1, 645f1fe, 80fb9bd, 7b06f65, 4dfe992),
and restore main's const-metadata test.

benchmark-design: the uncommitted Vue performance work from branch
docs/benchmark-evaluation-design.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
JuroOravec added a commit that referenced this pull request Oct 1, 2026
Benchmark-design transport request shape with PR #137 commit 7d62b6a
ported; custom transports forward only an explicitly configured CSRF
token. Keeps PR #137 commit 7b06f65's onEvent typing, main's VS Code
completion fix, and the benchmark-design removal of
analyze_component_members. VS Code out/ rebuilt.

benchmark-design: the uncommitted Vue performance work from branch
docs/benchmark-evaluation-design.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
JuroOravec added a commit that referenced this pull request Oct 1, 2026
Keep the benchmark-design Vue runtime and port these PR #137 fixes:
events-object bindings (7e67410), onEvent context name (7b06f65),
native control ownership (80fb9bd), component-root listeners
(db3c4cb), prepared dependency placeholders (dc6bb65), textarea
leading newlines (d28cc04, 6d72ee6).

benchmark-design: the uncommitted Vue performance work from branch
docs/benchmark-evaluation-design.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
JuroOravec added a commit that referenced this pull request Oct 1, 2026
client.js resolved by hand (benchmark-design design plus PR #137 commits
7e67410, c0ae1c3, 80fb9bd, 4eaa1a3, afe5062); events.js and
runtime.js rebuilt from the resolved sources with the package's build
settings.

benchmark-design: the uncommitted Vue performance work from branch
docs/benchmark-evaluation-design.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
JuroOravec added a commit that referenced this pull request Oct 1, 2026
Keeps 9d60e70's Project Board fix and qualification checks, main's
0.5.1 changelog sections under the benchmark-design Unreleased notes,
PR #137's stricter wheel CI step and server-render event anchor. Takes
the benchmark-design local playground runtime (local_playground_runtime,
serve, the docs e2e fixtures and the playground executor and README).
Playground bundles rebuilt from their sources.

benchmark-design: the uncommitted Vue performance work from branch
docs/benchmark-evaluation-design.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
JuroOravec added a commit that referenced this pull request Oct 1, 2026
Adapt two PR #137 compiler tests to the $citryPrepared template name,
and drop duplicate js fields that both branches added to two citry_ui
e2e fixtures.

benchmark-design: the uncommitted Vue performance work from branch
docs/benchmark-evaluation-design.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
JuroOravec added a commit that referenced this pull request Oct 1, 2026
PR #137 commit 80fb9bd adds a v-citry-vue-owned marker to native form
controls. The benchmark-design compiler treats custom directives as
lifecycle directives and its server render reader declines any
directive but v-show, so the marker entered the directive signature and
turned forms into shells. Exclude it from the signature and skip it
when rendering on the server; it only records property ownership in the
browser.

benchmark-design: the uncommitted Vue performance work from branch
docs/benchmark-evaluation-design.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
JuroOravec added a commit that referenced this pull request Oct 1, 2026
The Rust local-call check re-encoded generated binding values without
escaping < and >, while Python writes them with html.escape. PR #137's
component-root event wrapper ($el) => ... made the two disagree, so
every Citry event on a component tag failed to compile.

Also adapt PR #137 tests to the benchmark-design names and encodings:
the $citryPrepared template name, decoded comparison checks, ffbef06's
presence value in the carousel test, and drop two unit tests of a
helper the benchmark-design slot design no longer has.

benchmark-design: the uncommitted Vue performance work from branch
docs/benchmark-evaluation-design.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
JuroOravec added a commit that referenced this pull request Oct 1, 2026
…emovals

vue.md listed the v-on object form as rejected on component tags, which
PR #137 (7e67410) allows. The citry-core release notes now say that
analyze_component_members is gone and BUILD_PROFILE is new.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@JuroOravec JuroOravec changed the title Replace the Alpine ownership runtime with Vue Vue migration 4/4: replace the Alpine runtime with Vue Oct 1, 2026
JuroOravec added a commit that referenced this pull request Oct 2, 2026
- Add a Performance section after Advanced: an overview, Simple
  components, Constant values, Pure components, and the two caching
  pages, with redirects from the old URLs.
- Mark the i18n pages for review.
- Restore the Citry.events method entries and add a guard that fails on
  an unknown cross-reference key.
- Restore explainer comments in snippets and examples, and fit tutorial
  code to 70 columns.
- Audit every page against the code: fix wrong claims, examples that
  did not run, leftover Alpine wording, and the docs best practices.
- Run each getting-started step in a browser test.

Part of the Vue migration in #137.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
JuroOravec added a commit that referenced this pull request Oct 2, 2026
- Document returning a different component from an Events handler, and
  restore tutorial step 12.
- Show the State refresh and the code fixes from the docs audit.
- Replace the benchmarks page with first- and second-load time-to-usable
  charts at 1,400 outputs; spread the landing example's data() over lines.

Part of the Vue migration in #137.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
JuroOravec added a commit that referenced this pull request Oct 2, 2026
…ence

- Lead the benchmarks page with the charts, say entries instead of
  outputs, and match the chart label sizes.
- Drop TemplateNode from the API reference and the upgrade guide notes.

Part of the Vue migration in #137.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
JuroOravec and others added 3 commits October 2, 2026 14:40
Add a heading_length source guard that lists every ## and ### heading over
24 visible characters with its file and line. It reports at info level so
it never fails a build, even under --strict.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Move the page-level rules for user-facing text out of CLAUDE.md into
docs/best-practices/writing-docs.md, with before/after pairs from the Events
rewrite. CLAUDE.md keeps the sentence-level rules, the code-line and fence
rules, and a pointer. Mechanism 6 now asks for a cold read of user-facing
text by the saved docs-cold-reader agent.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
JuroOravec and others added 13 commits October 15, 2026 23:45
After an unrelated server re-render the tour showed the user's step but
its runtime reset to the server's active value, so Next repeated a step
and the tour never advanced. The step now follows the same rule as open:
a re-render keeps the user's step when the server's active value is
unchanged and moves the tour when it changed, marking exactly one
current panel. The dialog's accessible name and description now come
from each panel's own title and description ids instead of becoming
"undefined" after Next.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…re-renders

The previous fix guessed that any disabled attribute on the trigger was
the menu's own when the last render saw no author disable, so an author
disable added in a later render was dropped and a literal disabled could
be cleared. Each run now records the trigger's disabled as the author
left it, and the cleanup puts that value back before Vue applies the
next render (only if the trigger still holds this run's own write), so
every run reads exactly what the author wrote. Tests cover a bound
author disable, a literal disable with and without a server toggle, a
menu re-enable, and both changing in one event.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…return focus on removal

The templates bind open on the <dialog> so the server HTML of an open
dialog is correct. When the server's open turned false, Vue removed the
attribute, which does not take a modal dialog out of the top layer; the
next render read dialog.open as false and never called close(), so an
invisible modal kept the page scroll-locked and blocked clicks. A new
render that finds a dialog still modal without open now adds the
attribute back, so the normal takeover path closes it and releases the
lock. This covers CDialog, CAlertDialog, CCommandPalette, and CDrawer.

A CDialog removed while open now returns focus to its opener when focus
was lost and the opener is still on the page. The cross-component test
now checks real dialog state: no :modal element, no scroll lock, and a
real click succeeds after a server close.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…overlay fixes

Add changelog bullets for the dialog and drawer close, focus on dialog
removal, and the CTour step; reword the unchanged-open bullet; say why
dialog removal does not call onOpenChange; and rewrap the design-doc
paragraphs changed in the last round.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ver-card disable reason

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ile the menu disables it

When the menu had already disabled its trigger, a client binding that
set disabled to true changed nothing in the DOM, so no mutation was
observed; the cleanup then restored the stale author value and Vue did
not re-apply the unchanged binding. The trigger's disabled property now
reports every write that is not the menu's own to the current run, so
the author's value is recorded even when the DOM does not change. The
mutation-observer comparison stays as a second guard.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… one; follow server open in CCommandPalette

When the server closed an outer CDialog or CDrawer while an inner
dialog or drawer in it was open, the inner had already handed itself off
and was not in the list the outer closed, and its next run kept it open
because its own server open was unchanged, leaving an invisible modal
that blocked the page. A run now refuses to keep or open a dialog while
its nearest enclosing <dialog> is closed, and reports the forced close
to the inner's owner with reason "ancestor". The dialog controller's
and CDrawer's scroll locks hand the page's original styles to each
other, so the page is released when both close.

CCommandPalette now hands its server open value to the next run and
follows a changed value, as CDialog does. The cross-component test
covers nested dialogs and drawers opened by the user and by the server,
the palette, and requires modal state for the modal components.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Drop the dialog server-close bullet (that bug never shipped), cover
CAlertDialog in the focus bullet and CCommandPalette in the server open
bullet, and describe what 0.2.2 did to a re-rendered tour.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…records

Replace the per-element disabled property wrapper with the trigger's
mutation records. The trigger observer now asks for old values, and each
run queues the values the Menu writes itself; the Menu writes only
changed values, so each of its writes yields exactly one record. Any
other record is an author write, and the value after it becomes the
author's. Page code that calls setAttribute('disabled', '') while the
Menu has the trigger disabled now keeps the disable when the server
re-enables the Menu. toggleAttribute('disabled', true) on a trigger that
is already disabled produces no record in any engine and is still not
seen; the comment says so. A new setAttribute case fails on the previous
code; a toggleAttribute case guards the order where it is recorded.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…de a closed outer overlay

An inner CDrawer inside a CDrawer the server closed got a plain close()
from the outer, so its own next run saw it already closed and never
reported. The outer now skips an inner drawer waiting for its next run,
which then closes it and reports "ancestor". An inner CDialog or
CCommandPalette the server rendered open inside a closed outer kept its
open attribute when the controller refused to open it, so it appeared
as a visible non-modal dialog once the user opened the outer; the
refusal now removes that attribute, without a report.

The palette family JS was 1 byte over its gzip budget (and over its
brotli budget); shortened shipped comments, one shared modal check, and
an unused export bring it to 20288 B gzip and 17283 B brotli. Tests add
drawer-in-drawer and drawer-in-dialog-in-drawer, inner overlays rendered
open in a closed outer, and a palette opened while a drawer closes in
the same render (that last case did not reproduce and guards against a
regression).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ewrap the CTour bullet

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…the ancestor changelog entry

Co-Authored-By: Claude Opus 5.5 <[email protected]>
JuroOravec added a commit that referenced this pull request Oct 16, 2026
…lot syntax, overlay open state)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
JuroOravec and others added 4 commits October 16, 2026 13:11
…ything

Citry compiles Vue templates on the server, so the static
`citry.csp.incompatible-browser-code` rule returned nothing for every
`security_csp` mode. Remove `lint_csp_compatibility`,
`CspCompatibilityFinding`, the catalog entry and its generated binding,
the `citry check` and language server callers, the citry-lsp worker
`engine_settings` field that only fed the rule, and the empty
`validate_reached_bindings` hook. Render-time CSP checks and the
`security_csp` setting validation are unchanged.

The citry-ui manifest completeness check moves to the registration
tests. Changelogs, the upgrade guide, the security page, and the CSP and
public API design docs describe the current behavior.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Remove the unused native event name lists, the source-range helpers,
and the raw span map from `_decode_html_attribute` in
`_csp_validation.py`. The `on*` prefix rule is unchanged. Remove the
empty `inspect_reached_bindings` hook from the JavaScript policy, the
same kind of dead hook as the CSP one removed earlier.

Add a citry-ui smoke test that `citry check` loads the whole library.
Fix the `CitryRender.serialize` docstring and design docs that described
a separate CSP browser runtime, and tidy the changelog wording.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Rewrite the CSP design doc's fragment and mode-combination sections for
the single Events runtime, and make the `serialize` docstring and the
design doc say what strict mode does: raise instead of warning, and
require `csp_nonce` when Citry emits an executable script or a
`<style>` element. Tighten two comments in `_csp_validation.py` and the
wording of the protocol changelog and the public API audit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A preview control change reaches the frame as a message, so a test that
focused or clicked right after changing a control could act before the
value arrived. The combobox, dialog, textarea and checkbox tests now
change the control they wait on last, the menu controlled test makes a
visible change after the hidden setting, and the popover, drawer, menu
and tooltip tests wait for the values instead of reading them once.

The docs README shows the Vue way to read preview control values.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
JuroOravec added a commit that referenced this pull request Oct 16, 2026
…ts on 3.10 and Windows

Python 3.13 and later reject a frozen dataclass with any non-frozen
dataclass base. Python 3.10 to 3.12 accept one, so a Kwargs class whose
first dataclass base was frozen quietly became frozen there. Citry now
checks every dataclass base itself, raises the same ValueError on every
supported version, and names one frozen and one non-frozen base.

On Python 3.10, loading an i18n catalog package without __init__.py failed
because its resource path takes one name per joinpath call.

The diagnostic catalog validator reports paths with forward slashes, and
the Vue code error tests no longer need StrEnum (3.11+) or forward slashes
in file paths.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
JuroOravec added a commit that referenced this pull request Oct 17, 2026
JuroOravec added a commit that referenced this pull request Oct 17, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@JuroOravec
JuroOravec merged commit ff78430 into main Oct 19, 2026
34 of 35 checks passed
@JuroOravec
JuroOravec deleted the promotion/vue-runtime-migration branch October 19, 2026 10:56
JuroOravec added a commit that referenced this pull request Oct 19, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]>

# Conflicts:
#	benchmarks/README.md
#	docs/design/framework_interaction_benchmarks.md
#	docs/design/performance_architecture_experiments.md
#	docs/design/vue_board_hydration_plan.md
#	docs/design/vue_optimization_rollout.md
#	packages/py/citry/tests/test_simple_vue_mode.py
#	scripts/vue_render_parity/check.py
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.

1 participant