diff --git a/src/shared/native-chat-edit-patch-files.ts b/src/shared/native-chat-edit-patch-files.ts index 3ad996051ff..b0bd101338d 100644 --- a/src/shared/native-chat-edit-patch-files.ts +++ b/src/shared/native-chat-edit-patch-files.ts @@ -44,6 +44,10 @@ export function editFilesFromPatchText( callerPath: string | null, summaryOnly = false ): NativeChatEditFileSummary[] | null { + if (callerPath !== null && FILE_COUNT_PATH.test(callerPath)) { + // A file count cannot name a card, regardless of the patch contents. + return null + } // The body carries its own marker when the journal clipped it. Read as // content it becomes a numbered line of the file, and the rows that follow // are reported complete. @@ -52,12 +56,6 @@ export function editFilesFromPatchText( // One card per file the patch touches: run together, the later files' rows // and gutter numbers sit under the first file's name. const split = unifiedPatchSections(moved.body) - if (callerPath !== null && FILE_COUNT_PATH.test(callerPath)) { - // The producer joined several files' patches and kept a count in place of a - // path, so nothing here can name a file. Naming the card after the count - // would assert a file that does not exist. - return null - } // A patch that names one file is the file the call is reporting on, so the // call's own path wins — it is the provider's, where the header's is relative // to the patch. A patch naming several has no one path, and a rename's