Skip to content

fix(drafts): keep a pane's drafts and lens to the herdr they were made under - #1997

Merged
devswha merged 10 commits into
mainfrom
fix/pane-state-herdr-lifetime
Oct 26, 2026
Merged

devswha merged 10 commits into
mainfrom
fix/pane-state-herdr-lifetime

Conversation

@devswha

@devswha devswha commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner

Fixes #1608

What it does for the user

herdr gives pane IDs out again once it is replaced. Until now, a pane opened after a herdr restart showed the unsent message, terminal line, held input, held chat messages and lens of the pane that had its ID before, so text written for one program could be sent to another.

Now:

  • After herdr is replaced, each pane opens with an empty message box, no held input or held chat messages from the earlier pane, and its default lens, in the same render as the new herdr's snapshot.
  • A restart of the web server alone (same herdr) keeps every draft and lens where it was.
  • The earlier text is not deleted and never sent. Recover unsent text in the pane's menu (shown only while there is some) lists each text with its PC, pane and kind. Put in message box adds it to that pane's box and shows the chat, Copy puts it on the clipboard, and Discard removes it.
  • Against a server that names no herdr (an older remote bridge), drafts live in the page: they survive reconnects but are never written to localStorage.

How

  • Server (server/finishes.ts, server/core/status.ts, shared/protocol.ts): snapshots carry an optional herdr_lifetime. It is a sha256 digest of the herdr identity finishes.ts already proves (the socket's dev:inode:birthtime, or the Windows pid:start marker). It is the same for every server reading one herdr, unlike finish_epoch, and it is left out when the identity cannot be read or changes during the read. It passes unchanged through GET /api/session, socket snapshots and the remote PC relay; status frames keep the snapshot's value. createServer gets a herdrIdentity option for tests.
  • Client (src/lib/paneLifetime.ts): pane-state keys keep their names. Each PC's stored state says which herdr it belongs to (ovis:pane-lifetime:<PC>). useMachineRoster calls observe on every roster, before it is drawn, and a PC's connection does on each snapshot before its panes hear of it (lib/machineSession.ts); a read naming a herdr the page already left is stale. When the snapshot names another herdr, the earlier text moves to ovis:unsent:<id> records, lens and sending-lease keys are removed, and the stores drop their in-memory copies. Every pane-state store reads and writes through one adapter, paneLifetimes.paneStorage: the composer draft and lease, the terminal line, held input (usePaneAttach, PaneTerminal, followFocus), held and unconfirmed chat messages (pendingMessages, the older messageQueue) and the lens. Rows a live connection proves stay until the bridge settles them. The adapter uses localStorage only while the page's herdr for that PC matches the record, and page memory otherwise.
  • Several tabs: each PC keeps a short list of the herdrs its stored state outlived (ovis:pane-lifetimes-retired:<PC>). A tab whose snapshot names one of them is behind: it leaves stored state alone and keeps its own typing in memory, which goes to recovery once it catches up. A snapshot naming any other herdr is a successor.
  • A pane moved to another workspace (lib/paneMove.ts, added on main meanwhile) carries its held input and lens through the same adapter, so a PC that names no herdr keeps them in the page there too.
  • A link's lens (the URL keeps the pane's lens, so a reload lands with it) ends once the selected PC's herdr is replaced: it named the pane of the herdr before.
  • No proof, no state: a snapshot without herdr_lifetime after one was proven (a read that could not prove its herdr) draws its panes with none of the stored state, which stays where it is. Text typed meanwhile is kept in the page and goes to recovery once a snapshot names a herdr again, even the same one: nothing proved whose panes it was typed in. The PC's connection applies its snapshots, named or not, before its panes hear of them.
  • Text from before this release (stored with no record, for a herdr nothing proves) goes to recovery on the first load, not to the panes. Lenses stay: a lens is no text.
  • A send begun for a pane of the herdr before settles nothing in the draft its pane ID holds now, and does not hold the new pane's box as sending.
  • Nothing is lost to a full storage: text whose recovery record storage refuses, or an edit storage refused, is kept for recovery in the open page.
  • The held input reset on a lifetime change runs in its own layout effect, so it adds no second attach (the herdr-restart regression expects exactly one).
  • Recovery dialog, components/UnsentText.tsx: modelled on Slack's Drafts list, where unsent text is kept apart and put back only by hand. See its DESIGN.md entry.
  • The demo names one fictional herdr per PC.

