Skip to content

feat: Make plan approval options contextual#1794

Closed
charlesvien wants to merge 2 commits into04-21-add_fullscreen_expand_to_plan_previewfrom
04-21-make_plan_approval_options_contextual
Closed

feat: Make plan approval options contextual#1794
charlesvien wants to merge 2 commits into04-21-add_fullscreen_expand_to_plan_previewfrom
04-21-make_plan_approval_options_contextual

Conversation

@charlesvien
Copy link
Copy Markdown
Member

@charlesvien charlesvien commented Apr 22, 2026

Problem

Plan approval shows N mode options every time, regardless of the user's current mode. This PR makes it contextual to their pre-plan mode similar to claude code.

The issue:

CleanShot 2026-04-21 at 17.20.28@2x.png

Changes

  1. Track the pre-plan permission mode on the session (prePlanMode)
  2. Show "continue with <current mode>" as the default exit option instead of listing all modes
  3. Offer a "manually approve edits" downgrade only when not already in manual mode
  4. Remove the static bypass/auto/acceptEdits menu in favor of contextual options
  5. Document the upstream divergence in upstream.md file

How did you test this?

Manually

@charlesvien charlesvien changed the title Make plan approval options contextual feat: Make plan approval options contextual Apr 22, 2026
Copy link
Copy Markdown
Member Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@charlesvien charlesvien force-pushed the 04-21-add_fullscreen_expand_to_plan_preview branch from 6cdea85 to d0a4b67 Compare April 22, 2026 00:37
@charlesvien charlesvien force-pushed the 04-21-make_plan_approval_options_contextual branch from b1c1487 to 70691ec Compare April 22, 2026 00:37
@charlesvien charlesvien force-pushed the 04-21-add_fullscreen_expand_to_plan_preview branch from d0a4b67 to d4fec55 Compare April 22, 2026 00:41
@charlesvien charlesvien force-pushed the 04-21-make_plan_approval_options_contextual branch from 70691ec to 813b1f4 Compare April 22, 2026 00:41
@charlesvien charlesvien force-pushed the 04-21-add_fullscreen_expand_to_plan_preview branch from d4fec55 to f6b3492 Compare April 22, 2026 00:47
@charlesvien charlesvien force-pushed the 04-21-make_plan_approval_options_contextual branch from 813b1f4 to a4d0590 Compare April 22, 2026 00:47
@charlesvien charlesvien marked this pull request as ready for review April 22, 2026 00:47
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 22, 2026

Prompt To Fix All With AI
This is a comment left during a code review.
Path: packages/agent/src/adapters/claude/permissions/permission-handlers.ts
Line: 213

Comment:
**`prePlanMode` can be set to `"plan"` causing silent approval failure**

If `EnterPlanMode` is called while the session is already in plan mode, `prePlanMode` gets set to `"plan"`. `EnterPlanMode` is not in `BASE_ALLOWED_TOOLS` so `isToolAllowedForMode` returns `false` for plan mode, and `handleEnterPlanModeTool` is invoked. When the user later exits plan mode, `buildExitPlanModePermissionOptions("plan")` produces a first option with `optionId: "plan"`. Since `"plan"` is not in the `applyPlanApproval` allow-list (`"auto" | "default" | "acceptEdits" | "bypassPermissions"`), selecting "Yes, continue with plan" falls through to the rejection path — the user's approval is silently treated as a rejection.

Guard against overwriting `prePlanMode` when already in plan mode:

```suggestion
  if (session.permissionMode !== "plan") {
    session.prePlanMode = session.permissionMode;
  }
  session.permissionMode = "plan";
```

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: packages/agent/src/adapters/claude/permissions/permission-options.ts
Line: 95-100

Comment:
**`MODE_LABELS` missing `"plan"` entry**

`CodeExecutionMode` includes `"plan"`, so if `prePlanMode` is ever `"plan"` the label falls back to the raw string `"plan"`. Adding an entry makes the display name explicit and removes reliance on the fallback:

```suggestion
const MODE_LABELS: Record<CodeExecutionMode, string> = {
  default: "manual approval",
  acceptEdits: "auto-accept edits",
  bypassPermissions: "bypass permissions",
  auto: "auto mode",
  plan: "plan mode",
};
```

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "Make plan approval options contextual" | Re-trigger Greptile

): Promise<ToolPermissionResult> {
const { session, toolInput } = context;

session.prePlanMode = session.permissionMode;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 prePlanMode can be set to "plan" causing silent approval failure

If EnterPlanMode is called while the session is already in plan mode, prePlanMode gets set to "plan". EnterPlanMode is not in BASE_ALLOWED_TOOLS so isToolAllowedForMode returns false for plan mode, and handleEnterPlanModeTool is invoked. When the user later exits plan mode, buildExitPlanModePermissionOptions("plan") produces a first option with optionId: "plan". Since "plan" is not in the applyPlanApproval allow-list ("auto" | "default" | "acceptEdits" | "bypassPermissions"), selecting "Yes, continue with plan" falls through to the rejection path — the user's approval is silently treated as a rejection.

Guard against overwriting prePlanMode when already in plan mode:

Suggested change
session.prePlanMode = session.permissionMode;
if (session.permissionMode !== "plan") {
session.prePlanMode = session.permissionMode;
}
session.permissionMode = "plan";
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/agent/src/adapters/claude/permissions/permission-handlers.ts
Line: 213

Comment:
**`prePlanMode` can be set to `"plan"` causing silent approval failure**

If `EnterPlanMode` is called while the session is already in plan mode, `prePlanMode` gets set to `"plan"`. `EnterPlanMode` is not in `BASE_ALLOWED_TOOLS` so `isToolAllowedForMode` returns `false` for plan mode, and `handleEnterPlanModeTool` is invoked. When the user later exits plan mode, `buildExitPlanModePermissionOptions("plan")` produces a first option with `optionId: "plan"`. Since `"plan"` is not in the `applyPlanApproval` allow-list (`"auto" | "default" | "acceptEdits" | "bypassPermissions"`), selecting "Yes, continue with plan" falls through to the rejection path — the user's approval is silently treated as a rejection.

Guard against overwriting `prePlanMode` when already in plan mode:

```suggestion
  if (session.permissionMode !== "plan") {
    session.prePlanMode = session.permissionMode;
  }
  session.permissionMode = "plan";
```

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines +95 to +100
const MODE_LABELS: Record<string, string> = {
default: "manual approval",
acceptEdits: "auto-accept edits",
bypassPermissions: "bypass permissions",
auto: "auto mode",
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 MODE_LABELS missing "plan" entry

CodeExecutionMode includes "plan", so if prePlanMode is ever "plan" the label falls back to the raw string "plan". Adding an entry makes the display name explicit and removes reliance on the fallback:

Suggested change
const MODE_LABELS: Record<string, string> = {
default: "manual approval",
acceptEdits: "auto-accept edits",
bypassPermissions: "bypass permissions",
auto: "auto mode",
};
const MODE_LABELS: Record<CodeExecutionMode, string> = {
default: "manual approval",
acceptEdits: "auto-accept edits",
bypassPermissions: "bypass permissions",
auto: "auto mode",
plan: "plan mode",
};
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/agent/src/adapters/claude/permissions/permission-options.ts
Line: 95-100

Comment:
**`MODE_LABELS` missing `"plan"` entry**

`CodeExecutionMode` includes `"plan"`, so if `prePlanMode` is ever `"plan"` the label falls back to the raw string `"plan"`. Adding an entry makes the display name explicit and removes reliance on the fallback:

```suggestion
const MODE_LABELS: Record<CodeExecutionMode, string> = {
  default: "manual approval",
  acceptEdits: "auto-accept edits",
  bypassPermissions: "bypass permissions",
  auto: "auto mode",
  plan: "plan mode",
};
```

How can I resolve this? If you propose a fix, please make it concise.

@charlesvien charlesvien marked this pull request as draft April 22, 2026 00:58
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.

1 participant