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
1 change: 1 addition & 0 deletions contracts/snapshot-wire-enums.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"checkout_purpose_origin": ["token", "branch_description", "agent_title", "pull_request_title"],
"document_kind": ["text", "markdown", "image", "pdf", "binary"],
"editor_tab_kind": ["file", "diff", "session", "memory"],
"pane_find_route": ["agent", "bar"],
"pull_request_badge": ["merged", "closed", "review", "open"],
"pull_request_checks": ["unknown", "none", "pending", "failed", "passing"],
"review_decision": ["review_required", "changes_requested", "approved"],
Expand Down
5 changes: 5 additions & 0 deletions docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,11 @@ The recorder ignores the focus the shell's last element regains when the host ha
It never closes a whole tab; tab controls and their menus name that intent explicitly.
The explicit Close pane command still closes the core's focused pane through the same confirmation path.
⌘F follows where the operator works: inside a View area it opens the document's find, anywhere else the focused terminal pane's find bar, even with an editor open beside it; Escape and × end the pane search and give the keyboard back to that pane.
A pane whose agent searches its own conversation (`own_find` on its row, from the one table in `herdr-core/src/agent_find.rs`: Claude Code's transcript search and Codex's full-transcript find) sends `pane_find_open` instead, because a full-screen agent keeps its conversation inside itself and Herdr holds none of it, so the find bar would search only the rows on screen.
The core asks Herdr off the lock whether it holds the pane's history: with none it sends the agent's own keys with `pane.send_keys` and the agent's prompt, steps and count take over, and with some (an agent drawing inline, such as Claude Code's default renderer, which has no search of its own) it answers that the find bar opens; a failure opens the bar with the reason.
Herdr's history is the only witness, because the pinned API does not say whether a pane is on the alternate screen: an inline agent whose output has not yet passed one screen has no history either and gets its own keys, which for Claude Code's default renderer opens its transcript without a search while the whole conversation is still on screen.
Claude Code's transcript toggles on the key that opens it, so a screen that already shows its transcript footer gets only the search key; the footer is the one witness the agent offers, and a footer that changed sends the full keys as before.
The answer names the request that asked (`find.opened`), so the shell acts on it once.
Settings > Shortcuts rebinds the seven pane commands (split right and down, zoom, close pane, larger, smaller and reset text) in the running host's own set.
Each host keeps its set in the core apart from the other's, because the hosts reserve different keys: a browser's in `ui_state.browser_shortcut_bindings`, and the desktop app's in `ui_state.shortcut_bindings`, the macOS chord set, in the removed native app's text form (`command+shift+return`) and command names (`increase_text_size`), with `toggle_conversation` kept but never run here; a save that omits `browser_shortcut_bindings` keeps it.
The desktop app honours the operator's existing macOS chord set (user decision 2026-09-26): hided passes the state file the removed native app wrote (`~/Library/Application Support/hide/state.json`) as `shortcut_import_path`, and the core reads only its `shortcut_bindings` field, once, while its own set is empty, then records `shortcut_bindings_imported` so a later reset to defaults stays a reset; a missing file imports nothing and a later launch may still import, and an unreadable one is a diagnostic.
Expand Down
1 change: 1 addition & 0 deletions docs/UI_BEHAVIOR.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ Each area has a tab bar, a New tab button and the active tab's live pane canvas;
Only the active area's selected tab carries the accent; clicking a tab or pane activates its area and sends the keyboard to that pane.
All shown tabs stay attached and awake, while only the active area's tab receives read and sleep-visit updates.
Pane headers, child chips, relationship controls and pane splits remain inside each canvas; find belongs to the focused pane.
⌘F on a full-screen Claude Code or Codex pane opens that agent's own search over its whole conversation in the pane, with the agent's own keys and count (Claude Code: type, Enter, `n`/`N`; Codex: type, Enter, Ctrl+P), and no find bar appears; any other pane, and an agent drawing inline, gets the find bar.

Agent and View areas share the drag, divider and narrow-window controls described below.
A drag keeps its original tab in place and changes no terminal size until a valid drop.
Expand Down
71 changes: 71 additions & 0 deletions herdr-core/src/agent_find.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
//! The agents that search their own conversation, and the keys that open it.
//!
//! A full-screen agent (Claude Code with `tui: fullscreen`, Codex on its
//! default alternate screen) keeps its conversation inside itself: Herdr holds
//! no history for the pane, so a search of what Herdr holds finds only the
//! rows on screen. The agent's own find covers the whole conversation and
//! scrolls to each match, so ⌘F hands such a pane to it and the agent's own
//! prompt, keys and count take over. An agent that draws inline leaves its
//! conversation in Herdr's history, and Hide's find bar searches that, so the
//! decision also asks Herdr whether it holds any (`live::spawn_agent_find`).
//!
//! Adding an agent is one row in [`agent_find`]; an agent without one keeps
//! Hide's find bar.

/// How one agent's own search is opened, in Herdr's key names for
/// `pane.send_keys`. Every key is a mode switch in the agent: none of them
/// submits, interrupts or edits what the operator typed.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub(crate) struct AgentFind {
/// The keys that open the search from the agent's prompt.
pub(crate) open: &'static [&'static str],
/// Set when the opening keys toggle a view the operator may still be in,
/// so a second ⌘F would close it again.
pub(crate) already_open: Option<AlreadyOpen>,
}

/// The agent's search view as its screen shows it. The agent reports its mode
/// nowhere else, so its own footer is the only witness; a footer that changed
/// in a later version sends the opening keys again, which is what a second ⌘F
/// did before this check existed.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub(crate) struct AlreadyOpen {
/// Text only that view draws on screen.
pub(crate) footer: &'static str,
/// The keys that start a new search from inside that view.
pub(crate) keys: &'static [&'static str],
}

/// `agent_kind`'s own search over its conversation, or `None` for an agent
/// Hide knows no such search for.
pub(crate) fn agent_find(agent_kind: &str) -> Option<AgentFind> {
match agent_kind {
// Ctrl+O toggles the transcript, where `/` searches, `n` and `N` step
// and the footer counts (Claude Code 2.1, fullscreen renderer).
"claude" => Some(AgentFind {
open: &["ctrl+o", "/"],
already_open: Some(AlreadyOpen {
footer: "Showing detailed transcript",
keys: &["/"],
}),
}),
// F3 finds over the full transcript and stays open when pressed
// again; Enter steps and Ctrl+P goes back (Codex 0.157).
"codex" => Some(AgentFind {
open: &["f3"],
already_open: None,
}),
_ => None,
}
}

impl AgentFind {
/// The keys for a pane whose screen shows `visible`; `None` when the
/// screen was not read because nothing here depends on it.
pub(crate) fn keys(&self, visible: Option<&str>) -> &'static [&'static str] {
match (self.already_open, visible) {
(Some(view), Some(screen)) if screen.contains(view.footer) => view.keys,
_ => self.open,
}
}
}
1 change: 1 addition & 0 deletions herdr-core/src/agent_sleep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ mod tests {
last_activity: "1788871000000".to_owned(),
state_change_seq: Some(4),
session_id: Some("session-a".to_owned()),
own_find: true,
spawned_from_pane_id: None,
declared_parent_pane_id: None,
spawned_from_machine_id: None,
Expand Down
1 change: 1 addition & 0 deletions herdr-core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mod agent_find;
pub mod agent_hooks;
mod agent_sleep;
mod agent_sleep_herdr;
Expand Down
45 changes: 43 additions & 2 deletions herdr-core/src/live.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ use base64::engine::general_purpose::STANDARD as BASE64;
use serde::Deserialize;
use serde_json::{Value, json};

use crate::agent_find::AgentFind;
use crate::checkout_owner::OwnerOpen;
use crate::find::PaneFindOptions;
use crate::fork::ForkRequest;
use crate::handle::ChangeNotifier;
use crate::model::{
EditorDocumentSnapshot, PaneLayoutDirection, PaneLayoutNodeSnapshot, PaneLayoutSnapshot,
WorkspaceRegistration, WorkspaceSnapshot,
EditorDocumentSnapshot, PaneFindRoute, PaneLayoutDirection, PaneLayoutNodeSnapshot,
PaneLayoutSnapshot, WorkspaceRegistration, WorkspaceSnapshot,
};
use crate::recent_closed::{
ClosedAgent, ClosedContext, ClosedItem, ClosedLayoutBranch, ClosedLayoutNode, ClosedPane,
Expand Down Expand Up @@ -2231,6 +2232,46 @@ pub fn spawn_pane_find(route: PaneApiRoute, request: PaneFindRequest) -> Result<
)
}

/// Opens an agent's own search in its pane, unless Herdr holds the pane's
/// history, which Hide's find bar searches instead (`agent_find.rs`).
///
/// The requests run on this thread, never under the runtime mutex.
pub(crate) fn spawn_agent_find(
route: PaneApiRoute,
request_id: String,
find: AgentFind,
) -> Result<(), String> {
route.spawn(
"herdr-core-agent-find",
move |connector, herdr_pane_id| open_agent_find(connector, herdr_pane_id, find),
move |runtime, pane_id, result| runtime.ingest_agent_find(pane_id, request_id, result),
)
}

fn open_agent_find(
connector: &dyn ApiConnector,
pane_id: &str,
find: AgentFind,
) -> Result<PaneFindRoute, String> {
// An agent that draws inline leaves its conversation in Herdr's history,
// where the find bar reaches all of it; its own search may not exist in
// that mode (Claude Code's default renderer has none).
let pane = control_request(connector, "pane.get", wire::pane_target_params(pane_id)?)?;
if wire::pane_scroll(pane)?.is_some_and(|scroll| scroll.max_offset_from_bottom > 0) {
return Ok(PaneFindRoute::Bar);
}
let visible = match find.already_open {
Some(_) => Some(read_pane_text(connector, pane_id, "visible")?.text),
None => None,
};
control_request(
connector,
"pane.send_keys",
wire::pane_send_keys_params(pane_id, find.keys(visible.as_deref()))?,
)?;
Ok(PaneFindRoute::Agent)
}

/// Herdr's scroll position for one pane, in lines above the bottom.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct PaneScroll {
Expand Down
36 changes: 36 additions & 0 deletions herdr-core/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,29 @@ pub struct PaneFindSnapshot {
/// searched rather than everything the pane has ever printed.
pub truncated: bool,
pub unavailable_reason: Option<String>,
/// Where the last `pane_find_open` sent the search, named by the request
/// that asked, so the shell acts on its own answer once and never on a
/// late one.
#[serde(skip_serializing_if = "Option::is_none")]
pub opened: Option<PaneFindOpened>,
}

/// The answer to one `pane_find_open`.
#[derive(Clone, Debug, PartialEq, Serialize)]
pub struct PaneFindOpened {
pub request_id: String,
pub route: PaneFindRoute,
}

/// Where ⌘F's search went for an agent with its own find.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum PaneFindRoute {
/// The agent's own search is open in the pane and takes the typing.
Agent,
/// Herdr holds the pane's history, or the agent's search could not be
/// opened (`unavailable_reason` says why), so Hide's find bar opens.
Bar,
}

