Redesign settings as a full-screen view (#12163)
This commit is contained in:
@@ -38,6 +38,7 @@ const AppLayoutContent: React.FC<AppLayoutContentProps> = ({ activeSessions }) =
|
||||
const safeIsMacOS = (window?.electron?.platform || 'darwin') === 'darwin';
|
||||
const chatContext = useChatContext();
|
||||
const isOnPairRoute = location.pathname === '/pair';
|
||||
const isOnSettingsRoute = location.pathname === '/settings';
|
||||
|
||||
const [isFullScreen, setIsFullScreen] = useState(false);
|
||||
|
||||
@@ -96,6 +97,17 @@ const AppLayoutContent: React.FC<AppLayoutContentProps> = ({ activeSessions }) =
|
||||
|
||||
const { setChat } = chatContext;
|
||||
|
||||
if (isOnSettingsRoute) {
|
||||
return (
|
||||
<div className="relative flex h-full w-full flex-1 bg-background-secondary">
|
||||
<Outlet />
|
||||
<div className="hidden">
|
||||
<ChatSessionsContainer setChat={setChat} activeSessions={activeSessions} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const needsTrafficLightInset = safeIsMacOS && !isFullScreen;
|
||||
const headerPadding = needsTrafficLightInset ? 'pl-[96px]' : 'pl-4';
|
||||
const headerTop = needsTrafficLightInset ? 'top-[14px]' : 'top-[11px]';
|
||||
|
||||
@@ -0,0 +1,439 @@
|
||||
import { type ReactNode, useEffect, useState } from 'react';
|
||||
import { useConfig } from '../ConfigContext';
|
||||
import { Input } from '../ui/input';
|
||||
import { Switch } from '../ui/switch';
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '../ui/card';
|
||||
import { defineMessages, useIntl } from '../../i18n';
|
||||
|
||||
const i18n = defineMessages({
|
||||
title: {
|
||||
id: 'settings.agentLoop.title',
|
||||
defaultMessage: 'Agent Loop',
|
||||
},
|
||||
description: {
|
||||
id: 'settings.agentLoop.description',
|
||||
defaultMessage: 'Use the operation-based agent loop. Turn this off to use the legacy loop.',
|
||||
},
|
||||
operationsHeading: {
|
||||
id: 'settings.agentLoop.operations.heading',
|
||||
defaultMessage: 'Configurable operations',
|
||||
},
|
||||
enableOperation: {
|
||||
id: 'settings.agentLoop.operations.enable',
|
||||
defaultMessage: 'Enable {operation}',
|
||||
},
|
||||
slashCommandsTitle: {
|
||||
id: 'settings.agentLoop.operations.slashCommands.title',
|
||||
defaultMessage: 'Slash commands',
|
||||
},
|
||||
slashCommandsDescription: {
|
||||
id: 'settings.agentLoop.operations.slashCommands.description',
|
||||
defaultMessage: 'Recognizes commands such as /compact, /skills, and recipe shortcuts.',
|
||||
},
|
||||
maxTurnsTitle: {
|
||||
id: 'settings.agentLoop.operations.maxTurns.title',
|
||||
defaultMessage: 'Max turns',
|
||||
},
|
||||
maxTurnsDescription: {
|
||||
id: 'settings.agentLoop.operations.maxTurns.description',
|
||||
defaultMessage: 'Stops autonomous work and asks the user before continuing.',
|
||||
},
|
||||
contextCompactionTitle: {
|
||||
id: 'settings.agentLoop.operations.contextCompaction.title',
|
||||
defaultMessage: 'Context compaction',
|
||||
},
|
||||
contextCompactionDescription: {
|
||||
id: 'settings.agentLoop.operations.contextCompaction.description',
|
||||
defaultMessage: 'Summarizes conversation history before the context window fills.',
|
||||
},
|
||||
toolPairCompactionTitle: {
|
||||
id: 'settings.agentLoop.operations.toolPairCompaction.title',
|
||||
defaultMessage: 'Tool pair compaction',
|
||||
},
|
||||
toolPairCompactionDescription: {
|
||||
id: 'settings.agentLoop.operations.toolPairCompaction.description',
|
||||
defaultMessage:
|
||||
'Summarizes older tool requests and responses to save context. The cutoff is automatic when blank.',
|
||||
},
|
||||
recipeRetryTitle: {
|
||||
id: 'settings.agentLoop.operations.recipeRetry.title',
|
||||
defaultMessage: 'Recipe retry',
|
||||
},
|
||||
recipeRetryDescription: {
|
||||
id: 'settings.agentLoop.operations.recipeRetry.description',
|
||||
defaultMessage: 'Runs recipe checks again when a configured success check fails.',
|
||||
},
|
||||
stopHooksTitle: {
|
||||
id: 'settings.agentLoop.operations.stopHooks.title',
|
||||
defaultMessage: 'Stop hooks',
|
||||
},
|
||||
stopHooksDescription: {
|
||||
id: 'settings.agentLoop.operations.stopHooks.description',
|
||||
defaultMessage: 'Lets hooks block completion while preventing endless stop cycles.',
|
||||
},
|
||||
turnsLabel: {
|
||||
id: 'settings.agentLoop.operations.turns.label',
|
||||
defaultMessage: 'Turns',
|
||||
},
|
||||
thresholdLabel: {
|
||||
id: 'settings.agentLoop.operations.threshold.label',
|
||||
defaultMessage: 'Threshold %',
|
||||
},
|
||||
cutoffLabel: {
|
||||
id: 'settings.agentLoop.operations.cutoff.label',
|
||||
defaultMessage: 'Cutoff',
|
||||
},
|
||||
retryTimeoutLabel: {
|
||||
id: 'settings.agentLoop.operations.retryTimeout.label',
|
||||
defaultMessage: 'Retry timeout',
|
||||
},
|
||||
failureTimeoutLabel: {
|
||||
id: 'settings.agentLoop.operations.failureTimeout.label',
|
||||
defaultMessage: 'Failure timeout',
|
||||
},
|
||||
blockLimitLabel: {
|
||||
id: 'settings.agentLoop.operations.blockLimit.label',
|
||||
defaultMessage: 'Block limit',
|
||||
},
|
||||
autoPlaceholder: {
|
||||
id: 'settings.agentLoop.operations.auto.placeholder',
|
||||
defaultMessage: 'Auto',
|
||||
},
|
||||
});
|
||||
|
||||
type NumberSetting =
|
||||
| 'maxTurns'
|
||||
| 'compactionThreshold'
|
||||
| 'toolCallCutoff'
|
||||
| 'retryTimeout'
|
||||
| 'failureTimeout'
|
||||
| 'stopHookBlockCap';
|
||||
|
||||
type NumberSettings = Record<NumberSetting, string>;
|
||||
|
||||
const defaultNumberSettings: NumberSettings = {
|
||||
maxTurns: '1000',
|
||||
compactionThreshold: '80',
|
||||
toolCallCutoff: '',
|
||||
retryTimeout: '300',
|
||||
failureTimeout: '600',
|
||||
stopHookBlockCap: '8',
|
||||
};
|
||||
|
||||
function readNumber(value: unknown, fallback: number) {
|
||||
return typeof value === 'number' && Number.isFinite(value) ? value : fallback;
|
||||
}
|
||||
|
||||
function OperationRow({
|
||||
title,
|
||||
description,
|
||||
enabled,
|
||||
onEnabledChange,
|
||||
children,
|
||||
}: {
|
||||
title: string;
|
||||
description: string;
|
||||
enabled?: boolean;
|
||||
onEnabledChange?: (checked: boolean) => void;
|
||||
children?: ReactNode;
|
||||
}) {
|
||||
const intl = useIntl();
|
||||
|
||||
return (
|
||||
<div className="border-t border-border-primary py-3 first:border-t-0">
|
||||
<div className="min-w-0">
|
||||
<div className="flex items-center gap-2">
|
||||
{enabled !== undefined && onEnabledChange && (
|
||||
<input
|
||||
type="checkbox"
|
||||
aria-label={intl.formatMessage(i18n.enableOperation, { operation: title })}
|
||||
checked={enabled}
|
||||
onChange={(event) => onEnabledChange(event.target.checked)}
|
||||
className="h-4 w-4 cursor-pointer rounded border-border-primary accent-bgApp"
|
||||
/>
|
||||
)}
|
||||
<h4 className="text-sm font-medium text-text-primary">{title}</h4>
|
||||
</div>
|
||||
<p className="mt-0.5 text-xs text-text-secondary">{description}</p>
|
||||
</div>
|
||||
{children && <div className="mt-3 flex items-center gap-3">{children}</div>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function NumberInput({
|
||||
label,
|
||||
value,
|
||||
min,
|
||||
max,
|
||||
step = 1,
|
||||
placeholder,
|
||||
disabled = false,
|
||||
onChange,
|
||||
onBlur,
|
||||
}: {
|
||||
label: string;
|
||||
value: string;
|
||||
min: number;
|
||||
max: number;
|
||||
step?: number;
|
||||
placeholder?: string;
|
||||
disabled?: boolean;
|
||||
onChange: (value: string) => void;
|
||||
onBlur: () => void;
|
||||
}) {
|
||||
return (
|
||||
<label className="flex items-center gap-2 text-xs text-text-secondary">
|
||||
<span>{label}</span>
|
||||
<Input
|
||||
type="number"
|
||||
value={value}
|
||||
min={min}
|
||||
max={max}
|
||||
step={step}
|
||||
placeholder={placeholder}
|
||||
disabled={disabled}
|
||||
onChange={(event) => onChange(event.target.value)}
|
||||
onBlur={onBlur}
|
||||
className="w-24"
|
||||
/>
|
||||
</label>
|
||||
);
|
||||
}
|
||||
|
||||
export default function AgentLoopSettings() {
|
||||
const intl = useIntl();
|
||||
const { read, remove, upsert } = useConfig();
|
||||
const [enabled, setEnabled] = useState(true);
|
||||
const [slashCommandsEnabled, setSlashCommandsEnabled] = useState(true);
|
||||
const [toolPairCompactionEnabled, setToolPairCompactionEnabled] = useState(false);
|
||||
const [numbers, setNumbers] = useState(defaultNumberSettings);
|
||||
|
||||
useEffect(() => {
|
||||
let active = true;
|
||||
|
||||
Promise.all([
|
||||
window.electron.getSetting('useLegacyAgentLoop'),
|
||||
read('GOOSE_MAX_TURNS', false),
|
||||
read('GOOSE_AUTO_COMPACT_THRESHOLD', false),
|
||||
read('GOOSE_SLASH_COMMANDS_ENABLED', false),
|
||||
read('GOOSE_TOOL_PAIR_SUMMARIZATION', false),
|
||||
read('GOOSE_TOOL_CALL_CUTOFF', false),
|
||||
read('GOOSE_RECIPE_RETRY_TIMEOUT_SECONDS', false),
|
||||
read('GOOSE_RECIPE_ON_FAILURE_TIMEOUT_SECONDS', false),
|
||||
read('GOOSE_STOP_HOOK_BLOCK_CAP', false),
|
||||
]).then(
|
||||
([
|
||||
useLegacyAgentLoop,
|
||||
maxTurns,
|
||||
compactionThreshold,
|
||||
slashCommands,
|
||||
toolPairCompaction,
|
||||
toolCallCutoff,
|
||||
retryTimeout,
|
||||
failureTimeout,
|
||||
stopHookBlockCap,
|
||||
]) => {
|
||||
if (!active) return;
|
||||
|
||||
setEnabled(!useLegacyAgentLoop);
|
||||
setSlashCommandsEnabled(typeof slashCommands === 'boolean' ? slashCommands : true);
|
||||
setToolPairCompactionEnabled(
|
||||
typeof toolPairCompaction === 'boolean' ? toolPairCompaction : false
|
||||
);
|
||||
setNumbers({
|
||||
maxTurns: String(readNumber(maxTurns, 1000)),
|
||||
compactionThreshold: String(
|
||||
Number((readNumber(compactionThreshold, 0.8) * 100).toFixed(2))
|
||||
),
|
||||
toolCallCutoff:
|
||||
typeof toolCallCutoff === 'number' && Number.isFinite(toolCallCutoff)
|
||||
? String(toolCallCutoff)
|
||||
: '',
|
||||
retryTimeout: String(readNumber(retryTimeout, 300)),
|
||||
failureTimeout: String(readNumber(failureTimeout, 600)),
|
||||
stopHookBlockCap: String(readNumber(stopHookBlockCap, 8)),
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
return () => {
|
||||
active = false;
|
||||
};
|
||||
}, [read]);
|
||||
|
||||
const setNumber = (setting: NumberSetting, value: string) => {
|
||||
setNumbers((current) => ({ ...current, [setting]: value }));
|
||||
};
|
||||
|
||||
const saveNumber = async (
|
||||
setting: NumberSetting,
|
||||
configKey: string,
|
||||
min: number,
|
||||
max: number,
|
||||
serialize: (value: number) => number = (value) => value,
|
||||
integer = true
|
||||
) => {
|
||||
const parsed = Number(numbers[setting]);
|
||||
const clamped = Math.min(max, Math.max(min, Number.isFinite(parsed) ? parsed : min));
|
||||
const value = integer ? Math.round(clamped) : clamped;
|
||||
setNumber(setting, String(value));
|
||||
await upsert(configKey, serialize(value), false);
|
||||
};
|
||||
|
||||
const handleAgentLoopToggle = async (checked: boolean) => {
|
||||
setEnabled(checked);
|
||||
await window.electron.setSetting('useLegacyAgentLoop', !checked);
|
||||
};
|
||||
|
||||
const handleToolPairCompactionToggle = async (checked: boolean) => {
|
||||
setToolPairCompactionEnabled(checked);
|
||||
await upsert('GOOSE_TOOL_PAIR_SUMMARIZATION', checked, false);
|
||||
};
|
||||
|
||||
const handleSlashCommandsToggle = async (checked: boolean) => {
|
||||
setSlashCommandsEnabled(checked);
|
||||
await upsert('GOOSE_SLASH_COMMANDS_ENABLED', checked, false);
|
||||
};
|
||||
|
||||
const saveToolCallCutoff = async () => {
|
||||
if (numbers.toolCallCutoff.trim() === '') {
|
||||
await remove('GOOSE_TOOL_CALL_CUTOFF', false);
|
||||
return;
|
||||
}
|
||||
await saveNumber('toolCallCutoff', 'GOOSE_TOOL_CALL_CUTOFF', 1, 100000);
|
||||
};
|
||||
|
||||
return (
|
||||
<section className="pr-4">
|
||||
<Card className="rounded-xl">
|
||||
<CardHeader>
|
||||
<div className="flex items-center justify-between gap-6">
|
||||
<div>
|
||||
<CardTitle>{intl.formatMessage(i18n.title)}</CardTitle>
|
||||
<CardDescription className="mt-1">
|
||||
{intl.formatMessage(i18n.description)}
|
||||
</CardDescription>
|
||||
</div>
|
||||
<Switch checked={enabled} onCheckedChange={handleAgentLoopToggle} variant="mono" />
|
||||
</div>
|
||||
</CardHeader>
|
||||
|
||||
{enabled && (
|
||||
<CardContent className="px-4">
|
||||
<h3 className="mb-1 text-xs font-semibold uppercase tracking-wider text-text-secondary">
|
||||
{intl.formatMessage(i18n.operationsHeading)}
|
||||
</h3>
|
||||
|
||||
<OperationRow
|
||||
title={intl.formatMessage(i18n.slashCommandsTitle)}
|
||||
description={intl.formatMessage(i18n.slashCommandsDescription)}
|
||||
enabled={slashCommandsEnabled}
|
||||
onEnabledChange={handleSlashCommandsToggle}
|
||||
/>
|
||||
|
||||
<OperationRow
|
||||
title={intl.formatMessage(i18n.maxTurnsTitle)}
|
||||
description={intl.formatMessage(i18n.maxTurnsDescription)}
|
||||
>
|
||||
<NumberInput
|
||||
label={intl.formatMessage(i18n.turnsLabel)}
|
||||
value={numbers.maxTurns}
|
||||
min={1}
|
||||
max={10000}
|
||||
onChange={(value) => setNumber('maxTurns', value)}
|
||||
onBlur={() => saveNumber('maxTurns', 'GOOSE_MAX_TURNS', 1, 10000)}
|
||||
/>
|
||||
</OperationRow>
|
||||
|
||||
<OperationRow
|
||||
title={intl.formatMessage(i18n.contextCompactionTitle)}
|
||||
description={intl.formatMessage(i18n.contextCompactionDescription)}
|
||||
>
|
||||
<NumberInput
|
||||
label={intl.formatMessage(i18n.thresholdLabel)}
|
||||
value={numbers.compactionThreshold}
|
||||
min={1}
|
||||
max={99}
|
||||
step={0.1}
|
||||
onChange={(value) => setNumber('compactionThreshold', value)}
|
||||
onBlur={() =>
|
||||
saveNumber(
|
||||
'compactionThreshold',
|
||||
'GOOSE_AUTO_COMPACT_THRESHOLD',
|
||||
1,
|
||||
99,
|
||||
(value) => value / 100,
|
||||
false
|
||||
)
|
||||
}
|
||||
/>
|
||||
</OperationRow>
|
||||
|
||||
<OperationRow
|
||||
title={intl.formatMessage(i18n.toolPairCompactionTitle)}
|
||||
description={intl.formatMessage(i18n.toolPairCompactionDescription)}
|
||||
enabled={toolPairCompactionEnabled}
|
||||
onEnabledChange={handleToolPairCompactionToggle}
|
||||
>
|
||||
<div className="flex flex-wrap items-center gap-4">
|
||||
<NumberInput
|
||||
label={intl.formatMessage(i18n.cutoffLabel)}
|
||||
value={numbers.toolCallCutoff}
|
||||
min={1}
|
||||
max={100000}
|
||||
placeholder={intl.formatMessage(i18n.autoPlaceholder)}
|
||||
disabled={!toolPairCompactionEnabled}
|
||||
onChange={(value) => setNumber('toolCallCutoff', value)}
|
||||
onBlur={saveToolCallCutoff}
|
||||
/>
|
||||
</div>
|
||||
</OperationRow>
|
||||
|
||||
<OperationRow
|
||||
title={intl.formatMessage(i18n.recipeRetryTitle)}
|
||||
description={intl.formatMessage(i18n.recipeRetryDescription)}
|
||||
>
|
||||
<div className="flex flex-col gap-2">
|
||||
<NumberInput
|
||||
label={intl.formatMessage(i18n.retryTimeoutLabel)}
|
||||
value={numbers.retryTimeout}
|
||||
min={1}
|
||||
max={3600}
|
||||
onChange={(value) => setNumber('retryTimeout', value)}
|
||||
onBlur={() =>
|
||||
saveNumber('retryTimeout', 'GOOSE_RECIPE_RETRY_TIMEOUT_SECONDS', 1, 3600)
|
||||
}
|
||||
/>
|
||||
<NumberInput
|
||||
label={intl.formatMessage(i18n.failureTimeoutLabel)}
|
||||
value={numbers.failureTimeout}
|
||||
min={1}
|
||||
max={3600}
|
||||
onChange={(value) => setNumber('failureTimeout', value)}
|
||||
onBlur={() =>
|
||||
saveNumber('failureTimeout', 'GOOSE_RECIPE_ON_FAILURE_TIMEOUT_SECONDS', 1, 3600)
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</OperationRow>
|
||||
|
||||
<OperationRow
|
||||
title={intl.formatMessage(i18n.stopHooksTitle)}
|
||||
description={intl.formatMessage(i18n.stopHooksDescription)}
|
||||
>
|
||||
<NumberInput
|
||||
label={intl.formatMessage(i18n.blockLimitLabel)}
|
||||
value={numbers.stopHookBlockCap}
|
||||
min={1}
|
||||
max={100}
|
||||
onChange={(value) => setNumber('stopHookBlockCap', value)}
|
||||
onBlur={() => saveNumber('stopHookBlockCap', 'GOOSE_STOP_HOOK_BLOCK_CAP', 1, 100)}
|
||||
/>
|
||||
</OperationRow>
|
||||
</CardContent>
|
||||
)}
|
||||
</Card>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -3,11 +3,11 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from '../ui/tabs';
|
||||
import { View, ViewOptions } from '../../utils/navigationUtils';
|
||||
import ModelsSection from './models/ModelsSection';
|
||||
import ExternalBackendSection from './app/ExternalBackendSection';
|
||||
import AgentLoopSettings from './AgentLoopSettings';
|
||||
import AppSettingsSection from './app/AppSettingsSection';
|
||||
import ConfigSettings from './config/ConfigSettings';
|
||||
import PromptsSettingsSection from './PromptsSettingsSection';
|
||||
import type { ExtensionConfig } from '../../types/extensions';
|
||||
import { MainPanelLayout } from '../Layout/MainPanelLayout';
|
||||
import {
|
||||
Bot,
|
||||
Share2,
|
||||
@@ -27,6 +27,8 @@ import { CONFIGURATION_ENABLED } from '../../updates';
|
||||
import { trackSettingsTabViewed } from '../../utils/analytics';
|
||||
import { useFeatures } from '../../contexts/FeaturesContext';
|
||||
import { defineMessages, useIntl } from '../../i18n';
|
||||
import BackButton from '../ui/BackButton';
|
||||
import { useNavigationContext } from '../Layout/NavigationContext';
|
||||
|
||||
const i18n = defineMessages({
|
||||
title: {
|
||||
@@ -45,9 +47,9 @@ const i18n = defineMessages({
|
||||
id: 'settingsView.tabChat',
|
||||
defaultMessage: 'Chat',
|
||||
},
|
||||
tabExternalBackend: {
|
||||
tabAgent: {
|
||||
id: 'settingsView.tabExternalBackend',
|
||||
defaultMessage: 'External Backend',
|
||||
defaultMessage: 'Agent',
|
||||
},
|
||||
tabPrompts: {
|
||||
id: 'settingsView.tabPrompts',
|
||||
@@ -67,6 +69,9 @@ const i18n = defineMessages({
|
||||
},
|
||||
});
|
||||
|
||||
const settingsTabClass =
|
||||
'w-full gap-3 rounded-full px-3 py-2 text-sm font-medium hover:bg-background-tertiary/60 data-[state=active]:bg-background-tertiary data-[state=active]:shadow-none';
|
||||
|
||||
export type SettingsViewOptions = {
|
||||
deepLinkConfig?: ExtensionConfig;
|
||||
showEnvVars?: boolean;
|
||||
@@ -85,8 +90,20 @@ export default function SettingsView({
|
||||
const [activeTab, setActiveTab] = useState('models');
|
||||
const hasTrackedInitialTab = useRef(false);
|
||||
const { localInference } = useFeatures();
|
||||
const { navWidth } = useNavigationContext();
|
||||
const intl = useIntl();
|
||||
|
||||
const activeTabTitle = {
|
||||
models: intl.formatMessage(i18n.tabModels),
|
||||
'local-inference': intl.formatMessage(i18n.tabLocalInference),
|
||||
chat: intl.formatMessage(i18n.tabChat),
|
||||
sharing: intl.formatMessage(i18n.tabAgent),
|
||||
prompts: intl.formatMessage(i18n.tabPrompts),
|
||||
keyboard: intl.formatMessage(i18n.tabKeyboard),
|
||||
auth: intl.formatMessage(i18n.tabAuth),
|
||||
app: intl.formatMessage(i18n.tabApp),
|
||||
}[activeTab];
|
||||
|
||||
const handleTabChange = (tab: string) => {
|
||||
setActiveTab(tab);
|
||||
trackSettingsTabViewed(tab);
|
||||
@@ -103,6 +120,7 @@ export default function SettingsView({
|
||||
sharing: 'sharing',
|
||||
styles: 'chat',
|
||||
tools: 'chat',
|
||||
agent: 'sharing',
|
||||
app: 'app',
|
||||
chat: 'chat',
|
||||
prompts: 'prompts',
|
||||
@@ -147,150 +165,173 @@ export default function SettingsView({
|
||||
}, [onClose]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<MainPanelLayout>
|
||||
<div className="flex-1 flex flex-col min-h-0">
|
||||
<div className="bg-background-primary px-8 pb-8 pt-16">
|
||||
<div className="flex flex-col page-transition">
|
||||
<div className="flex justify-between items-center mb-1">
|
||||
<h1 className="text-4xl font-light">{intl.formatMessage(i18n.title)}</h1>
|
||||
</div>
|
||||
<div className="absolute inset-0 animate-fade-in bg-background-primary">
|
||||
<Tabs
|
||||
value={activeTab}
|
||||
onValueChange={handleTabChange}
|
||||
orientation="vertical"
|
||||
className="h-full min-h-0 w-full flex-row rounded-none"
|
||||
>
|
||||
<div className="h-full flex-shrink-0 p-2" style={{ width: navWidth }}>
|
||||
<aside
|
||||
aria-label={intl.formatMessage(i18n.title)}
|
||||
className="flex h-full w-full flex-col overflow-hidden rounded-xl border border-border-primary bg-background-primary"
|
||||
>
|
||||
<div className="h-[48px] flex-shrink-0 no-drag" />
|
||||
<div className="px-2">
|
||||
<BackButton
|
||||
onClick={onClose}
|
||||
variant="ghost"
|
||||
className="mb-3 w-full justify-start rounded-full px-3 text-sm font-medium hover:bg-background-tertiary/60"
|
||||
/>
|
||||
</div>
|
||||
<TabsList className="w-full flex-col items-stretch gap-0.5 bg-transparent px-2 py-0">
|
||||
<TabsTrigger
|
||||
value="models"
|
||||
className={settingsTabClass}
|
||||
data-testid="settings-models-tab"
|
||||
>
|
||||
<Bot className="h-5 w-5 text-text-secondary" />
|
||||
{intl.formatMessage(i18n.tabModels)}
|
||||
</TabsTrigger>
|
||||
{localInference && (
|
||||
<TabsTrigger
|
||||
value="local-inference"
|
||||
className={settingsTabClass}
|
||||
data-testid="settings-local-inference-tab"
|
||||
>
|
||||
<HardDrive className="h-5 w-5 text-text-secondary" />
|
||||
{intl.formatMessage(i18n.tabLocalInference)}
|
||||
</TabsTrigger>
|
||||
)}
|
||||
<TabsTrigger
|
||||
value="chat"
|
||||
className={settingsTabClass}
|
||||
data-testid="settings-chat-tab"
|
||||
>
|
||||
<MessageSquare className="h-5 w-5 text-text-secondary" />
|
||||
{intl.formatMessage(i18n.tabChat)}
|
||||
</TabsTrigger>
|
||||
<TabsTrigger
|
||||
value="sharing"
|
||||
className={settingsTabClass}
|
||||
data-testid="settings-sharing-tab"
|
||||
>
|
||||
<Share2 className="h-5 w-5 text-text-secondary" />
|
||||
{intl.formatMessage(i18n.tabAgent)}
|
||||
</TabsTrigger>
|
||||
<TabsTrigger
|
||||
value="prompts"
|
||||
className={settingsTabClass}
|
||||
data-testid="settings-prompts-tab"
|
||||
>
|
||||
<FileText className="h-5 w-5 text-text-secondary" />
|
||||
{intl.formatMessage(i18n.tabPrompts)}
|
||||
</TabsTrigger>
|
||||
<TabsTrigger
|
||||
value="keyboard"
|
||||
className={settingsTabClass}
|
||||
data-testid="settings-keyboard-tab"
|
||||
>
|
||||
<Keyboard className="h-5 w-5 text-text-secondary" />
|
||||
{intl.formatMessage(i18n.tabKeyboard)}
|
||||
</TabsTrigger>
|
||||
<TabsTrigger
|
||||
value="auth"
|
||||
className={settingsTabClass}
|
||||
data-testid="settings-auth-tab"
|
||||
>
|
||||
<KeyRound className="h-5 w-5 text-text-secondary" />
|
||||
{intl.formatMessage(i18n.tabAuth)}
|
||||
</TabsTrigger>
|
||||
<TabsTrigger
|
||||
value="app"
|
||||
className={settingsTabClass}
|
||||
data-testid="settings-app-tab"
|
||||
>
|
||||
<Monitor className="h-5 w-5 text-text-secondary" />
|
||||
{intl.formatMessage(i18n.tabApp)}
|
||||
</TabsTrigger>
|
||||
</TabsList>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
<main className="flex min-w-0 flex-1 flex-col overflow-hidden bg-background-primary">
|
||||
<div className="px-12 pb-8 pt-16">
|
||||
<div className="mx-auto max-w-5xl">
|
||||
<h1 className="text-4xl font-light">{activeTabTitle}</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex-1 min-h-0 relative px-6">
|
||||
<Tabs
|
||||
value={activeTab}
|
||||
onValueChange={handleTabChange}
|
||||
className="h-full flex flex-col"
|
||||
>
|
||||
<div className="px-1">
|
||||
<TabsList className="w-full mb-2 justify-start overflow-x-auto flex-nowrap">
|
||||
<TabsTrigger
|
||||
value="models"
|
||||
className="flex gap-2"
|
||||
data-testid="settings-models-tab"
|
||||
>
|
||||
<Bot className="h-4 w-4" />
|
||||
{intl.formatMessage(i18n.tabModels)}
|
||||
</TabsTrigger>
|
||||
{localInference && (
|
||||
<TabsTrigger
|
||||
value="local-inference"
|
||||
className="flex gap-2"
|
||||
data-testid="settings-local-inference-tab"
|
||||
>
|
||||
<HardDrive className="h-4 w-4" />
|
||||
{intl.formatMessage(i18n.tabLocalInference)}
|
||||
</TabsTrigger>
|
||||
)}
|
||||
<TabsTrigger value="chat" className="flex gap-2" data-testid="settings-chat-tab">
|
||||
<MessageSquare className="h-4 w-4" />
|
||||
{intl.formatMessage(i18n.tabChat)}
|
||||
</TabsTrigger>
|
||||
<TabsTrigger
|
||||
value="sharing"
|
||||
className="flex gap-2"
|
||||
data-testid="settings-sharing-tab"
|
||||
>
|
||||
<Share2 className="h-4 w-4" />
|
||||
{intl.formatMessage(i18n.tabExternalBackend)}
|
||||
</TabsTrigger>
|
||||
<TabsTrigger
|
||||
value="prompts"
|
||||
className="flex gap-2"
|
||||
data-testid="settings-prompts-tab"
|
||||
>
|
||||
<FileText className="h-4 w-4" />
|
||||
{intl.formatMessage(i18n.tabPrompts)}
|
||||
</TabsTrigger>
|
||||
<TabsTrigger
|
||||
value="keyboard"
|
||||
className="flex gap-2"
|
||||
data-testid="settings-keyboard-tab"
|
||||
>
|
||||
<Keyboard className="h-4 w-4" />
|
||||
{intl.formatMessage(i18n.tabKeyboard)}
|
||||
</TabsTrigger>
|
||||
<TabsTrigger value="auth" className="flex gap-2" data-testid="settings-auth-tab">
|
||||
<KeyRound className="h-4 w-4" />
|
||||
{intl.formatMessage(i18n.tabAuth)}
|
||||
</TabsTrigger>
|
||||
<TabsTrigger value="app" className="flex gap-2" data-testid="settings-app-tab">
|
||||
<Monitor className="h-4 w-4" />
|
||||
{intl.formatMessage(i18n.tabApp)}
|
||||
</TabsTrigger>
|
||||
</TabsList>
|
||||
</div>
|
||||
<ScrollArea className="min-h-0 flex-1 px-12">
|
||||
<div className="mx-auto max-w-5xl pb-10">
|
||||
<TabsContent
|
||||
value="models"
|
||||
className="mt-0 focus-visible:outline-none focus-visible:ring-0"
|
||||
>
|
||||
<ModelsSection setView={setView} />
|
||||
</TabsContent>
|
||||
|
||||
<ScrollArea className="flex-1 px-2">
|
||||
{localInference && (
|
||||
<TabsContent
|
||||
value="models"
|
||||
value="local-inference"
|
||||
className="mt-0 focus-visible:outline-none focus-visible:ring-0"
|
||||
>
|
||||
<ModelsSection setView={setView} />
|
||||
<LocalInferenceSection />
|
||||
</TabsContent>
|
||||
)}
|
||||
|
||||
{localInference && (
|
||||
<TabsContent
|
||||
value="local-inference"
|
||||
className="mt-0 focus-visible:outline-none focus-visible:ring-0"
|
||||
>
|
||||
<LocalInferenceSection />
|
||||
</TabsContent>
|
||||
)}
|
||||
<TabsContent
|
||||
value="chat"
|
||||
className="mt-0 focus-visible:outline-none focus-visible:ring-0"
|
||||
>
|
||||
<ChatSettingsSection />
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent
|
||||
value="chat"
|
||||
className="mt-0 focus-visible:outline-none focus-visible:ring-0"
|
||||
>
|
||||
<ChatSettingsSection />
|
||||
</TabsContent>
|
||||
<TabsContent
|
||||
value="sharing"
|
||||
className="mt-0 focus-visible:outline-none focus-visible:ring-0"
|
||||
>
|
||||
<div className="space-y-4 pb-8">
|
||||
<AgentLoopSettings />
|
||||
<ExternalBackendSection />
|
||||
</div>
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent
|
||||
value="sharing"
|
||||
className="mt-0 focus-visible:outline-none focus-visible:ring-0"
|
||||
>
|
||||
<div className="space-y-8 pb-8">
|
||||
<ExternalBackendSection />
|
||||
</div>
|
||||
</TabsContent>
|
||||
<TabsContent
|
||||
value="prompts"
|
||||
className="mt-0 focus-visible:outline-none focus-visible:ring-0"
|
||||
>
|
||||
<PromptsSettingsSection />
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent
|
||||
value="prompts"
|
||||
className="mt-0 focus-visible:outline-none focus-visible:ring-0"
|
||||
>
|
||||
<PromptsSettingsSection />
|
||||
</TabsContent>
|
||||
<TabsContent
|
||||
value="keyboard"
|
||||
className="mt-0 focus-visible:outline-none focus-visible:ring-0"
|
||||
>
|
||||
<KeyboardShortcutsSection />
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent
|
||||
value="keyboard"
|
||||
className="mt-0 focus-visible:outline-none focus-visible:ring-0"
|
||||
>
|
||||
<KeyboardShortcutsSection />
|
||||
</TabsContent>
|
||||
<TabsContent
|
||||
value="auth"
|
||||
className="mt-0 focus-visible:outline-none focus-visible:ring-0"
|
||||
>
|
||||
<AuthSettingsSection />
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent
|
||||
value="auth"
|
||||
className="mt-0 focus-visible:outline-none focus-visible:ring-0"
|
||||
>
|
||||
<AuthSettingsSection />
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent
|
||||
value="app"
|
||||
className="mt-0 focus-visible:outline-none focus-visible:ring-0"
|
||||
>
|
||||
<div className="space-y-8">
|
||||
{CONFIGURATION_ENABLED && <ConfigSettings />}
|
||||
<AppSettingsSection scrollToSection={viewOptions.section} />
|
||||
</div>
|
||||
</TabsContent>
|
||||
</ScrollArea>
|
||||
</Tabs>
|
||||
</div>
|
||||
</div>
|
||||
</MainPanelLayout>
|
||||
</>
|
||||
<TabsContent
|
||||
value="app"
|
||||
className="mt-0 focus-visible:outline-none focus-visible:ring-0"
|
||||
>
|
||||
<div className="space-y-8">
|
||||
{CONFIGURATION_ENABLED && <ConfigSettings />}
|
||||
<AppSettingsSection scrollToSection={viewOptions.section} />
|
||||
</div>
|
||||
</TabsContent>
|
||||
</div>
|
||||
</ScrollArea>
|
||||
</main>
|
||||
</Tabs>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import { SecurityToggle } from '../security/SecurityToggle';
|
||||
import { ResponseStylesSection } from '../response_styles/ResponseStylesSection';
|
||||
import { GoosehintsSection } from './GoosehintsSection';
|
||||
import { SpellcheckToggle } from './SpellcheckToggle';
|
||||
import { LegacyAgentLoopToggle } from './LegacyAgentLoopToggle';
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '../../ui/card';
|
||||
import { defineMessages, useIntl } from '../../../i18n';
|
||||
|
||||
@@ -66,12 +65,6 @@ export default function ChatSettingsSection() {
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card className="pb-2 rounded-lg">
|
||||
<CardContent className="px-4 pt-4">
|
||||
<LegacyAgentLoopToggle />
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card className="pb-2 rounded-lg">
|
||||
<CardContent className="px-2">
|
||||
<SecurityToggle />
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { defineMessages, useIntl } from '../../../i18n';
|
||||
import { Switch } from '../../ui/switch';
|
||||
|
||||
const i18n = defineMessages({
|
||||
title: {
|
||||
id: 'settings.legacyAgentLoop.title',
|
||||
defaultMessage: 'Use Legacy Agent Loop',
|
||||
},
|
||||
description: {
|
||||
id: 'settings.legacyAgentLoop.description',
|
||||
defaultMessage: 'Fall back to the classic agent loop if the new one causes issues',
|
||||
},
|
||||
});
|
||||
|
||||
export function LegacyAgentLoopToggle() {
|
||||
const intl = useIntl();
|
||||
const [enabled, setEnabled] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
window.electron.getSetting('useLegacyAgentLoop').then((value) => setEnabled(value ?? false));
|
||||
}, []);
|
||||
|
||||
const handleToggle = async (checked: boolean) => {
|
||||
setEnabled(checked);
|
||||
await window.electron.setSetting('useLegacyAgentLoop', checked);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<h3 className="text-text-primary text-xs">{intl.formatMessage(i18n.title)}</h3>
|
||||
<p className="text-xs text-text-secondary max-w-md mt-[2px]">
|
||||
{intl.formatMessage(i18n.description)}
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex items-center">
|
||||
<Switch checked={enabled} onCheckedChange={handleToggle} variant="mono" />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,12 +1,10 @@
|
||||
import { useEffect, useState, useCallback } from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { all_goose_modes, ModeSelectionItem } from './ModeSelectionItem';
|
||||
import { useConfig } from '../../ConfigContext';
|
||||
import { ConversationLimitsDropdown } from './ConversationLimitsDropdown';
|
||||
|
||||
export const ModeSection = () => {
|
||||
const [currentMode, setCurrentMode] = useState('auto');
|
||||
const [maxTurns, setMaxTurns] = useState<number>(1000);
|
||||
const { config, read, upsert } = useConfig();
|
||||
const { config, upsert } = useConfig();
|
||||
|
||||
const handleModeChange = async (newMode: string) => {
|
||||
try {
|
||||
@@ -25,33 +23,8 @@ export const ModeSection = () => {
|
||||
}
|
||||
}, [config.GOOSE_MODE]);
|
||||
|
||||
const fetchMaxTurns = useCallback(async () => {
|
||||
try {
|
||||
const turns = (await read('GOOSE_MAX_TURNS', false)) as number;
|
||||
if (turns) {
|
||||
setMaxTurns(turns);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error fetching max turns:', error);
|
||||
}
|
||||
}, [read]);
|
||||
|
||||
const handleMaxTurnsChange = async (value: number) => {
|
||||
try {
|
||||
await upsert('GOOSE_MAX_TURNS', value, false);
|
||||
setMaxTurns(value);
|
||||
} catch (error) {
|
||||
console.error('Error updating max turns:', error);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
fetchMaxTurns();
|
||||
}, [fetchMaxTurns]);
|
||||
|
||||
return (
|
||||
<div className="space-y-1">
|
||||
{/* Mode Selection */}
|
||||
{all_goose_modes.map((mode) => (
|
||||
<ModeSelectionItem
|
||||
key={mode.key}
|
||||
@@ -62,9 +35,6 @@ export const ModeSection = () => {
|
||||
handleModeChange={handleModeChange}
|
||||
/>
|
||||
))}
|
||||
|
||||
{/* Conversation Limits Dropdown */}
|
||||
<ConversationLimitsDropdown maxTurns={maxTurns} onMaxTurnsChange={handleMaxTurnsChange} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user