pub struct WorktreesService { /* private fields */ }Expand description
Hosts the cross-window WorktreesRegistry as a DaemonService.
Implementations§
Source§impl WorktreesService
impl WorktreesService
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates the service with an empty registry. Cheap — no I/O and no task;
the daemon calls start_menu_refresh to begin
off-thread menu caching, while tests use the bare service (menu computed
inline on demand).
Starts the background task that recomputes the tray menu snapshot every
[menu_refresh_interval] off the main thread — git enrichment is
blocking disk I/O — and stores it in menu_cache, so
the macOS tray’s menu() serves a cache instead of running git on the GUI
event loop. Idempotent, and a no-op outside a tokio runtime (mirroring the
Snowflake keep-alive heartbeat), so unit tests that build a bare service
keep computing the menu inline.
Sourcepub fn start_pr_poller(&self)
pub fn start_pr_poller(&self)
Starts the background task that keeps PR check badges fresh (#1337).
This is the half of the badge nothing else can do. Badges used to be resolved extension-side on repo-expand, so they were recomputed only when a repo node’s children were rebuilt — and the streamed snapshot carries worktree topology, not CI. While CI ran and no window opened or closed, nothing re-asked GitHub and a badge stayed wrong indefinitely.
The loop resolves every (repo, branch) pair in one gh api graphql call
(cost 1, independent of repo/worktree/window count), writes the cache the
tree snapshot reads, and bumps the registry’s change-notify only when a
verdict actually moved — so the server’s diff pushes to every open window
exactly when CI state changes, and never otherwise.
Cadence adapts: [pr_poll_interval] (~10 s) while any badge is pending,
doubling to [MAX_PR_POLL_INTERVAL] once everything is terminal, and it
polls nothing at all while no window is registered. That is a battery and
wakeup concern rather than a budget one.
Idempotent, and a no-op outside a tokio runtime (mirroring
start_menu_refresh and the Snowflake keep-alive
heartbeat), so unit tests build a bare service that never spawns gh.
Trait Implementations§
Source§impl DaemonService for WorktreesService
impl DaemonService for WorktreesService
Source§fn name(&self) -> &'static str
fn name(&self) -> &'static str
service field) and to label its status/menu.Source§fn handle<'life0, 'life1, 'async_trait>(
&'life0 self,
op: &'life1 str,
payload: Value,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn handle<'life0, 'life1, 'async_trait>(
&'life0 self,
op: &'life1 str,
payload: Value,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn subscribe(
&self,
op: &str,
_payload: &Value,
) -> Option<Box<dyn ServiceStream>>
fn subscribe( &self, op: &str, _payload: &Value, ) -> Option<Box<dyn ServiceStream>>
None when
op is not one this service streams (the default for every service). Read moremenu,
identified by its MenuAction::id.