Repository navigation
refactor(gui): extract acquire_io helper for Marlin commands - #124
Merged
Merged
Conversation
Nine Tauri command handlers repeated the same block to pull (stdin, response_router) out of the shared MarlinState — two spawn-if-missing variants (list_ports, connect) and seven fail-if-not-connected variants. Extract a single `acquire_io(state, Option<AppHandle>)` helper: Some(app) spawns the subprocess on demand, None returns "Not connected". Semantics are unchanged. Net -25 LoC; the single-reader response-router pattern and per-command locking behavior are preserved (the helper acquires and releases the same lock, then returns owned Arc/clone handles exactly as before).
CameronBrooks11
force-pushed
the
refactor/marlin-acquire-io-helper
branch
from
June 25, 2026 00:57
e2f20f7 to
b2ef4f3
Compare
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.
Nine Tauri command handlers repeated the same block to pull
(stdin, response_router)fromMarlinState— 2 spawn-if-missing variants (list_ports, connect) and 7 fail-if-not-connected variants. Collapsed into oneacquire_io(state, Option<AppHandle>)helper (Some(app)spawns on demand,None→ "Not connected").Behavior preserved: same lock acquire/release scope, same owned
Arc<Mutex<ChildStdin>>/ResponseRouterclones returned, single-reader router untouched.marlin_start_interactive(which doesn't acquire IO) left as-is.Net −25 LoC.
cargo fmtclean locally; clippy/build verified by CI (GTK libs unavailable in my env).