-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: Add 'Add & Run' button to command approval UI #5292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
95b6c2a
8fd1210
db8c60c
82c3e92
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,9 +51,42 @@ export async function executeCommandTool( | |
| cline.consecutiveMistakeCount = 0 | ||
|
|
||
| command = unescapeHtmlEntities(command) // Unescape HTML entities. | ||
| const didApprove = await askApproval("command", command) | ||
|
|
||
| if (!didApprove) { | ||
| // We need to capture the actual response to check if "Add & Run" was clicked | ||
| const { response, text, images } = await cline.ask("command", command) | ||
|
|
||
| if (response === "yesButtonClicked" || response === "addAndRunButtonClicked") { | ||
| // Handle yesButtonClicked or addAndRunButtonClicked with text. | ||
| if (text) { | ||
| await cline.say("user_feedback", text, images) | ||
| } | ||
|
|
||
| // Check if user selected "Add & Run" to add command to whitelist | ||
| if (response === "addAndRunButtonClicked") { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This duplicates the approval logic from The duplication could lead to maintenance issues if the approval flow needs to be updated in the future. Consider extracting the whitelist addition logic into a shared function that both places can call. |
||
| const clineProvider = await cline.providerRef.deref() | ||
| if (clineProvider) { | ||
|
||
| const state = await clineProvider.getState() | ||
| const currentCommands = state.allowedCommands ?? [] | ||
|
|
||
| // Add command to whitelist if not already present | ||
| if (!currentCommands.includes(command)) { | ||
| const newCommands = [...currentCommands, command] | ||
|
||
| await clineProvider.setValue("allowedCommands", newCommands) | ||
|
|
||
| // Notify webview of the updated commands | ||
| await clineProvider.postMessageToWebview({ | ||
| type: "invoke", | ||
| invoke: "setChatBoxMessage", | ||
| text: `Command "${command}" added to whitelist.`, | ||
|
||
| }) | ||
| } | ||
| } | ||
| } | ||
| } else { | ||
| // Handle both messageResponse and noButtonClicked with text. | ||
| if (text) { | ||
| await cline.say("user_feedback", text, images) | ||
| } | ||
| return | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're duplicating the approval logic in
executeCommandTool.ts, could we extract a shared function here that handles the command approval flow? This would help maintain consistency and reduce code duplication.For example: