🤯 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.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🐛 fix(chat-input): remove sandbox input notice (#16865)
AmAzing-2b44c2c8fdef
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.jsonindex b642a8fc674..d339e989ea2 100644--- a/locales/en-US/chat.json+++ b/locales/en-US/chat.json@@ -382,12 +382,10 @@"input.inputCompletionError.title": "Input suggestions paused","input.modelUnavailable": "The current model is no longer available. Choose another model to continue.","input.more": "More",- "input.sandboxModeNotice": "Running in a temporary Cloud Sandbox. Local runs are faster and can access your files.","input.send": "Send","input.sendWithCmdEnter": "Press <key/> to send","input.sendWithEnter": "Press <key/> to send","input.stop": "Stop",- "input.switchToLocal": "Use local machine","input.warp": "New Line","input.warpWithKey": "Press <key/> to insert a line break","inputQueue.delete": "Delete",diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.jsonindex d3b1fd88428..792d2121b3d 100644--- a/locales/zh-CN/chat.json+++ b/locales/zh-CN/chat.json@@ -382,12 +382,10 @@"input.inputCompletionError.title": "输入补全已暂停","input.modelUnavailable": "当前模型已下线。请选择其他模型后继续使用。","input.more": "更多",- "input.sandboxModeNotice": "正在使用临时云端沙箱,本机运行更快且可访问本地文件。","input.send": "发送","input.sendWithCmdEnter": "按 <key/> 发送","input.sendWithEnter": "按 <key/> 发送","input.stop": "停止",- "input.switchToLocal": "切换到本机","input.warp": "换行","input.warpWithKey": "按 <key/> 换行","inputQueue.delete": "删除",diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.tsindex 73aa84067e3..fcf7c431b37 100644--- a/packages/locales/src/default/chat.ts+++ b/packages/locales/src/default/chat.ts@@ -313,13 +313,10 @@ export default {'input.modelUnavailable':'The current model is no longer available. Choose another model to continue.','input.more': 'More',- 'input.sandboxModeNotice':- 'Running in a temporary Cloud Sandbox. Local runs are faster and can access your files.','input.send': 'Send','input.sendWithCmdEnter': 'Press <key/> to send','input.sendWithEnter': 'Press <key/> to send','input.stop': 'Stop',- 'input.switchToLocal': 'Use local machine','input.warp': 'New Line','input.warpWithKey': 'Press <key/> to insert a line break','inputQueue.delete': 'Delete',diff --git a/src/features/ChatInput/ChatInputNotice/index.tsx b/src/features/ChatInput/ChatInputNotice/index.tsxindex 4a865d7ca2f..7e7f6879990 100644--- a/src/features/ChatInput/ChatInputNotice/index.tsx+++ b/src/features/ChatInput/ChatInputNotice/index.tsx@@ -1,33 +1,17 @@'use client';import { Alert } from '@lobehub/ui';-import { Button } from '@lobehub/ui/base-ui';import { createStaticStyles, cx } from 'antd-style';-import { memo, useState } from 'react';+import { memo } from 'react';import { useTranslation } from 'react-i18next';-import { useAgentId } from '@/features/ChatInput/hooks/useAgentId';-import { useSelectExecutionTarget } from '@/features/ChatInput/hooks/useSelectExecutionTarget';-import { useChatInputNotice } from './useChatInputNotice';const styles = createStaticStyles(({ css }) => ({alert: css`- /* @lobehub/ui's root style sets align-items: flex-start, top-aligning the- * action button against the (shorter) icon+text row instead of centering- * it. */+ /* Keep the icon centered against the single-line title. */align-items: center !important;- /* Antd's alert section defaults to flex: 1, stretching to fill all- * leftover width and pushing the action button to the far edge. Shrink- * it to content so the action sits right next to the message. */- .ant-alert-section {- flex: 0 1 auto !important;- }-- /* The rendered title class is .ant-alert-title (not .ant-alert-message,- * which this version of antd no longer emits) — matching line-height to- * the icon's forced height keeps them vertically aligned. */.ant-alert-title {font-size: 12px;line-height: 18px !important;@@ -39,32 +23,6 @@ const styles = createStaticStyles(({ css }) => ({`,}));-const SwitchToLocalAction = memo(() => {- const { t } = useTranslation('chat');- const agentId = useAgentId();- const selectExecutionTarget = useSelectExecutionTarget(agentId);- const [loading, setLoading] = useState(false);-- const handleClick = async () => {- setLoading(true);- try {- await selectExecutionTarget('local');- } finally {- // The notice unmounts once the target switches; guard in case it doesn't- // (e.g. a hetero agent with no resolvable local device).- setLoading(false);- }- };-- return (- <Button loading={loading} size={'small'} type={'primary'} onClick={handleClick}>- {t('input.switchToLocal')}- </Button>- );-});--SwitchToLocalAction.displayName = 'SwitchToLocalAction';-const ChatInputNotice = memo(() => {const { t } = useTranslation('chat');const notice = useChatInputNotice();@@ -73,7 +31,6 @@ const ChatInputNotice = memo(() => {return (<Alert- action={notice.action === 'switchToLocal' ? <SwitchToLocalAction /> : undefined}classNames={{ alert: cx(styles.alert) }}style={{ fontSize: 12 }}title={t(notice.key)}diff --git a/src/features/ChatInput/ChatInputNotice/useChatInputNotice.test.tsx b/src/features/ChatInput/ChatInputNotice/useChatInputNotice.test.tsxindex 67bb89ee3b2..9902d24b90e 100644--- a/src/features/ChatInput/ChatInputNotice/useChatInputNotice.test.tsx+++ b/src/features/ChatInput/ChatInputNotice/useChatInputNotice.test.tsx@@ -134,7 +134,7 @@ describe('useChatInputNotice', () => {expect(result.current).toBeUndefined();});- it('returns the sandbox tip on desktop when the cloud sandbox is selected', () => {+ it('does not show an input notice when the cloud sandbox is selected', () => {testState.isDesktop = true;testState.agent.agencyConfig = { executionTarget: 'sandbox' };testState.aiInfra.isInitAiProviderRuntimeState = true;@@ -144,11 +144,7 @@ describe('useChatInputNotice', () => {const { result } = renderHook(() => useChatInputNotice());- expect(result.current).toEqual({- action: 'switchToLocal',- key: 'input.sandboxModeNotice',- type: 'info',- });+ expect(result.current).toBeUndefined();});it('does not return the sandbox tip off desktop even when the sandbox is selected', () => {@@ -164,7 +160,7 @@ describe('useChatInputNotice', () => {expect(result.current).toBeUndefined();});- it('shows the sandbox tip for heterogeneous agents that selected the sandbox', () => {+ it('does not show an input notice for heterogeneous agents that selected the sandbox', () => {testState.isDesktop = true;testState.agent.agencyConfig = {executionTarget: 'sandbox',@@ -174,14 +170,10 @@ describe('useChatInputNotice', () => {const { result } = renderHook(() => useChatInputNotice());- expect(result.current).toEqual({- action: 'switchToLocal',- key: 'input.sandboxModeNotice',- type: 'info',- });+ expect(result.current).toBeUndefined();});- it('prioritizes the model warning over the sandbox tip when both apply', () => {+ it('returns the model warning when a sandbox target also has an unavailable model', () => {testState.isDesktop = true;testState.agent.agencyConfig = { executionTarget: 'sandbox' };testState.aiInfra.isInitAiProviderRuntimeState = true;diff --git a/src/features/ChatInput/ChatInputNotice/useChatInputNotice.ts b/src/features/ChatInput/ChatInputNotice/useChatInputNotice.tsindex b48e4467116..0c254583a4d 100644--- a/src/features/ChatInput/ChatInputNotice/useChatInputNotice.ts+++ b/src/features/ChatInput/ChatInputNotice/useChatInputNotice.ts@@ -1,7 +1,4 @@-import { isDesktop } from '@lobechat/const';-import { useAgentId } from '@/features/ChatInput/hooks/useAgentId';-import { resolveExecutionTarget } from '@/helpers/executionTarget';import { useEnabledChatModels } from '@/hooks/useEnabledChatModels';import { useAgentStore } from '@/store/agent';import { agentByIdSelectors } from '@/store/agent/selectors';@@ -12,8 +9,6 @@ interface ResolveChatInputNoticeParams {currentChatModel?: unknown;isHeterogeneousAgent: boolean;isModelConfigReady: boolean;- /** Desktop has selected the ephemeral cloud sandbox as the execution target. */- isSandboxTarget: boolean;}const findEnabledChatModel = (@@ -30,12 +25,9 @@ export const resolveChatInputNotice = ({currentChatModel,isHeterogeneousAgent,isModelConfigReady,- isSandboxTarget,}: ResolveChatInputNoticeParams) => {- // Model-config notices (warning) take priority over the sandbox tip (info):- // an unusable model blocks the send, the sandbox is only a softer suggestion.- // They don't apply to heterogeneous agents (own toolchain) or before the- // model runtime config is ready.+ // Model-config notices don't apply to heterogeneous agents (own toolchain) or+ // before the model runtime config is ready.if (!isHeterogeneousAgent &&isModelConfigReady && // Example: an agent still references `gpt-4-32k`, or a model reclassified to@@ -43,13 +35,6 @@ export const resolveChatInputNotice = ({!currentChatModel)return { action: undefined, key: 'input.modelUnavailable', type: 'warning' } as const;-- // Sandbox is an ephemeral environment; nudge desktop users toward a device- // (e.g. local) for a better experience. Applies to hetero agents too, so it- // sits outside the model-notice guard above. `action: 'switchToLocal'`- // re-targets execution to this machine.- if (isSandboxTarget)- return { action: 'switchToLocal', key: 'input.sandboxModeNotice', type: 'info' } as const;};/** Union of every notice shape `resolveChatInputNotice` can return. */@@ -58,11 +43,10 @@ export type ChatInputNotice = NonNullable<ReturnType<typeof resolveChatInputNotiexport const useChatInputNotice = (): ChatInputNotice | undefined => {const agentId = useAgentId();- const [isHeterogeneousAgent, model, provider, agencyConfig] = useAgentStore((s) => [+ const [isHeterogeneousAgent, model, provider] = useAgentStore((s) => [agentByIdSelectors.isAgentHeterogeneousById(agentId)(s),agentByIdSelectors.getAgentModelById(agentId)(s),agentByIdSelectors.getAgentModelProviderById(agentId)(s),- agentByIdSelectors.getAgencyConfigById(agentId)(s),]);const enabledChatModelList = useEnabledChatModels();@@ -71,20 +55,9 @@ export const useChatInputNotice = (): ChatInputNotice | undefined => {);const currentChatModel = findEnabledChatModel(enabledChatModelList, model, provider);- // The sandbox suggestion only makes sense on desktop, where `local` is the- // recommended alternative. `clientExecutionAvailable: isDesktop` matches how- // HeteroDeviceSwitcher resolves the effective target for the chip.- const isSandboxTarget =- isDesktop &&- resolveExecutionTarget(agencyConfig, {- clientExecutionAvailable: isDesktop,- isHetero: isHeterogeneousAgent,- }) === 'sandbox';-return resolveChatInputNotice({currentChatModel,isHeterogeneousAgent,isModelConfigReady,- isSandboxTarget,});};