Skip to content

Commit 64f9cab

Browse files
committed
fix: enhance local file handling in EditorLayout
Updated local file operations to include localRootPath checks for both reading and writing files. Adjusted context initialization to differentiate between Tauri desktop and iOS environments, ensuring proper file system access. This improves reliability in local mode operations.
1 parent 6936f47 commit 64f9cab

3 files changed

Lines changed: 336 additions & 174 deletions

File tree

app/page.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,14 +278,14 @@ export default function EditorLayout() {
278278
const file = files.find((f) => f.path === path)
279279
if (!file || !file.dirty) return
280280

281-
if (localMode && localWriteFile) {
281+
if (localMode && localWriteFile && localRootPath) {
282282
try {
283283
await localWriteFile(path, file.content)
284284
markClean(path)
285+
return
285286
} catch (err) {
286287
console.error('Failed to save file:', path, err)
287288
}
288-
return
289289
}
290290

291291
if (repo) {
@@ -302,7 +302,7 @@ export default function EditorLayout() {
302302
}
303303
}
304304
},
305-
[files, localMode, localWriteFile, markClean, repo],
305+
[files, localMode, localRootPath, localWriteFile, markClean, repo],
306306
)
307307

308308
// ─── Keyboard shortcuts ────────────────────────────────
@@ -368,7 +368,7 @@ export default function EditorLayout() {
368368
const fileKind = detectFileKind(path)
369369
const isBinary = fileKind !== 'text'
370370

371-
if (localMode && localReadFile) {
371+
if (localMode && localReadFile && localRootPath) {
372372
try {
373373
if (isBinary && localReadFileBase64) {
374374
const base64 = await localReadFileBase64(path)
@@ -380,10 +380,10 @@ export default function EditorLayout() {
380380
openFile(path, content, '')
381381
}
382382
revealEditorFromChat()
383+
return
383384
} catch (err) {
384385
console.error('Failed to read local file:', path, err)
385386
}
386-
return
387387
}
388388

389389
if (repo) {
@@ -411,6 +411,7 @@ export default function EditorLayout() {
411411
activeView,
412412
layout,
413413
localMode,
414+
localRootPath,
414415
localReadFile,
415416
localReadFileBase64,
416417
])

0 commit comments

Comments
 (0)