oracle icon indicating copy to clipboard operation
oracle copied to clipboard

Manual-login run leaves Brave running when --browser-chrome-path points at Brave

Open OmerFarukOruc opened this issue 1 month ago • 4 comments

On Linux, with --browser-chrome-path pointing at Brave (the NixOS brave-origin wrapper), a --browser-manual-login run logs terminating shared Chrome but Brave keeps running (1 of 2 runs on 0.22.2). startsWithChromeExecutable in dist/src/browser/profileState.js accepts only Chrome or Chromium names, so terminateRecordedChromeForProfile refuses to stop Brave.

Steps:

oracle -e browser --browser-manual-login --browser-chrome-path "$(command -v brave-origin)" -m gpt-6-pro -p "Reply OK"
ps -eo pid,args | grep "user-data-dir=$HOME/.oracle/browser-profile"

After the answer, ps still lists the browser.

Would you accept Brave in that name check?

OmerFarukOruc avatar Nov 03 '26 15:11 OmerFarukOruc

Codex review: this still needs some work.

Summary Keep this issue open: current main still rejects Brave during recorded-process cleanup, contradicting supported browser selection and documented shutdown behavior.

Reproducibility: Current source deterministically rejects a brave-browser executable with the correct --user-data-dir before signaling its recorded PID; no browser run or tests were executed during this read-only review.

Next step Establish a failing Brave termination regression, then repair executable recognition without relaxing profile verification or final-lease protection.

Review details

Best possible solution:

Allow verified Brave browser processes to close after the final lease while retaining exact profile matching and existing preservation rules.

Do we have a high-confidence way to reproduce the issue?

Current source deterministically rejects a brave-browser executable with the correct --user-data-dir before signaling its recorded PID; no browser run or tests were executed during this read-only review.

Is this the best way to solve the issue?

A focused Brave executable-matching repair fits existing supported behavior; accepting arbitrary commands containing Brave or bypassing process verification would weaken the established safeguards.

AGENTS.md: found and applied where relevant.

Remaining risk / open question:

  • The exact command line of the recorded NixOS Brave process remains unverified; capture it before choosing wrapper-specific executable aliases.

Codex review notes: model internal, reasoning medium; reviewed against b4017d263c73.

Label changes

Label changes:

  • add P2: Consultations can finish successfully, but a supported browser remains running after expected cleanup.
  • add impact:ux-friction: Users must inspect and close the leftover browser themselves.
  • add issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.
  • add clawsweeper:source-repro: Current issue advisory state selects this label.
  • add clawsweeper:queueable-fix: Current issue advisory state selects this label.
  • add clawsweeper:fix-shape-clear: Current issue advisory state selects this label.

Label justifications:

  • P2: Consultations can finish successfully, but a supported browser remains running after expected cleanup.
  • impact:ux-friction: Users must inspect and close the leftover browser themselves.
Evidence reviewed

Acceptance criteria:

  • pnpm vitest run tests/browser/profileState.test.ts tests/browser/profileState.termination.test.ts tests/browser/index.test.ts tests/browser/reuseChrome.test.ts
  • pnpm run typecheck
  • oracle -e browser --browser-manual-login --browser-chrome-path "$(command -v brave-origin)" -m gpt-6-pro -p "Reply OK"
  • Repeat the Linux Brave smoke with --browser-keep-browser and with two controllers sharing the profile; confirm preservation and final shutdown respectively.

What I checked:

  • Current cleanup defect: terminateRecordedChromeForProfile returns false when executable verification fails; its anchored allowlist excludes Brave even with an exact matching profile. (src/browser/profileState.ts:203, b4017d263c73)
  • Supported browser boundary: Linux browser detection explicitly includes brave-browser and Snap Brave, while docs/chromium-forks.md describes launching Brave variants through the existing browser executable option. (src/browser/detect.ts:271, b4017d263c73)
  • Documented lifecycle contract: Manual-login documentation says omitting --browser-keep-browser closes the browser while preserving its profile; final lease release invokes the rejecting termination helper. (docs/browser-mode.md:322, b4017d263c73)
  • Affected release confirmed in source: The v0.22.2 source contains the same Chrome-only executable allowlist, consistent with the reporter's affected release. (src/browser/profileState.ts:203, b49ae76a1e57)
  • Existing safety coverage: Tests cover rejection of unrelated processes, duplicate or sibling profile arguments, unavailable identity queries, and preserving browsers while another lease remains; Brave termination coverage is absent from the inspected tests. (tests/browser/profileState.termination.test.ts:50, b4017d263c73)
  • Related work does not resolve this defect: https://github.com/steipete/oracle/pull/597 retries unavailable identity queries but leaves executable matching unchanged; https://github.com/steipete/oracle/issues/548 concerns recovery ownership rather than Brave recognition. (src/browser/profileState.ts:138, bfd25bd1d85c)
