Skip to content

decouple App god object into controllers with proper interface boundaries#8

Merged
DokaDev merged 5 commits intomainfrom
2nd-refactor
Mar 8, 2026
Merged

decouple App god object into controllers with proper interface boundaries#8
DokaDev merged 5 commits intomainfrom
2nd-refactor

Conversation

@DokaDev
Copy link
Owner

@DokaDev DokaDev commented Mar 8, 2026

right, so this is a fairly chunky refactoring that's been on the cards for a while. the App struct had grown into a proper god object, methods all over the place across half a dozen files, doing everything from GUI management to command execution to studio process handling. it was getting unwieldy.

here's roughly what happened.

first pass was tidying up the foundations. replaced concrete type assertions in keybinding.go with proper interface dispatch (IListContext, IScrollableContext, ITabbedContext). consolidated duplicated style and frame constants that were copy-pasted all over the shop into a single theme.go. got rid of a load of dead ANSI styling code in text_style.go that nobody was calling. also centralised the OnFocus/OnBlur logic into BaseContext rather than having it repeated in every context file. on top of that, extracted a runStreamingCommand helper to cut out the boilerplate that was showing up in every controller method.

then came the interface work. implemented IPopupHandler and IGuiCommon on App. these were defined in types but never actually wired up. this gave us a clean contract for controllers to depend on rather than reaching into App internals directly.

with that in place, extracted four controllers into their own types: MigrationsController, GenerateController, StudioController, and ClipboardController. zero cross-controller dependencies, which was nice. studio's process state (studioCmd, studioRunning) moved out of App entirely. controllers talk to App through IControllerHost, no type assertions needed.

along the way, caught and fixed a couple of thread safety issues. LogAction was being called outside the UI thread, and there was a missing finishCommand fallback path that could've left the app stuck in "command running" state forever. also made studioRunning atomic for good measure.

lastly, cleaned up a dead translation key that was left behind from the old type assertion pattern.

@DokaDev DokaDev merged commit 8aee1c2 into main Mar 8, 2026
1 check passed
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