fix(desktop): write project IDEA.md through the remote-aware fs path

writeProjectIdea used the local-only Electron writeTextFile, so on a remote
gateway IDEA.md never landed on the backend (where the project folder lives).
Route it through writeDesktopFileText (local Electron / POST /api/fs/write-text).
This commit is contained in:
Brooklyn Nicholson 2026-06-28 14:31:58 -05:00
parent e4cf3a2e9d
commit 9b71221187

View file

@ -2,7 +2,7 @@ import { atom } from 'nanostores'
import { liveSessionProjectId, type SidebarProjectTree } from '@/app/chat/sidebar/projects/workspace-groups'
import type { HermesGitBranch } from '@/global'
import { desktopDefaultCwd, isDesktopFsRemoteMode, selectDesktopPaths } from '@/lib/desktop-fs'
import { desktopDefaultCwd, isDesktopFsRemoteMode, selectDesktopPaths, writeDesktopFileText } from '@/lib/desktop-fs'
import { desktopGit } from '@/lib/desktop-git'
import { persistentAtom } from '@/lib/persisted'
import { activeGateway, ensureActiveGatewayOpen } from '@/store/gateway'
@ -336,20 +336,19 @@ export async function generateProjectIdea(name: string): Promise<string> {
}
}
// Write IDEA.md to a project's primary folder (desktop only, best-effort). Local
// fs write is hardened in the electron main; a remote backend / missing bridge
// just skips it.
// Write IDEA.md to a project's primary folder (best-effort). Routes through the
// remote-aware fs write, so it lands on the backend for a remote gateway and on
// disk locally — the project is created regardless of whether the file lands.
async function writeProjectIdea(folder: null | string | undefined, idea: string): Promise<void> {
const dir = (folder || '').trim()
const body = idea.trim()
const write = window.hermesDesktop?.writeTextFile
if (!dir || !body || !write) {
if (!dir || !body) {
return
}
try {
await write(`${dir.replace(/[/\\]+$/, '')}/IDEA.md`, body.endsWith('\n') ? body : `${body}\n`)
await writeDesktopFileText(`${dir.replace(/[/\\]+$/, '')}/IDEA.md`, body.endsWith('\n') ? body : `${body}\n`)
} catch {
// Best-effort: the project is created regardless of whether IDEA.md lands.
}