refactor(tui): group view state into sub-structs, add spawn_job helper - #113
Merged
Merged
Conversation
… helper App had 40+ flat fields and five duplicated select_next/select_prev pairs (proc_list, tree, histogram, settings, pointer_tree). Each view's selection/scroll state now lives in a shared ViewState, owned by a per-view struct (ProcListView, AllocTreeView, PointerTreeView, HistogramView, HexDumpView, SettingsView), collapsing the five duplicated pairs into ViewState::next/prev. handle_command also had six-plus near-identical "spawn thread -> run command -> send AppEvent" blocks. A spawn_job helper now wraps the thread spawn and sends a generic error Output event on failure, used by baseline, diff, diff <a> <b>, save, leak, leak-m, and both scan variants. Closes SickleFire#107.
SickleFire
approved these changes
Aug 19, 2026
SickleFire
left a comment
Owner
There was a problem hiding this comment.
LGTM! Good refactor on src/ui/tui.rs
Approved!
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.
Summary
Addresses #107. Two changes to
src/ui/tui.rs:1. Group view state into owned sub-structs
Apphad 40+ flat fields, and five view types each carried their own copy of the sameselected/scroll/select_next/select_prevpattern (proc_list_*,tree_*,histogram_*,settings_*,pointer_tree_*). Selection/scroll state is now a sharedViewState, and each view owns one:Appnow holdsproc_list: ProcListView,alloc_tree: AllocTreeView,pointer_tree: PointerTreeView,histogram: HistogramView,hex_dump: HexDumpView,settings_view: SettingsViewinstead of ~19 loose fields, and the five duplicated*_select_next/*_select_previmpls collapse into calls like:2.
spawn_jobhelper for command dispatchhandle_commandhad eight near-identical "spawn thread → run command → sendAppEvent" blocks (baseline,diff <proc>,diff <a> <b>,save,leak,leak-m, and bothscanvariants), each repeating the same thread-spawn boilerplate. Added:Each command's closure keeps whatever success/error events it needs to send (e.g.
scanstill sendsScanErroron failure sois_loadingresets correctly), it just no longer has to write thestd::thread::spawn(move || { ... })wrapper by hand:No behavioral changes — this is a pure state/structure refactor to make the file easier to extend and read.
Test plan
cargo build— clean, no new warningscargo test— 108/108 lib tests + 10/10 integration tests passcargo fmt -- --check src/ui/tui.rs— cleancargo clippy --lib— no new warnings introduced🤖 Generated with Claude Code