renderer-terminal
Skill9 starsChanged 5 days agoMITView on GitHub
xterm.js patterns in Walph (TerminalPanel, terminalBus buffering, fit/resize, focus, lifecycle with the pty in main). Use when creating or reviewing anything in src/renderer/src/components/TerminalPanel.tsx, lib/terminalBus.ts or terminal features.
In this repository17 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- app-testingSkill
- claude-panelSkill
- commands-settingsSkill
- containersSkill
- debuggerSkill
- files-git-searchSkill
- i18nSkill
- lspSkill
- main-ipcSkill
- main-processesSkill
- packaging-releaseSkill
- renderer-componentsSkill
- renderer-editorSkill
- renderer-storeSkill
- renderer-stylesSkill
- workspacesSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 23
Never unmount or move them between containers (the xterm would be recreated).
- Very specific: line 24
Only fit/resize when the host has a size: if (host.offsetWidth === 0 || host.offsetHeight === 0) return.
- Very specific: line 25
Every useEffect that creates xterm resources disposes them: observer.disconnect(), input.dispose(), detach(), term.dispose().
- Very specific: line 42
Every link (file, URL, OSC 8) opens only with ⌘/Ctrl-click.
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Terminal (components/TerminalPanel.tsx, lib/terminalBus.ts)
Data flow
pty (main, terminal/create.ts) ──terminal:data──▶ terminalBus ──▶ TerminalView (xterm.write)
TerminalView (xterm.onData) ──terminal:write──▶ pty
ResizeObserver → FitAddon.fit() ──terminal:resize──▶ pty.resize
pty exit ──terminal:exit──▶ App → removeTerminal(id)Rules
- Never subscribe to
window.api.terminal.onDatainside a component. The shell prints its prompt before the component mounts;terminalBusbuffers output per terminal untilattachTerminal(id, listener)is called. - Terminal list/active id live in the store (
createTerminal,killTerminal,removeTerminal). - All
TerminalViews (.terminal-pane) stay mounted in ONE flex container; panes outside the active group usehidden. Never unmount or move them between containers (the xterm would be recreated). - Only fit/resize when the host has a size:
if (host.offsetWidth === 0 || host.offsetHeight === 0) return. - Every
useEffectthat creates xterm resources disposes them:observer.disconnect(),input.dispose(),detach(),term.dispose(). - Addons are loaded right after
new Terminal()and disposed with it. WebGL loads only afteropenand with a measured host (retried from the ResizeObserver), perterminal.gpuAcceleration(live);onContextLossdisposes it (xterm 6 falls back to the DOM renderer); dispose it beforeterm.dispose()(browsers cap live GL contexts).
Groups, titles, links, find
TerminalInfo={ id, groupId, title, customTitle?, profile }; one panel tab per group (lib/terminalGroups.ts:insertAfter,removeTerminalFrom,groupLabel).splitTerminalcreates beside the active one (same profile, samegroupId); a pane'sonFocusCapturemakes it active. Title shown =customTitle ?? title;onTitleis subscribed inApp(setTerminalTitle, early titles wait inpendingTitles). Rename =startRenameTerminal(inline input in the tab).- Focus goes through
requestFocus('terminal')(focusBridge.ts: maximize, rename, closing find);TerminalPanelregisters the target withuseFocusTarget('terminal')and the returned counter re-runs its focus effect. - Registry of live xterm/search addons:
components/terminalRegistry.ts. - Links (
components/terminalLinks.ts):WebLinksAddon+ a link provider for files; text/regex inlib/terminalLinks.ts(joins wrapped rows, maps string index to cells, URLs excluded); validated on hover withapi.terminal.resolveLink; opens only with ⌘/Ctrl-click (openFile, Reveal line 1-based, column 0-based). - Every link (file, URL, OSC 8) opens only with ⌘/Ctrl-click; URLs only
http(s)/mailto(also filtered in main'ssetWindowOpenHandler). File links are resolved by main (terminal:resolveLink: shell cwd → window folder → initial cwd), never by the renderer. SearchAddondecorations needallowProposedApi: true.- Profiles (
terminal.profiles,terminal.defaultProfile) are user-only: the renderer sends only the profile name and main resolves it (terminal/resolveProfile.ts). - Find:
terminalFindIdin the store (the terminal whose find is open),TerminalFind.tsxinside the pane (a second ⌘F refocuses the field throughrequestFocus('terminalFind:<id>'));.terminal-findcounts asterminalFocus. - Layout:
panelPosition/panelWidthin the session;panelMaximizedis transient (editorhidden, stays mounted).
// ✅ CORRECT
const detach = attachTerminal(id, (data) => term.write(data))
return () => detach()
// ❌ WRONG — loses the initial prompt and leaks a listener per remount
useEffect(() => window.api.terminal.onData((tid, d) => tid === id && term.write(d)), [])Testing gotchas
- Synthetic
insertTextwith\ndoes not submit in xterm — send a real Enter key (cdp.mjs key Enter). - Text typed before the prompt appears gets echoed twice — wait for the prompt first.
- With WebGL on,
.xterm-rowsis empty: tests that read terminal text setterminal.gpuAcceleration: "off".
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

