Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
364 changes: 364 additions & 0 deletions design/hide-screens.pen

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ A count Hide cannot read is reported as unknown, never as zero.

A pane's parent travels the same channel, and it is the only lineage there is: Herdr records none.
hided is the sole writer of `parent_pane`, optional `parent_machine`, `child_session` and `parent_session` through `pane.report_metadata`; the unchanged value and lifetime contract is described in [status-model.md](status-model.md#where-a-parent-comes-from).
Fork agent adds one more, `fork`, on the pane it made, so the pane header can say a pane is a fork and a delegated child is not drawn as one.
Those tokens die with the pane, not with the agent, so a relationship holds only while both panes still report the sessions it was written for: `wire.rs` compares the child's, `agent_state::apply_lineage` the parent's, and an agent that took over a pane is a root.
A spawn without `--parent` is an operator handoff: `AgentRecord.parent` is empty and its separate optional `origin` records the spawner.
Delegated origin is derived from parent, and all CLI agent answers include nullable origin.
Expand Down
2 changes: 1 addition & 1 deletion docs/DESIGN_WORKFLOW.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ Workspace is `Screen / Workspace`.
It draws docked Agent Views, File Views and Tools beneath one full-width toolbar, using the Workspace columns, toolbar, toggle and divider masters in the library.
The toolbar's right edge carries Open server, File Views and Tools, with independent pressed states, a count when open File Views are hidden, and per-control tooltip and keyboard-focus states.
The columns start with their own tab strips; File Views carries its document header and Tools carries Sessions, Explorer and History, with Sessions first and the selection saved per Workspace.
The pane header's ancestor path, own PR mark, tree button and ask band follow the approved agent-hierarchy round 2 reference, the pane header board on this sheet, in both themes, and `design/review-targets.json` names it as the `pane-header` target.
The pane header's ancestor path, fork mark, own PR mark, tree button and ask band follow the approved agent-hierarchy round 2 reference, the pane header board on this sheet, in both themes (the fork mark is the issue 916 addition, chosen by the operator as a small icon after the title and drawn in the board's Forked pane section), and `design/review-targets.json` names it as the `pane-header` target.
The reference includes the full layout, both narrow-window fallbacks and explicit column calls, Tools without File Views, saved widths, and the divider at rest, under the pointer, focused and being dragged.
Light and Dark frames carry Korean text and long paths, including the one-line shortened document path and its full-path tooltip.
The server-picker comparison retains its distinct reachable endpoints, and the area-focus comparison retains two View areas with one keyboard owner and independently readable selections.
Expand Down
4 changes: 3 additions & 1 deletion docs/UI_BEHAVIOR.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,12 @@ The browser display's toolbar and its loading, load failed, and plain browser ta

### Agent panes and the Agents explorer