#[derive(Clone, Debug, PartialEq, Serialize)]
Expand Down Expand Up @@ -686,6 +709,10 @@ pub struct SidebarAgentSnapshot {
/// wire when Herdr recorded none.
#[serde(skip_serializing_if = "Option::is_none")]
pub session_id: Option<String>,
/// The agent has its own search over its whole conversation, so ⌘F on its
/// pane asks the core where the search goes (`pane_find_open`) rather
/// than opening Hide's find bar (`agent_find.rs`).
pub own_find: bool,
/// The pane this agent was spawned from: Herdr's own lineage record, or
/// the `parent_pane` token its spawner declared when Herdr recorded none.
/// `wire.rs::lineage_parent` is the one place that resolves the two.
Expand Down Expand Up @@ -4041,6 +4068,15 @@ mod wire_enum_tests {
assert_wire(&contract, "strip_tab_kind", &strip_kinds);
checked.insert("strip_tab_kind");

let find_routes = [PaneFindRoute::Agent, PaneFindRoute::Bar];
for variant in find_routes {
match variant {
PaneFindRoute::Agent | PaneFindRoute::Bar => {}
}
}
assert_wire(&contract, "pane_find_route", &find_routes);
checked.insert("pane_find_route");

let unchecked = contract
.keys()
.filter(|key| !checked.contains(key.as_str()))
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 @@ -284,6 +284,7 @@ mod tests {
last_activity: "0000000000001".to_owned(),
state_change_seq: None,
session_id: None,
own_find: false,
spawned_from_pane_id: None,
declared_parent_pane_id: None,
spawned_from_machine_id: None,
Expand Down
14 changes: 7 additions & 7 deletions herdr-core/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ use crate::live::{
use crate::model::{
ArchiveDetailSnapshot, CheckoutSnapshot, CoreOptions, DEFAULT_PANE_TEXT_SCALE,
DiagnosticSnapshot, Edited, EditorDocumentSnapshot, EditorTabKind, EditorTabSnapshot,
ExplorerOperationSnapshot, LastErrorSnapshot, PANE_TEXT_SCALE_STEP, PaneFindSnapshot,
PaneFocusRequestSnapshot, PaneForkSnapshot, PaneLayoutNodeSnapshot, PaneLayoutSnapshot,
PaneSnapshot, PetBadgesSnapshot, PetOriginSnapshot, PetSnapshot, RemoteFileEntrySnapshot,
RemoteFileListSnapshot, RemoteSessionSnapshot, RightPanelSection, SCHEMA_VERSION,
SessionRowSnapshot, SidebarAgentSnapshot, Snapshot, StripTabKind, StripTabSnapshot, Surface,
TabSnapshot, TerminalChunk, TerminalPaneSnapshot, UiStateSnapshot, WorkspaceSnapshot,
clamp_pane_text_scale,
ExplorerOperationSnapshot, LastErrorSnapshot, PANE_TEXT_SCALE_STEP, PaneFindOpened,
PaneFindRoute, PaneFindSnapshot, PaneFocusRequestSnapshot, PaneForkSnapshot,
PaneLayoutNodeSnapshot, PaneLayoutSnapshot, PaneSnapshot, PetBadgesSnapshot, PetOriginSnapshot,
PetSnapshot, RemoteFileEntrySnapshot, RemoteFileListSnapshot, RemoteSessionSnapshot,
RightPanelSection, SCHEMA_VERSION, SessionRowSnapshot, SidebarAgentSnapshot, Snapshot,
StripTabKind, StripTabSnapshot, Surface, TabSnapshot, TerminalChunk, TerminalPaneSnapshot,
UiStateSnapshot, WorkspaceSnapshot, clamp_pane_text_scale,
};
use crate::recent_closed::{ClosedAgent, ClosedContext, ClosedItem, ClosedPane, push_bounded};
use crate::remote::{RemoteReadCommand, RusshSftpTransport, parse_machine_identity};
Expand Down
12 changes: 12 additions & 0 deletions herdr-core/src/runtime/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,13 @@ pub(super) struct PaneFindPayload {
pub(super) step: i64,
}

/// ⌘F on a pane whose agent has its own find (`own_find` on its row).
#[derive(Debug, Deserialize)]
pub(super) struct PaneFindOpenPayload {
pub(super) pane_id: String,
pub(super) request_id: String,
}

#[derive(Debug, Deserialize)]
pub(super) struct PaneTextScalePayload {
pub(super) pane_id: String,
Expand Down Expand Up @@ -1127,6 +1134,7 @@ pub(super) enum Event {
TerminalScroll(TerminalScrollPayload),
TerminalClick(TerminalClickPayload),
PaneFind(PaneFindPayload),
PaneFindOpen(PaneFindOpenPayload),
PaneTextScale(PaneTextScalePayload),
EditorTextScale(EditorTextScalePayload),
ThemeSet(ThemeSetPayload),
Expand Down Expand Up @@ -1312,6 +1320,7 @@ pub(super) fn validate_event(event: EventEnvelope) -> Result<Event, EventValidat
"terminal_scroll" => decode!(TerminalScrollPayload, TerminalScroll),
"terminal_click" => decode!(TerminalClickPayload, TerminalClick),
"pane_find" => decode!(PaneFindPayload, PaneFind),
"pane_find_open" => decode!(PaneFindOpenPayload, PaneFindOpen),
"pane_text_scale" => decode!(PaneTextScalePayload, PaneTextScale),
"editor_text_scale" => decode!(EditorTextScalePayload, EditorTextScale),
"theme_set" => decode!(ThemeSetPayload, ThemeSet),
Expand Down Expand Up @@ -2971,6 +2980,9 @@ impl Runtime {
}
false
}
Event::PaneFindOpen(payload) => {
self.open_pane_find(payload.pane_id, payload.request_id)
}
Event::PaneTextScale(payload) => {
let current = self
.snapshot
Expand Down
61 changes: 61 additions & 0 deletions herdr-core/src/runtime/terminal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ impl Runtime {
total: outcome.total,
truncated: outcome.truncated,
unavailable_reason: None,
opened: None,
};
let changed = self.snapshot.find != next;
self.snapshot.find = next;
Expand All @@ -315,6 +316,66 @@ impl Runtime {
}
changed
}
/// ⌘F on a pane whose agent has its own find: a worker opens the
/// agent's search, or answers that Hide's find bar should open because
/// Herdr holds the pane's history (`live::spawn_agent_find`).
pub(super) fn open_pane_find(&mut self, pane_id: String, request_id: String) -> bool {
let find = self
.agent_row(&pane_id)
.and_then(|agent| crate::agent_find::agent_find(&agent.agent_kind));
// The agent left between the frame the shell acted on and this event:
// the pane is a plain terminal again, which the bar searches.
let Some(find) = find else {
return self.ingest_agent_find(&pane_id, request_id, Ok(PaneFindRoute::Bar));
};
// A device's pane opens through that device's Herdr; one that cannot
// be reached says why in the bar.
let route = match self.pane_api_route(&pane_id) {
Ok(route) => route,
Err(reason) => return self.ingest_agent_find(&pane_id, request_id, Err(reason)),
};
if let Err(message) = live::spawn_agent_find(route, request_id.clone(), find) {
return self.ingest_agent_find(&pane_id, request_id, Err(message));
}
false
}
/// Records where a `pane_find_open` sent the search. A failure opens the
/// bar with the reason, where the operator can search what Herdr holds.
pub fn ingest_agent_find(
&mut self,
pane_id: &str,
request_id: String,
result: Result<PaneFindRoute, String>,
) -> bool {
let (route, unavailable_reason) = match result {
Ok(route) => (route, None),
Err(message) => (PaneFindRoute::Bar, Some(message)),
};
crate::diagnostic!(serde_json::json!({
"component": "terminal", "kind": "pane.find_opened",
"pane_id": pane_id, "request_id": request_id, "route": route,
"reason": unavailable_reason,
}));
self.snapshot.find = PaneFindSnapshot {
pane_id: Some(pane_id.to_owned()),
unavailable_reason,
opened: Some(PaneFindOpened { request_id, route }),
..PaneFindSnapshot::default()
};
true
}
/// The agent row for a pane on this machine or on a device.
fn agent_row(&self, pane_id: &str) -> Option<&SidebarAgentSnapshot> {
let local = self.snapshot.navigator.agents.iter();
let devices = self
.snapshot
.status
.remote
.iter()
.filter_map(|remote| remote.session.as_ref())
.flat_map(|session| session.agents.iter());
local.chain(devices).find(|agent| agent.pane_id == pane_id)
}
/// Moves a pane's view by a wheel's signed lines (positive shows older
/// lines), and whether that changed the snapshot.
///
Expand Down
Loading
Loading