diff --git a/src/renderer/src/components/tab-bar/TabBarCreateEntry.keyboard.test.tsx b/src/renderer/src/components/tab-bar/TabBarCreateEntry.keyboard.test.tsx index 437e2c2b1..23dd2a595 100644 --- a/src/renderer/src/components/tab-bar/TabBarCreateEntry.keyboard.test.tsx +++ b/src/renderer/src/components/tab-bar/TabBarCreateEntry.keyboard.test.tsx @@ -10,7 +10,9 @@ import type { TabAgentLaunchOption } from './tab-agent-launch-options' // keyboard behavior under test only needs a controllable option list. const entryOptionsMock = vi.hoisted(() => ({ options: [] as TabEntryOption[] })) vi.mock('./tab-create-entry-action', () => ({ - getTabEntryOptions: () => entryOptionsMock.options + getTabEntryOptions: () => entryOptionsMock.options, + createTabEntryAllowAbsolutePathsSelector: () => () => true, + isTabEntryAbsolutePathLike: () => false })) vi.mock('../quick-open-file-list', () => ({ useRuntimeFileListForWorktree: () => ({ files: [], loading: false, loadError: null }) diff --git a/src/renderer/src/components/tab-bar/TabBarCreateEntry.tsx b/src/renderer/src/components/tab-bar/TabBarCreateEntry.tsx index dd2772f36..8c9941cba 100644 --- a/src/renderer/src/components/tab-bar/TabBarCreateEntry.tsx +++ b/src/renderer/src/components/tab-bar/TabBarCreateEntry.tsx @@ -1,7 +1,12 @@ import React, { useEffect, useMemo, useRef, useState } from 'react' import { Input } from '@/components/ui/input' import { useRuntimeFileListForWorktree } from '../quick-open-file-list' -import { getTabEntryOptions, type TabCreateEntryArgs } from './tab-create-entry-action' +import { + createTabEntryAllowAbsolutePathsSelector, + getTabEntryOptions, + isTabEntryAbsolutePathLike, + type TabCreateEntryArgs +} from './tab-create-entry-action' import { findMatchingTabAgentLaunchOptions, type TabAgentLaunchOption @@ -23,6 +28,8 @@ import { } from './TabBarCreateEntryRow' import type { TuiAgent } from '../../../../shared/types' import { translate } from '@/i18n/i18n' +import { getRendererAppPlatform } from '@/lib/renderer-app-platform' +import { useAppStore } from '@/store' const EMPTY_AGENT_OPTIONS: readonly TabAgentLaunchOption[] = [] const EMPTY_MENU_OPTIONS: readonly TabCreateMenuOption[] = [] @@ -62,6 +69,16 @@ export default function TabBarCreateEntry({ const [lastMenuOpen, setLastMenuOpen] = useState(menuOpen) const inputRef = useRef(null) const fileList = useRuntimeFileListForWorktree({ enabled: menuOpen, worktreeId }) + const shouldResolveAbsolutePaths = menuOpen && isTabEntryAbsolutePathLike(query.trim()) + const allowAbsolutePathsSelector = useMemo( + () => + createTabEntryAllowAbsolutePathsSelector(worktreeId, { + skip: !shouldResolveAbsolutePaths + }), + [shouldResolveAbsolutePaths, worktreeId] + ) + const allowAbsolutePaths = useAppStore(allowAbsolutePathsSelector) + const localPlatform = getRendererAppPlatform() === 'win32' ? 'windows' : 'posix' // Why: once ArrowDown moves focus into the static menu list, ArrowUp on the // first item should return to the search box so the keyboard trip isn't @@ -105,13 +122,16 @@ export default function TabBarCreateEntry({ [menuOptions, query] ) const options = useMemo(() => { - const entryOptions = getTabEntryOptions(query, fileList) + const entryOptions = getTabEntryOptions(query, fileList, 4, { + allowAbsolutePaths, + localPlatform + }) if (matchingMenuOptions.length === 0) { return entryOptions } // Why: a matched create-menu action should win over a generic new-file fallback. return entryOptions.filter((option) => option.classification.kind !== 'new-file') - }, [fileList, matchingMenuOptions.length, query]) + }, [allowAbsolutePaths, fileList, localPlatform, matchingMenuOptions.length, query]) const matchingAgentOptions = useMemo( () => findMatchingTabAgentLaunchOptions(query, agentOptions), [agentOptions, query] diff --git a/src/renderer/src/components/tab-bar/TabBarCreateEntryRow.tsx b/src/renderer/src/components/tab-bar/TabBarCreateEntryRow.tsx index 01513864e..7aa57731c 100644 --- a/src/renderer/src/components/tab-bar/TabBarCreateEntryRow.tsx +++ b/src/renderer/src/components/tab-bar/TabBarCreateEntryRow.tsx @@ -114,9 +114,12 @@ function getActionPresentation(option: ActiveOption): { showDetail: true } } - if (classification.kind === 'existing-file') { + if (classification.kind === 'existing-file' || classification.kind === 'absolute-file') { return { - detail: classification.relativePath, + detail: + classification.kind === 'absolute-file' + ? classification.filePath + : classification.relativePath, icon: