diff --git a/packages/handoff/src/index.ts b/packages/handoff/src/index.ts index 30c912f227f5631949ee153740b478522430c0f0..1d0261f873bce9bb028e72f2c3393acf5ccfa2e9 100644 --- a/packages/handoff/src/index.ts +++ b/packages/handoff/src/index.ts @@ -174,10 +174,11 @@ function extractCandidateFiles(entries: SessionEntry[], conversationText: string } } - // Secondary: file-like patterns from conversation text - const filePattern = /(?:^|\s)([a-zA-Z0-9._\-/]+\.[a-zA-Z0-9]+)(?:\s|$|[,;:\)])/gm; - let match; - while ((match = filePattern.exec(conversationText)) !== null) { + // Secondary: file-like patterns from conversation text. + // Trailing lookahead so the boundary isn't consumed — otherwise adjacent + // files separated by a single space (e.g. "file1.txt file2.txt") get skipped. + const filePattern = /(?:^|\s)([a-zA-Z0-9._\-/]+\.[a-zA-Z0-9]+)(?=\s|$|[,;:)])/gm; + for (const match of conversationText.matchAll(filePattern)) { const candidate = match[1]; if (candidate && !candidate.startsWith(".") && candidate.length > 2) { files.add(candidate);