Skip to main content

AppState

Struct AppState 

Source
pub struct AppState {
Show 15 fields pub agent: Option<Arc<Agent>>, pub store: SessionStore, pub model: String, pub config_error: Option<String>, pub yolo: Yolo, pub unasked: AtomicUsize, pub config_path: Option<PathBuf>, pub profile: Option<String>, pub config_explicit: bool, pub profiles_root: Option<PathBuf>, pub cron_root: Option<PathBuf>, pub config_writes: Arc<Mutex<()>>, pub model_probe: Arc<Mutex<Option<(Instant, bool)>>>, pub update: Option<Watch>, pub bots: Bots, /* private fields */
}

Fields§

§agent: Option<Arc<Agent>>

None when the provider is not configured; the dashboard still starts.

§store: SessionStore§model: String§config_error: Option<String>§yolo: Yolo

#285: /yolo for this dashboard process. One server, many tabs — so the switch is the server’s, read per run when the approver decides, and every tab sees the same state after a reload. That is the opposite of the terminal’s rule, and the reason is in the sentence the module already wrote down: a mode nobody can see must not be reachable. Here the page can show it (the stats row), so it can survive a reload — a mode that vanished on F5 would be exactly the invisible one.

§unasked: AtomicUsize

Tool calls this dashboard has run without a card, since the process started. The honest minimum the issue asked for: an approval-off state has to say how much has already gone by.

§config_path: Option<PathBuf>

The config file this process was started with, and the profile overlay in force. The settings endpoints read and write that file rather than a copy in memory: what the next run loads is the file, so what a page shows has to be the file too.

§profile: Option<String>§config_explicit: bool