A pane header is a quiet identity row: the ancestor path, provider, title, the pane's own PR mark, the tree button, the Not connected chip, and the retained overflow, zoom and close controls at the right end.
A pane header is a quiet identity row: the ancestor path, provider, title, the fork mark, the pane's own PR mark, the tree button, the Not connected chip, and the retained overflow, zoom and close controls at the right end.
A plain shell keeps its terminal mark.
A child pane's ancestor path names each ancestor from the root to its parent, `›` between them, and each name opens that pane; a root has none.
The names drop before current identity or actions when the pane narrows, leaving `›` with its accessible name.
The PR mark shows the pane's own PRs only, as Sessions draws them (below); a descendant's PRs stay on its own rows.
The fork mark, a small fork icon after the title, is drawn only on a pane Fork agent made; its tooltip and accessible name read `Forked from <source name>`, or `Forked from another pane` when that pane is no longer in the lineage, and a delegated child that was not forked has none (`web/src/PaneHeaderBand.tsx`, `PaneForkMark`; the fact is the core's, `PaneForkSnapshot.forked_from_pane_id`).
The tree button, a tree icon and the direct child count with `자식 에이전트 N` as its tooltip, opens the tree popover (docs/status-model.md, The descendant mark and the tree popover).
There is no status sentence, child-chip row or relationship sheet.
The zoom control names the panes it hides and unzooms the tab; the existing pane keyboard outline and focused-header wash remain.
Expand All @@ -340,6 +341,7 @@ A pane whose agent sleeps (PRD agent-sleep) shows its state in place of the term
The core band reads Sleeping, Waking or the resume failure, and typed input to the pane goes nowhere.
Opening the pane's tab by a committed move (a row, a tab, a checkout, a relation) wakes it in the same pane with its conversation; a Recent Panels preview does not, and neither does a click inside the tab already on screen.
The pane menu offers Sleep agent on an agent pane that is awake on this machine, or on the machine the window runs on when that machine's core runs on another machine, disabled with the core's reason when the agent is working, waiting for the operator, of another kind, or has no conversation Herdr reported; a device's pane offers none.
Fork agent follows it in the same group: it is offered on a local agent pane whose conversation Herdr reported (`fork.available`) and sends `fork_pane`, which starts that conversation again as a new session in a pane of its own; on an agent that has a fork command but has not reported its conversation yet it is drawn disabled with the core's reason, and on a shell or an agent with no fork command there is no item.
On such a window's own machine, bringing a tab forward wakes what sleeps there once that machine's Herdr has it in front.
Web owner: `web/src/PaneView.tsx` (`SleepBody`), `web/src/sleep.ts`, `web/src/PaneRelations.tsx`.

Expand Down
1 change: 1 addition & 0 deletions docs/status-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ The CLI's required `origin` field records the spawner in both modes (null for or
PR and issue panels still find the independent session through its own branch records without a delegated-by line.
Herdr records no lineage, so hided writes the four pane tokens through `pane.report_metadata`: `parent_pane` names the parent's pane id, `parent_machine` names its machine when the parent is remote, and `child_session` and `parent_session` are the original session digests.
The value and lifetime contract is unchanged.
A pane Hide's Fork agent made carries a fifth token, `fork` set to `1`, which the lineage writer writes with the other four from the registration's `forked` fact (`AgentRecord::forked`), so a wake that continues the registration in another pane writes it there too, and which is read only while the row still declares its parent, so a pane that hosts another agent later is not a fork and a delegated child never is (`SidebarAgentSnapshot.started_as_fork`, `PaneForkSnapshot.forked_from_pane_id`).
The session tokens are lowercase hexadecimal SHA-256 digests of each original `agent_session.value`; this keeps even a path-valued session inside Herdr's 80-character token limit.
A same-server relationship omits `parent_machine`.
A changed child session clears all four tokens, while an absent session proves neither a valid relationship nor a session change.
Expand Down
1 change: 1 addition & 0 deletions herdr-core/src/agent_sleep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,7 @@ mod tests {
descendant_line: None,
id: pane_id.to_owned(),
herdr_name: None,
started_as_fork: false,
pane_id: pane_id.to_owned(),
workspace_label: "Fixture".to_owned(),
identity_label: "Refactor the parser".to_owned(),
Expand Down
8 changes: 7 additions & 1 deletion herdr-core/src/coordination/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ fn record(
project,
actor: actor_for(agent, host.machine, host.on_node)?,
ended: false,
forked: false,
})
}

Expand Down Expand Up @@ -336,6 +337,7 @@ pub(crate) fn register_code_owned(
project: None,
actor: actor.clone(),
ended: false,
forked: false,
};
let registered = mutate(
client,
Expand Down Expand Up @@ -996,7 +998,7 @@ pub(crate) fn link_fork(
None,
native_parent.agent.as_deref().ok_or("parent_unavailable")?,
)?;
let child_record = record(
let mut child_record = record(
&native_child,
HostIdentity {
machine: &actor.device_id,
Expand All @@ -1009,6 +1011,7 @@ pub(crate) fn link_fork(
Some(parent_id),
native_child.cwd.clone(),
)?;
child_record.forked = true;
let value = mutate(
&client,
&authority,
Expand Down Expand Up @@ -1141,6 +1144,7 @@ mod tests {
origin: None,
project: None,
ended: false,
forked: false,
actor: actor.clone(),
},
check: false,
Expand Down Expand Up @@ -1365,6 +1369,7 @@ mod tests {
origin: None,
project: None,
ended: false,
forked: false,
actor: Actor {
pane_id: "sender".into(),
name: "sender".into(),
Expand Down Expand Up @@ -1461,6 +1466,7 @@ mod tests {
project: Some("/fixture/topic".into()),
actor: child_actor.clone(),
ended: false,
forked: false,
};
let child_id = super::super::apply(
&mut state,
Expand Down
51 changes: 49 additions & 2 deletions herdr-core/src/coordination/lineage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,24 @@ fn desired(
} else {
[Value::Null, Value::Null, Value::Null, Value::Null]
};
KEYS.into_iter()
let mut tokens = KEYS
.into_iter()
.zip(values)
.map(|(key, value)| (key.into(), value))
.collect()
.collect::<BTreeMap<String, Value>>();
// A fork carries its mark on the pane that hosts its registration, for as
// long as the lineage holds; it is cleared with it (`wire::FORK_TOKEN`).
if record.forked {
tokens.insert(
crate::wire::FORK_TOKEN.into(),
if live.is_some() {
Value::String("1".into())
} else {
Value::Null
},
);
}
tokens
}
fn plan(ledger: &Ledger, device: &str, agents: &[ProjectedAgent]) -> Vec<Patch> {
if ledger.agents.is_empty() {
Expand Down Expand Up @@ -350,6 +364,7 @@ mod tests {
session: crate::wire::session_digest(session),
},
ended: false,
forked: false,
}
}
#[test]
Expand Down Expand Up @@ -379,6 +394,38 @@ mod tests {
);
}
#[test]
fn a_forks_registration_carries_the_mark_only_while_its_lineage_holds() {
let parent = record("agent-1", "w1:p1", "parent", None);
let mut child = record("agent-2", "w2:p1", "child", Some(&parent.id));
let delegated = desired(&child, Some(&parent), child.actor.session.as_deref());
assert!(!delegated.contains_key("fork"));
child.forked = true;
let live = desired(&child, Some(&parent), child.actor.session.as_deref());
assert_eq!(live["fork"], "1");
assert!(desired(&child, Some(&parent), Some("replacement"))["fork"].is_null());
}
#[test]
fn a_fork_that_is_woken_in_another_pane_wears_the_mark_there() {
let parent = record("agent-1", "w1:p1", "parent", None);
let mut child = record("agent-2", "w2:p1", "child", Some(&parent.id));
child.forked = true;
// The wake continues the registration in a pane Herdr just made, which
// carries none of the tokens the closed pane held.
child.pane = "w3:p1".into();
child.actor.pane_id = "w3:p1".into();
let woken = agent(&child, BTreeMap::new());
let ledger = Ledger {
next_id: 3,
agents: vec![parent, child],
..Default::default()
};
let patches = plan(&ledger, crate::node::TEST_NODE, &[woken]);
assert_eq!(patches.len(), 1);
assert_eq!(patches[0].pane, "w3:p1");
assert_eq!(patches[0].tokens["fork"], "1");
assert_eq!(patches[0].tokens["parent_pane"], "w1:p1");
}
#[test]
fn an_ended_registration_keeps_lineage_and_same_server_omits_machine() {
let mut parent = record("agent-1", "w1:p1", "parent", None);
let mut child = record("agent-2", "w2:p1", "child", Some(&parent.id));
Expand Down
6 changes: 6 additions & 0 deletions herdr-core/src/coordination/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ pub struct AgentRecord {
pub project: Option<String>,
pub actor: Actor,
pub ended: bool,
/// Made by Fork agent: the conversation is another execution's, resumed
/// as a new session. The registration owns the fact, so it follows the
/// registration to the pane that wakes it.
#[serde(default)]
pub forked: bool,
}

#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
Expand Down Expand Up @@ -943,6 +948,7 @@ mod tests {
session: crate::wire::session_digest(session),
},
ended: false,
forked: false,
}
}
fn register(ledger: &mut Ledger, record: AgentRecord, caller: &Actor) -> String {
Expand Down
1 change: 1 addition & 0 deletions herdr-core/src/delivery/doorbell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,7 @@ mod tests {
project: None,
actor: sender.clone(),
ended: false,
forked: false,
});
assert_eq!(
line(&ledger, &letter),
Expand Down
1 change: 1 addition & 0 deletions herdr-core/src/factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3468,6 +3468,7 @@ mod tests {
project: Some(owned.worktree.clone()),
actor,
ended: false,
forked: false,
});
}
ledger.next_id = 3;
Expand Down
66 changes: 66 additions & 0 deletions herdr-core/src/fork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,72 @@ pub fn is_forkable(agent_kind: Option<&str>, session_id: Option<&str>) -> bool {
mod tests {
use super::*;

/// A row Herdr lists running `kind` with `session`, under the lineage
/// tokens Hide writes for a child of `parent` and, for a fork, the fork mark.
fn listed(
kind: &str,
session: Option<&str>,
parent: Option<&str>,
fork_mark: bool,
) -> crate::model::SidebarAgentSnapshot {
let mut agent = serde_json::json!({
"id": "w1:p2", "pane_id": "w1:p2", "agent": kind, "agent_status": "idle", "state_change_seq": 1,
"spawned_from_pane_id": parent,
"tokens": if fork_mark { serde_json::json!({"fork": "1"}) } else { serde_json::json!({}) },
});
agent["spawned_from_pane_id"] = parent.map_or(serde_json::Value::Null, Into::into);
let mut row = crate::sidebar::project_agents(
crate::sidebar::owned_label_fixture(serde_json::json!({"agents": [agent]})).unwrap(),
)
.agents
.remove(0);
row.session_id = session.map(str::to_owned);
row
}

#[test]
fn a_forkable_agent_with_a_session_offers_fork_and_one_without_says_why() {
let fork = |kind, session| {
crate::runtime::pane_fork_snapshot(Some(&listed(kind, session, None, false)))
};
let ready = fork("claude", Some("s-1"));
assert!(ready.available && ready.reason.is_none());
let waiting = fork("claude", None);
assert!(!waiting.available);
assert!(waiting.reason.is_some());
// An agent that has no fork command, and a pane with no agent, offer
// nothing and owe no reason.
let never = fork("cursor", Some("s-1"));
assert!(!never.available && never.reason.is_none());
assert_eq!(
crate::runtime::pane_fork_snapshot(None),
crate::model::PaneForkSnapshot::default()
);
}

#[test]
fn only_a_pane_the_fork_marked_says_which_pane_it_was_forked_from() {
let forked = listed("claude", Some("s-2"), Some("w1:p1"), true);
assert_eq!(
crate::runtime::pane_fork_snapshot(Some(&forked))
.forked_from_pane_id
.as_deref(),
Some("w1:p1")
);
// A delegated child has a parent too, and is not a fork of it.
let delegated = listed("claude", Some("s-3"), Some("w1:p1"), false);
assert_eq!(
crate::runtime::pane_fork_snapshot(Some(&delegated)).forked_from_pane_id,
None
);
// The mark counts only while the pane still declares its parent.
let orphan = listed("claude", Some("s-4"), None, true);
assert_eq!(
crate::runtime::pane_fork_snapshot(Some(&orphan)).forked_from_pane_id,
None
);
}

fn request(agent: ForkableAgent) -> ForkRequest {
ForkRequest {
source_reference: None,
Expand Down
10 changes: 10 additions & 0 deletions herdr-core/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,11 @@ pub struct SidebarAgentSnapshot {
/// cannot stand in for this.
#[serde(skip_serializing_if = "Option::is_none")]
pub herdr_name: Option<String>,
/// Whether this agent is the pane Hide's Fork made from its declared
/// parent (`wire::FORK_TOKEN`). Any child has a parent; only a fork is a
/// fork of it, and a name cannot tell them apart once the agent is woken.
#[serde(skip_serializing)]
pub started_as_fork: bool,
pub pane_id: String,
pub workspace_label: String,
/// The checkout the agent's pane is in, once the navigator has placed it.
Expand Down Expand Up @@ -2089,9 +2094,14 @@ pub struct ServerEndpointSnapshot {
/// Both facts come from Herdr: whether the pane runs an agent whose own fork
/// command can take its recorded session, and whether this pane is itself the
/// result of such a fork.
///
/// `reason` is set only on a pane whose agent can be forked in principle but
/// not yet, so the menu item that is drawn disabled can say why; an agent that
/// cannot be forked at all, and a pane with no agent, carry neither.
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize)]
pub struct PaneForkSnapshot {
pub available: bool,
pub reason: Option<String>,
pub forked_from_pane_id: Option<String>,
}

Expand Down
1 change: 1 addition & 0 deletions herdr-core/src/pet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ mod tests {
descendant_line: None,
id: pane_id.to_owned(),
herdr_name: None,
started_as_fork: false,
pane_id: pane_id.to_owned(),
workspace_label: "Fixture".to_owned(),
identity_label: "Fixture".to_owned(),
Expand Down
12 changes: 10 additions & 2 deletions herdr-core/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2571,9 +2571,17 @@ pub fn pane_fork_snapshot(agent: Option<&SidebarAgentSnapshot>) -> PaneForkSnaps
let Some(agent) = agent else {
return PaneForkSnapshot::default();
};
let available = is_forkable(Some(agent.agent_kind.as_str()), agent.session_id.as_deref());
PaneForkSnapshot {
available: is_forkable(Some(agent.agent_kind.as_str()), agent.session_id.as_deref()),
forked_from_pane_id: agent.spawned_from_pane_id.clone(),
available,
reason: (!available && ForkableAgent::parse(&agent.agent_kind).is_some())
.then(|| "This agent has not reported its conversation yet".to_owned()),
// Any child a parent declared has a `spawned_from_pane_id`; only one
// that was started as a fork is a fork of it.
forked_from_pane_id: agent
.started_as_fork
.then(|| agent.spawned_from_pane_id.clone())
.flatten(),
}
}

Expand Down
2 changes: 2 additions & 0 deletions herdr-core/src/runtime/delivery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1836,6 +1836,7 @@ pub(crate) mod tests {
project: None,
actor,
ended: false,
forked: false,
});
guard.delivery_ledger = Ok(Arc::new(ledger));
}
Expand Down Expand Up @@ -2317,6 +2318,7 @@ pub(crate) mod tests {
project: None,
actor: runtime.delivery_observations[pane].actor.clone(),
ended: false,
forked: false,
});
}
ledger.next_id = 3;
Expand Down
1 change: 1 addition & 0 deletions herdr-core/src/runtime/factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,7 @@ mod tests {
},
},
ended: false,
forked: false,
}
}

Expand Down
1 change: 1 addition & 0 deletions herdr-core/src/runtime/tests/agent_sleep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1440,6 +1440,7 @@ impl SleepingChild {
project: None,
actor: runtime.delivery_observations[pane].actor.clone(),
ended: false,
forked: false,
});
}
ledger.next_id = 3;
Expand Down
Loading
Loading