Skip to content

Move 26 run_worker command bodies into worker_commands.rs - #231

Merged
Sythos merged 1 commit into
mainfrom
enhancement-issue-206-worker
Oct 3, 2026
Merged

Sythos merged 1 commit into
mainfrom
enhancement-issue-206-worker

Conversation

@Sythos

@Sythos Sythos commented Oct 3, 2026

Copy link
Copy Markdown
Owner

Refs #206.

Step 5 of the split of main.rs, first part (run_worker). The bodies of 26 arms (of 139) move into run_<command> functions in the new crates/cordiale-ui/src/worker_commands.rs, and each arm now just calls its helper, with .await exactly when the helper is async. run_worker goes from 1,237 to 996 lines and main.rs from 12,630 to 12,391. The frame is untouched: the loop, the match &mut session_events, the select!, every arm pattern and guard, so the order of events is preserved by construction. The issue stays open for the last part (main()).

Which arms moved: only those with a body of ten lines or more that contain no return, ?, label, break or continue, assign or borrow mutably no run_worker local other than state, need at most seven parameters and have only parameters and pattern bindings of declared types as free variables. The other 113 stay inline: 103 are shorter than ten lines, five use session_events (Connect, TotpVerify, ShareConsume, RecoverySignIn, PasskeySignIn), two use the radio locals (RadioTrack, Disconnect), two would need more than seven parameters (AdminServerEdit, AdminCredentialEdit) and one is the None => return frame arm. The helpers take state: &mut WorkerState and ui: &slint::Weak<AppWindow> like the existing handlers, plus the arm's bindings with the types of the WorkerCommand fields. They are named run_* (no existing item has those names).

Checked by script: every helper body equals the original arm body after one normalisation that moving the code requires (&mut state and &state become state, &ui becomes ui, since they are references already: otherwise &mut state would be a &mut &mut and &ui trips needless_borrow); every parameter is used and every call passes exactly the names the body needs; no return, ?, label, break or continue in a helper; the token stream of main.rs with the 26 bodies masked is identical to the original except the mod and use lines; the #[test] count is unchanged (305). The CI log should show the same test counts as main (390 for cordiale-ui). Not verified: nothing is compiled before CI. Disjoint field borrows through the &mut reference (the notify and admin refresh arms) and the futures' Send-ness are the points to watch.

Branch: enhancement-issue-206-worker

Fifth step of splitting main.rs, first part: the bodies of 26 arms of
run_worker (selecting a network, the directory, the admin edits, the
personal preferences, ignore, notify and watch lists and a few more)
become run_* functions in src/worker_commands.rs, called in place. The
loop, the select!, every arm pattern and guard and the order of events
stay exactly as they were. Arms that touch the session events or the
radio locals, return or use ?, or would need more than seven parameters
stay inline. No behaviour change. Refs #206.
@Sythos Sythos added the enhancement New feature or request label Oct 3, 2026
@Sythos Sythos self-assigned this Oct 3, 2026
@Sythos
Sythos merged commit c146cb7 into main Oct 3, 2026
8 checks passed
@Sythos
Sythos deleted the enhancement-issue-206-worker branch October 3, 2026 04:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant