1. Off a runtime, a change's hooks save inline. A save under way holds
the persister's write lock and waits in its export for the doc's
change lock, which the change holds while its hooks run: the inline
save no longer waits for it (it does nothing; the save under way takes
the change in, and the chat stays marked for the next). Same for an
inline request_flush. Test: an_inline_save_from_a_changes_hooks_never_
waits_for_a_save_under_way (deadlocks and times out with the old wait).
2. The client's ViewerSink::relay_export goes through SessionDoc::export
(an export commits what's pending; its events under the change lock).
3. The import marker is per doc: a read of another doc during an import
still asks Loro for that doc's pending changes. (Its uncommitted
changes also move its version, so the cache's version check already
read it whole; the test documents both.)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: zeronsh[bot] <346184242+zeronsh[bot]@users.noreply.github.com>
Second-pass review: Loro delivers a LOCAL commit's events after releasing
its own lock, so an import could land in between (measured: the import
shows in reads ~7 ms before its events arrive), and the version the
commit's callback recorded covered the import with only the commit's
entries: a read in that gap trusted a stale cache.
SessionDoc now holds a change lock (reentrant) through every commit and
import and the delivery of its events: all SessionDoc writes commit
through SessionDoc::commit, and the engine's room/relay imports and the
client's room imports go through SessionDoc::import*. A read takes the
lock only to capture the version and the changes recorded up to it.
On a thread inside an import, Loro holds its transaction lock until the
import's events are delivered; a read there skips asking for pending
changes (it would wait on that lock; none can be pending).
The kept bytes are atomics, so the engine's eviction weighs a chat
without waiting on its cache. The app's order check leaves out rows
without an id, as `known` does.
Test: a_read_between_an_overlapping_import_and_its_events_is_whole (a
probe starts the import while the commit's events are delivered and reads
from another thread in the gap): passes; without the change lock it gets
a stale read and fails.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: zeronsh[bot] <346184242+zeronsh[bot]@users.noreply.github.com>
One old app anywhere on an account kept every chat on stored rows, and a rollout
had to wait out a 14-day window to see them all. A chat now goes to generation 3
whatever else is on the account. Old clients read that as a chat2 room as they
always have, and when one opens a chat the room tells its host, which stores for
as long as it's there. So storage is paid per chat, only while an old client has
that chat open.
With nothing left to gate, the rollout has one control: CHAT_RELAY_LAYER on the
edge, for everyone or a list of user ids. Engines run the layer by default and
follow the room's answer, with ZERON_RELAY_LAYER=0 as a kill switch. Gone: the
registry's list of old clients, the account-wide rule, and CLOUD_RELAY_LAYER.
The smoke test proves it against shipped v0.2.138, v0.2.137 and v0.2.116.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Other tests in the binary dial in parallel, and each success cuts an upload's
backoff short on purpose; CI saw 12 uploads against a bound of 10. A hot loop
makes thousands, so the bound is 50.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The desktop sidebar's Activity (PR #1262) on iPhone and iPad: one list
of the chats that need you, the one back last at the top, Pinned above,
and Working, Asleep and Archived folded at its foot. Turned on from the
Sessions "…" menu (with a link to Settings → Activity) or Settings; off
by default, and off the page is as it was.
- Engine truth through the core: rows carry the sleep state
(Chat::sleep_state) and whether a Waiting chat waits on a process;
the FFI's ChatIndicator gains Waiting (drawn exactly as Working).
CoreClient.sleepSession writes Chat.sleep (synced per field);
stopWaiting asks the chat's host (StopWaiting).
- Sleep from a swipe or the long-press menu: In 1 Hour, In 3 Hours,
This Evening, Tomorrow, Next Week (each saying when), or Custom… with
the system date picker. Asleep rows say when they wake; Wake from the
same places. Woke rows ring the alarm glyph until seen.
- Settings → Activity: the view, folding working chats into Working, a
note on Sleep, and auto-archive of idle chats (as the desktop's sweep).
Group by Project and New Section stand aside while it's on.
- Demo: one chat asleep, one woken, one waiting on a process.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: zeronsh[bot] <346184242+zeronsh[bot]@users.noreply.github.com>
The room's checkpoint upload now takes parts (main) and applies the relay
layer's rules (stale refusal, floor coverage, heal) to both the whole and
the staged commit, before reading the body.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The session list carries storeRecoveredAt (older edges omit it). The shared
core reads it for each Cloud machine, shows it on the chat's snapshot
(restored_at_ms, also on the mobile TranscriptStatus) for a week, and
dismiss_restored_note hides it for every chat on that machine until it
rebuilds again, kept across launches. Opening a Cloud chat reads the list at
most every five minutes so the note can show without a send.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Twice on staging a resume sat at the provider for minutes (4 min 46 s here;
7 to 11 min in provisioning earlier) while the user saw only the usual
"waking". Machine-ready times otherwise: p50 about 10 s, slowest of 179
staging wakes 27 s.
- Past 45 s without reaching ready (CLOUD_WAKE_SLOW_SECONDS), the wake reads
stage "slow", and a resume stuck in provisioning is stopped and resumed
again, up to twice, before the slow poll that was there already.
- A machine that is up but whose engine hasn't been heard from past the same
mark also reads "slow" until it is; the restart at a minute and a half is
unchanged.
- The stage clears as soon as the engine talks. The ledger records wake_slow
with what it was stuck on, and the wake's timeline adds slow, kicked,
slowReason and kicks.
- The apps say it plainly: desktop's waiting line and the shared core's setup
step (iOS, Android) read "Waking the (Cloud) machine is taking longer than
usual", and the send isn't called late meanwhile.
Tested with the fake Boat's new stallResumes (a resume stuck until a stop).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Acknowledging a send flushed the doc while the chat client held its lock. An
export can commit a pending transaction, whose local-update hook queues a push,
which takes that lock again. The flush and the outbox retirement now run off
that call, and the row stays until a save holds it.
- A relayed update for a doc that's gone counts as unreadable, not read.
- A relayed update that arrives ahead of its history is journaled apart, replayed
on load, and retired once nothing is waiting, as the engine does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A watch parked on a host without presence woke only on a presence beat. A
registry join or the periodic tick also copy presence in, and on a cold launch or
a return from the background either can be the first to show the host up, so the
watch could wait for good with its host there. All three now wake it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The mobile core never read a session's stage. While one of the phone's sends
waits on a Cloud machine, it now reads the session list every 5 seconds, and
for a minute after the machine last read as starting, waking or updating;
nothing waiting, nothing read. Any read of the list counts, a screen's too.
The setup step under the waiting message, which said "Waking the machine"
until the machine's heartbeat came back, now says "Updating the machine"
while it installs a release, and the send doesn't fail for its age
meanwhile. iOS and Android draw that step as they are.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The desktop transcript now shows Remove beside Retry on a failed send, and
beside "Sending..." while a send's files upload. It calls RemoveHeldSend and
takes the message out of view at once.
The lifecycle rule for stored files goes to 30 days, so a queued message on a
machine asleep for weeks still finds its files. If one has aged out anyway, a
Cloud machine past the 15-minute cap now takes the row out of its queue and
leaves it as its sender's failed message, with a retry that uploads the files
again. Before, the row waited for them forever.
A phone keeps each file it sent through the store until that message is in the
transcript, for queued rows as well as runs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A failed send nobody retried was deleted after a week, and a send that couldn't
upload for a week stopped trying. Now the outbox never gives up on its own: it
backs off to every 15 minutes after a week, and a failed send stays until it's
retried or removed.
RemoveHeldSend {chatId, id} takes a send out of the outbox, failed or still
uploading. It never goes out after that, even mid-upload, and its stored copies
are deleted. On mobile, PendingSend.removable marks those rows and
SessionHandle::remove_send does the same.
Every try uploads all of a send's files again, so none ages out at the edge
while it's alive. A phone now keeps its copy until the message has run, so a
retry after expiry uploads it again.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A reply whose host stopped reporting kept its working word ("Conjuring…")
for ever: zgx showed it for any reply still marked streaming, and a host that
dies never finishes one. It now shows only while the session's turn is heard
from and its host is there; otherwise the foot says why (its Cloud machine
asleep, failed, can't wake, files gone, or "Resuming" while it wakes; "can't
reach <computer>" for another computer gone quiet; "Interrupted"). This applies
to every host, not just Cloud (screens/chat/turn_state, pure).
A Cloud chat's model chip read "Choose…": the engine answered a Cloud target's
ListModels from this computer's own model discovery, which fails where Codex or
Claude Code isn't installed or signed in here. It now answers from the edge's
Cloud catalog (GET /cloud/{org}/models, as the phone reads it), the last list
kept on disk, then the local catalog. zgx keeps a Cloud chat's own agent listed
even when Cloud has no account for it, and the shared client knows a Cloud
device's agents without dialling its machine.
Sends to a machine that can't wake, or whose files are gone, are held: kept
across launches, shown in the deck's queue (only Remove), said in the alert's
line, and sent once a size or a fresh machine is picked. One held past an hour
doesn't go on its own: a deck alert says so and its row sends it. The engine's
WatchWaitingMessages (#1256; absent on older engines) feeds the same notice for
messages queued long ago that a waking machine will run, leaving out those past
their expiry, and its upload failures (the store's quota) show as an alert with
Try again.
Settings → Cloud's default machine is on the alert's grid (ds/grid, shared).
A sleeping machine's notice is quiet (a deck alert raising no pill of its own)
until there's something to send.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A chat on Cloud only ever said "Can't reach {host}", even of a machine asleep
or one that could never wake, and a machine that filled its disk just died.
The composer's deck now says its machine's state as a notice (asleep with Wake,
waking and how far), and one alert at a time: can't wake (it needs N GB, opening
to every size), failed with the real reason, disk filling (dismissable until the
level worsens), files going soon, and files gone (a fresh machine on the same
repository and branch). Nothing opens itself: each waits in the pill. Settings ->
Cloud picks the size new chats start on.
The sizes are a grid under the alert, one set of column lines for every row: name,
vCPU, memory, disk, credit rate, then a trailing slot with the pick, why it's out
of reach, or Current. Short of room the columns go from every row at once, memory
first and disk last. An alert alone in the deck leaves its glyph to the tab's; with
others, or still working, it keeps its own.
The deck gains that much as data (an alert's body, note, choices and grid); what's
said and offered is pure functions (screens/chat/cloud_machine) over the sessions
account/cloud reads, and screens/chat/cloud_tray's bind draws nothing. Sessions are
read every 60 s (3 s while one settles), and a read that changed nothing sets
nothing, so nothing redraws at rest.
The wire types and engine client are zeron/cloud-durable's own text, so the two
merge in either order. Zeron v2's composers get the same wiring.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The edge now limits what one user has stored and not yet collected by a Cloud
machine: 1 GiB and 500 files by default, set with ATTACHMENT_QUOTA_BYTES and
ATTACHMENT_QUOTA_OBJECTS. An upload past either gets 507, and the message shows
as failed in its chat with a retry. Collected, deleted and expired files free
their space.
A message to a Cloud-hosted chat now expires after 7 days instead of 1, so it
still runs once its machine comes back from days asleep. Other chats keep their
day. The outbox retries for the same week, and the lifecycle rule for stored
files becomes 14 days.
WatchWaitingMessages lists a chat's messages not yet taken by its agent, with
when each was sent and when it expires, so the composer can say an old one is
about to send.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On the iPhone the first NWPathMonitor report reached the core 111 to 275 ms
after the client started (11 launches). An offline launch at 275 ms ran out
the 250 ms patience and still made 18 refused dials and pulls. The report
releases the gate the moment it arrives, so the patience only bounds a
platform that never reports.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: zeronsh[bot] <346184242+zeronsh[bot]@users.noreply.github.com>
The client starts its registry, its warm rooms and the signaling socket the
moment it's built, but the platform's first path report (NWPathMonitor on
iOS) lands a moment later. Launched with no network, a real iPhone made 22
refused dials and pulls in those 120 ms before the report parked them.
Each connect now waits on a PathGate: the platform's first report, or 250 ms
if none comes. While the report says offline it waits for the network to come
back, with a 30 s safety timer so a wrong monitor can't silence the app. The
first report releases the gate whatever it says. The registry join, each
room's join and the signaling start all wait on it.
An online launch reported at once dials in about 8 ms in the test, and a
platform that never reports dials after about 256 ms. The offline-launch test
fails without the change (4 connections) and passes with it (0). The mock edge
counts client connections, leaving out the preview's localhost discovery
probe.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: zeronsh[bot] <346184242+zeronsh[bot]@users.noreply.github.com>
Android can leave a backgrounded process running for hours where iOS suspends it, and
each open socket's keepalive wakes the radio. Once delivery has had its time, the app
tells the core, and every socket closes and stays down until the next foreground, with
no polling or timed retries. Outboxes hold their rows and the version exchange catches
up on return. iOS doesn't call this.
A socket on an old path can die without saying so, so a path change now asks the rooms
and the registry instead of waiting for their next quiet probe.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: zeronsh[bot] <346184242+zeronsh[bot]@users.noreply.github.com>
Turns it on, says why an empty transcript is empty, and stops a stale turn reading as
running. Reports the network the way the core expects: its state at launch (Android says
nothing with no network), a move between networks, and being cut off in Doze while the
network stays up. Adds the rig's launch extras for debuggable builds.
Android 17 keeps an app that targets it off the local network without a permission, and
a direct connection on the same Wi-Fi fails silently, so the system prompt is asked once,
the first time a link could be used.
A backgrounded phone stops sending presence: Android can leave the process running for
hours where iOS suspends it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: zeronsh[bot] <346184242+zeronsh[bot]@users.noreply.github.com>
The owner parked peer-to-peer. A phone no longer opens a direct link to a
chat's host: the room carries every frame, catch-up and send. The link task,
LinkWanted and its idle clock are gone from crates/client, so nothing on a
phone pairs, holds a WebRTC connection, or sends STUN keepalives for a chat.
Terminals keep their own direct path, as on main.
The parked link and its pacing are on zeron/relay-mobile-direct-link.
relay-mobile.md says so up top and its behaviour tables describe the room
path. The room test keeps its route checks, minus the link.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: zeronsh[bot] <346184242+zeronsh[bot]@users.noreply.github.com>
The owner parked peer-to-peer. The pacing from 0a49ea3e4 (open on view, the
5-minute idle cap, the open settle, the leave grace and the fast retry after a
stable link) is kept on zeron/relay-mobile-direct-link, and this branch goes
back to the link as it was while the link itself is taken out.
This reverts commit 0a49ea3e4.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: zeronsh[bot] <346184242+zeronsh[bot]@users.noreply.github.com>
The owner's call: a link should be up by the time someone sends, so it opens
when a chat is opened and stays while it's on screen with the app in front,
for up to 5 minutes of nothing happening (LINK_IDLE, was 60 s). A send after
that brings it straight back, and the room carries the send meanwhile. A
sleeping Cloud machine reads host_online=false, so viewing never wakes one.
- A chat has to stay open 300 ms before it pairs, so flicking through chats
doesn't pair each one.
- Leaving a chat keeps its link 10 s, so going straight back reuses it. The
app going to the background, or the network, the host or the relay
generation going, still ends it at once.
- A link that lived a minute and then dropped retries after 1 s instead of
15 s. On a real iPhone the room carried 16 s of stream after each clean
close.
The room now hands the link task the whole LinkWanted, so the task can tell
leaving a chat from going to the background. Showing a chat never waits on
any of this: the link runs on its own task.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: zeronsh[bot] <346184242+zeronsh[bot]@users.noreply.github.com>
Brings the direct-link fixes in crates/preview to the phone: signaling
reconnects keep open connections, `gone` keeps the pairing pace, and private
LAN candidates are skipped when the public addresses differ.
relay.rs: both sides changed the PR-status watch. Kept the presence gate from
this branch and the 2-minute cap and next_watch_retry from relay-layer.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: zeronsh[bot] <346184242+zeronsh[bot]@users.noreply.github.com>
Every top-level chat with a branch keeps a WatchCheckoutChangeRequest on its
host while the app is in front, whether the chat is on screen or not. With the
host offline, each watch dialed its device room every 0.5 to 5 s: the room
answers host_offline after accepting the socket, so the dial cooldown never
applied, and the dark-peer gate only starts 60 s after launch and 5 minutes
after a host's last beat. A real iPhone showed a dial every 2 to 6 s to one
offline machine for the first minute after launch; a phone with several chats
on hosts that just went offline dials for 5 minutes each.
A watch now reads presence before it dials. A host that isn't fresh parks the
watch with no traffic until a beat says it's back, and then it dials at once.
A host that beats but doesn't answer is retried from 0.5 s up to 60 s. The
last status stays in the workspace through all of it, so a chat on an offline
host keeps showing its PR. presence_changed stores the new presence before it
wakes anything, so a woken watch reads it.
main has the same behaviour: relay.rs and the watch reconcile are unchanged
from it. The test fails without the fix with "dialed a host with no presence".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: zeronsh[bot] <346184242+zeronsh[bot]@users.noreply.github.com>
Each watch retried every 5 s at most, forever. With a few chats on an offline host
that kept a phone's radio up. Now it backs off to 2 minutes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A release ships ahead of any edge flag. This runs the real client against a real edge
with the flag off, or from before the layer: a send is a stored row, as ever.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An idle host may still be opening the chat its wake asked for. A few quick retries get
the link up in seconds, where waiting out the pairing curve took 15 s or more.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With no path or no host, a streaming tail is only a copy of what was. "Writing…" and
its clock went on for as long as the host stayed away, with a stop button that would
have waited in the doc for a later turn.
Also: the engine logs a chat link it accepts, which is how a rig sees a phone's link,
and relay_rig gives each chat a folder of its own.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The app runs the relay layer, and an empty transcript says why it's empty, with the
desktop's strings. A send waiting on a path or a host no longer ages into "Not
delivered". Debug arguments let a rig play an old phone, a phone with no network, and
a send from outside.
relay_rig drives a headless engine while a phone is tested against it, and
docs/design/relay-mobile.md is the handoff for Android.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
crates/client joins relay rooms when asked to: it says so to the registry and each
room, reads live frames, catches up from the host by version exchange, sends through
the outbox into the room's queue, and reads a Cloud machine's checkpoint. What came
by relay is journaled until a save holds it, so a kill loses nothing, and any chat
loaded before opens with no network and no host.
A chat on screen and doing something gets a direct link over the WebRTC stack
terminals use, and gives it and its connection up when it stops. A checkpoint a chat
off screen lacks waits until someone looks. The bootstrap pull and the socket share
one download, and a parked row doesn't read a checkpoint this doc already holds.
An empty transcript says why: syncing, offline, or that the chat lives on another
device. Off by default in zeron-client, and off, every byte is what shipped phones send.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>