File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed
Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import { cjk } from "@streamdown/cjk";
1313import { code } from "@streamdown/code" ;
1414import { math } from "@streamdown/math" ;
1515import { mermaid } from "@streamdown/mermaid" ;
16+ import { usePanel } from "@/hooks/usePanel" ;
1617import type { FilePreview as FilePreviewType } from "@/types" ;
1718
1819const streamdownPlugins = { cjk, code, math, mermaid } ;
@@ -52,6 +53,7 @@ export function DocPreview({
5253 width,
5354} : DocPreviewProps ) {
5455 const { resolvedTheme } = useTheme ( ) ;
56+ const { workingDirectory } = usePanel ( ) ;
5557 const isDark = resolvedTheme === "dark" ;
5658 const [ preview , setPreview ] = useState < FilePreviewType | null > ( null ) ;
5759 const [ loading , setLoading ] = useState ( true ) ;
@@ -66,7 +68,7 @@ export function DocPreview({
6668 setError ( null ) ;
6769 try {
6870 const res = await fetch (
69- `/api/files/preview?path=${ encodeURIComponent ( filePath ) } &maxLines=500`
71+ `/api/files/preview?path=${ encodeURIComponent ( filePath ) } &maxLines=500${ workingDirectory ? `&baseDir= ${ encodeURIComponent ( workingDirectory ) } ` : '' } `
7072 ) ;
7173 if ( ! res . ok ) {
7274 const data = await res . json ( ) ;
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import { Badge } from "@/components/ui/badge";
88import { ScrollArea } from "@/components/ui/scroll-area" ;
99import { Light as SyntaxHighlighter } from "react-syntax-highlighter" ;
1010import { atomOneDark } from "react-syntax-highlighter/dist/esm/styles/hljs" ;
11+ import { usePanel } from "@/hooks/usePanel" ;
1112import type { FilePreview as FilePreviewType } from "@/types" ;
1213
1314interface FilePreviewProps {
@@ -16,6 +17,7 @@ interface FilePreviewProps {
1617}
1718
1819export function FilePreview ( { filePath, onBack } : FilePreviewProps ) {
20+ const { workingDirectory } = usePanel ( ) ;
1921 const [ preview , setPreview ] = useState < FilePreviewType | null > ( null ) ;
2022 const [ loading , setLoading ] = useState ( true ) ;
2123 const [ error , setError ] = useState < string | null > ( null ) ;
@@ -27,7 +29,7 @@ export function FilePreview({ filePath, onBack }: FilePreviewProps) {
2729 setError ( null ) ;
2830 try {
2931 const res = await fetch (
30- `/api/files/preview?path=${ encodeURIComponent ( filePath ) } `
32+ `/api/files/preview?path=${ encodeURIComponent ( filePath ) } ${ workingDirectory ? `&baseDir= ${ encodeURIComponent ( workingDirectory ) } ` : '' } `
3133 ) ;
3234 if ( ! res . ok ) {
3335 const data = await res . json ( ) ;
You can’t perform that action at this time.
0 commit comments