Skip to content
Closed
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 docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ A fork's pane is drawn at the fork worker's answer through the same two records:
A pane Hide made is in its checkout and tab from that answer (`Runtime::created_pane_place`: a created tab's own, a drawn split's target's), so a focus that reaches it before the catalog does brings that checkout forward and is the tab move the engine answers, instead of leaving the keyboard in a pane of a checkout not in front: there the projection waited on `pane.projection_unavailable` until another focus arrived, or read the front checkout's own pane as a focus the engine moved and followed it (the agent journey's Grok fork on macOS and Windows, 2026-10-18, when Herdr ran the panes); and with the checkout forward but no tab move recorded, Herdr's step through the source's tab on its way to the fork's took the keyboard to the source for one frame.
Geometry is laid out with the same split arithmetic the core's own engine applies (`engine/own/layout.rs`, used by `pane_prediction.rs`), so the confirmed layout replaces the drawn one without a jump when they agree; when they do not, the engine's wins and `pane.prediction_mismatch` records both shapes.
The core's own engine holds a split or a new tab in its layout before it answers, so the first publish after the answer both draws and confirms it, with nothing for a prediction to draw ahead of (a split's answer reached the screen in a median 13.9 ms on it against 10.3 ms for Herdr's drawn prediction, the same one full session update, and the own engine answers about 3 ms sooner); `pane.prediction_mismatch` therefore compares the confirmed layout with the prediction folded over the layout last drawn, which already carries it when a publish drew it, never with the screen from before the operation.
A created tab's session can therefore reach the core before its answer, and then no later session is left to project the visible tab: the answer that moves the keyboard to the new pane projects it in the same step (`settle_selection_projection`), as every other writer of the visible tab does, because a navigator that still names the old tab leaves the selected pane outside the visible tab and a split sent from it finds no focused pane there (with-hide/hide-private#476).
A close is drawn on the canvas only: the closing pane keeps its sidebar row, session and read state until the engine confirms the close.
Whether a close waits in its tab's line is the engine's layout's answer, not the drawing's: once a close draws its sibling gone, a ⌘W on the pane left drawn alone still closes one of two panes in the engine's tab, so it waits behind the close ahead instead of meeting it in progress, stays drawn until it runs, and leaves with its tab.
A waiting close starts only after a settling close ahead has left the tab's records (one that failed or whose result is unknown stays for the operator, so the waiting close starts and meets its refusal, which drops the line) and after the session update in progress has been applied, because it reads the tab's panes from the navigator, which shows the previous session until then; a close started from it would see its tab change before its effect and cancel itself.
Expand Down
12 changes: 12 additions & 0 deletions hide-core/src/runtime/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5548,6 +5548,18 @@ impl Runtime {
.insert(checkout_id.clone(), tab_id.clone());
self.send_created_tab(checkout_id, tab_id.clone());
}
// The core's own engine lists the new tab before it
// answers, so the session that shows it can reach the
// core first. Then nothing is left to republish
// (`draw_created_tab` has no layout to draw), the
// navigator still names the old tab as the visible one,
// and the selected pane above lies outside it until some
// later session: a split sent then finds no focused pane
// in the visible tab (with-hide/hide-private#476). Every
// other writer of the visible tab projects it as it sets
// it; with the tab not listed yet, the session that lists
// it does.
self.settle_selection_projection();
self.yield_surface_to_terminal();
self.persist_current_ui_state();
}
Expand Down
80 changes: 80 additions & 0 deletions hide-core/src/runtime/tests/agent_areas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2358,3 +2358,83 @@ fn checkouts_not_yet_opened_keep_their_tabs_when_saved_workspaces_are_at_the_cap
assert!(views.get(crate::node::TEST_NODE, "/gone-1").is_none());
assert!(views.get(crate::node::TEST_NODE, "/gone-2").is_some());
}

/// The core's own engine lists a new tab before it answers the creation, so
/// the session that shows it can reach the core before the answer. The answer
/// moves the keyboard to the new pane; the visible tab moves with it in the
/// same step, since no session is left to carry it, and a split sent from
/// that pane then finds it in the visible tab (`herdr-coexistence.spec.ts`
/// "Opening a new terminal and splitting it", with-hide/hide-private#476).
#[test]
fn a_created_tab_the_session_listed_before_its_answer_is_the_visible_tab_at_the_answer() {
for session_first in [false, true] {
let (runtime, checkout) = live_tab_order_runtime("/agent-groups");
let mut runtime = with_new_views(runtime, "agent-groups-created-first");
let mut engine = EngineMoves::new();
let first = ["w-order:t1"];
runtime.ingest_session(Ok(engine.after(
&[],
tab_order_payload("/agent-groups", &first, &first, "w-order:t1"),
)));
runtime.sync_workspace_view();
// The engine created the tab with focus, as a session reports it.
let both = ["w-order:t1", "w-order:t2"];
let mut listed = tab_order_payload("/agent-groups", &both, &both, "w-order:t2");
listed.tab_focus = Some(crate::sidebar::SessionTabFocus {
generation: 1,
workspace_id: "w-order".into(),
tab_id: "w-order:t2".into(),
revision: 1,
creation: true,
});
let session = engine.after(&["w-order:t2"], listed);
let answer = |runtime: &mut Runtime| {
runtime.ingest_local_control_result(
RemoteControlAction::CreateTab {
workspace_id: "w-order".into(),
cwd: "/agent-groups".into(),
label: "Tab".into(),
area_id: Some("a1".into()),
group_id: None,
admission_id: None,
},
Ok(RemoteControlOutcome::Acknowledged {
created_tab_id: Some("w-order:t2".into()),
created_pane_id: Some("w-order:t2:p".into()),
}),
1,
);
};
if session_first {
runtime.ingest_session(Ok(session.clone()));
answer(&mut runtime);
} else {
answer(&mut runtime);
runtime.ingest_session(Ok(session.clone()));
}
let which = format!("session_first={session_first}");
assert_eq!(
checkout_active_tab_id(&runtime, &checkout).as_deref(),
Some("w-order:t2"),
"the checkout shows the created tab ({which})"
);
assert_eq!(
runtime.snapshot().tab.id.as_deref(),
Some("w-order:t2"),
"the shown tab is the created one ({which})"
);
assert_eq!(
runtime.snapshot().terminal.pane_id.as_deref(),
Some("w-order:t2:p"),
"the keyboard is in the created pane ({which})"
);
// The session read that follows changes nothing the answer did not.
runtime.ingest_session(Ok(engine.after(&[], session.clone())));
assert_eq!(
checkout_active_tab_id(&runtime, &checkout).as_deref(),
Some("w-order:t2"),
"the next session keeps the created tab ({which})"
);
assert_eq!(layout(&runtime).active(), Some("w-order:t2"), "{which}");
}
}
9 changes: 8 additions & 1 deletion web/e2e/agent-tab-groups.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { expect, test, type Locator, type Page } from "@playwright/test";
import { expect, test as base, type Locator, type Page } from "@playwright/test";
// Throwaway probe (with-hide/hide-private#476, #187, #140, #534, #518): this spec's flaky test only, registered 20 times.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const test = Object.assign((title: string, ...rest: any[]) => {
if (title !== "New tab and Reopen use the requested area and Rename works in either bar") return;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
for (let run = 1; run <= 20; run++) (base as any)(`${title} #${run}`, ...rest);
}, { describe: base.describe, use: base.use, step: base.step, setTimeout: base.setTimeout });
import fs from "node:fs";
import path from "node:path";
import { printLinesCommand } from "./pane-fixture";
Expand Down
7 changes: 4 additions & 3 deletions web/e2e/daemon-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,10 @@ type TaskOperation = { kind: string; phase: string; pane_id: string | null; agen
* the agent has started: the core holds one task slot and refuses another
* start, as `task_operation.busy`, while this one's agent is still starting,
* and the agent's row is published before that.
* A refused or failed start throws with the core's answer.
* A refused or failed start throws with the core's answer; `waitMs` bounds the
* wait for it, for a spec whose own timeout is shorter than the default.
*/
export async function startAgentInCheckout(control: HidedControl, folder: string, fields: Record<string, unknown>, what: string): Promise<string> {
export async function startAgentInCheckout(control: HidedControl, folder: string, fields: Record<string, unknown>, what: string, waitMs = 30_000): Promise<string> {
const requestId = `e2e-${crypto.randomUUID()}`;
control.send("agent_start_in_checkout", { checkout_path: folder, provider: "claude", request_id: requestId, ...fields });
const answer = await control.until((rest) => {
Expand All @@ -201,7 +202,7 @@ export async function startAgentInCheckout(control: HidedControl, folder: string
const operation = rest.task_operation as TaskOperation | null | undefined;
if (operation?.request_id !== requestId || operation.kind !== "agent_start") return undefined;
return operation.phase === "working" || operation.agent_phase === "starting" ? undefined : { operation };
}, `the core's answer to the start of ${what}`, 30_000);
}, `the core's answer to the start of ${what}`, waitMs);
const operation = "operation" in answer ? answer.operation : undefined;
if (operation?.phase !== "ready" || operation.agent_phase !== "started" || !operation.pane_id) throw new Error(`the core did not start ${what}: ${JSON.stringify(answer)}`);
return operation.pane_id;
Expand Down
9 changes: 8 additions & 1 deletion web/e2e/herdr-coexistence.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
// B1-B7/B14: real cold restoration and one Hide-triggered terminal split.
import { expect, test, type Page } from "@playwright/test";
import { expect, test as base, type Page } from "@playwright/test";
// Throwaway probe (with-hide/hide-private#476, #187, #140, #534, #518): this spec's flaky test only, registered 20 times.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const test = Object.assign((title: string, ...rest: any[]) => {
if (title !== "Opening a new terminal and splitting it keeps one tab and both terminal identities") return;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
for (let run = 1; run <= 20; run++) (base as any)(`${title} #${run}`, ...rest);
}, { describe: base.describe, use: base.use, step: base.step, setTimeout: base.setTimeout });
import path from "node:path";
import { paneCommandLine } from "./pane-fixture";
import { waitForTerminal } from "./group-start-helper";
Expand Down
19 changes: 16 additions & 3 deletions web/e2e/named-tab-stays.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
// A tab the operator named through Rename outlives its agents
// (docs/UI_BEHAVIOR.md, Agent areas): closing its last agent pane leaves a
// shell in the tab, and closing that shell closes the tab.
import { expect, test, type Page } from "@playwright/test";
import { expect, test as base, type Page } from "@playwright/test";
// Throwaway probe (with-hide/hide-private#476, #187, #140, #534, #518): this spec's flaky test only, registered 20 times.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const test = Object.assign((title: string, ...rest: any[]) => {
if (title !== "reopening an unnamed tab leaves it unnamed") return;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
for (let run = 1; run <= 20; run++) (base as any)(`${title} #${run}`, ...rest);
}, { describe: base.describe, use: base.use, step: base.step, setTimeout: base.setTimeout });
import path from "node:path";
import { startFixture } from "./engine-fixture";
import { newTab, tabPanes, tabsOf } from "./daemon-actions";
Expand Down Expand Up @@ -111,6 +118,9 @@ test("reopening an unnamed tab leaves it unnamed", async ({ page }) => {
await page.goto(`${daemon.origin}/#token=${daemon.token}`);
await enterWorkspace(page, "fixture");

// The number its sidebar line gives it now, which a reopen has to give back.
const number = /Tab (\d+)/.exec((await page.locator(`[data-sidebar-tab-line="${fixture.tab}"]`).textContent()) ?? "")?.[1];
expect(number, "the unnamed tab's sidebar line says its number").toBeDefined();
const closing = page.locator(`[data-agent-tab-bar] [data-tab="${fixture.tab}"]`);
await closing.hover();
await closing.getByRole("button", { name: /^Close tab/ }).click();
Expand All @@ -125,8 +135,11 @@ test("reopening an unnamed tab leaves it unnamed", async ({ page }) => {
expect(reopened.sidebar?.manual_name).toBeNull();

// The sidebar names it as any unnamed tab, so its last agent's close
// takes it (closing restored agents waits on a status check here).
await expect(page.locator(`[data-sidebar-tab-line="${reopenedId}"]`)).toContainText(`Tab ${reopened.sidebar!.number}`);
// takes it (closing restored agents waits on a status check here). A
// reopen makes the tab after the others and then moves it back to its old
// place, so the first snapshot that shows it carries a number it is about
// to leave; the number it settles on is the one it had when it closed.
await expect(page.locator(`[data-sidebar-tab-line="${reopenedId}"]`)).toContainText(`Tab ${number}`);
} finally {
control?.close();
daemon?.stop();
Expand Down
12 changes: 10 additions & 2 deletions web/e2e/pane-move.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
// Pane-header move B1-B10/B18/B21: production UI and real isolated PTYs.
import { expect, test } from "@playwright/test";
import { expect, test as base } from "@playwright/test";
// Throwaway probe (with-hide/hide-private#476, #187, #140, #534, #518): this spec's flaky test only, registered 20 times.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const test = Object.assign((title: string, ...rest: any[]) => {
if (title !== "a tab drop and the keyboard move menu keep the same terminal in a new tab") return;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
for (let run = 1; run <= 20; run++) (base as any)(`${title} #${run}`, ...rest);
}, { describe: base.describe, use: base.use, step: base.step, setTimeout: base.setTimeout });
import { beginDrag, expectDirection, paneView, selectMarker, startMove, tabNow, tabTitle } from "./pane-move-fixture";
import { sessionIn } from "./fixture-agents";
import { screenshot } from "./wire";
Expand Down Expand Up @@ -72,7 +79,8 @@ test("a tab drop and the keyboard move menu keep the same terminal in a new tab"
await page.locator('[data-menu-item="pane_move_area:a1"]').focus(); await page.keyboard.press("ArrowRight");
const choice = page.getByRole("menuitem", { name: "Move to new tab", exact: true }); await choice.focus(); await page.keyboard.press("Enter"); await flow.completed(2);
await expect.poll(async () => { const tab = await tabNow(flow, source); return tab !== undefined && tab !== flow.target.tab; }).toBe(true);
expect(await page.evaluate(id => window.__hideProbe!.paneText(id), source)).toContain("MOVE_KEPT");
// The pane's view in the new tab is a new one: it takes the screen back from its terminal when it attaches, after the move completes.
await expect.poll(() => page.evaluate(id => window.__hideProbe!.paneText(id), source)).toContain("MOVE_KEPT");
expect(await sessionIn(flow.daemon, source)).toBe(session);
expect(flow.sent.get("pane_move")).toBe(2);
await screenshot(page, "pane-move-menu-new-tab");
Expand Down
23 changes: 21 additions & 2 deletions web/e2e/sidebar-tab-groups.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import { test, expect, type Page } from "@playwright/test";
import { test as base, expect, type Page } from "@playwright/test";
// Throwaway probe (with-hide/hide-private#476, #187, #140, #534, #518): this spec's flaky test only, registered 20 times.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const test = Object.assign((title: string, ...rest: any[]) => {
if (title !== "2-1-2 tab segments align every tab's guide and line, and an unnamed single agent's tab keeps its guide alone") return;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
for (let run = 1; run <= 20; run++) (base as any)(`${title} #${run}`, ...rest);
}, { describe: base.describe, use: base.use, step: base.step, setTimeout: base.setTimeout });
import fs from "node:fs";
import path from "node:path";
import { toPage } from "../../desktop/src/main/wirePath";
import { agentIn, areaShowing, closePane, startAgentInCheckout, tabOfPane, withControl } from "./daemon-actions";
import { startFixture, type AgentFixture } from "./engine-fixture";
import { dumpOnFailure } from "./failure-dump";
import { setAgentSession } from "./fixture-agents";
import type { HidedControl } from "./hided-control.mjs";
import { startHided } from "./hided-fixture";
import { chooseTheme, countSent, enterWorkspace, rest, screenshot, sendEvent } from "./wire";

Expand All @@ -24,6 +33,14 @@ async function renameTab(page: Page, tab: string, name: string) {
/** The checkout's folder, in the spelling the core gives its panes. */
const folderOf = (engine: AgentFixture) => toPage(fs.realpathSync(path.join(engine.root, "fixture")));

/** The core's task slot, its last refusal and its newest diagnostics, as a start leaves them. */
function coreStart(control: HidedControl) {
return control.until((snapshot) => {
const status = snapshot.status as { last_error?: unknown; diagnostics?: { kind: string; message: string }[] } | undefined;
return { task: snapshot.task_operation ?? null, refused: status?.last_error ?? null, diagnostics: (status?.diagnostics ?? []).slice(-12).map((entry) => `${entry.kind}: ${entry.message}`) };
}, "the core's start state", 3_000);
}

/**
* Starts a Claude agent as the start panel does: in a tab of its own, or,
* given `beside`, in a new pane beside the agents of that tab. Returns where
Expand All @@ -34,7 +51,9 @@ async function startAgent(engine: AgentFixture, daemon: Awaited<ReturnType<typeo
const started = await withControl(daemon, async (control) => {
const area = beside ? await control.until((rest) => areaShowing(rest, beside), `the area showing ${beside}`) : undefined;
const what = beside ? `a new agent beside ${beside}` : "a new agent in a tab of its own";
const pane = await startAgentInCheckout(control, folder, beside ? { target: { ...area, tab_id: beside, add_pane: true } } : {}, what);
// The test's own timeout is 30 s, so the start gives up before it and a
// failed one says what the core held (with-hide/hide-private#518).
const pane = await dumpOnFailure(`start of ${what}`, () => coreStart(control), () => startAgentInCheckout(control, folder, beside ? { target: { ...area, tab_id: beside, add_pane: true } } : {}, what, 15_000));
return control.until((rest) => {
const tab = tabOfPane(rest, pane);
return tab && agentIn(rest, pane) ? { tab, pane } : undefined;
Expand Down
Loading
Loading