| 71 | }; |
| 72 | |
| 73 | const selectFile = async (filePath: string) => { |
| 74 | setSelectedFile(filePath); |
| 75 | |
| 76 | try { |
| 77 | const response = await fetch( |
| 78 | `/api/container/${sessionId}/file-content?path=${encodeURIComponent(filePath)}` |
| 79 | ); |
| 80 | |
| 81 | if (!response.ok) { |
| 82 | throw new Error("Failed to load file"); |
| 83 | } |
| 84 | |
| 85 | const content = await response.text(); |
| 86 | setFileContent(content); |
| 87 | } catch (err) { |
| 88 | setFileContent(`Error: ${err instanceof Error ? err.message : "Failed to load file"}`); |
| 89 | } |
| 90 | }; |
| 91 | |
| 92 | const renderTree = (parentPath: string, level: number = 0): React.JSX.Element[] => { |
| 93 | const children = files.filter((f) => { |