You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
keep the first restored macOS content view on WebKit's persistent data store so the WebUI hermes_session cookie survives app restarts
keep later restored views incognito for per-tab profile isolation, but seed only exact-origin, destination-scoped cookies before navigation
explicitly clear a stale hermes_profile cookie when restoring the default profile
carry cookie donors across all restored native window groups without writing auth tokens into the JSON session blob
preserve direct plain-HTTP WebUI targets on localhost, Tailscale, LAN, and SSH forwards via the scoped macOS web-content ATS exception
Root cause
build_restored_macos_tab unconditionally used .incognito(true). The source explicitly documented that authenticated servers would re-prompt after restart, so a valid 30-day WebUI auth cookie was discarded whenever the desktop app restored its session.
Security
login cookie values are never logged or written into desktop preferences/session JSON
donor selection requires exact normalized scheme, host, and effective port
copied cookies are additionally filtered by destination domain, path, and Secure scope
only the first restored view uses the persistent store; later views remain isolated
two fail-closed independent review cycles were run; the first found default-profile and cookie-scope blockers, both fixed; the second reported zero logic/security blockers
Verification
cargo fmt --check
cargo clippy -- -D warnings
cargo test — 27 passed, 1 intentional live-network test ignored
python3 scripts/test_macos_ats.py
plutil -lint src-tauri/Info.plist
release build completed and local app bundle passed codesign --verify --deep --strict
live macOS acceptance: logged in once, quit PID 2431, relaunched as PID 2558, restored /session/1a08bea49b3f returned HTTP 200 with no new /api/auth/login POST
Test plan
first restored tab uses the persistent cookie store
later restored tabs remain incognito
default-profile restore clears stale profile selection
native WKHTTPCookie conversion supplies a concrete domain for host-only server cookies, so the domain/path/Secure filter can match WebUI's hermes_session and hermes_profile cookies;
queued main-thread seed tasks are FIFO, so the first persistent donor is prepared before later incognito readers;
auth-cookie values remain in WebKit memory/storage and are not written into session JSON;
profile selector is still the only value persisted in the session blob.
The patch remains changes-needed on two deterministic isolation paths plus evidence.
1. Saved profile cannot reliably replace the donor profile cookie
The seed loop (windows.rs:741-767) copies every destination-scoped donor cookie, including the donor's hermes_profile. Native WKHTTPCookie conversion gives that cookie a concrete host domain.
The next Set branch (:775-780) writes session::profile_cookie(value), whose unit test explicitly requires domain() == None (session.rs:373-382). Locked wry 0.55.1 converts None to an empty NSHTTPCookieDomain. Cookie identity is name + domain + path, so the empty-domain cookie cannot replace the copied host-domain donor cookie. A restored B-profile tab can retain A's donor selector, emit competing same-name cookies, or hit wry's native cookie-construction expect if Darwin rejects the empty domain.
Before seeding, exclude every hermes_profile cookie from the donor copy. Then set the saved selector with the exact target host domain (or delete exact-origin selectors first and set one verified replacement). Add a real Mac restore with donor=A, restored=B and prove only one target-scoped profile cookie exists and B is active.
2. Cookie-operation failure navigates under the wrong profile
At windows.rs:738-807, every failure is logged and then navigation proceeds:
donor cookies() failure;
inherited set_cookie() failure;
target profile set_cookie() failure;
default-profile cookies() failure;
profile delete_cookie() failure.
This is safe-ish for auth inheritance (a failed auth seed can fall back to login), but it is not safe for profile authority. A failed set can open the deep route under default/stale profile; a failed clear can leave the donor/persistent hermes_profile selected. The code then navigates anyway, while the PR promises each restored tab reopens on its saved profile.
Make profile settlement fail closed before navigation:
seed same-origin auth cookies, excluding hermes_profile from donor copy;
set the exact saved profile or delete all destination-scoped profile cookies for default;
read back and require the exact expected selector/absence;
only then navigate the saved deep URL;
on failure, do not open that deep route under unknown profile authority—skip restoration for that tab or open a safe root/login surface with an explicit diagnostic.
Bind the operation to the restored window/tab identity so a late cookie callback cannot navigate a closed/replaced view.
3. Current tests do not traverse WebKit/Tauri cookie lifecycle
The added Rust tests cover pure booleans/origin/path predicates. They do not call WebviewWindow.cookies/set_cookie/delete_cookie, build persistent/incognito data stores, or prove FIFO settlement.
The reported live acceptance proves one restored tab stays authenticated. It does not prove the new multi-tab/multi-window claim.
Required exact-head Mac matrix:
first restored persistent tab: default profile and named profile;
second/third incognito tabs: auth inherited, each exact saved profile, no cross-tab profile bleed;
later native window group inherits from the same exact-origin donor;
default-profile tab clears a donor's non-default selector;
different scheme/host/effective port receives zero donor cookies;
donor read, auth set, profile set, profile read, and profile delete failures—profile failures never navigate the saved deep route;
app restart plus reopen proves cookies remain out of session JSON and values/logs;
exact PR cargo fmt, clippy, tests, release build, codesign, and live restore evidence.
Also exercise a cold persistent-store read near wry's one-second native cookie-operation timeout; timeout must not silently navigate under unverified profile ownership.
The upstream workflow is currently action_required with zero jobs, so there is no repository-owned exact-head CI result yet. Maintainer approval is required before this can be called gate-clean.
scripts/test_macos_ats.py is not wired into .github/workflows/test.yml, and it checks source plist bytes rather than the built app bundle. Wire it into the Mac gate and inspect the built bundle's merged Info.plist.
4. ATS exception is broad—document it honestly
NSAllowsArbitraryLoadsInWebContent=true is scoped to embedded WebKit versus native Rust probes, but it permits arbitrary cleartext subresources inside that WebView, not only localhost/Tailscale/LAN/SSH hosts. Top-level navigation remains host-gated by navigation_allowed, which limits the impact. Keep this only as an explicit product tradeoff and add an integration oracle for allowed configured HTTP target plus rejected foreign top-level navigation; the current Python test only asserts a plist boolean.
Verdict: changes needed. The cookie-persistence model is promising, but profile identity must settle fail-closed and the claimed restored-tab matrix needs exact Mac execution before merge.
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
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.
Summary
hermes_sessioncookie survives app restartshermes_profilecookie when restoring the default profileRoot cause
build_restored_macos_tabunconditionally used.incognito(true). The source explicitly documented that authenticated servers would re-prompt after restart, so a valid 30-day WebUI auth cookie was discarded whenever the desktop app restored its session.Security
Verification
cargo fmt --checkcargo clippy -- -D warningscargo test— 27 passed, 1 intentional live-network test ignoredpython3 scripts/test_macos_ats.pyplutil -lint src-tauri/Info.plistcodesign --verify --deep --strict/session/1a08bea49b3freturned HTTP 200 with no new/api/auth/loginPOSTTest plan