Skip to content

refactor(acp): decompose long functions in zeph-acp agent module#3472

Merged
bug-ops merged 1 commit intomainfrom
3459-decompose-zeph-acp-agent
Apr 26, 2026
Merged

refactor(acp): decompose long functions in zeph-acp agent module#3472
bug-ops merged 1 commit intomainfrom
3459-decompose-zeph-acp-agent

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Apr 26, 2026

Summary

  • Decomposed three functions that suppressed clippy::too_many_lines with deferred TODOs in crates/zeph-acp/src/agent/mod.rs
  • Extracted 8 private helper methods/functions with doc comments; no public API changes
  • Promoted req_handler!/notif_handler! macros to module scope for run_agent
  • Fixed DRY violation: do_load_session, do_fork_session, do_resume_session now call spawn_notify_drainer instead of inlining the drainer block
  • Added /compact to is_acp_native_slash_command (was listed in /help but not intercepted)

Helpers added

Helper Type Parent function
evict_oldest_idle_session_if_full method do_new_session
spawn_notify_drainer associated fn do_new_session (now also do_load_session, do_fork_session, do_resume_session)
build_new_session_response method do_new_session
is_acp_native_slash_command free fn do_prompt
acquire_prompt_channels method do_prompt
persist_user_message_async method do_prompt
compute_stop_reason free fn do_prompt
build_prompt_response free fn do_prompt

Test plan

  • cargo clippy -p zeph-acp --all-features -- -D warnings — clean
  • cargo nextest run -p zeph-acp --all-features --lib --bins — 72/72 passed
  • All three #[allow(clippy::too_many_lines)] suppressions removed; do_fork_session suppression untouched

Closes #3459

Extract private helpers from three functions that suppressed
clippy::too_many_lines with deferred TODOs:

- do_new_session: evict_oldest_idle_session_if_full,
  spawn_notify_drainer, build_new_session_response
- do_prompt: is_acp_native_slash_command, acquire_prompt_channels,
  persist_user_message_async, compute_stop_reason, build_prompt_response
- run_agent: promote req_handler!/notif_handler! macros to module scope,
  reducing function body below the lint threshold

Also wire spawn_notify_drainer in do_load_session, do_fork_session, and
do_resume_session (DRY fix), and add /compact to is_acp_native_slash_command.

Removes all three #[allow(clippy::too_many_lines)] suppressions.
No public API changes.

Closes #3459
@github-actions github-actions Bot added the rust Rust code changes label Apr 26, 2026
@bug-ops bug-ops enabled auto-merge (squash) April 26, 2026 14:44
@github-actions github-actions Bot added refactor Code refactoring without functional changes size/L Large PR (201-500 lines) labels Apr 26, 2026
@bug-ops bug-ops merged commit bd6b858 into main Apr 26, 2026
32 checks passed
@bug-ops bug-ops deleted the 3459-decompose-zeph-acp-agent branch April 26, 2026 14:50
bug-ops added a commit that referenced this pull request Apr 26, 2026
/compact was incorrectly added to is_acp_native_slash_command in
PR #3472, causing the ACP layer to intercept it and return
"unknown command: /compact" instead of forwarding it to the core
agent loop where CompactCommand is handled.

Remove the /compact predicate from is_acp_native_slash_command and
drop it from the /help text in handle_slash_command.

Closes #3474
bug-ops added a commit that referenced this pull request Apr 26, 2026
/compact was incorrectly added to is_acp_native_slash_command in
PR #3472, causing the ACP layer to intercept it and return
"unknown command: /compact" instead of forwarding it to the core
agent loop where CompactCommand is handled.

Remove the /compact predicate from is_acp_native_slash_command and
drop it from the /help text in handle_slash_command.

Closes #3474
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Code refactoring without functional changes rust Rust code changes size/L Large PR (201-500 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tech-debt: decompose long functions in zeph-acp agent module

1 participant