Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

💄 style(chat-input): move the agent mode switch into advanced params (#22581)

Arvin Xu692391778efa
diff --git a/locales/en-US/setting.json b/locales/en-US/setting.json
index d5353b76db4..9ebf1287aff 100644
--- a/locales/en-US/setting.json
+++ b/locales/en-US/setting.json
@@ -1672,6 +1672,7 @@
"settingModel.model.title": "Model",
"settingModel.params.panel.advanced": "Advanced Settings",
"settingModel.params.panel.agentTitle": "Agent Advanced Settings",
+ "settingModel.params.panel.chatMode": "Mode",
"settingModel.params.panel.contextCompression": "Auto-compress Context",
"settingModel.params.panel.creativity": "Creativity",
"settingModel.params.panel.historyLimit": "Limit History Messages",
diff --git a/locales/zh-CN/setting.json b/locales/zh-CN/setting.json
index e6f34d705b7..40828775411 100644
--- a/locales/zh-CN/setting.json
+++ b/locales/zh-CN/setting.json
@@ -1672,6 +1672,7 @@
"settingModel.model.title": "模型",
"settingModel.params.panel.advanced": "高级设置",
"settingModel.params.panel.agentTitle": "代理高级设置",
+ "settingModel.params.panel.chatMode": "运行模式",
"settingModel.params.panel.contextCompression": "自动压缩上下文",
"settingModel.params.panel.creativity": "创造力",
"settingModel.params.panel.historyLimit": "限制历史消息",
diff --git a/packages/locales/src/default/setting.ts b/packages/locales/src/default/setting.ts
index f4b94d2bba3..1a8f4f79768 100644
--- a/packages/locales/src/default/setting.ts
+++ b/packages/locales/src/default/setting.ts
@@ -1561,6 +1561,7 @@ export default {
'settingModel.params.title': 'Advanced Parameters',
'settingModel.params.panel.advanced': 'Advanced Settings',
'settingModel.params.panel.agentTitle': 'Agent Advanced Settings',
+ 'settingModel.params.panel.chatMode': 'Mode',
'settingModel.params.panel.contextCompression': 'Auto-compress Context',
'settingModel.params.panel.creativity': 'Creativity',
'settingModel.params.panel.historyLimit': 'Limit History Messages',
diff --git a/src/features/ChatInput/ActionBar/Params/Controls.tsx b/src/features/ChatInput/ActionBar/Params/Controls.tsx
index ff908bcdbd2..f6177728600 100644
--- a/src/features/ChatInput/ActionBar/Params/Controls.tsx
+++ b/src/features/ChatInput/ActionBar/Params/Controls.tsx
@@ -10,6 +10,7 @@ import {
cx,
Flexbox,
Icon,
+ Segmented,
Select,
SliderWithInput,
Spin,
@@ -38,6 +39,9 @@ import { systemAgentSelectors } from '@/store/user/selectors';
import type { LobeAgentChatConfig, LobeAgentConfig } from '@/types/agent';
import { useAgentId } from '../../hooks/useAgentId';
+import { useChatInputResourceAccess } from '../../hooks/useChatInputResourceAccess';
+import { useEffectiveAgentMode } from '../../hooks/useEffectiveAgentMode';
+import { useToggleAgentMode } from '../../hooks/useToggleAgentMode';
import { useUpdateAgentConfig } from '../../hooks/useUpdateAgentConfig';
import { useParamsModelConfig } from './useParamsModelConfig';
@@ -426,8 +430,12 @@ const SliderField = ({
);
const Controls = ({ variant = 'popover' }: ControlsProps) => {
- const { t } = useTranslation(['setting', 'components']);
+ const { t } = useTranslation(['setting', 'components', 'chat']);
const agentId = useAgentId();
+ const toggleAgentMode = useToggleAgentMode();
+ const { canUseResource } = useChatInputResourceAccess();
+ const { canSelectAgentMode, currentMode, isAgentModeUnavailable } =
+ useEffectiveAgentMode(agentId);
const { updateAgentConfig } = useUpdateAgentConfig();
const { allowed: canCreate } = usePermission('create_content');
// Saving feedback belongs to this form. Keeping it here prevents a write from
@@ -737,6 +745,36 @@ const Controls = ({ variant = 'popover' }: ControlsProps) => {
</div>
<div className={styles.body}>
<div className={styles.commonSection}>
+ <ControlRow
+ tag="agentMode"
+ title={t('settingModel.params.panel.chatMode')}
+ action={
+ <Segmented
+ disabled={!canCreate || !canUseResource}
+ size={'small'}
+ value={currentMode}
+ options={[
+ {
+ disabled: !canSelectAgentMode,
+ label: t('chatMode.agent', { ns: 'chat' }),
+ value: 'agent',
+ },
+ { label: t('chatMode.chat', { ns: 'chat' }), value: 'chat' },
+ ]}
+ onChange={(value) => {
+ if (value === 'agent' && !canSelectAgentMode) return;
+ void toggleAgentMode(value === 'agent');
+ }}
+ />
+ }
+ tooltip={
+ isAgentModeUnavailable
+ ? t('chatMode.agentUnsupported', { ns: 'chat' })
+ : t(currentMode === 'agent' ? 'chatMode.agentDesc' : 'chatMode.chatDesc', {
+ ns: 'chat',
+ })
+ }
+ />
<ControlRow
tag="compression"
title={t('settingModel.params.panel.contextCompression')}
diff --git a/src/features/ChatInput/ControlBar/ModeSelector.tsx b/src/features/ChatInput/ControlBar/ModeSelector.tsx
deleted file mode 100644
index d7b179b4713..00000000000
--- a/src/features/ChatInput/ControlBar/ModeSelector.tsx
+++ /dev/null
@@ -1,269 +0,0 @@
-import { Flexbox, Icon, Popover, Tooltip } from '@lobehub/ui';
-import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
-import * as stylex from '@stylexjs/stylex';
-import {
- ChevronDownIcon,
- FolderIcon,
- InfinityIcon,
- MessageCircleIcon,
- SearchIcon,
- TerminalIcon,
- WrenchIcon,
-} from 'lucide-react';
-import { memo, useCallback, useState } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import { useBusinessAgentModeSync } from '@/business/client/hooks/useBusinessAgentMode';
-import { SkeletonBar } from '@/components/Skeleton';
-import { useAgentId } from '@/features/ChatInput/hooks/useAgentId';
-import { useChatInputResourceAccess } from '@/features/ChatInput/hooks/useChatInputResourceAccess';
-import { useEffectiveAgentMode } from '@/features/ChatInput/hooks/useEffectiveAgentMode';
-import { useToggleAgentMode } from '@/features/ChatInput/hooks/useToggleAgentMode';
-import { usePermission } from '@/hooks/usePermission';
-
-const styles = stylex.create({
- activeOption: {
- backgroundColor: { 'default': cssVar.colorFillSecondary, ':hover': cssVar.colorFillSecondary },
- backgroundImage: 'none',
- },
- agentTooltip: { display: 'flex', flexDirection: 'column', gap: '4px', minWidth: '160px' },
- agentTooltipCap: {
- display: 'flex',
- gap: '6px',
- alignItems: 'center',
- fontSize: '12px',
- color: cssVar.colorTextSecondary,
- },
- agentTooltipTitle: {
- marginBlockEnd: '2px',
- fontSize: '12px',
- fontWeight: 600,
- color: cssVar.colorText,
- },
- button: {
- cursor: 'pointer',
- display: 'flex',
- flex: 'none',
- gap: '6px',
- alignItems: 'center',
- paddingBlock: '2px',
- paddingInline: '4px',
- borderRadius: '4px',
- fontSize: '12px',
- color: { 'default': cssVar.colorTextSecondary, ':hover': cssVar.colorText },
- whiteSpace: 'nowrap',
- transition: 'all 0.2s',
- backgroundColor: { 'default': null, ':hover': cssVar.colorFillTertiary },
- backgroundImage: { 'default': null, ':hover': 'none' },
- },
- buttonDisabled: {
- cursor: 'not-allowed',
- opacity: 0.5,
- color: { 'default': cssVar.colorTextSecondary, ':hover': cssVar.colorTextSecondary },
- backgroundColor: { 'default': null, ':hover': 'transparent' },
- backgroundImage: { 'default': null, ':hover': 'none' },
- },
- option: {
- cursor: 'pointer',
- width: '100%',
- paddingBlock: '10px',
- paddingInline: '8px',
- borderRadius: cssVar.borderRadius,
- transition: 'background-color 0.2s',
- backgroundColor: { 'default': null, ':hover': cssVar.colorFillSecondary },
- backgroundImage: { 'default': null, ':hover': 'none' },
- },
- optionDesc: { fontSize: '12px', lineHeight: 1.4, color: cssVar.colorTextDescription },
- optionDisabled: {
- cursor: 'not-allowed',
- opacity: 0.55,
- backgroundColor: { 'default': null, ':hover': 'transparent' },
- backgroundImage: { 'default': null, ':hover': 'none' },
- },
- optionDisabledActive: {
- backgroundColor: { 'default': cssVar.colorFillSecondary, ':hover': 'transparent' },
- backgroundImage: 'none',
- },
- optionIcon: {
- flexShrink: 0,
- borderWidth: '1px',
- borderStyle: 'solid',
- borderColor: cssVar.colorBorderSecondary,
- borderRadius: cssVar.borderRadius,
- backgroundColor: cssVar.colorBgElevated,
- backgroundImage: 'none',
- },
- optionTitle: { fontSize: '14px', fontWeight: 500, lineHeight: 1.4, color: cssVar.colorText },
- // The popup pads its option rows by 4px, so its corner must be one step larger
- // than the rows' radius (borderRadius 8 → borderRadiusLG 12 = 8 + 4) to wrap them
- // concentrically instead of looking tighter than them.
- popoverPopup: { borderRadius: cssVar.borderRadiusLG },
-});
-
-const AGENT_CAPS = [
- { icon: WrenchIcon, key: 'tools' },
- { icon: SearchIcon, key: 'web' },
- { icon: FolderIcon, key: 'files' },
- { icon: TerminalIcon, key: 'env' },
-] as const;
-
-const ModeSelector = memo(() => {
- const { t } = useTranslation('chat');
- const agentId = useAgentId();
- const toggleAgentMode = useToggleAgentMode();
- useBusinessAgentModeSync(agentId);
- const [open, setOpen] = useState(false);
- const { allowed: canCreateContent, reason } = usePermission('create_content');
- // Agent/Chat mode is a caller runtime preference for ordinary Workspace
- // members; only members who cannot use the Agent are disabled.
- const { canUseResource, isGroupContext } = useChatInputResourceAccess();
- const disabled = !canCreateContent || !canUseResource;
- const disabledReason = !canCreateContent
- ? reason
- : t(isGroupContext ? 'input.viewOnlyGroup' : 'input.viewOnlyAgent');
-
- const { canSelectAgentMode, currentMode, isAgentModeUnavailable, isPreferenceLoading } =
- useEffectiveAgentMode(agentId);
- const CurrentIcon = currentMode === 'agent' ? InfinityIcon : MessageCircleIcon;
-
- const handleSelect = useCallback(
- async (mode: 'chat' | 'agent') => {
- if (disabled) return;
- if (mode === 'agent' && !canSelectAgentMode) return;
-
- setOpen(false);
- await toggleAgentMode(mode === 'agent');
- },
- [disabled, canSelectAgentMode, toggleAgentMode],
- );
-
- const handleOpenChange = useCallback(
- (nextOpen: boolean) => {
- if (disabled) return;
-
- setOpen(nextOpen);
- },
- [disabled],
- );
-
- const agentTooltip = (
- <div {...stylex.props(styles.agentTooltip)}>
- <div {...stylex.props(styles.agentTooltipTitle)}>{t('chatMode.agent')}</div>
- {AGENT_CAPS.map(({ key, icon }) => (
- <div {...stylex.props(styles.agentTooltipCap)} key={key}>
- <Icon icon={icon} size={12} />
- {t(`chatMode.agentCap.${key}`)}
- </div>
- ))}
- </div>
- );
-
- const chatTooltip = t('chatMode.chatDesc');
- const buttonTooltip = isAgentModeUnavailable
- ? t('chatMode.agentUnsupported')
- : currentMode === 'agent'
- ? agentTooltip
- : chatTooltip;
- const agentDesc = canSelectAgentMode ? t('chatMode.agentDesc') : t('chatMode.agentUnsupported');
-
- const popoverContent = (
- <Flexbox gap={4} style={{ maxWidth: 320, minWidth: 280 }}>
- <Flexbox
- horizontal
- align="center"
- gap={12}
- className={
- stylex.props(
- styles.option,
- currentMode === 'agent' && styles.activeOption,
- !canSelectAgentMode && styles.optionDisabled,
- currentMode === 'agent' && !canSelectAgentMode && styles.optionDisabledActive,
- ).className
- }
- onClick={() => handleSelect('agent')}
- >
- <Flexbox
- align="center"
- className={stylex.props(styles.optionIcon).className}
- height={32}
- justify="center"
- width={32}
- >
- <Icon icon={InfinityIcon} size={16} />
- </Flexbox>
- <Flexbox flex={1}>
- <div {...stylex.props(styles.optionTitle)}>{t('chatMode.agent')}</div>
- <div {...stylex.props(styles.optionDesc)}>{agentDesc}</div>
- </Flexbox>
- </Flexbox>
-
- <Flexbox
- horizontal
- align="center"
- gap={12}
- className={
- stylex.props(styles.option, currentMode === 'chat' && styles.activeOption).className
- }
- onClick={() => handleSelect('chat')}
- >
- <Flexbox
- align="center"
- className={stylex.props(styles.optionIcon).className}
- height={32}
- justify="center"
- width={32}
- >
- <Icon icon={MessageCircleIcon} size={16} />
- </Flexbox>
- <Flexbox flex={1}>
- <div {...stylex.props(styles.optionTitle)}>{t('chatMode.chat')}</div>
- <div {...stylex.props(styles.optionDesc)}>{t('chatMode.chatDesc')}</div>
- </Flexbox>
- </Flexbox>
- </Flexbox>
- );
-
- const button = (
- <div {...stylex.props(styles.button, disabled && styles.buttonDisabled)}>
- <Icon icon={CurrentIcon} size={14} />
- <span>{t(`chatMode.${currentMode}`)}</span>
- <Icon icon={ChevronDownIcon} size={12} />
- </div>
- );
-
- // Hold the pill's footprint (~70x23 settled) instead of collapsing the left cluster.
- if (isPreferenceLoading) return <SkeletonBar height={22} radius={4} width={68} />;
-
- if (disabled)
- return (
- <Tooltip title={disabledReason}>
- <div>{button}</div>
- </Tooltip>
- );
-
- return (
- <Popover
- className={stylex.props(styles.popoverPopup).className}
- content={popoverContent}
- open={!disabled && open}
- placement="topLeft"
- trigger="click"
- styles={{
- // Match the inner viewport's corner to the enlarged popup radius so its
- // border corners don't poke through the rounded popup.
- content: {
- border: `1px solid ${cssVar.colorBorderSecondary}`,
- borderRadius: cssVar.borderRadiusLG,
- padding: 4,
- },
- }}
- onOpenChange={handleOpenChange}
- >
- <div>{open ? button : <Tooltip title={buttonTooltip}>{button}</Tooltip>}</div>
- </Popover>
- );
-});
-
-ModeSelector.displayName = 'ModeSelector';
-
-export default ModeSelector;
diff --git a/src/features/ChatInput/ControlBar/WorkspaceControls.tsx b/src/features/ChatInput/ControlBar/WorkspaceControls.tsx
index 1d5516ac4c1..51e3e8e9558 100644
--- a/src/features/ChatInput/ControlBar/WorkspaceControls.tsx
+++ b/src/features/ChatInput/ControlBar/WorkspaceControls.tsx
@@ -29,7 +29,7 @@ interface WorkspaceControlsProps {
*
* Both ControlBar (normal agents) and HeteroControlBar (heterogeneous agents)
* compose this, so the Device / Branch / diff / PR cluster can't drift between
- * them. The bar-specific bits (ModeSelector, ApprovalMode, ContextWindow, the
+ * them. The bar-specific bits (ApprovalMode, ContextWindow, the
* full-access badge) stay in their respective bars.
*/
const WorkspaceControls = memo<WorkspaceControlsProps>(
diff --git a/src/features/ChatInput/ControlBar/index.tsx b/src/features/ChatInput/ControlBar/index.tsx
index 002283ac97f..b0c366822d6 100644
--- a/src/features/ChatInput/ControlBar/index.tsx
+++ b/src/features/ChatInput/ControlBar/index.tsx
@@ -3,6 +3,7 @@ import * as stylex from '@stylexjs/stylex';
import { memo } from 'react';
import ChatInputCredits from '@/business/client/features/ChatInputCredits';
+import { useBusinessAgentModeSync } from '@/business/client/hooks/useBusinessAgentMode';
import { SkeletonBar } from '@/components/Skeleton';
import { useAgentStore } from '@/store/agent';
import { agentByIdSelectors } from '@/store/agent/selectors';
@@ -13,7 +14,6 @@ import { useChatInputResourceAccess } from '../hooks/useChatInputResourceAccess'
import { useEffectiveAgentMode } from '../hooks/useEffectiveAgentMode';
import { useChatInputStore } from '../store';
import ApprovalMode from './ApprovalMode';
-import ModeSelector from './ModeSelector';
import { resolveControlBarView } from './resolveControlBarView';
import WorkspaceControls from './WorkspaceControls';
@@ -21,7 +21,7 @@ const styles = stylex.create({
// `flex: none` keeps the row at 28px inside the column-flex composer; without
// it the bar shrinks to the compact chips' min-content height.
bar: { flex: 'none', height: '28px', paddingBlock: '0', paddingInline: '4px' },
- // Left cluster (mode + device + working directory + git) is the variable-width
+ // Left cluster (device + working directory + git) is the variable-width
// part. It shrinks first and, once its long labels have truncated as far as
// they can, scrolls horizontally instead of wrapping each chip's text. The
// scrollbar is hidden — trackpad / wheel still works.
@@ -43,10 +43,10 @@ interface ControlBarSkeletonProps {
}
/**
- * Same-height stand-in for the control bar: the 28px row with the mode pill on the
- * left and, when configured, the context-window pill pinned right. Pill sizes follow
- * the settled DOM (mode button ~70x23, context-window tag ~89x24), so the composer
- * does not move when the real controls replace it.
+ * Same-height stand-in for the control bar: the 28px row with, when configured,
+ * the context-window pill pinned right. The pill size follows the settled DOM
+ * (context-window tag ~89x24), so the composer does not move when the real
+ * controls replace it.
*/
export const ControlBarSkeleton = ({ showContextWindow }: ControlBarSkeletonProps) => (
<Flexbox
@@ -56,13 +56,16 @@ export const ControlBarSkeleton = ({ showContextWindow }: ControlBarSkeletonProp
className={stylex.props(styles.bar).className}
justify={'space-between'}
>
- <SkeletonBar height={22} radius={4} width={68} />
+ <div />
{showContextWindow && <SkeletonBar height={22} radius={4} width={88} />}
</Flexbox>
);
const ControlBar = memo(() => {
const agentId = useAgentId();
+ // The Agent/Chat switch lives in the advanced params panel now; the bar stays
+ // mounted with the composer, so it keeps the business mode sync alive.
+ useBusinessAgentModeSync(agentId);
const { canShowControls, isAccessLoading } = useChatInputResourceAccess();
const showContextWindow = useChatInputStore((s) =>
s.rightActions.flat().includes('contextWindow'),
@@ -89,14 +92,13 @@ const ControlBar = memo(() => {
className={stylex.props(styles.bar).className}
justify={'space-between'}
>
- {/* Left: chat-mode switcher + (agent-only) execution device + working directory */}
+ {/* Left: (agent-only) execution device + working directory */}
<Flexbox
horizontal
align={'center'}
className={stylex.props(styles.leftGroup).className}
gap={4}
>
- <ModeSelector />
{isAgentRuntimeMode && <WorkspaceControls agentId={agentId} />}
</Flexbox>