Skip to content

feat(claude): allow enabling skip-permissions toggle on running tasks#1685

Open
Fizza-Mukhtar wants to merge 2 commits intogeneralaction:mainfrom
Fizza-Mukhtar:feat/toggle-auto-approve-running-task
Open

feat(claude): allow enabling skip-permissions toggle on running tasks#1685
Fizza-Mukhtar wants to merge 2 commits intogeneralaction:mainfrom
Fizza-Mukhtar:feat/toggle-auto-approve-running-task

Conversation

@Fizza-Mukhtar
Copy link
Copy Markdown

@Fizza-Mukhtar Fizza-Mukhtar commented Apr 7, 2026

What

Converts the read-only "Auto-approve" badge in the task tab bar into a
clickable toggle. Users can now enable or disable skip-permissions
for file operations on an already-running task — no restart required.

Closes #1671

Why

Previously, if a user forgot to enable "Skip permissions for file
operations" at task creation time, they had no way to enable it
mid-session. The only option was to stop the task and lose context.

How

  • The badge is now a <button> that toggles task.metadata.autoApprove
  • On enable: persists to DB and kills the PTY — the session manager
    restarts it with --dangerously-skip-permissions and Claude's resume
    flag, preserving session context
  • On disable: persists to DB only — the current session continues
    uninterrupted; the flag is removed on next spawn
  • Button is only shown for providers that have autoApproveFlag defined
    (Claude, Codex, Gemini, etc.)
  • Visual state: orange when active, muted when inactive

Testing

  • Create a Claude task without skip-permissions → grey button visible →
    click → PTY restarts with flag → button turns orange
  • Create with skip-permissions → orange → click → grey, session continues
  • Non-Claude providers (no autoApproveFlag): button not shown
  • pnpm run type-check and pnpm run lint pass

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Chore (refactoring code, technical debt, workflow improvements)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (does not change functionality, e.g. code style improvements, linting)
  • This change requires a documentation update

Mandatory Tasks

  • I have self-reviewed the code

Checklist

  • I have read the contributing guide
  • I have commented my code, particularly in hard-to-understand areas
  • I have checked if my PR needs changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works

Summary by CodeRabbit

  • New Features

    • Auto-approve is now an interactive toggle shown only for agents that support it.
    • Toggle respects a temporary override (resets when switching tasks) and otherwise falls back to task/global settings.
    • Enabling auto-approve triggers an immediate terminal restart; failures clear the override and show a destructive error toast.
  • Style

    • Visual indicator, tooltip text, and dot color update dynamically to reflect enabled/disabled state.

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 7, 2026

@Fizza-Mukhtar is attempting to deploy a commit to the General Action Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 7, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2d3d51a2-57ba-4263-9dbc-e74908346e03

📥 Commits

Reviewing files that changed from the base of the PR and between 817b529 and 125531a.

📒 Files selected for processing (1)
  • src/renderer/components/ChatInterface.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/renderer/components/ChatInterface.tsx

📝 Walkthrough

Walkthrough

Replaced static auto-approve indicator with an interactive toggle in ChatInterface that stores an autoApproveOverride state, persists task.metadata.autoApprove via rpc.db.saveTask(...), resets the override on task change or on error, and calls window.electronAPI.ptyKill(terminalId) when enabling. Toggle only renders if the agent exposes autoApproveFlag.

Changes

Cohort / File(s) Summary
Auto-approve Toggle
src/renderer/components/ChatInterface.tsx
Added autoApproveOverride state (reset on task.id change). Compute autoApproveEnabled from override or existing task/global defaults, gated by agentMeta[agent]?.autoApproveFlag. Replaced static indicator with conditional <button> that updates task.metadata.autoApprove via rpc.db.saveTask(...), sets/clears override, calls window.electronAPI.ptyKill(terminalId) when enabling, and shows a destructive toast on error. Updated button classes, tooltip text, and indicator color based on state.

