From 39b486a8d153748715283c7a6e40d304b8e8f92a Mon Sep 17 00:00:00 2001 From: Sawyer Date: Fri, 18 Sep 2026 02:05:27 -0700 Subject: [PATCH] fix(web): a bare filename on a fence's first line labels the package file (CL-8517) --- apps/web/src/chat/deployable-package.test.ts | 7 +++++++ apps/web/src/chat/deployable-package.ts | 15 ++++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/apps/web/src/chat/deployable-package.test.ts b/apps/web/src/chat/deployable-package.test.ts index b995608e7..5a8a3f127 100644 --- a/apps/web/src/chat/deployable-package.test.ts +++ b/apps/web/src/chat/deployable-package.test.ts @@ -30,6 +30,13 @@ describe("deployablePackageFromBody", () => { expect(result?.strippedBody).toBe("Here is the package:\n\nPress Deploy."); }); + test("reads a bare filename on the fence's first line", () => { + const body = + `\`\`\`json\npackage.json\n${PACKAGE_JSON}\n\`\`\`\n\n` + + `\`\`\`json\ndefinition.json\n${DEFINITION_JSON}\n\`\`\``; + expect(deployablePackageFromBody(body)?.pkg.name).toBe("Echo"); + }); + test("is null when only one of the two files is present", () => { const body = `package.json\n\`\`\`\n${PACKAGE_JSON}\n\`\`\``; expect(deployablePackageFromBody(body)).toBeNull(); diff --git a/apps/web/src/chat/deployable-package.ts b/apps/web/src/chat/deployable-package.ts index bdbf1167b..83465637f 100644 --- a/apps/web/src/chat/deployable-package.ts +++ b/apps/web/src/chat/deployable-package.ts @@ -119,17 +119,14 @@ function findNamedFencedBlocks(lines: readonly string[]): Map content.trim() !== ""); - const first = contentLines[firstContent] ?? ""; - if (/^\s*(\/\/|#)/.test(first)) { - const fromComment = namedFile(first); - if (fromComment !== null) { - name = fromComment; - contentLines.splice(0, firstContent + 1); - } + const fromFirstLine = namedFile(contentLines[firstContent] ?? ""); + if (fromFirstLine !== null) { + name = fromFirstLine; + contentLines.splice(0, firstContent + 1); } } if (name !== null && !found.has(name)) {