Repository navigation
Conversation
…t dropped importValidatedCookies always passed `domain` to cookies.set(). Chromium rejects a __Host--prefixed cookie that carries a Domain attribute, so the most important session cookies (e.g. GitHub's __Host- pair) silently failed and the imported session could read as logged out. Omit the domain and force path '/' + Secure for __Host- names. Also extracts importCookiesFromJson from importCookiesFromFile so the same validated pipeline can take an in-memory array. Fixes both the Settings file import and any programmatic import. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
When the optional agentcookie CLI (github.com/mvanhorn/agentcookie) is on PATH, orca pulls the user's current browser session from `agentcookie export` and loads it through its own validated importer, on startup and on a 5-minute interval. This turns orca's manual one-shot cookie import into automatic, always-fresh sign-in for the embedded browser, with no debug port and no change to behavior when agentcookie is not installed. - src/main/browser/agentcookie-session-sync.ts: PATH detection + pull loop - on by default (agentcookieSyncEnabled), inert when agentcookie is absent - detected/last-sync status surfaced in settings for a future Settings UI row Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — integrates an optional external agentcookie CLI to keep the embedded browser signed in automatically, plus a __Host- cookie import fix that also applies to the existing Settings file-import path.
- Add
AgentcookieSessionSync— PATH-detectsagentcookie, runsagentcookie export, and imports the result through the existingimportValidatedCookiespipeline on startup and a 5-minute interval. Inert when agentcookie is absent or the setting is off. - Extract
importCookiesFromJson— shared by the Settings file import and the agentcookie pull so both get identical validation and__Host-host-only shaping. - Fix
__Host-cookie import — previouslyimportValidatedCookiesalways passed adomaintocookies.set(), causing Chromium to silently reject__Host--prefixed cookies (e.g. GitHub's session pair). Now omitsdomain, forcespath='/', and forcessecure=truefor those cookies. - Wire into app lifecycle —
startAgentcookieSessionSync()at app ready,agentcookieSync.stop()at will-quit.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Resolved conflicts, preserving this PR's change on top of upstream's restructuring.
Greptile SummaryThis PR adds optional automatic cookie sync from the
Confidence Score: 3/5Safe to merge for the __Host- bug fix; the agentcookie sync path needs the lastImported naming resolved before the Settings UI is built on top of it. The __Host- fix and the refactor of importCookiesFromFile into importCookiesFromJson are clean and well-tested. The sync loop is inert when agentcookie is absent. The main concern is agentcookieLastImported: it stores an imported cookie count but is named and typed identically to a timestamp field, creating a high likelihood of the wrong rendering when the planned Settings UI row is added. Files Needing Attention: src/main/browser/agentcookie-session-sync.ts and src/shared/types.ts — the lastImported/agentcookieLastImported field semantics need to be settled before the UI layer consumes them.
|
| Filename | Overview |
|---|---|
| src/main/browser/agentcookie-session-sync.ts | New sync loop: PATH-detects agentcookie, runs agentcookie export, and imports the result. Has a naming bug where lastImported stores a cookie count rather than a timestamp, a missing idempotency guard in start(), and silent stderr discard. |
| src/main/browser/browser-cookie-import.ts | Extracts importCookiesFromJson from importCookiesFromFile and fixes __Host- prefix cookies being silently dropped by omitting the domain field when Chromium requires host-only cookies. Fix is correct and well-tested. |
| src/main/index.ts | Wires AgentcookieSessionSync into the app lifecycle: starts after app.whenReady() and stops on will-quit. Guard against double-init is correct; status is persisted to settings with safe conditional spreading. |
| src/shared/types.ts | Adds four optional agentcookie* fields to GlobalSettings. All are optional for backward compatibility. agentcookieLastImported is ambiguously named — it stores a count, but the `number |
| src/shared/constants.ts | Adds defaults for the four new agentcookie settings fields; defaults are sensible (enabled=true, detected=false, sync timestamps null). |
| src/main/browser/agentcookie-session-sync.test.ts | Tests PATH detection, no-op when absent, and enabled/disabled state. Does not cover the successful sync path with a real (mocked) export, or the lastImported count semantics. |
| src/main/browser/browser-cookie-import.test.ts | Adds tests for importCookiesFromJson including the __Host- host-only regression case; coverage is thorough for the new exported function. |
Sequence Diagram
sequenceDiagram
participant App as Electron App
participant Sync as AgentcookieSessionSync
participant FS as PATH / fs.accessSync
participant AC as agentcookie CLI
participant CI as importCookiesFromJson
participant Session as persist:orca-browser
participant Store as SettingsStore
App->>Sync: new AgentcookieSessionSync(options)
App->>Sync: start()
Sync->>FS: detectAgentcookie()
FS-->>Sync: "binary path | null"
Sync->>Store: "onStatus({ detected, lastSyncAt: null, lastImported: null })"
alt agentcookie installed and enabled
Sync->>Sync: syncNow() [immediate]
Sync->>FS: detectAgentcookie()
FS-->>Sync: binary path
Sync->>AC: execFile(binary, ['export'])
AC-->>Sync: JSON cookie array stdout
Sync->>CI: importCookiesFromJson(stdout, partition)
CI->>Session: cookies.set() per cookie
Session-->>CI: ok or skipped
CI-->>Sync: BrowserCookieImportResult
Sync->>Store: "onStatus({ detected:true, lastSyncAt: Date.now(), lastImported: count })"
loop Every 5 minutes
Sync->>Sync: syncNow() [interval]
Note over Sync: concurrency guard: skip if already running
end
end
App->>Sync: stop() on will-quit
Sync->>Sync: clearInterval(timer)
Reviews (1): Last reviewed commit: "Merge upstream/main into feat/agentcooki..." | Re-trigger Greptile
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/browser/browser-cookie-import.ts (1)
568-586: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winForce secure before deriving the URL for
__Host-cookies.
deriveUrlonly forceshttpswhensecureis alreadytrue, butimportValidatedCookiesoverridessecuretotrueduringcookies.set(). A__Host-*entry withsecuremissing orfalsegets anhttp://URL, thencookies.set()rejects it with the per-cookie catch silently counting it as skipped. Force the secure flag invalidateCookieEntrywhenname.startsWith('__Host-')so the derived URL scheme matches the host-prefixed cookie.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 5b76905c-8002-42cc-aa91-a6985983428b
📒 Files selected for processing (7)
src/main/browser/agentcookie-session-sync.test.tssrc/main/browser/agentcookie-session-sync.tssrc/main/browser/browser-cookie-import.test.tssrc/main/browser/browser-cookie-import.tssrc/main/index.tssrc/shared/constants.tssrc/shared/types.ts
|
No rush on the review, just clearing the way. Merged main into the branch (6d38a94). It was a long way behind and conflicted in src/main/index.ts; resolved, and the PR is mergeable again. The agentcookie integration itself is unchanged. |
|
Compatibility note before this lands: the startup/five-minute sync drives the shared JSON/file import pipeline. On current #12601 documents the divergence and #12607 centralizes the filter plus explicit import modes. Please rebase onto/adopt #12607's shared policy before merge, and have the periodic caller deliberately select merge semantics. The manual file importer uses imported-domain replacement; applying that replacement mode every five minutes would overwrite cookies that the live embedded session rotates between syncs. Conversely, inheriting native Chromium's full-jar clear would also destroy unrelated live state. #12166's |
|
thanks for reporting. looking into it |
|
Apologies for the two months — this sat far longer than it should have. The Status: #12607 landed today. The Google source-bound filter now lives in a shared policy module applied to file, Firefox, Safari, and native Chromium imports, and On the agentcookie integration: to be clear, this isn't a knock on the implementation — it's cleanly built and does what it says. My hesitation is about the approach, and I'd genuinely welcome you pushing back if you see it differently or think I've got something wrong. The main thing is the execution surface. Secondarily, it overlaps what we already have: Two things we ran into that are worth sharing either way, in case they're useful for agentcookie on your side:
The |
|
No pushback on the PATH point. Resolving an unpinned binary from PATH on a timer and treating its stdout as session cookies is a hijack surface I shouldn't have shipped as a default-on loop; pinning would narrow it but not close it, and you already own an importer that does the decryption natively. I agree the durable part of this PR is the "stop making users re-import by hand" loop, and that belongs on your importer, not an external binary. Want me to rework this PR down to that: the startup/five-minute keep-alive calling browser-cookie-import through #12607's shared policy with explicit merge semantics, no agentcookie in the loop? If you'd rather build it fresh internally, happy to close this instead. The interval finding is genuinely useful, thank you. I'll take the fixed-cadence lesson back to agentcookie (backoff plus change detection rather than a flat five minutes). And the credit on the __Host- fix is appreciated. |
A second start() overwrote this.timer without clearing the first interval, so stop() left the original timer firing. Return early when a timer is already running. stop() clears the handle, so restart still works.
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

Major · Preserve host-only scope for agentcookie cookies. · browser-cookie-import.ts:575-580
src/main/browser/browser-cookie-import.ts:575-580
Major · Security & Privacy · Quick win Preserve host-only scope for
agentcookiecookies.
agentcookie exportrepresents a host-only cookie asdomain: "example.com". The importer passes that value to Electron asdomain, which converts it into a cookie valid for subdomains. A session cookie can therefore be sent tosub.example.comeven though the source cookie was host-only.Omit
domainwhen the exported host key has no leading dot. Keep it for domain cookies.Suggested fix
const isHostPrefixed = cookie.name.startsWith('__Host-') + const isHostOnly = !cookie.domain.startsWith('.') await targetSession.cookies.set({ url: cookie.url, name: cookie.name, value: stripNonPrintable(cookie.value), - ...(isHostPrefixed ? {} : { domain: cookie.domain }), + ...(isHostPrefixed || isHostOnly ? {} : { domain: cookie.domain }), path: isHostPrefixed ? '/' : cookie.path,

Minor · Join or cancel the active session sync before quit… · agentcookie-session-sync.ts:116-121
src/main/browser/agentcookie-session-sync.ts:116-121
Minor · Stability & Availability · Quick win Join or cancel the active session sync before quit teardown.
stop()only clears the interval. Ifagentcookie exportis already running,syncNow()continues afterstop(), callsimportCookiesFromJson(...), and writes cookies throughtargetSession.cookies.set(...). The quit path can destroy browser backends while this work is still pending. The continuation can also callsettingsStore.updateSettings(...)after the final settings flush has started.Make
stop()cancel or await the active pull, include that completion in the quit teardown barrier, and suppress the importer and status callback after cancellation. This prevents partial cookie writes and late settings mutations during shutdown.

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
7df30541-129f-4dba-bd5b-ef3090d2f48d
Files selected for processing: 2-
src/main/browser/agentcookie-session-sync.test.tssrc/main/browser/agentcookie-session-sync.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
-
Main moved the cookie importer under src/main/browser/cookies, dropped the shared types barrel and split main process startup into src/main/startup. Port the agentcookie sync onto that layout: - importCookiesFromJson now lives in the import pipeline. Failure copy for the file import is unchanged. - The sync starts from main-process-runtime-launch and stops from the quit handler, through a slot on the main process state. - The __Host- shaping from this branch is dropped because main already has it, along with its test. Also rename lastImported to lastImportedCount and agentcookieLastImported to agentcookieLastImportedCount, since the value is a cookie count and sits next to the lastSyncAt timestamp.
|
Merged main in 840cf75. This took more than a plain merge because main moved the cookie importer under
This does not change the design. The PATH lookup and timer are still here, and the question above about reworking this or closing it is still open. Ran oxfmt, oxlint, tc:node, tc:web, tc:cli, the changed-code quality check and 918 tests covering the sync, cookie import and startup, all on Node 24. |
There was a problem hiding this comment.
Actionable comments posted: 4

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
57e5dd9c-bba9-42ec-8fd1-55722d2f3ec5
Files selected for processing: 12-
src/main/browser/agentcookie-session-sync.test.tssrc/main/browser/agentcookie-session-sync.tssrc/main/browser/cookies/browser-cookie-import-pipeline.tssrc/main/browser/cookies/browser-cookie-import.test.tssrc/main/browser/cookies/browser-cookie-import.tssrc/main/startup/main-process-agentcookie-sync.tssrc/main/startup/main-process-quit.tssrc/main/startup/main-process-runtime-launch.tssrc/main/startup/main-process-state.tssrc/shared/agentcookie-settings-types.tssrc/shared/default-global-settings.tssrc/shared/global-settings-base.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
-
| if (!stdout.trim()) { | ||
| return null | ||
| } | ||
| return importCookiesFromJson(stdout, targetPartition) |
There was a problem hiding this comment.
Do not overwrite a newer destination cookie with a stale export.
The periodic pull writes every exported cookie identity again. If the source export lags a cookie rotation in Orca’s browser, a write to the same identity replaces the working destination value and can sign the user out. The importer preserves unrelated cookies, but that merge behavior does not protect matching identities. Compare source and destination freshness, or skip unchanged and older source values before periodic writes. (raw.githubusercontent.com)
There was a problem hiding this comment.
This still holds at 37262cb. importCookiesFromJson passes every exported cookie to importValidatedCookies, and the write step sets each one without reading what the partition already has. An export that lags a rotation in Orca's browser would overwrite the newer value. That comes from reading the code; I have not reproduced it.
I have not changed this. What a periodic pull should do here (skip older values, or sync on a signed-out signal instead of a timer) depends on the rework-or-close question above, so I am leaving this thread open for that answer.
A correction to my 20:24Z comment: the design did change, in 37262cb, and that comment no longer holds. It said the design was unchanged and the PATH lookup was still here. Since 37262cb the sync is off by default and there is no PATH lookup: it runs only the absolute path in agentcookieBinaryPath, and only when agentcookieSyncEnabled is true. The timer is still here, and it now always runs and checks those settings on each tick.
That commit went in while the rework-or-close question was open, and the question is still open. The PR description is also out of date: it still says on by default and PATH detected.
There was a problem hiding this comment.
@mvanhorn Thanks for the correction. At 37262cba4, sync is off by default and uses the configured absolute agentcookieBinaryPath, not a PATH lookup. Those changes address the earlier default-enablement and PATH-lookup concerns. They do not address same-identity cookie replacement.
This finding remains open. The overwrite risk follows from the write path you describe; a resulting sign-out has not been reproduced.
The rework-or-close decision still needs a maintainer answer. If periodic sync remains, the key regression check is to rotate a destination cookie, import a stale source value for the same identity, and verify that the destination value survives. A signed-out trigger would reduce repeated imports, but would not itself establish cookie freshness.
The PR description should also reflect the disabled default and configured executable path.
You are interacting with an AI system.
| lastSyncAt: Date.now(), | ||
| lastImportedCount: imported |
There was a problem hiding this comment.
Do not stamp a failed pull as a completed sync.
When the export fails or the importer returns ok: false, this branch still sets lastSyncAt to the current time. The settings callback retains the previous imported count when lastImportedCount is null. The persisted time can thus describe a failed attempt while the count describes an older success. Update the success fields together, or store a separate last-attempt time and failure status. (raw.githubusercontent.com)
There was a problem hiding this comment.
This holds at 45ed8e8. syncNow() sets lastSyncAt to Date.now() whatever pullAgentcookieSession returns, including null from a failed export and ok: false from the importer. The onStatus callback in startAgentcookieSessionSync then saves the new time but keeps the old agentcookieLastImportedCount, so settings can pair a failed attempt's time with an older success's count. That comes from reading the code; I have not reproduced it.
I have not changed this. It waits on the answer to the rework-or-close question above, so I am leaving this thread open.
There was a problem hiding this comment.
@mvanhorn Understood. The supplied code supports the finding, but the failure path has not been reproduced at runtime. The finding remains unresolved while the rework-or-close decision is pending.
You are interacting with an AI system.
Running whichever agentcookie came first on PATH at startup let an earlier PATH entry supply the session cookies. Turn the sync off by default and only execute the absolute path in agentcookieBinaryPath, with no PATH search. The timer now always runs and checks the settings on each tick, so turning the sync on takes effect without a restart. Export failures log their stderr through the cookie import diagnostics instead of disappearing.
There was a problem hiding this comment.
Actionable comments posted: 1

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
bde8aada-cfb6-4881-bcb6-19bdb711b120
Files selected for processing: 5-
src/main/browser/agentcookie-session-sync.test.tssrc/main/browser/agentcookie-session-sync.tssrc/main/startup/main-process-agentcookie-sync.tssrc/shared/agentcookie-settings-types.tssrc/shared/default-global-settings.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
-
|
|
||
| // syncNow pulls once. Concurrency-guarded so the interval can't stack pulls. | ||
| async syncNow(): Promise<AgentcookieSyncStatus> { | ||
| const binary = resolveApprovedAgentcookie(this.options.getApprovedBinaryPath()) |
There was a problem hiding this comment.
Recheck approval before importing an in-flight export.
If agentcookieSyncEnabled becomes false or agentcookieBinaryPath is cleared while agentcookie export runs, syncNow() retains the previously approved path. pullAgentcookieSession() then imports the output without checking either setting again. One export can therefore write session cookies after approval is revoked. Recheck the live settings before passing the output to importCookiesFromJson, and test a settings change during a pending export. (raw.githubusercontent.com)
There was a problem hiding this comment.
This holds at 45ed8e8. syncNow() reads the approved path once, before the export, and isEnabled is only checked by the startup and interval callers before they call it. Nothing rechecks either setting after agentcookie export returns, so pullAgentcookieSession imports the output even if sync was turned off or the path was cleared during the export. The export timeout is 30 seconds, and no test covers a settings change while one is pending. That comes from reading the code; I have not reproduced it.
I have not changed this. It waits on the answer to the rework-or-close question above, so I am leaving this thread open.
There was a problem hiding this comment.
@mvanhorn Understood. The finding remains valid based on code inspection, but it has not been reproduced. No fix is confirmed. This thread should remain open pending the rework-or-close decision.
You are interacting with an AI system.
The startup and interval pulls discarded the syncNow promise, so a failure in the import or the status callback became an unhandled rejection. Catch it at those call sites and write it to the cookie import diagnostics.
Resolve the global-settings-base import conflict: keep the AgentcookieSettings import and take main's moved browser-extension-settings path.
Resolve the conflict in browser-cookie-import.test.ts: keep main's trimmed test file and re-add the importCookiesFromJson tests this PR introduces.
Resolve conflict in src/shared/global-settings-base.ts by keeping AgentcookieSettings alongside the new AntigravityChatAuthSettings, EmulatorOpeningSettings and SshRemoteControlSettings groups.
Main moved the file import into src/main/browser/cookies/imports, split startup into runtime-startup and quit, and moved shared settings under src/shared/settings. importCookiesFromJson now lives next to importCookiesFromFile in import-cookie-file.ts, the sync moved to browser/cookies/sync, and the startup hook and settings types follow main's new layout.
|
Merged main again in f2d9f0b. There was a conflict, resolved by hand; the agentcookie files follow main's new layout. |
Main moved runtime services onto DesktopCore and quit teardown into desktop-core-shutdown. The agentcookie sync slot now lives on core and stops next to automations.
…integration # Conflicts: # src/main/browser/cookies/browser-cookie-import.test.ts
|
Merged main again in d77aa53. The two conflicts were resolved by keeping main's team-policy stop calls in |

What
When the optional agentcookie CLI is installed, orca's embedded browser stays signed into your sites automatically. orca detects agentcookie on PATH and pulls your current session from
agentcookie exportthrough its own importer, on startup and on a 5-minute interval. If agentcookie is not installed, nothing here runs and orca behaves exactly as today.Why
orca's cookie import is manual and one-shot today (the Settings file picker / import-from-browser). For anyone running agentcookie, this makes sign-in automatic and always fresh - the agent's browser does not silently log out mid-task - with no debug port and nothing to click. It is the "have the companion installed and the editor is better" pattern, fully opt-outable.
How
src/main/browser/agentcookie-session-sync.ts: PATH-detects agentcookie, runsagentcookie export, and imports the result intopersist:orca-browserthrough the existing validated pipeline. Guarded loop (one pull at a time): startup plus interval.agentcookieSyncEnabled), and completely inert when agentcookie is not installed.Also: a
__Host-import bug fix (separate commit)While wiring this I found
importValidatedCookiesalways passed adomaintocookies.set(). Chromium rejects a__Host--prefixed cookie that carries aDomain, so those cookies (for example GitHub's__Host-session pair) were silently dropped - by the existing Settings file import too. They are now imported host-only (no domain, path/, Secure).Tests
importCookiesFromJsonplus a__Host-host-only-shaping regression.Notes
agentcookie is optional and external. orca depends on nothing new and behaves identically without it. Happy to flip the default (on vs opt-in) or shape the UI however you prefer.
ELI5
If you install the optional agentcookie CLI, Orca’s embedded browser can auto-import your signed-in site sessions on a timer so you stay logged in without manual cookie import.