Sequence Diagram

sequenceDiagram
    participant User
    participant ChatInterface
    participant Database as rpc.db
    participant ElectronAPI as window.electronAPI
    participant Terminal

    User->>ChatInterface: click auto-approve toggle
    ChatInterface->>Database: saveTask(updated task.metadata.autoApprove)
    Database-->>ChatInterface: success / error
    alt success and enabling
        ChatInterface->>ElectronAPI: ptyKill(terminalId)
        ElectronAPI->>Terminal: kill terminal
        Terminal-->>ElectronAPI: terminated
        ElectronAPI-->>ChatInterface: success
    else error
        ChatInterface-->>User: revert override, show destructive toast
    end
    ChatInterface->>User: update button state & tooltip
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 I nudged a tiny toggle bright,
Click—an option wakes mid-flight.
I save the choice, give terminal a shove,
It restarts quick, like a curious shove.
Hooray — permissions hopped to light! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: enabling a skip-permissions toggle on running tasks, which matches the core modification of converting a read-only badge into a clickable toggle.
Linked Issues check ✅ Passed The PR fully addresses issue #1671 requirements: allows enabling skip-permissions mid-session without restart, provides user-facing toggle control, and preserves session context via PTY restart on enable.
Out of Scope Changes check ✅ Passed All changes in ChatInterface.tsx are directly scoped to the feature: adding autoApproveOverride state, converting the indicator to an interactive button, persisting changes, and handling PTY termination—no unrelated modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/renderer/components/ChatInterface.tsx (2)

1206-1238: Consider adding aria-pressed for accessibility.

For toggle buttons, aria-pressed communicates the current state to screen readers.

Add aria-pressed attribute
                   <button
                     type="button"
