Add keybinding to cycle the log tail line count in the Logs tab#821
Open
DevLeonardoK wants to merge 3 commits into
Open
Add keybinding to cycle the log tail line count in the Logs tab#821DevLeonardoK wants to merge 3 commits into
DevLeonardoK wants to merge 3 commits into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a
tkeybinding (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.tailconfig option, which now acts as the initial value; the keybinding lets you change it at runtime without editing the config or restarting.Behavior details
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 baredocker logs --tail 50 --followdoes). This is implemented with a small writer that keeps the last N lines and atomically rewrites the view viaSetContent, so there is no empty-frame flicker.m) is unchanged and keeps plaindocker logssemantics.Testing
go build ./...,go vet ./...,go test ./...all pass; cheatsheets regenerated withgo run scripts/cheatsheet/main.go generate.tail: 50the 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 toallbehaves as expected.