Skip to content

Remove pending status write-back after expert exit#65

Merged
Cassin01 merged 1 commit into
mainfrom
revert/exit-set-pending-after-exit
Apr 18, 2026
Merged

Remove pending status write-back after expert exit#65
Cassin01 merged 1 commit into
mainfrom
revert/exit-set-pending-after-exit

Conversation

@Cassin01
Copy link
Copy Markdown
Owner

Summary

  • Revert the set_marker("pending") call introduced in 8e3fe25 (Fix expert status not resetting to pending on exit+relaunch flows #64) that forced expert status back to pending immediately after /exit.
  • Rename the shared helper exit_expert_and_set_pendingexit_expert, drop its detector argument, and update all five call sites (reset.rs + four tower/app.rs flows: change_expert_role, reset_expert, return_expert_from_worktree, launch_expert_in_worktree).
  • Keep the rest of 8e3fe25's refactor (helper consolidation, PreparedExpertFiles, prepare_expert_files_with_role) intact.

Why

exit_expert_and_set_pending mixed two concerns — sending /exit and writing the status marker. The pending write-back is now removed; status transitions are left to the init-time seed and downstream hooks/event handlers. Other set_marker("pending") call sites unrelated to the exit flow (feature-execution cancel in handle_feature_execution, feature-execution retry handler, init_session seeding) are untouched.

Test plan

  • make fmt-check
  • make lint (clippy -D warnings)
  • make build (release)
  • make test (813 passed)
  • Manual: verify expert restart flows (reset, change role, return from worktree, launch in worktree) still leave the expert in a correct visible state once downstream hooks fire.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Removes the immediate “pending” status marker write-back that occurred right after sending /exit, and simplifies the shared exit helper API used by both the Tower UI and CLI reset flow.

Changes:

  • Replace exit_expert_and_set_pending(...) with exit_expert(...) and update call sites in Tower and CLI reset.
  • Remove the ExpertStateDetector::set_marker(..., "pending") write-back from the exit helper.
  • Drop now-unneeded detector construction/imports in the affected flows.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/tower/app.rs Updates expert restart flows to call exit_expert without forcing a pending marker.
src/commands/reset.rs CLI reset now uses exit_expert and no longer constructs an ExpertStateDetector.
src/commands/common.rs Renames/simplifies the shared exit helper and removes pending marker write-back.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/commands/common.rs
Comment on lines +195 to 200
/// Send Escape + /exit to an expert and wait for it to stop.
pub async fn exit_expert(claude: &ClaudeManager, expert_id: u32) -> Result<()> {
claude.send_keys(expert_id, "Escape").await?;
claude.send_exit(expert_id).await?;
tokio::time::sleep(std::time::Duration::from_secs(3)).await;
detector
.set_marker(expert_id, "pending")
.context("Failed to set expert status to pending")?;
Ok(())
Comment thread src/commands/common.rs
Comment on lines +196 to 200
pub async fn exit_expert(claude: &ClaudeManager, expert_id: u32) -> Result<()> {
claude.send_keys(expert_id, "Escape").await?;
claude.send_exit(expert_id).await?;
tokio::time::sleep(std::time::Duration::from_secs(3)).await;
detector
.set_marker(expert_id, "pending")
.context("Failed to set expert status to pending")?;
Ok(())
@Cassin01 Cassin01 marked this pull request as ready for review April 18, 2026 05:58
Revert the set_marker("pending") call added in 8e3fe25 that was invoked
right after exiting an expert. Exit should only stop the expert; status
transitions are handled by the existing init-time seed and downstream
hooks/event handlers.

Rename the shared helper exit_expert_and_set_pending to exit_expert,
drop its detector argument, and update all five call sites (reset.rs
and four tower/app.rs flows: change_expert_role, reset_expert,
return_expert_from_worktree, launch_expert_in_worktree).

Helper consolidation and PreparedExpertFiles from 8e3fe25 are kept as-is.
@Cassin01 Cassin01 force-pushed the revert/exit-set-pending-after-exit branch from 7da0586 to 4908e16 Compare April 18, 2026 06:04
@Cassin01 Cassin01 merged commit 1df0944 into main Apr 18, 2026
1 check passed
@Cassin01 Cassin01 deleted the revert/exit-set-pending-after-exit branch April 19, 2026 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants