Skip to content
This repository was archived by the owner on Jan 30, 2026. It is now read-only.

Commit 671f762

Browse files
authored
Merge pull request #31 from sotopia-lab/fix_files
Fix: Preserve File Contents During File System Refresh
2 parents 1c96234 + 36c1d88 commit 671f762

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

frontend/hooks/useFileSystem.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,11 @@ export const useFileSystem = () => {
164164

165165
// If we're at the last segment, it's a file
166166
if (index === segments.length - 1) {
167-
// Check if the file already exists
168-
if (!existingFiles.has(currentPath)) {
169-
currentLevel.push({
170-
name: segment,
171-
type: 'file',
172-
path: currentPath
173-
});
174-
}
167+
currentLevel.push({
168+
name: segment,
169+
type: 'file',
170+
path: currentPath
171+
});
175172
} else {
176173
// It's a folder
177174
let folder = currentLevel.find(
@@ -223,8 +220,8 @@ export const useFileSystem = () => {
223220

224221
// Update the file system state while preserving existing file contents
225222
setFileSystem(prev => ({
226-
...prev,
227-
tree: newTree
223+
tree: newTree,
224+
files: prev.files // Preserve all existing file contents
228225
}));
229226
};
230227

0 commit comments

Comments
 (0)