the file manager only found out a file was over the node's upload limit
after sending the whole thing. the client server resource now exposes
the node's `upload_size` and `useFileUploader` rejects bigger files
before any bytes go out. added `useFileUploader.spec.tsx`, the api
fixtures have the new field.
Files with an empty MIME type were incorrectly rejected as folders when
their size was 0 or exactly 4096 bytes. One matching file also blocked
the entire upload batch.
This removes the MIME type and size heuristic from `useFileUploader` and
checks dropped items using `webkitGetAsEntry()` instead. Actual
directories remain rejected when the browser provides directory entry
information.
## 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.
Fixes some internal Discord discussions.
Most of this works around gaps in ghostty-web 0.4.0's selection and link
handling. Several fixes reach into its private internals, so the
dependency is pinned to `0.4.0` now instead of free spinning.
Ghostty seems to be an overall regression as a library over XTerm, below
are some internal hook ins to provide vital functionality back to the
console that v1 originally had.
### Selection
- Double-click selects the word on the line you clicked. Ghostty's
`getWordAtCell` reads the live screen row whatever the scroll position,
so once you'd scrolled up it picked a word from a different line.
- Triple-click now selects and copies the whole line, including every
row it wraps onto.
- Copying no longer puts a line break where a line only wrapped.
Ghostty's `getSelection` puts `\n` between every row, which broke copied
URLs and commands. The fix covers Ctrl/Cmd+C, drag-copy, right-click
copy and triple-click. If a row wrapped at a space, the space is kept.
### Links
- URLs that wrap across rows are detected as one link, and hovering any
part of them underlines the whole URL.
- Only `http:` and `https:` links can be opened. Console output comes
from the game server, so a `javascript:`, `file:` or `ssh:` link in the
output is ignored rather than passed to `window.open`.
### Focus
- The page no longer scrolls when the console takes focus. Ghostty
focuses the console on open and its hidden textarea on every press; both
now focus with `preventScroll`.