fix: prevent terminal container from overflowing page on desktop

The desktop terminal page sometimes grew an outer scrollbar because the
terminal instance/wrapper/container chain lacked height constraints.
Without min/max-height enforcement, xterm.js's internal viewport could
expand its parent flex/grid track past the available space.

- Add overflow: hidden to .terminal-page.
- Add max-height: 100% and overflow: hidden to .terminal-instance.
- Add max-height: 100% to .terminal-wrapper.
- Add min-height: 0 to .terminal-container.
- Constrain .xterm-viewport to max-height/width 100% so it fills but
  never exceeds its container.

Quality gates: npm run typecheck, npm run lint, npm test -- --run (87 passed).

Refs: openspec/changes/fix-terminal-container-overflow
This commit is contained in:
Developer
2026-06-14 09:07:43 +00:00
parent 84cf423684
commit ac9f7a9299
13 changed files with 75 additions and 17 deletions
@@ -0,0 +1,38 @@
# Fix Terminal Container Overflow on Desktop
## Summary
On the desktop Terminal page, the terminal container sometimes grows taller than its allocated flex/grid track and acquires its own scrollbar, which in turn causes the outer page to scroll. This happens because the flex container chain from `.terminal-page` down to `.terminal-container` is missing `min-height: 0`, allowing a child with intrinsic content height to expand its parent.
## Scope
- `apps/web/src/styles/utilities.css`
- `.terminal-page`
- `.terminal-page-content`
- `.terminal-instance`
- `.terminal-wrapper`
- `.terminal-container`
- `.xterm-viewport`
## Root Cause
`.terminal-page-content` is a flex item that receives its height from the flex parent. In CSS flexbox, a flex item's `min-height` defaults to `auto`, which is based on its content. If the xterm.js viewport/canvas renders taller than the available track, the flex item expands to fit it, pushing the page beyond `100vh` and creating a page-level scrollbar.
## Fix
1. Add `min-height: 0` to every flex/grid item in the terminal layout chain so each level respects the constrained height from its parent.
2. Keep `overflow: hidden` on the wrapper/container so xterm.js's internal viewport is the only scroll surface.
3. Ensure `.terminal-container .xterm-viewport` fills the container and does not expand past it.
## Acceptance Criteria
- [x] Terminal page never shows an outer vertical scrollbar due to terminal content.
- [x] Terminal wrapper and container stay within their allocated track.
- [x] xterm.js internal viewport still scrolls normally.
- [x] Mobile terminal layout is unaffected.
- [x] Quality gates pass: `npm run typecheck`, `npm run lint`, `npm test -- --run`.
## Related
- `openspec/specs/tool-terminal`
- `openspec/changes/fix-tmux-mouse-config`
@@ -0,0 +1,13 @@
# Fix Terminal Container Overflow on Desktop — Tasks
- [x] Discard debug `terminal.tsx` changes from `debug/mobile-terminal-scroll`.
- [x] Create focused branch `fix/terminal-container-overflow` from `dev`.
- [x] Update `utilities.css` to prevent terminal container from overflowing its flex/grid track:
- [x] `.terminal-page`: add `overflow: hidden`.
- [x] `.terminal-instance`: add `max-height: 100%` and `overflow: hidden`.
- [x] `.terminal-wrapper`: add `max-height: 100%`.
- [x] `.terminal-container`: add `min-height: 0`.
- [x] `.terminal-container .xterm-viewport`: add `max-height: 100% !important` and `width: 100% !important`.
- [x] Run `npm run typecheck` and `npm run lint` in `apps/web`.
- [x] Run `npm test -- --run` in `apps/web` (87 passed).
- [x] Update project maps for changed files.