Rather than rekeying every pane-state key, this fences the existing keys. That kept the 41 browser scripts that seed ovis:view:<pane> untouched. The earlier attempt (74 files, local branch fix/pane-state-lifetime) changed them all.

Stored formats (docs/development.md, Stored-format changes)

  • New keys, each its own record: ovis:pane-lifetime:<PC> (a string), ovis:pane-lifetimes-retired:<PC> (a JSON list of at most 16 strings) and ovis:unsent:<uuid> (JSON {machine_id, pane_id, pane_title?, kind, text, at}), both written by src/lib/paneLifetime.ts. No existing record changes shape, and no older writer rewrites either key, so an old tab cannot erase them.
  • What changes in meaning: the bare pane-state keys now belong to the herdr named in the PC's record. With no record (the first load after this release), the stored text has no proven herdr: it moves to ovis:unsent: records, and lenses stay. Nothing is written back to the server.
  • Older code: a tab that is still open, or a rolled-back release, ignores both new keys. It reads and writes the bare keys as before, and archived text stays untouched in storage until a new release reads it again.
  • No HTTP or WebSocket contract carries these stores. The snapshot's herdr_lifetime is the only contract change.

A real review is needed

This changes the HTTP/WS contract (a new optional snapshot field read by the client), and it decides where queued unsent text goes after a disconnect. Please review it as a contract change rather than merging on checks alone.

Remote bridges only send herdr_lifetime once they run a bundle with this server change. server/ and shared/ changed, so the next release's guards will ask for REMOTE_BUNDLE_VERSION to be raised. Until remote PCs update, their drafts stay page-only, as the issue specifies for older bridges.

Not covered

  • A chat prompt read that started on the old herdr and answers after the replacement could still fill the composer once with that pane's restored text. The next read clears it, because an untouched fill is cleared. It is not stored or sent.
  • A tab still running an older release keeps writing the bare keys as before, so text typed there after a herdr replacement can reach the new pane in an updated tab. A reload ends it. Two updated tabs racing the record check and a draft write in the same instant are not fenced either (Codex review, MEDIUM).
  • Settings' forget-lens choices does not clear lenses kept in page memory for a PC without a lifetime (code review LOW).
  • Recovery records do not expire; they are removed by Put in message box or Discard.

Reviews

  • omo-native-code-reviewer, before the rebase: BLOCK on one HIGH (held and unconfirmed chat messages were not fenced), fixed. Of its 4 MEDIUM and 7 LOW, three of each were fixed; the others are under Not covered or were judged harmless (the digest is auth-gated; the lens can switch one commit before the roster does, and herdr-restart-regression still sees a single attach). On the rebased branch: APPROVE, no HIGH or MEDIUM, three LOW, all fixed: text a page kept while storage refused its record now goes to storage once storage takes it on the same herdr (it went to recovery while the pane still held it); a herdr replacement counts the PC's terminal lines as changed, so a paste still waiting on the clipboard is not put into the new pane's line; and DESIGN.md says why no coding-agent app is the model.
  • Codex gpt-6.1-sol, before the rebase: no HIGH, six MEDIUM; four fixed, a send in flight across the replacement fixed after the gate review, and an older release's open tab under Not covered. Codex Sol review did not run on the rebased branch (host stall); the merge pass reviews.
  • Codex gpt-6-astra (the contract, on the rebased branch): no HIGH, three MEDIUM. Fixed: a PC's connection now reports its snapshot's herdr to the fence before any pane hears of it, so a terminal that reconnects to a replaced herdr no longer shows the earlier pane's draft until the roster catches up (a read naming a herdr the page already left is stale); and Put in message box keeps the recovery record when the box of a PC with no proven herdr holds the text in the page alone. The third (a snapshot naming no herdr after one was proven) was declined at first, then fixed after the merge pass's gate review (below).
  • Merge pass gate (omo-native-gate-reviewer, gpt-6-astra) on 569dc79: three blockers, each fixed with a regression test that fails without it. Its re-review of e96f12a kept two open, both fixed with a test each: a socket snapshot naming no herdr now reaches the fence before any pane, and text typed while no herdr was proven goes to recovery even when the same herdr is named again. Its next re-review asked for that last case through the PC's connection too, now tested there. A snapshot naming no herdr after one was proven no longer keeps the earlier herdr's drafts on its panes; text stored before this release goes to recovery instead of to the current herdr's panes; and a late acknowledgement of a send begun under the earlier herdr no longer trims the new pane's draft.

