Skip to content

Commit

Permalink
feat: add goose mode to the chat window (#1471)
Browse files Browse the repository at this point in the history
  • Loading branch information
yingjiehe-xyz authored Mar 3, 2025
1 parent 7edb624 commit 27b9cd9
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions ui/desktop/src/components/BottomMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Sliders } from 'lucide-react';
import { ModelRadioList } from './settings/models/ModelRadioList';
import { Document, ChevronUp, ChevronDown } from './icons';
import type { View } from '../ChatWindow';
import { getApiUrl, getSecretKey } from '../config';

export default function BottomMenu({
hasMessages,
Expand All @@ -14,6 +15,7 @@ export default function BottomMenu({
setView: (view: View) => void;
}) {
const [isModelMenuOpen, setIsModelMenuOpen] = useState(false);
const [gooseMode, setGooseMode] = useState('approve');
const { currentModel } = useModel();
const { recentModels } = useRecentModels(); // Get recent models

Check warning on line 20 in ui/desktop/src/components/BottomMenu.tsx

View workflow job for this annotation

GitHub Actions / Lint Electron Desktop App

'recentModels' is assigned a value but never used. Allowed unused vars must match /^_/u
const dropdownRef = useRef<HTMLDivElement>(null);
Expand All @@ -35,6 +37,29 @@ export default function BottomMenu({
};
}, [isModelMenuOpen]);

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();
setGooseMode(value);
}
} catch (error) {
console.error('Error fetching current mode:', error);
}
};

fetchCurrentMode();
}, []);

// Add effect to handle Escape key
useEffect(() => {
const handleEsc = (event: KeyboardEvent) => {
Expand Down Expand Up @@ -76,6 +101,17 @@ export default function BottomMenu({
<ChevronUp className="ml-1" />
</span>

<div className="relative flex items-center ml-6">
<div
className="flex items-center cursor-pointer"
onClick={() => {
setView('settings');
}}
>
<span>Goose Mode: {gooseMode}</span>
</div>
</div>

{/* Model Selector Dropdown - Only in development */}
<div className="relative flex items-center ml-auto mr-4" ref={dropdownRef}>
<div
Expand Down

0 comments on commit 27b9cd9

Please sign in to comment.