refactor: promote BrowserPanelView computed vars to standalone subviews#68
Merged
Merged
Conversation
Nuclear-review finding WP6 (lowest severity): BrowserPanelView was a single ~1900-line View struct decomposed only via private computed vars, making it hard to scan and hard for the type checker to isolate errors. Promotes the 4 largest cohesive computed-var groups into standalone private struct View types in the same file, taking explicit `let`/`@Binding` params instead of implicitly reading the parent's state: - BrowserNavigationButtonsView (back/forward/reload/stop + download indicator) - 1 param (panel) - BrowserProfileMenuView (profile toolbar button + popover) - 6 params - BrowserThemeModeMenuView (theme toolbar button + popover) - 4 params - BrowserImportHintContentView (blank-tab card/inline-strip overlays + toolbar-chip popover, which all share the same hint body) - 4 params Body content moved verbatim; behavior, timing, and state ownership are unchanged. Groups that would need more than ~8 parameters to extract cleanly (omnibarField, webView, and the top-level addressBar composition) were left in place per the conservative scope of this pass. BrowserPanelView's own body shrinks from ~1913 to ~1604 lines.
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.
What this does
BrowserPanelView.swifthad one giant ~1900-line SwiftUI view struct withdozens of private computed properties strung together — hard to scan, and
every small change re-typechecked the whole thing. This splits out the four
largest, most self-contained chunks (navigation buttons, the profile menu,
the theme-mode menu, and the browser-import hint content) into their own
small view types in the same file. Nothing about how the browser panel looks
or behaves changes — this is purely moving code around for readability.
Summary
Addresses nuclear-review finding WP6 (lowest severity). Extracted 4 cohesive
computed-var groups from
BrowserPanelViewinto standaloneprivate structView types, all within
Sources/Panels/BrowserPanelView.swift(no newfiles, no pbxproj changes):
BrowserNavigationButtonsView— back/forward/reload/stop buttons + thedownload-in-progress indicator. 1 param (
panel).BrowserProfileMenuView— profile toolbar button + its popover (profilelist, new/import/rename actions). 6 params (
panel,iconColor,isPresentedbinding,popoverPadding,onSelectProfile,onAction).BrowserThemeModeMenuView— theme-mode toolbar button + its popover.4 params (
currentMode,iconColor,isPresentedbinding,onSelectMode).BrowserImportHintContentView— the browser-data import hint shared bythe blank-tab floating-card overlay, the blank-tab inline strip, and the
toolbar-chip popover (all three render the same hint body/buttons).
4 params (
summary,onImport,onOpenSettings,onDismiss).Body content for each group moved verbatim; only the property plumbing
changed (state that used to be read implicitly from
BrowserPanelViewisnow passed in explicitly as
let/@Binding). No new@State, no timingchanges, no
.id()changes,OmnibarStateuntouched.Left in place, per the conservative scope of this pass:
omnibarField,webView, and the top-leveladdressBarcomposition — extracting thosecleanly would need well over 8 parameters (omnibar callbacks, focus state,
search overlay wiring), so a smaller clean extraction was preferred over a
maximal one.
BrowserPanelView's own body shrinks from ~1913 to ~1604 lines (-16%).Test Plan
PROGRAMA_SKIP_ZIG_BUILD=1 xcodebuild -project GhosttyTabs.xcodeproj -scheme programa -configuration Debug -destination 'platform=macOS' build→ BUILD SUCCEEDED, no new warnings introduced