feat(wails): move the Go side to v3

Phases 2 and 3 of plan 009, plus the parts of phase 1 that could not
land before them. Nothing in the tree imports wails/v2 any more; all
three lint and test configurations are green and `go build .` produces
a running binary.

The point of the migration is one file. backend/events/emit.go probed
ctx.Value("events") — a v2-*private* context key — to decide whether
emitting was safe, because runtime.EventsEmit called log.Fatalf on a
context without the runtime and took the process down with it. v3's
emit takes no context, so that is now application.Get() == nil. D1
held: events.Emit keeps its ctx as the WithSink test seam, and all 45
call sites and 7 test files are untouched.

The bootstrap splits into application.New + Window.NewWithOptions +
Run. Ten bound services implement ServiceStartup instead of being
handed a context by hand from OnStartup, which also stops ten
SetContext methods being exported as bindings. jobs.Registry and
explore.SearchIndex keep theirs — neither is bound, so converting them
would be churn for no binding removed.

Four things differed from the plan and are written up in it: GPU policy
moved to the per-window LinuxWindow options rather than surviving on
LinuxOptions; there is no OnStartup/OnDomReady option, so app-level
wiring hangs off ApplicationStarted; application.NewService is generic,
so FEBindings []any could not survive (the binding generator is a
static analyser and would have seen nothing); and the quit veto had to
be restructured, because v3's dialog answers on a callback rather than
returning the button, so ShouldQuit vetoes, asks, and quits again from
the callback.

Window state saving moves to a WindowClosing hook — the size has to be
read while the window still exists, and v3's OnShutdown has neither
context nor window. backend/logging is deleted rather than ported:
v3 takes a *slog.Logger directly, so the v2 logger.Logger adapter had
no caller left.

Phase 1's tail rides along, now that it can: the Makefile's wails
invocations, all 50 webkit2_41 sites, lefthook, both packaging recipes
and ci.yml's apt lists. v3 builds against GTK4 + WebKitGTK 6.0, which
Arch and ubuntu:24.04 both ship, so the tag is a deletion rather than
a translation.

