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

Function notify_active_sessions

atomic-cli/src/commands/git/watch.rs:435–474  ·  view source on GitHub ↗

Write one pending notice for every active managed session (RFC §11.2 rule 6: "pushed into the session as a notice before the agent's next tool call"). Notice writing is advisory: failures are logged and never change the daemon's own outcome.

(
    sessions: &SessionStore,
    root: &Path,
    kind: WatchNoticeKind,
    detail: &str,
    remediation: &str,
)

Source from the content-addressed store, hash-verified

433/// tool call"). Notice writing is advisory: failures are logged and never
434/// change the daemon's own outcome.
435fn notify_active_sessions(
436 sessions: &SessionStore,
437 root: &Path,
438 kind: WatchNoticeKind,
439 detail: &str,
440 remediation: &str,
441) {
442 let kind_code = match kind {
443 WatchNoticeKind::ExternalHeadChange => "external-head-change",
444 WatchNoticeKind::UnsafeState => "unsafe-state",
445 WatchNoticeKind::ExportSuppressed => "external-head-change",
446 };
447 let active = match sessions.active_sessions() {
448 Ok(active) => active,
449 Err(error) => {
450 log::warn!("shim watch: cannot list active sessions for notices: {error}");
451 return;
452 }
453 };
454 if active.is_empty() {
455 print_warning(&format!(
456 "shim watch: {kind_code}: {detail} ({remediation})"
457 ));
458 return;
459 }
460 let delivered = active.len();
461 for session in active {
462 if let Err(error) =
463 sessions.write_watch_notice(&session.session_id, kind_code, detail, remediation)
464 {
465 log::warn!(
466 "shim watch: could not write the watch notice for session {}: {error}",
467 session.session_id
468 );
469 }
470 }
471 print_info(&format!(
472 "shim watch: {kind_code} notice delivered to {delivered} active session(s)"
473 ));
474}
475
476/// The daemon entry point: consent, then the hint loop (or a single pass).
477pub(crate) fn run_watch(root: &Path, once: bool, poll_ms: u64) -> CliResult<()> {

Callers 1

reactive_passFunction · 0.85

Calls 6

print_warningFunction · 0.85
print_infoFunction · 0.85
active_sessionsMethod · 0.80
write_watch_noticeMethod · 0.80
is_emptyMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected