GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(plugin-browser): revoke stale browser grants on startup by feiiiiii5 · Pull Request #61639 · anomalyco/opencode

Conversation

@feiiiiii5

@feiiiiii5 feiiiiii5 commented Nov 4, 2026 •
edited by opencodejr Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Issue for this PR

Closes #61609

Type of change

  • Bug fix

What does this PR do?

A browser grant is released through Effect.acquireRelease, which does not run when the process is killed hard (SIGKILL) or crashes. The persisted session keeps its browser:* and skill:browser allows, but the in-memory attachment is gone after the restart. whollyDisabled still sees the allows and lists the browser tools, so the model can call them and gets [browser.disconnected].

This change reconciles at startup, before the plugin registers its tools: page through the sessions for the location and remove only the browser grant entries (browser, browser:*, skill:browser), leaving every other permission untouched. A single failing session is ignored so cleanup cannot block startup. The same withoutAccess helper now performs both the normal release and the startup cleanup so the removal rule lives in one place.

How did you verify your code works?

packages/plugin-browser/test/connection-grants.test.ts:

  • a stale session with browser:* and skill:browser allows has exactly those entries removed and keeps an unrelated allow;
  • a clean session is not updated at all;
  • the session list pagination is exercised (the stale session is on the second page).

Red: cd packages/plugin-browser && bun test test/connection-grants.test.ts -> 2 failed, exit 1 (the cleanup entry point did not exist). Green: same command -> 2 passed, exit 0. Related bun test test/rpc.test.ts test/tools.test.ts test/connection-grants.test.ts -> 44 passed, 0 failed; bun run typecheck:tsc passes; prettier and oxlint pass on both files. The full package suite has 2 pre-existing failures in test/tunnel.test.ts (local proxy returns 502; that file does not import the changed module).

I did not reproduce the SIGKILL path through a live server in this change; the issue already has a service-level reproduction and this PR's test calls the startup cleanup directly.

Visual

Not user-facing UI.

Screenshots / recordings

Not a UI change.

Checklist

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

Added by the opencode bot (AI-generated).

Related: #61238, #54044, #55795

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@feiiiiii5
fix(plugin-browser): revoke stale browser grants on startup
c37da56
BrowserConnection released its session grants with acquireRelease, which does not run after SIGKILL/crash, so browser and browser-skill allows stayed on the persisted session while the in-memory attachment was gone; whollyDisabled kept browser tools exposed and calls failed with browser.disconnected. On startup, page the sessions for the location and remove only the browser grant entries before registering tools, reusing one withoutAccess helper for normal release. Add unit regressions for a stale session, a clean session and pagination.
opencodejr[bot]
opencodejr Bot reviewed Nov 4, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The stale grant from the issue is cleared, but the new startup cleanup revokes live grants in other locations, so this needs changes before it can go in.

I checked it by running the issue's reproduction (kill -9, then restart) on base and with this PR, from source. With the PR, the allows are gone once the browser plugin loads for the location. In my run that was on the first browser RPC; before that, the session still returns the stale allows.

The regression: I attached a browser to a session in project A, then sent one request to project B in the same server, so the browser plugin started there. The session in A lost both allows ([]) while its attachment was still live (its state call succeeds), so the browser tools disappear from a session that is attached. On base, the grant stays. ctx.session.list() with no filter returns every session from every location, and the plugin starts once per location. Scoping the list to this location (directory / workspaceID) would fix the cross-location case. It still relies on "no attachment exists for these sessions when this instance starts", which is worth checking.

The shared withoutAccess helper also changes the normal release: see the inline comment.

Public API: unchanged.

Tests: connection-grants, rpc and tools all pass (44 tests), and typecheck:tsc passes.

Related: #61238, #54044, #55795

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/plugin-browser/src/connection.ts Outdated
return ctx.session.update({ sessionID: session.id, permissions }).pipe(Effect.ignore)
}
const page = (cursor?: Session.ListCursor): Effect.Effect<void> =>
ctx.session.list(cursor === undefined ? undefined : { cursor }).pipe(

@opencodejr opencodejr Bot Nov 4, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ctx.session.list() without a filter returns every session in the database, not just this location's. Each location starts its own plugin instance, so starting location B clears the grant of a session that is attached right now in location A. I reproduced this: A's permissions went from the two allows to [] while A's attachment was still live. Please filter by ctx.location (directory / workspaceID). Because this runs before the agent transform and tool registration, a large session table also delays every location's startup. Running it in the background (forkScoped) would avoid that.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/plugin-browser/src/connection.ts Outdated
)
return index === -1 ? rules : rules.toSpliced(index, 1)
}, current)
const permissions = withoutAccess(current)

