From cb6cb74696d46d09b7dc67e5c10b3377ae7e7a0d Mon Sep 17 00:00:00 2001 From: Brooklyn Nicholson Date: Fri, 4 Sep 2026 14:18:39 -0500 Subject: [PATCH] Keep renderer-owned fences out of artifact promotion Artifact detection runs before the rich-fence registry, so a fence long enough to look like a code document was promoted to a code card and never reached its own renderer. A multi-listing set crosses that threshold easily, which made the same content render two different ways depending on how many properties it held. `listing` joins the languages that are never artifacts, next to `mermaid` for the same reason. --- apps/desktop/src/lib/artifact-detect.test.ts | 7 +++++++ apps/desktop/src/lib/artifact-detect.ts | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/apps/desktop/src/lib/artifact-detect.test.ts b/apps/desktop/src/lib/artifact-detect.test.ts index d4aba79129..a5a250b5d3 100644 --- a/apps/desktop/src/lib/artifact-detect.test.ts +++ b/apps/desktop/src/lib/artifact-detect.test.ts @@ -78,6 +78,13 @@ describe('detectArtifact', () => { expect(detectArtifact('markdown', longCode(80))).toBeNull() expect(detectArtifact('mermaid', longCode(80))).toBeNull() }) + + it('leaves rich-renderer fences alone however long they get', () => { + // Detection runs before the rich-fence registry, so a long `listing` set + // (or any renderer-owned language) would otherwise be stolen by the code + // card and never render as its own component. + expect(detectArtifact('listing', longCode(200))).toBeNull() + }) }) describe('artifactSlug', () => { diff --git a/apps/desktop/src/lib/artifact-detect.ts b/apps/desktop/src/lib/artifact-detect.ts index 464b92b6a9..8a25234103 100644 --- a/apps/desktop/src/lib/artifact-detect.ts +++ b/apps/desktop/src/lib/artifact-detect.ts @@ -34,11 +34,15 @@ const CODE_MIN_CHARS = 3000 const HTML_LANGUAGES = new Set(['html', 'htm', 'xhtml']) // Languages whose fences are never artifacts: prose-ish, terminal output, and -// the fences already owned by richer renderers (mermaid diagrams, small svg). +// the fences already owned by richer renderers (mermaid diagrams, small svg, +// listing cards). Artifact detection runs BEFORE the rich-fence registry, so a +// language that has its own renderer must opt out here or a long enough fence +// gets promoted to a code card and never reaches it. const NON_ARTIFACT_LANGUAGES = new Set([ '', 'console', 'diff', + 'listing', 'log', 'logs', 'markdown',