Whether config_path came from --config rather than from $ECLIPSE_CONFIG. It decides one thing: an explicit file is the file a write lands in, exactly as config set treats it (config::write_target). A path the process merely defaulted to is not explicit, so a served profile’s overlay is where its writes go (#571).

§profiles_root: Option<PathBuf>

Where profiles/ lives — [eclipse_core::config::home_root], the directory the config layout hangs off. The served profile's overlay is under it, and so is the file a dashboard write lands in (#571). None` when this process has no home, and then there is nowhere to write but the file it was started with.

§cron_root: Option<PathBuf>

The install root whose cron state is probed by /healthz. None in unit tests.

§config_writes: Arc<Mutex<()>>

One writer at a time to config_path (#399). A setting is a read-edit-write over the whole file, so two overlapping writes both read the old text and the later one silently drops the earlier one — the value the user saw confirmed is simply gone. Held inside the blocking closure, never across an await.

§model_probe: Arc<Mutex<Option<(Instant, bool)>>>

Last model-reachability probe, cached so /healthz is not a slow request every hit. (when, reachable); None when no probe has run yet.

§update: Option<Watch>

Where the update badge is read from, when this process has an install to report on. None in unit tests and in a checkout with no marker: the page then shows nothing rather than inventing a version. A read, never a check — the gateway’s schedule owns the network.

§bots: Bots

#509: the bots this config declared, each with the agent its conversation runs on. Empty for every config without [bots], which is what keeps the page identical for someone who has none.

Implementations§

Source§

impl AppState

Source

pub fn new( agent: Option<Arc<Agent>>, store: SessionStore, model: String, config_error: Option<String>, auth_token: String, login_ttl: Duration, ) -> Self

Source

pub fn with_bots(self, cfg: &Config, env: EnvFn<'_>) -> Self

#509: the bots the config declared, with one agent each built from their declaration.

A bot whose agent could not be built keeps the reason rather than failing startup: a broken bot must not be able to lock the person out of their own dashboard.

Source

pub fn claim_tick(&self, session: &str) -> bool

Claim a session’s loop tick for this process. false when another sweep already has it.

Source

pub fn release_tick(&self, session: &str)

Release the claim. Called from the tick’s own task, however it ended.

Source

pub fn try_chat_slot(&self) -> Option<OwnedSemaphorePermit>

Take one of the MAX_CONCURRENT_CHATS slots, or None when the cap is reached. The permit is held for the length of the run, so a caller takes it before starting the agent and drops it when the response is done. Every route that can start a run goes through here — the dashboard’s own handler included — so the cap is one number and not one per surface.

Source

pub fn token(&self) -> &str

The shared credential the API checks as Authorization: Bearer. A getter rather than a public field: the token is a credential, and the only readers should be auth checks.

Source

pub fn with_credentials(self, auth: Credentials) -> Self

What a person signs in with. Set at startup from .env; Token until then.

Source

pub fn auth_mode(&self) -> &'static str

How the sign-in page should describe itself: password or token.

Source

pub fn with_cron_root(self, root: PathBuf) -> Self

Where cron state lives, for the health check.

Source

pub fn with_config_path( self, path: Option<PathBuf>, profile: Option<String>, ) -> Self

Where this process reads its config from, for the settings page.

Source

pub fn with_config_targets( self, explicit: bool, profiles_root: Option<PathBuf>, ) -> Self

Whether that path was given with --config, and where profiles/ lives. See AppState::config_explicit and AppState::profiles_root.

Source

pub fn current_model(&self) -> Option<String>

What the next turn will be asked for. A model chosen in the picker wins over the one the file names, so the header cannot keep claiming the old one after a switch.

Public because the gateway’s /v1 door asks the same question — a reply that names a different model than the one that answered is the one thing a client cannot check.

Auto Trait Implementations§

§

impl !Freeze for AppState

§

impl !RefUnwindSafe for AppState

§

impl !UnwindSafe for AppState

§

impl Forget for AppState

§

impl Move for AppState

§

impl Send for AppState
where Arc<Agent>: Send, RawVecInner: Send, Arc<Mutex<Option<Db>>>: Send, Arc<Semaphore>: Send, Mutex<HashMap<String, Pending>>: Send, Atomic<u64>: Send, Mutex<HashMap<String, Cancel>>: Send, Arc<Atomic<bool>>: Send, Atomic<usize>: Send, Mutex<HashMap<String, Session>>: Send, Mutex<Attempts>: Send, Arc<Mutex<()>>: Send, Arc<Mutex<Option<(Instant, bool)>>>: Send, Mutex<HashSet<String>>: Send, NodeRef<Owned, String, Result<Arc<Agent>, String>, LeafOrInternal>: Send, BoxRaw<(String, Result<Arc<Agent>, String>)>: Send, NodeRef<Owned, String, BotConfig, LeafOrInternal>: Send, BoxRaw<(String, BotConfig)>: Send,

§

impl Sync for AppState
where Arc<Agent>: Sync, RawVecInner: Sync, Arc<Mutex<Option<Db>>>: Sync, Arc<Semaphore>: Sync, Mutex<HashMap<String, Pending>>: Sync, Atomic<u64>: Sync, Mutex<HashMap<String, Cancel>>: Sync, Arc<Atomic<bool>>: Sync, Atomic<usize>: Sync, Mutex<HashMap<String, Session>>: Sync, Mutex<Attempts>: Sync, Arc<Mutex<()>>: Sync, Arc<Mutex<Option<(Instant, bool)>>>: Sync, Mutex<HashSet<String>>: Sync, NodeRef<Owned, String, Result<Arc<Agent>, String>, LeafOrInternal>: Sync, BoxRaw<(String, Result<Arc<Agent>, String>)>: Sync, NodeRef<Owned, String, BotConfig, LeafOrInternal>: Sync, BoxRaw<(String, BotConfig)>: Sync,

§

impl Unpin for AppState
where Arc<Agent>: Unpin, *const u8 is !null: Unpin, Arc<Mutex<Option<Db>>>: Unpin, Arc<Semaphore>: Unpin, Align4<u32>: Unpin, Align1<u8>: Unpin, Arc<Inner<bool>>: Unpin, Align8<u64>: Unpin, Arc<Inner>: Unpin, Arc<Atomic<bool>>: Unpin, Align8<usize>: Unpin, Arc<Mutex<()>>: Unpin, Arc<Mutex<Option<(Instant, bool)>>>: Unpin, *const LeafNode<String, Result<Arc<Agent>, String>> is !null: Unpin, Box<(String, Result<Arc<Agent>, String>)>: Unpin, *const LeafNode<String, BotConfig> is !null: Unpin, Box<(String, BotConfig)>: Unpin,

§

impl UnsafeUnpin for AppState

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more