Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

feat(desktop): reveal the file explorer tree from the Files nav label

Diego Zacariasecb4be453705
diff --git a/desktop-app/ui/src/components/SidebarNav/index.tsx b/desktop-app/ui/src/components/SidebarNav/index.tsx
index 473d5cf52..3df859e8a 100644
--- a/desktop-app/ui/src/components/SidebarNav/index.tsx
+++ b/desktop-app/ui/src/components/SidebarNav/index.tsx
@@ -198,6 +198,17 @@ export function SidebarNav({
setSessionMenuId(null)
}
+ const handleFilesNavSelect = () => {
+ handleSelect(DESKTOP_ROUTES.files)
+ // The Files label doubles as the explorer's reveal: activating it both
+ // focuses the files tab and exposes the tree. It only ever expands —
+ // collapsing stays the chevron's job, so a second click never hides the
+ // tree the user just opened. Skip the reveal while the sidebar is
+ // collapsed: the tree cannot render there, so the flag would have no
+ // visible effect and only defer its discovery fetch to a later expand.
+ if (!collapsed) setFilesExplorerOpen(true)
+ }
+
const startSessionRename = (session: (typeof latestChatSessions)[number]) => {
setSessionMenuId(null)
setRenamingSessionId(`${session.agentRef}${SESSION_KEY_SEPARATOR}${session.id}`)
@@ -562,7 +573,7 @@ export function SidebarNav({
<NavItemControl
data-testid="nav-files"
className="nav-link-main"
- onClick={() => handleSelect(DESKTOP_ROUTES.files)}
+ onClick={handleFilesNavSelect}
aria-label="Files"
leadingIcon={<IconAttachFile />}
trailingIcon={
diff --git a/desktop-app/ui/src/components/__tests__/SidebarNav.test.tsx b/desktop-app/ui/src/components/__tests__/SidebarNav.test.tsx
index 45baa91eb..38ac26727 100644
--- a/desktop-app/ui/src/components/__tests__/SidebarNav.test.tsx
+++ b/desktop-app/ui/src/components/__tests__/SidebarNav.test.tsx
@@ -34,6 +34,11 @@ vi.mock('@contexts/NavigationContext', () => ({
handleSelectChatAgent: vi.fn(),
}),
}))
+// The real tree pulls TanStack Query and GFS contexts; the sidebar tests only
+// care that revealing it flips the explorer open, not what it renders.
+vi.mock('../SidebarNav/FileExplorerTree', () => ({
+ FileExplorerTree: () => <div data-testid="file-explorer-tree" />,
+}))
function baseProps(overrides: Partial<SidebarNavProps> = {}): SidebarNavProps {
return {
@@ -301,3 +306,95 @@ describe('SidebarNav flattened resources menu', () => {
expect(trigger.classList.contains('active')).toBe(true)
})
})
+
+describe('SidebarNav Files label engages the file explorer', () => {
+ beforeEach(() => {
+ vi.clearAllMocks()
+ if (!window.matchMedia) {
+ Object.defineProperty(window, 'matchMedia', {
+ writable: true,
+ configurable: true,
+ value: vi.fn().mockImplementation((query: string) => ({
+ matches: false,
+ media: query,
+ onchange: null,
+ addListener: vi.fn(),
+ removeListener: vi.fn(),
+ addEventListener: vi.fn(),
+ removeEventListener: vi.fn(),
+ dispatchEvent: vi.fn(),
+ })),
+ })
+ }
+ })
+
+ afterEach(() => {
+ cleanup()
+ })
+
+ it('opens the files section and reveals the tree on a label click', () => {
+ const onSelect = vi.fn()
+ render(<SidebarNav {...baseProps({ onSelect })} />)
+
+ // The tree starts collapsed to defer its discovery fetch.
+ expect(screen.getByTestId('nav-files-explorer-toggle').getAttribute('aria-expanded')).toBe(
+ 'false'
+ )
+ expect(screen.queryByTestId('file-explorer-tree')).toBeNull()
+
+ fireEvent.click(screen.getByTestId('nav-files'))
+
+ // Navigation still fires, and the same click now exposes the tree.
+ expect(onSelect).toHaveBeenCalledWith('files')
+ expect(screen.getByTestId('nav-files-explorer-toggle').getAttribute('aria-expanded')).toBe(
+ 'true'
+ )
+ expect(screen.getByTestId('file-explorer-tree')).not.toBeNull()
+ })
+
+ it('never collapses an already-open tree on a second label click', () => {
+ const onSelect = vi.fn()
+ render(<SidebarNav {...baseProps({ onSelect })} />)
+
+ // Open the tree via the chevron first.
+ fireEvent.click(screen.getByTestId('nav-files-explorer-toggle'))
+ expect(screen.getByTestId('nav-files-explorer-toggle').getAttribute('aria-expanded')).toBe(
+ 'true'
+ )
+
+ // Clicking the label again re-navigates but leaves the tree open.
+ fireEvent.click(screen.getByTestId('nav-files'))
+ expect(onSelect).toHaveBeenCalledWith('files')
+ expect(screen.getByTestId('nav-files-explorer-toggle').getAttribute('aria-expanded')).toBe(
+ 'true'
+ )
+ expect(screen.getByTestId('file-explorer-tree')).not.toBeNull()
+ })
+
+ it('navigates without arming the tree while the sidebar is collapsed', () => {
+ const onSelect = vi.fn()
+ render(<SidebarNav {...baseProps({ onSelect, collapsed: true })} />)
+
+ fireEvent.click(screen.getByTestId('nav-files'))
+
+ // Navigation still fires, but the reveal is skipped: the tree cannot render
+ // collapsed, so the label must not defer its discovery fetch to a later expand.
+ expect(onSelect).toHaveBeenCalledWith('files')
+ expect(screen.getByTestId('nav-files-explorer-toggle').getAttribute('aria-expanded')).toBe(
+ 'false'
+ )
+ expect(screen.queryByTestId('file-explorer-tree')).toBeNull()
+ })
+
+ it('keeps the chevron as the only control that collapses the tree', () => {
+ render(<SidebarNav {...baseProps()} />)
+ const toggle = screen.getByTestId('nav-files-explorer-toggle')
+
+ fireEvent.click(toggle)
+ expect(toggle.getAttribute('aria-expanded')).toBe('true')
+
+ fireEvent.click(toggle)
+ expect(toggle.getAttribute('aria-expanded')).toBe('false')
+ expect(screen.queryByTestId('file-explorer-tree')).toBeNull()
+ })
+})