Files
anidev-design-system/patterns/WORKSPACES.md
T

26 lines
4.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# SSH console and log reader
Both workspaces use the approved Dock layout and local demo data. The terminal surface is pure black (#000) in both UI themes; its foreground and ANSI colors remain light enough for that surface. No SSH login, private key or host command execution is implemented.
## Terminal
`components/ssh-console.js` mounts xterm.js 6.0.0, addon-fit 0.11.0 and addon-search 0.16.0. The official MIT distributions and licenses are copied into `vendor/xterm/` by `node scripts/vendor-terminal.mjs`; there is no CDN dependency. `patterns/demo-pty.js` supplies a local shell fixture with line editing, history, completion, signals, an alternate-screen pager/top and streaming output.
Replace the `createTransport` option of `mountSsh` to connect a project backend. The factory receives `{host, cols, rows, write, onClose}` and returns `{send(data), resize(cols, rows), close(), dispose()}`. Forward `Terminal.onData` unchanged to the server PTY; forward server output to `write`. Input includes control characters and escape sequences, not just printable text. Resize the actual server PTY. The backend owns SSH host validation, authentication, authorization, credentials and session lifetime. The demo adapter never evaluates JavaScript or invokes a host shell.
Keyboard events are intercepted only by a focused, enabled terminal. xterm encodes arrows, Home/End, Delete, Tab/Shift+Tab, F1–F12, Ctrl and Alt sequences. Ctrl+C/D/Z are terminal signals, not app commands. Ctrl+K goes to the terminal instead of the Dock command palette. Ctrl+Shift+C copies a selection; Ctrl+Shift+V and Shift+Insert use the browser's native paste event. macOS Cmd+C/V/A preserve copy/paste/select-all. The toolbar also provides clipboard actions. Bracketed paste is enabled by the PTY; the demo flattens pasted newlines and waits for Enter rather than auto-executing pasted commands.
Ctrl+Shift+F opens output search. Ctrl+Shift+M disables input and focuses the toolbar so Tab can leave the terminal. Enable input again with the button. Focus loss and unmount release Keyboard Lock. The fullscreen action requests Keyboard Lock only if supported; denial falls back to regular terminal key capture. Browser/OS-reserved combinations cannot be guaranteed in an ordinary tab. Holding Esc remains the browser's fullscreen escape route. Terminal events do not bubble into app shortcuts. Components outside the terminal retain native keyboard behavior.
References: [xterm Terminal API](https://xtermjs.org/docs/api/terminal/classes/terminal/), [Keyboard Lock and its fullscreen/OS limitations](https://developer.chrome.com/docs/capabilities/web-apis/keyboard-lock).
## Log reader
`components/log-reader.js` provides level/source/literal-text filters, highlighted matches, stream pause/resume with a bounded backlog, follow mode, older/newer windows, event JSON, clipboard and filtered `.log` export. Opening an event or scrolling up stops following; the follow button or Ctrl+End jumps to the latest data. Ctrl+F focuses the local search. Arrow keys move through rows and Enter opens an event; Escape closes details and restores row focus.
Open local `.log`, `.txt` and JSONL files up to 8 MB. File contents stay in the browser. Text and JSON fields are escaped before rendering. At most 2,000 records and a separate 2,000-event paused backlog are retained; at most 150 rows are rendered at once. Search/export operate on retained records, not only the visible page. `parseLogText` supports JSONL and `timestamp LEVEL source message` text. Malformed JSON is treated as plain text. File mode stops the synthetic feed; the demo stream button explicitly returns to demo data.
Both mount functions return cleanup handlers. The app disposes them on every route change, including observers, timers, event listeners, terminal instances and keyboard lock. Loading an async terminal after navigation cannot revive a disposed page. Replacing the demo feed with a real source should retain these limits and cleanup rules.
The xterm runtime is an intentional dependency: a real terminal parser/keyboard encoder replaces ad-hoc key handling. No framework or CDN was added. The vendor manifest records exact package versions and the MIT licenses are distributed alongside the runtime.