UI bug fixes

This commit is contained in:
Stijnus
2025-02-18 14:13:13 +01:00
parent 6e89710ec7
commit 0e60d9cca8
9 changed files with 133 additions and 116 deletions

View File

@@ -1,5 +1,4 @@
import { atom, map } from 'nanostores';
import { workbenchStore } from './workbench';
import { PROVIDER_LIST } from '~/utils/constants';
import type { IProviderConfig } from '~/types/model';
import type {
@@ -11,7 +10,7 @@ import type {
import { DEFAULT_TAB_CONFIG } from '~/components/@settings/core/constants';
import Cookies from 'js-cookie';
import { toggleTheme } from './theme';
import { chatStore } from './chat';
import { create } from 'zustand';
export interface Shortcut {
key: string;
@@ -26,10 +25,8 @@ export interface Shortcut {
}
export interface Shortcuts {
toggleTerminal: Shortcut;
toggleTheme: Shortcut;
toggleChat: Shortcut;
toggleSettings: Shortcut;
toggleTerminal: Shortcut;
}
export const URL_CONFIGURABLE_PROVIDERS = ['Ollama', 'LMStudio', 'OpenAILike'];
@@ -37,15 +34,8 @@ export const LOCAL_PROVIDERS = ['OpenAILike', 'LMStudio', 'Ollama'];
export type ProviderSetting = Record<string, IProviderConfig>;
// Define safer shortcuts that don't conflict with browser defaults
// Simplified shortcuts store with only theme toggle
export const shortcutsStore = map<Shortcuts>({
toggleTerminal: {
key: '`',
ctrlOrMetaKey: true,
action: () => workbenchStore.toggleTerminal(),
description: 'Toggle terminal',
isPreventDefault: true,
},
toggleTheme: {
key: 'd',
metaKey: true,
@@ -55,22 +45,13 @@ export const shortcutsStore = map<Shortcuts>({
description: 'Toggle theme',
isPreventDefault: true,
},
toggleChat: {
key: 'j', // Changed from 'k' to 'j' to avoid conflicts
toggleTerminal: {
key: '`',
ctrlOrMetaKey: true,
altKey: true, // Added alt key to make it more unique
action: () => chatStore.setKey('showChat', !chatStore.get().showChat),
description: 'Toggle chat',
isPreventDefault: true,
},
toggleSettings: {
key: 's',
ctrlOrMetaKey: true,
altKey: true,
action: () => {
document.dispatchEvent(new CustomEvent('toggle-settings'));
// This will be handled by the terminal component
},
description: 'Toggle settings',
description: 'Toggle terminal',
isPreventDefault: true,
},
});
@@ -319,3 +300,35 @@ export const setDeveloperMode = (value: boolean) => {
localStorage.setItem(SETTINGS_KEYS.DEVELOPER_MODE, JSON.stringify(value));
}
};
// First, let's define the SettingsStore interface
interface SettingsStore {
isOpen: boolean;
selectedTab: string;
openSettings: () => void;
closeSettings: () => void;
setSelectedTab: (tab: string) => void;
}
export const useSettingsStore = create<SettingsStore>((set) => ({
isOpen: false,
selectedTab: 'user', // Default tab
openSettings: () => {
set({
isOpen: true,
selectedTab: 'user', // Always open to user tab
});
},
closeSettings: () => {
set({
isOpen: false,
selectedTab: 'user', // Reset to user tab when closing
});
},
setSelectedTab: (tab: string) => {
set({ selectedTab: tab });
},
}));