feat(wails): move the frontend onto v3's generated bindings

frontend/wailsjs/ is deleted and frontend/bindings/ takes its place —
a real TypeScript module tree nested by Go import path, generated by
wails3's static analyser rather than by building the app and running
it.  The @go alias absorbs the constant prefix, so a call site imports
'@go/library/library.js' and the codemod over all 93 sites was a
specifier rewrite plus splitting @go/models' namespaces into one
import per package.

The 12 SetContext bindings and the fake `context` model are gone, as
Phase 2's ServiceStartup port promised: 272 methods across 12
services, none of them plumbing.

@runtime/runtime is now a local shim (src/wails/runtime.ts) over
@wailsio/runtime, so the 22 EventsOn imports are untouched.  It
unwraps v3's WailsEvent into v2's callback shape, which is exact here:
nothing in backend/events passes more than one data argument, and v3
only packs arguments into a slice when there is more than one.

v3 tells the truth about two things v2 lied about, and that is most of
the diff.  A Go nil slice really does arrive as JSON null, and a Go
named string type really is an enum; v2 typed them as T[] and string.
utils/binding.ts states the app's actual contract — an absent list is
an empty list — once, at the boundary where it is true, and also drops
the CancellablePromise the app never cancels.  Four test fixtures
widen an enum field back to its value union.

Not done, and Phase 5's to fix: frontend/test/support/wails-fake.ts
still fakes window.go, which v3 does not have, so `make ui-test` is
broken and harness.test.ts fails to compile on EventsEmit.  That test
also asserts v2 ordering that no longer holds — v3's Events.Emit calls
the backend and does not notify in-page listeners at all.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UDCbcCZQepnpSQYJ6SxxZm
This commit is contained in:
2026-08-14 17:48:38 -04:00
co-authored by Claude Opus 5
parent c9905fbcff
commit 162c68769f
133 changed files with 5755 additions and 5094 deletions
+23 -18
View File
@@ -1,21 +1,26 @@
#!/usr/bin/env bash
#
# Fails when frontend/wailsjs/ is stale against the bound Go structs.
# Fails when frontend/bindings/ is stale against the bound Go services.
#
# frontend/wailsjs/ is generated by `wails`, not by `go generate`, so the
# pre-commit codegen check does not cover it at all. Without this, a
# frontend/bindings/ is generated by `wails3`, not by `go generate`, so
# the pre-commit codegen check does not cover it at all. Without this, a
# renamed Go struct field or a changed method signature first shows up at
# runtime, inside a window, as a binding that never settles.
#
# `wails generate module` builds the app with the `bindings` tag and runs
# it to dump the bindings — about three seconds, so it is cheap enough to
# gate a commit on.
# v3's generator is a static analyser rather than a build-and-run of the
# app, which is what makes this cheap enough to gate a commit on — and
# also what makes the build tags matter. It sees only the configuration
# it is told about; the one that matters is the one users run, which is
# the default tag set (GTK4 + WebKitGTK 6.0). The other two
# configurations this repo builds — `indexbuild` and `dev` — add no bound
# service, so generating under them would only widen the surface past
# what ships.
set -euo pipefail
cd "$(dirname "$0")/.."
TARGET="frontend/wailsjs"
TARGET="frontend/bindings"
if [ -n "$(git status --porcelain -- "$TARGET")" ]; then
echo "bindings-check: $TARGET has uncommitted changes; stage or stash them first" >&2
@@ -23,21 +28,21 @@ if [ -n "$(git status --porcelain -- "$TARGET")" ]; then
exit 1
fi
go tool wails generate module >/dev/null 2>&1
go tool wails3 generate bindings -clean=true -ts -i >/dev/null 2>&1
# `wails generate module` rewrites the three runtime files as 755 every
# time. That is not drift, so compare content only.
if ! git -c core.fileMode=false diff --quiet -- "$TARGET"; then
if ! git diff --quiet -- "$TARGET"; then
echo "bindings-check: $TARGET is out of date with the Go bindings." >&2
echo "Run 'make bindings' and stage the result." >&2
git -c core.fileMode=false diff --stat -- "$TARGET" >&2
git diff --stat -- "$TARGET" >&2
exit 1
fi
# Restore the modes the generator churned, so the tree is left clean.
chmod 644 \
frontend/wailsjs/runtime/runtime.js \
frontend/wailsjs/runtime/runtime.d.ts \
frontend/wailsjs/runtime/package.json
# An added or removed *file* is a rename or a new service, which a diff
# of tracked paths alone does not see.
if [ -n "$(git status --porcelain -- "$TARGET")" ]; then
echo "bindings-check: $TARGET gained or lost files." >&2
git status --short -- "$TARGET" >&2
exit 1
fi
echo "bindings-check: frontend/wailsjs is current"
echo "bindings-check: frontend/bindings is current"