🤯 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(working-sidebar): switch file views with icon buttons (#21427)
AmAzing-1b76cc01d598
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.jsonindex 58f13a74432..5768964ae36 100644--- a/locales/en-US/chat.json+++ b/locales/en-US/chat.json@@ -3206,7 +3206,6 @@"workingPanel.files.validation.whitespace": "Names can't start or end with a space","workingPanel.files.views.changes": "Git Changes","workingPanel.files.views.project": "Project",- "workingPanel.files.views.title": "File View","workingPanel.goal.collapse": "Show less","workingPanel.goal.decision": "{{count}} decisions pending","workingPanel.goal.more": "{{count}} more",diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.jsonindex f91699b4f4a..8588a83317c 100644--- a/locales/zh-CN/chat.json+++ b/locales/zh-CN/chat.json@@ -3206,7 +3206,6 @@"workingPanel.files.validation.whitespace": "名称首尾不能有空格","workingPanel.files.views.changes": "Git 变更","workingPanel.files.views.project": "项目",- "workingPanel.files.views.title": "文件视图","workingPanel.goal.collapse": "收起","workingPanel.goal.decision": "{{count}} 个决策待处理","workingPanel.goal.more": "还有 {{count}} 个",diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.tsindex 6585211a8e4..9d30444c282 100644--- a/packages/locales/src/default/chat.ts+++ b/packages/locales/src/default/chat.ts@@ -3814,7 +3814,6 @@ export default {'Some expanded folders are too large to list fully — only the first entries are shown','workingPanel.files.views.changes': 'Git Changes','workingPanel.files.views.project': 'Project',- 'workingPanel.files.views.title': 'File View','workingPanel.pr.action.arming': 'Arming auto-merge…','workingPanel.pr.action.autoMerge': 'Auto-merge when ready','workingPanel.pr.action.bypassSuffix': 'bypass rules',diff --git a/src/features/Conversation/WorkingSidebar/Files/__tests__/harness.tsx b/src/features/Conversation/WorkingSidebar/Files/__tests__/harness.tsxindex 3e2d3b594b4..52be30292e5 100644--- a/src/features/Conversation/WorkingSidebar/Files/__tests__/harness.tsx+++ b/src/features/Conversation/WorkingSidebar/Files/__tests__/harness.tsx@@ -2,7 +2,7 @@// `../index` so the module mocks are registered before the pane loads.import { fireEvent, screen } from '@testing-library/react';-import type { ReactNode as ReactNodeType, Ref } from 'react';+import type { ComponentProps, ReactNode as ReactNodeType, Ref } from 'react';import { useImperativeHandle } from 'react';import { afterEach, beforeEach, vi } from 'vitest';@@ -237,8 +237,19 @@ vi.mock('@lobehub/ui', async (importOriginal) => {...((await importOriginal()) as Record<string, unknown>),confirmModal: uiSpies.confirmModal,toast: { error: uiSpies.toastError, success: uiSpies.toastSuccess },- ActionIcon: ({ onClick, title }: { onClick?: () => void; title?: string }) => (- <button title={title} type={'button'} onClick={onClick} />+ ActionIcon: ({+ 'aria-pressed': pressed,+ disabled,+ onClick,+ title,+ }: ComponentProps<'button'>) => (+ <button+ aria-pressed={pressed}+ disabled={disabled}+ title={title}+ type={'button'}+ onClick={onClick}+ />),Button: ({ children, title }: { children?: ReactNodeType; title?: string }) => (<button title={title} type={'button'}>diff --git a/src/features/Conversation/WorkingSidebar/Files/__tests__/index.test.tsx b/src/features/Conversation/WorkingSidebar/Files/__tests__/index.test.tsxindex a192ca2b67c..824b367ad13 100644--- a/src/features/Conversation/WorkingSidebar/Files/__tests__/index.test.tsx+++ b/src/features/Conversation/WorkingSidebar/Files/__tests__/index.test.tsx@@ -77,7 +77,7 @@ describe('Files — reveal request integration', () => {it('switches from the project view to a Git changes view', () => {render(<Files workingDirectory="/repo" />);- fireEvent.click(screen.getByText('workingPanel.files.views.changes'));+ fireEvent.click(screen.getByTitle('workingPanel.files.views.changes'));expect((explorerTreeProps.current?.nodes as { id: string }[]).map((node) => node.id)).toEqual(['\0project-root',@@ -89,10 +89,36 @@ describe('Files — reveal request integration', () => {]);});+ it('exposes the selected file filter to assistive technology and resets it with the workspace', () => {+ const { rerender } = render(<Files workingDirectory="/repo" />);+ const project = () =>+ screen.getByRole('button', { name: 'workingPanel.files.views.project', pressed: true });+ const changes = () =>+ screen.getByRole('button', { name: 'workingPanel.files.views.changes', pressed: false });++ expect(project()).toBeInTheDocument();+ fireEvent.click(changes());+ expect(+ screen.getByRole('button', { name: 'workingPanel.files.views.changes', pressed: true }),+ ).toBeInTheDocument();+ fireEvent.click(+ screen.getByRole('button', { name: 'workingPanel.files.views.project', pressed: false }),+ );+ expect(project()).toBeInTheDocument();+ fireEvent.click(changes());++ rerender(<Files workingDirectory="/another-repo" />);+ expect(project()).toBeInTheDocument();+ fireEvent.click(changes());+ rerender(<Files workingDirectory="/non-git" />);+ expect(project()).toBeInTheDocument();+ expect(changes()).toBeDisabled();+ });+it('sends active Git and ignore filters to the file host before search truncation', async () => {render(<Files workingDirectory="/repo" />);- fireEvent.click(screen.getByText('workingPanel.files.views.changes'));+ fireEvent.click(screen.getByTitle('workingPanel.files.views.changes'));fireEvent.click(screen.getByText('workingPanel.files.filters.hideIgnored'));expandSearch();fireEvent.change(screen.getByPlaceholderText('workingPanel.files.searchPlaceholder'), {@@ -114,7 +140,7 @@ describe('Files — reveal request integration', () => {it('resets the Git changes view when the workspace changes or is not Git-backed', async () => {const { rerender } = render(<Files workingDirectory="/repo" />);- fireEvent.click(screen.getByText('workingPanel.files.views.changes'));+ fireEvent.click(screen.getByTitle('workingPanel.files.views.changes'));expect((explorerTreeProps.current?.nodes as { id: string }[]).map((node) => node.id),).not.toContain('.env.local');@@ -126,7 +152,7 @@ describe('Files — reveal request integration', () => {).toContain('.env.local');});- fireEvent.click(screen.getByText('workingPanel.files.views.changes'));+ fireEvent.click(screen.getByTitle('workingPanel.files.views.changes'));rerender(<Files workingDirectory="/non-git" />);await waitFor(() => {expect(diff --git a/src/features/Conversation/WorkingSidebar/Files/index.tsx b/src/features/Conversation/WorkingSidebar/Files/index.tsxindex 008161b6c95..da9b8e407ed 100644--- a/src/features/Conversation/WorkingSidebar/Files/index.tsx+++ b/src/features/Conversation/WorkingSidebar/Files/index.tsx@@ -3,7 +3,6 @@import type { ProjectFileIndexEntry } from '@lobechat/electron-client-ipc';import {ActionIcon,- Button,Center,createStaticStyles,DropdownMenu,@@ -16,8 +15,6 @@ import {} from '@lobehub/ui';import type { GitStatusEntry } from '@pierre/trees';import {- CheckIcon,- ChevronDownIcon,EllipsisIcon,FileIcon,FilePlusIcon,@@ -387,27 +384,6 @@ const Files = memo<FilesProps>(setExpandedIds([]);}, []);- const viewItems = useMemo(- () => [- {- extra: viewMode === 'project' ? <CheckIcon size={14} /> : undefined,- icon: <FolderTreeIcon size={14} />,- key: 'project',- label: t('workingPanel.files.views.project'),- onClick: () => setViewMode('project'),- },- {- disabled: data?.source !== 'git',- extra: viewMode === 'changes' ? <CheckIcon size={14} /> : undefined,- icon: <GitCompareArrowsIcon size={14} />,- key: 'changes',- label: t('workingPanel.files.views.changes'),- onClick: () => setViewMode('changes'),- },- ],- [data?.source, t, viewMode],- );-useEffect(() => {if (!isFiltering) return;treeRef.current?.setExpanded(defaultExpandedIds);@@ -531,22 +507,23 @@ const Files = memo<FilesProps>(</div>) : (<>- <DropdownMenu items={viewItems} placement={'bottomLeft'}>- <Button- icon={viewMode === 'project' ? FolderTreeIcon : GitCompareArrowsIcon}- size={'small'}- style={{ maxWidth: 'calc(100% - 84px)' }}- title={t('workingPanel.files.views.title')}- type={'text'}- >- {t(- viewMode === 'project'- ? 'workingPanel.files.views.project'- : 'workingPanel.files.views.changes',- )}- <ChevronDownIcon size={12} />- </Button>- </DropdownMenu>+ <ActionIcon+ active={viewMode === 'project'}+ aria-pressed={viewMode === 'project'}+ icon={FolderTreeIcon}+ size={'small'}+ title={t('workingPanel.files.views.project')}+ onClick={() => setViewMode('project')}+ />+ <ActionIcon+ active={viewMode === 'changes'}+ aria-pressed={viewMode === 'changes'}+ disabled={data?.source !== 'git'}+ icon={GitCompareArrowsIcon}+ size={'small'}+ title={t('workingPanel.files.views.changes')}+ onClick={() => setViewMode('changes')}+ /><div style={{ flex: 1 }} /></>)}