Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions GOVERNANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,11 @@ For significant changes that affect users or the overall architecture:
### Path to Core Maintainer Status

1. **Demonstrate Expertise**

- Make significant contributions over 6+ months
- Show deep understanding of the codebase
- Provide thoughtful code reviews

2. **Show Leadership**

- Help onboard new contributors
- Participate actively in technical discussions
- Demonstrate good judgment in contentious situations
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { describe, expect, it } from 'vitest';
import { stripCodeFenceFromArtifact } from './Markdown';
import { stripCodeFenceFromArtifact } from '~/utils/markdown-utils';

describe('stripCodeFenceFromArtifact', () => {
it('should remove code fences around artifact element', () => {
Expand Down
45 changes: 1 addition & 44 deletions app/components/chat/Markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import ReactMarkdown, { type Components } from 'react-markdown';
import type { BundledLanguage } from 'shiki';
import { createScopedLogger } from '~/utils/logger';
import { allowedHTMLElements, rehypePlugins, remarkPlugins } from '~/utils/markdown';
import { stripCodeFenceFromArtifact } from '~/utils/markdown-utils';
import { Artifact } from './Artifact';
import { CodeBlock } from './CodeBlock';

Expand Down Expand Up @@ -76,47 +77,3 @@ export const Markdown = ({ children, html = false, limitedMarkdown = false }: Ma
</ReactMarkdown>
);
};

/**
* Removes code fence markers (```) surrounding an artifact element while preserving the artifact content.
* This is necessary because artifacts should not be wrapped in code blocks when rendered for rendering action list.
*
* @param content - The markdown content to process
* @returns The processed content with code fence markers removed around artifacts
*
* @example
* // Removes code fences around artifact
* const input = "```xml\n<div class='__liblabArtifact__'></div>\n```";
* stripCodeFenceFromArtifact(input);
* // Returns: "\n<div class='__liblabArtifact__'></div>\n"
*
* @remarks
* - Only removes code fences that directly wrap an artifact (marked with __liblabArtifact__ class)
* - Handles code fences with optional language specifications (e.g. ```xml, ```typescript)
* - Preserves original content if no artifact is found
* - Safely handles edge cases like empty input or artifacts at start/end of content
*/
export const stripCodeFenceFromArtifact = (content: string) => {
if (!content || !content.includes('__liblabArtifact__')) {
return content;
}

const lines = content.split('\n');
const artifactLineIndex = lines.findIndex((line) => line.includes('__liblabArtifact__'));

// Return original content if artifact line not found
if (artifactLineIndex === -1) {
return content;
}

// Check previous line for code fence
if (artifactLineIndex > 0 && lines[artifactLineIndex - 1]?.trim().match(/^```\w*$/)) {
lines[artifactLineIndex - 1] = '';
}

if (artifactLineIndex < lines.length - 1 && lines[artifactLineIndex + 1]?.trim().match(/^```$/)) {
lines[artifactLineIndex + 1] = '';
}

return lines.join('\n');
};
1 change: 0 additions & 1 deletion app/lib/prisma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { PrismaClient } from '@prisma/client';
import { env } from '~/env/server';

declare global {
// eslint-disable-next-line no-var
var prisma: PrismaClient;
}

Expand Down
244 changes: 0 additions & 244 deletions app/lib/runtime/__snapshots__/message-parser.spec.ts.snap

This file was deleted.

Loading