diff --git a/src/renderer/src/components/tab-bar/TabBarCreateEntryRow.test.tsx b/src/renderer/src/components/tab-bar/TabBarCreateEntryRow.test.tsx index 07425eb590f..54c71dd9da7 100644 --- a/src/renderer/src/components/tab-bar/TabBarCreateEntryRow.test.tsx +++ b/src/renderer/src/components/tab-bar/TabBarCreateEntryRow.test.tsx @@ -69,4 +69,20 @@ describe('EntryActionRow', () => { expect(text.indexOf('SecondaryNav.tsx')).toBeLessThan(text.indexOf('app/src/components/')) expect(container.querySelector('[data-tooltip-content]')?.textContent).toBe(filePath) }) + + it('does not duplicate the root separator for absolute root-level files', () => { + act(() => { + root.render( + createElement(EntryActionRow, { + id: 'root-file-result', + onClick: vi.fn(), + option: makeFileOption('/foo'), + selected: false + }) + ) + }) + + expect(container.querySelector('button')?.textContent).toContain('foo/') + expect(container.querySelector('button')?.textContent).not.toContain('foo//') + }) }) diff --git a/src/renderer/src/components/tab-bar/TabBarCreateEntryRow.tsx b/src/renderer/src/components/tab-bar/TabBarCreateEntryRow.tsx index eca7ae586d4..9b3a8a21eca 100644 --- a/src/renderer/src/components/tab-bar/TabBarCreateEntryRow.tsx +++ b/src/renderer/src/components/tab-bar/TabBarCreateEntryRow.tsx @@ -96,7 +96,12 @@ export function EntryActionRow({ function FilenameFirstPath({ path }: { path: string }): React.JSX.Element { const filename = basename(path) const directory = dirname(path) - const directoryLabel = directory === '.' ? '' : `${directory}${path.includes('\\') ? '\\' : '/'}` + const directoryLabel = + directory === '.' + ? '' + : directory.endsWith('/') || directory.endsWith('\\') + ? directory + : `${directory}${path.includes('\\') ? '\\' : '/'}` return ( diff --git a/tests/e2e/tab-create-entry-file-paths.spec.ts b/tests/e2e/tab-create-entry-file-paths.spec.ts index de32431f926..0dc97ad5920 100644 --- a/tests/e2e/tab-create-entry-file-paths.spec.ts +++ b/tests/e2e/tab-create-entry-file-paths.spec.ts @@ -3,7 +3,8 @@ import path from 'node:path' import { expect, test } from './helpers/orca-app' import { ensureTerminalVisible, waitForActiveWorktree, waitForSessionReady } from './helpers/store' -const relativeFilePath = 'app/src/components/SecondaryNav.tsx' +const relativeFilePath = + 'packages/orca/src/renderer/src/components/navigation/worktree/secondary-nav/SecondaryNav.tsx' test('new-tab file results prioritize the filename and reveal the full path on hover', async ({ orcaPage, @@ -26,10 +27,10 @@ test('new-tab file results prioritize the filename and reveal the full path on h const row = orcaPage.locator('[role="option"]').filter({ hasText: 'Open file' }).first() await expect(row).toBeVisible() await expect(row).toContainText('SecondaryNav.tsx') - await expect(row).toContainText('app/src/components/') + await expect(row).toContainText('packages/orca/src/renderer/src/components/navigation/') const rowText = await row.textContent() expect(rowText?.indexOf('SecondaryNav.tsx')).toBeLessThan( - rowText?.indexOf('app/src/components/') ?? -1 + rowText?.indexOf('packages/orca/src/renderer/src/components/navigation/') ?? -1 ) await row.hover({ force: true })