🤯 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(local-file): merge file actions into one segmented bar and reveal the file in Finder (#19263)
Inneieffd8ed0e058
diff --git a/apps/desktop/src/main/controllers/LocalFileCtr.ts b/apps/desktop/src/main/controllers/LocalFileCtr.tsindex a581d7eac3d..d95fef62423 100644--- a/apps/desktop/src/main/controllers/LocalFileCtr.ts+++ b/apps/desktop/src/main/controllers/LocalFileCtr.ts@@ -292,19 +292,18 @@ export default class LocalFileCtr extends ControllerModule {success: boolean;}> {const resolvedTarget = expandTilde(targetPath) ?? targetPath;- const folderPath = isDirectory ? resolvedTarget : path.dirname(resolvedTarget);- logger.debug('Attempting to open folder:', {- folderPath,- isDirectory,- targetPath: resolvedTarget,- });+ logger.debug('Attempting to open folder:', { isDirectory, targetPath: resolvedTarget });try {- await shell.openPath(folderPath);- logger.debug('Folder opened successfully:', { folderPath });+ if (isDirectory) {+ await shell.openPath(resolvedTarget);+ } else {+ shell.showItemInFolder(resolvedTarget);+ }+ logger.debug('Folder opened successfully:', { targetPath: resolvedTarget });return { success: true };} catch (error) {- logger.error(`Failed to open folder ${folderPath}:`, error);+ logger.error(`Failed to open folder for ${resolvedTarget}:`, error);return { error: (error as Error).message, success: false };}}diff --git a/apps/desktop/src/main/controllers/__tests__/LocalFileCtr.test.ts b/apps/desktop/src/main/controllers/__tests__/LocalFileCtr.test.tsindex 18e4a2199d5..e4ba87bc23e 100644--- a/apps/desktop/src/main/controllers/__tests__/LocalFileCtr.test.ts+++ b/apps/desktop/src/main/controllers/__tests__/LocalFileCtr.test.ts@@ -34,6 +34,7 @@ vi.mock('electron', () => ({},shell: {openPath: vi.fn(),+ showItemInFolder: vi.fn(),},}));@@ -174,16 +175,29 @@ describe('LocalFileCtr', () => {expect(mockShell.openPath).toHaveBeenCalledWith(path.join(os.homedir(), 'git/work'));});- it('should open parent directory when isDirectory is false', async () => {- vi.mocked(mockShell.openPath).mockResolvedValue('');-+ it('should reveal and select the file when isDirectory is false', async () => {const result = await localFileCtr.handleOpenLocalFolder({path: '/test/folder/file.txt',isDirectory: false,});expect(result).toEqual({ success: true });- expect(mockShell.openPath).toHaveBeenCalledWith('/test/folder');+ expect(mockShell.showItemInFolder).toHaveBeenCalledWith('/test/folder/file.txt');+ expect(mockShell.openPath).not.toHaveBeenCalled();+ });++ it('should expand a leading ~ when revealing a file', async () => {+ const os = await import('node:os');++ const result = await localFileCtr.handleOpenLocalFolder({+ path: '~/git/work/file.txt',+ isDirectory: false,+ });++ expect(result).toEqual({ success: true });+ expect(mockShell.showItemInFolder).toHaveBeenCalledWith(+ path.join(os.homedir(), 'git/work/file.txt'),+ );});it('should return error when opening folder fails', async () => {diff --git a/src/features/LocalFile/LocalFile.tsx b/src/features/LocalFile/LocalFile.tsxindex 9338d4ec3a4..01b0324a7b0 100644--- a/src/features/LocalFile/LocalFile.tsx+++ b/src/features/LocalFile/LocalFile.tsx@@ -1,5 +1,4 @@import { Flexbox, Popover } from '@lobehub/ui';-import { Button } from '@lobehub/ui/base-ui';import { createStaticStyles, cssVar } from 'antd-style';import { ExternalLink, EyeIcon, FolderOpen } from 'lucide-react';import React from 'react';@@ -29,6 +28,61 @@ const styles = createStaticStyles(({ css }) => ({outline-offset: 1px;}`,+ segment: css`+ cursor: pointer;++ position: relative;++ display: inline-flex;+ gap: 6px;+ align-items: center;++ padding-block: 5px;+ padding-inline: 11px;+ border: none;++ font-family: inherit;+ font-size: 13px;+ line-height: 20px;+ color: ${cssVar.colorTextSecondary};+ white-space: nowrap;++ background: transparent;++ & + &::before {+ content: '';++ position: absolute;+ inset-block: 5px;+ inset-inline-start: 0;++ width: 1px;++ background: ${cssVar.colorBorderSecondary};+ }++ &:hover {+ color: ${cssVar.colorText};+ background: ${cssVar.colorFillTertiary};+ }++ &:hover::before,+ &:hover + &::before {+ background: transparent;+ }++ &:focus-visible {+ border-radius: 6px;+ outline: 2px solid ${cssVar.colorPrimaryBorder};+ outline-offset: -2px;+ }+ `,+ segmented: css`+ overflow: hidden;+ display: inline-flex;+ align-items: stretch;+ border-radius: ${cssVar.borderRadiusLG};+ `,title: css`overflow: hidden;display: block;@@ -97,34 +151,22 @@ export const LocalFile = ({// File: show popover with actionsconst popoverContent = (- <Flexbox horizontal gap={4} padding={4}>+ <div className={styles.segmented}>{canPreview && (- <Button- icon={EyeIcon}- size="small"- title={t('LocalFile.action.preview')}- onClick={handlePreview}- >+ <button className={styles.segment} type={'button'} onClick={handlePreview}>+ <EyeIcon size={15} />{t('LocalFile.action.preview')}- </Button>+ </button>)}- <Button- icon={ExternalLink}- size="small"- title={t('LocalFile.action.open')}- onClick={handleOpenFile}- >+ <button className={styles.segment} type={'button'} onClick={handleOpenFile}>+ <ExternalLink size={15} />{t('LocalFile.action.open')}- </Button>- <Button- icon={FolderOpen}- size="small"- title={t('LocalFile.action.showInFolder')}- onClick={handleOpenFolder}- >+ </button>+ <button className={styles.segment} type={'button'} onClick={handleOpenFolder}>+ <FolderOpen size={15} />{t('LocalFile.action.showInFolder')}- </Button>- </Flexbox>+ </button>+ </div>);return (