fix: preserve root separator in filename-first paths

This commit is contained in:
Neil
2026-08-05 00:55:29 -07:00
parent 886e25f298
commit d0c756dd94
3 changed files with 26 additions and 4 deletions
@@ -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//')
})
})
@@ -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 (
<span className="flex min-w-0 flex-1 items-center gap-1">
@@ -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 })