diff --git a/PLAN.md b/PLAN.md index b3831f9..ad08bde 100644 --- a/PLAN.md +++ b/PLAN.md @@ -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). diff --git a/Plans/08 WebKit engine/S044-engine-seam.md b/Plans/08 WebKit engine/S044-engine-seam.md new file mode 100644 index 0000000..66d06c4 --- /dev/null +++ b/Plans/08 WebKit engine/S044-engine-seam.md @@ -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. diff --git a/Plans/08 WebKit engine/S045-gtk-host.md b/Plans/08 WebKit engine/S045-gtk-host.md new file mode 100644 index 0000000..7e58409 --- /dev/null +++ b/Plans/08 WebKit engine/S045-gtk-host.md @@ -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>`, `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. diff --git a/Plans/08 WebKit engine/S046-smoke-harness.md b/Plans/08 WebKit engine/S046-smoke-harness.md new file mode 100644 index 0000000..2c901be --- /dev/null +++ b/Plans/08 WebKit engine/S046-smoke-harness.md @@ -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. diff --git a/Plans/08 WebKit engine/S047-page-channel.md b/Plans/08 WebKit engine/S047-page-channel.md new file mode 100644 index 0000000..e746ca3 --- /dev/null +++ b/Plans/08 WebKit engine/S047-page-channel.md @@ -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. diff --git a/Plans/08 WebKit engine/S048-ui-callbacks.md b/Plans/08 WebKit engine/S048-ui-callbacks.md new file mode 100644 index 0000000..0dbb20f --- /dev/null +++ b/Plans/08 WebKit engine/S048-ui-callbacks.md @@ -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, `