MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / apply_common_actions

Function apply_common_actions

atomic-agent/src/turn/phase.rs:632–659  ·  view source on GitHub ↗

Apply the common (non-strategy-specific) actions from a transition result to the given session state. This updates `phase`, `last_interaction`, and `ended_at` as indicated by the transition actions. Returns the subset of actions that require strategy-specific handling (e.g., `RecordTurn`, `RecordIfChanged`, `WarnStaleSession`). The caller is responsible for dispatching those. # Example ```rust

(
    state: &mut S,
    result: &TransitionResult,
)

Source from the content-addressed store, hash-verified

630/// // session.last_interaction was updated
631/// ```
632pub fn apply_common_actions<S: SessionState>(
633 state: &mut S,
634 result: &TransitionResult,
635) -> Vec<Action> {
636 state.set_phase(result.new_phase);
637
638 let mut remaining = Vec::new();
639
640 for action in &result.actions {
641 match action {
642 Action::UpdateInteraction => {
643 state.touch_interaction();
644 }
645 Action::ClearEndedAt => {
646 state.clear_ended_at();
647 }
648 // Strategy-specific actions are passed through
649 Action::RecordTurn
650 | Action::RecordIfChanged
651 | Action::DiscardIfNoFiles
652 | Action::WarnStaleSession => {
653 remaining.push(*action);
654 }
655 }
656 }
657
658 remaining
659}
660
661// All phases and events for exhaustive testing
662

Calls 4

set_phaseMethod · 0.45
touch_interactionMethod · 0.45
clear_ended_atMethod · 0.45
pushMethod · 0.45