claude-code - 💡(How to fix) Fix [BUG] Codicon font blocked by webview CSP font-src — diff markers render as tofu on 2.1.116 (extends #26836) [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#51677Fetched 2026-04-22 07:55:50
View on GitHub
Comments
0
Participants
1
Timeline
8
Reactions
2
Author
Participants
Timeline (top)
labeled ×4mentioned ×2subscribed ×2

Error Message

Error Messages/Logs

document.fonts reports the codicon font in error state: // => [{ status: "error", family: "codicon" }] // => ["error"]

Root Cause

File: C:\Users\<user>\.vscode\extensions\anthropic.claude-code-<ver>-win32-x64\webview\index.css

@font-face {
  font-family: codicon;
  font-display: block;
  src: url(data:font/ttf;base64,AAEAAAALAIAAAwAw...);  /* ← blocked by CSP font-src */
  font-weight: normal;
  font-style: normal;
}

The embedded TTF is valid (decoded and parsed: sfnt 0x00010000, 462 glyphs, cmap format 12 covers U+EA60 .. U+F101 with all expected codicon codepoints present). The problem is purely CSP — the webview's CSP meta tag defines font-src as an allowlist that excludes data:.

Fix Action

Fix / Workaround

This issue was originally reported in #26836 (auto-closed by the stale-bot despite multiple confirmations of it still reproducing). This report adds:

  • A definitive root-cause trace using DevTools FontFace API
  • Verification that the embedded codicon TTF is valid (all 462 PUA glyphs present via cmap fmt 12)
  • A verified, working workaround
  • Two concrete proposed fixes for the extension

Working Workaround (verified)

Patch webview/index.css to prepend local() sources so Chromium uses a system-installed codicon font instead of the blocked data: URI:

Code Example

AFFECTED RESOURCES
4 directives
Resource    Status     Directive    Source location
data        blocked    font-src     index.html?id=4cedd4...:0
data        blocked    font-src     index.html?id=96853a...:0
data        blocked    font-src     index.html?id=b44a3b...:0
data        blocked    font-src     index.html?id=fe4090...:0

---

[...document.fonts].filter(f => f.family === 'codicon')
// => [{ status: "error", family: "codicon" }]

---

[...document.fonts].filter(f => f.family === 'codicon').map(f => f.status)
   // => ["error"]

---

@font-face {
  font-family: codicon;
  font-display: block;
  src: url(data:font/ttf;base64,AAEAAAALAIAAAwAw...);  /* ← blocked by CSP font-src */
  font-weight: normal;
  font-style: normal;
}

---

@font-face {
  font-family: codicon;
  font-display: block;
  src: local('codicon'), url(data:font/ttf;base64,AAEA...);  /* ← added local() first */
  ...
}
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues — this extends #26836 which was auto-closed for inactivity but remains unfixed on current release
  • This is a single bug report
  • I am using the latest version of Claude Code (2.1.116)

What's Wrong?

In the Claude Code VS Code Extension chat panel, every diff line renders with an empty tofu square (☐) in the gutter instead of the proper codicon + / glyphs. Root cause: the extension's webview bundles the codicon font as a data:font/ttf;base64,... source in @font-face, but the webview's Content Security Policy does not include data: in its font-src directive, so Chromium silently rejects the font.

This issue was originally reported in #26836 (auto-closed by the stale-bot despite multiple confirmations of it still reproducing). This report adds:

  • A definitive root-cause trace using DevTools FontFace API
  • Verification that the embedded codicon TTF is valid (all 462 PUA glyphs present via cmap fmt 12)
  • A verified, working workaround
  • Two concrete proposed fixes for the extension

What Should Happen?

.codicon-diff-insert / .codicon-diff-remove elements in the diff view render as + and glyphs from the embedded codicon font.

Error Messages/Logs

DevTools Issues tab shows 4 blocked directives on every diff render:

AFFECTED RESOURCES
4 directives
Resource    Status     Directive    Source location
data        blocked    font-src     index.html?id=4cedd4...:0
data        blocked    font-src     index.html?id=96853a...:0
data        blocked    font-src     index.html?id=b44a3b...:0
data        blocked    font-src     index.html?id=fe4090...:0

document.fonts reports the codicon font in error state:

[...document.fonts].filter(f => f.family === 'codicon')
// => [{ status: "error", family: "codicon" }]

The CSS injection itself works — .codicon-diff-insert::before { content: '<PUA char>' } is correctly applied at runtime (verified via getComputedStyle(el, '::before').content), the character is valid (U+EA60 / U+EB3B), but the font to render it failed to load.

Steps to Reproduce

  1. Install Claude Code VS Code Extension v2.1.116 on Windows 11.
  2. Open any project in VS Code, start Claude Code, ask it to edit a file (any Edit/Write tool call triggers the diff view in the chat panel).
  3. Every diff line in the result renders with a tofu square instead of +/ glyphs next to it.
  4. In VS Code: Ctrl+Shift+PDeveloper: Open Webview Developer ToolsIssues tab — see 4 font-src blocked data: violations.
  5. Console:
    [...document.fonts].filter(f => f.family === 'codicon').map(f => f.status)
    // => ["error"]

Root Cause

File: C:\Users\<user>\.vscode\extensions\anthropic.claude-code-<ver>-win32-x64\webview\index.css

@font-face {
  font-family: codicon;
  font-display: block;
  src: url(data:font/ttf;base64,AAEAAAALAIAAAwAw...);  /* ← blocked by CSP font-src */
  font-weight: normal;
  font-style: normal;
}

The embedded TTF is valid (decoded and parsed: sfnt 0x00010000, 462 glyphs, cmap format 12 covers U+EA60 .. U+F101 with all expected codicon codepoints present). The problem is purely CSP — the webview's CSP meta tag defines font-src as an allowlist that excludes data:.

Proposed Fixes (either works)

Option A — Relax the webview CSP. Add data: to the font-src directive of the <meta http-equiv="Content-Security-Policy"> set when constructing the webview HTML. Minimal change, single-line diff.

Option B — Host the font as a webview-local resource. Ship codicon.ttf as an actual file under webview/ (or resources/) and reference it via vscode-resource: / asWebviewUri(), then add the corresponding path to font-src. This is the cleaner long-term solution and matches how VS Code Core serves codicons to its built-in webviews.

Working Workaround (verified)

Patch webview/index.css to prepend local() sources so Chromium uses a system-installed codicon font instead of the blocked data: URI:

@font-face {
  font-family: codicon;
  font-display: block;
  src: local('codicon'), url(data:font/ttf;base64,AAEA...);  /* ← added local() first */
  ...
}

Plus install the codicon font system-wide (decoded from the extension's own embedded @font-face%LOCALAPPDATA%\Microsoft\Windows\Fonts\codicon.ttf, registered in HKCU\Software\Microsoft\Windows NT\CurrentVersion\Fonts, loaded via Win32 AddFontResourceW + WM_FONTCHANGE broadcast).

After VS Code window reload, codicon glyphs render correctly in diff views. local() is not CSP-gated (it doesn't make a network request), so it bypasses the font-src restriction. But this patch is invasive and gets overwritten on every extension update — it's a workaround, not a fix.

Claude Model

N/A (UI rendering bug, not model behavior)

Is this a regression?

Yes — originally reported on 2.1.39 in #26836, still reproduces on 2.1.116.

Last Working Version

Per #26836: last confirmed working in VS Code 1.109.4. Claude Code extension version when it worked: unknown.

Claude Code Version

2.1.116

Platform

Claude.ai (Max subscription)

Operating System

Windows 11 Pro 10.0.26200

Terminal/Shell

VS Code integrated terminal (PowerShell 7)

Additional Information

  • Confirming users on the parent issue (#26836): @MtkN1 on 2.1.109, @jrynlds-pinc on 2.1.116 (2026-04-20).
  • Disabling the bundled CSP or switching to a strict CSP (both recommended by Chromium's Issues panel) would also resolve this, but Option A/B above are the minimal targeted fixes.
  • Unrelated but adjacent observation while inspecting the same webview: Uncaught TypeError: Cannot read properties of undefined (reading 'toUrl') thrown from kv.toUri → kv.asBrowserUri → nP.$loadForeignModule in webview/index.js. Surfaces regularly during diff view init. Filing as a separate issue if it doesn't go away after the font fix.

extent analysis

TL;DR

To fix the issue with codicon glyphs not rendering in the Claude Code VS Code Extension diff view, update the webview's Content Security Policy to include data: in its font-src directive or host the codicon font as a local resource.

Guidance

  1. Verify the root cause: Confirm that the issue is due to the Content Security Policy (CSP) blocking the data: font source by checking the DevTools Issues tab for font-src blocked directives.
  2. Apply a proposed fix: Choose either Option A (relax the webview CSP by adding data: to the font-src directive) or Option B (host the font as a webview-local resource and update the font-src directive accordingly).
  3. Test the fix: After applying the fix, reload the VS Code window and verify that the codicon glyphs render correctly in the diff view.
  4. Consider the working workaround: If a permanent fix is not feasible, apply the working workaround by patching webview/index.css to prepend local() sources and installing the codicon font system-wide.

Example

To implement Option A, update the <meta http-equiv="Content-Security-Policy"> tag in the webview HTML to include data: in the font-src directive:

<meta http-equiv="Content-Security-Policy" content="font-src 'self' data:;">

Notes

The provided working workaround is invasive and may be overwritten on every extension update. A permanent fix is recommended to ensure long-term stability.

Recommendation

Apply Option B — Host the font as a webview-local resource, as it is a cleaner and more sustainable solution that matches how VS Code Core serves codicons to its built-in webviews. This approach also avoids potential security concerns associated with relaxing the CSP.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] Codicon font blocked by webview CSP font-src — diff markers render as tofu on 2.1.116 (extends #26836) [1 participants]