Skip to content

refactor(gui): extract acquire_io helper for Marlin commands - #124

Merged
CameronBrooks11 merged 1 commit into
mainfrom
refactor/marlin-acquire-io-helper
Jun 25, 2026
Merged

CameronBrooks11 merged 1 commit into
mainfrom
refactor/marlin-acquire-io-helper

Conversation

@CameronBrooks11

Copy link
Copy Markdown
Member

Nine Tauri command handlers repeated the same block to pull (stdin, response_router) from MarlinState — 2 spawn-if-missing variants (list_ports, connect) and 7 fail-if-not-connected variants. Collapsed into one acquire_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>>/ResponseRouter clones returned, single-reader router untouched. marlin_start_interactive (which doesn't acquire IO) left as-is.

Net −25 LoC. cargo fmt clean locally; clippy/build verified by CI (GTK libs unavailable in my env).

@CameronBrooks11 CameronBrooks11 added rust Pull requests that update Rust code tauri Pull requests that update Tauri code labels Jun 25, 2026
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
CameronBrooks11 force-pushed the refactor/marlin-acquire-io-helper branch from e2f20f7 to b2ef4f3 Compare June 25, 2026 00:57
@CameronBrooks11
CameronBrooks11 merged commit cf30c2b into main Jun 25, 2026
21 checks passed
@CameronBrooks11
CameronBrooks11 deleted the refactor/marlin-acquire-io-helper branch June 25, 2026 01:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rust Pull requests that update Rust code tauri Pull requests that update Tauri code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant