webkit-spike: hidden run result, D-035..D-040, plans 08 WebKit engine S044-S055

GTK 4 host + transparent egui GLArea over WebKitGTK proven hidden (Xvfb + nested
niri): pick fall-through, real input and IME, egui menus over video, pacing equal
with and without the overlay. Spike fixes: IM client widget, wl-input Y flip,
SPIKE_EGUI=0 layout, URL trim.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
astar76 2026-11-13 02:01:11 -06:00
commit 63b39d7b7e
30 changed files with 640 additions and 16 deletions

View file

@ -12,7 +12,8 @@ About 19k lines written across storage, networking, ad blocker, media, importer,
3. **Gaps** — work through `docs/REVIEW.md`, fix the user's review items, add MPRIS media keys (other candidates deferred, D-002).
4. **UI redesign** — Material You (tonal-spot schemes, spring motion, expressive shapes) and the animated new tab page per `docs/UI-BRIEF.md`, using the `app-taste` skill. Starts only after the framework works.
5. **Polish pass** (`Plans/07 Polish pass`, input `docs/review/phase5.md`) — the crash, load speed, SVG/masks, small fixes, flyouts and context menu, custom download manager, a DevTools window, motion rules, a little-things sweep and site passes; ends with the phase 5 review (S042).
6. Packaging and release (Linux AppImage/tar.gz, Windows installer and zip) when the user asks.
6. **WebKit engine** (`Plans/08 WebKit engine`, D-032–D-040, runs first) — GTK 4 host with the egui overlay over WebKitGTK 6.0 views, engine callbacks, ad block via content filters + web process extension, network/privacy/downloads, profile and sealed cookies, tuning defaults, Servo removal, site pass vs Chromium; Widevine later.
7. Packaging and release (Linux AppImage/tar.gz, Windows installer and zip) when the user asks.
Each of phases 1–4 ends with a user review plan (D-003).

View file

@ -0,0 +1,35 @@
# S044 — Engine seam: pure logic out of the Servo files
> Category 08 WebKit engine · Model: Opus · Effort: medium · Depends on: — · Size: M · Human: no · **cargo** (main target/)
> Files touched: src/hub.rs, src/net/privacy.rs (new), src/adblock.rs, src/tabs.rs, src/app.rs, src/actions.rs, src/selftest.rs, src/store/cookies.rs, Cargo.toml (no dep changes)
## Goal
First step of `docs/engine/servo-removal.md` §7: everything that must survive Servo moves out of Servo-typed code, and
the event surface the glue produces becomes engine-neutral, so S045 can swap the engine without touching app logic.
The app still builds and runs on Servo at the end of this plan.
## Read
- `docs/engine/servo-removal.md` §3 (all), §7.
- `src/hub.rs` (whole), `src/tabs.rs` (types), `src/app.rs` `handle_event` (547–800), the `hub::` uses in `src/actions.rs` (grep).
## Steps
- [ ] Move `privacy_headers`, `strip_tracking`, the Firefox-style language list and third-party matching (from `hub.rs` / `net::nacre` callers) into `src/net/privacy.rs` with their unit tests (`privacy_language_list_is_firefox_style`, `privacy_headers_follow_the_settings_and_reach_requests`, `third_party_matching_keeps_same_site_subdomains`); Servo code calls the new module.
- [ ] Move `HubConfig` and the request decision (HTTPS-only upgrade, tracking strip, image permission, ad-block verdict → `Decision` enum with Block/Replace/Redirect/Allow) out of `Hub::decide` into an engine-neutral `fn decide(cfg, req) -> Decision` (pure, unit-tested); `load_web_resource` becomes a thin adapter.
- [ ] Give tabs a Nacre-owned view id (`ViewId(u64)`, reuse `new_tab_id`) and make `hub::Event` carry it instead of `WebViewId`; one map `WebViewId → ViewId` lives in the Servo glue only.
- [ ] Replace Servo payload types in `Event` and `tabs.rs` (`LoadStatus`, `JSValue`, `ContextMenu`, `EmbedderControl`, `PermissionRequest`, `ConsoleLogLevel`, …) by small Nacre enums/structs (`LoadState`, `JsValue` = `serde_json::Value`, `PageMenuRequest`, `Control`, `PermissionAsk`, …) holding a glue-side handle (boxed responder closure) where Servo needs an answer object.
- [ ] Port `selftest.rs` JS-result matches and `fakeload` to the neutral types.
- [ ] `nice cargo build --release -j 2` green; `nice cargo test --release -j 2` green (new tests counted).
- [ ] Smoke on Servo still green: `tools/smoke.sh tests/smoke/launch.txt`, `basics.txt`, `input.txt` (hidden).
- [ ] PROGRESS entry, INDEX line, tracker, commit `S044: …`, push.
## End criteria
- `grep -rn "servo::" src --include=*.rs | grep -v -E "src/(hub|window|app|resources)\.rs"` lists only glue adapters (each named in PROGRESS); `src/net/privacy.rs` has no `servo` import.
- `cargo test` green, launch/basics/input smokes green.
## Pitfalls
- No behaviour change: this is a move, not a rewrite (CLAUDE.md §3). Keep the `hub::Event`-after-spin design.
- Servo needs answers synchronously in `load_web_resource`; keep the decision pure and fast.
- One cargo user per target/ (CLAUDE.md §4).
## Handoff (→ PROGRESS.md)
List the neutral types and where the glue adapters live; S045 implements the same `Event` surface on WebKit.

View file

@ -0,0 +1,38 @@
# S045 — GTK 4 host with the egui overlay; WebKitGTK views; Servo out of the build
> Category 08 WebKit engine · Model: Opus · Effort: high · Depends on: S044 · Size: L · Human: no · **cargo** (main target/)
> Files touched: Cargo.toml, build.rs, src/main.rs, src/app.rs, src/window.rs, src/hub.rs → src/engine/{mod,view,host}.rs, src/egui_area.rs (new, from the spike), src/keys.rs, src/tabs.rs, src/ui/mod.rs, src/actions.rs (load/back/forward/reload/stop/close)
## Goal
D-033/D-035: Nacre runs in a `gtk::Application` window: `Gtk.Overlay { Gtk.Fixed { Gtk.Stack of WebKit WebViews at
egui's page rect }, EguiArea }`, today's egui Material You chrome drawn unchanged by the overlay. winit, Servo and
`servo-net` leave the build. At the end the app builds, opens pages, tabs/navigation work and it looks like today.
## Read
- `docs/engine/webkit-spike.md` (Result + Unproven); `spikes/webkit-egui/src/{egui_area.rs,main.rs}` (whole).
- `docs/engine/servo-removal.md` §1, §3.1, §3.2 (rows for url/title/status/load/favicon/history/closed/crashed), §3.3, §3.4, §3.5.
- `src/app.rs` (event loop parts: `App::new`, `spin`, `start_servo`, `open_window`, `draw`, `ApplicationHandler` impl, `window_input`), `src/window.rs`, `src/keys.rs` header.
## Steps
- [ ] Cargo: drop `servo`, `servo-net`, `content-security-policy`, the `media` feature, `[patch.crates-io]` Servo entries, `winit`, `egui-winit`, `gilrs` (WebKit reads gamepads), the gst-mse rpath in `build.rs`; add `gtk4 =0.11.5` (v4_20), `webkit6 =0.6.1` (v2_52) as in the spike. Keep `vendor/` on disk (S053 deletes it). Keep `vendor/epaint` patch until S053 re-checks text.
- [ ] `src/egui_area.rs` from the spike (GLArea, `contains()` pick rule, input controllers, IME with `set_client_widget`, repaint timer); add clipboard (gdk clipboard ↔ egui copy/cut/paste), cursor icon from egui output, HiDPI scale, window focus/theme events.
- [ ] `src/engine/`: per-profile `NetworkSession` + `WebContext` (persistent dirs from `paths.rs`, ephemeral for incognito), `Settings`, one `WebView` per tab, signals → the S044 `Event` surface (uri, title, mouse-target → status, load-changed + estimated progress, favicon, back-forward list, close, web-process-terminated → crash page).
- [ ] Replace the winit `ApplicationHandler` with GTK: `App` lives in `Rc<RefCell<…>>`, `handle_event` runs from a GLib idle after signals, ticks via `glib::timeout_add_local`, windows = `gtk::ApplicationWindow` (undecorated, Nacre's own titlebar as today), `open_window`/`close_window`/`quit` with orderly view teardown.
- [ ] Keys: GTK key events → `keys.rs` (rename `to_servo` → `to_page`/drop), capture-phase shortcuts so Ctrl+L/T/W/Tab work while the page has focus; page keys go to WebKit natively.
- [ ] Page actions: load, back/forward, reload/hard reload, **stop** (new), zoom, show/hide on tab switch; `ui/chrome.rs load_estimate` uses real progress.
- [ ] `nice cargo build --release -j 2` green (fix compile errors in place); `nice cargo test --release -j 2` green.
- [ ] Hidden check with the spike harness (`spikes/webkit-egui/run/nested.sh`, adapt `spike.sh` to run `target/release/nacre` with a throwaway home): new tab page, https://en.wikipedia.org/wiki/Web_browser, YouTube watch plays after a click; `grim` shots of chrome dark/light next to a pre-switch shot of the same page (`target/smoke` from an older launch run, or check out the last Servo commit's shots in PROGRESS) — Read them, list differences.
- [ ] PROGRESS entry (what is stubbed for S047/S048: dialogs, pop-ups, menus, permissions, scripts), INDEX line, tracker, commit `S045: …`, push.
## End criteria
- `cargo tree -i servo` fails (no Servo in the graph); release build and `cargo test` green.
- Hidden run: Wikipedia renders under today's chrome; YouTube `video.currentTime > 2` after a real click (wl-input); tabs open/switch/close; shots read and differences listed in PROGRESS.
## Pitfalls
- Hidden harness quirks (D-035): software GL env, `WL_INPUT_FLIP_Y=1`, short runtime dir, override `NIRI_SOCKET`, `dbus-run-session`.
- GTK must own the main loop; never block it (net/store work stays on threads → `App::spawn`).
- Don't restructure working modules; app/actions/ui logic stays, only the engine boundary changes.
- Features not ported yet must show as "unavailable"/no-op, not panic.
## Handoff (→ PROGRESS.md)
Where each `Event` comes from; what is stubbed; how to run Nacre hidden until S046 lands.

View file

@ -0,0 +1,32 @@
# S046 — Smoke harness and selftest on the GTK host (hidden nested niri)
> Category 08 WebKit engine · Model: Opus · Effort: medium · Depends on: S045 · Size: M · Human: no · **cargo** (main target/)
> Files touched: tools/smoke.sh, tools/nested-session.sh (new, from spikes/webkit-egui/run/nested.sh), tools/wl-input/ (moved from the spike bin) or src/bin/wl-input.rs, src/selftest.rs, tests/smoke/{launch,basics,input,keys,chrome}.txt, CLAUDE.md §5
## Goal
Every later 08 plan verifies with the smoke harness. Port it to D-035: hidden Xvfb + nested niri + software GL
(`SMOKE_VISIBLE=1` keeps the real-GPU path on the user's screen), selftest commands working on WebKit, the five
basic scripts green.
## Read
- `tools/smoke.sh` (whole), `src/selftest.rs` header + command dispatcher, `spikes/webkit-egui/run/{nested.sh,spike.sh}`, `docs/engine/webkit-spike.md` "How it was run".
## Steps
- [ ] `tools/nested-session.sh start|stop` (Xvfb + niri, config from the spike, throwaway runtime dir, env file) and `smoke.sh` using it instead of a bare Xvfb; keep throwaway HOME/XDG, keyring, fake Discord, `SMOKE_HOME`, `SMOKE_ARGS`, `SMOKE_SIZE` (niri output size via config `mode`), `SMOKE_TIMEOUT`.
- [ ] Move `wl-input` into the main crate as `src/bin/wl-input.rs` (wayland-client deps in `[dev-dependencies]`/bin-only) or keep it a tiny separate crate under `tools/`; document it.
- [ ] selftest: `shot` via `grim` on the nested output (or a GTK snapshot of the window); `click`/`rclick`/`pagetype`/`pagescroll` via real input (wl-input/wtype) when available, else GTK synthesized events; `js`/`assert`/`save` over `evaluate_javascript` → `serde_json`.
- [ ] Make `launch.txt`, `basics.txt`, `input.txt`, `keys.txt`, `chrome.txt` green hidden (fix the app where they fail, script only where the check is Servo-specific).
- [ ] `SMOKE_VISIBLE=1` path documented and syntax-checked (not run while the user sleeps, D-034).
- [ ] CLAUDE.md §5 smoke row rewritten (nested niri, software GL, env); §4 pitfalls: drop Xvfb-only notes.
- [ ] PROGRESS entry, INDEX line, tracker, commit `S046: …`, push.
## End criteria
- `tools/smoke.sh tests/smoke/launch.txt` (and basics, input, keys, chrome) exit 0 hidden; shots Read.
- Nothing appears on DP-1 during the runs (`niri msg windows` on the user's niri shows no Nacre window).
## Pitfalls
- `pgrep -f`/`pkill -f` patterns match your own shell command line; wait on pid files.
- One nested session at a time (fixed X display number); stop it on every exit path (trap).
## Handoff (→ PROGRESS.md)
Which scripts pass, which are deferred to the plan that ports their feature.

View file

@ -0,0 +1,32 @@
# S047 — Page scripts, page messages, find and JS on WebKit
> Category 08 WebKit engine · Model: Opus · Effort: medium · Depends on: S046 · Size: M · Human: no · **cargo** (main target/)
> Files touched: src/engine/*, src/inject.rs, src/app.rs (`install_page_scripts`, `on_page_message`, cosmetic), src/actions.rs (eval, find, autofill, media actions), tests/smoke/{dialogs,stores-*,integ-*}.txt as needed
## Goal
Everything Nacre does inside pages runs on WebKit: user scripts at document start in all frames, user style sheets,
the page → browser channel (script message handler `nacre`), `evaluate_javascript` with JSON results, find in page,
cosmetic filters, autofill, media actions; Servo-only shims in `inject.rs` dropped.
## Read
- `docs/engine/servo-removal.md` §3.3 (eval, page messages, scripts), §3.7 (inject shims list).
- `src/inject.rs` (whole), `src/app.rs` `install_page_scripts` / `on_page_message` / `apply_cosmetic`.
## Steps
- [ ] `UserContentManager` per profile: `WebKitUserScript` (document start, all frames) for Nacre's scripts, `WebKitUserStyleSheet` for user styles; reinstall on settings change.
- [ ] Script message handler `nacre` → `inject::PageMessage` → `Event::PageMessage`; replace the Servo transport in `inject.rs`.
- [ ] `evaluate_javascript` wrapper returning `serde_json::Value` (JSCValue → JSON string); callers in actions/selftest.
- [ ] Find bar on `FindController` (count, next/prev, highlight, close).
- [ ] Drop/re-check the Servo shims listed in servo-removal §3.7 (UA cleanup, SVG colour, WebGL vendor, fonts check, compressor, caret workaround, seek-then-play, navigator fixes) — each removed or kept with a one-line reason.
- [ ] Smoke: `basics.txt` find steps, `dialogs.txt`, `stores-*`/`integ-*` that use page scripts (autofill, scripts store) green hidden.
- [ ] PROGRESS entry, INDEX line, tracker, commit `S047: …`, push.
## End criteria
- `cargo test` green; the listed smokes exit 0 hidden; `grep -n "Servo" src/inject.rs` returns nothing.
## Pitfalls
- Scripts in iframes: `WebKitUserContentInjectedFrames::AllFrames`; message handlers registered before views are created.
- `evaluate_javascript` returns undefined for statements; selftest scripts expect values.
## Handoff (→ PROGRESS.md)
The JSON result shape and any inject script that changed behaviour.

View file

@ -0,0 +1,36 @@
# S048 — WebKit UI callbacks: pop-ups, dialogs, menus, permissions, full screen, inspector, PiP
> Category 08 WebKit engine · Model: Opus · Effort: high · Depends on: S047 · Size: L · Human: no · **cargo** (main target/)
> Files touched: src/engine/*, src/app.rs (`on_create_new`, `on_permission`, `on_control`, `on_notification`, fullscreen, PiP), src/tabs.rs, src/ui/{dialogs,menus,mod}.rs, src/ui/pages/devtools.rs, src/store/permissions.rs (`unavailable()`), tests/smoke/{dialogs,basics,integ-*}.txt
## Goal
Every engine request that needs the UI goes through Nacre's egui: pop-ups as tabs/windows (related views), alert/
confirm/prompt/beforeunload, file chooser, colour chooser, `<select>` (`show-option-menu`), Nacre's own context menu
(`context-menu` + hit test → `PageMenu`), permission requests → `store::permissions`, HTTP auth, notifications,
full screen, Web Inspector (replaces the Servo devtools pages), PiP by moving the view (state kept).
## Read
- `docs/engine/servo-removal.md` §3.2 (all request/show rows), §3.10, §3.12 (`ui/menus.rs`, `ui/dialogs.rs`, permissions reasons).
- `spikes/webkit-egui/src/main.rs` (`connect_create`, `connect_context_menu`), `src/app.rs` `on_create_new`/`on_permission`/`on_control`, `src/ui/menus.rs` `PageMenu`, `src/ui/dialogs.rs` header.
## Steps
- [ ] `create` → `actions::on_navigation` pop-up rules → related view as tab or pop-up window; `close` signal.
- [ ] `run-dialog` (alert/confirm/prompt/before-unload) and `authenticate` → `tabs::Dialog` egui dialogs, answered asynchronously.
- [ ] `run-file-chooser` (rfd/portal as today), `run-color-chooser`, `show-option-menu` → existing egui pickers positioned at the element rect.
- [ ] `context-menu` → `PageMenu` (link/image/selection/editable from `HitTestResult`), actions via `execute_editing_command` + Nacre actions; WebKit's own menu suppressed.
- [ ] `permission-request` (geolocation, notifications, user media, device info, pointer lock, clipboard, media key system → "later" for Widevine) → `store::permissions`; recompute `unavailable()` reasons for WebKit (remove the Servo 0.7 texts).
- [ ] `show-notification` → system notification; `enter/leave-fullscreen` → window full screen and chrome hidden.
- [ ] Web Inspector (`enable-developer-extras`, inspector window attached/detached); `nacre://devtools` console/network either fed from WebKit or replaced by an "Open Web Inspector" page — pick the smaller, record in PROGRESS.
- [ ] PiP: move the playing view into the PiP window and back (no reload); check page state stays.
- [ ] Smoke: `dialogs.txt`, `basics.txt` (pop-ups, full screen), PiP steps green hidden; shots of each dialog Read.
- [ ] PROGRESS entry, INDEX line, tracker, commit `S048: …`, push.
## End criteria
- `cargo test` green; `dialogs.txt` and `basics.txt` exit 0 hidden; a shot of the egui context menu over a page and of a file chooser request Read.
## Pitfalls
- Signal handlers must return quickly; keep the request object (`ScriptDialog`, `PermissionRequest`, `FileChooserRequest`) alive until the egui answer.
- `create` must return the new view synchronously.
## Handoff (→ PROGRESS.md)
Which requests are wired, which show "unavailable" and why.

View file

@ -0,0 +1,36 @@
# S049 — Ad blocker on WebKit: content filters + web process extension
> Category 08 WebKit engine · Model: Opus · Effort: high · Depends on: S048 · Size: L · Human: no · **cargo** (main target/)
> Files touched: Cargo.toml (workspace member), webext/ (new cdylib crate), src/adblock.rs, src/engine/*, src/app.rs (cosmetic, counts), docs/DESIGN.md (ad blocker section), tests/smoke/{net-adblock,crash-adblock}.txt
## Goal
D-036: network rules compiled once into WebKit content filters (adblock-rust `content-blocking` → Apple JSON →
`WebKitUserContentFilterStore`, cached by list hash), cosmetic filters as today, and a minimal web process
extension for redirect resources, extra headers, tracking-param strip on subresources and blocked counts. The
shield counts and the per-site pause keep working.
## Read
- D-036; `docs/engine/servo-removal.md` §3.6, §3.7 (headers).
- `src/adblock.rs` (whole), the adblock parts of `src/app.rs`/`src/actions.rs` (grep `adblock`), `tests/smoke/net-adblock.txt`.
## Steps
- [ ] Convert lists with adblock-rust's content-blocking feature; measure rule count and compile time for the default lists; write the JSON, compile with `UserContentFilterStore::save`, load and attach per `UserContentManager`; rebuild on list update; per-site pause = an `ignore-previous-rules` rule for that domain (or detach filters for that view).
- [ ] Rules the conversion can't express: list them with counts in DESIGN.md; redirect rules → extension.
- [ ] `webext/`: cdylib web process extension (check crates.io for maintained `webkit6` web-process-extension bindings first; else minimal FFI to `webkit_web_page` `send-request`); gets its config (headers on/off, redirect map, tracking params) from the UI process via `WebContext` initialization user data + messages; `send-request` adds DNT/Sec-GPC/Save-Data, rewrites tracking params, redirects to `nacre-resource:` (URI scheme handler in the UI process serving adblock resources), reports blocked/redirected counts.
- [ ] Blocked counts: content-filter blocks are invisible to the embedder — count them from the extension (`send-request` sees the request? verify) or from `resource-load-started` vs. finished; document the method and its limits.
- [ ] Ship/locate the extension: `WebContext::set_web_process_extensions_directory` to the build dir in dev and `$APPDIR/lib/nacre` in packages.
- [ ] Smoke: `python3 tests/smoke/net/server.py &` + `net-adblock.txt`, `crash-adblock.txt` (as a blocking stress test) green hidden; `privacy-net.txt` header checks green.
- [ ] RAM check: web process PSS with and without filters on 3 sites (`tools/engine-test/sample.py`), in PROGRESS.
- [ ] PROGRESS entry, INDEX line, tracker, commit `S049: …`, push.
## End criteria
- `net-adblock.txt` and `privacy-net.txt` exit 0 hidden; the server's `/log` shows blocked URLs never requested and DNT/GPC headers present.
- `cargo test` green (conversion has unit tests on a small list).
## Pitfalls
- Content-filter compile of big lists can take seconds: do it off the main thread / cache by hash.
- The extension runs in every web process: keep it tiny (no adblock engine there, D-036).
- WebKit content filter regex dialect is limited (no lookbehind, etc.).
## Handoff (→ PROGRESS.md)
Conversion coverage numbers, count method, extension load path.

View file

@ -0,0 +1,34 @@
# S050 — Network bridge, HTTPS-only, certificates, error pages, privacy switches, downloads
> Category 08 WebKit engine · Model: Opus · Effort: medium · Depends on: S049 · Size: M · Human: no · **cargo** (main target/)
> Files touched: src/engine/*, src/net/{bridge,download,dlm}.rs (glue only), src/actions.rs (navigation policy, request_headers), src/app.rs, src/ui/pages/misc.rs (error/cert pages), assets/ (error page look), tests/smoke/{net-privacy,net-downloads,net-real,privacy-*,cache*}.txt
## Goal
The network features run on WebKit: proxy = Nacre's bridge (`NetworkProxySettings`), secure DNS through the bridge,
HTTPS-only and tracking strip on navigations (`decide-policy`), certificate warning + allow (`load-failed-with-tls-errors`,
`allow_tls_certificate_for_host`), Nacre's own error pages (`load-failed` → `load_alternate_html`), third-party cookie
policy, Accept-Language, privacy mode switches, Google UA quirk per view, downloads through `net::download`/the
download manager stubs, HTTP cache on disk.
## Read
- `docs/engine/servo-removal.md` §3.6, §3.7, §3.12 (error pages); D-014; `src/net/bridge.rs` header; `tests/smoke/net-privacy.txt`, `net-downloads.txt` headers.
## Steps
- [ ] Proxy settings to the bridge per session; `NACRE_NO_BRIDGE=1` path; never a real proxy/Tor in tests.
- [ ] `decide-policy`: navigation actions → `actions::on_navigation` (app scope, external schemes, HTTPS-only upgrade, tracking strip); response policy → downloads (`download` for non-displayable MIME / Content-Disposition).
- [ ] `download-started` → Nacre's downloads store/UI or the custom manager hand-off; progress, cancel, destination, finished state.
- [ ] TLS errors → Nacre's certificate warning page; "continue" allows the cert for the host for the run.
- [ ] Error pages from Nacre's look (port `assets/servo/neterror.html`/`badcert.html` style into `nacre://` pages).
- [ ] `CookieManager` accept policy (third-party), `set_preferred_languages`, privacy mode Accept-Language, per-view UA quirk.
- [ ] Smoke (start `python3 tests/smoke/net/server.py &` / `cache/server.py &`): `net-privacy.txt`, `net-downloads.txt`, `privacy-net.txt`, `privacy-mode.txt`, `cache.txt` + `cache-restart.txt` green hidden.
- [ ] PROGRESS entry, INDEX line, tracker, commit `S050: …`, push.
## End criteria
- The listed smokes exit 0 hidden; server `/log` shows DoH lookups through the bridge and the HTTPS upgrade.
## Pitfalls
- Never connect to Tor or proxies in tests (CLAUDE.md §4).
- `decide-policy` is async-capable: use `use_()`/`ignore()` on the decision, don't block.
## Handoff (→ PROGRESS.md)
What still differs from the Servo-era behaviour.

View file

@ -0,0 +1,32 @@
# S051 — Profile folder, sealed cookies, site data, incognito, media source
> Category 08 WebKit engine · Model: Opus · Effort: medium · Depends on: S050 · Size: M · Human: no · **cargo** (main target/)
> Files touched: src/paths.rs, src/store/cookies.rs, src/app.rs (`servo_first_setup`, `clear_on_exit`, media), src/actions.rs (`clear_data`, site info), src/media.rs, src/ui/pages/{misc,settings}.rs (texts), tests/smoke/{cookies*,restore,privacy-incognito}.txt
## Goal
Decisions D-037, D-038, D-039 implemented: profile folder `nacre-browser` with a one-time move from `nacre-servo`;
WebKit's cookie DB on tmpfs sealed into `cookies.bin`; `WebsiteDataManager` for clear data (with dates) and site
info; incognito = ephemeral `NetworkSession`; media state from the page probe + `is-playing-audio`/`set_is_muted`,
one MPRIS player.
## Read
- D-019, D-037, D-038, D-039; `docs/engine/servo-removal.md` §3.8, §3.9; `src/paths.rs`, `src/store/cookies.rs` (whole); `tests/smoke/cookies.txt` header.
## Steps
- [ ] `paths.rs`: `APP_DIR = "nacre-browser"`; migration (rename config/data/cache once if new missing and old present; delete Servo-only engine files after; log it); unit test with temp dirs; `~/.config/nacre` never touched.
- [ ] Cookies: persistent storage path in `$XDG_RUNTIME_DIR/nacre-<profile>/cookies.sqlite`; at start decrypt `cookies.bin` → `add_cookie` (or write the SQLite) ; seal at quit and 60 s after `changed`; no keyring → run-only; convert Servo-era `cookies.bin` when it parses, else move aside.
- [ ] Clear data / clear on exit / site info flyout on `WebsiteDataManager` (types + since-time) and `CookieManager::get_cookies`; drop the "Servo keeps no dates" text.
- [ ] Incognito: ephemeral session, nothing written; check the throwaway home after a run.
- [ ] Media: probe events + `is-playing-audio` → media state; mute via `set_is_muted`; check whether WebKitGTK publishes its own MPRIS player (`busctl --user list | grep mpris` in the nested bus) and apply D-039 (one player).
- [ ] Smoke: `cookies.txt` → `cookies-restart.txt` → `cookies-cleared.txt` with `SMOKE_KEYRING=1`, `cookies-nokeyring.txt`, `restore.txt`, `privacy-incognito.txt` green hidden; `grep -c` of a test cookie value in the home dir = 0.
- [ ] PROGRESS entry, INDEX line, tracker, commit `S051: …`, push.
## End criteria
- Listed smokes exit 0; no plain cookie value anywhere under the throwaway home (grep); migration unit test green.
## Pitfalls
- Never touch the user's real profile; tests use throwaway homes only.
- WebKit may write `cookies.sqlite-wal`/`-shm` next to the DB: all on tmpfs.
## Handoff (→ PROGRESS.md)
Migration behaviour, seal timing, MPRIS outcome (which player).

View file

@ -0,0 +1,26 @@
# S052 — WebKit tuning defaults, background tabs, memory check
> Category 08 WebKit engine · Model: Sonnet · Effort: high · Depends on: S051 · Size: S · Human: no · **cargo** (main target/)
> Files touched: src/engine/*, src/app.rs (`rest_background_tabs`), src/store/settings.rs (freeze/limited rows), src/ui/pages/settings.rs (texts), docs/engine/tune/README or engine-comparison.md (new row)
## Goal
D-040 defaults in the engine setup with env overrides; background tabs really rest (WebKit can suspend/freeze
hidden views — the old "limited" setting row comes back); RAM of Nacre measured against the D-032 tune data.
## Read
- D-032, D-040; `docs/engine/tune/` (base and mem500/no-page-cache rows); `tools/engine-test/run.sh` header, `sample.py` header; `src/app.rs` `rest_background_tabs`.
## Steps
- [ ] Defaults: page cache off, memory pressure 500 MB, cache model DocumentViewer, HW policy default; `NACRE_WK_*` overrides; log the effective values at start.
- [ ] Background tabs: hidden views frozen/suspended after the setting's delay (check the WebKitGTK 2.54 API: `WebView` visibility already throttles; web process suspension if available); settings texts updated.
- [ ] Measure: Nacre hidden with the tune site list (`tools/engine-test/tune-sites.txt`, 10 tabs, idle phase) with `sample.py`; compare to the tune "mem500/no-page-cache" rows; write the row and the comparison (software GL caveat for VRAM).
- [ ] PROGRESS entry, INDEX line, tracker, commit `S052: …`, push.
## End criteria
- Start log shows the four values; the measurement row is in the doc; `launch.txt`/`basics.txt` still green.
## Pitfalls
- Never run the measurement alongside cargo; one engine run at a time.
## Handoff (→ PROGRESS.md)
Nacre's PSS vs the tune data and what dominates.

View file

@ -0,0 +1,31 @@
# S053 — Remove Servo: vendor crates, gst-mse, Servo-only tests/tools, docs and texts
> Category 08 WebKit engine · Model: Sonnet · Effort: high · Depends on: S052 · Size: M · Human: no · **cargo** (main target/)
> Files touched: Cargo.toml ([patch] epaint), vendor/, build.rs, src/resources.rs, assets/servo/, tools/gst-mse.sh, tests/gst-mse/, tests/smoke/{mse*,painters*,youtube-mse,crash-adblock}.txt, docs/{DESIGN,REVIEW,FEATURES}.md, docs/S027-handoff.md, docs/engine/{mse-spike,privacy-mode}.md, CLAUDE.md §2/§4/§5, PLAN.md, src/ui/pages/{settings,misc}.rs (texts), spikes/webkit-egui/
## Goal
`docs/engine/servo-removal.md` §2, §4, §5, §7 steps 3–4: everything Servo-only leaves the repo, docs describe the
WebKit engine, user-visible texts say WebKit. MSE test pages are kept as plain MSE tests.
## Read
- `docs/engine/servo-removal.md` §2, §4, §5, §3.12 (texts); CLAUDE.md §2, §4, §5.
## Steps
- [ ] Delete `vendor/servo-*`, `vendor/gst-mse` (keep `docs/engine/gst-mse-patches.md`), `src/resources.rs`, `assets/servo/`; remove `vendor/epaint` + its patch, rebuild, check egui text (gallery smoke shot).
- [ ] Delete `tools/gst-mse.sh`, `tests/gst-mse/`, `mse-off.txt`, `mse-leak-check.sh`, `painters*.txt`; port `mse.txt`/`mse-player.txt`/`youtube-mse.txt` without leak/log checks; keep `crash-adblock.txt` as a blocking stress test; update `privacy-net.txt` header.
- [ ] Docs: DESIGN.md WebKit cheat sheet replaces the Servo one; Engine limits rewritten; Servo patch sections removed; REVIEW.md Servo items removed; FEATURES.md states reset to "re-verify on WebKit" where they were verified on Servo; remove `docs/S027-handoff.md`, `docs/engine/mse-spike.md`; `privacy-mode.md` Servo part marked historical.
- [ ] CLAUDE.md §2 facts (WebKit, GTK host, no Servo), §4 pitfalls (no clang/SpiderMonkey/hours-long builds; nested niri), §5 tools; PLAN.md goal/out-of-scope (printing, private mode, 3rd-party cookies now possible; Widevine later).
- [ ] User-visible texts (settings About/engine row, misc pages, task manager) say WebKitGTK + version.
- [ ] Remove `spikes/webkit-egui/` (its harness lives in tools/ since S046); keep `docs/engine/webkit-spike.md`.
- [ ] `nice cargo build --release -j 2`, `cargo test`, smokes launch/basics/input/chrome/gallery/mse green hidden.
- [ ] PROGRESS entry, INDEX line, tracker, commit `S053: …`, push.
## End criteria
- `grep -rni "servo" src Cargo.toml build.rs tools tests/smoke | grep -v -i "nacre-servo"` empty except the migration code in `paths.rs`; build/test/smokes green.
## Pitfalls
- History docs (PROGRESS, DECISIONS, docs/review) stay untouched.
- Don't delete `docs/engine/engine-comparison*`, `tune/`, `runs/` (decision record).
## Handoff (→ PROGRESS.md)
Final file list removed; any doc left with Servo wording on purpose.

View file

@ -0,0 +1,30 @@
# S054 — Site pass on WebKit vs Chromium reference
> Category 08 WebKit engine · Model: Opus · Effort: high · Depends on: S053 · Size: M · Human: no (visible GPU part only when the user is awake) · runs the built app; cargo only for fixes
> Files touched: fixes in src/ as found, tests/smoke/{heavy-web,site-doctor,https}.txt, docs/engine/site-pass-webkit.md (new)
## Goal
D-030/D-031: the daily sites run about as well as in Chromium. For each site, Nacre's hidden shot and the Chromium
reference (Claude browser pane at the same width) side by side, every visible difference fixed or listed.
Supersedes the Servo-era site work of S041 for the engine part.
## Read
- D-030, D-031, D-035; `tests/smoke/heavy-web.txt`, `site-doctor.txt` headers; `docs/engine/webkit-spike.md` Unproven list.
## Steps
- [ ] Site list: YouTube (home, watch, search, Shorts), Reddit, Discord web, GitHub, Wikipedia, DuckDuckGo, Google search + sign-in page, a news site, Twitch, a maps site; size 1280x800.
- [ ] Hidden Nacre shots (`heavy-web.txt`, `site-doctor.txt` extended) + Chromium pane shots at the same width; Read each pair; list differences in `docs/engine/site-pass-webkit.md`.
- [ ] Fix Nacre-side causes (UA, scripts, chrome overlap, input); WebKit engine differences listed, not patched.
- [ ] Interaction checks per site: video plays/seeks/full screen, sign-in form typing, infinite scroll, context menu, pop-up sign-in windows.
- [ ] GPU path (D-035 unproven): if the user is awake and asks, a `SMOKE_VISIBLE=1` run of the watch page with stats (60 fps video under the overlay, dmabuf path); else write it as open in PROGRESS.
- [ ] PROGRESS entry, INDEX line, tracker, commit `S054: …`, push.
## End criteria
- `docs/engine/site-pass-webkit.md` has a row per site with both shots' paths and every difference (fixed/open); `heavy-web.txt` exits 0 hidden.
## Pitfalls
- Never connect to Tor or proxies; sign in only with test data, never the user's accounts.
- The pane's viewport under 768 px emulates a phone: keep ≥ 1024.
## Handoff (→ PROGRESS.md)
Open differences ranked by daily impact.

View file

@ -0,0 +1,26 @@
# S055 — Widevine (later): user-downloaded CDM on first use
> Category 08 WebKit engine · Model: Opus · Effort: high · Depends on: S054 · Size: M · Human: 🧑 user approves the CDM download and tests a DRM site with their account · **cargo** (main target/)
> Files touched: src/engine/*, src/store/settings.rs, src/ui/pages/settings.rs, src/media.rs, docs/DESIGN.md
## Goal
D-032: EME with Widevine where WebKitGTK supports it, CDM downloaded by the user from Google on first use, never
bundled. Runs only when the user asks (not part of the unattended run).
## Read
- D-032; WebKitGTK 2.54 EME/Thunder/OpenCDM support notes (check upstream docs first: whether WebKitGTK on Arch is built with EME and which CDM path it takes).
## Steps
- [ ] Find out whether Arch's `webkitgtk-6.0` has EME + a Widevine path (Thunder/OCDM or GStreamer decryptor); if not, write the finding and what a build would need, stop there.
- [ ] If possible: first-use prompt in egui (what is downloaded, from where, size), download to the profile, enable the setting, `media-key-system` permission flow.
- [ ] Test on a DRM test page (Shaka demo / Bitmovin) hidden; the user tests a real service.
- [ ] PROGRESS entry, INDEX line, tracker, commit `S055: …`, push.
## End criteria
- Either a working EME demo (Shaka Widevine clip plays, hidden) or a written finding of why not, with the needed build options.
## Pitfalls
- Downloads need the user's explicit yes (D-032); never bundle the CDM.
## Handoff (→ PROGRESS.md)
State of DRM support and what the user must do.

View file

@ -6,6 +6,20 @@ Tracker: https://claude.ai/artifact/9AD7fPfwJ4ASFzVTJGKU4h
Engine switch to WebKit (D-032): new category `08 WebKit engine` comes first; Servo-only plans are struck out.
## 08 WebKit engine
- [ ] [S044 — Engine seam: pure logic out of the Servo files](08%20WebKit%20engine/S044-engine-seam.md) · Opus medium
- [ ] [S045 — GTK 4 host with the egui overlay; WebKitGTK views; Servo out of the build](08%20WebKit%20engine/S045-gtk-host.md) · Opus high
- [ ] [S046 — Smoke harness and selftest on the GTK host (hidden nested niri)](08%20WebKit%20engine/S046-smoke-harness.md) · Opus medium
- [ ] [S047 — Page scripts, page messages, find and JS on WebKit](08%20WebKit%20engine/S047-page-channel.md) · Opus medium
- [ ] [S048 — WebKit UI callbacks: pop-ups, dialogs, menus, permissions, full screen, inspector, PiP](08%20WebKit%20engine/S048-ui-callbacks.md) · Opus high
- [ ] [S049 — Ad blocker on WebKit: content filters + web process extension](08%20WebKit%20engine/S049-adblock-webext.md) · Opus high
- [ ] [S050 — Network bridge, HTTPS-only, certificates, error pages, privacy switches, downloads](08%20WebKit%20engine/S050-net-privacy-downloads.md) · Opus medium
- [ ] [S051 — Profile folder, sealed cookies, site data, incognito, media source](08%20WebKit%20engine/S051-profile-cookies-media.md) · Opus medium
- [ ] [S052 — WebKit tuning defaults, background tabs, memory check](08%20WebKit%20engine/S052-tuning-defaults.md) · Sonnet high
- [ ] [S053 — Remove Servo: vendor crates, gst-mse, Servo-only tests/tools, docs and texts](08%20WebKit%20engine/S053-servo-removal.md) · Sonnet high
- [ ] [S054 — Site pass on WebKit vs Chromium reference](08%20WebKit%20engine/S054-site-pass.md) · Opus high
- [ ] [S055 — Widevine (later): user-downloaded CDM on first use](08%20WebKit%20engine/S055-widevine.md) · Opus high · 🧑
## 01 First build
- [x] [S001 — Compile to a binary](01%20First%20build/S001-compile.md) · Opus medium
- [x] [S002 — Unit tests green](01%20First%20build/S002-unit-tests.md) · Sonnet high

View file

@ -38,3 +38,9 @@
- D-032 — 2026-11-13 — Engine switch: Nacre drops Servo and moves to a tuned WebKit (WebKitGTK 6.0 or WPE WebKit 2.54, picked by the 08 spike), Linux only (no Windows builds). Widevine comes later as its own plan (user downloads Google's CDM on first use, never bundled). Reason: engine test (docs/engine/engine-comparison.md, docs/engine/tune/): Servo fails heavy sites (YouTube, Discord, icons); WebKit tuned is at or below Chromium's RAM (2.4–2.5 GB vs 3.3 GB at 10 tabs with page cache off / memory limit) and its VRAM drops with a lighter cache model; WebKit has EME, Web Inspector, mature media. Dropped plans: S011, S029, S030, S032, S033, S037, S038 (Servo-specific; site passes/perf get new WebKit plans). The egui UI, stores, net bridge, ad blocker and nacre:// pages stay. Servo glue (hub.rs, window.rs, vendor/servo-*, gst_mse patches) is removed once WebKit glue works. Supersedes D-028/D-029 order. — user, 2026-11-13 — every remaining plan
- D-033 — 2026-11-13 — Engine host: WebKitGTK 6.0 (installed) in a GTK4 window with Nacre's egui UI over/around the WebKit views (spike design (b), `spikes/webkit-egui/`). No WPE WebKit comparison. — user, 2026-11-13 ("keep webkit normally") — 08 WebKit engine plans
- D-034 — 2026-11-13 — Unattended run (user asleep): spike and 08 plans run their GUI tests hidden in a nested `kwin_wayland --virtual` (or Xvfb via smoke.sh), never on DP-1, so nothing switches the user's workspace or steals focus; visible runs only when the user is awake and asked. Orchestrator decides recommended options alone (no 🧑 plans run tonight). User goal restated: after the WebKit switch Nacre keeps today's look (egui Material You chrome), then the UI is cleaned up and animated (S039 motion, S043 refine). — orchestrator for the user, 2026-11-13 ("do what you think is best … it should look how it is now, UI needs to be fixed, animations and cleanness") — 08 plans, S039, S043
- D-035 — 2026-11-13 — Spike result (extends D-033): the GTK 4 host works — egui in a transparent `Gtk.GLArea` over the WebKitGTK views, GTK's pick sends input to egui only where egui draws, the page gets click/wheel/right click/typing/IME natively, pacing is identical with and without the overlay (`docs/engine/webkit-spike.md`). egui's own IME needs `IMMulticontext::set_client_widget`. GPU path still unproven (hidden runs are software GL). Hidden GUI tests use **Xvfb + a nested niri** (winit backend on X11; `spikes/webkit-egui/run/`), not `kwin_wayland` (not installed): software GL with `LIBGL_ALWAYS_SOFTWARE=1 WEBKIT_DMABUF_RENDERER_FORCE_SHM=1 GSK_RENDERER=gl`, `WL_INPUT_FLIP_Y=1`, short runtime dir; GPU checks only in visible runs (D-034). — orchestrator's session, 2026-11-13 (user asleep, recommended options) — 08 WebKit engine plans, smoke harness
- D-036 — 2026-11-13 — Ad blocking on WebKit: network rules compiled to WebKit content filters (`WebKitUserContentFilterStore`, Apple content-blocker JSON from adblock-rust's `content-blocking` conversion), stored once and shared by every web process; cosmetic filters stay page script/user style sheets. A small web process extension (cdylib loaded via `WebContext` extensions dir) does only what filters can't: DNT/Sec-GPC/Save-Data headers, redirect resources (→ `nacre-resource:` URI scheme), tracking-param strip on subresources, blocked counts/network log back to the UI. No adblock engine inside web processes (RAM per process). — content filters run inside WebKit with no IPC per request; an engine per web process would multiply RAM — S049, S050
- D-037 — 2026-11-13 — Cookies at rest on WebKit (keeps D-019's rule "never plain on disk"): WebKit's SQLite cookie store lives in the per-run `$XDG_RUNTIME_DIR` (tmpfs, 0700) via `CookieManager::set_persistent_storage`; Nacre fills it from the sealed `cookies.bin` at start and seals it back (D-019 key, XChaCha20-Poly1305) at quit and every 60 s after a cookie change. No keyring → cookies for the run only, as before. Servo-era `cookies.bin` is converted when it parses, else moved aside. — keeps encryption without patching WebKit; tmpfs never touches the disk — S051
- D-038 — 2026-11-13 — Profile folder `nacre-servo` → `nacre-browser` (config, data, cache): on first start, if `nacre-browser` is missing and `nacre-servo` exists, it is renamed (one move, logged); Servo-only engine files inside are deleted after the move. `~/.config/nacre` belongs to the Python Nacre and is never touched (the importer reads it). — engine name out of the path; `nacre` is taken by the original — S051
- D-039 — 2026-11-13 — Media on WebKit: Nacre's page-script media probe (`inject.rs` `media.*`, mediaSession hook) stays the one source for the new tab card, Discord and MPRIS; WebKit's `is-playing-audio` and `set_is_muted` replace the mute script. If WebKitGTK publishes its own MPRIS player it is not left as a second player (turned off or Nacre's skipped, whichever the plan finds possible; one player only). — one engine-neutral source already feeds three features — S051, S013
- D-040 — 2026-11-13 — WebKit tuning defaults (D-032 data, `docs/engine/tune/`): page cache off, memory pressure limit 500 MB per web process, cache model `DocumentViewer`, hardware acceleration policy default (on demand; `never` broke JS checks), related views only for pop-ups. Env overrides for tests (`NACRE_WK_PAGE_CACHE`, `NACRE_WK_MEM_LIMIT`, `NACRE_WK_CACHE_MODEL`, `NACRE_WK_HW`). — lowest PSS/VRAM in the tune runs without failed sites — S052

View file

@ -342,6 +342,14 @@ Later: S010 list: user checks the Discord icon with their own client (the Discor
- Removed: `tools/wpt-mse.sh`, `tests/wpt-mse/` (Servo MSE conformance, nothing else used them) and their CLAUDE.md/DESIGN.md mentions.
- Not done (on purpose): src/, Cargo.toml, vendor/, build.rs, gst-mse tools and MSE/painter smoke scripts stay until the WebKit glue builds. No cargo run.
## webkit-spike — GTK 4 host + egui overlay over WebKitGTK, result (D-033/D-035, 2026-11-13)
- Done: spike run hidden (Xvfb + nested niri, software GL; kwin_wayland not installed) on YouTube watch, Wikipedia, DuckDuckGo: egui flyout over a playing video, GTK pick routes egui vs page right, real click/wheel/right click/typing/IME reach the page natively; egui context menu from WebKit's hit test opens links in tabs; window.open → tab. Details and numbers: `docs/engine/webkit-spike.md`.
- Pacing identical with/without the overlay (29.6 vs 29.4 fps, llvmpipe cap; 628 video frames, 0 dropped); egui 65 renders/15 s, 0.46 ms p50; overlay +~20 MB PSS (1310 vs 1287 MB, one YouTube tab).
- Spike fixes: egui IME needs `IMMulticontext::set_client_widget`; `wl-input` `WL_INPUT_FLIP_Y=1` (nested niri mirrors Y); `SPIKE_EGUI=0` layout; URL trim. Harness: `spikes/webkit-egui/run/`.
- Decisions D-035 (result + hidden harness), D-036 ad block, D-037 cookies, D-038 profile `nacre-browser`, D-039 media, D-040 tuning.
- Plans `08 WebKit engine` S044–S055 written, in INDEX before the other open plans, tracker seeded.
- Not proven: GPU/dmabuf path and 60 fps under the overlay (needs a visible run), Web Inspector, full screen, file chooser, HiDPI.
## Later
- Turnstile widget paints as a black half-disc (Servo painting of its iframe/shadow DOM, S006 site doctor).
- Google sign-in past the email step: press Next with a real account, by the user (S006).

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 201 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Some files were not shown because too many files have changed in this diff Show more