| 492 | } |
| 493 | |
| 494 | fn transition_from_active(event: Event) -> TransitionResult { |
| 495 | match event { |
| 496 | // Turn start while active → Ctrl-C recovery, continue |
| 497 | // The previous turn was interrupted — just continue with the new one. |
| 498 | // Any pending changes from the interrupted turn will be captured |
| 499 | // when this new turn ends. |
| 500 | Event::TurnStart => { |
| 501 | TransitionResult::with_actions(Phase::Active, vec![Action::UpdateInteraction]) |
| 502 | } |
| 503 | |
| 504 | // Turn ended → go idle, record the turn |
| 505 | Event::TurnEnd => TransitionResult::with_actions( |
| 506 | Phase::Idle, |
| 507 | vec![Action::RecordTurn, Action::UpdateInteraction], |
| 508 | ), |
| 509 | |
| 510 | // A record happened mid-turn → note it, defer turn recording to TurnEnd |
| 511 | Event::Recorded => { |
| 512 | TransitionResult::with_actions(Phase::ActiveRecorded, vec![Action::UpdateInteraction]) |
| 513 | } |
| 514 | |
| 515 | // Another session started while this one is active → warn |
| 516 | Event::SessionStart => { |
| 517 | TransitionResult::with_actions(Phase::Active, vec![Action::WarnStaleSession]) |
| 518 | } |
| 519 | |
| 520 | // Session stopped while active → end |
| 521 | Event::SessionStop => { |
| 522 | TransitionResult::with_actions(Phase::Ended, vec![Action::UpdateInteraction]) |
| 523 | } |
| 524 | } |
| 525 | } |
| 526 | |
| 527 | fn transition_from_active_recorded(event: Event) -> TransitionResult { |
| 528 | match event { |