feat: proper rendering of surge in all terminal sizes. #322
Merged
SuperCoolPencil merged 13 commits intomainfrom Apr 6, 2026
Merged
feat: proper rendering of surge in all terminal sizes. #322SuperCoolPencil merged 13 commits intomainfrom
SuperCoolPencil merged 13 commits intomainfrom
Conversation
Binary Size Analysis
|
- Show only [h] keybindings in the footer by default - Press h to open a styled modal with all shortcuts - Press esc to close the modal - Remove broken history feature (no View handler, caused crash) Co-Authored-By: Claude Opus 4.6 <[email protected]>
- Use minGraphHeight variable instead of hardcoded 9 for chunk map budget - Remove double spaces in help modal title - Add test for HelpModalState rendering and esc-to-close behavior - Omit network activity graph box when too small to render Co-Authored-By: Claude Opus 4.6 <[email protected]>
Member
|
Are you planning to fix settings TUI in this PR or are we just targeting the dashboard? |
Collaborator
Author
|
I am planning to I'll let you know when done :) |
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.
closes #252
Greptile Summary
This PR delivers solid responsive terminal layout improvements to the Surge TUI, replacing the History feature with a
HelpModalthat shows keyboard shortcuts, and adding proper dimension clamping and cursor normalization throughout the category manager and settings views. The test suite is thorough with broad coverage across terminal sizes.HistoryStateshifted every subsequent constant's value by 1, but the inline "is N" comments were not updated —SearchStatethroughHelpModalStateall show one-higher-than-actual values.updateCategoryInputWidthsForViewportreplicates theleftWidth/rightWidthcalculation fromrenderCategoryTwoColumnbut omits therightWidth < minRightWidthre-adjustment and thebodyHeight >= 9guard, which can leave model-side input widths mismatched until the next render.internal/benchmark/metrics.goand its test file are deleted with no mention in the PR description — please confirm this is intentional.Confidence Score: 5/5
Safe to merge after confirming the benchmark deletion is intentional; no runtime correctness issues found in the rendering paths.
All remaining findings are P2 style/cleanup concerns. The responsive layout logic, state-machine transitions, and new tests are sound. No P0/P1 issues were identified.
internal/tui/model.go (stale iota comments), internal/tui/update_category.go (width logic duplication), internal/benchmark/metrics.go (unexplained deletion)
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A([DashboardState]) -->|"h: ToggleHelp"| B([HelpModalState]) B -->|esc| A C([tea.WindowSizeMsg]) --> D{current state?} D -->|CategoryManagerState| E[normalizeCategoryManagerSelection] E --> F{catMgrEditing?} F -->|yes| G[updateCategoryInputWidthsForViewport] F -->|no| H[skip input resize] D -->|SettingsState| I[normalizeSettingsSelection] I --> J{SettingsIsEditing?} J -->|yes| K[updateSettingsInputWidthForViewport] J -->|no| L[skip] D -->|other states| M[update width/height only]Comments Outside Diff (5)
internal/tui/view_test.go, line 195-206 (link)hideGraphStatspath — 5-axis labels never renderedAt
m.width = 140,rightWidth = int(138 × 0.4) = 55, which falls in the[50, 70)band that setshideGraphStats = true. That path emits at most 3 Y-axis labels (maxSpeed,maxSpeed×0.5,"0 MB/s"). The labels"0.8 MB/s"and"0.2 MB/s"(frommaxSpeed×0.75/×0.25) only appear in the full-statselsebranch, which requiresrightWidth ≥ 70— i.e.m.width ≥ 177. This test will always fail as written.Prompt To Fix With AI
internal/benchmark/metrics.gobenchmarkpackageBoth
metrics.goand its test file are removed here, but the PR's stated purpose is responsive TUI rendering. No remaining Go file imports this package so it compiles cleanly, but bundling an unrelated deletion makesgit bisectharder. Consider splitting this into a separate commit or PR.Prompt To Fix With AI
internal/tui/view_test.go, line 195-206 (link)At
m.width = 140, the layout math resolves to:availableWidth = 138leftWidth = int(138 × 0.6) = 82rightWidth = 138 − 82 = 56hideGraphStats = rightWidth >= 50 && rightWidth < 70→trueWhen
hideGraphStatsistruethe code takes the branch atview.go:588, which only emits 3 labels (max, 0.5×max, "0 MB/s"). The 5-label path (including the 0.75×max and 0.25×max entries that produce"0.8 MB/s"and"0.2 MB/s"with defaultmaxSpeed=1.0) only executes in theelsebranch whenhideGraphStats=false, i.e. whenrightWidth ≥ 70. That requireswidth ≳ 177.Fix: use a width that gives
rightWidth ≥ 70, for examplewidth = 200:Prompt To Fix With AI
internal/tui/view.go, line 547-556 (link)topSpeedduplicatesmaxSpeedlogicBoth variables are updated with identical comparisons (
if v > x { x = v }) in the same loop, sotopSpeed == maxSpeedimmediately after the loop exits. The only distinction is thatmaxSpeedsubsequently receives headroom (×1.1, rounded).topSpeedsimply captures the raw peak, which means it can be derived frommaxSpeedbefore the headroom block runs:This eliminates the duplicate conditional per element without changing any observable behaviour.
Prompt To Fix With AI
internal/tui/view.go, line 388 (link)minGraphHeightLine 388 subtracts a literal
9for the graph minimum when computing the available chunk-map height, but the PR introducesminGraphHeight(lines 321–323) which can be5on short terminals. On ashortTerminallayout the chunk map is allocated 4 fewer rows than the actual graph minimum allows, producing a tighter chunk map than necessary and an inconsistent layout budget.Prompt To Fix With AI
Prompt To Fix All With AI
Reviews (8): Last reviewed commit: "feat(tui): make category page appear con..." | Re-trigger Greptile
Context used: