web_ui: scope /cancel and /logout's SIGINT to the harness's own claude child
This commit is contained in:
parent
29a11476a4
commit
3617578341
3 changed files with 79 additions and 24 deletions
|
|
@ -9,7 +9,7 @@ use axum::{
|
|||
};
|
||||
use serde::Deserialize;
|
||||
|
||||
use super::{AppState, error_response};
|
||||
use super::{AppState, SigintOutcome, error_response};
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub(super) struct SendForm {
|
||||
|
|
@ -54,26 +54,19 @@ pub(super) async fn post_send(
|
|||
pub(super) async fn post_cancel_turn(State(state): State<AppState>) -> Response {
|
||||
let out = super::sigint_claude().await;
|
||||
let note = match out {
|
||||
Ok(o) if o.status.success() => {
|
||||
SigintOutcome::Signalled => {
|
||||
// A process actually got signalled — the *next* turn's wake
|
||||
// prompt should tell the agent it was cut off mid-work. Only
|
||||
// set on an actual signal: a `pkill` exit 1 ("no process to
|
||||
// interrupt") means /cancel raced an already-finished turn, so
|
||||
// there's nothing to flag as interrupted.
|
||||
// set on an actual signal: `NoProcess` means /cancel raced an
|
||||
// already-finished turn, so there's nothing to flag as
|
||||
// interrupted.
|
||||
state
|
||||
.interrupted
|
||||
.store(true, std::sync::atomic::Ordering::Relaxed);
|
||||
"operator: /cancel — sent SIGINT to claude".to_owned()
|
||||
}
|
||||
Ok(o) if o.status.code() == Some(1) => {
|
||||
"operator: /cancel — no claude process to interrupt".to_owned()
|
||||
}
|
||||
Ok(o) => format!(
|
||||
"operator: /cancel — pkill exited {} stderr={}",
|
||||
o.status,
|
||||
String::from_utf8_lossy(&o.stderr).trim()
|
||||
),
|
||||
Err(e) => format!("operator: /cancel — pkill failed: {e}"),
|
||||
SigintOutcome::NoProcess => "operator: /cancel — no claude process to interrupt".to_owned(),
|
||||
SigintOutcome::Failed(e) => format!("operator: /cancel — kill failed: {e}"),
|
||||
};
|
||||
state
|
||||
.bus
|
||||
|
|
|
|||
Loading…
Reference in a new issue