Skip to content
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

feat(desktop-ui): Command/ctrl + comma goes to Settings view #1439

Merged
merged 1 commit into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ui/desktop/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

export type ViewConfig = {
view: View;
viewOptions?: SettingsViewOptions | Record<any, any>;

Check warning on line 37 in ui/desktop/src/App.tsx

View workflow job for this annotation

GitHub Actions / Lint Electron Desktop App

Unexpected any. Specify a different type

Check warning on line 37 in ui/desktop/src/App.tsx

View workflow job for this annotation

GitHub Actions / Lint Electron Desktop App

Unexpected any. Specify a different type
};

export default function App() {
Expand All @@ -50,7 +50,7 @@

const { switchModel } = useModel();
const { addRecentModel } = useRecentModels();
const setView = (view: View, viewOptions: Record<any, any> = {}) => {

Check warning on line 53 in ui/desktop/src/App.tsx

View workflow job for this annotation

GitHub Actions / Lint Electron Desktop App

Unexpected any. Specify a different type

Check warning on line 53 in ui/desktop/src/App.tsx

View workflow job for this annotation

GitHub Actions / Lint Electron Desktop App

Unexpected any. Specify a different type
setInternalView({ view, viewOptions });
};

Expand All @@ -63,7 +63,7 @@
}

useEffect(() => {
const handleAddExtension = (_: any, link: string) => {

Check warning on line 66 in ui/desktop/src/App.tsx

View workflow job for this annotation

GitHub Actions / Lint Electron Desktop App

Unexpected any. Specify a different type
const command = extractCommand(link);
const extName = extractExtensionName(link);
window.electron.logInfo(`Adding extension from deep link ${link}`);
Expand Down Expand Up @@ -137,10 +137,10 @@
};

setupStoredProvider();
}, []);

Check warning on line 140 in ui/desktop/src/App.tsx

View workflow job for this annotation

GitHub Actions / Lint Electron Desktop App

React Hook useEffect has missing dependencies: 'addRecentModel' and 'switchModel'. Either include them or remove the dependency array

useEffect(() => {
const handleFatalError = (_: any, errorMessage: string) => {

Check warning on line 143 in ui/desktop/src/App.tsx

View workflow job for this annotation

GitHub Actions / Lint Electron Desktop App

Unexpected any. Specify a different type
setFatalError(errorMessage);
};

Expand All @@ -150,6 +150,12 @@
};
}, []);

useEffect(() => {
const handleSetView = (_, view) => setView(view);
window.electron.on('set-view', handleSetView);
return () => window.electron.off('set-view', handleSetView);
}, []);

const handleConfirm = async () => {
if (pendingLink && !isInstalling) {
setIsInstalling(true);
Expand Down
2 changes: 1 addition & 1 deletion ui/desktop/src/components/MoreMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export default function MoreMenu({ setView }: { setView: (view: View) => void })
}}
className="w-full text-left p-2 text-sm hover:bg-bgSubtle transition-colors"
>
Settings
Settings (cmd+,)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tiny nit: would show this as ⌘,

(or i think electron has a helper to do ⌘/^ depending if on windows? but i can't seem to find it and this is something we can review later when we have more official windows support)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, totally agree, just following the current pattern in the menu:
image
I'll probably redo this menu so that it more matches more standard app menus, like Chrome:
image

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh! i didn't realize haha - yes lets merge and separate we can clean these up 🙇

</button>

<button
Expand Down
16 changes: 16 additions & 0 deletions ui/desktop/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,22 @@ app.whenReady().then(async () => {
// Get the existing menu
const menu = Menu.getApplicationMenu();

// App menu
const appMenu = menu.items.find((item) => item.label === 'Goose');
// add Settings to app menu after About
appMenu.submenu.insert(1, new MenuItem({ type: 'separator' }));
appMenu.submenu.insert(1,
new MenuItem({
label: 'Settings',
accelerator: 'CmdOrCtrl+,',
click() {
const focusedWindow = BrowserWindow.getFocusedWindow();
if (focusedWindow) focusedWindow.webContents.send('set-view', 'settings');
},
})
);
appMenu.submenu.insert(1, new MenuItem({ type: 'separator' }));

// Add Environment menu items to View menu
const viewMenu = menu.items.find((item) => item.label === 'View');
if (viewMenu) {
Expand Down
Loading