Skip to content

Commit b535100

Browse files
committed
fix(web): show the Docker icon on dockerfile code blocks
A ```dockerfile fence asked the icon resolver for file.dockerfile, which no icon matches, so chat fell back to the language text. Docker files are recognised by name, so the fence now resolves as Dockerfile.
1 parent a3abb52 commit b535100

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

‎apps/web/src/pierre-icons.test.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,12 @@ describe("Pierre file icons", () => {
5656

5757
it("normalizes common markdown fence language aliases", () => {
5858
assert.equal(syntheticFileNameForLanguageId("typescript"), "file.ts");
59+
assert.equal(syntheticFileNameForLanguageId("dockerfile"), "Dockerfile");
5960
assert.equal(syntheticFileNameForLanguageId("shellscript"), "file.sh");
6061
assert.equal(syntheticFileNameForLanguageId("python"), "file.py");
6162
});
63+
64+
it("gives a dockerfile fence the Docker icon", () => {
65+
assert.isTrue(hasSpecificPierreIconForFileName(syntheticFileNameForLanguageId("dockerfile")));
66+
});
6267
});

‎apps/web/src/pierre-icons.ts‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ const completeIconResolver = createFileTreeIconResolver(T3_PIERRE_ICONS);
5151
const LANGUAGE_EXTENSION_ALIASES: Record<string, string> = {
5252
bash: "sh",
5353
csharp: "cs",
54-
dockerfile: "dockerfile",
5554
javascript: "js",
5655
jsx: "jsx",
5756
markdown: "md",
@@ -79,9 +78,17 @@ export function inferEntryKindFromPath(pathValue: string): "file" | "directory"
7978
return base.includes(".") ? "file" : "directory";
8079
}
8180

81+
/** Languages whose files are recognised by name rather than by extension. */
82+
const LANGUAGE_FILE_NAMES: Record<string, string> = {
83+
dockerfile: "Dockerfile",
84+
};
85+
8286
export function syntheticFileNameForLanguageId(languageId: string): string {
8387
const normalized = languageId.toLowerCase();
84-
return `file.${LANGUAGE_EXTENSION_ALIASES[normalized] ?? normalized}`;
88+
return (
89+
LANGUAGE_FILE_NAMES[normalized] ??
90+
`file.${LANGUAGE_EXTENSION_ALIASES[normalized] ?? normalized}`
91+
);
8592
}
8693

8794
export function resolvePierreIconForEntry(

0 commit comments

Comments
 (0)