Phase 4 is next and the branch is not usable until it lands: the app
builds, but frontend/wailsjs/ is v2's tree and nothing regenerates it,
so the frontend cannot reach the backend yet.

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 14:01:02 -04:00
co-authored by Claude Opus 5
parent f47b2db308
commit 4471db3aef
32 changed files with 601 additions and 564 deletions
+38 -26
View File
@@ -8,10 +8,10 @@ LDFLAGS := -X 'main.version=$(VERSION)' -X 'main.commit=$(COMMIT)'
DEV_YJ_HOME ?= $(HOME)/.local/share/yellowjacket-dev
dev: setup generate clean
if [ -f .env ]; then set -a; . ./.env; set +a; fi; : "$${YJ_HOME:=$(DEV_YJ_HOME)}"; export YJ_HOME; go tool wails dev -tags webkit2_41 -loglevel Debug -v 2
if [ -f .env ]; then set -a; . ./.env; set +a; fi; : "$${YJ_HOME:=$(DEV_YJ_HOME)}"; export YJ_HOME; go tool wails3 dev -config ./build/config.yml
dev-debug: setup generate clean
if [ -f .env ]; then set -a; . ./.env; set +a; fi; : "$${YJ_HOME:=$(DEV_YJ_HOME)}"; export YJ_HOME; YJ_LOG_LEVEL=debug go tool wails dev -tags webkit2_41 -loglevel Debug -v 2
if [ -f .env ]; then set -a; . ./.env; set +a; fi; : "$${YJ_HOME:=$(DEV_YJ_HOME)}"; export YJ_HOME; YJ_LOG_LEVEL=debug go tool wails3 dev -config ./build/config.yml
# ── Headless harness (plan 005) ──────────────────────────────────────
# The same dev server `make dev` runs, minus the blocking GTK window:
@@ -100,11 +100,15 @@ ui-visual-update: ## Re-record the screenshot baselines
ui-setup: ## Install the Vitest browser provider's own Chromium (once)
@cd frontend && pnpm install && npx playwright install chromium
# frontend/wailsjs is generated by `wails`, NOT by `go generate`, so the
# pre-commit codegen check does not cover it: a renamed Go struct field
# currently surfaces at runtime, in a window. File modes are ignored
# because `wails generate module` rewrites the runtime files as 755.
bindings-check: ## Fail if frontend/wailsjs is stale against the Go bindings
# Bindings are generated by `wails`, NOT by `go generate`, so the
# pre-commit codegen check does not cover them: a renamed Go struct
# field currently surfaces at runtime, in a window.
#
# NOTE (plan 009 phase 4): this still checks v2's frontend/wailsjs,
# which nothing regenerates now that the v2 CLI is gone. It is
# excluded from the pre-commit hook until the frontend moves to
# frontend/bindings.
bindings-check: ## Fail if the generated bindings are stale
@./scripts/bindings-check.sh
# A backtick inside a comment in a css`` literal ends the literal, and
@@ -125,11 +129,17 @@ skill-check: ## Fail if .pi/ documents a make target that does not exist
commit-check: ## Fail if a commit subject is not a Conventional Commit
@./scripts/commit-check.sh $(if $(RANGE),--range $(RANGE))
bindings: ## Regenerate frontend/wailsjs from the bound Go structs
go tool wails generate module -tags webkit2_41
@chmod 644 frontend/wailsjs/runtime/runtime.js \
frontend/wailsjs/runtime/runtime.d.ts \
frontend/wailsjs/runtime/package.json
# v3 generates TypeScript into frontend/bindings/, nested by Go import
# path, rather than v2's frontend/wailsjs/. The 93 frontend import
# sites still point at the old tree, so this writes the new one beside
# it until plan 009 phase 4 moves them; the chmod dance that used to
# follow is gone with v2's generator, which wrote its runtime files 755.
#
# The tag set is pinned deliberately: the generator is a static
# analyser, so it only sees the configuration it is told about, and the
# one that matters is the one users run.
bindings: ## Regenerate frontend/bindings from the bound Go services
go tool wails3 generate bindings -clean=true -ts -i
.PHONY: dev-headless dev-headless-fresh dev-stop dev-logs \
sandbox-seed sandbox-seed-bulk sandbox-seeds e2e e2e-setup e2e-report \
@@ -158,7 +168,7 @@ fresh-install: setup generate clean
case "$$(findmnt -no FSTYPE -T "$$YJ_HOME" 2>/dev/null)" in \
tmpfs|ramfs) echo "==> WARNING: $$YJ_HOME is RAM-backed; the search index import needs ~6GB of real disk. Set FRESH_HOME_BASE to a disk-backed path." ;; \
esac; \
go tool wails dev -tags webkit2_41 -loglevel Debug -v 2
go tool wails3 dev -config ./build/config.yml
# Named, persistent sandboxes: `make sandbox foo` runs dev against
# $(FRESH_HOME_BASE)/yellowjacket-sandbox-foo, creating it on first use
@@ -218,7 +228,7 @@ sandbox-%: setup generate clean
case "$$(findmnt -no FSTYPE -T "$$YJ_HOME" 2>/dev/null)" in \
tmpfs|ramfs) echo "==> WARNING: $$YJ_HOME is RAM-backed; the search index import needs ~6GB of real disk. Set FRESH_HOME_BASE to a disk-backed path." ;; \
esac; \
go tool wails dev -tags webkit2_41 -loglevel Debug -v 2
go tool wails3 dev -config ./build/config.yml
sandboxes: ## List existing named sandboxes
@ls -d "$(SANDBOX_DIR)"-* 2>/dev/null \
@@ -228,10 +238,10 @@ sandboxes: ## List existing named sandboxes
.PHONY: sandbox sandbox-rm sandboxes
build-dev: generate
go tool wails build -tags webkit2_41 -debug -clean -ldflags "$(LDFLAGS)"
go tool wails3 task build DEV=true
build-prod: generate
go tool wails build -tags webkit2_41 -clean -upx -ldflags "-s -w $(LDFLAGS)"
go tool wails3 task build
build-frontend:
cd frontend && pnpm install && pnpm build
@@ -272,14 +282,16 @@ bulkdata-clean: ## Delete the bulk measurement library
.PHONY: testdata testdata-force testdata-clean bulkdata bulkdata-clean
# The tag sets must match `make test` exactly, or lint is checking three
# configurations that nothing builds. webkit2_41 is not optional: without
# it wails resolves webkit2gtk-4.0, which Ubuntu 24.04 no longer ships, so
# the `dev` pass (wails' own app_dev.go is dev-tagged and pulls in the 4.0
# assetserver) fails to typecheck anywhere but Arch.
# configurations that nothing builds. The webkit2_41 tag these all used
# to carry is gone with v2: v3 builds against GTK4 + WebKitGTK 6.0 by
# default, which both Arch and ubuntu:24.04 ship, so the default tag set
# is the one that ships. (`-tags gtk3` still exists as an escape hatch
# for a machine without webkitgtk-6.0; it is not what CI or releases
# build.)
lint:
go tool golangci-lint run --build-tags webkit2_41
go tool golangci-lint run --build-tags "webkit2_41 indexbuild"
go tool golangci-lint run --build-tags "webkit2_41 dev"
go tool golangci-lint run
go tool golangci-lint run --build-tags indexbuild
go tool golangci-lint run --build-tags dev
# Three passes: the app build, the `indexbuild` build that adds the
# CI-only dump importer, and the `dev` build that adds profiling and
@@ -287,12 +299,12 @@ lint:
# exercise backend/explore/dump*.go, cmd/indexbuild or the harness
# control surface at all.
test: testdata
go test -tags webkit2_41 -race -count=1 -timeout 120s ./...
go test -tags "webkit2_41 indexbuild" -race -count=1 -timeout 300s \
go test -race -count=1 -timeout 120s ./...
go test -tags indexbuild -race -count=1 -timeout 300s \
./backend/explore/... ./cmd/...
# backend/testctl only exists under the `dev` tag, so the pass above
# does not compile it, let alone run it.
go test -tags "webkit2_41 dev" -race -count=1 -timeout 120s \
go test -tags dev -race -count=1 -timeout 120s \
./backend/testctl/...
vulncheck: