refactor: centralize TUI layout logic and constants to standardize responsive dimensions#342
Merged
SuperCoolPencil merged 5 commits intomainfrom Apr 10, 2026
Merged
refactor: centralize TUI layout logic and constants to standardize responsive dimensions#342SuperCoolPencil merged 5 commits intomainfrom
SuperCoolPencil merged 5 commits intomainfrom
Conversation
…rs.go to standardize responsive dimensions
…shboardState when closing category manager
Binary Size Analysis
|
…yout padding logic
…etail row calculation logic
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.
Greptile Summary
This PR centralizes TUI layout constants into
constants.goand extracts responsive dimension helpers intolayout_helpers.go, replacing scattered inline arithmetic inview_category.go,view_settings.go, andupdate_category.go. The refactor also replaces hardcoded style padding literals with named constants instyles.go.Confidence Score: 5/5
Safe to merge — all findings are P2 suggestions; no logic regressions introduced by the refactor
The refactor is purely extractive: constants and helpers carry identical values/logic from their inline origins, the navigation state fix (
SettingsStateinstead ofDashboardState) is straightforwardly correct, and callers guard against extreme edge cases. The only remaining gap is missing unit tests for the non-trivial branching inCalculateTwoColumnWidthsandGetGraphAreaDimensions, which is a P2 best-practice concern and does not block merge.internal/tui/layout_helpers.go —
CalculateTwoColumnWidthsandGetGraphAreaDimensionshave branching logic without unit test coverageImportant Files Changed
CalculateTwoColumnWidthshas branching edge-case logic with no accompanying unit tests(0, 1)and(1, 2)withDefaultPaddingY/XandPopupPaddingY/X; functionally identical, improves consistencyCalculateTwoColumnWidths; also fixes navigation state to return toSettingsStateinstead ofDashboardStateGetSettingsDimensionsandCalculateTwoColumnWidthsdirectly, removing the previously flagged pass-through wrapperGetSettingsDimensionsandCalculateTwoColumnWidthsdirectly;updateSettingsInputWidthForViewportmirrors the same pattern as the category equivalentGetListWidth,GetHeaderHeight, andGetGraphAreaDimensionsfrom the new helper module; no logic changesFlowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Window resize event] --> B[GetSettingsDimensions] B --> C{width within Min/Max bounds?} C -- clamp to range --> D[constrained width] D --> E{height fits terminal?} E -- clamp to maxHeight --> F[constrained height] F --> G{modalWidth >= threshold 72 settings / 76 category} G -- yes --> H[CalculateTwoColumnWidths] G -- no --> I[Compact single-column layout] H --> J{leftWidth >= 16?} J -- clamp to 16 --> K{rightWidth >= minRight?} J -- yes --> K K -- clamp + recalc left --> L[Two-column render] K -- yes --> L A2[Dashboard render] --> B2[GetListWidth] B2 --> C2{rightWidth >= MinRightColumnWidth?} C2 -- yes --> D2[Split list / detail] C2 -- no --> E2[Full-width list] A3[Graph render] --> B3[GetGraphAreaDimensions] B3 --> C3{isStatsHidden?} C3 -- yes --> D3[graphWidth = rightWidth - axis - frame x5] C3 -- no --> E3[graphWidth = rightWidth - stats - axis - frame x3]Comments Outside Diff (1)
internal/tui/view.go, line 406 (link)GraphTargetHeightRatioconstant unused at its only use-siteGraphTargetHeightRatio = 0.4was introduced inconstants.gospecifically for this calculation, but the raw literal0.4was left in place. The constant is never actually referenced anywhere, making it dead code and defeating the PR's stated goal.Prompt To Fix With AI
Prompt To Fix All With AI
Reviews (4): Last reviewed commit: "refactor: reduce minimum settings window..." | Re-trigger Greptile