Skip to content

fix(tui): auto-accept permissions across background sessions - #65202

Open
neriousy wants to merge 1 commit into
devfrom
tui-autoaccept-sessions
Open

neriousy wants to merge 1 commit into
devfrom
tui-autoaccept-sessions

Conversation

@neriousy

@neriousy neriousy commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Issue for this PR

Refs #64869

Type of change

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

What does this PR do?

The TUI's auto-accept (session.permissions: "autoaccept" or --auto) ran inside the <Session> route, so it only answered requests for the session on screen and its subagents. Requests from other tabs, from sessions with no tab, and from sessions the service resumed by itself after a restart waited forever. Combined with the file-lock bug fixed in the core PR, that is what blocked every edit to one file in #64869.

The desktop/web app already handles this server-wide (packages/app/src/session/requests/auto-approve.ts). This brings the TUI closer to it:

  • The auto-accept effect moves from routes/session/index.tsx into LocalProvider, which is mounted once for the app. It answers every pending request in the data store, whichever session it belongs to.
  • On connect/reconnect, and when the mode switches to auto-accept, it lists session.active and the locally known sessions and re-syncs their pending permissions. That picks up requests made while the TUI was disconnected or the mode was off.
  • It forgets answered request IDs on permission.replied, and clears them when the mode turns off.

Prompt mode is unchanged: the session view still shows its own family's requests.

No feature flag: autoaccept already promises to auto-approve. This fixes it for sessions that aren't on screen.

How did you verify your code works?

  • New test/context/autoaccept.test.tsx, which mounts the real providers with no session route: a live permission.asked for a background session is approved, a pending request on an active session is approved on connect with --auto, and switching prompt → autoaccept sweeps and approves. It passes --rerun-each 10.
  • test/session-panel.test.tsx (the session's own permission prompt in prompt mode) still passes.
  • bun typecheck and bun run typecheck:tsc in packages/tui.

Screenshots / recordings

No visual change.

Checklist

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

Added by the opencode bot (AI-generated).

Fixes #44007

Related: #64869, #56907, #52486

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The fix works, but I think the scope of auto-accept needs narrowing before merge.

How I checked: I started the TUI from each checkout with session.permissions: "autoaccept" on the home screen, with no session open. Then I created a session and an ask permission request on it through the API. On the base the request stayed pending. With this PR it was approved within 4 s. The new autoaccept.test.tsx and session-panel.test.tsx pass with the PR, and the new test fails on the base. typecheck:tsc passes.

Public API: unchanged. The existing autoaccept setting and --auto now apply to more sessions, but nothing is added, removed or renamed.

Concern:

  • Auto-accept now reaches beyond this TUI. The event stream and session.active aren't filtered by directory, and the background service is shared by the whole user. So a TUI started with --auto in one project would also approve requests from sessions in other projects, from another TUI running in prompt mode, or from the desktop app. Before this change, it only covered the session on screen. The app's auto-approver limits itself per project, and #62043 limits it to open tabs and their session families. Details are in the inline comment.

Fixes #44007
Related: #64869, #56907, #52486

autoApproved.clear()
return
}
for (const sessionID of data.session.permission.sessions()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This approves every pending request in the data store. The client's event stream is server-wide, though: api.event.subscribe has no directory filter. The background service is also shared by every TUI and the desktop app for this user. So with --auto in project A, this effect also answers permission.asked for sessions in project B. That includes sessions a different TUI is showing in prompt mode, where the user expects to be asked. The connect sweep below has the same problem, since it pulls in everything from session.active, which is server-wide.

Could this be limited to what this TUI owns? For example, only sessions whose location matches this TUI's directory or project, or open tabs plus their session families (as #62043 does). packages/app/src/session/requests/auto-approve.ts checks each request's project for the same reason.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TUI --auto stalls background tabs at permission requests

1 participant