Repository navigation
fix(session): keep permission prompts in subagent views - #56906
AILIFE4798 wants to merge 2 commits into
Conversation
Viewing a subagent dropped its permission requests, so the dialog never opened and auto-accept approved nothing. Keep the viewed session and its descendants, and do not let the child composer cover the prompt.
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
There was a problem hiding this comment.
The TUI part fixes the reported bug. I reproduced it with opencode-drive and the simulated model: with a request pending on a subagent, base shows no prompt in that subagent's view, and Enter does nothing. With this PR the prompt appears and Enter approves it. bun test test/util/session.test.ts and typecheck in packages/tui and packages/app pass. I did not run the desktop app changes; I only read them.
Public API: unchanged.
Two things are worth fixing before merge (details inline):
- TUI pickers blocked (shown in a test run): while a request is pending in the parent view, the subagent and terminal pickers can't be opened, and the hidden open state makes the picker reappear later.
- Desktop auto-approve (from reading the code): for sessions the app hasn't loaded, the new loop ignores a project's own auto-accept setting.
| sessionID={route.sessionID} | ||
| open={composer.open || (!!session()?.parentID && forms().length === 0)} | ||
| open={ | ||
| promptedPermissions().length === 0 && |
There was a problem hiding this comment.
This check now also overrides composer.open, which is the user's explicit request to open the Down (subagents) or terminal picker. It is not limited to the forced subagent composer.
I saw this with a request pending in the root view: Down no longer opens the subagent picker. composer.open stays true behind the prompt. My next Enter answered the permission prompt, and then the picker popped up. On base the same keys open the picker and move into the child.
Suggested fix: only let a pending prompt override the forced child composer, e.g. composer.open || (!!session()?.parentID && forms().length === 0 && promptedPermissions().length === 0). Use the same condition in the Match at line 1494.
| ...input.data.session.list().map((session) => session.id), | ||
| ...input.data.session.permission.sessions(), | ||
| ]) | ||
| for (const id of ids) { |
There was a problem hiding this comment.
Session IDs that come only from permission.sessions() are, by definition, not in data.session yet. So approve(request) gets projectID = undefined, and covers(undefined) checks the app-wide default instead of the project's own setting.
If auto-accept is on by default and a project turns it off, that project's requests would still be auto-approved here. That is the case consider() was written for: it fetches the session's project before approving. Calling consider(request) for IDs not returned by session.list() keeps the per-project override working.
A pending prompt no longer hides an explicitly opened picker. Unloaded sessions go through consider() so a project auto-accept override still applies.


Issue for this PR
Closes #56907
Type of change
What does this PR do?
Viewing a subagent dropped that session's permission requests. The prompt never opened, and auto-accept walked the same empty list, so the session hung with nothing to approve.
The TUI now keeps the viewed session and its descendants. Ancestors and siblings stay out. A pending permission prompt is shown instead of the forced subagent composer. The desktop dock is no longer covered by the child placeholder while a request is pending, and auto-accept also scans permissions that were synced before the session info arrived.
How did you verify your code works?
Opened a subagent that requested shell permission. With auto-accept off, the prompt appeared in that view and accepting it ran the command. With auto-accept on, the request was approved and the command finished.
bun test test/util/session.test.tsinpackages/tuipassed.Screenshots / recordings
Checklist
Added by the opencode bot (AI-generated).
Related: #52411, #44007