🤯 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(channel): distinguish device environment validation failures (#21863)
AmAzing-adb630f9102c
diff --git a/apps/server/src/services/channel/ChannelService.environment.test.ts b/apps/server/src/services/channel/ChannelService.environment.test.tsindex f3e9a6a1791..04e4f6e4c59 100644--- a/apps/server/src/services/channel/ChannelService.environment.test.ts+++ b/apps/server/src/services/channel/ChannelService.environment.test.ts@@ -65,6 +65,45 @@ describe('changing an Agent member’s channel environment', () => {});const service = () => new ChannelService({} as never, 'owner');+ describe.each(['create', 'update'] as const)('%s directory validation', (action) => {+ it.each([+ {+ message: 'Could not reach the device to verify the working directory',+ name: 'unreachable device',+ result: undefined,+ },+ {+ message: 'The working directory does not exist or is not a directory',+ name: 'missing directory',+ result: { exists: false, isDirectory: false },+ },+ {+ message: 'The working directory does not exist or is not a directory',+ name: 'file instead of a directory',+ result: { exists: true, isDirectory: false },+ },+ {+ message: 'The device connector must be upgraded to verify the working directory',+ name: 'legacy connector with an existing directory',+ result: { exists: true, isDirectory: true, repoType: 'github' },+ },+ ])('reports $name without saving the environment', async ({ message, result }) => {+ statPath.mockResolvedValue(result);+ const input = { agentId: 'agent-1', deviceId: 'mac', workingDirectory: '/b' };++ const save =+ action === 'create'+ ? service().create({ agents: [input], title: 'c' })+ : service().updateAgentEnvironment('channel', 'member-1', input);++ await expect(save).rejects.toMatchObject({ code: 'BAD_REQUEST', message });+ expect(create).not.toHaveBeenCalled();+ expect(update).not.toHaveBeenCalled();+ expect(wake).not.toHaveBeenCalled();+ expect(notify).not.toHaveBeenCalled();+ });+ });+it('validates the new directory on the device and stores its canonical path', async () => {await service().updateAgentEnvironment('channel', 'member-1', {deviceId: 'mac',diff --git a/apps/server/src/services/channel/ChannelService.ts b/apps/server/src/services/channel/ChannelService.tsindex 0c363541cae..a3e13d4f040 100644--- a/apps/server/src/services/channel/ChannelService.ts+++ b/apps/server/src/services/channel/ChannelService.ts@@ -84,10 +84,20 @@ export class ChannelService {userId: this.userId,workspaceId: this.workspaceId,});- if (!path?.isDirectory || !path.canonicalPath)+ if (!path)throw new ChannelError('BAD_REQUEST',- 'The device must be online and support directory verification',+ 'Could not reach the device to verify the working directory',+ );+ if (!path.isDirectory)+ throw new ChannelError(+ 'BAD_REQUEST',+ 'The working directory does not exist or is not a directory',+ );+ if (!path.canonicalPath)+ throw new ChannelError(+ 'BAD_REQUEST',+ 'The device connector must be upgraded to verify the working directory',);config.deviceId = device.deviceId;config.deviceOwnerId = device.userId;diff --git a/locales/en-US/channel.json b/locales/en-US/channel.jsonindex a2a57992dd2..985f7a08b45 100644--- a/locales/en-US/channel.json+++ b/locales/en-US/channel.json@@ -50,13 +50,15 @@"environment.chooseDevice": "Choose a device","environment.configurationFailed": "Could not load this Agent’s settings. Try again.","environment.configurationLoading": "Loading this Agent’s settings…",- "environment.defaultsHint": "Each Agent uses its own device and working directory. You can change them for this channel later from the member list.",+ "environment.connectorUpgradeRequired": "This device’s LobeHub connector needs an update. Update LobeHub Desktop or the LobeHub CLI on that device, then reconnect and try again.","environment.deviceLabel": "Device for {{name}}","environment.deviceOffline": "This device is offline. Reconnect it or choose another device.","environment.deviceRequired": "Choose an online device for this coding Agent.","environment.deviceUnavailable": "This device is unavailable in the current space. Choose an accessible device.",+ "environment.deviceUnreachable": "Could not connect to the device to check the working directory. Check the device connection and try again.","environment.devicesFailed": "Could not confirm device status. Refresh the device list and try again.","environment.devicesLoading": "Checking device status…",+ "environment.directoryInvalid": "The working directory does not exist or is not a folder on this device. Update the working directory and try again.","environment.directoryLabel": "Working directory for {{name}}","environment.directoryRequired": "Choose a working directory on this device.","environment.directoryUnavailable": "Could not verify the directory. Check the device connection and choose the directory again.",diff --git a/locales/zh-CN/channel.json b/locales/zh-CN/channel.jsonindex 9aaf90cc4ad..e27d7af78f1 100644--- a/locales/zh-CN/channel.json+++ b/locales/zh-CN/channel.json@@ -50,13 +50,15 @@"environment.chooseDevice": "选择设备","environment.configurationFailed": "未能读取此 Agent 的配置,请重试。","environment.configurationLoading": "正在读取 Agent 配置…",- "environment.defaultsHint": "默认沿用各 Agent 自己的设备和工作目录,之后可在成员列表里为本频道单独修改。",+ "environment.connectorUpgradeRequired": "设备连接器需升级。请更新目标设备上的 LobeHub 桌面端或 LobeHub CLI,重新连接后重试。","environment.deviceLabel": "{{name}} 的设备","environment.deviceOffline": "此设备已离线,请重新连接或选择其他设备。","environment.deviceRequired": "请为此编程 Agent 选择在线设备。","environment.deviceUnavailable": "当前空间无法使用此设备,请选择有权限访问的设备。",+ "environment.deviceUnreachable": "无法连接设备以验证工作目录,请检查设备连接后重试。","environment.devicesFailed": "未能确认设备状态,请刷新设备列表后重试。","environment.devicesLoading": "正在确认设备状态…",+ "environment.directoryInvalid": "工作目录不存在或不是文件夹,请修改工作目录后重试。","environment.directoryLabel": "{{name}} 的工作目录","environment.directoryRequired": "请选择此设备上的工作目录。","environment.directoryUnavailable": "无法验证工作目录,请检查设备连接并重新选择目录。",diff --git a/packages/locales/src/default/channel.ts b/packages/locales/src/default/channel.tsindex 177b4d4ef72..9b327fd12d0 100644--- a/packages/locales/src/default/channel.ts+++ b/packages/locales/src/default/channel.ts@@ -23,17 +23,21 @@ export default {'environment.chooseDevice': 'Choose a device','environment.configurationFailed': 'Could not load this Agent’s settings. Try again.','environment.configurationLoading': 'Loading this Agent’s settings…',- 'environment.defaultsHint':- 'Each Agent uses its own device and working directory. You can change them for this channel later from the member list.',+ 'environment.connectorUpgradeRequired':+ 'This device’s LobeHub connector needs an update. Update LobeHub Desktop or the LobeHub CLI on that device, then reconnect and try again.','environment.deviceLabel': 'Device for {{name}}','environment.deviceOffline': 'This device is offline. Reconnect it or choose another device.','environment.deviceRequired': 'Choose an online device for this coding Agent.',+ 'environment.deviceUnreachable':+ 'Could not connect to the device to check the working directory. Check the device connection and try again.','environment.deviceUnavailable':'This device is unavailable in the current space. Choose an accessible device.','environment.devicesFailed':'Could not confirm device status. Refresh the device list and try again.','environment.devicesLoading': 'Checking device status…','environment.directoryLabel': 'Working directory for {{name}}',+ 'environment.directoryInvalid':+ 'The working directory does not exist or is not a folder on this device. Update the working directory and try again.','environment.directoryRequired': 'Choose a working directory on this device.','environment.inherited.deviceOffline':'This Agent’s device is offline. Reconnect the device, or remove the Agent.',diff --git a/src/features/Channels/CreateChannel/MemberSelection.tsx b/src/features/Channels/CreateChannel/MemberSelection.tsxindex 92ed6645738..4c68724a68e 100644--- a/src/features/Channels/CreateChannel/MemberSelection.tsx+++ b/src/features/Channels/CreateChannel/MemberSelection.tsx@@ -170,9 +170,6 @@ export const MemberSelection = ({</Flexbox></div></AsyncBoundary>- <Text fontSize={12} type="secondary">- {t('environment.defaultsHint')}- </Text></Flexbox>);};diff --git a/src/features/Channels/CreateChannel/saveError.test.ts b/src/features/Channels/CreateChannel/saveError.test.tsindex 16056ad12e4..4d4048fc88c 100644--- a/src/features/Channels/CreateChannel/saveError.test.ts+++ b/src/features/Channels/CreateChannel/saveError.test.ts@@ -7,6 +7,12 @@ describe('channel member save feedback', () => {['Choose an online device and working directory', 'environment.executionRequired'],['Choose a working directory for this device', 'environment.directoryRequired'],['Choose an accessible device shared with this workspace', 'environment.deviceUnavailable'],+ ['Could not reach the device to verify the working directory', 'environment.deviceUnreachable'],+ ['The working directory does not exist or is not a directory', 'environment.directoryInvalid'],+ [+ 'The device connector must be upgraded to verify the working directory',+ 'environment.connectorUpgradeRequired',+ ],['The device must be online and support directory verification','environment.directoryUnavailable',diff --git a/src/features/Channels/CreateChannel/saveError.ts b/src/features/Channels/CreateChannel/saveError.tsindex 48652d9606c..4fdbfb65086 100644--- a/src/features/Channels/CreateChannel/saveError.ts+++ b/src/features/Channels/CreateChannel/saveError.ts@@ -13,6 +13,15 @@ export const getChannelSaveErrorKey = (error: unknown) => {case 'Choose an accessible device shared with this workspace': {return 'environment.deviceUnavailable';}+ case 'Could not reach the device to verify the working directory': {+ return 'environment.deviceUnreachable';+ }+ case 'The working directory does not exist or is not a directory': {+ return 'environment.directoryInvalid';+ }+ case 'The device connector must be upgraded to verify the working directory': {+ return 'environment.connectorUpgradeRequired';+ }case 'The device must be online and support directory verification': {return 'environment.directoryUnavailable';}