Skip to content
Draft
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 @@ -17,7 +17,9 @@ import RuntimeSelectorPill, { RuntimeSelectorLoadingIndicator } from './RuntimeS
import {
composeRuntimeSelectorLabel,
getCurrentThoughtLevelLabel,
isThinkingModeOption,
isConfigSetting,
localizeThinkingModeOption,
RUNTIME_SUBMENU_TRIGGER_PROPS,
RuntimeSelectorCheckedItem,
RuntimeSelectorModelList,
Expand Down Expand Up @@ -69,6 +71,15 @@ const AcpModelSelector: React.FC<{
});

const defaultModelLabel = t('common.defaultModel');
const thinkingMode = isThinkingModeOption(thoughtLevel);
const displayThoughtLevel = localizeThinkingModeOption(thoughtLevel, {
enabled: t('agent.thinkingMode.enabled'),
disabled: t('agent.thinkingMode.disabled'),
});
const thoughtControlLabel = thinkingMode ? t('agent.thinkingMode.label') : t('agent.thoughtLevel.label');
const thoughtSwitchSuccess = thinkingMode
? t('agent.thinkingMode.switchSuccess')
: t('agent.thoughtLevel.switchSuccess');
const rawDisplayLabel =
(model_info?.current_model_id &&
model_info.available_models.find((m) => m.id === model_info.current_model_id)?.label) ||
Expand All @@ -81,19 +92,19 @@ const AcpModelSelector: React.FC<{
defaultModelLabel,
fallbackLabel: t('conversation.welcome.useCliModel'),
});
const combinedLabel = composeRuntimeSelectorLabel({ modelLabel: display_label, thoughtLevel });
const combinedLabel = composeRuntimeSelectorLabel({ modelLabel: display_label, thoughtLevel: displayThoughtLevel });
const isRuntimeSetting = isConfigSetting(setStatus);
const handleThoughtLevelSelect = useCallback(
async (value: string) => {
if (!thoughtLevel || value === thoughtLevel.currentValue || isRuntimeSetting) return;
try {
await setConfigOption(thoughtLevel.id, value);
Message.success(t('agent.thoughtLevel.switchSuccess'));
Message.success(thoughtSwitchSuccess);
} catch (error) {
Message.error(t(configErrorMessageKey(error)));
}
},
[isRuntimeSetting, setConfigOption, thoughtLevel, t]
[isRuntimeSetting, setConfigOption, thoughtLevel, thoughtSwitchSuccess]
);
const tooltipContent = combinedLabel;

