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
609 changes: 477 additions & 132 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/.vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
!webview-ui/build/assets/*.js
!webview-ui/build/assets/*.ttf
!webview-ui/build/assets/*.css
!webview-ui/build/assets/fonts/*.woff
!webview-ui/build/assets/fonts/*.woff2
!webview-ui/build/assets/fonts/*.ttf

# Include default themes JSON files used in getTheme
!integrations/theme/default-themes/**
Expand Down
4 changes: 2 additions & 2 deletions src/core/webview/ClineProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ export class ClineProvider

const csp = [
"default-src 'none'",
`font-src ${webview.cspSource}`,
`font-src ${webview.cspSource} data:`,
`style-src ${webview.cspSource} 'unsafe-inline' https://* http://${localServerUrl} http://0.0.0.0:${localPort}`,
`img-src ${webview.cspSource} https://storage.googleapis.com https://img.clerk.com data:`,
`media-src ${webview.cspSource}`,
Expand Down Expand Up @@ -752,7 +752,7 @@ export class ClineProvider
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; font-src ${webview.cspSource}; style-src ${webview.cspSource} 'unsafe-inline'; img-src ${webview.cspSource} https://storage.googleapis.com https://img.clerk.com data:; media-src ${webview.cspSource}; script-src ${webview.cspSource} 'wasm-unsafe-eval' 'nonce-${nonce}' https://us-assets.i.posthog.com 'strict-dynamic'; connect-src https://openrouter.ai https://api.requesty.ai https://us.i.posthog.com https://us-assets.i.posthog.com;">
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; font-src ${webview.cspSource} data:; style-src ${webview.cspSource} 'unsafe-inline'; img-src ${webview.cspSource} https://storage.googleapis.com https://img.clerk.com data:; media-src ${webview.cspSource}; script-src ${webview.cspSource} 'wasm-unsafe-eval' 'nonce-${nonce}' https://us-assets.i.posthog.com 'strict-dynamic'; connect-src https://openrouter.ai https://api.requesty.ai https://us.i.posthog.com https://us-assets.i.posthog.com;">
<link rel="stylesheet" type="text/css" href="${stylesUri}">
<link href="${codiconsUri}" rel="stylesheet" />
<script nonce="${nonce}">
Expand Down
5 changes: 5 additions & 0 deletions webview-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"fzf": "^0.5.2",
"i18next": "^25.0.0",
"i18next-http-backend": "^3.0.2",
"katex": "^0.16.11",
"knuth-shuffle-seeded": "^1.0.6",
"lru-cache": "^11.1.0",
"lucide-react": "^0.518.0",
Expand All @@ -59,7 +60,9 @@
"react-use": "^17.5.1",
"react-virtuoso": "^4.7.13",
"rehype-highlight": "^7.0.0",
"rehype-katex": "^7.0.1",
"remark-gfm": "^4.0.1",
"remark-math": "^6.0.0",
"remove-markdown": "^0.6.0",
"shell-quote": "^1.8.2",
"shiki": "^3.2.1",
Expand All @@ -80,6 +83,8 @@
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.2.0",
"@testing-library/user-event": "^14.6.1",
"@types/jest": "^29.0.0",
"@types/katex": "^0.16.7",
"@types/node": "20.x",
"@types/react": "^18.3.23",
"@types/react-dom": "^18.3.5",
Expand Down
30 changes: 29 additions & 1 deletion webview-ui/src/components/common/MarkdownBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import React, { memo, useEffect } from "react"
import { useRemark } from "react-remark"
import styled from "styled-components"
import { visit } from "unist-util-visit"
import rehypeKatex from "rehype-katex"
import remarkMath from "remark-math"

import { vscode } from "@src/utils/vscode"
import { useExtensionState } from "@src/context/ExtensionStateContext"
Expand Down Expand Up @@ -75,6 +77,31 @@ const StyledMarkdown = styled.div`
);
}

/* KaTeX styling */
.katex {
font-size: 1.1em;
color: var(--vscode-editor-foreground);
font-family: KaTeX_Main, "Times New Roman", serif;
line-height: 1.2;
white-space: normal;
text-indent: 0;
}

.katex-display {
display: block;
margin: 1em 0;
text-align: center;
padding: 0.5em;
overflow-x: auto;
overflow-y: hidden;
background-color: var(--vscode-textCodeBlock-background);
border-radius: 3px;
}

.katex-error {
color: var(--vscode-errorForeground);
}

font-family:
var(--vscode-font-family),
system-ui,
Expand Down Expand Up @@ -126,6 +153,7 @@ const MarkdownBlock = memo(({ markdown }: MarkdownBlockProps) => {
const [reactContent, setMarkdown] = useRemark({
remarkPlugins: [
remarkUrlToLink,
remarkMath,
() => {
return (tree) => {
visit(tree, "code", (node: any) => {
Expand All @@ -138,7 +166,7 @@ const MarkdownBlock = memo(({ markdown }: MarkdownBlockProps) => {
}
},
],
rehypePlugins: [],
rehypePlugins: [rehypeKatex as any],
rehypeReactOptions: {
components: {
a: ({ href, children }: any) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ describe("mergeExtensionState", () => {
experiments: {
powerSteering: true,
marketplace: false,
concurrentFileReads: true,
disableCompletionCommand: false,
concurrentFileReads: true,
multiFileApplyDiff: true,
} as Record<ExperimentId, boolean>,
}
Expand All @@ -237,8 +237,8 @@ describe("mergeExtensionState", () => {
expect(result.experiments).toEqual({
powerSteering: true,
marketplace: false,
concurrentFileReads: true,
disableCompletionCommand: false,
concurrentFileReads: true,
multiFileApplyDiff: true,
})
})
Expand Down
1 change: 1 addition & 0 deletions webview-ui/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
@import "tailwindcss/theme.css" layer(theme);
@import "./preflight.css" layer(base);
@import "tailwindcss/utilities.css" layer(utilities);
@import "katex/dist/katex.min.css";

@plugin "tailwindcss-animate";

Expand Down
12 changes: 11 additions & 1 deletion webview-ui/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,17 @@ export default defineConfig(({ mode }) => {
// Default naming for other chunks, ensuring uniqueness from entry
return `assets/chunk-[hash].js`
},
assetFileNames: `assets/[name].[ext]`,
assetFileNames: (assetInfo) => {
if (
assetInfo.name &&
(assetInfo.name.endsWith(".woff2") ||
assetInfo.name.endsWith(".woff") ||
assetInfo.name.endsWith(".ttf"))
) {
return "assets/fonts/[name][extname]"
}
return "assets/[name][extname]"
},
manualChunks: (id, { getModuleInfo }) => {
// Consolidate all mermaid code and its direct large dependencies (like dagre)
// into a single chunk. The 'channel.js' error often points to dagre.
Expand Down
Loading