+                    aria-pressed={autoApproveEnabled}
                     onClick={() => {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/renderer/components/ChatInterface.tsx` around lines 1206 - 1238, The
toggle button rendering in the ChatInterface component doesn't expose its
pressed state to assistive tech; update the button element that uses
autoApproveEnabled (the onClick handler that calls rpc.db.saveTask and
window.electronAPI.ptyKill(terminalId)) to include an aria-pressed attribute set
to the boolean autoApproveEnabled so screen readers can announce the toggle
state (e.g., aria-pressed={autoApproveEnabled}), ensuring the rest of the click
behavior remains unchanged.

1217-1221: Comment may be misleading given the current implementation.

The comment suggests the session manager will restart "with autoApprove: true," but per the code flow, TerminalPane passes autoApprove={autoApproveEnabled} which is derived from the task prop. The session manager doesn't re-read from the database — it uses the value passed by the renderer.

Consider updating the comment to reflect the actual mechanism, or ensuring the parent refreshes the task prop before respawn occurs.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/renderer/components/ChatInterface.tsx` around lines 1217 - 1221, The
comment on the ptyKill call is misleading: it claims the session manager will
restart "with autoApprove: true" but the restart uses the prop passed by the
renderer, not a DB re-read. Update the comment in ChatInterface.tsx near
window.electronAPI.ptyKill(terminalId) to state that the next spawn uses the
current autoApprove prop passed from TerminalPane (autoApproveEnabled derived
from task) or, alternatively, ensure the parent refreshes/recomputes the task
prop (so TerminalPane receives the updated autoApproveEnabled) before calling
ptyKill; reference TerminalPane, autoApproveEnabled, task prop,
window.electronAPI.ptyKill, and terminalId when making the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/renderer/components/ChatInterface.tsx`:
- Around line 1208-1221: The click handler races killing the PTY before the
`rpc.db.saveTask` completes and lacks error handling or cache invalidation;
change the onClick to perform an optimistic UI update of the local
`autoApproveEnabled` state (so `TerminalPane` sees the new value immediately),
then await `rpc.db.saveTask({...task, metadata:{...task.metadata, autoApprove:
next}})`, handle errors (rollback optimistic state and surface/log the error)
and only call `window.electronAPI.ptyKill(terminalId)` after the save resolves
successfully; additionally, on success invalidate or refresh the parent task
cache or emit an update so the `task` prop used by `TerminalPane` (and any query
cache) is updated consistently—reference functions/values: rpc.db.saveTask,
window.electronAPI.ptyKill, autoApproveEnabled, task, terminalId, and
TerminalPane.

---

Nitpick comments:
In `@src/renderer/components/ChatInterface.tsx`:
- Around line 1206-1238: The toggle button rendering in the ChatInterface
component doesn't expose its pressed state to assistive tech; update the button
element that uses autoApproveEnabled (the onClick handler that calls
rpc.db.saveTask and window.electronAPI.ptyKill(terminalId)) to include an
aria-pressed attribute set to the boolean autoApproveEnabled so screen readers
can announce the toggle state (e.g., aria-pressed={autoApproveEnabled}),
ensuring the rest of the click behavior remains unchanged.
- Around line 1217-1221: The comment on the ptyKill call is misleading: it
claims the session manager will restart "with autoApprove: true" but the restart
uses the prop passed by the renderer, not a DB re-read. Update the comment in
ChatInterface.tsx near window.electronAPI.ptyKill(terminalId) to state that the
next spawn uses the current autoApprove prop passed from TerminalPane
(autoApproveEnabled derived from task) or, alternatively, ensure the parent
refreshes/recomputes the task prop (so TerminalPane receives the updated
autoApproveEnabled) before calling ptyKill; reference TerminalPane,
autoApproveEnabled, task prop, window.electronAPI.ptyKill, and terminalId when
making the change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b85031d8-ad49-404f-a917-81f247153deb

📥 Commits

Reviewing files that changed from the base of the PR and between c797ed5 and 465d8f0.

📒 Files selected for processing (1)
  • src/renderer/components/ChatInterface.tsx

@Fizza-Mukhtar Fizza-Mukhtar marked this pull request as draft April 7, 2026 07:24
@Fizza-Mukhtar Fizza-Mukhtar marked this pull request as ready for review April 7, 2026 15:10
Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/renderer/components/ChatInterface.tsx`:
- Around line 940-946: The autoApproveOverride state in ChatInterface persists
across task switches causing stale overrides; add a useEffect in the
ChatInterface component that watches the task (e.g., task.id or the task object)
and calls setAutoApproveOverride(null) whenever the task changes so the override
resets for the new task; reference autoApproveOverride, setAutoApproveOverride,
and autoApproveEnabled to ensure the new effect clears the override before
autoApproveEnabled is recomputed.
- Around line 1228-1230: The catch block currently swallows the error and only
calls setAutoApproveOverride(null); change it to capture the error (catch (err))
and provide user-facing feedback: reset the override as before, then surface the
error via the app's notification mechanism (for example call an existing
notifyError/toast/enqueueSnackbar or set an error state) including err.message
so the user sees why the toggle failed; if no notification helper exists in this
component, create a small error state (e.g., autoApproveError) and render a
brief inline message or toast after catching the error.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0e66d97a-faf1-441c-ad50-87ed5a6af3cf

📥 Commits

Reviewing files that changed from the base of the PR and between 465d8f0 and 817b529.

📒 Files selected for processing (1)
  • src/renderer/components/ChatInterface.tsx

@Fizza-Mukhtar Fizza-Mukhtar marked this pull request as draft April 7, 2026 15:16
@Fizza-Mukhtar Fizza-Mukhtar force-pushed the feat/toggle-auto-approve-running-task branch from 817b529 to 125531a Compare April 8, 2026 09:23
@Fizza-Mukhtar Fizza-Mukhtar marked this pull request as ready for review April 8, 2026 09:25
Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feat]: Allow enabling “skip permissions for file operations” even after session start

1 participant