Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add jiushiwon/wg-skills --skill xterm-js-rendering-pitfallsgit clone --depth 1 https://github.com/jiushiwon/wg-skillsWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/jiushiwon/wg-skills/xterm-js-rendering-pitfalls)<a href="https://agentmods.dev/skills/jiushiwon/wg-skills/xterm-js-rendering-pitfalls"><img src="https://agentmods.dev/badge/skills/jiushiwon/wg-skills/xterm-js-rendering-pitfalls/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/jiushiwon/wg-skills/xterm-js-rendering-pitfalls"><img src="https://agentmods.dev/badge/skills/jiushiwon/wg-skills/xterm-js-rendering-pitfalls.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00203 | $0.02602 |
| Opus 5.5 | $0.00081 | $0.01041 |
| Sonnet 5.5 | $0.00041 | $0.00520 |
| Haiku 4.5 | $0.00020 | $0.00260 |
Grade A, and why
xterm-js-rendering-pitfalls scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 24d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 234 lines — stays where its author put it; the contents beside it link to each section on GitHub.
xterm.js 渲染坑合集
本类项目(Electron + SSH/本地终端、底层用 @xterm/xterm 6.x + @xterm/addon-fit)一整天的调试
最终归纳出 4 个反复出现的坑——都和"xterm 是 canvas 渲染"+"CSS 变量和 React state 的盲区"有关。
坑 1:fontFamily 传 var(--font-mono) → vi 越界、gg/G 失效
现象
- 终端字符排到视口外
- vi 里
gg(到头)/G(到尾)看着"没反应" - 内容已经铺满屏幕却到不了头尾
根因
- xterm 用 canvas 的
ctx.font渲染文字,ctx.font不支持 CSS 变量 'var(--font-mono)'对 canvas 是非法值 → canvas 回退到浏览器默认字体- 但
fit()测量单元尺寸时走的是 DOMgetComputedStyle,能解析var(),按 JetBrains Mono 算 - 两个字体字形/字距不一致 → 终端"逻辑 rows/cols"和"实际显示"对不上
- 远端 vi 按
TIOCSWINSZ拿到的窗口尺寸和真实可见区域错位 → vi 屏幕坐标算错
修复
function resolveMonoFont(): string {
try {
const v = getComputedStyle(document.documentElement)
.getPropertyValue('--font-mono').trim()
if (v) return v
} catch { /* ignore */ }
return "'JetBrains Mono', 'Courier New', monospace"
}
// 创建 Terminal 时
new Terminal({
fontFamily: resolveMonoFont(), // ← 运行期解析后的字面量字体栈
...
})
关键:传字面量字符串 'JetBrains Mono', monospace 让 canvas 与测量用同一字体,尺寸/对齐才一致。
坑 2:xterm 主题切换不生效——state 孤岛
现象
- 全局
<html data-theme="dark">切了,其他 UI 区域都跟随深色 - 但 xterm 画布仍然是白色(light 配色)
根因
最容易掉进的写法:
// ThemeToggle.tsx
export function useTheme() {
const [theme, setThemeState] = useState<Theme>(readStoredTheme)
...
return { theme, setTheme }
}
// SshTerminal.tsx
const { theme } = useTheme()
useEffect(() => {
term.options.theme = getXtermTheme(theme)
}, [theme])
致命陷阱:useTheme() 每个调用方各自 useState,主题切换不会跨组件传播——
ThemeToggle点 dark 时它自己变 dark,但SshTerminal自己的useState还是 light<html data-theme>切了(CSS 变量全局生效,其他区域跟随)- 但
SshTerminal的 effect 没被触发(依赖的 theme state 没变) term.options.theme仍是 light,画布白底
修复(架构级 lift state up)
把主题 state 提升到全局 Context/Reducer,所有组件共享:
// store/appContext.tsx
interface AppState {
...,
theme: Theme
}
// reducer
case 'SET_THEME': return { ...state, theme: action.payload }
// AppProvider 唯一持有
const toggleTheme = useCallback(() => {
dispatch({ type: 'SET_THEME', payload: state.theme === 'light' ? 'dark' : 'light' })
}, [state.theme])
// 各组件用 useApp() 拿
const { theme, toggleTheme } = useApp()
What ships with it
1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 24d ago Changed 2b4f293d92f6
- 25d ago Changed · -17 lines 5667e02c9be7
- 2mo ago First seen · 251 lines · 203 tokens per session scan A 6cc496305ff5
xterm-js-rendering-pitfalls is a skill published in the GitHub repository jiushiwon/wg-skills (154 stars, last pushed 7d ago), licensed Apache-2.0. It adds 203 tokens to every session and 2,602 once invoked, about $0.0008 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-30.
xterm-js-rendering-pitfalls compared with skills from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| xterm-js-rendering-pitfallsjiushiwon/wg-skills | Skill | 154 | 7d ago | Apache-2.0 | A | 203 | Claude Code, Codex |
| systematic-debuggingopen-metadata/OpenMetadata | Skill | 16k | today | Apache-2.0 | A | 37 | Claude Code |
| log-error-digestzebbern/claude-code-guide | Skill | 4.7k | today | MIT | A | 71 | Claude Code, Codex |
| observability-audit-sessionsIBM/mcp-context-forge | Skill | 4.9k | today | Apache-2.0 | A | 64 | Claude Code, Codex |
| cwv-optimizeradobe/skills | Skill | 342 | today | Apache-2.0 | A | 112 | Claude Code |
| ci-fixersipyourdrink-ltd/bernstein | Skill | 1.2k | today | Apache-2.0 | A | 15 | Claude Code, Codex |
| diagnosing-missing-recordingsPostHog/posthog | Skill | 41k | today | none | A | 76 | Claude Code, Codex |