Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Switch } from '../../ui/switch';
import { Input } from '../../ui/input';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '../../ui/card';
import { AlertCircle } from 'lucide-react';
import { ExternalGoosedConfig } from '../../../utils/settings';
import { ExternalGoosedConfig } from '../../../utils/settingsTypes';

const DEFAULT_CONFIG: ExternalGoosedConfig = {
enabled: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '../..
import { Button } from '../../ui/button';
import { Switch } from '../../ui/switch';
import { ShortcutRecorder } from './ShortcutRecorder';
import { KeyboardShortcuts, defaultKeyboardShortcuts } from '../../../utils/settings';
import { KeyboardShortcuts, defaultKeyboardShortcuts } from '../../../utils/settingsTypes';
import { trackSettingToggled } from '../../../utils/analytics';

interface ShortcutConfig {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState, useEffect, useRef } from 'react';
import { Button } from '../../ui/button';
import { KeyboardShortcuts } from '../../../utils/settings';
import { KeyboardShortcuts } from '../../../utils/settingsTypes';
import { getShortcutLabel, formatShortcut } from './KeyboardShortcutsSection';

interface ShortcutRecorderProps {
Expand Down
2 changes: 1 addition & 1 deletion ui/desktop/src/preload.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Electron, { contextBridge, ipcRenderer, webUtils } from 'electron';
import { Recipe } from './recipe';
import { GooseApp } from './api';
import type { Settings } from './utils/settings';
import type { Settings } from './utils/settingsTypes';

interface NotificationData {
title: string;
Expand Down
78 changes: 15 additions & 63 deletions ui/desktop/src/utils/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,73 +2,25 @@ import { app } from 'electron';
import fs from 'fs';
import path from 'path';

export interface EnvToggles {
GOOSE_SERVER__MEMORY: boolean;
GOOSE_SERVER__COMPUTER_CONTROLLER: boolean;
}

export interface ExternalGoosedConfig {
enabled: boolean;
url: string;
secret: string;
}

export interface KeyboardShortcuts {
focusWindow: string | null;
quickLauncher: string | null;
newChat: string | null;
newChatWindow: string | null;
openDirectory: string | null;
settings: string | null;
find: string | null;
findNext: string | null;
findPrevious: string | null;
alwaysOnTop: string | null;
}
// Re-export types and constants for backwards compatibility in main process
export type {
EnvToggles,
ExternalGoosedConfig,
KeyboardShortcuts,
Settings,
} from './settingsTypes';
export { defaultKeyboardShortcuts, defaultSettings } from './settingsTypes';

type DefaultKeyboardShortcuts = {
[K in keyof KeyboardShortcuts]: string;
};

export interface Settings {
envToggles: EnvToggles;
showMenuBarIcon: boolean;
showDockIcon: boolean;
enableWakelock: boolean;
spellcheckEnabled: boolean;
externalGoosed?: ExternalGoosedConfig;
globalShortcut?: string | null; // Deprecated: use keyboardShortcuts.focusWindow
keyboardShortcuts?: KeyboardShortcuts;
}
import {
Settings,
KeyboardShortcuts,
EnvToggles,
defaultKeyboardShortcuts,
defaultSettings,
} from './settingsTypes';

const SETTINGS_FILE = path.join(app.getPath('userData'), 'settings.json');

export const defaultKeyboardShortcuts: DefaultKeyboardShortcuts = {
focusWindow: 'CommandOrControl+Alt+G',
quickLauncher: 'CommandOrControl+Alt+Shift+G',
newChat: 'CommandOrControl+T',
newChatWindow: 'CommandOrControl+N',
openDirectory: 'CommandOrControl+O',
settings: 'CommandOrControl+,',
find: 'CommandOrControl+F',
findNext: 'CommandOrControl+G',
findPrevious: 'CommandOrControl+Shift+G',
alwaysOnTop: 'CommandOrControl+Shift+T',
};

const defaultSettings: Settings = {
envToggles: {
GOOSE_SERVER__MEMORY: false,
GOOSE_SERVER__COMPUTER_CONTROLLER: false,
},
showMenuBarIcon: true,
showDockIcon: true,
enableWakelock: false,
spellcheckEnabled: true,
// globalShortcut is deprecated - not set in defaults, only kept in interface for backwards compatibility
keyboardShortcuts: defaultKeyboardShortcuts,
};

// Settings management
export function loadSettings(): Settings {
try {
Expand Down
67 changes: 67 additions & 0 deletions ui/desktop/src/utils/settingsTypes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Shared types and constants that can be used in both main and renderer processes
// This file should NOT import any Node.js or Electron modules

export interface EnvToggles {
GOOSE_SERVER__MEMORY: boolean;
GOOSE_SERVER__COMPUTER_CONTROLLER: boolean;
}

export interface ExternalGoosedConfig {
enabled: boolean;
url: string;
secret: string;
}

export interface KeyboardShortcuts {
focusWindow: string | null;
quickLauncher: string | null;
newChat: string | null;
newChatWindow: string | null;
openDirectory: string | null;
settings: string | null;
find: string | null;
findNext: string | null;
findPrevious: string | null;
alwaysOnTop: string | null;
}

type DefaultKeyboardShortcuts = {
[K in keyof KeyboardShortcuts]: string;
};

export interface Settings {
envToggles: EnvToggles;
showMenuBarIcon: boolean;
showDockIcon: boolean;
enableWakelock: boolean;
spellcheckEnabled: boolean;
externalGoosed?: ExternalGoosedConfig;
globalShortcut?: string | null; // Deprecated: use keyboardShortcuts.focusWindow
keyboardShortcuts?: KeyboardShortcuts;
}

export const defaultKeyboardShortcuts: DefaultKeyboardShortcuts = {
focusWindow: 'CommandOrControl+Alt+G',
quickLauncher: 'CommandOrControl+Alt+Shift+G',
newChat: 'CommandOrControl+T',
newChatWindow: 'CommandOrControl+N',
openDirectory: 'CommandOrControl+O',
settings: 'CommandOrControl+,',
find: 'CommandOrControl+F',
findNext: 'CommandOrControl+G',
findPrevious: 'CommandOrControl+Shift+G',
alwaysOnTop: 'CommandOrControl+Shift+T',
};

export const defaultSettings: Settings = {
envToggles: {
GOOSE_SERVER__MEMORY: false,
GOOSE_SERVER__COMPUTER_CONTROLLER: false,
},
showMenuBarIcon: true,
showDockIcon: true,
enableWakelock: false,
spellcheckEnabled: true,
// globalShortcut is deprecated - not set in defaults, only kept in interface for backwards compatibility
keyboardShortcuts: defaultKeyboardShortcuts,
};