try to fix code-server claude thing.
Firefox patches: CORS crossorigin on stylesheet link, Shift+Enter line break via insertLineBreak + innerText, nix-ld for Claude Code node binary. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
d92c327cdf
commit
458be246f0
1 changed files with 18 additions and 7 deletions
|
|
@ -33,14 +33,25 @@
|
|||
# Make the claude CLI available in code-server's integrated terminal.
|
||||
environment.systemPackages = [ pkgs.claude-code ];
|
||||
|
||||
# Patch the Claude Code extension to add crossorigin="anonymous" to its
|
||||
# stylesheet link — required for Firefox due to stricter CORS handling.
|
||||
# Idempotent: sed won't match after the first apply.
|
||||
# Patch the Claude Code extension for Firefox compatibility.
|
||||
# Idempotent: sed patterns won't match after first apply.
|
||||
system.activationScripts.claude-code-firefox-fix.text = ''
|
||||
for f in /home/fred/.local/share/code-server/extensions/anthropic.claude-code-*/extension.js; do
|
||||
[ -f "$f" ] && ${pkgs.gnused}/bin/sed -i \
|
||||
's|<link href="''${q}" rel="stylesheet">|<link href="''${q}" rel="stylesheet" crossorigin="anonymous">|' \
|
||||
"$f"
|
||||
for d in /home/fred/.local/share/code-server/extensions/anthropic.claude-code-*/; do
|
||||
[ -d "$d" ] || continue
|
||||
# CORS fix: Firefox needs crossorigin on the stylesheet link.
|
||||
${pkgs.gnused}/bin/sed -i \
|
||||
's|rel="stylesheet">|rel="stylesheet" crossorigin="anonymous">|g' \
|
||||
"$d/extension.js"
|
||||
# Firefox contentEditable="plaintext-only" doesn't visually render
|
||||
# newlines on Shift+Enter. Two fixes:
|
||||
# 1. Intercept Shift+Enter to explicitly insert a line break.
|
||||
${pkgs.gnused}/bin/sed -i \
|
||||
's|if(d.key==="Enter"&&!d.shiftKey)|if(d.key==="Enter"\&\&d.shiftKey){d.preventDefault();document.execCommand("insertLineBreak");T7();return}if(d.key==="Enter"\&\&!d.shiftKey)|' \
|
||||
"$d/webview/index.js"
|
||||
# 2. Read innerText (converts <br> to \n) instead of textContent (ignores <br>).
|
||||
${pkgs.gnused}/bin/sed -i \
|
||||
's|t\.current?.textContent|t.current?.innerText|g' \
|
||||
"$d/webview/index.js"
|
||||
done
|
||||
'';
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue