Skip to content

fix(browser): keep browser defaults below user permissions - #74

Open
trmosala wants to merge 1 commit into
devfrom
browser-permissions
Open

trmosala wants to merge 1 commit into
devfrom
browser-permissions

Conversation

@trmosala

Copy link
Copy Markdown
Owner

Issue for this PR

None. Follows the browser review findings on the injected browser permissions and the desktop_set_panel rejection.

The CookieMonster split carries copies of the removed permission block. They need the same removal when the split lands:

  • CM-Split-v2: packages/desktop/wpp/legacy-config.mjs, pinned by packages/desktop/wpp/legacy-config.fixture.ts.
  • The in-progress CM-Split work: packages/desktop/src/main/wpp-integration/provider-config.mjs, pinned by packages/desktop/wpp/provider-config.fixture.ts.

CM-WPP-Bits has no browser permission rules, so this PR has no companion PR.

No file overlap with #72 or #73. Neither changes any of the 6 files in this PR.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Two fixes in the CM Browser permission path:

  • Injected permissions replaced user rules. o1CodeConfigContent() put 19 browser permission rules in OPENCODE_CONFIG_CONTENT. OpenCode merges that config after the user's global config, so these rules replaced the user's own. A user's browser_fill: "ask" became allow, and browser_execute_site_tool: "deny" became allow. OpenCode applies the last matching rule, so the injected rules also beat a user's wildcard "*": "deny".

    The rules now live in the cm-browser plugin's config hook, which already handled the 4 tab lifecycle tools this way. The hook puts its defaults before the user's rules and skips any tool the user has set, so the user's rule wins. The values are unchanged: browser_open_history stays ask, and every other browser tool is allow. The injected config no longer has a permission block.

  • desktop_set_panel always failed. route() in browser/router.ts rejected set_panel whenever an authority object was present. The bridge passes the ordinary task's authority on every request, so the tool could never switch panels. Only a delegated subagent's authority carries a lease token, so the check now rejects only that case. The panel handler in browser/tabs.ts still matches the request to its window's task, and still requires agent access before it shows a browser tab.

Behaviour change: a user with a wildcard ask or deny rule, or a single-value permission setting, now gets that policy for browser tools too. The cm-browser README and AGENTS.md already describe this behaviour. Users without such rules see no change.

V2 is unaffected. packages/core doesn't read OPENCODE_CONFIG_CONTENT and doesn't run V1 plugin config hooks, so it never saw either the injected rules or the hook defaults.

How did you verify your code works?

  • bun test from packages/cm-browser: 105 pass. The plugin test now checks that every bundled browser tool has a default, that only browser_open_history keeps ask, and that the user's exact and wildcard rules stay after the defaults.
  • bun test src/main/browser/ src/main/wpp-bridge/ from packages/desktop: 866 pass. This includes a new router test: an ordinary session's set_panel request reaches the panel handler, and a delegated child's request is rejected with access_denied before reaching it.
  • providerConfig.test.ts now checks that the injected config has no permission block.
  • bun typecheck from packages/cm-browser, from packages/desktop, and from the repo root (32 of 32 packages): pass.
  • oxlint on the 6 changed files: 0 errors. The 9 warnings are on lines this PR doesn't change.
  • Prettier: all 6 changed files are clean. packages/cm-browser/test/plugin.test.ts wasn't clean on dev; the assertion this PR replaced was the cause.
  • Not run: a live Electron session or the native browser smoke test.

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

The desktop injected 19 browser permission rules through
OPENCODE_CONFIG_CONTENT, which merges after the user's global config.
Those rules replaced any ask or deny the user had set, including a
wildcard deny. Move them into the cm-browser config hook, which already
places its lifecycle defaults before user rules, so the user's last
matching rule wins. The values are unchanged: browser_open_history
stays ask and every other browser tool is allow.

The router also rejected desktop_set_panel whenever an authority object
was present. The bridge passes ordinary task authority on every request,
so ordinary sessions could never switch panels. Reject only delegated
authority, which carries a lease token. The panel handler still checks
native task ownership and agent access.
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant