Skip to content

Decision mode on a linked computer's thread - #4066

Merged
backnotprop merged 13 commits into
mainfrom
feat/inbox-decision-mode-linked
Nov 28, 2026
Merged

backnotprop merged 13 commits into
mainfrom
feat/inbox-decision-mode-linked

Conversation

@backnotprop

@backnotprop backnotprop commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

This push (fixes after an independent review, 2026-11-28)

  • Merged main at 52e3560 (no rebase); merge commit 93cc126. One conflict, packages/inbox/decisions/DecisionMode.tsx: main's inboxApi.thread(first.thread.id, sendReadMs()) (Inbox: a Send always ends when its connection dies without a word #4158) is kept inside this branch's try/catch (the away path), and main's sendReadMs import sits beside this branch's imports. No size ceiling moved.
  • Try again on a held Send that was refused or cancelled now sends. sendGroup is a useCallback over [props.refresh], and App's refresh is stable, so Send read the outbox as it was when the dialog opened. It never saw the settled entry, kept the old key, and the outbox answers a settled key with how it ended ("Cancelled", "Not delivered") every time. Send now reads the current outbox (propsRef.current.outbox, DecisionMode.tsx:570). No other closure in the dialog read a prop that goes stale.
  • A held reply can no longer land on an answer the person never sent. The case: Laptop is away. In Studio's window the person picks A (held) and presses Send; the reply names the question at the revision that pick makes on Laptop. Meanwhile B was picked on Laptop. When Laptop is back, the pick is refused, and before this change the reply still matched, so the agent got B while Studio showed the reply as sent. Now the outbox (packages/server/inbox-outbox.ts, rule 22 in inbox-machines.md) records on a held reply the held picks and marks it relies on: those waiting for that machine on a decision it names (reliedOn, kept as after). When one of them surely never applied there, the reply is refused with that one's answer and never sent. The window then shows the Send's existing refused state with Try again, and Try again sends under a new key from the thread as it now is. The words come from the pick's own refusal ("Not delivered: …"); no new words.
    • An older linked computer is safe: nothing new goes on the wire. after lives only in this Inbox's outbox file and is never sent on, so no mark or capability gate is needed. This is the Inbox (Bun only), so there is no Pi twin.
  • Doc comment on INBOX_LINKED_MARKS (decisions) corrected: a Can't do it's reason stays the window's own Inbox's comment draft, with no door route.
  • Tests added:
    • packages/inbox/decisionHeldRetry.test.tsx (DOM, new file: the dialog's other Send tests start an Inbox): a held Send refused, and one cancelled, then Try again posts a new key. It fails without the fix (the same key is replayed).
    • packages/server/inbox-outbox.test.ts, "a held reply goes only on top of the held picks and marks it carries": a refused held pick takes the reply that names its question with it (kept across a restart, never sent, refused with the pick's answer), and later writes still go in order; a delivered pick lets the reply go; a pick on another message named with message_id; an action item's held mark taken back. Three of the four fail without the change.
    • packages/server/inbox-decisions-linked.test.ts (CI only, two real Inboxes): the collision end to end. Laptop's own window picks B while Studio still holds the older revision, Laptop stops, and Studio picks A (held) and sends (held). With Laptop back, both are refused, no reply reaches Laptop, and the question is still B and not sent there. Try again under a new key is delivered. (B is picked just before Laptop stops, not while it is away: Laptop's store sees the same order either way, and the test cannot reach a stopped Inbox's window.)
  • Ran locally, one file at a time: decisionHeldRetry (DOM) 2/2, inbox-outbox 39/39, inbox-outbox-file-wire 3/3, inbox-decisions-merged 5/5, decisionFarThread 4/4, decisionSaves 8/8, decisionReasonDrafts 8/8, heldPick (DOM) 5/5, inbox-structure 5/5, ci-e2e-shard 8/8, dom-test-allowlist 1/1. tsc --noEmit passes for packages/core, server and inbox.
  • Ran in CI only: inbox-decisions-linked.test.ts, decisionMode.test.tsx, inbox-decisions.test.ts, and every e2e spec. That includes the rewritten step 5 of inbox-decision-mode-linked.spec.ts, which has never run before: the last head conflicted with main, so GitHub ran no checks on it.

Known, not fixed

  • Linked computers' decisions are one read behind (M2). The merged read answers from what each computer last gave and reads it again in the background. Nothing tells the windows when that background read lands; a window sees it at its next decisions read.
  • Step 5's root cause is unproven ("Decision mode is one switch for both"). It failed the same way before and after the last merge. The spec now checks each hop on its own and names the one that fails; the cause is in this PR's CI result, not in a fix.
  • A far thread's reason drafts are never swept (the FAR_REASON_KEY skip in comment-drafts.ts), and stay after an unlink, when reading them gives 404.
  • With more than 24 h of clock skew between the computers, trusted() treats the two sides differently, so two timed opposite flips can stay different for good.
  • A held pick refused in the instant before a Send made while away, before the window hears of it: the reply is not held behind it and is sent as the window built it. This needs Laptop to answer the drain and then be unreachable again within that moment.

Earlier push (merge of main, 2026-11-27)

  • Merged main at ca2b323 into the branch (no rebase). New head 750f5a6.
  • Files resolved by hand:
    • packages/core/inbox-types.ts: the linked marks list keeps main's linked-reads and reply-drafts and adds decisions last. Both sides' comment lines are kept.
    • packages/inbox/api.ts: one import line. Main's linkedReads import and this branch's rememberDecisionMachines are both kept. 2119 lines, at its ceiling, the same as main.
    • tests/inbox-size-ceilings.json: main's values, with Thread.tsx lowered from 5705 to 5694, its size after the merge. No ceiling was raised.
    • docs/agent-guides/inbox-messages.md: the Decision mode paragraph keeps this branch's "one set" sentence and main's new keepWatched sentences.
    • docs/agent-guides/server-and-storage.md: main's two reply-draft rows. The comment-draft row is main's, plus this branch's machine sentence.
    • apps/mobile/contract/generated/swift/Wire.swift, apps/mobile/contract/parity/ledger.json: main's copies, regenerated with bun scripts/mobile/all.ts. scripts/mobile/check.ts says the contract is in step.
    • bun.lock: main's, from the merge. Not edited by hand.
  • Send: decision mode's Send calls inboxApi.reply with its own idempotency key, on main and here alike. Inbox: a Send survives another tab's save of the same answers #4109's sendOverSameAnswers belongs to the reply box (useSendReply), and decision mode does not use it on main either.
  • Ran locally, one file at a time: 71 tests, 0 failed. The files were inbox-structure, inbox-decisions-merged, inbox-comment-drafts-far, inbox-remove-agent, decisionFarThread, decisionSaves, decisionReasonDrafts, decisionsModel, decisionReadRetry, DOM heldPick and decisionSittingWait, ci-e2e-shard, and dom-test-allowlist. tsc --noEmit passes for packages/core, shared, server and inbox.
  • Ran in CI only: inbox-decisions-linked.test.ts, decisionMode.test.tsx, inbox-decisions.test.ts (each starts an Inbox) and every e2e spec.
  • CI on 750f5a6: inbox-decision-mode-linked.spec.ts step 5 fails ("Decision mode is one switch for both"). After Decision mode is turned off in Studio's Settings, Laptop's switch still shows on after 20 s (:343). Steps 1 to 4 pass. The same step failed the same way on 984b94e before this merge, so it is not a flake and the merge did not cause it. The cause is not found. The same flip passes for Checklist in inbox-routines-machines.spec.ts. One difference is that this spec stops and restarts Laptop (steps 3 and 4) before the flip. Until this is fixed, "turning it off on one computer turns it off on both" is not proven for Decision mode.
  • Nobody has tried this by hand: two real computers, a computer that is really asleep (not a stopped Inbox), or an older Plannotator on the other side.
  • Corrected below: this body said a Can't do it reason is kept on Laptop through new door routes. The code keeps it on the window's own Inbox. The only new door route is GET decisions.

Decision mode on a thread whose agent is on a linked computer: "Decide these N", the dialog and every answer in it work there as they do here. Before this, the button never showed for such a thread, because GET /api/inbox/decisions listed only this Inbox's decisions.

What a person sees

  • A linked computer's thread (Laptop's, opened in Studio's window) shows "Decide these N" under its open questions, as a thread of this computer does. It works both ways.
  • In the dialog, a pick, an un-pick, Undo, Done and Can't do it all land on Laptop. A reason typed under "Can't do it…" is kept as a draft on the computer it was typed on (Studio), and reaches Laptop with the Can't do it mark, as its note. Pictures and files load from Laptop.
  • When Laptop is asleep:
    • a pick or a mark says "Waiting for Laptop: this applies when Laptop is back." in the dialog's notice line;
    • Send's chip says "Will send when Laptop is back";
    • once Laptop is back, everything is delivered once and in order, and those words go.
  • If a held pick is refused on Laptop, the card is unpicked and the notice says why, as on the thread's own cards.
  • An older Plannotator on the other computer (no decisions mark) is never asked. Its threads show no "Decide these N", and nothing says so.
  • Decision mode is already in the one shared capability set (Capabilities: one set of switches for all your linked computers #4014). Turning it off or on in Settings on one computer turns it on both. Nothing was built for this; the e2e spec proves it.

How

  • Merged decisions: GET /api/inbox/decisions?machines=1 (packages/server/inbox-decisions-merged.ts) reads each linked computer that lists the new decisions mark through its door (GET decisions, machine tokens only, 2 s).
    • When a computer is away or slow, its last list stands.
    • A door 404 (decision mode off there) gives none.
    • The window remembers the thread, message, project and file ids of far decisions as that computer's (rememberDecisionMachines), so their reads and writes go there.
  • Writes: no new write path. Picks, action marks and the reply already go through the forward and the outbox (DOOR_WRITES). The only new door route is GET decisions (machineOnly). The reason is a comment draft on the window's own Inbox (machine on the comment-draft route, decision-reason: keys only; inbox-comment-drafts.ts), on no door.
  • Send while away: the fresh reads of the thread fail with machine_offline, so the dialog sends from the thread as it holds it, with the picks and marks still held laid over it (decisions/farThread.ts). The reply then carries every answer the person sees, at the revision each held pick makes there.
  • One rule for held picks: components/Thread.tsx and decisions/saves.ts each settled held picks, and decision mode's copy never settled one. A refused held pick stayed drawn as saved, and its raised revision stayed for good. Both now use packages/inbox/heldPicks.ts.

Tests

  • packages/server/inbox-decisions-linked.test.ts (CI; two real Inboxes linked both ways): each merged read lists the other's decisions with machine, and a read without machines=1 lists only its own.
    • From Studio, through the forward: a pick and an un-pick land on Laptop; a reason is saved on Studio for Laptop's thread, read back there, and never on Laptop.
    • With Laptop stopped: its decisions are kept, a pick and a reply are each held (202), and two reason saves land on Studio at once with nothing held.
    • With Laptop back: each is delivered once and in order. There is one person reply, both questions are sent, Studio's own thread is untouched, and a phone token never reaches the three door routes.
  • packages/server/inbox-decisions-merged.test.ts: an older computer is never asked. One that is away or slow keeps its last list. One with decision mode off gives none. The merge keeps the order, skips held threads and duplicates, applies the project filter, and drops malformed entries.
  • packages/inbox/decisionFarThread.test.ts: a Send while away carries the held picks at the revision they make there, the held marks, and the latest of two picks. An un-pick or a mark taken back is not sent. A thread of this Inbox, or another failure, never sends from the held model.
  • packages/inbox/decisionSaves.test.ts: a held pick settles. Delivered, it is drawn from the thread again. Refused, it is unpicked, the person is told why, and its revision is given back. Held picks are listed in order for the Send.
  • packages/inbox/decisionReasonDrafts.test.ts: a far thread's reason is read and written on this Inbox, named by that computer, never sent there.
  • tests/e2e/inbox-decision-mode-linked.spec.ts (two compiled Inboxes, Studio and Laptop, linked by the CLI): "Decide these N" both ways, the dialog's writes on Laptop, Laptop asleep then back, and Decision mode flipped across the two windows' Settings. It saves whole-window shots to .local/proof/decision-mode-linked/.

e2e: inbox-decision-mode-linked.spec.ts inbox-decision-mode.spec.ts inbox-machines.spec.ts

Not in this PR

  • The general comment box of a far thread still keeps no draft (commentPictures.tsx). The door routes added here would let it.
  • A reply draft typed in this window for a far thread, and not yet saved there, is not checked by decision mode's Send.

Decide these N, the dialog and every answer in it work on a thread whose
agent is on a linked computer, through the forward and the outbox as the
thread's own answers do. GET /api/inbox/decisions?machines=1 adds each
linked computer's decisions (mark "decisions"; an older computer is never
asked; one away keeps what it last gave). A Can't do it's reason is kept as
that computer's comment draft (door routes GET/POST threads/:id/comment-draft,
machine tokens only). While that computer is away a pick, a mark and Send are
held and delivered once, in order; Send carries the held answers and its chip
says it will send when that computer is back.

Held-pick settlement was written twice (the thread's cards and decision
mode, the second never settling). It is one module now, heldPicks.ts.
- A held Can't do it keeps its reason until the mark lands there; refused
  there, the card opens again with its reason and the dialog says why.
- A reason for a linked computer's thread is this Inbox's own draft (one
  file per computer, thread and key), never sent there or held in the
  outbox; the comment-draft door routes are gone.
- A held Send refused there turns its chip to Not sent with Try again,
  which sends with a new key and counts its answers as unsent again.
- The merged read answers from what each computer last gave and reads it
  again behind; a stalled body never holds it.
- A Send while away goes from the thread when its reply box holds words.
- Waiting for <computer> is a status line, not an alert.
- App.tsx: the dialog's onAway moved to app/decideTuck.ts.
@backnotprop backnotprop added the ci:e2e Run the full browser suite (Inbox window e2e) on this PR label Nov 25, 2026
Conflicts resolved: the linked marks list keeps main's linked-reads and
reply-drafts and adds decisions; api.ts imports both main's linkedReads
helpers and rememberDecisionMachines; the docs keep both sides' words;
the mobile contract is main's, regenerated with scripts/mobile/all.ts;
the size ceilings are main's, with Thread.tsx lowered to its merged size.
…mputers

Step 5 failed on two heads with only "Laptop's switch is still on". It now
waits for Laptop's line to Studio after the restart in step 4, then checks
in order: the pressed window, that computer's saved switch and flip stamp,
the other computer's take of the flip, and the other computer's window.
A failure now names the side that broke.
…ox-decision-mode-linked

# Conflicts:
#	packages/inbox/decisions/DecisionMode.tsx
…end's key; a held reply is refused with a held pick it relies on

Send read the outbox as it was when the dialog opened, so Try again on a held Send
that was refused or cancelled replayed its settled key for good. It reads the
outbox as it is now.

A held reply now relies on the held picks and marks waiting for that machine on
the decisions it names. When one of them surely never applied there, the reply is
refused with that one's answer and never sent, so it cannot land on an answer
made on that machine meanwhile.
…ox-decision-mode-linked

# Conflicts:
#	tests/inbox-size-ceilings.json
…it on screen

A pick by a click moves the queue on 350 ms later. That move was never called off, so an Undo, or the card
chosen again from All, inside that moment was followed by the move to the next question. The move is now
called off when the person moves first (Undo, another card, an action item's card open again).
…efore the window listened shows

A window reads its settings at load and opens its event stream only after the first list read lands. A capability
switch turned in between (another window, an agent, or a linked computer's flip taken here) is told only to the
streams open then, and no frame replays it, so that window's Settings kept the old state until a reload. This is
what the two-computer spec's step 5 hit: Laptop's new Settings window kept Decision mode on.
@backnotprop
backnotprop marked this pull request as ready for review November 28, 2026 08:37
@backnotprop
backnotprop merged commit f3bbcdc into main Nov 28, 2026
61 checks passed
backnotprop added a commit to bendrucker/plannotator that referenced this pull request Nov 28, 2026
…panel swipes and the HTML viewer's lost highlights

ui 0.67.0 and core 0.25.35 went to npm on 2026-11-28 with package files
that match the v0.29.6 tag (c21f65e), so this pair carries what merged
after v0.29.6, up to v0.29.7.

core 0.25.36 is additive: the linked mark "decisions" and
InboxDecision.machine (backnotprop#4066), DraftFileUploader.previewUrl (backnotprop#4165), and
holdingsOf no longer counting a question Mark read closed (backnotprop#4160). No
exports subpath changes; nothing removed.

ui 0.68.0 is a minor: Escape while an input method composes only ends the
composition, and shortcuts skip such keys; holdsImeEscape is new (backnotprop#3689,
backnotprop#4162). HtmlViewer treats a collapsed live Range as lost (backnotprop#4152). Compact
panels: OverlayScrollArea scrollMemory, SidebarContainer closing and
scrollPositions, ActionMenu compactEdgeSwipe, four new hooks and the panel
rules in theme.css (backnotprop#2861). useLaunchAnnouncement waits for ready (backnotprop#4067).
ui uses nothing new from core; its exact pin follows so a host gets one
core. Publish core first.

README and HANDOFF name the new pair, and HANDOFF adds what the published
0.25.35 / 0.67.0 already held beyond their notes (backnotprop#4114, backnotprop#4151).

bun.lock is bun install's own output: the two package version lines, and
six app workspace version lines (0.29.5 to 0.29.7) the release bumps left
behind.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:e2e Run the full browser suite (Inbox window e2e) on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant