Repository navigation
fix(tui): auto-approve background tab permissions - #62043
maorlipchuk wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
This fixes the background-tab stall. I ran the #44007 reproduction from source with a simulated model. On the base, the background tab waited at ! and the session only continued once I selected it (16s). With this PR the request is approved about 4s in while the other tab stays selected, and the ! is gone. The new tests pass, and the type check shows no new errors.
Public API: unchanged. It only moves client-side behaviour in the TUI, with no config keys, flags, events or SDK changes.
The approach looks sound. Pending requests are fetched again only when the set of sessions changes or on reconnect, and permission.sync is cached, so repeated changes cost little. The descendant walk keeps a selected child from approving its parent or siblings. Prompt mode is unchanged.
One request: test/background-autoaccept.test.ts is large for what it checks (229 lines, 8 cases, a hand-written fetch router and several promise resolvers). Could you cut it down to the core cases: a background tab is approved, a background tab's child is approved, and prompt mode leaves the request pending? The negative cases (tabs disabled, selected child) assert that nothing was sent after a single renderOnce(), which is a weak check.
| import { tmpdir } from "./fixture/fixture" | ||
| import { directory, json } from "./fixture/tui-client" | ||
|
|
||
| async function fixture(options: { |
There was a problem hiding this comment.
This fixture (a hand-written fetch router, five resolvers, a mutable pendingChild flag) plus 8 cases is a lot to follow for this fix. Could you trim it to the core cases (background root approved, background child approved, prompt mode left pending)? The "nothing replied" tests only check after one renderOnce(), so they would still pass if a late reply arrived afterwards.
There was a problem hiding this comment.
Thanks.
simplified the fixture to the requested background root, background child, and prompt-mode cases, removing the mutable flag and extra resolvers. The prompt-mode test now waits for the pending request to survive navigation and appear in the approval UI, then verifies manual approval and UI removal. The production implementation is unchanged.
There was a problem hiding this comment.
Thanks, that's much easier to follow. I checked 599cd8b: there are now three cases (background root, background child, and prompt mode left pending until you approve it by hand), all with a single fixture, and nothing else changed. The negative check now waits for the approval prompt to appear instead of relying on one renderOnce(). All three pass locally (bun test test/background-autoaccept.test.ts: 3 pass). Nothing more from me on the tests.
|
Thanks for independently reproducing and verifying the fix. Updated the tests as requested. The targeted tests, TUI TypeScript check, and formatting check pass. The repository-wide check currently encounters an unchanged desktop benchmark type error involving gpuCache, outside this change. |
There was a problem hiding this comment.
My earlier test comment is addressed: the file is now three focused cases (background root, background child, prompt mode until manual approval), and the prompt-mode check waits for the approval prompt to appear. They pass locally. The app code is unchanged since my last review, which still holds: the background-tab stall from #44007 is fixed, and the public API is unchanged. Nothing new from me.
There was a problem hiding this comment.
The new commit only merges dev, and none of this PR's files changed, so my earlier review still holds: the background-tab stall from #44007 is fixed, and the public API is unchanged. The trimmed test file from the previous push addresses my earlier comment, and its three tests still pass on the new head. Nothing new from me.
e8fc1c6 to
bd20322
Compare
There was a problem hiding this comment.
This push only rebases onto newer dev. The diff is the same as the one I last reviewed, and the new base doesn't touch the TUI or client code, so my earlier review still holds: the background-tab stall from #44007 is fixed, and the public API is unchanged. The trimmed tests still pass. Nothing new from me.
bd20322 to
1be10af
Compare
There was a problem hiding this comment.
This push only rebases onto newer dev; the diff is unchanged. Because the new base touches the same TUI files, I re-ran the #44007 reproduction on the new head: the background tab's request is still auto-approved while another tab is selected. The trimmed tests pass, and the type check shows no errors in the changed files. Public API is unchanged. Nothing new from me.
1be10af to
e41f68e
Compare
There was a problem hiding this comment.
This push only rebases onto newer dev; the diff is unchanged and the new base doesn't touch the TUI or client code. My earlier review still holds: the background-tab stall from #44007 is fixed, and the public API is unchanged. The trimmed tests pass on the new head. Nothing new from me.
e41f68e to
b01b698
Compare
There was a problem hiding this comment.
This push only rebases onto newer dev; the diff is unchanged. Because the new base has many TUI changes, I re-ran the #44007 reproduction on the new head: the background tab's request is still auto-approved while another tab is selected. The trimmed tests pass. Public API is unchanged. Nothing new from me.
b01b698 to
83b46a8
Compare
There was a problem hiding this comment.
This push only rebases onto a dev that is one commit newer and doesn't touch the TUI or client code; the diff is unchanged. My earlier review still holds: the background-tab stall from #44007 is fixed, and the public API is unchanged. The trimmed tests pass on the new head. Nothing new from me.
|
Confirmed the same background-tab stall on v2.2.6 (macOS + Ghostty, |
83b46a8 to
2d54595
Compare
There was a problem hiding this comment.
This push only rebases onto newer dev; the diff is unchanged. Because the new base has many TUI changes, including to tabs, I re-ran the #44007 reproduction on both checkouts. On the base, the background tab still waits until it is selected (16s). With this PR its request is approved about 4s in while the other tab stays selected. The trimmed tests pass, and the type check shows no errors in the changed files. Public API is unchanged. Nothing new from me.
2d54595 to
1493ac4
Compare
There was a problem hiding this comment.
This push only rebases onto newer dev; the diff is unchanged, and the new base doesn't touch permission handling. My earlier review still holds: the background-tab stall from #44007 is fixed, and the public API is unchanged. The trimmed tests pass on the new head. Nothing new from me.


Issue for this PR
Fixes #44007. Updated implementation of the approach proposed in #44009, based on current
dev.Type of change
What does this PR do?
Moves automatic permission approval out of the selected session view into the always-mounted TUI application. With autoaccept enabled, requests from open background tabs and their child sessions no longer wait for tab selection.
Approval remains scoped to the selected session, open tabs, and actual descendants. Pending requests are refreshed on reconnect; replies use
once, and configured denials and questions are unchanged.How did you verify your code works?
Reproduced the background-tab stall on unmodified
dev. With this change, both a background session and child session completed actual shell commands without selecting their tabs. Verification used an isolated real server, a headless TUI client, and a deterministic local model endpoint.bun run checkpasses. The full TUI suite has the same two rendering failures on pristinedevand this branch (go-upsell-artandspinner-renderable).Visual
Illustration of the behavior change, not a terminal screenshot:
Screenshots / recordings
No layout changes. The headless before/after check confirms the background tab changes from waiting at
!to completing while another view remains selected.Checklist
Added by the opencode bot (AI-generated).
Related: #56907, #52486, #47545