Navigation Recovery State Machine (state/navigation_recovery.rs)

vtcode · src/agent/runloop/unified/state/navigation_recovery.rs · rust · Apache-2.0
automation, ui, ai, lang:rust, tag:recovery

Implements a state machine controlling navigation synthesis and execution, allowing one automatic recovery attempt per user request before blocking further actions.

// Source: https://github.com/vinhnx/vtcode | License: Apache-2.0 | Copyright 2025 Vinh Nguyen
// Provided via justclaw.it.com; keep this notice with the code.
//! One navigation synthesis/execution allowance per genuine user request.

#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub(crate) enum NavigationRecovery {
    #[default]
    Ready,
    Synthesizing,
    Consumed,
    Blocked,
}

impl NavigationRecovery {
    pub(crate) fn arm(&mut self) {
        *self = match self {
            Self::Ready | Self::Synthesizing => Self::Synthesizing,
            Self::Consumed | Self::Blocked => Self::Blocked,
        };
    }

    pub(crate) fn consume(&mut self) -> bool {
        if *self != Self::Synthesizing {
            return false;
        }
        *self = Self::Consumed;
      

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key