mirror of
https://github.com/pterodactyl/panel.git
synced 2026-12-01 20:05:48 -05:00
## Description This PR resolves several visual artifacts, resize desync issues, and edge-case rendering glitches with the Ghostty-web terminal integration in the server console: ### 1. Reliable Terminal Resizing & Layout Transitions - **Bypass `FitAddon` throttle lock (`unlockFitResize`)**: Ghostty's `FitAddon` sets a 50ms `_isResizing` lock via `setTimeout`, which silently dropped subsequent `fit()` calls triggered immediately after layout/route transitions. Unlocking this ensures post-layout re-fits are never lost. - **WASM Line Bounds & Viewport Clamping (`patchWasmTerminal`)**: - Guards against potential null/undefined line reads from the WASM terminal (`getLine` and `getScrollbackLine` fallback to empty arrays). - Synchronizes and clamps viewport coordinates during `term.resize` to prevent scroll desync and jumps when resizing windows or toggling devtools. ### 2. Precise Font Metrics & Clean Canvas Redraws - **Canvas-based Font Measurement (`measureTerminalFont`)**: Accurately computes font cell width, baseline, ascent, and descent using a 2D canvas context instead of relying on rough estimates. - **Artifact Prevention in `adjustRendering`**: Automatically flushes and repaints the canvas background with the theme background color when viewport offsets change or full redraws occur, eliminating ghosting/text smearing. ### 3. Clear & Output Lifecycle Improvements - **Terminal Clear Handling**: Extends `preserveScrollPositionOnWrite` to intercept `term.clear()`, issuing ANSI reset escapes (`\x1b[2J\x1b[3J\x1b[H`) and resetting viewport positions. - **Prefix Newlines**: Normalizes `term.writeln` to ensure initial logs and scrollback buffer transitions don't overwrite the first line. ### 4. Layout & Styling Polish - Replaced negative margin gutter compensation hacks (`-ml-4 w-[calc(100%+2rem)]`) in `Terminal.tsx` with clean `w-full` and `overflow-hidden`. - Ensured consistent container and input rounding across mobile and desktop breakpoints. --- ## Changes Overview - `resources/scripts/components/server/console/useTerminal.ts`: Added `unlockFitResize`, `measureTerminalFont`, `patchWasmTerminal`, viewport clamping, canvas clear on redraw, and clear handling. - `resources/scripts/themes/classic/views/server/console/Terminal.tsx`: Cleaned container classes and removed mobile negative-margin overrides.