@opencodejr opencodejr Bot Nov 4, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes the release behaviour. Before, each release removed one copy of each allow (findIndex + toSpliced), so a replaced attachment kept the new attachment's grant (see the comment above grant). withoutAccess removes every matching allow. If the old attachment's release runs after the new one's grant, the new live attachment loses its tools. It also removes allows a user added to the session on purpose. I'd keep the single-copy removal here and use withoutAccess only for the startup cleanup.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@feiiiiii5
fix(plugin-browser): preserve live grants during reconciliation
5058310
Scope stale-grant cleanup to the current directory and workspace. Remove only one appended grant pair when an attachment is released, preserving ordered user rules. Wait for active and replaced attachment finalizers before plugin teardown completes so a reload cannot revoke its replacement's grants.
opencodejr[bot]
opencodejr Bot reviewed Nov 4, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both earlier points are addressed. The startup cleanup now covers only this location's directory and workspace. Re-running my two-location scenario, a live attachment in location A keeps its grant when location B starts, and its state RPC still succeeds. Releasing an attachment removes a single copy of each allow again, and I checked the replace case.

With the issue's kill -9 reproduction, the stale allows are still cleared once the browser plugin loads for the location.

Tests: the core browser-grants test passes (4 tests), and the plugin-browser connection-grants, rpc and tools tests pass (46). typecheck:tsc passes.

Public API: unchanged.

One new point, on the added core test (inline).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/core/test/plugin/browser-grants.test.ts Outdated
const closing = yield* Scope.close(scope, Exit.void).pipe(Effect.forkScoped({ startImmediately: true }))
yield* Deferred.await(releasing)
// Let teardown reach its completion wait while the old finalizer remains blocked.
yield* Effect.yieldNow

@opencodejr opencodejr Bot Nov 4, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is about 200 lines for what it checks, and it's hard to follow. Two tests hold up the old release by matching on the first fiber that calls session.get (old.fiber). Here, the "teardown is still pending" check depends on a single Effect.yieldNow being enough for the scope close to reach its wait. That's a scheduler-order assumption, and if it's wrong, pollUnsafe() can give false results either way. Could you cut this down to the core cases: the cross-location test (lines 18–50) plus one simple replace test? If you keep the teardown-wait test, it would be better to wait on an explicit signal than on yieldNow.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@feiiiiii5
test(plugin-browser): synchronize grant teardown assertions
067e24d
opencodejr[bot]
opencodejr Bot reviewed Nov 4, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This push changes only the core test, so the fix itself is as I verified at the previous commit.

The replace test is now short and clear, and the fiber-ID matching is gone.

The test thread stays open. The teardown-wait test is still most of the file. It wraps rpc.register and agent.transform to insert finalizers, so it depends on the order finalizers are registered in make. It also swaps yieldNow for closing.currentDispatcher.flush(), which still depends on how Effect schedules fibers rather than on an explicit signal. I'd drop it, or reduce it to one case that waits only on deferreds.

Tests: the core test passed in 8 of 8 runs, and the plugin-browser tests pass (46). typecheck:tsc passes.

Public API: unchanged.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@feiiiiii5
test(plugin-browser): keep grant regressions focused
59536ca
opencodejr[bot]
opencodejr Bot reviewed Nov 4, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test thread is addressed: the core test is now the cross-location case plus a simple replace case. The teardown tests that relied on finalizer ordering and the scheduler are gone. The source is unchanged since my last check of the fix against a running server.

Tests: the core test passed in 5 of 5 runs, and the plugin-browser tests pass (46). typecheck:tsc passes.

Public API: unchanged.

No further concerns.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@feiiiiii5
fix(plugin-browser): reconcile stale grants with connection state mac…
3abb991
…hine
opencodejr[bot]
opencodejr Bot reviewed Nov 5, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After the rebase onto dev's state-machine connection, the startup cleanup still works. I re-ran it against the CLI from source, with latest dev as the base.

  • Kill -9, then restart: on dev the stale allows survive. With this PR they are cleared once the browser plugin loads for the location.
  • Two locations: a live attachment in location A keeps its grant when location B starts.
  • Replacing an attachment: the new attachment keeps its grant.

The earlier points (cleanup limited to this location, release behaviour, and the focused tests) still hold after the rebase. Teardown now waits for revokes to drain through dev's state machine.

Tests: the core browser-grants test passed in 5 of 5 runs, and the plugin-browser tests pass (46). typecheck:tsc passes.

Public API: unchanged.

No further concerns.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
This was referenced Nov 12, 2026
fix(browser): keep a configured browser deny when the desktop attaches #63614
Closed
feat(desktop): signed-in browser pane with extensions, previews, prompts and agent safeguards #63002
Merged
@cynthiabaran cynthiabaran mentioned this pull request Nov 27, 2026
agents: browser tools exposed despite agent-level "deny browser" when the agent has execute #54044
Open

This branch has not been deployed

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

Reviewers

@opencodejr opencodejr[bot] opencodejr[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

browser tools stay listed after a hard restart leaves a stale session grant

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@feiiiiii5
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.