Verification

On the branch rebased onto main 4d2e360.

  • Reproduced on main first (3597f45, the regression run against unchanged main): after a herdr restart the reused pane stays on the earlier pane's picked chat lens.
  • Server, curl -i on an isolated herdr (GET /api/session): 200 OK each time; herdr_lifetime is the same across a web server restart, a new one once herdr is replaced, and absent from a server whose herdr identity cannot be read.
  • Browser regressions (bun run check run --build, isolated herdr): on the final commit, pane-lifetime-regression (new: a server restart keeps draft and lens; a herdr restart opens the reused pane IDs empty on their default lens and keeps the text for recovery; Recover fills the box without sending; an older bridge keeps the draft out of storage), herdr-restart-regression (one reattach), held-rows-demo, prompt-dock-demo, composer-reconnect, terminal-draft, restored-draft-demo, notification-view, default-view, pwa-update, split-view and ui-regression pass. Before the gate fixes, on main 4d2e360: terminal-keyboard and key-bar-customization; earlier: terminal-autoswitch.
  • Recover unsent text on the demo at 1440x900 and 390x844 (3x), light and dark: the dialog is centred on desktop and a bottom sheet on the phone, each record shows its PC, pane, kind and time with Put in message box, Copy and Discard; nothing clipped or overlapping, no page errors.
  • Unit tests: each new safeguard fails when its fix is undone (the socket snapshot reaching the fence first, a stale roster, storing a page's kept text on the same herdr, terminal line counts, keeping the recovery record for a page-only box, the fenced pane move), and passes restored.
  • bun run check fast: green on the final commit: workflow syntax, generated types and themes, typecheck, build, and 7211 unit tests (0 fail).

mp added 7 commits October 26, 2026 18:42
herdr gives pane IDs out again once it is replaced, and nothing in a
snapshot told a browser that the panes behind those IDs are new.

Snapshots now carry an optional herdr_lifetime: a sha256 digest of the
identity finishes.ts already proves (the socket's device, inode and
creation time, or the Windows pid:start marker). It is the same for every
server that reads one herdr, so it survives a server restart, unlike
finish_epoch, and changes only with herdr itself. The identity is read
before and after the snapshot read; an unreadable identity or a
replacement during the read leaves the field out. It travels unchanged
through GET /api/session, socket snapshots and the remote PC relay.

createServer takes a herdrIdentity option so tests can give one.
…e under

After herdr restarted and gave its pane IDs out again, a pane opened
with the unsent message, terminal line, held input and lens of the pane
that had its ID before. The user could send text written for another
program.

The stored pane state keeps its keys. Each PC's state now says which
herdr it belongs to (ovis:pane-lifetime:<PC>, from the snapshot's
herdr_lifetime). When a roster names another herdr, before it is drawn,
the earlier herdr's text moves to ovis:unsent:<id> records and its
lenses and sending leases go; the in-memory copies are dropped in the
same render. A server restart alone keeps everything.

- Nothing is deleted or sent on its own. Recover unsent text, in the
  pane's menu while there is some, lists each text with its PC, pane and
  kind: Put in message box adds it to that pane's box, Copy, Discard.
- A PC whose server names no herdr (an older bridge) keeps its pane state
  in the page: it survives reconnects and never reaches storage.
- A tab that is behind another one leaves the stored state alone and
  keeps its own typing in memory until it catches up, then for recovery.
- The demo names one fictional herdr per PC.

Fixes #1608
…ge refuses

Review follow-ups for the pane lifetime fence:

- Held and unconfirmed chat messages (ovis:pending:, and the older
  ovis:queue:) go through the same per-herdr storage. A replaced herdr's
  rows go to recovery, one record per message; rows a live connection
  proves stay until the bridge settles them.
- Each PC keeps the herdrs its stored state outlived. A tab handed one of
  them is behind and leaves storage alone; any other herdr is a
  successor, so a tab that missed one is never stuck in page memory.
- Once a page saw a PC prove its herdr, a snapshot without a lifetime
  changes nothing, so the message box does not empty for one read.
- Text whose recovery record storage refuses, an edit storage refused, and
  input held but not yet saved are kept for recovery instead of lost.
  Records are kept once per pane, kind and text.
- Put in message box keeps the record when the box could not save it.
… from the tab's menu in checks

- The dialog's state and its Put in message box move into
  src/lib/useUnsentRecovery.ts: App stays at its hook ceiling.
- The browser lane counts the new regression on top of #1849's script.
- The pane lifetime regression opens the pane's actions from its tab's
  menu (a lone pane has no menu of its own) and prints the roster,
  storage and lens when the reused pane does not open on its default lens.
…p what a page held for the same herdr

Review findings on the rebased branch (omo-native-code-reviewer LOW 1-3, Codex gpt-6-astra MEDIUM 2-3):

- A PC's connection reports its snapshot's herdr_lifetime to the fence before any pane hears of
  it (lib/machineSession.ts), so a terminal that reconnects to a replaced herdr no longer shows the
  earlier pane's draft until the roster catches up. A read naming a herdr the page already left
  (a roster the connection overtook) is stale, never a herdr to go back to.
- Text a page kept while storage refused its record goes to storage once storage takes it on the
  same herdr, instead of to recovery while the pane still holds it; only another tab's different
  text for that pane is left to recovery.
- A herdr replacement counts every terminal line of that PC the page knows as changed, so a paste
  still waiting on the clipboard is not put into the new pane's line.
- Put in message box keeps the recovery record when the box of a PC with no proven herdr holds
  the text in the page alone, so a reload can still recover it.
- DESIGN.md says why no coding-agent app is the model for Unsent text.
A link or an alert opens its pane on the lens it names, drawn over the pane's own until the pane or
its lens is picked by hand. The address bar keeps that lens in the URL, so a reload lands with it.
After herdr was replaced, the reused pane ID kept the old pane's chat lens through it, though its
own lens was already reset (pane-lifetime-regression caught it). The named lens now ends when the
selected PC's herdr is replaced.
@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 14 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 4d2e360 and f0bdaec.

Files selected for processing: 43
  • DESIGN.md
  • changelog.d/pane-state-herdr-lifetime.md
  • scripts/ci-browser.sh
  • scripts/held-rows-demo-regression.ts
  • scripts/pane-lifetime-regression.ts
  • scripts/prompt-dock-demo-regression.ts
  • server/api.contract.test.ts
  • server/core/status.ts
  • server/finishes.test.ts
  • server/finishes.ts
  • server/index.ts
  • shared/protocol.ts
  • site/demo/transport.ts
  • src/App.tsx
  • src/components/Composer.tsx
  • src/components/PaneCanvas.tsx
  • src/components/PaneTerminal.tsx
  • src/components/UnsentText.css
  • src/components/UnsentText.tsx
  • src/lib/composerDraft.ts
  • src/lib/followFocus.test.ts
  • src/lib/followFocus.ts
  • src/lib/i18n.ja.ts
  • src/lib/i18n.ko.ts
  • src/lib/i18n.zh.ts
  • src/lib/i18n/terminal.ja.ts
  • src/lib/i18n/terminal.ko.ts
  • src/lib/i18n/terminal.zh.ts
  • src/lib/machineSession.test.ts
  • src/lib/machineSession.ts
  • src/lib/messageQueue.ts
  • src/lib/paneLifetime.test.ts
  • src/lib/paneLifetime.ts
  • src/lib/paneMove.test.ts
  • src/lib/paneMove.ts
  • src/lib/pendingMessages.ts
  • src/lib/terminalDraft.test.ts
  • src/lib/terminalDraft.ts
  • src/lib/useMachineRoster.ts
  • src/lib/usePaneAttach.ts
  • src/lib/usePaneLens.ts
  • src/lib/useUnsentRecovery.hook.test.ts
  • src/lib/useUnsentRecovery.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devswha

devswha commented Oct 26, 2026

Copy link
Copy Markdown
Owner Author

CodeRabbit's review limit was reached on this PR, so no CodeRabbit review ran. This PR changes the HTTP/WS contract (herdr_lifetime in the snapshot), so per AGENTS.md here are the code-review agents' findings and how each was resolved. Codex gpt-6.1-sol did not run on the rebased branch (host stall); the merge pass reviews.

omo-native-code-reviewer, rebased branch: APPROVE (no HIGH or MEDIUM)

Finding Resolution
L1: text a page kept while storage refused its record went to recovery once storage took it on the same herdr, while the pane still held it (a later double send) Fixed: it goes to storage; only another tab's different text for that pane goes to recovery. Unit test fails without the fix.
L2: DESIGN.md did not say which coding-agent app Unsent text follows, or why none Fixed: none of them reuses a conversation ID, so Slack's Drafts is the model.
L3: a herdr replacement did not count the PC's terminal lines as changed, so a waiting clipboard paste was guarded only by the connection change Fixed: every line of that PC the page knows is counted. Unit test fails without the fix.

omo-native-code-reviewer, before the rebase: BLOCK, then fixed

Finding Resolution
H1: held and unconfirmed chat messages (ovis:pending:, ovis:queue:) bypassed the fence Fixed: fenced and archived as pending.
M1: retiring deleted stored text even when its archive write failed Fixed: kept for recovery in the open page.
M2: a tab that missed a herdr stayed page-only for good Fixed: retired-herdr list per PC, retried on each roster.
M3: older bridges keep drafts page-only Declined: the issue asks for that until they name a herdr.
M4: a snapshot missing its lifetime flipped the generation Fixed: no news once a herdr was proven.
L1: a send in flight keeps its lease across the replacement Declined, under Not covered.
L2: "in the same render" is one commit early for the lens Harmless: herdr-restart-regression still sees one attach.
L3: two tabs retiring at once Duplicates deduped; the race is under Not covered.
L4: Settings' forget-lens choices misses page-only lenses Declined, under Not covered.
L5: i18n entries under another feature's marker Fixed.
L6: the digest is unsalted No issue: auth-gated, and equal across servers by design.
L7: Put in message box discarded the record when the box could not save Fixed.

Codex gpt-6-astra (the contract), rebased branch: no HIGH, three MEDIUM

Finding Resolution
A terminal reconnecting to a replaced herdr showed the old pane's draft until the roster caught up Fixed: the PC's connection reports its snapshot's herdr to the fence before any pane hears of it; a roster naming a herdr the page left is stale. Unit test fails without the fix.
Put in message box dropped the record for a PC whose box keeps text in the page only Fixed: the record stays until the text is stored. Hook test fails without the fix.
A snapshot with no lifetime after one was proven could show reused IDs the old drafts Declined, under Not covered: the server reads a snapshot again when herdr changes during the read, so it needs an unreadable identity at that moment.

Codex gpt-6.1-sol, before the rebase: no HIGH, six MEDIUM

Fixed: a stale first roster rolling the record back (retired list), failed archives deleting text (page recovery), unsaved composer edits and held input awaiting persistence dropped at retirement. Declined, under Not covered: an older release's open tab writing bare keys, and a send in flight across the replacement.

Found by the browser regression

pane-lifetime-regression showed a reused pane kept the old pane's chat lens through the URL's view=chat after a reload. Fixed: a link's or alert's lens ends when the selected PC's herdr is replaced.

@devswha

devswha commented Oct 26, 2026

Copy link
Copy Markdown
Owner Author

Merge pass note: this PR conflicts with #1987 (OpenCode subagents, still in review) in server/core/status.ts and server/index.ts. Both are open maintainer PRs. Each merges cleanly into main on its own. Whichever is approved and green first merges first, and the other needs a rebase.

Both touch server/, so neither can merge before the 0.4.18 Release run finishes. Astra is reviewing this PR.

@devswha

devswha commented Oct 26, 2026

Copy link
Copy Markdown
Owner Author

Merge pass review of 569dc79. The Astra gate (omo-native-gate-reviewer, gpt-6-astra) rejected it on three blockers it reproduced.

What holds: 41 focused tests pass, 59/59 locally. The build and scripts/pane-lifetime-regression.ts pass. Native Windows and Mac weren't re-run.

BLOCKER 1: a missing lifetime fails open (src/lib/paneLifetime.ts:140; report R1)

  • What happens: once lifetime A has been established, a snapshot with no lifetime name leaves A's drafts live and keeps saving edits to them. That includes the case where an older bridge sits in front of a replacement herdr.
  • Fix: keep the text, but don't assign it to panes whose lifetime is unknown.

BLOCKER 2: legacy drafts are adopted without proof they belong here (src/lib/paneLifetime.ts:177-182; report R2)

  • What happens: on first load with no lifetime record, the existing draft and lens keys are assigned to the current herdr. A replacement pane then inherits them, and recovery stays empty.
  • Fix: send legacy text whose owner is unknown to recovery, not to the live pane.

BLOCKER 3: a late acknowledgement changes the replacement's draft (src/lib/composerDraft.ts:128-150, src/components/Composer.tsx:814-815; report R3)

  • Reproduction: send deploy under A, replace A with B, then type deploy new target. A's acknowledgement trims B's draft to new target.
  • Fix: tie each settlement to the lifetime it was sent under.

All three break this PR's promise that text written for one program is never shown to or changed for another, and is never silently lost. Please add regression tests for R1–R3.

This PR touches server/ and shared/ and conflicts with #1987, so it merges only after the 0.4.18 Release run. The re-review will cover only the new commits.

…tle a send only under its own herdr

The merge pass's gate review (omo-native-gate-reviewer) on 569dc79 found three ways text could
still reach the wrong pane; each now has a regression test that fails without its fix:

- A snapshot that names no herdr after one was proven drew its panes with the earlier herdr's
  drafts. Its panes now get none of the stored state, which stays in storage; text typed meanwhile
  is kept in the page and goes to storage when the same herdr is named again, or to recovery when
  another is. A page whose storage took another tab's record still moves its own text there.
- Text stored before this release has no record of its herdr. It was adopted as the current
  herdr's; it now goes to Recover unsent text on the first load. Lenses stay: a lens is no text.
- A late acknowledgement of a send begun for the earlier herdr's pane trimmed the new pane's draft
  that started with the same text. Each send is tied to the herdr it began under: a replacement
  releases the box, and the old settle and end change nothing.
- A link's lens also ends when reads naming no herdr come between the two herdrs.

The demo regressions that seed held rows before the page loads now seed the demo herdr's record.
@devswha

devswha commented Oct 26, 2026

Copy link
Copy Markdown
Owner Author

Fixed in e96f12a, one regression test per blocker in src/lib/paneLifetime.test.ts (each fails with its fix undone):

  • R1 A snapshot naming no herdr after one was proven now fails closed: its panes get none of the stored state, which stays in storage. Text typed meanwhile is kept in the page and goes to storage if the same herdr is named again, to recovery if another is.
  • R2 Text stored with no record (before this release) now goes to Recover unsent text on the first load. Lenses stay: a lens is no text, and 49 browser scripts seed bare lens keys. The two demo regressions that seed held rows before load now seed the demo herdr's record.
  • R3 Each composer send is tied to the herdr it began under: a replacement frees the new pane's box, and the old send's settle and end change nothing (your deploy / deploy new target case is the test).

Also: a link's lens now ends across reads that name no herdr in between. Verified on e96f12a: 11 browser regressions (pane-lifetime, herdr-restart one reattach, held-rows, prompt-dock, composer-reconnect, terminal-draft, restored-draft, notification-view, default-view, pwa-update, ui-regression) and bun run check fast (7209 unit tests, 0 fail)..

@devswha

devswha commented Oct 26, 2026

Copy link
Copy Markdown
Owner Author

Merge pass re-review of e96f12a (Astra gate): R2 and R3 are fixed. R1 is still open, and the new code adds one unsafe case.

Fixed:

  • R2: legacy drafts whose owner is unknown now go to recovery.
  • R3: a send's acknowledgement settles only under its own herdr.
  • A plain reconnect of the same herdr still keeps the drafts.
  • Checks: 42 focused tests pass. Each of the three regressions fails when its fix is turned off in memory. The fresh-build browser regression passes.

BLOCKER 1, R1: socket snapshots with no lifetime still get past the fence (src/lib/machineSession.ts:41; report B1)

  • Why: MachineSession calls observe only when the lifetime field is present.
  • Reproduction: after lifetime A, a disconnect, then a snapshot with no lifetime, a pane subscriber still sees A's lifetime and the text old socket pane text.
  • Test gap: the regression calls observe directly, so it doesn't cover this path in.
  • Fix: apply snapshots with no lifetime to the fence before pane subscribers are notified, and add a regression that goes through that path.

BLOCKER 2, new: text with no lifetime proof becomes a live draft (src/lib/paneLifetime.ts:146-154, src/lib/paneLifetime.test.ts:151-169; report B2)

  • Why: the new back branch treats A, then no lifetime, then A again as proof that text typed in between belongs to A.
  • Reproduction: written with no lifetime proof becomes A's live draft, and the recovery list is empty. A later A snapshot doesn't prove who owns the text typed in between. The new test explicitly expects this adoption.
  • Fix: restore A's drafts that were proven before, but send edits made without lifetime proof to recovery. Change the test to match.

This PR touches server/ and shared/ and conflicts with #1987. It merges once it's approved and green. The re-review will cover only the new commits.

…nothing typed without proof

The merge pass's gate re-review of e96f12a kept two cases open; each has a regression test that
fails without its fix:

- A PC's connection applied only snapshots that named a herdr. One naming none (after a reconnect)
  reached the panes with the earlier herdr's drafts still live. Every socket snapshot now reaches
  the fence before any pane hears of it.
- Text typed while no read proved the panes' herdr was stored as that herdr's once the same herdr
  was named again. A later read does not prove who the text was for: it now goes to recovery, and
  the herdr's own stored state comes back as it was.
@devswha

devswha commented Oct 26, 2026

Copy link
Copy Markdown
Owner Author

Both fixed in 93f97c4, each with a regression test that fails with its fix undone:

  • B1 Every socket snapshot now reaches the fence before any pane subscriber, named or not (src/lib/machineSession.ts). The new test in src/lib/machineSession.test.ts goes through MachineSession: lifetime A, then old socket pane text, a disconnect, and a snapshot with no lifetime. The subscriber sees no lifetime and no text.
  • B2 Text typed while no read proved the panes' herdr is no longer adopted when the same herdr is named again. It goes to recovery, and A's proven drafts come back as they were. The R1 test in src/lib/paneLifetime.test.ts now expects exactly that.

Verified on 93f97c4: 12 browser regressions (pane-lifetime, herdr-restart one reattach, held-rows, prompt-dock, composer-reconnect, terminal-draft, restored-draft, notification-view, default-view, pwa-update, split-view, ui-regression) and bun run check fast (7210 unit tests, 0 fail)..

The "Integration and browser" failure on e96f12a was its jobs being cancelled, not a test failure.

@devswha

devswha commented Oct 26, 2026

Copy link
Copy Markdown
Owner Author

Merge pass re-review of 93f97c4 (Astra gate). Both production blockers are fixed. One regression test is still missing.

Fixed, checked through the real MachineSession path:

  • Snapshots with no lifetime are fenced before any subscriber runs.
  • A's proven drafts come back.
  • Edits made without lifetime proof go to recovery, not to the live draft.
  • R2, R3 and a plain reconnect still behave correctly.
  • 43 focused tests pass, as does the fresh-build browser regression. The B1 ingress test and the B2 unit test each fail without their fix.

T1 (test only): B2 has no regression through the real input path

  • src/lib/machineSession.test.ts:219-235 stops right after receiving the snapshot with no lifetime. It never types any text without proof, and never receives A again. B2's test at src/lib/paneLifetime.test.ts:151-175 calls observe directly instead.
  • With the unsafe B2 adoption branch restored in memory, all 12 committed MachineSession tests still pass. Astra's temporary probe through the real path does fail in that case: an otherwise empty pane picked up unidentified new draft, and recovery left it out. That probe passes on the current head.
  • What to add: extend the committed ingress test with A → no lifetime → edit → A. Assert that A's original draft comes back, and that edits made without proof appear only in recovery. Include one for an otherwise empty pane. Confirm the test fails when B2's old branch is put back.

No other production change is needed. This PR touches server/ and shared/, and conflicts with #1987. The re-review will cover only the new commits.

…PC's connection

The merge pass's gate asked for B2's regression through the real input path: lifetime A over the
connection, a reconnect whose snapshot proves no herdr, an edit in an otherwise empty pane, then
A again. A's own draft comes back and the edit is only in recovery. Restoring the old adoption
branch fails this test.
@devswha

devswha commented Oct 26, 2026

Copy link
Copy Markdown
Owner Author

T1 added in f0bdaec (test only): src/lib/machineSession.test.ts "brings a PC's own drafts back once its connection names its herdr again, and leaves what was typed with no proof to recovery" goes through MachineSession: A, a draft in one pane, a reconnect with no lifetime, an edit in an otherwise empty pane, then A again. A's draft comes back, the empty pane stays empty, and the edit is only in recovery. With the old adoption branch restored, it fails (12 pass, 1 fail). bun run check fast on f0bdaec: green, 7211 unit tests, 0 fail.

@devswha

devswha commented Oct 26, 2026

Copy link
Copy Markdown
Owner Author

Merge pass review report. Overall: PASSED. This PR changes held and unsent input, drafts and the HTTP contract. The Astra gate (omo-native-gate-reviewer, gpt-6-astra) reviewed it in four rounds and approved f0bdaec. CodeRabbit was rate-limited, so this agent review takes its place, as AGENTS.md allows.

What it does: herdr hands pane IDs out again once it is replaced. Until now, a pane opened after a herdr restart showed the previous pane's unsent text, held input and lens, so text written for one program could be sent to another (#1608). That state is now tied to the herdr lifetime it was made under.

Findings and how each was resolved:

  • R1 (569dc79), a missing lifetime failed open: a snapshot with no lifetime left the old lifetime's drafts live. e96f12a fixed the direct path. 93f97c4 fixed the socket path, where MachineSession skipped observe when the field was absent: a snapshot with no lifetime is now fenced before any pane subscriber runs.
  • R2 (569dc79), legacy drafts adopted without proof: existing drafts were assigned to the current herdr on first load. Fixed in e96f12a: legacy text whose owner is unknown goes to recovery.
  • R3 (569dc79), late acknowledgements: an acknowledgement from lifetime A trimmed a draft typed under B. Fixed in e96f12a: a settlement applies only under its own lifetime.
  • B2 (e96f12a), text adopted without proof: the sequence A → no lifetime → A adopted text typed in between as A's live draft. Fixed in 93f97c4: A's proven drafts come back, and edits made without lifetime proof go to recovery. They are never made live and never lost.
  • T1 (93f97c4), missing ingress regression for B2: added in f0bdaec. It runs A → no lifetime → edit → A through MachineSession, including an otherwise empty pane. With the old branch restored, it fails at src/lib/machineSession.test.ts:266.

What holds: a plain reconnect of the same herdr keeps the drafts. 43 focused tests pass, the MachineSession suite passes 13/13, and the fresh-build scripts/pane-lifetime-regression.ts passes. Native Windows and Mac were not re-run.

Conflict: this PR conflicts with #1987 (server/core/status.ts, server/index.ts), and whichever merges second needs a rebase. Because it changes queued input and drafts, it merges on its own.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Terminal: keep a pane's drafts and lens from showing up in a different pane after herdr restarts

1 participant