Expand Down Expand Up @@ -170,12 +181,12 @@ const AcpModelSelector: React.FC<{
triggerProps={RUNTIME_SUBMENU_TRIGGER_PROPS}
title={
<RuntimeSelectorSubMenuTitle
label={t('agent.thoughtLevel.label')}
value={getCurrentThoughtLevelLabel(thoughtLevel)}
label={thoughtControlLabel}
value={getCurrentThoughtLevelLabel(displayThoughtLevel)}
/>
}
>
{thoughtLevel.options.map((item) => (
{displayThoughtLevel?.options.map((item) => (
<Menu.Item
key={item.value}
className={item.value === thoughtLevel.currentValue ? 'bg-2!' : ''}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,27 @@ export const getCurrentThoughtLevelLabel = (thoughtLevel: AcpDerivedOption | nul
);
};

export const isThinkingModeOption = (option: AcpDerivedOption | null | undefined): boolean => {
if (!option || option.options.length !== 2) return false;
const values = new Set(option.options.map((item) => item.value.toLowerCase()));
return values.has('enabled') && values.has('disabled');
};

export const localizeThinkingModeOption = (
option: AcpDerivedOption | null | undefined,
labels: { enabled: string; disabled: string }
): AcpDerivedOption | null => {
if (!option) return null;
if (!isThinkingModeOption(option)) return option;
return {
...option,
options: option.options.map((item) => ({
...item,
label: item.value.toLowerCase() === 'enabled' ? labels.enabled : labels.disabled,
})),
};
};

export const composeRuntimeSelectorLabel = ({
modelLabel,
thoughtLevel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ export function useAcpConfigOptions({
setStatus,
mode: deriveSelectOption(configOptions, 'mode', ['mode']),
model: deriveSelectOption(configOptions, 'model', ['model']),
thoughtLevel: deriveSelectOption(configOptions, 'thought_level', ['thought_level', 'reasoning_effort']),
thoughtLevel: deriveSelectOption(configOptions, 'thought_level', ['thought_level', 'reasoning_effort', 'thinking']),
reload,
setConfigOption,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { isBackendHttpError } from '@/common/adapter/httpBridge';
import { isSideQuestionSupported } from '@/common/chat/sideQuestion';
import { parseError, uuid } from '@/common/utils';
import AgentModeSelector from '@/renderer/components/agent/AgentModeSelector';
import { isThinkingModeOption, localizeThinkingModeOption } from '@/renderer/components/agent/runtimeSelectorOptions';
import CommandQueuePanel from '@/renderer/components/chat/CommandQueuePanel';
import MobileActionSheet, {
type MobileActionSheetEntry,
Expand Down Expand Up @@ -152,6 +153,15 @@ const AcpSendBox: React.FC<{
});
const runtimeMode = runtimeConfig.mode;
const runtimeThoughtLevel = runtimeConfig.thoughtLevel;
const runtimeThinkingMode = isThinkingModeOption(runtimeThoughtLevel);
const displayRuntimeThoughtLevel = localizeThinkingModeOption(runtimeThoughtLevel, {
enabled: t('agent.thinkingMode.enabled'),
disabled: t('agent.thinkingMode.disabled'),
});
const thoughtControlLabel = runtimeThinkingMode ? t('agent.thinkingMode.label') : t('agent.thoughtLevel.label');
const thoughtSwitchSuccess = runtimeThinkingMode
? t('agent.thinkingMode.switchSuccess')
: t('agent.thoughtLevel.switchSuccess');
const handleThoughtLevelSetOption = useCallback(
async (optionId: string, value: string) => runtimeConfig.setConfigOption(optionId, value),
[runtimeConfig]
Expand Down Expand Up @@ -499,26 +509,26 @@ Please check your local CLI tool authentication status`,
});
}

if (runtimeThoughtLevel) {
if (runtimeThoughtLevel && displayRuntimeThoughtLevel) {
entries.push({
key: 'thought-level',
icon: <Brain theme='outline' size='16' />,
label: t('agent.thoughtLevel.label'),
label: thoughtControlLabel,
meta:
runtimeThoughtLevel.options.find((item) => item.value === runtimeThoughtLevel.currentValue)?.label ||
displayRuntimeThoughtLevel.options.find((item) => item.value === runtimeThoughtLevel.currentValue)?.label ||
runtimeThoughtLevel.currentValue ||
'',
submenu: {
title: t('agent.thoughtLevel.label'),
options: runtimeThoughtLevel.options.map((item) => ({
title: thoughtControlLabel,
options: displayRuntimeThoughtLevel.options.map((item) => ({
key: item.value,
label: item.label,
description: item.description ?? undefined,
active: runtimeThoughtLevel.currentValue === item.value,
})),
onSelect: (value) => {
void handleThoughtLevelSetOption(runtimeThoughtLevel.id, value)
.then(() => Message.success(t('agent.thoughtLevel.switchSuccess')))
.then(() => Message.success(thoughtSwitchSuccess))
.catch((error) => Message.error(t(configErrorMessageKey(error))));
},
},
Expand Down Expand Up @@ -597,6 +607,7 @@ Please check your local CLI tool authentication status`,
attachEntries,
canSwitchModel,
currentMode,
displayRuntimeThoughtLevel,
handleSheetModeChange,
handleThoughtLevelSetOption,
isMobile,
Expand All @@ -608,6 +619,8 @@ Please check your local CLI tool authentication status`,
selectModel,
setContent,
t,
thoughtControlLabel,
thoughtSwitchSuccess,
]);

useAddEventListener('acp.selected.file', setAtPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import type { AcpConfigSetStatus, AcpDerivedOption } from '@/renderer/hooks/agen
import {
composeRuntimeSelectorLabel,
getCurrentThoughtLevelLabel,
isThinkingModeOption,
localizeThinkingModeOption,
RUNTIME_SUBMENU_TRIGGER_PROPS,
RuntimeSelectorCheckedItem,
RuntimeSelectorModelList,
Expand Down Expand Up @@ -44,6 +46,12 @@ const AionrsModelSelector: React.FC<{
const defaultModelLabel = t('common.defaultModel');

const current_model = selection?.current_model;
const thinkingMode = isThinkingModeOption(thoughtLevel);
const displayThoughtLevel = localizeThinkingModeOption(thoughtLevel, {
enabled: t('agent.thinkingMode.enabled'),
disabled: t('agent.thinkingMode.disabled'),
});
const thoughtControlLabel = thinkingMode ? t('agent.thinkingMode.label') : t('agent.thoughtLevel.label');

const renderLogo = () => <Brain theme='outline' size='14' fill={iconColors.secondary} className='shrink-0' />;

Expand Down Expand Up @@ -77,7 +85,7 @@ const AionrsModelSelector: React.FC<{
defaultModelLabel,
fallbackLabel: t('conversation.welcome.selectModel'),
});
const combinedLabel = composeRuntimeSelectorLabel({ modelLabel: label, thoughtLevel });
const combinedLabel = composeRuntimeSelectorLabel({ modelLabel: label, thoughtLevel: displayThoughtLevel });
const handleThoughtLevelSelect = (value: string) => {
if (!thoughtLevel || value === thoughtLevel.currentValue || !onSetThoughtLevel) return;
void onSetThoughtLevel(thoughtLevel.id, value);
Expand Down Expand Up @@ -134,12 +142,12 @@ const AionrsModelSelector: React.FC<{
triggerProps={RUNTIME_SUBMENU_TRIGGER_PROPS}
title={
<RuntimeSelectorSubMenuTitle
label={t('agent.thoughtLevel.label')}
value={getCurrentThoughtLevelLabel(thoughtLevel)}
label={thoughtControlLabel}
value={getCurrentThoughtLevelLabel(displayThoughtLevel)}
/>
}
>
{thoughtLevel.options.map((item) => (
{displayThoughtLevel?.options.map((item) => (
<Menu.Item
key={item.value}
className={item.value === thoughtLevel.currentValue ? '!bg-2' : ''}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import { ipcBridge } from '@/common';
import type { IConversationMcpStatus } from '@/common/config/storage';
import AgentModeSelector from '@/renderer/components/agent/AgentModeSelector';
import { isThinkingModeOption, localizeThinkingModeOption } from '@/renderer/components/agent/runtimeSelectorOptions';
import CommandQueuePanel from '@/renderer/components/chat/CommandQueuePanel';
import MobileActionSheet, {
type MobileActionSheetEntry,
Expand Down Expand Up @@ -183,6 +184,15 @@ const AionrsSendBox: React.FC<{
});
const runtimeMode = runtimeConfig.mode;
const runtimeThoughtLevel = runtimeConfig.thoughtLevel;
const runtimeThinkingMode = isThinkingModeOption(runtimeThoughtLevel);
const displayRuntimeThoughtLevel = localizeThinkingModeOption(runtimeThoughtLevel, {
enabled: t('agent.thinkingMode.enabled'),
disabled: t('agent.thinkingMode.disabled'),
});
const thoughtControlLabel = runtimeThinkingMode ? t('agent.thinkingMode.label') : t('agent.thoughtLevel.label');
const thoughtSwitchSuccess = runtimeThinkingMode
? t('agent.thinkingMode.switchSuccess')
: t('agent.thoughtLevel.switchSuccess');

useEffect(() => {
if (!runtimeMode?.currentValue) return;
Expand Down Expand Up @@ -511,18 +521,18 @@ const AionrsSendBox: React.FC<{
...attachEntries,
];

if (runtimeThoughtLevel) {
if (runtimeThoughtLevel && displayRuntimeThoughtLevel) {
entries.splice(1, 0, {
key: 'thought-level',
icon: <Brain theme='outline' size='16' />,
label: t('agent.thoughtLevel.label'),
label: thoughtControlLabel,
meta:
runtimeThoughtLevel.options.find((item) => item.value === runtimeThoughtLevel.currentValue)?.label ||
displayRuntimeThoughtLevel.options.find((item) => item.value === runtimeThoughtLevel.currentValue)?.label ||
runtimeThoughtLevel.currentValue ||
'',
submenu: {
title: t('agent.thoughtLevel.label'),
options: runtimeThoughtLevel.options.map((item) => ({
title: thoughtControlLabel,
options: displayRuntimeThoughtLevel.options.map((item) => ({
key: item.value,
label: item.label,
description: item.description ?? undefined,
Expand All @@ -531,7 +541,7 @@ const AionrsSendBox: React.FC<{
onSelect: (value) => {
void runtimeConfig
.setConfigOption(runtimeThoughtLevel.id, value)
.then(() => Message.success(t('agent.thoughtLevel.switchSuccess')))
.then(() => Message.success(thoughtSwitchSuccess))
.catch((error) => Message.error(t(configErrorMessageKey(error))));
},
},
Expand Down Expand Up @@ -588,6 +598,7 @@ const AionrsSendBox: React.FC<{
}, [
attachEntries,
currentMode,
displayRuntimeThoughtLevel,
dynamicModes,
handleSheetModeChange,
handleSheetModelSelect,
Expand All @@ -600,6 +611,8 @@ const AionrsSendBox: React.FC<{
runtimeThoughtLevel,
setContent,
t,
thoughtControlLabel,
thoughtSwitchSuccess,
]);

useAddEventListener('aionrs.selected.file', setAtPath);
Expand Down
4 changes: 4 additions & 0 deletions packages/desktop/src/renderer/services/i18n/i18n-keys.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ export type I18nKey =
| 'agent.setup.noAlternatives'
| 'agent.setup.notConfigured'
| 'agent.setup.switching'
| 'agent.thinkingMode.disabled'
| 'agent.thinkingMode.enabled'
| 'agent.thinkingMode.label'
| 'agent.thinkingMode.switchSuccess'
| 'agent.thoughtLevel.label'
| 'agent.thoughtLevel.switchFailed'
| 'agent.thoughtLevel.switchSuccess'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,11 @@
"label": "Denk-Stufe",
"switchSuccess": "Denk-Stufe gewechselt",
"switchFailed": "Wechsel der Denk-Stufe fehlgeschlagen"
},
"thinkingMode": {
"label": "Denkmodus",
"enabled": "Ein",
"disabled": "Aus",
"switchSuccess": "Denkmodus gewechselt"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,11 @@
"label": "Thinking Level",
"switchSuccess": "Thinking level switched",
"switchFailed": "Failed to switch thinking level"
},
"thinkingMode": {
"label": "Thinking Mode",
"enabled": "On",
"disabled": "Off",
"switchSuccess": "Thinking mode switched"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,11 @@
"label": "Nivel de razonamiento",
"switchSuccess": "Nivel de razonamiento cambiado",
"switchFailed": "Error al cambiar el nivel de razonamiento"
},
"thinkingMode": {
"label": "Modo de razonamiento",
"enabled": "Activado",
"disabled": "Desactivado",
"switchSuccess": "Modo de razonamiento cambiado"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,11 @@
"label": "سطح تفکر",
"switchSuccess": "سطح تفکر تغییر کرد",
"switchFailed": "تغییر سطح تفکر ناموفق بود"
},
"thinkingMode": {
"label": "حالت تفکر",
"enabled": "فعال",
"disabled": "غیرفعال",
"switchSuccess": "حالت تفکر تغییر کرد"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,11 @@
"label": "Niveau de réflexion",
"switchSuccess": "Niveau de réflexion changé",
"switchFailed": "Échec du changement de niveau de réflexion"
},
"thinkingMode": {
"label": "Mode de réflexion",
"enabled": "Activé",
"disabled": "Désactivé",
"switchSuccess": "Mode de réflexion modifié"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,11 @@
"label": "思考レベル",
"switchSuccess": "思考レベルを切り替えました",
"switchFailed": "思考レベルの切り替えに失敗しました"
},
"thinkingMode": {
"label": "思考モード",
"enabled": "オン",
"disabled": "オフ",
"switchSuccess": "思考モードを切り替えました"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,11 @@
"label": "사고 강도",
"switchSuccess": "사고 강도가 전환되었습니다",
"switchFailed": "사고 강도 전환에 실패했습니다"
},
"thinkingMode": {
"label": "사고 모드",
"enabled": "켜기",
"disabled": "끄기",
"switchSuccess": "사고 모드가 전환되었습니다"
}
}
Loading