-
Notifications
You must be signed in to change notification settings - Fork 2.7k
feat: enable smart approve for user by default #1599
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,8 @@ | ||
| import * as RadioGroup from '@radix-ui/react-radio-group'; | ||
| import React from 'react'; | ||
| import React, { useEffect, useState } from 'react'; | ||
| import { getApiUrl, getSecretKey } from '../../../config'; | ||
|
|
||
| const ModeSelection = ({ value, onChange }) => { | ||
| export const ModeSelection = () => { | ||
| const modes = [ | ||
| { | ||
| value: 'auto', | ||
|
|
@@ -11,7 +12,8 @@ const ModeSelection = ({ value, onChange }) => { | |
| { | ||
| value: 'approve', | ||
| label: 'Approval needed', | ||
| description: 'Editing, creating, and deleting files will require human approval.', | ||
| description: | ||
|
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. 'Classifies the tool as either a read-only tool or write tool. Write tools will ask for human approval'
Contributor
Author
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. sg, done |
||
| 'Classifies the tool as either a read-only tool or write tool. Write tools will ask for human approval.', | ||
| }, | ||
| { | ||
| value: 'chat', | ||
|
|
@@ -20,11 +22,64 @@ const ModeSelection = ({ value, onChange }) => { | |
| }, | ||
| ]; | ||
|
|
||
| const [currentMode, setCurrentMode] = useState('auto'); | ||
|
|
||
| const handleModeChange = async (newMode: string) => { | ||
| const storeResponse = await fetch(getApiUrl('/configs/store'), { | ||
| method: 'POST', | ||
| headers: { | ||
| 'Content-Type': 'application/json', | ||
| 'X-Secret-Key': getSecretKey(), | ||
| }, | ||
| body: JSON.stringify({ | ||
| key: 'GOOSE_MODE', | ||
| value: newMode, | ||
| isSecret: false, | ||
| }), | ||
| }); | ||
|
|
||
| if (!storeResponse.ok) { | ||
| const errorText = await storeResponse.text(); | ||
| console.error('Store response error:', errorText); | ||
| throw new Error(`Failed to store new goose mode: ${newMode}`); | ||
| } | ||
| setCurrentMode(newMode); | ||
| }; | ||
|
|
||
| useEffect(() => { | ||
| const fetchCurrentMode = async () => { | ||
| try { | ||
| const response = await fetch(getApiUrl('/configs/get?key=GOOSE_MODE'), { | ||
| method: 'GET', | ||
| headers: { | ||
| 'Content-Type': 'application/json', | ||
| 'X-Secret-Key': getSecretKey(), | ||
| }, | ||
| }); | ||
|
|
||
| if (response.ok) { | ||
| const { value } = await response.json(); | ||
| if (value) { | ||
| setCurrentMode(value); | ||
| } | ||
| } | ||
| } catch (error) { | ||
| console.error('Error fetching current mode:', error); | ||
| } | ||
| }; | ||
|
|
||
| fetchCurrentMode(); | ||
| }, []); | ||
|
|
||
| return ( | ||
| <div> | ||
| <h4 className="font-medium mb-4 text-textStandard">Mode Selection</h4> | ||
|
|
||
| <RadioGroup.Root className="flex flex-col space-y-2" value={value} onValueChange={onChange}> | ||
| <RadioGroup.Root | ||
| className="flex flex-col space-y-2" | ||
| value={currentMode} | ||
| onValueChange={handleModeChange} | ||
| > | ||
| {modes.map((mode) => ( | ||
| <RadioGroup.Item | ||
| key={mode.value} | ||
|
|
@@ -41,7 +96,7 @@ const ModeSelection = ({ value, onChange }) => { | |
| </div> | ||
| <div className="flex-shrink-0"> | ||
| <div className="w-4 h-4 flex items-center justify-center rounded-full border border-gray-500 dark:border-gray-400"> | ||
| {value === mode.value && ( | ||
| {currentMode === mode.value && ( | ||
| <div className="w-2 h-2 bg-black dark:bg-white rounded-full" /> | ||
| )} | ||
| </div> | ||
|
|
@@ -52,5 +107,3 @@ const ModeSelection = ({ value, onChange }) => { | |
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default ModeSelection; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
could we keep a note here explaining 'Read Write approve' -