Repository navigation
Conversation
There was a problem hiding this comment.
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.activearen't filtered by directory, and the background service is shared by the whole user. So a TUI started with--autoin 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.
| autoApproved.clear() | ||
| return | ||
| } | ||
| for (const sessionID of data.session.permission.sessions()) { |
There was a problem hiding this comment.
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.
Issue for this PR
Refs #64869
Type of change
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:routes/session/index.tsxintoLocalProvider, which is mounted once for the app. It answers every pending request in the data store, whichever session it belongs to.session.activeand 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.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:
autoacceptalready promises to auto-approve. This fixes it for sessions that aren't on screen.How did you verify your code works?
test/context/autoaccept.test.tsx, which mounts the real providers with no session route: a livepermission.askedfor 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 typecheckandbun run typecheck:tscinpackages/tui.Screenshots / recordings
No visual change.
Checklist
Added by the opencode bot (AI-generated).
Fixes #44007
Related: #64869, #56907, #52486