Skip to content

Keep a pane's Codex conversation while tool output fills the screen - #16

Merged
devswha merged 6 commits into
devswha:mainfrom
Yoonwoo-Ha:fix/codex-transcript-binding
Sep 24, 2026
Merged

devswha merged 6 commits into
devswha:mainfrom
Yoonwoo-Ha:fix/codex-transcript-binding

Conversation

@Yoonwoo-Ha

@Yoonwoo-Ha Yoonwoo-Ha commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Codex doesn't say which rollout it writes to, so the chat recognises a Codex pane's rollout by a recent answer on screen, matched within the last 400 lines. A long run of exec/wait output pushes that answer past the 400 lines. The chat then flipped to "Conversation unavailable — show terminal output" until Codex answered again.

  • A TUI started as codex resume <thread> reads that thread by id (threads.id in state_5.sqlite), whatever the screen shows.
  • A pane whose Codex has been matched once keeps that rollout for as long as the same process runs. A later match to a different rollout replaces it, and a different process starts over.
  • Neither fallback survives a newer thread. After /new the command line still names the resumed thread and the process is the same, so each fallback holds only while no other thread in the pane's cwd has begun since. For the resume fallback, "since" means since the Codex process started (its start time from /proc; without that, the resumed thread must be the cwd's newest). For a match, it means since the match. Only interactive threads count (source cli or vscode): subagents and codex exec runs share the cwd but never replace the TUI's conversation. A thread another Codex pane in the same cwd shows is that pane's, and doesn't count either: when this pane's screen can't tell, those panes are resolved on the spot (at most once per 5s), whether or not anyone opened their chat. Once a newer thread appears, the chat says it can't tell, as main does, until the new thread's answer matches.

One trade-off: a new thread in another Codex pane in the same cwd counts as newer until that pane shows an answer of it. Until then, this pane says it can't tell while its own answer is off screen. It never shows the wrong conversation.

Testing

  • bun run typecheck is clean; bun test: 272 pass.
  • New unit tests for reading the thread id from a codex resume command line.
  • A contract test on real herdr panes running a stand-in codex process that prints its own answer (never on the typed command line) and then floods the screen. The test waits for the process to appear rather than sleeping. It covers:
    • resumed by id with no answer on screen; then a newer thread row appears, and the pane falls back to scrollback
    • matched once, then 600 lines of output push the answer out of the read, and the rollout is kept; after the process is replaced, the binding is dropped
    • matched and kept, then a newer thread row appears, and the pane falls back to scrollback
  • The keep tests fail on main's codex.ts, and each newer-thread test fails without its guard.
  • Live: a real codex resume <id> pane that is mostly exec/wait output resolves its conversation on every poll.

🤖 Generated with Claude Code

@devswha devswha left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The per-pane binding approach is sound: two panes in the same cwd, process restarts, and Codex-home checks all behave. Three things before merge:

  1. The new contract test is timing-dependent. codex-binding.contract.test.ts waits a fixed 700ms after typing. On a slow-starting shell (zsh here), pane.process_info still shows only the shell. Both new tests fail both in the full run and alone, and pass with longer waits. Also, in the matched test the first match comes from the typed command line (SAY='<answer>'), not from Codex's output. Please poll until a codex process appears, and keep the answer text out of the typed command.
  2. The resume fallback can show the wrong conversation for a long time. After codex resume A, then /new, the command line still names A. So every poll returns A's rollout until B produces a matching answer of at least 64 characters. With short answers or a long tool run, the chat shows A and the user's new prompts never appear. On main this showed "Conversation unavailable", which was honest. Suggestion: only use resumedPath while A is the newest thread for that cwd, or drop it once a newer thread row appears after the process started.
  3. Rebase onto main. #5 is merged and conflicts with this PR in server/codex.ts (paneRead/readTail → codexHistoryTail) and in the codex.test.ts imports.

Minor: the 64-entry cache evicts in insertion order, not least recently used. Re-set the key on each hit to keep active panes.

@Yoonwoo-Ha
Yoonwoo-Ha force-pushed the fix/codex-transcript-binding branch from 672017c to c51a517 Compare September 24, 2026 10:25
@Yoonwoo-Ha

Copy link
Copy Markdown
Contributor Author

Thanks. Addressed in c51a517. The branch is rebased onto main, which resolves the codexHistoryTail and import conflicts.

  1. Test timing. The test now polls pane.process_info until a codex process appears instead of sleeping 700ms. The stand-in prints the answer itself (--say reads answer.txt), so the typed command line never contains it. It passed 3 runs in a row on its own (zsh), and in the full suite.
  2. Stale resume fallback. resumedPath is used only while no other thread in the pane's cwd has a created_at later than the Codex process's start (read from /proc/<pid>/stat). Without a start time, it is used only while A is the cwd's newest thread. After /new, the chat shows "Conversation unavailable", as on main, until B's answer matches. A new contract test covers resume A, then a newer thread row, then scrollback. I checked that it fails without the guard.
  3. Rebase. Done.

Minor. The binding is re-inserted on each hit, so the cache evicts least recently used.

@Yoonwoo-Ha

Copy link
Copy Markdown
Contributor Author

One more follow-up (b84e6be). Your point 2 applied to a screen match as well: after /new, the same process kept showing the matched thread until the new one produced a matching answer. A match now holds only while no thread in the pane's cwd has begun since the match, using the same query as the resume guard. There is a contract test for it (matched, kept through the flood, then a newer thread row appears, and the pane falls back to scrollback), and it fails without the guard. The PR description is updated.

@Yoonwoo-Ha
Yoonwoo-Ha force-pushed the fix/codex-transcript-binding branch from b84e6be to 48bdfbb Compare September 24, 2026 10:50

@devswha devswha left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. The contract test, the stale fallback, the rebase and the LRU point are all done. One real issue with the new "newer thread begins" check:

  1. The pane's own subagents and codex exec runs count as a newer thread. The check (server/codex.ts ~405–423) reads threads rows with cwd = ? AND archived = 0 AND agent_role IS NULL, and nothing ties a row to this pane's process. agent_role IS NULL doesn't keep subagents out: a local state_5.sqlite here has 429 subagent threads with a NULL agent_role, all in their parent's cwd, and 13,058 source='exec' threads. Scenario: the pane's Codex spawns a subagent during a long tool run, which is exactly the case this PR targets. The binding is marked superseded and dropped, and the chat shows "Conversation unavailable". Any codex exec in the same repo does the same, including the Codex plugin run from Claude Code. Please filter to interactive sources (source IN ('cli','vscode')). Better still, on Linux use the rollout file descriptors you already collect as the proof that the process moved on.
  2. Two Codex panes in one repo. A thread started in one pane drops the other pane's binding while its answer is off screen. It never flips to the wrong conversation, but it shows "unavailable" until its own answer is back on screen. The fd-based check would fix this too.

Minor: the "kept through the flood" step still uses a fixed Bun.sleep(3500) and never checks that the answer actually left the screen, so it would pass even if the flood didn't happen. Also, #18 is merged: there's a trivial conflict in the server/codex.test.ts import line.

Yoonwoo-Ha and others added 4 commits September 24, 2026 20:52
…the screen

Codex does not say which rollout it writes, so the chat recognises it by a
recent answer on screen. A long run of exec/wait output pushes that answer
past the 400 lines read, and the chat flipped to "Conversation unavailable"
until Codex answered again. Now a TUI started as `codex resume <thread>`
reads that thread by id, and a pane whose Codex was matched once keeps that
rollout while the same process runs; a later match to another rollout (after
/new) replaces it, and another process starts over.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…dy binding test

Review follow-ups:

- After `codex resume A` then /new, the command line still names A, and the
  fallback showed A's conversation until the new thread produced a matching
  answer. It now holds only while no other thread in the pane's cwd began
  after that Codex process started (Linux: its start time from /proc); a
  later thread, from /new or another pane, makes the chat say it cannot tell,
  as main did. Without a start time it holds only while A is the cwd's newest.
- The contract test waits until the stand-in codex process runs instead of a
  fixed 700ms, and the matched answer comes from the process's own output,
  never from the typed command line. It also covers the newer-thread case.
- A pane's binding is re-inserted on use, so the 64 kept are the recent ones.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The review's /new case applied to a screen match as well: after /new the
same process writes a new thread, and the pane kept showing the matched
one until the new thread produced a matching answer. A binding now holds
only while no thread in the pane's cwd began since the match; otherwise
the chat says it cannot tell, as main did.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…s /new

Review follow-ups for the "newer thread begins" guard:

- Subagents (many with a NULL agent_role) and `codex exec` runs share
  their parent's cwd, so one spawned during a long tool run dropped the
  binding: the exact case this PR targets. Only interactive threads
  (source cli or vscode, when the store has that column) count now, for
  both the resume fallback and a screen match.
- A thread another pane is bound to is that pane's, and no longer counts.
  A superseded binding is kept rather than deleted, so a pane left unsure
  by a second Codex in the same repo holds again once that thread is bound
  to its own pane.
- The contract test waits until the flood has pushed the answer out of the
  400 lines the match reads, instead of a fixed sleep. It covers a
  subagent and an exec thread (kept), an interactive one (dropped), and
  another pane's thread (unsure until bound there, then kept).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@Yoonwoo-Ha
Yoonwoo-Ha force-pushed the fix/codex-transcript-binding branch from 48bdfbb to 42138b1 Compare September 24, 2026 12:14
@Yoonwoo-Ha

Copy link
Copy Markdown
Contributor Author

Thanks. Addressed in 42138b1, rebased onto main (the import conflict is resolved):

  1. Subagents and codex exec. Only interactive threads count as "newer": source IN ('cli', 'vscode'), when the store has that column. This applies to both the resume fallback and a screen match. My own store confirms the problem too: 51 exec threads and about 20 subagent threads with a NULL agent_role.
    • About fds: a Codex TUI that holds its rollout open (exactly one .jsonl fd) already resolves from that fd before any of this runs. The binding is only the fallback for TUIs that hold none (app-server TUIs, like most here). So there is no per-process fd to use as proof in the case this code handles.
  2. Two panes. A thread bound to another pane no longer counts. A superseded binding is now kept instead of deleted, so once the other pane's thread is bound there, this pane holds again. What remains: while the other pane's new thread isn't bound yet (nobody has read that pane's chat), this pane shows "unavailable" when its answer is off screen. It never shows the wrong conversation.

Minor. The test now waits until the flood has pushed the answer out of the 400 lines the match reads, instead of sleeping. New cases:

  • subagent and exec rows keep the binding
  • an interactive row drops it
  • another pane's thread leaves it unsure until bound there, then keeps it

Each case fails without its part of the fix. bun test passes, and the contract test passed 3 runs in a row.

… as /new

A second Codex in the same repo starting a thread left this pane unsure
(chat "unavailable" while its answer was off screen) until someone opened
the other pane's chat and bound it. When this pane's own screen cannot
tell and a newer interactive thread exists, the other Codex panes in the
cwd are now resolved on the spot, without looking further. A thread one
of them shows is theirs (and they are bound to it), not a /new of this
pane. This runs at most once per 5s per set of panes, and only while such
a thread is unclaimed. A /new in this pane shows in no other pane, so it
still reads as unsure.

The two-pane contract test no longer reads the other pane's chat first. It
fails without this change.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@Yoonwoo-Ha

Copy link
Copy Markdown
Contributor Author

Follow-up on point 2, two Codex panes in one repo (0454317).

The binding no longer waits for someone to open the other pane's chat. When this pane's own screen can't tell and a newer interactive thread exists, the server resolves the other Codex panes in the same cwd on the spot, without them looking further. A thread one of them shows is that pane's, and that pane gets bound to it. It is not read as a /new here.

The check runs at most once per 5s per set of panes, and only while such a thread is unclaimed. A /new in this pane shows in no other pane, so it still reads as unsure.

The two-pane contract test no longer reads the other pane's chat first. It fails without the change.

The check of the other Codex panes resolved each one in full: its
processes, open files, the store and up to 32 rollout tails matched
against its screen. It now reads each pane's screen once and matches it
against the unclaimed newer threads only, usually one. A pane that shows
one is bound to it. The 5s limit is kept per set of threads and panes, so
a pane that appears since is looked at at once.

Checked with two real Codex 0.156.1 panes in one folder. A was matched,
then its answer was pushed off screen. B was opened afterwards and
answered. A kept its conversation without anyone reading B's chat (119 ms
for that read, 12 ms once B was bound). With this check disabled, the
same run left A "unavailable". A /new in A afterwards was not taken for
its old conversation.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@Yoonwoo-Ha

Yoonwoo-Ha commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor Author

Follow-up (3f3aa6e): the other-pane check now reads each other Codex pane's screen once and matches it only against the unclaimed newer threads, instead of resolving each pane in full.

Checked with two real Codex 0.156.1 panes in one folder:

  1. Pane A answered and was matched.
  2. A 450-line reply pushed that answer off screen, and A kept its conversation by its binding.
  3. Pane B was opened afterwards and answered. A still kept its conversation, without anyone reading B's chat. That read took 119 ms; once B was bound, reads took 12 ms.
  4. With the check disabled, the same run left A "unavailable".
  5. A /new in A afterwards showed "unavailable", never A's old conversation.

One thing I learned about the store: Codex 0.156.1 writes a TUI's thread row at its first message, with created_at set to when the TUI started, and with source = 'vscode'. So a Codex opened before this pane's match never counts as newer. One opened after it counts from its first message until its answer shows.

@devswha
devswha merged commit c05eacb into devswha:main Sep 24, 2026
@devswha

devswha commented Sep 24, 2026

Copy link
Copy Markdown
Owner

Merged at 3f3aa6e. Thanks. The source filter and the cross-pane claim work, and a /new in the same pane no longer brings back the old conversation. A few follow-ups, none of which can show the wrong conversation:

  1. vscode is too broad. Rows with source='vscode' also come from Codex Desktop and app-server clients, which likely includes the Codex plugin in Claude Code (inferred, not verified). No pane shows those threads, so none gets claimed, and a Desktop session or plugin run in the same repo still leaves the pane "unavailable" while its answer is off screen. Worth narrowing, for example by the thread's originator or client, if the store records it.
  2. The 32-row candidate list for a screen match has no source filter (~501). A burst of codex exec runs in the repo can push the pane's own thread out of the top 32.
  3. Claims are matched against a narrower set. Another pane's screen is matched only against unclaimed threads, so a "unique" match comes more easily. If that pane shows 64+ characters of this pane's new answer (pasted or quoted), the claim goes to the wrong pane.
  4. Housekeeping. Bindings for closed panes stay until the 64-entry cap evicts them, and they keep counting as "another pane's". sessionSnapshot() also runs on every unsure poll, before the 5s throttle.

@Yoonwoo-Ha

Copy link
Copy Markdown
Contributor Author

Thanks. The follow-ups are in #20:

  • Candidates: the 32 are interactive threads only.
  • Claims: another pane claims a thread only when its screen shows the thread's first message as well as its answer, and the match must be unique against this pane's own thread and that pane's binding.
  • Housekeeping: the route's session snapshot is reused, and closed panes' bindings are dropped.

On vscode: on my machine, TUIs attached to a Codex Desktop app-server record originator = "Codex Desktop" as well, so the store can't tell them apart. That behavior is unchanged (a thread that no pane shows reads as unsure).

devswha pushed a commit that referenced this pull request Sep 24, 2026
From the merge reviews:

- #19: codexHistoryTail read the remembered chain as it was. After a
  backtrack the live file's tail reached an archived parent, the read
  threw, and an app-server TUI without an open rollout lost its screen
  match until the entry was evicted. Both codexHistoryTail and
  codexHistorySegments now use the chain only while every file in it
  exists, and look it up again otherwise. transcriptStream's own check is
  folded into that.
- #16: the 32 candidates for a screen match are interactive threads only,
  so a burst of `codex exec` runs no longer pushes a pane's own thread
  out.
- #16: another pane now claims a newer thread only when its screen shows
  that thread's first message as well as its answer. An answer of this
  pane quoted or pasted there claims nothing. Its screen is matched
  against this pane's own thread and its own binding too, so a match is
  unique across all of them.
- #16: the conversation route hands its session snapshot down, so an
  unsure poll takes no extra snapshot, and closed panes' bindings are
  dropped with it.

Not changed: narrowing `source='vscode'`. On this machine, TUIs attached
to a Codex Desktop app-server record originator "Codex Desktop" too, so
the store cannot tell a Desktop or plugin thread from a TUI's. A thread
no pane shows keeps reading as unsure, never as another conversation.

