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: AtomicUsizeTool 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: boolWhether 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
impl AppState
pub fn new( agent: Option<Arc<Agent>>, store: SessionStore, model: String, config_error: Option<String>, auth_token: String, login_ttl: Duration, ) -> Self
Sourcepub fn with_bots(self, cfg: &Config, env: EnvFn<'_>) -> Self
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.
Sourcepub fn claim_tick(&self, session: &str) -> bool
pub fn claim_tick(&self, session: &str) -> bool
Claim a session’s loop tick for this process. false when another sweep already has it.
Sourcepub fn release_tick(&self, session: &str)
pub fn release_tick(&self, session: &str)
Release the claim. Called from the tick’s own task, however it ended.
Sourcepub fn try_chat_slot(&self) -> Option<OwnedSemaphorePermit>
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.
Sourcepub fn token(&self) -> &str
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.
Sourcepub fn with_credentials(self, auth: Credentials) -> Self
pub fn with_credentials(self, auth: Credentials) -> Self
What a person signs in with. Set at startup from .env; Token until then.
Sourcepub fn auth_mode(&self) -> &'static str
pub fn auth_mode(&self) -> &'static str
How the sign-in page should describe itself: password or token.
Sourcepub fn with_cron_root(self, root: PathBuf) -> Self
pub fn with_cron_root(self, root: PathBuf) -> Self
Where cron state lives, for the health check.
Sourcepub fn with_config_path(
self,
path: Option<PathBuf>,
profile: Option<String>,
) -> Self
pub fn with_config_path( self, path: Option<PathBuf>, profile: Option<String>, ) -> Self
Where this process reads its config from, for the settings page.
Sourcepub fn with_config_targets(
self,
explicit: bool,
profiles_root: Option<PathBuf>,
) -> Self
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.
Sourcepub fn current_model(&self) -> Option<String>
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.