Repository navigation
fix(cli): start fresh TUI Sessions at the default permission mode - #3021
Conversation
Elevating a Session to Full access and starting a fresh one with /new leaked the elevation: the status line kept showing Full access and the next prompt created the new Session with bypass. startNewSession cleared the boundary display mode but not the base permission mode that session.create uses. Capture the construction-time default and reset to it in startNewSession, matching the desktop model where a new chat uses the configured default rather than the previous Session's mode. Full access stays an explicit per-session opt-in: setPermissionMode before the first prompt still raises the fresh Session. Fixes apache#3020 Generated-by: Maka
Astro-Han
left a comment
There was a problem hiding this comment.
Thanks — this is a small, well-contained fix at the right lifecycle boundary.
I traced the TUI path from /new through startNewSession() and the next preparePrompt() into the actual session.create request. Resetting the driver’s seed permission prevents Full access from leaking across Sessions, while resumed Sessions continue to take their configuration and execution boundary from the Runtime Host. The control lock also prevents /new from racing an in-flight permission change.
The regression test exercises the production driver seam and is mutation-sensitive. The focused CLI suite passes 260/260, and CI is green.
One non-blocking suggestion: because the new field is described as the construction-time default rather than specifically ask, consider using a non-ask value in a small parameterized assertion. That would distinguish the intended implementation from a future hard-coded this.#permissionMode = 'ask'. All current TUI production callers pass ask, so I do not consider this necessary for merge.
Approved.
中文对照
感谢,这是一项边界清楚、落点正确的小修复。
我核对了从 TUI /new、startNewSession() 到下一次 preparePrompt() 和实际 session.create 请求的完整链路。重置 driver 用于创建新 Session 的初始权限,可以阻止 Full access 跨 Session 泄漏;恢复已有 Session 时,配置和 execution boundary 仍然由 Runtime Host 决定。control lock 也避免了 /new 与进行中的权限切换发生竞态。
回归测试命中了生产 driver seam,并且删除重置代码后会失败。CLI 聚焦测试 260/260 通过,CI 全绿。
有一个非阻塞的小建议:新增字段表达的是“构造时传入的默认值”,而不只是固定的 ask。可以考虑用一个非 ask 值补充参数化断言,从而防止未来被简化成硬编码的 this.#permissionMode = 'ask'。当前所有 TUI 生产调用点都明确传入 ask,所以这不影响本次合并。
批准。
Disclosure: This review was prepared with assistance from OpenAI Codex and Claude Opus. I reviewed the evidence, verified the production path and focused tests, and made the final judgment.
Summary
In the TUI, elevating a session to Full access (
bypass) and then running/newsilently carried the elevation into the fresh session: the status line kept showing Full access, and the next prompt created the new session withpermissionMode: 'bypass'— tools ran with direct file/network access in a session the user never elevated.startNewSession()cleared the session binding and the boundary display mode, but not the base#permissionModethatsession.createuses. The fix captures the construction-time default (#defaultPermissionMode, what the TUI passes at cold start —ask) and resets to it instartNewSession(). This matches the desktop model, where a new chat uses the settings-backed default rather than the previously viewed session's mode, and keeps Full access an explicit per-session opt-in:setPermissionModebefore the first prompt still raises the fresh session.Fixes #3020
Verification
packages/clisuite: 260/260 pass (includes the new regression test).'bypass' !== 'ask'; restored, it passes.setPermissionMode('bypass')→startNewSession()→preparePrompt()): before —getPermissionMode()after/newreturnedbypassand the newsession.createcarriedbypass; after — both areask.biome checkclean on both touched files.packages/cli; left to CI).Security
This changes security-relevant behavior (permission/boundary mode of newly created sessions). Per the review policy and the contributor's request, the fast path does not apply: this PR requires independent review by another human before merge (AI review does not count), in addition to the human contributor of record.
Prepared with AI assistance (Maka agent); the investigation, reproduction, and fix were reviewed by the human contributor. The final commit carries
Generated-by: Maka— please keep the trailer when squash-merging.Checklist
Does this PR entail a change in behavior?