feat(tasks): let skip-permissions be changed on an existing task - #283
Open
miadisabelle wants to merge 1 commit into
Open
miadisabelle wants to merge 1 commit into
miadisabelle wants to merge 1 commit into
Conversation
Whether a task's agent launches with its skip-permissions flag is decided when the task is created and fixed for the life of the task. Changing it meant closing the task and starting again, losing its worktree and conversation, and the title bar did not show which tasks were running with the flag. - `setTaskSkipPermissions(taskId, enabled)` changes it and saves. It takes effect the next time the agent starts: a terminal restart or resume, or a new or reconnected chat. A running agent keeps the permissions it was launched with. - The title bar shows the setting as a clickable badge after the verification badge, styled like the landing badge: "skip confirms" in the warning colour when on, "confirms on" muted when off. It appears when one of the task's agents takes such a flag, resolved by command so a definition restored without its flags still qualifies, and not on landed tasks. - Coordinator tasks do not get the badge. Sub-task propagation is fixed when the coordinator's MCP server registers, so turning the flag off there would stop the coordinator's own agent from skipping prompts while its sub-tasks went on skipping them until the next launch. - The chat view's permission-mode selector now follows the running session's own mode instead of the task flag. The flag can now change while a chat runs, and the session refuses a mode change based on how it was started, so reading the task flag would enable the selector for a session that rejects it. Claude reports its mode only in each turn's init message, so a session launched skipping permissions now sets `bypassPermissions` itself when it connects; without that the selector would be enabled until the first prompt. A Codex chat resumed after turning the flag off is sent no approval policy on `thread/resume`, as before, so it may keep the policy the thread started with. Whether Codex keeps it across a resume was not verified here; a new chat, or a terminal restart, applies the change. 7 tests: on, off, no save when already off or absent, an unknown task, and the Claude session reporting its mode on connect (fails without the change) or not, when it does not bypass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Whether a task's agent launches with its skip-permissions flag is decided when the task is created and fixed for its whole life. Changing it means closing the task and starting again, which loses its worktree and conversation — and the title bar doesn't show which tasks are running with the flag.
What changes
setTaskSkipPermissions(taskId, enabled)changes the flag on an existing task and saves. It takes effect the next time the agent starts — a terminal restart or resume, or a new or reconnected chat. A running agent keeps the permissions it was launched with; I traced every restart path (restartAgent/switchAgentbumpgeneration, which remountsTerminalViewand rebuilds args) to confirm the flag is read at spawn, not cached.resolveSkipPermissionsArgs, so a definition restored without its flags still qualifies) and not on landed tasks.claude.ts— "This task skips permissions; turn that off to choose a mode."), and once the flag can change mid-chat, reading it would enable the selector for a session that rejects the choice. Claude reports its mode only in each turn'sinitmessage, so a session launched skipping permissions now setsbypassPermissionsitself on connect — otherwise the selector would be enabled from connect until the first prompt.Deliberately not covered
Coordinator tasks don't get the badge. Sub-task propagation is fixed when the coordinator's MCP server registers, so turning the flag off there would stop the coordinator's own agent from skipping prompts while its sub-tasks kept skipping them until the next launch. For a safety setting, partly applying is worse than not offering it.
Codex chat resume: resuming a Codex thread after turning the flag off sends no
approvalPolicy/sandboxonthread/resume, exactly as today, so the thread may keep the policy it started with. I couldn't verify whether Codex keeps it across a resume without a live Codex session. A new chat or a terminal restart applies the change either way; if you'd rather the resume sendon-request/workspace-writeexplicitly when the flag is off, that's a small follow-up — I left it alone because it would also change resume behaviour for tasks whose flag never changed.Your call on the badge
With the default off, most tasks will show a muted "confirms on". Showing it only when on is a one-line change, but then turning it off from the title bar couldn't be undone there — and upstream's own chat note already tells users to "switch the task to skip permissions", which this gives them a place to do. Happy to go either way.
7 tests: the setter (on, off, no save when already off or absent, unknown task) and the Claude session reporting its mode on connect — which fails without that change.
npm run compile,check:staticand both suites pass.🤖 Generated with Claude Code
https://claude.ai/code/session_01SK5d1Qh4JcJVF39HEkFBxX