From b94ecbcaa1123616d07e089193a885d7e8bb5736 Mon Sep 17 00:00:00 2001 From: OrcaWin Date: Sat, 12 Sep 2026 18:10:50 -0700 Subject: [PATCH] perf: reject file-count labels before parsing edit patches (#20330) Co-authored-by: Orca Worker --- src/shared/native-chat-edit-patch-files.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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