You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Split main.rs: 28k lines, a 1,700-line main() and an 86-field WorkerState #206
crates/cordiale-ui/src/main.rs is 28,699 lines at v0.1.16. About 16,000 are production code and about 12,700 are the #[cfg(test)] module in the same file; appwindow.slint adds another 7,400.
Measured with a small script that matches braces (so roughly right, not exact):
381 top-level functions; 12 longer than 100 lines and 6 longer than 200.
WorkerState: 86 fields in one struct that every handler takes as &mut.
Why it hurts: nearly every issue touches this file, so branches conflict constantly (the last round of merges needed main merged into each branch in turn); a one-line change recompiles and re-lints the whole crate; and a 1,200-line async loop is hard to reason about for ordering and cancellation.
The code already has the seams: home.rs, ceremony.rs, passkeys.rs, totp.rs, reply.rs, debug_info.rs, dates.rs are separate modules that came out well.
Proposal (no behaviour change, one small PR per step so the diffs stay reviewable and merge cleanly)
Move the test module out of main.rs (a tests/ folder of per-area files next to the modules). That alone removes 12k lines from the file.
Extract the frame dispatch (handle_frame and its per-kind handlers) into frames/.
Extract slash commands, admin handlers, query windows, channel list and history into their own modules.
Split WorkerState into a few sub-structs by area (connection, windows and history, settings caches, admin, presence), passed to the handlers that need them.
Break main() into setup functions (callbacks per area), and run_worker into a command dispatcher plus handlers.
Do the steps while few branches are open, and keep cargo test green after each one.
Activity
Move the unit tests of cordiale-ui out of main.rs
Merge PR #218: Move the unit tests of cordiale-ui out of main.rs
Move the frame dispatch of cordiale-ui to frames.rs
Merge PR #221: Move the frame dispatch of cordiale-ui to frames.rs
Move the slash commands of cordiale-ui to slash.rs
Merge PR #222: Move the slash commands of cordiale-ui to slash.rs
Move the admin handlers of cordiale-ui to admin_handlers.rs
Merge PR #223: Move the admin handlers of cordiale-ui to admin_handle…
Move history, channel and query window handling to their own modules
4 remaining items
Merge PR #226: Group the settings and preferences fields of WorkerSta…
Group the per-network fields of WorkerState into NetworkState
Merge PR #227: Group the per-network fields of WorkerState into Netwo…
Group the transcript and window-content fields of WorkerState into Tr…
Merge PR #228: Group the transcript and window-content fields of Work…
Group the connection and session fields of WorkerState into SessionState
Merge PR #229: Group the connection and session fields of WorkerState…
Group the window and sidebar fields of WorkerState into WindowState
Merge PR #230: Group the window and sidebar fields of WorkerState int…
Move 26 run_worker command bodies into worker_commands.rs
Merge PR #231: Move 26 run_worker command bodies into worker_commands.rs
Move the UI callback registrations of main() into ui_callbacks.rs