Skip to content

feat(tui): add viewport scrolling for dashboard and detail views - #8169

Merged
stasadev merged 2 commits into
ddev:mainfrom
stasadev:20260220_stasadev_tui_viewport
Feb 22, 2026
Merged

stasadev merged 2 commits into
ddev:mainfrom
stasadev:20260220_stasadev_tui_viewport

Conversation

@stasadev

@stasadev stasadev commented Feb 21, 2026 •

Copy link
Copy Markdown
Member

The Issue

The TUI dashboard project list and detail view had no scrolling support. When there were more projects or content than fit on the terminal screen, the title bar would disappear and content would be cut off. Long URLs, add-on lists, and service lists were also truncated at the terminal edge without any indication.

How This PR Solves The Issue

Used the viewport component from bubbles/viewport instead of implementing custom scroll tracking:

  • Added dashboardViewport and detailViewport fields using viewport.Model
  • Created updateDashboardViewport() helper that rebuilds dashboard content and adjusts scroll position to keep the cursor visible
  • Fixed viewport reset on refresh by removing GotoTop() call in projectsLoadedMsg handler
  • Split view rendering into content builders (buildDashboardContent(), buildDetailContent()) and view renderers that wrap the viewport
  • Added PageUp/PageDown keybindings for faster navigation
  • Viewport initialization in WindowSizeMsg handler with proper sizing
  • Added ansi.Wrap() for proper message wrapping (errors, confirmations) to multiple lines
  • Reorganized dashboard layout with consistent divider placement and spacing
  • Dynamic key references in status messages (e.g., uses m.keys.Start.Help().Key)
  • Add-ons now wrap to multiple lines with proper indentation instead of truncating
  • Services displayed as comma-separated list with wrapping only at service boundaries

The viewport component automatically handles scroll indicators, boundary checking, and smooth scrolling. Title bar and footer remain visible at all times. The scroll position is preserved during auto-refresh.

This PR replaces cyan color with blue for better readability on white background.

Manual Testing Instructions

List scrolling - create enough projects to overflow the terminal:

for name in proj-{01..30}; do
  mkdir -p ~/tmp/$name && cd ~/tmp/$name
  ddev config --auto --project-name=$name
done
ddev tui

Press up/down or pgup/pgdown - the list scrolls and scroll indicators appear. The title bar and footer must remain visible at all times. Wait 5+ seconds and verify the scroll position doesn't jump to top during auto-refresh.

Detail view scrolling - create a project with many URLs, add-ons, and services:

mkdir -p ~/tmp/test-detail && cd ~/tmp/test-detail
ddev config --auto \
  --additional-hostnames=one,two,three,four,five,six,seven,eight,nine,ten
ddev add-on get ddev/ddev-redis
ddev add-on get ddev/ddev-memcached
ddev start
ddev tui

Open the project detail (Enter). Press up/down or pgup/pgdown - content scrolls with indicators, title stays visible. Add-ons wrap across multiple lines with indentation. Services display as comma-separated list with commas at line breaks.

Message wrapping - trigger a long error message to verify it wraps properly instead of being truncated (e.g., docker connection error with long host).

Automated Testing Overview

Updated all existing tests to initialize viewports properly by sending WindowSizeMsg before loading data. Tests verify:

  • Viewport initialization
  • Scroll position management
  • Content building with proper wrapping
  • Filter mode with scrolling

Release/Deployment Notes

Vendored new dependencies:

  • github.com/charmbracelet/bubbles/viewport
  • github.com/charmbracelet/x/ansi

Users can now navigate large project lists and detailed views without losing visibility of the title or footer. PageUp/PageDown provide faster navigation. Scroll position is preserved during auto-refresh. Long messages, add-ons, and services wrap properly instead of being truncated.

## The Issue

The TUI dashboard project list and detail view had no scrolling support.
When there were more projects or content than fit on the terminal screen,
the title bar would disappear and content would be cut off. Long URLs,
add-on lists, and service lists were also truncated at the terminal edge
without any indication. Additionally, the viewport would reset to top every
5 seconds during auto-refresh, making it difficult to browse the list.

## How This PR Solves The Issue

Used the `viewport` component from bubbles/viewport instead of implementing
custom scroll tracking:

- Added `dashboardViewport` and `detailViewport` fields using `viewport.Model`
- Created `updateDashboardViewport()` helper that rebuilds dashboard content
  and adjusts scroll position to keep the cursor visible
- Fixed viewport reset on refresh by removing `GotoTop()` call in projectsLoadedMsg handler
- Split view rendering into content builders (`buildDashboardContent()`,
  `buildDetailContent()`) and view renderers that wrap the viewport
- Added PageUp/PageDown keybindings for faster navigation
- Viewport initialization in WindowSizeMsg handler with proper sizing
- Added `ansi.Wrap()` for proper message wrapping (errors, confirmations) to multiple lines
- Reorganized dashboard layout with consistent divider placement and spacing
- Dynamic key references in status messages (e.g., uses `m.keys.Start.Help().Key`)
- Add-ons now wrap to multiple lines with proper indentation instead of truncating
- Services displayed as comma-separated list with wrapping only at service boundaries

The viewport component automatically handles scroll indicators, boundary
checking, and smooth scrolling. Title bar and footer remain visible at all
times. The scroll position is preserved during auto-refresh.

## Manual Testing Instructions

**List scrolling** - create enough projects to overflow the terminal:

```bash
for name in proj-{01..30}; do
  mkdir -p ~/tmp/$name && cd ~/tmp/$name
  ddev config --auto --project-name=$name
done
ddev tui
```

Press up/down or pgup/pgdown - the list scrolls and scroll indicators appear.
The title bar and footer must remain visible at all times. Wait 5+ seconds
and verify the scroll position doesn't jump to top during auto-refresh.

**Detail view scrolling** - create a project with many URLs, add-ons, and services:

```bash
mkdir -p ~/tmp/test-detail && cd ~/tmp/test-detail
ddev config --auto \
  --additional-hostnames=one,two,three,four,five,six,seven,eight,nine,ten
ddev add-on get ddev/ddev-redis
ddev add-on get ddev/ddev-memcached
ddev start
ddev tui
```

Open the project detail (Enter). Press up/down or pgup/pgdown - content scrolls
with indicators, title stays visible. Add-ons wrap across multiple lines with
indentation. Services display as comma-separated list with commas at line breaks.

**Message wrapping** - trigger a long error message to verify it wraps properly
instead of being truncated (e.g., docker connection error with long host).

**Filter + scroll** - type `/` to filter, then use up/down to navigate the
filtered list. Enter opens the detail view for the selected project.

## Automated Testing Overview

Updated all existing tests to initialize viewports properly by sending
WindowSizeMsg before loading data. Tests verify:
- Viewport initialization
- Scroll position management
- Content building with proper wrapping
- Filter mode with scrolling

## Release/Deployment Notes

Vendored new dependencies:
- `github.com/charmbracelet/bubbles/viewport`
- `github.com/charmbracelet/x/ansi`

Users can now navigate large project lists and detailed views without losing
visibility of the title or footer. PageUp/PageDown provide faster navigation.
Scroll position is preserved during auto-refresh. Long messages, add-ons, and
services wrap properly instead of being truncated.

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
@stasadev
stasadev requested a review from a team as a code owner February 21, 2026 18:06
@github-actions github-actions Bot added dependencies Pull requests that update a dependency file enhancement labels Feb 21, 2026
@github-actions

github-actions Bot commented Feb 21, 2026 •

Copy link
Copy Markdown

@stasadev

Copy link
Copy Markdown
Member Author

Before:

image

After:

image

@stasadev

Copy link
Copy Markdown
Member Author

Before:

image

After:

image

@rfay rfay left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty amazing. Works great. Hard to believe that scrolling could even be a possilibity.

@rfay

rfay commented Feb 22, 2026

Copy link
Copy Markdown
Member

We can probably deploy on a phone now.

@rfay

rfay commented Feb 22, 2026

Copy link
Copy Markdown
Member

The site selector color is definitely better.

@stasadev
stasadev merged commit fae2ec7 into ddev:main Feb 22, 2026
33 of 34 checks passed
@stasadev
stasadev deleted the 20260220_stasadev_tui_viewport branch February 22, 2026 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants