Skip to content

Comments

feat: graceful shutdown on Ctrl-C with MCP cleanup#359

Merged
bug-ops merged 1 commit intomainfrom
feat/m24/graceful-shutdown
Feb 16, 2026
Merged

feat: graceful shutdown on Ctrl-C with MCP cleanup#359
bug-ops merged 1 commit intomainfrom
feat/m24/graceful-shutdown

Conversation

@bug-ops
Copy link
Owner

@bug-ops bug-ops commented Feb 16, 2026

Summary

  • Add Agent::shutdown() with farewell message and MCP server cleanup
  • Cancel-aware LLM streaming via tokio::select! on shutdown signal
  • Native tool loop checks shutdown flag each iteration
  • McpManager::shutdown_all_shared(&self) with 5s per-client timeout
  • Shutdown called in all exit paths (CLI, TUI agent, TUI task)

Closes #355, closes #356, closes #357, closes #358

Test plan

  • cargo nextest run --workspace --lib --bins (1427 pass)
  • cargo clippy --workspace -- -D warnings (clean)
  • cargo +nightly fmt --check (clean)
  • Manual: start long response, Ctrl-C — verify "Shutting down..." and clean exit

Add Agent::shutdown() that sends farewell message and gracefully
shuts down MCP server connections with per-client timeout. Cancel
LLM streaming on shutdown signal via tokio::select. Ensure shutdown
runs in all exit paths including TUI mode.

Closes #355, closes #356, closes #357, closes #358
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 17.24138% with 24 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/zeph-mcp/src/manager.rs 0.00% 8 Missing ⚠️
crates/zeph-core/src/agent/mod.rs 0.00% 7 Missing ⚠️
crates/zeph-core/src/agent/streaming.rs 45.45% 6 Missing ⚠️
src/main.rs 0.00% 3 Missing ⚠️

❌ Your patch status has failed because the patch coverage (17.24%) is below the target coverage (60.00%). You can increase the patch coverage or adjust the target coverage.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #359      +/-   ##
==========================================
- Coverage   79.39%   79.33%   -0.07%     
==========================================
  Files         100      100              
  Lines       25770    25796      +26     
==========================================
+ Hits        20460    20464       +4     
- Misses       5310     5332      +22     
Files with missing lines Coverage Δ
src/main.rs 63.43% <0.00%> (-0.10%) ⬇️
crates/zeph-core/src/agent/streaming.rs 50.58% <45.45%> (-0.26%) ⬇️
crates/zeph-core/src/agent/mod.rs 81.55% <0.00%> (-0.43%) ⬇️
crates/zeph-mcp/src/manager.rs 82.39% <0.00%> (-2.09%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bug-ops bug-ops enabled auto-merge (squash) February 16, 2026 02:37
@bug-ops bug-ops merged commit 827a652 into main Feb 16, 2026
18 checks passed
@bug-ops bug-ops deleted the feat/m24/graceful-shutdown branch February 16, 2026 02:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

2 participants