Skip to content

Commit f89d768

Browse files
committed
remove option to skip notif
1 parent 67fd5a7 commit f89d768

File tree

9 files changed

+22
-366
lines changed

9 files changed

+22
-366
lines changed

packages/types/src/global-settings.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,6 @@ export const globalSettingsSchema = z.object({
110110
hasOpenedModeSelector: z.boolean().optional(),
111111
lastModeExportPath: z.string().optional(),
112112
lastModeImportPath: z.string().optional(),
113-
114-
// Message modification confirmation preferences
115-
skipEditMessageConfirmation: z.boolean().optional(),
116-
skipDeleteMessageConfirmation: z.boolean().optional(),
117113
})
118114

119115
export type GlobalSettings = z.infer<typeof globalSettingsSchema>

src/core/webview/__tests__/ClineProvider.spec.ts

Lines changed: 0 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,11 +1164,6 @@ describe("ClineProvider", () => {
11641164
describe("deleteMessage", () => {
11651165
beforeEach(async () => {
11661166
await provider.resolveWebviewView(mockWebviewView)
1167-
// Mock that skipDeleteMessageConfirmation is false by default
1168-
;(mockContext.globalState.get as any).mockImplementation((key: string) => {
1169-
if (key === "skipDeleteMessageConfirmation") return false
1170-
return undefined
1171-
})
11721167
})
11731168

11741169
test("handles deletion with confirmation dialog", async () => {
@@ -1231,63 +1226,6 @@ describe("ClineProvider", () => {
12311226
expect((provider as any).initClineWithHistoryItem).toHaveBeenCalledWith({ id: "test-task-id" })
12321227
})
12331228

1234-
test("handles deletion with skipDeleteMessageConfirmation enabled", async () => {
1235-
// Mock that skipDeleteMessageConfirmation is true
1236-
const contextProxy = (provider as any).contextProxy
1237-
const getValueSpy = vi.spyOn(contextProxy, "getValue")
1238-
getValueSpy.mockImplementation((key: any) => {
1239-
if (key === "skipDeleteMessageConfirmation") return true
1240-
return undefined
1241-
})
1242-
1243-
// Setup mock messages
1244-
const mockMessages = [
1245-
{ ts: 1000, type: "say", say: "user_feedback" },
1246-
{ ts: 2000, type: "say", say: "text", value: 3000 }, // Message to delete
1247-
{ ts: 3000, type: "say", say: "user_feedback" },
1248-
{ ts: 4000, type: "say", say: "user_feedback" },
1249-
] as ClineMessage[]
1250-
1251-
const mockApiHistory = [
1252-
{ ts: 1000 },
1253-
{ ts: 2000 },
1254-
{ ts: 3000 },
1255-
{ ts: 4000 },
1256-
] as (Anthropic.MessageParam & {
1257-
ts?: number
1258-
})[]
1259-
1260-
// Setup Cline instance with auto-mock from the top of the file
1261-
const mockCline = new Task(defaultTaskOptions) // Create a new mocked instance
1262-
mockCline.clineMessages = mockMessages
1263-
mockCline.apiConversationHistory = mockApiHistory
1264-
await provider.addClineToStack(mockCline)
1265-
1266-
// Mock getTaskWithId
1267-
;(provider as any).getTaskWithId = vi.fn().mockResolvedValue({
1268-
historyItem: { id: "test-task-id" },
1269-
})
1270-
1271-
// Mock initClineWithHistoryItem
1272-
;(provider as any).initClineWithHistoryItem = vi.fn()
1273-
1274-
// Trigger message deletion
1275-
const messageHandler = (mockWebviewView.webview.onDidReceiveMessage as any).mock.calls[0][0]
1276-
await messageHandler({ type: "deleteMessage", value: 3000 })
1277-
1278-
// Verify that NO dialog message was sent to webview (skipped)
1279-
expect(mockPostMessage).not.toHaveBeenCalledWith({
1280-
type: "showDeleteMessageDialog",
1281-
messageTs: 3000,
1282-
})
1283-
1284-
// Verify only messages before the deleted message were kept
1285-
expect(mockCline.overwriteClineMessages).toHaveBeenCalledWith([mockMessages[0]])
1286-
1287-
// Verify only API messages before the deleted message were kept
1288-
expect(mockCline.overwriteApiConversationHistory).toHaveBeenCalledWith([mockApiHistory[0]])
1289-
})
1290-
12911229
test("handles case when no current task exists", async () => {
12921230
// Clear the cline stack
12931231
;(provider as any).clineStack = []
@@ -1308,11 +1246,6 @@ describe("ClineProvider", () => {
13081246
describe("editMessage", () => {
13091247
beforeEach(async () => {
13101248
await provider.resolveWebviewView(mockWebviewView)
1311-
// Mock that skipEditMessageConfirmation is false by default
1312-
;(mockContext.globalState.get as any).mockImplementation((key: string) => {
1313-
if (key === "skipEditMessageConfirmation") return false
1314-
return undefined
1315-
})
13161249
})
13171250

13181251
test("handles edit with confirmation dialog", async () => {
@@ -1390,56 +1323,6 @@ describe("ClineProvider", () => {
13901323
// We need to verify the recursive call happened by checking if the handler was called again
13911324
expect((mockWebviewView.webview.onDidReceiveMessage as any).mock.calls.length).toBeGreaterThanOrEqual(1)
13921325
})
1393-
1394-
test("handles edit with skipEditMessageConfirmation enabled", async () => {
1395-
// Mock that skipEditMessageConfirmation is true
1396-
const contextProxy = (provider as any).contextProxy
1397-
const getValueSpy = vi.spyOn(contextProxy, "getValue")
1398-
getValueSpy.mockImplementation((key: any) => {
1399-
if (key === "skipEditMessageConfirmation") return true
1400-
return undefined
1401-
})
1402-
1403-
// Setup mock messages
1404-
const mockMessages = [
1405-
{ ts: 1000, type: "say", say: "user_feedback" },
1406-
{ ts: 2000, type: "say", say: "text", value: 3000 }, // Message to edit
1407-
{ ts: 3000, type: "say", say: "user_feedback" },
1408-
] as ClineMessage[]
1409-
1410-
const mockApiHistory = [{ ts: 1000 }, { ts: 2000 }, { ts: 3000 }] as (Anthropic.MessageParam & {
1411-
ts?: number
1412-
})[]
1413-
1414-
// Setup Task instance
1415-
const mockCline = new Task(defaultTaskOptions)
1416-
mockCline.clineMessages = mockMessages
1417-
mockCline.apiConversationHistory = mockApiHistory
1418-
mockCline.overwriteClineMessages = vi.fn()
1419-
mockCline.overwriteApiConversationHistory = vi.fn()
1420-
mockCline.handleWebviewAskResponse = vi.fn()
1421-
1422-
await provider.addClineToStack(mockCline)
1423-
1424-
// Trigger message edit
1425-
const messageHandler = (mockWebviewView.webview.onDidReceiveMessage as any).mock.calls[0][0]
1426-
await messageHandler({
1427-
type: "submitEditedMessage",
1428-
value: 3000,
1429-
editedMessageContent: "Edited message content",
1430-
})
1431-
1432-
// Verify that NO dialog message was sent to webview (skipped)
1433-
expect(mockPostMessage).not.toHaveBeenCalledWith({
1434-
type: "showEditMessageDialog",
1435-
messageTs: 3000,
1436-
text: "Edited message content",
1437-
})
1438-
1439-
// Verify messages were edited directly
1440-
expect(mockCline.overwriteClineMessages).toHaveBeenCalledWith([mockMessages[0]])
1441-
expect(mockCline.overwriteApiConversationHistory).toHaveBeenCalledWith([mockApiHistory[0]])
1442-
})
14431326
})
14441327

14451328
describe("getSystemPrompt", () => {
@@ -2784,12 +2667,6 @@ describe("ClineProvider - Comprehensive Edit/Delete Edge Cases", () => {
27842667
describe("Edit Messages with Images and Attachments", () => {
27852668
beforeEach(async () => {
27862669
await provider.resolveWebviewView(mockWebviewView)
2787-
// Mock that skip confirmations are false by default
2788-
;(mockContext.globalState.get as any).mockImplementation((key: string) => {
2789-
if (key === "skipEditMessageConfirmation") return false
2790-
if (key === "skipDeleteMessageConfirmation") return false
2791-
return undefined
2792-
})
27932670
})
27942671

27952672
test("handles editing messages containing images", async () => {

src/core/webview/__tests__/webviewMessageHandler.spec.ts

Lines changed: 2 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -500,71 +500,8 @@ describe("webviewMessageHandler - message dialog preferences", () => {
500500
vi.mocked(mockClineProvider.contextProxy.getValue).mockReturnValue(false)
501501
})
502502

503-
describe("skipEditMessageConfirmation", () => {
504-
it("should save edit message confirmation preference when set to true", async () => {
505-
await webviewMessageHandler(mockClineProvider, {
506-
type: "skipEditMessageConfirmation",
507-
bool: true,
508-
})
509-
510-
expect(mockClineProvider.contextProxy.setValue).toHaveBeenCalledWith("skipEditMessageConfirmation", true)
511-
expect(mockClineProvider.postStateToWebview).toHaveBeenCalled()
512-
})
513-
514-
it("should save edit message confirmation preference when set to false", async () => {
515-
await webviewMessageHandler(mockClineProvider, {
516-
type: "skipEditMessageConfirmation",
517-
bool: false,
518-
})
519-
520-
expect(mockClineProvider.contextProxy.setValue).toHaveBeenCalledWith("skipEditMessageConfirmation", false)
521-
expect(mockClineProvider.postStateToWebview).toHaveBeenCalled()
522-
})
523-
524-
it("should default to false when bool is not provided", async () => {
525-
await webviewMessageHandler(mockClineProvider, {
526-
type: "skipEditMessageConfirmation",
527-
})
528-
529-
expect(mockClineProvider.contextProxy.setValue).toHaveBeenCalledWith("skipEditMessageConfirmation", false)
530-
expect(mockClineProvider.postStateToWebview).toHaveBeenCalled()
531-
})
532-
})
533-
534-
describe("skipDeleteMessageConfirmation", () => {
535-
it("should save delete message confirmation preference when set to true", async () => {
536-
await webviewMessageHandler(mockClineProvider, {
537-
type: "skipDeleteMessageConfirmation",
538-
bool: true,
539-
})
540-
541-
expect(mockClineProvider.contextProxy.setValue).toHaveBeenCalledWith("skipDeleteMessageConfirmation", true)
542-
expect(mockClineProvider.postStateToWebview).toHaveBeenCalled()
543-
})
544-
545-
it("should save delete message confirmation preference when set to false", async () => {
546-
await webviewMessageHandler(mockClineProvider, {
547-
type: "skipDeleteMessageConfirmation",
548-
bool: false,
549-
})
550-
551-
expect(mockClineProvider.contextProxy.setValue).toHaveBeenCalledWith("skipDeleteMessageConfirmation", false)
552-
expect(mockClineProvider.postStateToWebview).toHaveBeenCalled()
553-
})
554-
555-
it("should default to false when bool is not provided", async () => {
556-
await webviewMessageHandler(mockClineProvider, {
557-
type: "skipDeleteMessageConfirmation",
558-
})
559-
560-
expect(mockClineProvider.contextProxy.setValue).toHaveBeenCalledWith("skipDeleteMessageConfirmation", false)
561-
expect(mockClineProvider.postStateToWebview).toHaveBeenCalled()
562-
})
563-
})
564-
565503
describe("deleteMessage", () => {
566-
it("should show dialog when skipDeleteMessageConfirmation is false", async () => {
567-
vi.mocked(mockClineProvider.contextProxy.getValue).mockReturnValue(false)
504+
it("should always show dialog for delete confirmation", async () => {
568505
vi.mocked(mockClineProvider.getCurrentCline).mockReturnValue({} as any) // Mock current cline exists
569506

570507
await webviewMessageHandler(mockClineProvider, {
@@ -577,36 +514,10 @@ describe("webviewMessageHandler - message dialog preferences", () => {
577514
messageTs: 123456789,
578515
})
579516
})
580-
581-
it("should skip dialog and directly delete when skipDeleteMessageConfirmation is true", async () => {
582-
vi.mocked(mockClineProvider.contextProxy.getValue).mockReturnValue(true)
583-
vi.mocked(mockClineProvider.getCurrentCline).mockReturnValue({
584-
clineMessages: [{ ts: 123456789, text: "test message" }],
585-
apiConversationHistory: [{ ts: 123456789, text: "test message" }],
586-
} as any) // Mock current cline with required properties
587-
588-
// Mock the necessary functions for deletion
589-
vi.mocked(mockClineProvider.getTaskWithId).mockResolvedValue({
590-
historyItem: { id: "test-history-id" },
591-
} as any)
592-
593-
await webviewMessageHandler(mockClineProvider, {
594-
type: "deleteMessage",
595-
value: 123456789, // Changed from messageTs to value
596-
})
597-
598-
// Should not show dialog
599-
expect(mockClineProvider.postMessageToWebview).not.toHaveBeenCalledWith(
600-
expect.objectContaining({
601-
type: "showDeleteMessageDialog",
602-
}),
603-
)
604-
})
605517
})
606518

607519
describe("submitEditedMessage", () => {
608-
it("should show dialog when skipEditMessageConfirmation is false", async () => {
609-
vi.mocked(mockClineProvider.contextProxy.getValue).mockReturnValue(false)
520+
it("should always show dialog for edit confirmation", async () => {
610521
vi.mocked(mockClineProvider.getCurrentCline).mockReturnValue({} as any) // Mock current cline exists
611522

612523
await webviewMessageHandler(mockClineProvider, {
@@ -621,26 +532,5 @@ describe("webviewMessageHandler - message dialog preferences", () => {
621532
text: "edited content",
622533
})
623534
})
624-
625-
it("should skip dialog and directly edit when skipEditMessageConfirmation is true", async () => {
626-
vi.mocked(mockClineProvider.contextProxy.getValue).mockReturnValue(true)
627-
vi.mocked(mockClineProvider.getCurrentCline).mockReturnValue({
628-
clineMessages: [{ ts: 123456789, text: "test message" }],
629-
apiConversationHistory: [{ ts: 123456789, text: "test message" }],
630-
} as any) // Mock current cline with required properties
631-
632-
await webviewMessageHandler(mockClineProvider, {
633-
type: "submitEditedMessage",
634-
value: 123456789, // messageTs as number
635-
editedMessageContent: "edited content", // text content in editedMessageContent field
636-
})
637-
638-
// Should not show dialog
639-
expect(mockClineProvider.postMessageToWebview).not.toHaveBeenCalledWith(
640-
expect.objectContaining({
641-
type: "showEditMessageDialog",
642-
}),
643-
)
644-
})
645535
})
646536
})

src/core/webview/webviewMessageHandler.ts

Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -99,19 +99,11 @@ export const webviewMessageHandler = async (
9999
* Handles message deletion operations with user confirmation
100100
*/
101101
const handleDeleteOperation = async (messageTs: number): Promise<void> => {
102-
// Check if user has opted to skip the confirmation
103-
const skipDeleteMessageConfirmation = getGlobalState("skipDeleteMessageConfirmation")
104-
105-
if (skipDeleteMessageConfirmation) {
106-
// Directly handle the deletion without showing dialog
107-
await handleDeleteMessageConfirm(messageTs)
108-
} else {
109-
// Send message to webview to show delete confirmation dialog
110-
await provider.postMessageToWebview({
111-
type: "showDeleteMessageDialog",
112-
messageTs,
113-
})
114-
}
102+
// Send message to webview to show delete confirmation dialog
103+
await provider.postMessageToWebview({
104+
type: "showDeleteMessageDialog",
105+
messageTs,
106+
})
115107
}
116108

117109
/**
@@ -146,20 +138,12 @@ export const webviewMessageHandler = async (
146138
* Handles message editing operations with user confirmation
147139
*/
148140
const handleEditOperation = async (messageTs: number, editedContent: string): Promise<void> => {
149-
// Check if user has opted to skip the confirmation
150-
const skipEditMessageConfirmation = getGlobalState("skipEditMessageConfirmation")
151-
152-
if (skipEditMessageConfirmation) {
153-
// Directly handle the edit without showing dialog
154-
await handleEditMessageConfirm(messageTs, editedContent)
155-
} else {
156-
// Send message to webview to show edit confirmation dialog
157-
await provider.postMessageToWebview({
158-
type: "showEditMessageDialog",
159-
messageTs,
160-
text: editedContent,
161-
})
162-
}
141+
// Send message to webview to show edit confirmation dialog
142+
await provider.postMessageToWebview({
143+
type: "showEditMessageDialog",
144+
messageTs,
145+
text: editedContent,
146+
})
163147
}
164148

165149
/**
@@ -1216,14 +1200,6 @@ export const webviewMessageHandler = async (
12161200
await updateGlobalState("historyPreviewCollapsed", message.bool ?? false)
12171201
// No need to call postStateToWebview here as the UI already updated optimistically
12181202
break
1219-
case "skipEditMessageConfirmation":
1220-
await updateGlobalState("skipEditMessageConfirmation", message.bool ?? false)
1221-
await provider.postStateToWebview()
1222-
break
1223-
case "skipDeleteMessageConfirmation":
1224-
await updateGlobalState("skipDeleteMessageConfirmation", message.bool ?? false)
1225-
await provider.postStateToWebview()
1226-
break
12271203
case "toggleApiConfigPin":
12281204
if (message.text) {
12291205
const currentPinned = getGlobalState("pinnedApiConfigs") ?? {}

src/shared/ExtensionMessage.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,6 @@ export type ExtensionState = Pick<
185185
| "alwaysAllowSubtasks"
186186
| "alwaysAllowExecute"
187187
| "alwaysAllowUpdateTodoList"
188-
| "skipEditMessageConfirmation"
189-
| "skipDeleteMessageConfirmation"
190188
| "allowedCommands"
191189
| "allowedMaxRequests"
192190
| "browserToolEnabled"

src/shared/WebviewMessage.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@ export interface WebviewMessage {
8080
| "allowedMaxRequests"
8181
| "alwaysAllowSubtasks"
8282
| "alwaysAllowUpdateTodoList"
83-
| "skipEditMessageConfirmation"
84-
| "skipDeleteMessageConfirmation"
8583
| "autoCondenseContext"
8684
| "autoCondenseContextPercent"
8785
| "condensingApiConfigId"

0 commit comments

Comments
 (0)