Repository navigation
Load older messages and remove a queued message in a paired Mac's Bot chat - #910
sambitcreate wants to merge 20 commits into
Conversation
…Bot chat Remote revision 67 (provisional) adds two Bot session routes: a page of entries older than one the device holds, projected like its session, and a withdraw for one of the person's queued messages (bot:activity holders; a routine's input or the self-intro reads as gone). No feature tokens, as the server list is full: the desktop treats a 404 as an older host. The remote Bot chat shows Load older messages while the session has older entries, keeps loaded pages across a reconnect of the same epoch, and gives queued rows the same Remove as a local chat. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018VA6REg8PpdXdPfTkkCKZJ
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018VA6REg8PpdXdPfTkkCKZJ
There was a problem hiding this comment.
Important
The new routes need stronger ownership and pagination fencing before merge; the current implementation can withdraw non-person work or leave remote history stale/unreachable.
Reviewed changes across the complete initial diff for the Remote Bot transcript paging and queued-message withdrawal feature.
- Remote protocol and host adds revision 67 page/withdraw DTOs, OpenAPI routes, grant checks, projector paging, runtime withdrawal, and idempotent receipts.
- Peer bridge and renderer adds validated peer operations, forward-compatible page parsing, follower paging state, same-epoch page retention, and Load older/Remove controls with old-host fallbacks.
- Cross-platform contracts and docs advances the shared fixture revision for iOS and Android and documents the new desktop-only behavior and compatibility contract.
@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏
…hread-awyxuf-pr3b # Conflicts: # docs/aiden-on-the-go-remote-access.md # renderer/main/remote-bot-chat-view.test.tsx
There was a problem hiding this comment.
Important
No new issues were introduced by this merge delta. The three required findings from the prior Pullfrog review remain unchanged and open.
Reviewed changes since the prior Pullfrog review, covering the updated stacked base and its interaction with this PR's Bot session paging.
- Merged the updated stacked base — incorporated the latest remote Bot behavior and documentation into the feature branch without changing the previously reviewed paging or withdrawal paths.
- Hardened remote unread tracking — moved remote Bot seen state fully into the host clock domain and now clears a dot only when the session view displays the feed's latest reply.
- Extended behavioral coverage — verified that an older session snapshot keeps a newer feed reply unread, while a displayed reply clears it.
@v0 or keep the SHA fresh with Dependabot | Fix it ➔ | View workflow run | Using GPT Sol | 𝕏
…hread-awyxuf-pr3b
…with the abort - Taking back a queued message checks whose message it is inside the Bot's lane, with the abort, so a request racing a routine's send never takes the routine's input. - A same-epoch snapshot can mean the host removed or reordered entries, so older pages kept across it are read again and replaced (or dropped if that fails), and a page asked for before a snapshot is never placed. - A page whose oldest entries this Mac can't show still moves Load older past them: the host supervisor returns the host's own oldest entry as the next cursor. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018VA6REg8PpdXdPfTkkCKZJ
There was a problem hiding this comment.
Important
Snapshot reconciliation still loses part of an already loaded transcript after enough pages have been fetched.
Reviewed changes since the prior Pullfrog review, covering the fixes for queued ownership and transcript pagination fencing.
- Serialized queued ownership — moved person-only provenance inspection into the Bot runtime's per-Bot withdrawal lane so routine and self-introduction submissions cannot be aborted by a racing remote request.
- Advanced filtered pages — preserved the host's oldest raw entry ID independently of entries this Mac can parse, allowing all-unknown pages to move pagination forward.
- Reconciled same-epoch snapshots — invalidated pages requested against an earlier shown history and re-read carried prefixes after snapshots, with one remaining boundary issue inline.
@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏
…a time A same-epoch snapshot re-read only one 200-entry page and then dropped the rest of the loaded history. Read pages until every kept entry is covered, and keep the pages read so far if a later one fails. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018VA6REg8PpdXdPfTkkCKZJ
There was a problem hiding this comment.
Important
Multi-page reconciliation is still not bounded to the carried transcript when a newer host sends entry kinds this client filters out.
Reviewed changes since the prior Pullfrog review, covering the fix for carried Bot history longer than one host page.
- Paged snapshot reconciliation — Re-read carried history in bounded pages until its visible entry count is covered, retaining completed pages when a later request fails.
- Extended behavioral coverage — Added unchanged-history, oldest-entry rewrite, and partial-failure cases for a 300-entry carried prefix.
- Updated the Remote contract guide — Documented bounded multi-page reconciliation and partial-read behavior.
@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏
Bound the re-read by the entries the host sent, read or not, so pages of entry kinds this Mac filters out can't walk it past the kept range. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018VA6REg8PpdXdPfTkkCKZJ
There was a problem hiding this comment.
Important
Raw host-entry accounting now prevents reconciliation from reading beyond the old range, but it can discard compatible messages that were already loaded when newer entry kinds are interleaved.
Reviewed changes since the prior Pullfrog review at e8c218b58, covering the forward-compatibility accounting fix for same-epoch Bot history reconciliation.
- Counted raw host entries — Added an internal
hostCountalongside the raw cursor before peer compatibility filtering removes entry kinds this Mac cannot read. - Bounded snapshot reconciliation — Switched the reread completion count from retained entries to raw host entries so unknown pages cannot walk beyond the intended boundary.
- Extended mixed-version coverage — Added peer and follower cases for mixed and all-unknown pages, including the cursor used by the next Load older request.
@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏
…n it covered Track how many host entries the loaded pages spanned (drawn or not) and re-read until the oldest kept entry, or that span if the host dropped it, so messages older than entries this Mac can't show stay after a snapshot. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018VA6REg8PpdXdPfTkkCKZJ
There was a problem hiding this comment.
Important
Snapshot reconciliation still miscounts carried history when compatibility filtering changes the snapshot boundary.
Reviewed changes since the prior Pullfrog review at 9ff30540a, covering the raw-span reconciliation fix.
- Tracked the loaded host span — Added separate visible-entry and raw-host counters so filtered page entries no longer shorten the stable-boundary reread.
- Stopped at the retained boundary — Rereads now stop at the oldest retained visible entry, falling back to the recorded raw span when that entry disappeared.
- Extended mixed-version coverage — Updated the newer-host test to preserve compatible entries across an unchanged same-epoch snapshot and bound a deletion reread.
@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏
When a same-epoch snapshot moves into the loaded range, read until the oldest kept entry and drop anything older the pages brought, so what was shown stays and nothing older is added; the span is only a bound when that entry is gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018VA6REg8PpdXdPfTkkCKZJ
There was a problem hiding this comment.
Important
The ID-anchored reread still has a finite fallback that can drop already loaded messages across a large compatibility-filtered snapshot gap.
Reviewed changes since the prior Pullfrog review at 17dd2104d, covering the follow-up for shifted mixed-version snapshot boundaries.
- Anchored reconciliation — Continued rereading until the oldest retained visible entry is found and trimmed any entries fetched beyond that anchor.
- Bounded missing-anchor fallback — Added a
span + carriedtraversal budget for cases where the host no longer has the oldest retained entry. - Extended coverage and docs — Added a shifted-boundary mixed-version case and documented trimming and fallback behavior.
@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏
When the oldest kept entry is deleted, cut the re-read back to the earliest surviving kept entry and resume Load older from it, instead of adding history the person had not loaded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018VA6REg8PpdXdPfTkkCKZJ
A newer host's unshown entries can make the gap between kept entries larger than the bounded re-read. When the bound runs out first, ask the host whether it still has the oldest kept entry, then each later one, and read on to the earliest it has, so shown messages are not dropped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018VA6REg8PpdXdPfTkkCKZJ
There was a problem hiding this comment.
Important
Same-epoch reordering can still remove a surviving loaded message during reconciliation.
Reviewed changes since the prior Pullfrog review at 805f572fc, covering the retained-boundary trim added for missing older entries.
- Trimmed missing-anchor rereads — Cut a bounded reread back to the earliest retained entry it reached and resumed Load older from that surviving entry.
- Extended deletion coverage — Verified that dropping the oldest retained entry keeps the next retained message and can still page to older host history.
- Updated the Remote contract guide — Documented the surviving-entry trim and resumed paging behavior.
@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏
The host may reorder kept entries within the same epoch, so the re-read is cut at whichever kept entry comes first in its current order rather than in the order this Mac showed them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018VA6REg8PpdXdPfTkkCKZJ
A rewrite that removed every kept entry no longer costs one request per loaded entry: after 8 gone the bounded re-read stands. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018VA6REg8PpdXdPfTkkCKZJ
There was a problem hiding this comment.
Important
Same-epoch reconciliation can still drop a surviving loaded message when a reorder moves it across a page or compatibility-filtered boundary.
Reviewed changes since the prior Pullfrog review at e8eea7698, covering the retained-anchor and host-order reconciliation repairs.
- Probed surviving anchors — Continued past the bounded reread by checking retained IDs and reading through arbitrarily large compatibility-filtered gaps.
- Selected host-order boundaries — Trimmed reread history at the first retained entry in the host's current order instead of its previous order.
- Expanded reconciliation coverage — Added shifted-gap, deletion, and reducer-level reorder cases for retained Bot history.
@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏
Reaching the oldest kept entry no longer ends a re-read while another kept entry is still unread: the host is asked about it (within the same 8-entry budget) and reading goes on to it, so a reordered entry isn't dropped. Test hosts answer operation_stale for ids they don't have, as the real host does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018VA6REg8PpdXdPfTkkCKZJ
There was a problem hiding this comment.
Important
The retained-ID probing still has a bounded case that can remove history already visible to the user.
Reviewed changes since the prior Pullfrog review at b646dab76, covering the retained-entry reconciliation follow-up.
- Bounded retained-ID probing — Added one-entry existence probes for retained entries missed by the normal reread, capped at eight per reconciliation.
- Cross-boundary rereads — Continued paging through compatibility-filtered gaps until each successfully probed retained entry is fetched.
- Behavioral documentation and coverage — Documented the probe budget and added follower cases for an all-removed prefix and a retained entry moved farther back.
@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏
After 8 questions with kept entries still unaccounted for, the loaded part is dropped and Load older starts again from the snapshot, instead of showing a partial re-read that may miss entries the host kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018VA6REg8PpdXdPfTkkCKZJ
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes since the prior Pullfrog review at 3333387c4, covering the retained-history probe-exhaustion fix.
- Reset exhausted reconciliation — Changed the eight-probe limit to discard the loaded prefix and resume from the fresh snapshot instead of publishing a partial reread with unresolved retained entries.
- Covered surviving entries beyond the budget — Added a follower case where earlier retained IDs are stale while later survivors remain beyond a large compatibility-filtered gap.
- Documented the fallback — Updated the Remote contract guide to state that unresolved loaded pages are dropped when the fixed probe budget expires.
@v0 or keep the SHA fresh with Dependabot | View workflow run | Using GPT Sol | 𝕏
|
Two failures on cfac9e5, both outside this PR's diff:
I'll rerun the failed jobs once when the run finishes. If either fails again, I'll record it in the PR description. Generated by Claude Code |
The Compose test rule runs composition coroutines on an unconfined dispatcher, so the card's Play continuation adopted its file on the IO worker that finished the download. The test's main-thread sync did not wait for it, and a disposal could land between adopt's disposed check and its owned assignment, leaving the file unreleased. That surfaced as a bare AssertionError from eventually in replacingCardReleasesOldDeliveryAndOwnsTheNextOne on CI. The test's load now hops back to the main thread, as the card does on a device, with a hop that always suspends and ignores cancellation so late delivery after disposal is still covered. App code is unchanged.
There was a problem hiding this comment.
Important
The Android test-harness follow-up introduces an unsafe continuation race that should be fixed before merging.
Reviewed changes since the prior Pullfrog review at cfac9e5cb, focused on the Android recording-ownership test follow-up.
- Moved mocked recording delivery to the main thread — Added a posted continuation handoff before the card adopts a downloaded recording.
- Recorded the hosted-test diagnosis — Documented the unconfined Compose test dispatcher race and the intended canceled late-delivery coverage.
@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏
… test Resuming the raw continuation from a main-thread post could run it before the download thread had returned COROUTINE_SUSPENDED. withContext handles a resume that races the suspension, and NonCancellable keeps the late-delivery-after-disposal case. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018VA6REg8PpdXdPfTkkCKZJ
…p test
The withContext(Dispatchers.Main) {} hop from the previous commit does
not keep the card on the main thread. The empty block usually finishes
on main before the download thread suspends, so that thread takes the
result and carries on. With a pause in adopt whenever it ran off the
main thread, 10 of 13 adopts were on the worker and 3 or 4 of the 6
cases failed on each run.
The hop now always suspends and is resumed only by the posted
main-thread task. With the same probe, 15 of 15 adopts ran on main and
all cases passed. Resuming while the worker is still returning
COROUTINE_SUSPENDED is the ordinary dispatcher handoff.
There was a problem hiding this comment.
Important
The Android test-harness fix still does not guarantee main-thread continuation, so the hosted ownership race can remain.
Reviewed changes since the prior Pullfrog review at 542d584d6, focused on the follow-up for the Android recording-ownership test.
- Replaced the raw continuation handoff — Switched the posted unintercepted-continuation resume to nested
withContext(NonCancellable)andwithContext(Dispatchers.Main)calls. - Retained canceled-delivery coverage — Kept cancellation disabled while attempting to return the mocked download to Main so a disposed owner still receives and releases late files.
@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏
…' into claude/project-thread-awyxuf-pr3b # Conflicts: # .memory/bot-chat-activity.md
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes since the prior Pullfrog review at f68566c49, including the updated stacked base and the Android ownership-test follow-up.
- Restored the deterministic Main-thread handoff — Replaced the ineffective empty
withContext(Main)hop with an always-suspending posted resume through the intercepted continuation, preserving canceled late-delivery coverage while returning adoption to Android Main. - Merged the updated stacked base — Carried forward the remote Bot unread-baseline, stable plan-card revision, and host-feed documentation updates without changing this PR's paging or withdrawal guarantees.
- Recorded the test diagnosis — Updated project memory with the failed alternative, probe results, and the final test-only behavior.
@v0 or keep the SHA fresh with Dependabot | View workflow run | Using GPT Sol | 𝕏
…hread-awyxuf-pr3b # Conflicts: # docs/aiden-remote-api-v1.md

Requested by sbt · project thread
Stacked on #909 (which is stacked on #907 and #895). Merge those first; GitHub then retargets this PR.
Problem
In a paired Mac's Bot chat:
Change
PR 3b of the fix plan.
Remote protocol, revision 67 (provisional; re-claim the next free number at merge, after #907's 66).
GET /bots/{botId}/session/entries?before=&limit=(getBotSessionEntries,bot:read+chat:read): the entries just older than one the device holds, oldest first. The page uses the same projection as the device's session, fits its byte limit, and has a truthfulhasOlder. Abeforethe session doesn't hold is 409operation_stale.POST /bots/{botId}/queued/{submissionId}/withdraw(withdrawBotQueuedMessage, needsbot:activity, keyed):withdrawn,startedorgone. A routine's input or the self-intro readsgone, because it isn't the person's to take back.Host.
olderEntriesand the session service'solderEntries/withdrawQueued.withdraw. It is the sameBotSessionService.withdrawthe desktop's own Remove uses.Desktop client.
botSessionEntriesandbotWithdrawQueued. Unreadable entries in a page are dropped, as in the session.loadOlderplaces a page before what is shown. A reconnect snapshot of the same epoch keeps the loaded pages; a new epoch drops them.Dropped from the plan: a count of every waiting approval. The next approval already appears after each answer. A count would need a new key on the approval, and phones' approval decoders refuse unknown keys, so it would also need a new opt-in.
Docs:
docs/aiden-remote-api-v1.md: new "Bot chat pages and queued messages, revision 67" section.docs/aiden-on-the-go-remote-access.md: Bots bullet..memory/bot-chat-activity.md.Screenshots
Scout on the Studio is running, with one message queued and earlier messages on the host.
Scope
A feature (PR 3b of the stack). Still to come: Needs you on phones (PR 4), and the same Bot signals from the headless server (PR 5). The headless server builds the same session service; PR 5 checks what it serves.
Verification
npm run type-check: clean. eslint on the touched files: clean.test:remote-chat(254): pass.test:peer-hosts(186): pass.test:bots(5 + 11 + 1083): pass.test:sidebar(260): pass.test:aiden-remoteminusaiden-remote-service.test.ts(which needs IPv6, missing in the cloud container): pass after one fix. A session-equivalence test caught a cursor difference; the cursor is now kept only whilehasOlder. That file reruns at 140/140.goneand still runs.chat:readfor pages,bot:activityfor withdraw).AI disclosure
Written with Claude Code.
Checklist
Android CI flake fixed in this branch
AidenBrowserRecordingOwnershipUiTest.replacingCardReleasesOldDeliveryAndOwnsTheNextOne. The test is onmainand flakes there too; nothing in this PR's feature work touches the recording card. This branch carries a test-only fix for it (below) because the flake kept failing this PR's "Android build and APK" job. The production recording code is unchanged.AssertionErrorfromeventually(the file was never released) in "Android build and APK" on cfac9e5: https://github.com/sambitcreate/aiden-agent/actions/runs/45362691722/job/138337222924loadnow continues on the main thread through a hop that always suspends and is resumed by a posted main-thread task. AwithContext(Dispatchers.Main) {}hop (f68566c) was tried and does not hold: with the same probe, 10 of 13 adopts still ran on the worker. A temporary pause inadoptwhen it ran off the main thread reproduced the symptom in 4 of 6 cases before the fix and 0 of 18 after it. The fullconnectedDebugAndroidTestsuite (212 tests) passes on a headless API 36 AVD.Generated by Claude Code