Skip to content

Commit 49c55e6

Browse files
committed
Revert "Expose bypass clear reminder permission mode (#668)"
This reverts commit 3b88415.
1 parent cc57710 commit 49c55e6

13 files changed

Lines changed: 84 additions & 386 deletions

File tree

apps/hook/server/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,10 +1261,6 @@ if (args[0] === "sessions") {
12611261

12621262
console.log(
12631263
JSON.stringify({
1264-
...(result.clearContextNudge && {
1265-
systemMessage:
1266-
"Plannotator requested bypass mode. Hooks cannot clear context. Run /clear before continuing if you want a fresh implementation session.",
1267-
}),
12681264
hookSpecificOutput: {
12691265
hookEventName: "PermissionRequest",
12701266
decision: {

apps/pi-extension/plannotator-browser.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ export interface PlanReviewDecision {
3535
savedPath?: string;
3636
agentSwitch?: string;
3737
permissionMode?: string;
38-
clearContextNudge?: boolean;
3938
}
4039

4140
export interface BrowserDecisionSession<T> {

apps/pi-extension/plannotator-events.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ export interface PlannotatorReviewResultEvent {
7373
savedPath?: string;
7474
agentSwitch?: string;
7575
permissionMode?: string;
76-
clearContextNudge?: boolean;
7776
}
7877

7978
export interface PlannotatorReviewStatusPayload {
@@ -247,7 +246,6 @@ export function registerPlannotatorEventListeners(pi: ExtensionAPI): void {
247246
savedPath: result.savedPath,
248247
agentSwitch: result.agentSwitch,
249248
permissionMode: result.permissionMode,
250-
clearContextNudge: result.clearContextNudge,
251249
} satisfies PlannotatorReviewResultEvent;
252250
setStoredReviewStatus(session.reviewId, { status: "completed", ...reviewResult });
253251
pi.events.emit(PLANNOTATOR_REVIEW_RESULT_CHANNEL, reviewResult);

apps/pi-extension/server.test.ts

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
44
import { createServer as createNetServer } from "node:net";
55
import { tmpdir } from "node:os";
66
import { join } from "node:path";
7-
import { getGitContext, runGitDiff, startPlanReviewServer, startReviewServer } from "./server";
7+
import { getGitContext, runGitDiff, startReviewServer } from "./server";
88

99
const tempDirs: string[] = [];
1010
const originalCwd = process.cwd();
@@ -82,45 +82,6 @@ afterEach(() => {
8282
});
8383

8484
describe("pi review server", () => {
85-
test("plan approve preserves clear context nudge decisions", async () => {
86-
const homeDir = makeTempDir("plannotator-pi-home-");
87-
const repoDir = makeTempDir("plannotator-pi-plan-");
88-
process.env.HOME = homeDir;
89-
process.chdir(repoDir);
90-
process.env.PLANNOTATOR_PORT = String(await reservePort());
91-
92-
const server = await startPlanReviewServer({
93-
plan: "# Plan\n\nShip it.",
94-
htmlContent: "<!doctype html><html><body>plan</body></html>",
95-
origin: "pi",
96-
permissionMode: "acceptEdits",
97-
});
98-
99-
try {
100-
const approveResponse = await fetch(`${server.url}/api/approve`, {
101-
method: "POST",
102-
headers: { "Content-Type": "application/json" },
103-
body: JSON.stringify({
104-
permissionMode: "bypassPermissions",
105-
clearContextNudge: true,
106-
planSave: { enabled: false },
107-
}),
108-
});
109-
expect(approveResponse.status).toBe(200);
110-
111-
await expect(server.waitForDecision()).resolves.toEqual({
112-
approved: true,
113-
feedback: undefined,
114-
savedPath: undefined,
115-
agentSwitch: undefined,
116-
permissionMode: "bypassPermissions",
117-
clearContextNudge: true,
118-
});
119-
} finally {
120-
server.stop();
121-
}
122-
});
123-
12485
test("serves review diff parity endpoints including drafts, uploads, and editor annotations", async () => {
12586
const homeDir = makeTempDir("plannotator-pi-home-");
12687
const repoDir = initRepo();

apps/pi-extension/server/serverPlan.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ export interface PlanReviewDecision {
5454
savedPath?: string;
5555
agentSwitch?: string;
5656
permissionMode?: string;
57-
clearContextNudge?: boolean;
5857
}
5958

6059
export interface PlanServerResult {
@@ -352,7 +351,6 @@ export async function startPlanReviewServer(options: {
352351
let feedback: string | undefined;
353352
let agentSwitch: string | undefined;
354353
let requestedPermissionMode: string | undefined;
355-
let clearContextNudge: boolean | undefined;
356354
let planSaveEnabled = true;
357355
let planSaveCustomPath: string | undefined;
358356
try {
@@ -361,7 +359,6 @@ export async function startPlanReviewServer(options: {
361359
if (body.agentSwitch) agentSwitch = body.agentSwitch as string;
362360
if (body.permissionMode)
363361
requestedPermissionMode = body.permissionMode as string;
364-
if (body.clearContextNudge === true) clearContextNudge = true;
365362
if (body.planSave !== undefined) {
366363
const ps = body.planSave as { enabled: boolean; customPath?: string };
367364
planSaveEnabled = ps.enabled;
@@ -423,7 +420,6 @@ export async function startPlanReviewServer(options: {
423420
savedPath,
424421
agentSwitch,
425422
permissionMode: effectivePermissionMode,
426-
clearContextNudge,
427423
});
428424
json(res, { ok: true, savedPath });
429425
} else if (url.pathname === "/api/deny" && req.method === "POST") {

packages/editor/App.tsx

Lines changed: 29 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { TaterSpriteRunning } from '@plannotator/ui/components/TaterSpriteRunnin
1515
import { TaterSpritePullup } from '@plannotator/ui/components/TaterSpritePullup';
1616
import { Settings } from '@plannotator/ui/components/Settings';
1717
import { FeedbackButton, ApproveButton, ExitButton } from '@plannotator/ui/components/ToolbarButtons';
18-
import { ApproveDropdown, type ApproveExtraEntry } from '@plannotator/ui/components/ApproveDropdown';
18+
import { ApproveDropdown } from '@plannotator/ui/components/ApproveDropdown';
1919
import { useSharing } from '@plannotator/ui/hooks/useSharing';
2020
import { getCallbackConfig, CallbackAction, executeCallback, type ToastPayload } from '@plannotator/ui/utils/callback';
2121
import { useAgents } from '@plannotator/ui/hooks/useAgents';
@@ -77,7 +77,6 @@ import type { PlanDiffMode } from '@plannotator/ui/components/plan-diff/PlanDiff
7777
import { DEMO_PLAN_CONTENT as DEFAULT_DEMO_PLAN_CONTENT } from './demoPlan';
7878
import { DIFF_DEMO_PLAN_CONTENT } from './demoPlanDiffDemo';
7979
import { canUseAnnotateWideMode, resolveWideModeExitLayout, type WideModeLayoutSnapshot, type WideModeType } from './wideMode';
80-
import { buildApprovalRequestBody, type ApprovalOverride } from './approvalBody';
8180
const USE_DIFF_DEMO =
8281
import.meta.env.VITE_DIFF_DEMO === '1' ||
8382
import.meta.env.VITE_DIFF_DEMO === 'true';
@@ -104,7 +103,6 @@ const App: React.FC = () => {
104103
const [showImport, setShowImport] = useState(false);
105104
const [showFeedbackPrompt, setShowFeedbackPrompt] = useState(false);
106105
const [showClaudeCodeWarning, setShowClaudeCodeWarning] = useState(false);
107-
const [pendingApprovalOverride, setPendingApprovalOverride] = useState<ApprovalOverride | null>(null);
108106
const [showExitWarning, setShowExitWarning] = useState(false);
109107
// When the warning dialog confirms, route to the handler matching the button that opened it.
110108
const [exitWarningAction, setExitWarningAction] = useState<'close' | 'approve'>('close');
@@ -943,8 +941,7 @@ const App: React.FC = () => {
943941
};
944942

945943
// API mode handlers
946-
const handleApprove = async (override: ApprovalOverride = {}) => {
947-
setPendingApprovalOverride(null);
944+
const handleApprove = async () => {
948945
setIsSubmitting(true);
949946
try {
950947
const obsidianSettings = getObsidianSettings();
@@ -955,14 +952,24 @@ const App: React.FC = () => {
955952
? await autoSavePromiseRef.current
956953
: autoSaveResultsRef.current;
957954

955+
// Build request body - include integrations if enabled
956+
const body: { obsidian?: object; bear?: object; octarine?: object; feedback?: string; agentSwitch?: string; planSave?: { enabled: boolean; customPath?: string }; permissionMode?: string } = {};
957+
958+
// Include permission mode for Claude Code
959+
if (origin === 'claude-code') {
960+
body.permissionMode = permissionMode;
961+
}
962+
958963
const effectiveAgent = getEffectiveAgentName(getAgentSwitchSettings());
959-
const body = buildApprovalRequestBody({
960-
origin,
961-
permissionMode,
962-
override,
963-
effectiveAgent,
964-
planSaveSettings,
965-
});
964+
if (effectiveAgent) {
965+
body.agentSwitch = effectiveAgent;
966+
}
967+
968+
// Include plan save settings
969+
body.planSave = {
970+
enabled: planSaveSettings.enabled,
971+
...(planSaveSettings.customPath && { customPath: planSaveSettings.customPath }),
972+
};
966973

967974
const effectiveVaultPath = getEffectiveVaultPath(obsidianSettings);
968975
if (obsidianSettings.enabled && effectiveVaultPath) {
@@ -1033,25 +1040,6 @@ const App: React.FC = () => {
10331040
}
10341041
};
10351042

1036-
const approveWithClaudeCodeWarning = useCallback((override: ApprovalOverride = {}) => {
1037-
setPendingApprovalOverride(override);
1038-
if (origin === 'claude-code' && (allAnnotations.length > 0 || codeAnnotations.length > 0)) {
1039-
setShowClaudeCodeWarning(true);
1040-
return;
1041-
}
1042-
handleApprove(override);
1043-
}, [allAnnotations.length, codeAnnotations.length, origin, handleApprove]);
1044-
1045-
const claudeCodeExtraEntries = useMemo<ApproveExtraEntry[]>(() => (origin === 'claude-code' ? [{
1046-
id: 'approve-bypass-clear-reminder',
1047-
label: 'Approve + Bypass + /clear Reminder',
1048-
description: 'Requests bypass mode and reminds you to run /clear. Hooks cannot clear context directly.',
1049-
onSelect: () => approveWithClaudeCodeWarning({
1050-
permissionMode: 'bypassPermissions',
1051-
clearContextNudge: true,
1052-
}),
1053-
}] : []), [approveWithClaudeCodeWarning, origin]);
1054-
10551043
// Annotate mode handler — sends feedback via /api/feedback
10561044
const handleAnnotateFeedback = async () => {
10571045
setIsSubmitting(true);
@@ -1646,24 +1634,18 @@ const App: React.FC = () => {
16461634
)}
16471635

16481636
{(!annotateMode || gate) && (
1649-
!annotateMode && (
1650-
(origin === 'opencode' && availableAgents.length > 0) ||
1651-
(origin === 'claude-code' && claudeCodeExtraEntries.length > 0)
1652-
) ? (
1637+
origin === 'opencode' && !annotateMode && availableAgents.length > 0 ? (
16531638
<ApproveDropdown
16541639
onApprove={() => {
1655-
if (origin === 'opencode') {
1656-
const warning = getAgentWarning();
1657-
if (warning) {
1658-
setAgentWarningMessage(warning);
1659-
setShowAgentWarning(true);
1660-
return;
1661-
}
1640+
const warning = getAgentWarning();
1641+
if (warning) {
1642+
setAgentWarningMessage(warning);
1643+
setShowAgentWarning(true);
1644+
return;
16621645
}
1663-
approveWithClaudeCodeWarning();
1646+
handleApprove();
16641647
}}
1665-
agents={origin === 'opencode' ? availableAgents : []}
1666-
extraEntries={claudeCodeExtraEntries}
1648+
agents={availableAgents}
16671649
disabled={isSubmitting}
16681650
isLoading={isSubmitting}
16691651
/>
@@ -1681,7 +1663,6 @@ const App: React.FC = () => {
16811663
return;
16821664
}
16831665
if (origin === 'claude-code' && (allAnnotations.length > 0 || codeAnnotations.length > 0)) {
1684-
setPendingApprovalOverride({});
16851666
setShowClaudeCodeWarning(true);
16861667
return;
16871668
}
@@ -1738,7 +1719,6 @@ const App: React.FC = () => {
17381719
onIdentityChange={handleIdentityChange}
17391720
origin={origin}
17401721
onUIPreferencesChange={setUiPrefs}
1741-
onPermissionModeChange={setPermissionMode}
17421722
externalOpen={mobileSettingsOpen}
17431723
onExternalClose={() => setMobileSettingsOpen(false)}
17441724
gitUser={gitUser}
@@ -2094,15 +2074,10 @@ const App: React.FC = () => {
20942074
{/* Claude Code annotation warning dialog */}
20952075
<ConfirmDialog
20962076
isOpen={showClaudeCodeWarning}
2097-
onClose={() => {
2098-
setShowClaudeCodeWarning(false);
2099-
setPendingApprovalOverride(null);
2100-
}}
2077+
onClose={() => setShowClaudeCodeWarning(false)}
21012078
onConfirm={() => {
2102-
const override = pendingApprovalOverride ?? {};
21032079
setShowClaudeCodeWarning(false);
2104-
setPendingApprovalOverride(null);
2105-
handleApprove(override);
2080+
handleApprove();
21062081
}}
21072082
title="Annotations Won't Be Sent"
21082083
message={<>{agentName} doesn't yet support feedback on approval. Your {allAnnotations.length + codeAnnotations.length} annotation{(allAnnotations.length + codeAnnotations.length) !== 1 ? 's' : ''} will be lost.</>}

packages/editor/approvalBody.test.ts

Lines changed: 0 additions & 72 deletions
This file was deleted.

0 commit comments

Comments
 (0)