Tests: the archived-parent tail and the exec burst each fail without
their change. A pane showing only the other thread's answer leaves this
pane unsure; the pane that typed it claims it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
devswha added a commit that referenced this pull request Sep 24, 2026
devswha added a commit that referenced this pull request Nov 21, 2026
…w PC added' notice for it

The notice is for devices already in the account when the PC was added. It now compares the PC's admitted_at with this sign-in's signed_in_at (GET /v1/session, read once per sign-in); a PC admitted earlier is not told as new. The first-PC exemption's admitted-before-you notice is unchanged. Owner finding #16.
devswha added a commit that referenced this pull request Nov 21, 2026
… by itself, not only in Settings

A join a member could also approve (the PC already has an account member) reached the PC's own window only as a row in Settings > Devices, so on a PC with a member nothing popped up while the new device waited. The own window now shows a card for it, one join at a time: the device's name and a field for the six digits it shows. The field never takes the focus by itself; one wrong entry ends the join; Not now only hides the card and the join lapses at its own deadline. The list is read only in the PC's own window while it is not locked, and read again once a lock is lifted. Owner finding #16.
devswha added a commit that referenced this pull request Nov 21, 2026
…it in by itself, on one plain screen

Right after Google sign-in a phone new to the account showed the connect tabs, a 'new PC added' notice, the turn-on hint with QR, and a 'My PCs' list with 'Needs approval'. Nothing asked the PC: the launch skipped a PC inside its 24-hour window and a join waited for presses, so the Mac never showed its card.

- The sign-in's launch now asks to join the account PC that is on, PCs inside their 24 hours included (security-triage: the request grants nothing), with no press: its page sends the request at once.
- That join waits on one plain screen: the PC's name, 'Press [Allow] on <PC>' (or 'Type this number on <PC>' when the account already has a member), the number when the join shows one, a spinner, and the PC screen's QR (a code in a browser). No tabs, no banner, no list. After Allow the phone opens the PC as before.
- With none of the account's PCs on, the front page says 'Turn on Ovis on the PC' with Check again and the QR way in. The signed-in front page no longer lists the account's PCs; Add a PC still does.
- C3 pins 1 and 2: on a PC inside its 24 hours (as last read, kept in this browser by the join) nothing is selected by itself: no restored session, no fallback selection, no herdr-focus follow, no keyboard jump. Its own row in the sidebar shows New PC with 'I didn't add this' until the window passes.

Owner finding #16.
devswha added a commit that referenced this pull request Nov 21, 2026
…onnect tabs, in every state the sweep found

Owner sweep for #16. Each state that put a signed-in device (app or browser) on the connect tabs now opens Ovis or shows one plain line with the reason:
- none of the account's PCs on (directory, or the relay finds nobody): '<PC>: Ovis is off - turn it on', with Check again;
- the PC this device opened is off (its relay too): the same line naming it, not the tabs and the list;
- the join a launch asked ends declined, removed or with the PC off: one line with Ask again or Check again, within the existing request limits;
- a reload of the page a launch's join waits on asks again (it asked nothing before);
- a slow account read keeps the launch's card and goes on when the read lands, instead of falling back to the tabs;
- a signed-in device removed from a PC it had opened: one line with Ask again, which runs the front page's launch;
- an account with no PC yet: 'Sign in with the same account on the PC where Ovis runs';
- a later load of the front page in the tab, with nothing saved here, launches again unless the person chose the front page (Cancel, Back, Forget).
Each plain line keeps the account menu, the PC screen's QR (a code in a browser) and 'Other ways to connect'. Browser scripts reload after a hash-only navigation to /#add.
devswha added a commit that referenced this pull request Nov 21, 2026
…age until the account's PCs are read

C3 pin 1 on the path of an approved device signing in again: its launch opens the saved PC before the account's PCs are read, and with no window kept in this browser the page held nothing. The PC's page now holds its sessions ('unknown': no restore, no default selection, no herdr-focus follow, no keyboard jump) while a sign-in's PCs are not read yet, reads them, and goes on as they say; a pairing that joins no account holds nothing. The move off a PC that went away waits for that read before its own. Security-triage pin (a) for #16.
devswha added a commit that referenced this pull request Nov 21, 2026
…sees its notice and removes it

Gate B2 on #16: the 'new PC added' notice was cut by the latest sign-in's signed_in_at. Removing a PC wants a sign-in under ten minutes old, so a browser leaves for Sign in again and comes back with a later sign-in: the notice was filtered out and the removal never finished. The cut is now this device's first sign-in to the account, kept on the device and moved only earlier, so a later sign-in keeps the PCs it was told of; one press after the return removes the PC. Red test for the round trip.
devswha added a commit that referenced this pull request Nov 21, 2026
…ign-in and the account's PCs are read

e49469c (the #16 sweep, item 13) let a later front-page load in the tab, with nothing saved here, start the account launch at once. While the sign-in was still being read, or a sign-in was under way, that launch put its Connecting card over the front page, so the page showed Connecting instead of the provider being signed in with, and a code being typed or a read in flight landed under a card. That broke three front-page tests in accountController.test.ts. The relaunch now waits until the sign-in is read as signed in and the account's PCs are read; until then the front page draws as before.
devswha added a commit that referenced this pull request Nov 21, 2026
… fails; the notice test moves the fake's clock, not the wall clock

Gate B3 and the low note on #16 pin (a):
- A failed read of the account's PCs released a new PC's hold (fail open): the rows a failed read keeps carry no new window. The page now stays held until a read answers (fail closed), and a failed read no longer clears the window kept in this browser. Red test: a 503 directory keeps pcHeld().
- NewPcNotices.test.tsx made its second sign-in later with Bun.sleep(5), which the conventions' fixed-sleep check refuses: the fake account service now runs on the test's clock, moved on by a minute instead.
devswha added a commit that referenced this pull request Nov 22, 2026
Preview-qa on #16: an Android 15 re-join showed its number, the Mac never showed the request (its own window had lost its server for ~3 minutes, and the phone's relay session then ended with upstream_lost), and after the deadline the phone said '거절됐어요'. Once the number is shown, failureOf read a timeout as a decline. Now only the PC's refusal (auth_failed) is 'pair-declined'; a timeout, an admission timeout, an unreachable relay or an internal error after the number is the new 'pair-unanswered', drawn as one plain line 'No answer from {name}' (ko 'Mac에서 응답이 없어요') with the same Ask again. en/ja/zh. Follow-up, not in this commit: the Mac's own window reading its waiting joins again at once when it reconnects.
devswha added a commit that referenced this pull request Nov 22, 2026
The signed-in front page drew a page of its own when no PC was on or the
account had none yet. It is now the same My PCs: with none on, the list with
its rows saying Off under No PC is online and Check again (the launch's own
retry, or the sign-in's when nothing is saved here); with none in the account,
the empty list saying to sign in with the same account on the PC, over Add PC.
Other ways to connect goes with that page.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
devswha added a commit that referenced this pull request Nov 23, 2026
…dd a PC (#4487)

Part 1 of 3 of the one Connect a PC screen. This PR changes only the
hosted page (`src/`); the phone app's own pages (`app/`) follow in parts
2 and 3.

## What changes for a person

The hosted page had three different screens called Connect a PC: the
front page with Ovis relay | Tailscale | SSH tabs, each tab holding its
own list of PCs; and `/#add` (More → Connect a PC inside a PC), a
tab-less list of ways plus "Your PCs". They become two views:

- **My PCs** is the front page once the person is signed in or this
phone saved any PC. It is one list of every PC: the relay's (this
phone's pairings, then the account's PCs it can open) and the ones the
phone app saved by a Tailscale address, over SSH or at another address.
Each row shows the PC's name, a small way tag (Relay / Tailscale / SSH /
Address) and, for a relay PC, On, Off or Update needed. Tapping a row
opens the PC as before. **Add PC** stays at the bottom of the screen
while the list scrolls. The account's notices (join requests, new PC,
unconfirmed PC), the "no PC is online" card, the directory error with
Try again, the account ⋮ menu, Forget on a row this phone can forget,
and Removed on a PC that removed this phone all stay on My PCs. Signed
out, a sign-in that ended or was signed out everywhere is said above the
list too.
- **Add a PC** is the three tabs, holding only the ways in, with no
list: the sign-in (signed out) and the PC's QR (a code where there is no
scanner, a browser) on the relay tab; the Tailscale address field, its
QR and the Tailscale-off card; user@host and Add by address on SSH. It
opens from Add PC, with Back to My PCs, and is the front page itself,
titled Connect a PC, when the person is signed out with nothing saved.
- **`/#add`** (More → Connect a PC inside a relay PC) now shows My PCs
with Back to the PC the person came from, whose row says **In use now**
instead of its state.
- The #16 one-line front page is folded into My PCs: with no PC on, the
same list with its rows saying Off under "No PC is online" and Check
again (the launch's own retry, or the sign-in's when nothing is saved
here); with no PC in the account yet, the empty list saying "Sign in
with the same account on the PC where Ovis runs" over Add PC. Its "Other
ways to connect" goes with it.
- A row says first what this device knows itself (a pairing's saved Ovis
too old, then a check that found it off or on), then the account's word.
Forget sits in a column of its own beside the row's open link.
- Add PC over My PCs has an entry of its own in the history: the phone's
or browser's Back returns to My PCs, and the focus moves to Add PC's
title and back.
- **Needs approval** is no longer shown as a PC's state on these views:
an account PC this phone is not let into yet says On or Off like any
other, and tapping it leads to the same wait-for-approval screen as
before.

Unchanged: the join, wait, declined and removed screens (the plain wait
a sign-in's launch puts up on a PC's own page), sign-in, the PC's own
pages, the desktop/Mac `ConnectPhoneDialog`, and the phone app's own
pages. In the phone app, More → Connect a PC on a PC opened by Tailscale
or SSH still goes to the app's own screen (`addPcExit`, part 2 changes
that). A relay with no account service keeps its plain list of pairings
as the front page; with nothing saved it opens on the tabs instead of
the old tab-less screen.

The layout follows the mockup the owner approved (one list, Add pinned
at the bottom), as the Claude app keeps New chat within reach over its
list of chats; no pixels copied.

## Known limits

- Reloading `/#add` loses the In use now mark and its Back target (the
page before this PR had the same reload limit for its Back).
- One PC saved under several routes (relay and a Tailscale name, say)
shows as several rows: grouping them needs a verified PC id per saved
route.

## Removed

- `RelayAddPc` (the tab-less `/#add` screen) and `SavedPcs`; its helpers
(`Way`, `AddressForm`, `scanQr`, `sshHandoff`, `useAddressOpen`,
`addressOf`, `publicHttp`) stay and the tabs use them.
- `ScanQrStep` and the signed-out branches of `RelayShellCardContent`
that drew the old front pages.
- The per-tab "PCs this phone is on" lists, the #16 front page's own
layout (PcApprovalWait's account menu and Other ways to connect), and
the strings "PCs this phone is on", "Enter an address" and "Other ways
to connect".

## Evidence

Before/after captures at 390 px (light, Korean; plus 360, 768 and 1280)
were shown to the owner: signed out, signed in with 2 PCs, 7 PCs of
mixed ways (the list scrolls, Add PC stays), Add a PC on each tab,
`/#add` from inside a PC (In use now), and the browser without a
scanner. They come from a fixture with made-up PCs, no real account.

## Validation

- `bun run check fast` on the head (1933b56): workflow syntax,
generated types and themes, typecheck, build, unit tests (1149 files,
23,265 pass, 0 fail).
- Browser regressions that walk these screens, in the CI runner image on
the head (`bun run build:shell` and the app build first, each through
`bun run check run`): `add-pc-more-relay-regression.ts` pass (now also:
a row's chevron and middle hit the open link, never Forget, at both
densities; Back from Add PC lands on My PCs with the focus);
`relay-shell-browser-qa.ts` pass;
`relay-second-device-join-regression.ts` pass (6 cases);
`relay-offline-reasons-regression.ts` pass (5 cases);
`relay-join-browser-qa.ts` pass (16 cases).
- `HERDR_TEST_SHARDS=4 bun run check integration` on this PC (on
fb4f22e; later commits change `src/` and browser scripts only): 2,287
pass, 6 fail, 113 skip in 151 files. The 6 are
`server/machine-profile.contract.test.ts` (4) and
`server/reattach.contract.test.ts` (2): neither imports `src/`, both
fail the same way on a clean `origin/main` on this PC, and both pass in
the CI runner image (108 pass, 0 fail).
- `scripts/acceptance/first-run.ts` (not in CI): its list steps are
tightened, but in the image it stops at `phone.pairs` (4 pass, 2 fail, 9
blocked) exactly as `origin/main` does, so those steps did not run.
- The adversarial review's 12 findings and what became of each are in a
comment on this PR.
- Skipped: the whole browser lane (`check browser`), native Windows and
macOS, and device QA on Android or iOS.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
devswha added a commit that referenced this pull request Nov 23, 2026
… key (#4531)

## What changed

For the 24 hours after a PC joins the account in one press (`new_until`
on its directory entry), a device of the account that is not paired with
it now gets in on the person's press the same way it gets into any other
PC of the account. The press on that PC's join sheet (**Ask to join**,
on the PC's own page, where a tap on its row in My PCs also leads) first
signs in with this device's registered account key. Only when that is
refused or cannot be tried does the same press send the join request it
sends today, with no second press.

The decision behind it, in plain words: a press is enough. During the 24
hours nothing opens the new PC without that press: its page load still
puts up the sheet first, a launch still never opens it (it puts up the
sheet, or asks to join it, below), and a reload never opens it by
itself. The **New PC** mark, the **I didn't add this** notice and every
other 24-hour behaviour (nothing in the app is selected by itself on
that PC) stay as they are.

## Why

Before this, nothing ever used the account key for such a PC. Its page
skipped the account sign-in for a new PC (`openUnpaired`:
`!isNewAccountPc(...)`), and the sheet's press only ever sent a join
request (PAIR with intent `account`). On a PC with no paired member,
that join is a first join, which only the PC's own window can Allow. So
a PC with no screen added by `ovis add` (#4514), by the Mac app's add
over SSH, or by one press could not be opened by any device for 24
hours. Yet the PC had already admitted the account's eligible devices
from the account's list, and it answers ok to their account sign-in:
`server/devices.ts:2263` `matchAccountRelay` → `listedAccess` →
`server/account/account-devices.ts:131` `access()`. Nothing on the PC
reads `new_until`, and the only hold is the usual 10-second join hold
that the client already waits out. On a PC with a screen, the phone said
"press Allow on the PC" while the PC already listed that phone as
"Through your account".

## The condition, before and after

Before:
- Page load (`openUnpaired`): the account sign-in when `join &&
accountOpen && openKey !== null && !isNewAccountPc(pc) &&
!launchJoinFor(pc)`, otherwise the join sheet.
- Sheet press (`confirmed` → `pair()`): always the join request.

After:
- Launch with nothing saved to open (`showFront`, `shell.tsx:507`): when
the account's PC it picks is inside its 24 hours and this device may
sign in to it by the account key (the same `accountOpenOf` guards), it
puts up that PC's sheet and asks nothing: no `keepConfirmedPc`, no
launch card. One press there opens it by the account key. A new PC
without that way in, and any PC that is not new, keep the launch's join
asked at once, as before.
- Page load: unchanged. It uses the same condition, now built by
`accountOpenOf(pc)` plus `!isNewAccountPc(pc)`
(`src/lib/relay/shell.tsx:1266`).
- Sheet press (`src/lib/relay/shell.tsx:1064`, `pressedAccountOpen`):
the account sign-in, marked `pressed`, when the account's row for this
PC is inside its 24 hours (`isNewAccountPc`, an unreadable window
included) and `join && accountOpen && openKey !== null &&
!launchJoinFor(pc)` hold. Those are the same guards a load uses. In
every other case it sends the join request as before: every PC that is
not new, a fresh never-seen PC (the "new" sheet), a new PC with no key
registered here, and a page whose read of the account failed or was not
answered.
- The sheet starts a fresh read of the account's PCs as it comes up
(`arrived()`, unchanged), and that read blanks the rows until it is
back. A press made during it now waits for it (`shell.tsx:1066`, the
existing `readAgain`, bounded by `ACCOUNT_READ_WAIT_MS`) before
choosing, so a quick tap on a new PC is not sent as a join only because
its row was not back yet. For a PC that is not new, a press in that
window gets the same join as before, at most that long later.
- A refusal of the pressed sign-in goes through the existing handling in
`failed()`:
- `not_listed` gets one retry, then the join. `admission` and a PC
without the account's way in (`AccountOpenUnsupportedError`) get the
join. `held` waits and retries (JoinWait), and a frozen hold waits. All
of this is unchanged from a load.
- New for `pressed` only, in the existing "pair" step: `keepConfirmedPc`
before the existing `joinPc` fallback (`shell.tsx:699`). The sheet that
follows then sends the join at once. This is the same one-navigation
consent that a launch's join and a typed-code match already use, so the
person is not asked to press twice.
- New for `pressed` only (`shell.tsx:690`): `auth_failed` goes to that
same "pair" step. A PC answers a key it does not list (not eligible, the
account service's own rule for a new sign-in method, removed) with a
bare `auth_failed`, not `not_listed`: `server/devices.ts:2267` returns
null for a missing row, and `server/relay/session.ts:433`/`:715` close
with `auth_failed`. `server/account/one-press.contract.test.ts` checks
this for a "stranger" key. Without this mapping the existing handling
would show "removed" and mark the PC removed on this device
(`src/lib/relay/shellState.ts:185` → `revoked` → `markRemovedPc`). That
would be a regression from today's join for exactly the device that is
not on the PC's list.
- Any other failure (the PC off, the relay unreachable,
`account_unreachable`, `account_readd_required`, `auth_revoked`) shows
its failure screen. Its Try again tries the account way again, as after
a load.

## Every caller changed

- `src/lib/relay/shell.tsx` `confirmed()`, the sheet's `onPair`:
`pressedAccountOpen`, otherwise `pair()` as before, after the account
read the sheet started when one is still running.
- `src/lib/relay/shell.tsx` `showFront`, the account launch: the branch
above, for a new PC with the account way in.
- `src/lib/relay/shell.tsx` `openUnpaired`: the same condition, moved
into `accountOpenOf` (no behaviour change); its comment now says what
really happens.
- `src/lib/relay/shell.tsx` `failed()`: the two `pressed`-only additions
above.
- `src/lib/relay/shellState.ts`: `Attempt.pressed`.
- Not changed: `accountOpenablePcs` in `pcPick.ts` (a launch still never
opens a new PC), `accountLaunchPcs` and its order, `arrived()`, the
sheet component and its words, the New PC notices, and the in-app hold
of a new PC (`enterApp` → `setPcNewness`).

## Why this is no weaker than today

The join request this replaces on a press is approved by the new PC
itself: on a first join only its own window can approve, and on a PC
with members a member or the PC can. A PC someone else slipped into the
account would simply approve it. The join only adds friction for honest
PCs: the person walks to a PC with a screen, and a PC with no screen
cannot be opened at all. What protects the person is unchanged: nothing
opens the new PC without their press (page load, reload and launch are
each covered by a test), the New PC mark, and **I didn't add this**,
which removes the listing. The PC checks that listing with the account
service before it grants a new account-only session (docs/account.md,
"In one press"), so after a removal the account way is refused within a
minute.

What this lets in: only a device of the same account whose key that PC
already admitted from the account's list. The PC's account rows are per
account, so no device of another account gets in. No device that the
PC's own checks refuse gets in either: a hold makes the device wait, and
freezes, removal evidence and tombstones leave its row out
(`accountRowStale`), so it gets `auth_failed` and then the same join it
would have got before.

One correction to the reasoning as first stated: the join does not add
friction "only on PCs with no screen". It adds a walk to every honest PC
with a screen too. On a PC with no screen it blocks the person
completely.

## A removed device, and one fallback per press

- A device the PC really removed is not turned into a silent re-join.
Its account sign-in gets `auth_failed`, because its row is left out
(`accountRowStale`: tombstones, removal evidence, freezes). The fallback
then sends only the join request the press sent before this change, and
the PC judges it as any other join. A key the account removed is refused
whoever approves it (`server/devices.ts:983`, `admissionAllowed` →
`removedByAccount`). A key the PC revoked is refused for any member's
approval (`server/devices.ts:984` and `:2725`), and it comes back only
when a person approves it on the PC's own window with the digits, as
before. Nothing on this device changes the removed mark: it stays until
the PC actually lets the device in.
- The fallback happens once per press, never in a loop. The flow is
account sign-in, then `auth_failed`, then one join request, which the PC
turns down; after that nothing tries the account way or the join again
by itself. The one-navigation mark that sends the join is taken by that
join's own page. A reload sends nothing and asks for the press again.
Try again on the join's failure screen is a new press, and it sends the
join again (the attempt it retries), as before.
- Pinned by `a device its new PC removed gets only the join a press sent
before, once …` in `shellAccountOpen.test.tsx`. The test runs on the
same document, as in a browser. The account way gets `auth_failed`, then
one join goes up for approval and the PC declines it. After 30 minutes
of fake time there are exactly two attempts (account, join), one
approval prompt, no app, the removed mark is still there, and a reload
sends nothing. A mutation that makes the join's page try the account way
again fails this test.

## What is still refused

- A launch never signs in to a new PC by the account key. It puts up the
sheet, which waits for the press (or, with no account way in, asks to
join, as before).
- A load or a reload of a new PC's page never signs in. It puts up the
sheet.
- With no key registered here, or a PC that does not list the key, no
longer admits it, or predates the account way in, the press sends the
join, which the PC decides as today.
- The account service's own 24-hour rule for a new sign-in method stays.
Such a device is not on the PC's list and gets the join.

## Words on screen

Unchanged. The sheet keeps **Add this device to {name}** with **Ask to
join**, and those words fit both outcomes: the press asks, and a PC that
already let this device in through the account answers at once and
opens. Otherwise the existing **Approve it on {name}** screen with the
number follows. While the account sign-in runs, the sheet shows its
connecting step, whose first line already reads "Ask to join: Through
your account, with this device's key". The sheet does not say, today or
after this change, when or by which sign-in the PC was added; the in-app
notice with **I didn't add this** does. No screenshots, since nothing
drawn changed.

## Validation

- Red first, in `src/lib/relay/shellAccountOpen.test.tsx`: 9 new or
changed tests failed on main's code and pass now. They cover: a new PC's
page load and reload open nothing, and its press tries the account key
and opens on ok; `not_listed` (twice), `admission`, `auth_failed`
(direct and over the wire) and a PC without the way in each send the
join with no second press and mark nothing removed; a hold is waited out
and then the PC opens. Three more pin behaviour that stays, and passed
before and after: a launch's join card for a new PC asks by a join only;
with no registered key the press sends the join; a PC past its 24 hours
whose sign-in was refused at load keeps the press as the join alone.
Added after the review: the three tests named under Review (LOW 1, LOW
2, LOW 3), each checked against a mutation that breaks it. Added before
it: the removed-device / once-per-press test above, and a press made
while the sheet's read of the account's PCs is still out (it waits, then
signs in by the account key). Each of these two was checked against a
mutation that breaks it (the join's page trying the account way again;
no wait for the read): both fail. Those tests drive the same document
the way a browser does, with a fragment change on the page that put the
sheet up (`land`). The A3 test still loads the sheet as a fresh page.
- `dori heavy newpc -- bun run check fast`: green on the final tree
(typecheck, build, 24404 unit tests), as on each earlier push.
- `bun test` on `src/lib/relay/shell*.test.*`,
`src/components/RelayShell.test.tsx` and
`src/components/AddPcSheet.test.tsx`: green.
- Browser, in the CI runner image (`herdr-ci-runner:local`, from a git
bundle of this branch): `relay-second-device-join-regression.ts` (drives
the join sheet from a PC's own page), `relay-first-link-regression.ts`
and `relay-shell-browser-qa.ts` (press the confirm and the new-PC sheet)
pass on the final source, as on each earlier push. None of them drives a
PC inside its 24 hours, and no browser script does.
- Skipped: the integration suite and native Windows (no server, shared
or Windows code changed), and screenshots (no words changed).

## Review

An independent review found no HIGH. Each finding and how it was
resolved:

- MEDIUM: a press made during the account read that the sheet starts
found no row and sent the old join. Fixed in 9937f28, which the
reviewer read and agreed with: the press waits for that read (the
existing `readAgain`, bounded). Pinned by "a press made while the
sheet's page still reads the account's PCs waits for them …"; a mutation
without the wait fails it.
- LOW 1: the `attempt.pressed === true &&` guard on the `auth_failed`
mapping (`shell.tsx:690`) had no test. Mapping every account sign-in's
`auth_failed` to the join passed every shell test. Added "a PC past its
24 hours that answers its page's account sign-in with auth_failed says
this device was removed, as before …": a load's sign-in ends on
`revoked` with the removed mark and no join. The same mutation fails it
now.
- LOW 2: after a successful open, `enrolled` (`shell.tsx:875`) drops
`pressed`, which was unpinned. With `pressed` kept, a later
`auth_failed` on the open session would quietly go to a join instead of
"removed". Added "a new PC opened by the press that later ends its
session with auth_failed says this device was removed …": `revoked`, the
removed mark, no join. Keeping `pressed` in `enrolled` fails it.
- LOW 3: after a press opened a new PC with no screen, `rememberPc`
(`shell.tsx:924`) made it the PC opened last. `accountLaunchPcs` then
asked it first, and when nothing else could be opened, every launch
during its 24 hours sent a first join by itself that only the PC's own
window could allow. Fixed here: for a new PC with the account way in and
a key here, a launch puts up its sheet and sends nothing, so one press
opens it by the account key. A new PC without that way in keeps the
launch's join. Pinned by "puts up the sheet of a new PC this device may
sign in to by the account's key and asks it nothing; one press there
opens it by that key" in `shell.test.tsx`. That test checks: the launch
sends nothing and leaves no confirmed or launch-card mark, the PC's page
shows the sheet and sends nothing, and the press opens it by the account
key. Making the launch ask the join again fails it. "A launch never
opens a new PC by itself" stays pinned by the existing "C3: a launch
never opens an account-only PC when it is inside its new window / its
new window does not parse". The existing "#16: asks to join a PC new in
the account after a sign-in too, at once" still passes for a sign-in
with no registered key.
- LOW 4: known limit, below.

## Known limits

- When the PC runs a newer Ovis than the shell, the first open of a
pressed sign-in reloads the page once
(`src/lib/relay/updateFlow.ts:130`, `reloadOnce`). The reloaded page is
the new PC's own page, which puts the sheet up again, so the person
presses twice. The second press opens it, since the reload happens once
per version.

- For a PC that is not new, an account sign-in made by its page load and
refused with `auth_failed` (a key the PC does not list) still shows
"removed" and marks the PC removed, as before this change. Only the
pressed sign-in maps it to the join. That is left for its own change.
- When the account way is refused on a new PC with no screen and no
member, the join that follows is still a first join that only the PC's
own window (or `ovis approve`, another PR) can allow.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus <[email protected]>
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.

2 participants