refactor(client): split hooks/builders.rs by event category#49
Merged
BlindMaster24 merged 1 commit intomainfrom Apr 24, 2026
Merged
refactor(client): split hooks/builders.rs by event category#49BlindMaster24 merged 1 commit intomainfrom
BlindMaster24 merged 1 commit intomainfrom
Conversation
client/hooks/builders.rs had grown to 574 lines with ~60 `on_*` builder methods all listed in one flat file. Split by event category per the AGENTS.md guideline (~400-600 lines or mixed responsibilities): * builders/mod.rs - module wiring + the catch-all on_event hook. * builders/connection.rs - connect/disconnect/max-payload/cmd-lifecycle. * builders/session.rs - login/logout/kick/user presence + text messages. * builders/directory.rs - channel/server/file/account/ban directory. * builders/media.rs - audio block/video/desktop/hotkey/voice activation/ file transfer/sound devices. * builders/reconnect.rs - internal errors + auto-reconnect/login/join recovery pipeline. Each submodule adds `impl ClientHooks` methods onto the same ClientHooks struct defined in the parent hooks/ module. No new public items, no re-exports needed; external call sites (`ClientHooks::new().on_*(...)`) continue to compile unchanged. Structural only, no semantic change. Method bodies are byte-for-byte identical to the pre-split file. Local verification: * cargo fmt --all --check clean * cargo clippy --workspace --all-targets --all-features -- -D warnings clean * cargo test --workspace --all-features -> 287 passed / 0 failed
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
3 tasks
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
client/hooks/builders.rshad grown to 574 lines containing ~60on_*builder methods in one flat file. Split by event categoryper the AGENTS.md guideline ("split files when a module grows
beyond ~400-600 lines or mixes multiple responsibilities"):
builders/mod.rs- module wiring + the catch-allon_eventhook (keeps its existing spot because it is cross-cutting, not
tied to a specific event category).
builders/connection.rs- connect success/fail/crypt/lost,max-payload updates, command processing/error/success.
builders/session.rs- login/logout/kick/user presence(logged-in, logged-out, user-update, joined, user-joined,
user-left, text messages, user-state-change).
builders/directory.rs- channel/server/file/account/bandirectory mutations.
builders/media.rs- audio block/video/desktop/voice-activation/hotkey/file-transfer/sound-device events.
builders/reconnect.rs- internal errors + auto-reconnect/auto-login/auto-join recovery pipeline.
Each submodule adds
impl ClientHooksmethods to the sameClientHooksstruct defined in the parenthooks/module. No newpublic items, no re-exports needed; external call sites
(
ClientHooks::new().on_*(...)) continue to compile unchanged.Structural only, no semantic change:
session.rsusesChannelId,TextMessage,User;media.rsandreconnect.rsonly needClient,Message).Net diff:
builders.rsdeleted (574 lines), six new files created(
mod.rs~45,connection.rs~75,session.rs~90,directory.rs~105,media.rs~235,reconnect.rs~100). Gitdetects
builders.rs -> builders/mod.rsas the primary rename.Local verification:
cargo fmt --all --checkcleancargo clippy --workspace --all-targets --all-features -- -D warningscleancargo test --workspace --all-features-> 287 passed / 0 failedReview & Testing Checklist for Human
ClientHooks::new().on_*(...)chains stillcompile from
crates/teamtalk/tests/and any downstreamcrates. Each
on_*method is a#[must_use]builder thatstores a boxed closure in the matching optional field on
ClientHooksand returnsself; no runtime behavior haschanged.
connection= transport + command lifecycle;session= auth + presence + text;directory= channels/server/files/accounts/bans;media= audio/video/desktop/sound devices/hotkeys/voiceactivation/file transfer;
reconnect= internal-error + auto-recovery pipeline.Boundaries are subjective;
on_eventis intentionally keptin
builders/mod.rsas the one truly cross-cutting hook.--no-default-features,--features async,--features mock,--features all) stillcompile. Local
cargo check --all-featuresis clean; CIcovers the matrix.
Notes
Next PR in the P0 structural refactor queue after #44
(
can_issue_logged_in_commanddedup), #45 (poll_command_completionextract), #46 (
client/bus.rssplit), #47 (bot/storage.rssplit),and #48 (
bot/fsm.rssplit). Branches from cleanmain,independent of the other refactor PRs, so can be merged in any
order.
Upcoming: split
types/entities/media_common.rs(458 lines) andthe
client/backend.rs(1334 lines) +client/backend_mock.rs(1101 lines) pair, then P1 API tweaks (jitter,
StreamTypes,SdkErrorCode,TimeoutKind,SecretString, indexed dispatch)each with their own tests, then a big test-fill PR driven by
scripts/audit_teamtalk_coverage.py.The pre-existing
semverCI gate is expected to remain red;release-plzhandles the eventual version bump.Link to Devin session: https://app.devin.ai/sessions/71fdd6196cb74723a2e277bb81993a9c
Requested by: @BlindMaster24