Repository navigation
feat: show a real WebKit page in the Mac card's Browser tab - #19
Merged
Merged
Conversation
On macOS a card's Browser tab is a stream of screenshots from headless Chrome. The capture passed a clip at 0,0, but Chrome reads the clip in page coordinates. Once the page scrolled, the clip pointed above the viewport and those rows came back blank: scroll 300px and the top 300px of the frame was empty, scroll a full screen and nothing was left. Start the clip at the visual viewport's page offset, which is what Playwright does for its own screenshots. Windows shows the live WebView2 surface and doesn't use this capture. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each live frame was a lossless PNG at Retina density. In the Mac app that took 133ms on average to capture, up to 284ms, and came to about 530KB of base64. Scrolling showed three or four frames a second, each one late. JPEG at quality 85 takes about 40ms and 130KB for the same page, so a scroll now lands at roughly 8 frames a second with nothing queued behind it. Text stays sharp at 2x. Only the live frame changes. Screenshots a worker observes and ones saved to a card's artifacts stay PNG, and the Windows WebView2 capture is untouched. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two behaviours the browser tests never checked: a card page can't load plaintext from a host other than this machine, and a target=_blank link opens as another tab of the same card. Both pass on the current code and fail when the route or the popup listener is removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The manager now talks to one interface instead of Playwright pages. Headless Chrome and WebView2 sit behind Playwright adapters in playwright-engine.ts; pool.ts and native-pool.ts are unchanged, so the Windows calls happen in the same order as before. The capture tests only change how they reach the manager's internals. This is where the Mac's native WebKit surface plugs in next. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On macOS 14 and later a card's Browser tab is now a WKWebView placed over the card, like the WebView2 surface on Windows, instead of JPEG frames from headless Chrome. Google and other sites see an ordinary WebKit browser, and scrolling is native. - One WebKit data store per card, kept between launches. - Guest pages get no bridge; MemCode's scripts run in their own content world. Plaintext only reaches this machine (content rules plus the navigation check). Camera, microphone and downloads are refused. - The human's own clicks, keys and scrolling are seen by an AppKit event monitor, so taking control from a worker needs no timing guess. - Address bar, tabs, back/forward/reload and page-opened windows work. Worker click/type/scroll on the Mac come in the next commit. macOS 13 keeps the headless Chrome frames. Windows is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Workers can now click, type, press keys, choose options, scroll and hover in the WKWebView over the card, and observe returns the accessibility tree in the same shape as Playwright's aria snapshot. - Each input goes straight to the WKWebView as a trusted event, and the driver waits until the page has seen it (a counter of trusted events in MemCode's own content world) before the next step. Without that wait, WebKit could apply a later insertText before an earlier keyDown. - Clicking a select, file, date, time or color control is refused: WebKit answers those with an AppKit menu or panel on screen. Selects go through choose, as on the other platforms. - If a worker click makes the visible card take the keyboard, it goes back to whatever had it, unless the human clicked meanwhile. - The content world is now kept alive. WebKit dropped its state whenever the API object was released, so the counter reset on every call. The tests run the same driver scripts against real Chrome pages through a host with the Rust module's methods. The scripts were also checked in a WKWebView: counts, refs, tree, and a fresh counter after navigation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On the Mac, a popup that closed itself with window.close() stayed open as a tab. wry's UI delegate has no webViewDidClose:, so WebKit's request went unheard. OAuth sign-in popups finished, but left a tab behind. Each card view now has a small delegate in front of wry's. It notes webViewDidClose: and forwards every other message to wry's delegate, so popups, file uploads and the camera and microphone denial work as before. The next browser call drops the closed view, outside WebKit's callback, and the runtime closes its tab when browser_pages no longer lists it. A card's first tab can close itself too when it has one history entry, as in Chrome. Unit tests cover the close and the forwarding. A real WKWebView check confirmed that popups still open through the forwarded delegate and that both kinds of close are heard. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Mention Blocks like a regular teammate with your question or request: @blocks review this pull request Run |
Alex793x
added a commit
that referenced
this pull request
Nov 23, 2026
… [skip ci] #19 lists block2 and the objc2 crates as MemCode's own dependencies. They were already in the lock through Tauri, so no notice changes; only the Cargo.lock fingerprint moves. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Alex793x
added a commit
that referenced
this pull request
Nov 23, 2026
… [skip ci] #19 lists block2 and the objc2 crates as MemCode's own dependencies. They were already in the lock through Tauri, so no notice changes; only the Cargo.lock fingerprint moves. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change
On the Mac, a card's Browser tab used to show screenshots of a hidden headless Chrome. Scrolling
blanked the page, and frames arrived 3–4 times a second. Google also answered searches with its
"unusual traffic" page, because that Chrome reports itself as
HeadlessChromewithnavigator.webdriverset.render.ts,manager.ts). The screenshot clip now starts where thepage is scrolled, and live frames are JPEG: about 40 ms a frame at 2× instead of 133 ms, and about
130 KB instead of 530 KB. macOS 13 and Linux still use these frames.
BrowserEngineport (runtime/browser/engine.ts). The manager talks to an engine. HeadlessChrome and WebView2 now sit behind Playwright adapters in
playwright-engine.ts.pool.tsandnative-pool.tsare unchanged.src-tauri/src/browser/macos/,runtime/browser/webkit-engine.ts). A WKWebView sits over the card, the way WebView2 does onWindows, so scrolling is native.
http:is blocked except for localhost.webkit-driver.ts,webkit-accessibility.ts). They have thesame tools and the same text format as on Windows: click, type, press, choose, scroll, hover,
and observe with an aria-snapshot tree. A click, key press or scroll by the person in the card
takes control from the worker.
would open a native panel. Use choose or type instead.
self_close.rs). A popup that callswindow.close(),such as an OAuth sign-in, now closes its tab.
These seven commits were first made on top of
test/sharing-two-computers. They are replayed hereonto
devwithout any of the sharing commits, and the diff is byte-identical to the build that wastested.
Validation
On a Mac (macOS 27.2, Apple silicon), at this branch's head:
npm ci, thennpm run typecheck: passed.npm test: 1,183 tests, 1,180 passed, 0 failed, 3 skipped.npm run build: passed.cargo testinsrc-tauri: 46 passed, 1 ignored. The three unused-import warnings it prints(
beta_store.rs,browser.rslines 3–4) are in lines this branch doesn't change, and they showon
devtoo.Earlier, on the same diff before the replay:
scripts/macos-cold-start.mjspassed against a releaseMemCode.appbuilt from it. The nativeprocess started, the bundled Node was used, and the renderer reached
workspace:load. It was notrerun on this branch.
and reported that it works much better.
Still pending:
Windows. WebView2 now goes through the new port, so it needs a check on the PC.
npm ci,node scripts/prepare-desktop-runtime.mjs,npm run dev.The Windows Rust target was not compile-checked, because
ringneeds a Windows C toolchain.Not tried by hand in the app yet: a worker driving the Mac page, and a sign-in popup closing
itself. Both are covered by tests and by a scratch WKWebView harness.
Known gaps:
iframes.
keyboard focus is handed back to whatever had it.
User impact
On macOS 14 and later, each card now keeps its own browser cookies and sign-ins across restarts.
WebKit stores them under
~/Library/WebKit/<bundle id>/WebsiteDataStore/. The old headless browserkept nothing between sessions. Saved projects, settings and updates are unchanged.
🤖 Generated with Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.