|
1 | 1 | import { useEffect, useState, memo, useCallback, useRef } from 'react' |
2 | 2 | import { FileBrowser, type FileBrowserHandle } from './FileBrowser' |
| 3 | +import { getRepoRelativeDisplayPath } from './display-path' |
3 | 4 | import { Button } from '@/components/ui/button' |
4 | 5 | import { PathDisplay } from '@/components/ui/path-display' |
5 | 6 | import { FullscreenSheet, FullscreenSheetHeader, FullscreenSheetContent } from '@/components/ui/fullscreen-sheet' |
@@ -71,28 +72,9 @@ export const FileBrowserSheet = memo(function FileBrowserSheet({ isOpen, onClose |
71 | 72 | return |
72 | 73 | } |
73 | 74 |
|
74 | | - if (!info.currentPath || info.currentPath === '.' || info.currentPath === '') { |
75 | | - setDisplayPath('/') |
76 | | - setCurrentPath(info.currentPath || '.') |
77 | | - return |
78 | | - } |
79 | | - |
80 | | - setCurrentPath(info.currentPath) |
81 | | - |
82 | | - const pathParts = info.currentPath.split('/').filter(Boolean) |
83 | | - |
84 | | - if (repoName) { |
85 | | - const repoIndex = pathParts.findIndex(p => p === repoName || p.startsWith(repoName + '-')) |
86 | | - if (repoIndex >= 0) { |
87 | | - const subPath = pathParts.slice(repoIndex + 1) |
88 | | - setDisplayPath(subPath.length > 0 ? '/' + subPath.join('/') : '/') |
89 | | - } else { |
90 | | - setDisplayPath('/' + pathParts.join('/')) |
91 | | - } |
92 | | - } else { |
93 | | - setDisplayPath('/' + pathParts.join('/')) |
94 | | - } |
95 | | - }, [allowNavigateAboveBase, repoName]) |
| 75 | + setCurrentPath(info.currentPath || '.') |
| 76 | + setDisplayPath(getRepoRelativeDisplayPath(info.currentPath || '.', normalizedBasePath)) |
| 77 | + }, [allowNavigateAboveBase, normalizedBasePath]) |
96 | 78 |
|
97 | 79 | const handleDownloadDirectory = useCallback(async (options: { includeGit?: boolean, includePaths?: string[] }) => { |
98 | 80 | if (!currentPath) return |
|
0 commit comments