Skip to main content

zeph_worktree/
handle.rs

1// SPDX-License-Identifier: MIT
2//! [`WorktreeHandle`] — a live record of a managed git worktree.
3
4use std::{path::PathBuf, time::SystemTime};
5
6/// A live record of a git worktree that [`WorktreeManager`][crate::WorktreeManager]
7/// has created for a subagent.
8///
9/// Handles are stored in-memory for the duration of the session.  They are not
10/// persisted to disk; on restart, [`WorktreeManager::reconcile`][crate::WorktreeManager::reconcile]
11/// re-discovers handles from the git worktree registry.
12#[derive(Debug, Clone)]
13pub struct WorktreeHandle {
14    /// Absolute path on disk where the worktree was checked out.
15    pub path: PathBuf,
16    /// The git branch name created for this worktree.
17    pub branch_name: String,
18    /// The resolved base ref used to create the branch.
19    ///
20    /// `"HEAD"` for [`WorktreeBaseRef::Head`][zeph_config::WorktreeBaseRef::Head],
21    /// `"origin/{branch}"` for [`WorktreeBaseRef::Fresh`][zeph_config::WorktreeBaseRef::Fresh].
22    pub base_ref_resolved: String,
23    /// The subagent identifier that this worktree was created for.
24    pub subagent_id: String,
25    /// Wall-clock time when the worktree was created.
26    pub created_at: SystemTime,
27}