π€― 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
π style(chat-input): show the project environment as one device chip with full paths (#20837)
Arvin Xu3c5949594e7f
diff --git a/src/features/ChatInput/ControlBar/ProjectDeviceSwitcher.tsx b/src/features/ChatInput/ControlBar/ProjectDeviceSwitcher.tsxindex 99d07465b3a..bf17502e7d0 100644--- a/src/features/ChatInput/ControlBar/ProjectDeviceSwitcher.tsx+++ b/src/features/ChatInput/ControlBar/ProjectDeviceSwitcher.tsx@@ -1,6 +1,6 @@'use client';-import { Flexbox, Icon, Popover } from '@lobehub/ui';+import { Flexbox, Icon, Popover, Tooltip } from '@lobehub/ui';import { confirmModal, toast } from '@lobehub/ui/base-ui';import { createStaticStyles, cssVar } from 'antd-style';import { ChevronDownIcon } from 'lucide-react';@@ -21,11 +21,11 @@ import { useProjectTopicDirectory } from './useProjectTopicDirectory';import { workingDirectoryChipStyles } from './workingDirectoryChipStyles';const styles = createStaticStyles(({ css }) => ({+ // Picking a device here really picks an environment, and the path is what+ // tells them apart, so it wraps in full instead of truncating.desc: css`- overflow: hidden;- max-width: 200px;- text-overflow: ellipsis;- white-space: nowrap;+ min-width: 0;+ overflow-wrap: anywhere;`,hint: css`padding-block: 6px;@@ -33,6 +33,10 @@ const styles = createStaticStyles(({ css }) => ({font-size: 11px;color: ${cssVar.colorTextDescription};`,+ status: css`+ flex: none;+ white-space: nowrap;+ `,title: css`padding-block: 4px;padding-inline: 8px;@@ -54,7 +58,9 @@ interface ProjectDeviceSwitcherProps {* The directory belongs to the project, so the only choice left is which* device to run on β and each device brings the project's own directory there.* Only devices the project has a directory on are offered; picking one moves- * the conversation to that directory rather than to an arbitrary path.+ * the conversation to that directory rather than to an arbitrary path. The+ * directory itself has no chip of its own; its path rides on this trigger's+ * tooltip.*/const ProjectDeviceSwitcher = ({ agentId, topicId }: ProjectDeviceSwitcherProps) => {const { t } = useTranslation('chat');@@ -99,7 +105,7 @@ const ProjectDeviceSwitcher = ({ agentId, topicId }: ProjectDeviceSwitcherProps)};const content = (- <Flexbox style={{ maxWidth: 320, minWidth: 280 }}>+ <Flexbox style={{ maxWidth: 400, minWidth: 280 }}><div className={styles.title}>{t('heteroAgent.executionTarget.title')}</div>{targets.map((target) => {const selectable = target.online && target.allowed;@@ -114,11 +120,13 @@ const ProjectDeviceSwitcher = ({ agentId, topicId }: ProjectDeviceSwitcherProps)target.allowed ? (<><span className={styles.desc}>{target.directory.path}</span>- <ExecutionTargetDeviceStatus- offlineLabel={t('heteroAgent.executionTarget.offline')}- online={target.online}- onlineLabel={t('heteroAgent.executionTarget.online')}- />+ <span className={styles.status}>+ <ExecutionTargetDeviceStatus+ offlineLabel={t('heteroAgent.executionTarget.offline')}+ online={target.online}+ onlineLabel={t('heteroAgent.executionTarget.online')}+ />+ </span></>) : (<span className={styles.desc}>{t('heteroAgent.executionTarget.fixedTip')}</span>@@ -135,6 +143,18 @@ const ProjectDeviceSwitcher = ({ agentId, topicId }: ProjectDeviceSwitcherProps)</Flexbox>);+ const trigger = (+ <div className={workingDirectoryChipStyles.chip}>+ <ExecutionTargetIcon devicePlatform={directory?.platform} target={'device'} />+ <span className={workingDirectoryChipStyles.label}>+ {directory+ ? projectDirectoryDeviceName(directory, devices)+ : t('heteroAgent.executionTarget.unknownDevice')}+ </span>+ <Icon icon={ChevronDownIcon} size={12} />+ </div>+ );+return (<Popovercontent={content}@@ -144,14 +164,14 @@ const ProjectDeviceSwitcher = ({ agentId, topicId }: ProjectDeviceSwitcherProps)trigger="click"onOpenChange={setOpen}>- <div className={workingDirectoryChipStyles.chip}>- <ExecutionTargetIcon devicePlatform={directory?.platform} target={'device'} />- <span className={workingDirectoryChipStyles.label}>- {directory- ? projectDirectoryDeviceName(directory, devices)- : t('heteroAgent.executionTarget.unknownDevice')}- </span>- <Icon icon={ChevronDownIcon} size={12} />+ <div>+ {open || !directory ? (+ trigger+ ) : (+ <Tooltip title={t('directories.boundTip', { ns: 'project', path: directory.path })}>+ {trigger}+ </Tooltip>+ )}</div></Popover>);diff --git a/src/features/ChatInput/ControlBar/ProjectDirectoryChip.tsx b/src/features/ChatInput/ControlBar/ProjectDirectoryChip.tsxdeleted file mode 100644index 22fa1100bce..00000000000--- a/src/features/ChatInput/ControlBar/ProjectDirectoryChip.tsx+++ /dev/null@@ -1,36 +0,0 @@-'use client';--import { Tooltip } from '@lobehub/ui';-import { cx } from 'antd-style';-import { useTranslation } from 'react-i18next';--import DirIcon from './DirIcon';-import { useProjectTopicDirectory } from './useProjectTopicDirectory';-import { workingDirectoryChipStyles } from './workingDirectoryChipStyles';--interface ProjectDirectoryChipProps {- topicId: string;-}--/**- * The working directory of a project-directory conversation. It belongs to the- * project, so it is shown but not picked here β switching devices- * (`ProjectDeviceSwitcher`) is what moves the conversation to the project's- * directory on another machine.- */-const ProjectDirectoryChip = ({ topicId }: ProjectDirectoryChipProps) => {- const { t } = useTranslation('project');- const { directory } = useProjectTopicDirectory(topicId);- if (!directory) return null;-- return (- <Tooltip title={t('directories.boundTip', { path: directory.path })}>- <div className={cx(workingDirectoryChipStyles.chip, workingDirectoryChipStyles.readonly)}>- <DirIcon />- <span className={workingDirectoryChipStyles.label}>{directory.name}</span>- </div>- </Tooltip>- );-};--export default ProjectDirectoryChip;diff --git a/src/features/ChatInput/ControlBar/WorkingDirectorySection.tsx b/src/features/ChatInput/ControlBar/WorkingDirectorySection.tsxindex 490bd81ca25..3503b43daf1 100644--- a/src/features/ChatInput/ControlBar/WorkingDirectorySection.tsx+++ b/src/features/ChatInput/ControlBar/WorkingDirectorySection.tsx@@ -16,7 +16,6 @@ import { deviceSelectors, useDeviceStore } from '@/store/device';import { useElectronStore } from '@/store/electron';import GitStatus from './GitStatus';-import ProjectDirectoryChip from './ProjectDirectoryChip';import { useActiveProjectDirectoryTopicId } from './useProjectTopicDirectory';import { useRepoType } from './useRepoType';import WorkingDirectoryPicker from './WorkingDirectoryPicker';@@ -61,7 +60,8 @@ const WorkingDirectorySectionInner = memo<WorkingDirectorySectionProps>(({ agentconst topicWorkingDirectoryConfig = useChatStore((s) => topicSelectors.currentTopicMetadata(s)?.workingDirectoryConfig,);- // The project owns this conversation's directory; it is shown, not picked.+ // The project owns this conversation's directory and the device switcher+ // already names it, so there is nothing to pick or show here.const projectTopicId = useActiveProjectDirectoryTopicId();// Only trust the persisted config when it actually describes the directory we// resolved β the topic override wins in `useEffectiveWorkingDirectory`, so this@@ -98,11 +98,7 @@ const WorkingDirectorySectionInner = memo<WorkingDirectorySectionProps>(({ agentreturn (<>- {projectTopicId ? (- <ProjectDirectoryChip topicId={projectTopicId} />- ) : (- <WorkingDirectoryPicker agentId={agentId} />- )}+ {!projectTopicId && <WorkingDirectoryPicker agentId={agentId} />}{effectiveWorkingDirectory && repoType && (<GitStatusagentId={agentId}