How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge; those execution lanes are retired.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

Reviewed November 3, 2026, 10:14 AM ET / 15:14 UTC.

clawsweeper[bot] avatar Nov 03 '26 15:11 clawsweeper[bot]

The recorded PID on NixOS is the bash wrapper, not the browser. In a run that left Brave open, the log's chromePid=2229772 was this process, with the browser as its child (PID 2229778):

2229772 /nix/store/<hash>-bash-5.3p20/bin/bash /nix/store/<hash>-brave-origin-1.98.63/bin/.brave-origin-wrapped --enable-features=… --user-data-dir=/home/<user>/.oracle/browser-profile …
2229778 /nix/store/<hash>-brave-origin-1.98.63/opt/brave.com/brave-origin/brave --enable-features=… --user-data-dir=/home/<user>/.oracle/browser-profile …

So startsWithChromeExecutable sees bash first, and adding brave to the name list alone would not match it. Brave stayed open after 2 of 4 runs and closed in the other 2.

OmerFarukOruc avatar Nov 03 '26 16:11 OmerFarukOruc

Fixed in #620 (06dda10e). The cleanup identity check now recognizes the supported Linux Brave executable names, including brave-origin and .brave-wrapped, while still requiring the exact owned profile directory. The new regressions fail on the previous code and pass with this change. All cross-platform CI checks passed at the merged PR head.

steipete avatar Nov 05 '26 05:11 steipete

Oracle 0.23.1 still skips closing Brave on NixOS. The PID that 0.23.1 writes to chrome.pid is still the bash wrapper from my earlier comment, and Brave runs as its child. startsWithChromeExecutable in dist/src/browser/profileState.js reads the first word of that PID's command line, which is bash, so the brave-origin and .brave-wrapped names from #620 never match it. terminateRecordedChromeForProfile then skips termination, and the window stays open.

I ran the exported isChromeCommandForUserDataDirForTest from the installed 0.23.1 package on both command-line shapes:

// probe.mjs
const [modPath, profile, ...cmds] = process.argv.slice(2);
const { isChromeCommandForUserDataDirForTest: check } = await import(modPath);
for (const c of cmds) console.log(`${check(c, profile)}\t${c}`);
P=/home/user/.oracle/browser-profile
node probe.mjs <oracle-0.23.1>/dist/src/browser/profileState.js "$P" \
  "/nix/store/<hash>-bash-5.3p20/bin/bash /nix/store/<hash>-brave-origin-1.99.57/bin/.brave-origin-wrapped --enable-features=X --user-data-dir=$P --no-first-run about:blank" \
  "/nix/store/<hash>-brave-origin-1.99.57/opt/brave.com/brave-origin/brave --enable-features=X --user-data-dir=$P --no-first-run about:blank"
false	/nix/store/<hash>-bash-5.3p20/bin/bash /nix/store/<hash>-brave-origin-1.99.57/bin/.brave-origin-wrapped --enable-features=X --user-data-dir=/home/user/.oracle/browser-profile --no-first-run about:blank
true	/nix/store/<hash>-brave-origin-1.99.57/opt/brave.com/brave-origin/brave --enable-features=X --user-data-dir=/home/user/.oracle/browser-profile --no-first-run about:blank

The wrapper shape, which is the recorded PID, returns false. The Brave child returns true. The command lines of a live 0.23.1 window give the same two results.

Could you reopen this issue, or would you prefer a new one?

OmerFarukOruc avatar Nov 20 '26 23:11 OmerFarukOruc