Skip to content

Add keybinding to cycle the log tail line count in the Logs tab#821

Open
DevLeonardoK wants to merge 3 commits into
jesseduffield:masterfrom
DevLeonardoK:feature/cycle-log-tail-lines
Open

Add keybinding to cycle the log tail line count in the Logs tab#821
DevLeonardoK wants to merge 3 commits into
jesseduffield:masterfrom
DevLeonardoK:feature/cycle-log-tail-lines

Conversation

@DevLeonardoK

@DevLeonardoK DevLeonardoK commented Jul 15, 2026

Copy link
Copy Markdown

Description

Adds a t keybinding (available in the containers and services panels) that cycles how many lines are shown in the Logs tab: all → 50 → 100 → 200 → 500 → all. The current value is displayed in the Logs tab subtitle, e.g. tail: 50 (t to cycle).

This builds on the existing logs.tail config option, which now acts as the initial value; the keybinding lets you change it at runtime without editing the config or restarting.

Behavior details

  • The tail count is a true sliding window: with tail: 50, the main panel always shows only the 50 most recent lines as new ones stream in, rather than just limiting the initial snapshot and growing unbounded afterwards (which is what a bare docker logs --tail 50 --follow does). This is implemented with a small writer that keeps the last N lines and atomically rewrites the view via SetContent, so there is no empty-frame flicker.
  • Works from both the containers panel and the services panel (the services Logs tab renders the underlying container's logs through the same path).
  • The tail value is part of the main-panel context cache key, so cycling forces a re-render immediately.
  • Viewing logs in a subprocess (m) is unchanged and keeps plain docker logs semantics.

Testing

  • go build ./..., go vet ./..., go test ./... all pass; cheatsheets regenerated with go run scripts/cheatsheet/main.go generate.
  • Manually verified in a terminal against containers emitting numbered log lines (both a standalone container and a docker-compose service): with tail: 50 the panel shows exactly the 50 most recent lines (e.g. lines 251–300 when the container is at line 300), the window keeps sliding as new lines arrive, and cycling through every preset and back to all behaves as expected.

Lets you press 't' while focused on the containers panel to cycle
through common --tail presets (all, 50, 100, 200, 500) for the
selected container's Logs tab, instead of only being able to set a
fixed value via the logs.tail config option. The current value is
shown in the Logs tab subtitle.
Previously the selected --tail value only trimmed the initial log
snapshot; since logs are followed live afterwards, the view kept
growing unbounded past the chosen count. Now the main panel writer
re-truncates to the last N lines on every new line, so e.g. tail: 50
always shows only the 50 most recent lines. Behavior when
following logs to stdout (the 'm' keybinding) is unchanged, matching
plain `docker logs --tail N -f` there.
The services panel's Logs tab renders the underlying container's logs
through the same code path, so bind 't' there as well and include the
tail value in the services context cache key so the tab re-renders
when the value changes. Also switch the tail-limiting writer to
SetContent so the clear+rewrite is atomic and the view never renders
empty in between.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant