fix: check the Assistant config inside its lock and pass bare stream events through (OM-179)

ensureAssistantMode now checks whether opencode.json exists after taking the file lock, so a conversion that ran in between cannot leave it acting on a stale result.

The browser event stream again delivers a message frame that carries a typed event without the directory envelope, as it did before the client migration, instead of dropping it silently.
This commit is contained in:
Chris Scott committed 2026-11-05 16:43:56 -05:00
1 parent 052b501963
commit 8b6ed7a861
3 files changed
+20 -4

No files matched your search

+1 -2
View File
@@ -1183,8 +1183,6 @@ export async function ensureAssistantMode(
const assistantAgentPath = getAssistantDefaultAgentPath(assistantDir)
const agentsMdExists = await fileExists(agentsMdPath)
const opencodeJsonExists = await fileExists(opencodeJsonPath)
const overwriteOpenCodeConfig = options?.overwriteOpenCodeConfig ?? false
const overwriteAgentsMd = options?.overwriteAgentsMd ?? false
@@ -1212,6 +1210,7 @@ export async function ensureAssistantMode(
}
const opencodeJsonUpdated = await withFileLock(opencodeJsonPath, async () => {
const opencodeJsonExists = await fileExists(opencodeJsonPath)
const existingOpenCodeJsonContent = opencodeJsonExists ? await readFileContent(opencodeJsonPath) : undefined
const parsedOpenCodeConfig = existingOpenCodeJsonContent === undefined
? undefined