Repository navigation
fix(drafts): keep a pane's drafts and lens to the herdr they were made under - #1997
Conversation
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.
…the reused pane's 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.
|
Warning Review limit reachedYou'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. View limit details
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. Comment |
|
CodeRabbit's review limit was reached on this PR, so no CodeRabbit review ran. This PR changes the HTTP/WS contract ( omo-native-code-reviewer, rebased branch: APPROVE (no HIGH or MEDIUM)
omo-native-code-reviewer, before the rebase: BLOCK, then fixed
Codex gpt-6-astra (the contract), rebased branch: no HIGH, three MEDIUM
Codex gpt-6.1-sol, before the rebase: no HIGH, six MEDIUMFixed: 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
|
|
Merge pass note: this PR conflicts with #1987 (OpenCode subagents, still in review) in Both touch |
|
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 BLOCKER 1: a missing lifetime fails open (
BLOCKER 2: legacy drafts are adopted without proof they belong here (
BLOCKER 3: a late acknowledgement changes the replacement's draft (
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 |
…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.
|
Fixed in e96f12a, one regression test per blocker in
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 |
|
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:
BLOCKER 1, R1: socket snapshots with no lifetime still get past the fence (
BLOCKER 2, new: text with no lifetime proof becomes a live draft (
This PR touches |
…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.
|
Both fixed in 93f97c4, each with a regression test that fails with its fix undone:
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 The "Integration and browser" failure on e96f12a was its jobs being cancelled, not a test failure. |
|
Merge pass re-review of 93f97c4 (Astra gate). Both production blockers are fixed. One regression test is still missing. Fixed, checked through the real
T1 (test only): B2 has no regression through the real input path
No other production change is needed. This PR touches |
…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.
|
T1 added in f0bdaec (test only): |
|
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:
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 Conflict: this PR conflicts with #1987 ( |
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:
localStorage.How
server/finishes.ts,server/core/status.ts,shared/protocol.ts): snapshots carry an optionalherdr_lifetime. It is a sha256 digest of the herdr identityfinishes.tsalready proves (the socket's dev:inode:birthtime, or the Windows pid:start marker). It is the same for every server reading one herdr, unlikefinish_epoch, and it is left out when the identity cannot be read or changes during the read. It passes unchanged throughGET /api/session, socket snapshots and the remote PC relay; status frames keep the snapshot's value.createServergets aherdrIdentityoption for tests.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>).useMachineRostercallsobserveon 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 toovis: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 oldermessageQueue) and the lens. Rows a live connection proves stay until the bridge settles them. The adapter useslocalStorageonly while the page's herdr for that PC matches the record, and page memory otherwise.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.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.herdr_lifetimeafter 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.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.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 branchfix/pane-state-lifetime) changed them all.Stored formats (docs/development.md, Stored-format changes)
ovis:pane-lifetime:<PC>(a string),ovis:pane-lifetimes-retired:<PC>(a JSON list of at most 16 strings) andovis:unsent:<uuid>(JSON{machine_id, pane_id, pane_title?, kind, text, at}), both written bysrc/lib/paneLifetime.ts. No existing record changes shape, and no older writer rewrites either key, so an old tab cannot erase them.ovis:unsent:records, and lenses stay. Nothing is written back to the server.herdr_lifetimeis 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_lifetimeonce they run a bundle with this server change.server/andshared/changed, so the next release's guards will ask forREMOTE_BUNDLE_VERSIONto be raised. Until remote PCs update, their drafts stay page-only, as the issue specifies for older bridges.Not covered
Reviews
Verification
On the branch rebased onto main 4d2e360.
curl -ion an isolated herdr (GET /api/session): 200 OK each time;herdr_lifetimeis 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.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-viewandui-regressionpass. Before the gate fixes, on main 4d2e360:terminal-keyboardandkey-bar-customization; earlier:terminal-autoswitch.bun run check fast: green on the final commit: workflow syntax, generated types and themes, typecheck, build, and 7211 unit tests (0 fail).