Skip to content

Split the file tree row and git changes header - #69

Merged
AhmadKharfan merged 2 commits into
developfrom
refactor/split-long-composables
Jul 29, 2026
Merged

Split the file tree row and git changes header#69
AhmadKharfan merged 2 commits into
developfrom
refactor/split-long-composables

Conversation

@AhmadKharfan

Copy link
Copy Markdown
Owner

Why

A sweep for oversized functions across the whole project found four composables far over the 60-line threshold that were real complexity rather than incidental length:

Function Lines
AslFileTreeRow (:designsystem) 165 — worst in the repo
GitChangesHeader 120
GitActionsOverflowMenu 64
RemotesView 63

What changed

FileTree.ktAslFileTreeRow keeps the gesture detection, the menu-anchor arithmetic and its three remembers (that coordination is why the composable exists) and delegates the rest:

  • FileTreeRowContent(node, expanded, selected, selectDirectories, callbacks, modifier) — the visual row.
  • RowScope.FileTreeRowLabel(...) — the name and git-status portion.
  • BoxScope.FileTreeRowMenu(...) — the context menu.
  • FileTreeRowCallbacks — a small holder grouping the three row callbacks.

GitPanelScreen.ktGitChangesHeader's status/progress area and chip row became separate composables. The LaunchedEffect auto-dismissing statusMessage stayed put, since moving it into a child would change how it is keyed. RemotesView was split too.

Behavior

No behavior change. No state moved, nothing became or stopped being remembered, and composition order is preserved. FileTree.kt's gesture handling and the menu-position arithmetic that decides whether the context menu opens upward near a screen edge are unchanged.

Scope — what was deliberately left long

Not every long function should be split. Left alone on purpose:

  • data/templates/*.ktrenderWrapper (81), renderAppBuild (70), renderAppBuildKts (68), renderAppBuildGroovy (64) and the other template files build Gradle/manifest file content as strings. Their length is the shape of the file they emit; fragmenting them destroys the ability to see the output at a glance.
  • CodeEditorView.onKeyDown (66) — a dispatch when over key codes.
  • TerminalEmulatorView.

GitActionsOverflowMenu was assessed and kept whole — there was no seam that would not have produced meaningless fragments. One honest baseline entry beats shredding a coherent function.

Tests

No new tests. Pure composable moves with no logic to assert on.

Verification

  • ./gradlew :designsystem:compileDebugKotlin :feature:git:testDebugUnitTest :app:compileDebugKotlin — pass.
  • ./gradlew detekt — passes.
  • Confirmed zero Modifier-extension composables remain, and that the RowScope/BoxScope extensions are intact.

Baseline

Both baselines regenerated in their own commit — removals only, zero additions. :designsystem 125 → 123, :feature:git 25 → 21. Project total 363 → 357.

One removal needs explaining: LongParameterList for AslEditorToolbar, which this PR never touched. It is untouched on this branch and now has 7 parameters because #57 removed its onOverflowSelect. The baseline was not regenerated then, so that improvement went unrecorded — the second such stale entry traced back to that PR.

Note

The first attempt at this split made FileTreeRowContent a @Composable extension on Modifier, called as Modifier.width(...).padding(...).FileTreeRowContent(...). It compiled and rendered correctly, but it inverts the Compose convention — modifier extensions return Modifier, composables emit UI — and at the call site it reads as a modifier chain whose result is discarded. It was reworked into a plain composable taking modifier as its last parameter. The RowScope/BoxScope extensions were kept, since layout-scope extensions are the correct idiom for children needing weight or align.

@AhmadKharfan
AhmadKharfan merged commit cffef63 into develop Jul 29, 2026
2 checks passed
@AhmadKharfan
AhmadKharfan deleted the refactor/split-long-composables branch July 29, 2026 16:26
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