pub struct AppContext {
pub harness: Mutex<Option<Harness>>,
/* private fields */
}Expand description
Shared application context threaded through all command handlers.
Holds the language provider, backup/checkpoint stores, and configuration.
Constructed once at startup and passed by
reference to dispatch.
Write-rarely stores use parking_lot::Mutex for interior mutability so this
context can become thread-safe while preserving the current single-request
dispatch behavior. config is a thread-safe owned snapshot so future
read-only dispatch can hold configuration across other work without holding
a lock guard.
Fields§
§harness: Mutex<Option<Harness>>Implementations§
Source§impl AppContext
impl AppContext
pub fn build_status_snapshot(&self) -> StatusPayload
pub fn build_status_snapshot_for_session( &self, session_id: &str, ) -> StatusPayload
Source§impl AppContext
impl AppContext
pub fn new(provider: Box<dyn LanguageProvider>, config: Config) -> Self
pub fn from_app(app: Arc<App>, config: Config) -> Self
pub fn with_app_and_provider( app: Arc<App>, provider: Box<dyn LanguageProvider>, config: Config, ) -> Self
Sourcepub fn status_bar_counts(&self) -> Option<StatusBarCounts>
pub fn status_bar_counts(&self) -> Option<StatusBarCounts>
Current agent status-bar counts. Generation identities are checked before project scoping or tsconfig membership work, so unchanged responses reuse the last honest aggregate from the continuously drained stores.
pub fn try_health_snapshot(&self, project_root: &Path) -> RootHealthSnapshot
pub fn should_emit_status_bar(&self, counts: &StatusBarCounts) -> bool
Sourcepub fn clear_tsconfig_membership_cache(&self)
pub fn clear_tsconfig_membership_cache(&self)
Invalidate the status-bar tsconfig-membership cache. Called from the
watcher seam when a tsconfig-like file changes and from configure
when the project root changes, so the next bar count re-reads from disk.
Sourcepub fn mark_status_bar_tier2_stale(&self) -> bool
pub fn mark_status_bar_tier2_stale(&self) -> bool
Mark the status-bar Tier-2 counts stale (rendered with ~) without
changing the numbers — called when the watcher sees a source-file change,
so the bar honestly signals the counts predate the latest edit until the
next background scan completes. Returns true only when the visible stale
bit flips. No-op before the first populate.
Sourcepub fn update_status_bar_tier2(
&self,
dead_code: Option<usize>,
unused_exports: Option<usize>,
duplicates: Option<usize>,
todos: Option<usize>,
stale: bool,
)
pub fn update_status_bar_tier2( &self, dead_code: Option<usize>, unused_exports: Option<usize>, duplicates: Option<usize>, todos: Option<usize>, stale: bool, )
Refresh the cached Tier-2 + todos counts for the status bar. Each count
is Option: None preserves the last-known value (the category wasn’t
recomputed or has no real aggregate yet) so we never overwrite a real
count with a fabricated 0. stale marks the Tier-2 numbers as
not-yet-reconciled with the latest edits.
Sourcepub fn gitignore(&self) -> Option<Arc<Gitignore>>
pub fn gitignore(&self) -> Option<Arc<Gitignore>>
Borrow the cached project gitignore matcher. Returns None when no
project_root is configured or when the project has no gitignore files.
Shared gitignore matcher handle for the watcher filter thread.
Sourcepub fn gitignore_generation(&self) -> Arc<AtomicU64> ⓘ
pub fn gitignore_generation(&self) -> Arc<AtomicU64> ⓘ
Monotonic generation bumped after every matcher rebuild/clear. The watcher filter thread uses it to wait until the main thread has rebuilt ignore rules after it reports an ignore-file change.
Sourcepub fn clear_gitignore(&self)
pub fn clear_gitignore(&self)
Rebuild the gitignore matcher from the current project_root and
cache it. Called by the configure handler whenever the project root
changes, and by the watcher event drain when a .gitignore file
itself is modified.
The builder honors:
<project_root>/.gitignore- Git’s global excludes file (the same source used by
ignore::WalkBuilder) - the repository’s real
info/excludefile, resolved through Git’s common dir for linked worktrees - nested
.gitignorefiles (each.gitignorediscovered during the recursive walk)
Stores None if there’s no project_root or no matchable gitignore
files. Logs build errors but never fails configure.
Clear any cached gitignore matcher without rebuilding.
Used by handle_configure in degraded mode (e.g. project_root == $HOME)
where running the gitignore-discovery walk would exceed the configure
budget. The watcher event filter falls back to the hardcoded infra-dir
skip list when no matcher is present.
pub fn rebuild_gitignore(&self)
Sourcepub fn bash_compress_flag(&self) -> Arc<AtomicBool> ⓘ
pub fn bash_compress_flag(&self) -> Arc<AtomicBool> ⓘ
Shared atomic mirror of experimental.bash.compress. Updated by the
configure handler. Read by the BgTaskRegistry compressor closure.
Sourcepub fn sync_bash_compress_flag(&self)
pub fn sync_bash_compress_flag(&self)
Update the shared bash_compress_flag mirror. Call this from the
configure handler whenever experimental.bash.compress changes so the
BgTaskRegistry watchdog sees the new value on the next completion.
pub fn set_bash_compress_enabled(&self, enabled: bool)
Sourcepub fn filter_registry(&self) -> RwLockReadGuard<'_, FilterRegistry>
pub fn filter_registry(&self) -> RwLockReadGuard<'_, FilterRegistry>
Read-only access to the TOML filter registry, building it lazily on
first use. Returns an RwLockReadGuard that callers can lookup
against directly.
Returns the shared Arc<RwLock<FilterRegistry>> handle so threads
outside AppContext (notably the bash watchdog) can read it without
touching the rest of the context.
Sourcepub fn reset_filter_registry(&self)
pub fn reset_filter_registry(&self)
Force a fresh load of the TOML filter registry. Called when configure
changes the project root, storage_dir, or trust state so subsequent
compress::compress calls pick up new filters.
pub fn app(&self) -> Arc<App> ⓘ
Sourcepub fn lsp_child_registry(&self) -> LspChildRegistry
pub fn lsp_child_registry(&self) -> LspChildRegistry
Clone the LSP child registry handle. Used by main.rs to give the signal handler thread a way to SIGKILL LSP children on shutdown.
pub fn stdout_writer(&self) -> SharedStdoutWriter
pub fn set_progress_sender(&self, sender: Option<ProgressSender>)
pub fn emit_progress(&self, frame: ProgressFrame)
pub fn status_emitter(&self) -> &StatusEmitter
Sourcepub fn progress_sender_handle(&self) -> Option<ProgressSender>
pub fn progress_sender_handle(&self) -> Option<ProgressSender>
Get a clone of the current progress sender for use from background
threads. Returns None when the main loop hasn’t installed one (tests,
CLI without push frames).
Used by configure’s deferred file-walk thread to push warnings after
configure has already returned, so configure latency stays sub-100 ms
even on huge directories.
pub fn advance_configure_generation(&self) -> u64
Sourcepub fn note_configure_warm_key(&self, key: String) -> (u64, bool)
pub fn note_configure_warm_key(&self, key: String) -> (u64, bool)
Record the warm-maintenance key for a successful configure and return the generation this configure operates under.
An unchanged key ADOPTS the running generation without advancing it: in-flight build workers gate their publish on the generation flag being unchanged, so advancing on an equivalent rebind would silently discard every adopted build’s result at completion (the receiver never resolves, and long builds can never finish under rebind traffic). Only a genuinely different warm config advances the generation, which is what cancels superseded in-flight builds.
pub fn note_configure_session_binding( &self, root: PathBuf, session_id: String, ) -> bool
Sourcepub fn forget_configure_session_binding(&self, root: &Path, session_id: &str)
pub fn forget_configure_session_binding(&self, root: &Path, session_id: &str)
Undo Self::note_configure_session_binding when the maintenance job
carrying the session’s bash replay was dropped as stale: the session has
not actually been replayed, so its next bind must count as first again.
Sourcepub fn watcher_drain_has_work(&self) -> bool
pub fn watcher_drain_has_work(&self) -> bool
Cheap emptiness probes for the maintenance scheduler: a drain kind with no pending work is not enqueued at all, so idle roots stop paying a dispatch cycle per kind per tick. Every probe is lock-free or try-lock (a contended source reports “maybe work” and the kind is enqueued — fail-open keeps the skip an optimization, never a correctness gate).
pub fn lsp_drain_has_work(&self) -> bool
pub fn completion_drains_have_work(&self) -> bool
pub fn configure_tail_has_work(&self) -> bool
Sourcepub fn cached_artifact_cache_key(&self, canonical_root: &Path) -> Option<String>
pub fn cached_artifact_cache_key(&self, canonical_root: &Path) -> Option<String>
Peek the memoized artifact key without deriving it. Passive readers (status snapshots) use this so reporting never spawns a git probe.
pub fn memoized_artifact_cache_key(&self, canonical_root: &Path) -> String
pub fn memoized_artifact_cache_key_for_configure( &self, raw_root: &Path, canonical_root: &Path, storage_root: &Path, git_common_dir: Option<&Path>, ) -> Result<String, ArtifactCacheKeyProbeError>
pub fn configure_generation(&self) -> u64
pub fn configure_generation_flag(&self) -> Arc<AtomicU64> ⓘ
pub fn advance_semantic_fingerprint_generation(&self) -> u64
pub fn semantic_fingerprint_generation(&self) -> u64
pub fn semantic_fingerprint_generation_flag(&self) -> Arc<AtomicU64> ⓘ
pub fn configure_warnings_sender(&self) -> Sender<(u64, ConfigureWarningsFrame)>
pub fn drain_configure_warnings(&self) -> Vec<(u64, ConfigureWarningsFrame)>
pub fn bash_background(&self) -> &BgTaskRegistry
pub fn drain_bg_completions(&self) -> Vec<BgCompletion>
Sourcepub fn provider(&self) -> &dyn LanguageProvider
pub fn provider(&self) -> &dyn LanguageProvider
Access the language provider.
Sourcepub fn backup(&self) -> &Mutex<BackupStore>
pub fn backup(&self) -> &Mutex<BackupStore>
Access the backup store.
Sourcepub fn checkpoint(&self) -> &Mutex<CheckpointStore>
pub fn checkpoint(&self) -> &Mutex<CheckpointStore>
Access the checkpoint store.
pub fn set_db(&self, conn: Arc<Mutex<Connection>>)
pub fn clear_db(&self)
pub fn db(&self) -> Option<Arc<Mutex<Connection>>>
Sourcepub fn set_config(&self, config: Config)
pub fn set_config(&self, config: Config)
Atomically publish a fully-built configuration snapshot.
Sourcepub fn update_config(&self, update: impl FnOnce(&mut Config))
pub fn update_config(&self, update: impl FnOnce(&mut Config))
Clone-mutate-publish the current configuration without returning a guard.
pub fn force_restrict_guard(&self, req_id: &str) -> ForceRestrictGuard<'_>
pub fn with_force_restrict<R>(&self, req_id: &str, f: impl FnOnce() -> R) -> R
pub fn request_force_restrict(&self, req_id: &str) -> bool
pub fn set_harness(&self, harness: Harness)
pub fn harness_opt(&self) -> Option<Harness>
pub fn harness(&self) -> Harness
pub fn storage_dir(&self) -> PathBuf
pub fn harness_dir(&self) -> PathBuf
pub fn inspect_dir(&self) -> PathBuf
pub fn bash_tasks_dir(&self, session_id: &str) -> PathBuf
pub fn backups_dir(&self, session_id: &str, path_hash: &str) -> PathBuf
pub fn filters_dir(&self) -> PathBuf
Sourcepub fn trust_file(&self) -> PathBuf
pub fn trust_file(&self) -> PathBuf
HOST-GLOBAL — NOT under harness_dir. Read by trust.rs across both harnesses.
pub fn set_canonical_cache_root(&self, root: PathBuf)
pub fn canonical_cache_root(&self) -> PathBuf
pub fn canonical_cache_root_opt(&self) -> Option<PathBuf>
pub fn set_cache_role( &self, is_worktree_bridge: bool, git_common_dir: Option<PathBuf>, )
pub fn set_artifact_owner( &self, status: Option<ArtifactOwnerStatus>, lease: Option<ArtifactOwnerLease>, )
pub fn set_cache_writer_capabilities( &self, callgraph_writer: bool, inspect_writer: bool, )
pub fn callgraph_writer(&self) -> bool
pub fn inspect_writer(&self) -> bool
pub fn artifact_owner_status(&self) -> Option<ArtifactOwnerStatus>
pub fn is_worktree_bridge(&self) -> bool
pub fn git_common_dir(&self) -> Option<PathBuf>
Sourcepub fn set_degraded_reasons(&self, reasons: Vec<String>)
pub fn set_degraded_reasons(&self, reasons: Vec<String>)
Replace the current degraded-mode reasons. Empty vec = full-featured
mode (no degradation). Called by handle_configure after deciding
which subsystems to disable for this project root.
pub fn set_heavy_root_work_allowed(&self, allowed: bool)
pub fn heavy_root_work_allowed(&self) -> bool
pub fn add_degraded_reason(&self, reason: impl Into<String>) -> bool
Sourcepub fn degraded_reasons(&self) -> Vec<String>
pub fn degraded_reasons(&self) -> Vec<String>
Snapshot of current degraded-mode reasons. Order is stable
(insertion order from set_degraded_reasons) so UI rendering and
snapshot diffs are deterministic.
Sourcepub fn is_degraded(&self) -> bool
pub fn is_degraded(&self) -> bool
True iff at least one degraded reason is recorded.
pub fn cache_role(&self) -> &'static str
Sourcepub fn callgraph_store(&self) -> &RwLock<Option<Arc<ReadonlyCallGraphStore>>>
pub fn callgraph_store(&self) -> &RwLock<Option<Arc<ReadonlyCallGraphStore>>>
Access the persisted call graph store.
pub fn mark_callgraph_store_force_rebuild(&self) -> u64
pub fn fulfill_callgraph_store_force_token(&self, token: u64)
pub fn callgraph_store_dir(&self) -> PathBuf
pub fn ensure_callgraph_store( &self, ) -> Result<Option<Arc<ReadonlyCallGraphStore>>, CallGraphStoreError>
Sourcepub fn callgraph_project_root(&self) -> Option<PathBuf>
pub fn callgraph_project_root(&self) -> Option<PathBuf>
Resolve the project root used for the callgraph store: prefer the canonical cache root, falling back to the configured project root.
Sourcepub fn revalidate_callgraph_store_generation(&self)
pub fn revalidate_callgraph_store_generation(&self)
Drop a cached reader when another process published a newer generation. The next access reopens through the pointer and converges to that generation instead of serving a stale long-lived connection.
pub fn callgraph_store_for_ops(&self) -> CallgraphStoreAccess
Sourcepub fn callgraph_store_rx(
&self,
) -> &Mutex<Option<Receiver<CallGraphStoreBuildEvent>>>
pub fn callgraph_store_rx( &self, ) -> &Mutex<Option<Receiver<CallGraphStoreBuildEvent>>>
Access the callgraph-store background-build receiver (drained by the main loop once the cold build completes).
Sourcepub fn add_pending_callgraph_store_paths<I>(&self, paths: I)where
I: IntoIterator<Item = PathBuf>,
pub fn add_pending_callgraph_store_paths<I>(&self, paths: I)where
I: IntoIterator<Item = PathBuf>,
Record source-file paths that could not be applied to the writable store so the next ready-store replay can refresh them.
pub fn enqueue_callgraph_store_refresh<I>(&self, paths: I) -> boolwhere
I: IntoIterator<Item = PathBuf>,
Sourcepub fn take_pending_callgraph_store_paths(&self) -> Vec<PathBuf>
pub fn take_pending_callgraph_store_paths(&self) -> Vec<PathBuf>
Take and clear paths waiting for a ready writable store.
Paths outside the current project root are dropped: the pending sink is shared with detached refresh batches, so a batch superseded by a root change can defer paths from the PREVIOUS root after configure cleared the sink. Replaying those would index foreign files into the new root’s store (refresh accepts absolute out-of-root paths).
Sourcepub fn search_index(&self) -> &RwLock<Option<SearchIndex>>
pub fn search_index(&self) -> &RwLock<Option<SearchIndex>>
Access the search index.
Sourcepub fn search_index_rx(&self) -> &RwLock<Option<Receiver<SearchIndex>>>
pub fn search_index_rx(&self) -> &RwLock<Option<Receiver<SearchIndex>>>
Access the search-index build receiver.
pub fn add_pending_search_index_paths<I>(&self, paths: I)where
I: IntoIterator<Item = PathBuf>,
pub fn take_pending_search_index_paths(&self) -> Vec<PathBuf>
pub fn add_pending_semantic_index_paths<I>(&self, paths: I)where
I: IntoIterator<Item = PathBuf>,
pub fn take_pending_semantic_index_paths(&self) -> Vec<PathBuf>
pub fn mark_pending_semantic_corpus_refresh(&self)
pub fn take_pending_semantic_corpus_refresh(&self) -> bool
pub fn clear_pending_index_updates(&self)
pub fn inspect_manager(&self) -> Arc<InspectManager> ⓘ
pub fn add_pending_tier2_paths<I>(&self, paths: I)where
I: IntoIterator<Item = PathBuf>,
pub fn pending_tier2_paths(&self) -> Vec<PathBuf>
pub fn remove_pending_tier2_paths<I>(&self, paths: I)where
I: IntoIterator<Item = PathBuf>,
Sourcepub fn has_new_reuse_completions(&self) -> bool
pub fn has_new_reuse_completions(&self) -> bool
Returns true when one or more watcher-driven (reuse-path) Tier-2 scans
have completed since the last call, advancing the last-seen marker. The
per-request inspect drain uses this to refresh the status bar after a
background scan — those completions bypass drain_completions.
Peek variant of take_new_reuse_completions: reports whether new reuse
completions exist WITHOUT consuming the observation, so the maintenance
scheduler’s skip probe cannot swallow a status-bar refresh.
pub fn take_new_reuse_completions(&self) -> bool
pub fn reset_tier2_refresh_scheduler(&self)
pub fn request_tier2_refresh_pull(&self) -> bool
pub fn tick_tier2_refresh_scheduler( &self, changed_path_count: usize, ) -> Option<Tier2TriggerReason>
pub fn note_tier2_refresh_started(&self)
pub fn tier2_trigger_reason(&self) -> Option<&'static str>
Sourcepub fn symbol_cache(&self) -> SharedSymbolCache
pub fn symbol_cache(&self) -> SharedSymbolCache
Access the shared symbol cache.
Sourcepub fn reset_symbol_cache(&self) -> u64
pub fn reset_symbol_cache(&self) -> u64
Clear the shared symbol cache and return the new active generation.
Sourcepub fn semantic_index(&self) -> &RwLock<Option<SemanticIndex>>
pub fn semantic_index(&self) -> &RwLock<Option<SemanticIndex>>
Access the semantic search index.
Sourcepub fn semantic_index_rx(&self) -> &Mutex<Option<Receiver<SemanticIndexEvent>>>
pub fn semantic_index_rx(&self) -> &Mutex<Option<Receiver<SemanticIndexEvent>>>
Access the semantic-index build receiver.
pub fn semantic_index_status(&self) -> &RwLock<SemanticIndexStatus>
Sourcepub fn reset_semantic_cold_seed_gate_for_configure(&self) -> u64
pub fn reset_semantic_cold_seed_gate_for_configure(&self) -> u64
Reset this context’s cold semantic seed gate for a newly accepted configure and return the generation token for the worker being spawned.
pub fn semantic_cold_seed_active_flag(&self) -> Arc<AtomicBool> ⓘ
pub fn semantic_cold_seed_generation_flag(&self) -> Arc<AtomicU64> ⓘ
pub fn semantic_cold_seed_generation(&self) -> u64
pub fn semantic_cold_seed_active(&self) -> bool
pub fn schedule_semantic_cold_seed_gate_for_configure(&self)
pub fn defer_callgraph_store_warm_for_semantic_cold_seed(&self)
Sourcepub fn clear_semantic_cold_seed_gate_and_resume_deferred_work(&self)
pub fn clear_semantic_cold_seed_gate_and_resume_deferred_work(&self)
Clear the cold-seed gate and resume work that was intentionally held back while the full semantic corpus was accumulating. This entry point is used by the code that drains events from the semantic worker.
Sourcepub fn resume_deferred_work_after_semantic_cold_seed_gate_cleared(&self)
pub fn resume_deferred_work_after_semantic_cold_seed_gate_cleared(&self)
Resume work after the semantic worker has already cleared the atomic gate itself, such as on cached-index load or before a retry backoff sleep.
pub fn install_semantic_refresh_worker( &self, sender: Sender<SemanticRefreshRequest>, event_rx: Receiver<SemanticRefreshEvent>, worker_slot: SemanticRefreshWorkerSlot, )
pub fn clear_semantic_refresh_worker(&self)
pub fn semantic_refresh_sender(&self) -> Option<Sender<SemanticRefreshRequest>>
pub fn semantic_refresh_event_rx( &self, ) -> &Mutex<Option<Receiver<SemanticRefreshEvent>>>
pub fn with_semantic_refresh_retry_attempts_mut<R>( &self, f: impl FnOnce(&mut BTreeMap<PathBuf, usize>) -> R, ) -> R
pub fn clear_semantic_refresh_retry_attempts(&self, paths: &[PathBuf])
pub fn clear_all_semantic_refresh_retry_attempts(&self)
pub fn semantic_refresh_circuit_is_open(&self) -> bool
pub fn record_semantic_refresh_transient_failure( &self, trip_threshold: usize, ) -> bool
pub fn trip_semantic_refresh_circuit(&self, trip_threshold: usize)
pub fn reset_semantic_refresh_transient_failure_count(&self)
pub fn reset_semantic_refresh_circuit_after_success(&self)
pub fn semantic_refresh_transient_failure_count(&self) -> usize
pub fn semantic_refresh_probe_is_scheduled(&self) -> bool
pub fn semantic_refresh_probe_ready(&self) -> bool
pub fn take_semantic_refresh_probe_ready(&self) -> bool
pub fn ensure_semantic_refresh_probe_scheduled(&self, delay: Duration)
Sourcepub fn semantic_embedding_model(&self) -> &Mutex<Option<EmbeddingModel>>
pub fn semantic_embedding_model(&self) -> &Mutex<Option<EmbeddingModel>>
Access the cached semantic embedding model.
Sourcepub fn watcher(&self) -> &Mutex<Option<RecommendedWatcher>>
pub fn watcher(&self) -> &Mutex<Option<RecommendedWatcher>>
Access the file watcher handle (kept alive to continue watching).
Sourcepub fn watcher_rx(&self) -> &Mutex<Option<Receiver<WatcherDispatchEvent>>>
pub fn watcher_rx(&self) -> &Mutex<Option<Receiver<WatcherDispatchEvent>>>
Access the pre-filtered watcher event receiver.
Sourcepub fn watcher_drain_pending_path_count(&self) -> usize
pub fn watcher_drain_pending_path_count(&self) -> usize
Include partially consumed dispatch events when reporting drain backlog.
Sourcepub fn watcher_drain_path_slice_count(&self) -> usize
pub fn watcher_drain_path_slice_count(&self) -> usize
Number of path-budgeted watcher batches since this runtime was installed.
Sourcepub fn install_watcher_runtime(
&self,
rx: Receiver<WatcherDispatchEvent>,
runtime: WatcherThreadHandle,
)
pub fn install_watcher_runtime( &self, rx: Receiver<WatcherDispatchEvent>, runtime: WatcherThreadHandle, )
Install a watcher filter thread and its dispatch receiver. The caller must have stopped any previous watcher runtime first.
Sourcepub fn stop_watcher_runtime(&self)
pub fn stop_watcher_runtime(&self)
Stop the watcher filter thread (if any) and clear the dispatch receiver. Used on reconfigure, watcher failure, root deletion, and test teardown.
Sourcepub fn stop_watcher_runtime_in_background(&self)
pub fn stop_watcher_runtime_in_background(&self)
Request watcher shutdown without joining on the executor lane. Some platform watcher backends can block while their OS thread unwinds, so idle-root and root-deleted cleanup performs the join on a detached reaper thread instead.
Sourcepub fn watcher_registry_count(&self) -> usize
pub fn watcher_registry_count(&self) -> usize
Process-scoped watcher count used by maintenance diagnostics and regression tests. The count drops as soon as shutdown is requested.
Sourcepub fn artifact_eviction_blocked(&self) -> bool
pub fn artifact_eviction_blocked(&self) -> bool
Return whether artifact eviction would discard work that still needs a live handle. Callers use this as the single safety gate before clearing resident stores and inspect caches.
Sourcepub fn evict_idle_artifacts(&self) -> bool
pub fn evict_idle_artifacts(&self) -> bool
Drop idle root-scoped artifact handles. Persistent data remains on disk; artifact-backed query paths schedule a background reload on first use. Returns false when an active build, bash task, inspect scan, or pending disk update makes eviction unsafe.
Sourcepub fn lsp(&self) -> MutexGuard<'_, LspManager>
pub fn lsp(&self) -> MutexGuard<'_, LspManager>
Access the LSP manager.
Sourcepub fn lsp_notify_file_changed(&self, file_path: &Path, content: &str)
pub fn lsp_notify_file_changed(&self, file_path: &Path, content: &str)
Notify LSP servers that a file was written. Call this after write_format_validate in command handlers.
Sourcepub fn lsp_clear_diagnostics_for_file(&self, file_path: &Path) -> bool
pub fn lsp_clear_diagnostics_for_file(&self, file_path: &Path) -> bool
Drop cached LSP diagnostics for a deleted/renamed-away file so its
errors/warnings don’t linger in the warm set (no server republishes for
a vanished path), keeping the status bar and aft_inspect honest.
Returns true if any entry was removed. Best-effort: a contended borrow is
skipped silently (the watcher drain retries on subsequent events).
Sourcepub fn lsp_mark_diagnostics_stale_for_file(
&self,
file_path: &Path,
) -> StaleDiagnosticsMark
pub fn lsp_mark_diagnostics_stale_for_file( &self, file_path: &Path, ) -> StaleDiagnosticsMark
Mark diagnostics stale for a file changed outside AFT’s text-sync path. Best-effort: a contended LSP lock is skipped and the next watcher event or scoped diagnostics pull can reconcile the file.
Sourcepub fn lsp_resync_changed_file_for_diagnostics(&self, file_path: &Path) -> bool
pub fn lsp_resync_changed_file_for_diagnostics(&self, file_path: &Path) -> bool
Resync a watcher-stale diagnosed file with the active LSP server.
workspace/didChangeWatchedFiles tells servers that the filesystem
changed, but it does not update an already-open document’s in-memory text.
Sending the normal didOpen/didChange path gives push-only servers a chance
to publish fresh diagnostics and keeps pull-capable servers’ document state
current for the next diagnostic request.
Sourcepub fn lsp_notify_and_collect_diagnostics(
&self,
file_path: &Path,
content: &str,
timeout: Duration,
) -> PostEditWaitOutcome
pub fn lsp_notify_and_collect_diagnostics( &self, file_path: &Path, content: &str, timeout: Duration, ) -> PostEditWaitOutcome
Notify LSP and optionally wait for diagnostics.
Call this after write_format_validate when the request has "diagnostics": true.
Sends didChange to the server, waits briefly for publishDiagnostics, and returns
any diagnostics for the file. If no server is running, returns empty immediately.
v0.17.3: this is the version-aware path. Pre-edit cached diagnostics
are NEVER returned — only entries whose version matches the
post-edit document version (or, for unversioned servers, whose
epoch advanced past the pre-edit snapshot).
pub fn lsp_notify_watched_config_file( &self, file_path: &Path, change_type: FileChangeType, )
Sourcepub fn lsp_post_multi_file_write(
&self,
file_path: &Path,
content: &str,
file_paths: &[PathBuf],
params: &Value,
) -> Option<PostEditWaitOutcome>
pub fn lsp_post_multi_file_write( &self, file_path: &Path, content: &str, file_paths: &[PathBuf], params: &Value, ) -> Option<PostEditWaitOutcome>
Post-write LSP hook for multi-file edits. When the patch includes
config-file edits, notify active workspace servers via
workspace/didChangeWatchedFiles before sending the per-document
didOpen/didChange for the current file.
Sourcepub fn lsp_post_write(
&self,
file_path: &Path,
content: &str,
params: &Value,
) -> Option<PostEditWaitOutcome>
pub fn lsp_post_write( &self, file_path: &Path, content: &str, params: &Value, ) -> Option<PostEditWaitOutcome>
Post-write LSP hook: notify server and optionally collect diagnostics.
This is the single call site for all command handlers after write_format_validate.
Behavior:
- When
diagnostics: trueis inparams, notifies the server, waits until matching diagnostics arrive or the timeout expires, and returnsSome(outcome)with the verified-fresh diagnostics + per-server status. - When
diagnostics: false(or absent), just notifies (fire-and-forget) and returnsNone. Callers must NOT wrap this inSome(...); theNoneis what tells the response builder to omit the LSP fields entirely (preserves the no-diagnostics-requested response shape).
v0.17.3: default wait_ms raised from 1500 to 3000 because real-world
tsserver re-analysis on monorepo files routinely takes 2-5s. Still
capped at 10000ms.
Sourcepub fn validate_path(
&self,
req_id: &str,
path: &Path,
) -> Result<PathBuf, Response>
pub fn validate_path( &self, req_id: &str, path: &Path, ) -> Result<PathBuf, Response>
Validate that a file path falls within the configured project root.
When project_root is configured (normal plugin usage), this resolves the
path and checks it starts with the root. Returns the canonicalized path on
success, or an error response on violation.
When no project_root is configured (direct CLI usage), all paths pass
through unrestricted for backward compatibility.
Sourcepub fn validate_read_path(
&self,
req_id: &str,
session_id: &str,
path: &Path,
) -> Result<PathBuf, Response>
pub fn validate_read_path( &self, req_id: &str, session_id: &str, path: &Path, ) -> Result<PathBuf, Response>
Validate a read path, including the narrow exception for a bash artifact
registered to the requesting session. Mutating tools deliberately use
AppContext::validate_path and never receive this exception.
Sourcepub fn lsp_server_count(&self) -> usize
pub fn lsp_server_count(&self) -> usize
Count active LSP server instances.
Sourcepub fn symbol_cache_stats(&self) -> Value
pub fn symbol_cache_stats(&self) -> Value
Symbol cache statistics from the language provider.
Sourcepub fn memory_root_snapshot(&self) -> RootMemorySnapshot
pub fn memory_root_snapshot(&self) -> RootMemorySnapshot
Build one root’s memory estimate using only non-blocking lock attempts.
A contended subsystem is represented as busy rather than delaying the
status control path.
Sourcepub fn memory_snapshot(&self, current_root: Option<&Path>) -> MemorySnapshot
pub fn memory_snapshot(&self, current_root: Option<&Path>) -> MemorySnapshot
Attribute all actor roots registered in this process. Standalone mode has no actor registry, so the current context is inserted directly.
Trait Implementations§
Source§impl Drop for AppContext
impl Drop for AppContext
Auto Trait Implementations§
impl !Freeze for AppContext
impl !RefUnwindSafe for AppContext
impl !UnwindSafe for AppContext
impl Send for AppContext
impl Sync for AppContext
impl Unpin for AppContext
impl UnsafeUnpin for AppContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more