From 176aa3f4a80d18f64853303888954e71a315e6a4 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 07:43:22 +0000 Subject: [PATCH 1/4] Show phones when a Bot is waiting on the person (provisional revision 68) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A Bot's session state stays "running" while it waits on an approval, so phones showed "Working…" for a Bot that was actually waiting for the person. GET /bots summaries now carry needsYou: true, gated per device by the new bot:needs-you opt-in (Android's Bot decoder rejects unknown keys). The host reads the same signal its own Bot rows, host feed and Dock badge use, without reading transcripts, and drops it rather than failing the list if the read fails. iOS and Android negotiate the opt-in alone. Home rows read "Waiting for you" and stop showing as working; an approval the phone can see keeps "Needs your OK". The iOS inbox lists the Bot under Needs you. Revision 68 is provisional and is re-claimed at merge. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_018VA6REg8PpdXdPfTkkCKZJ --- .memory/bot-chat-activity.md | 3 +- android/CHANGELOG.md | 2 + android/README.md | 2 + .../bots/AidenBotSessionController.kt | 2 + .../features/bots/AidenBotsHomeScreen.kt | 12 +++- .../features/remote/AidenRemoteCoordinator.kt | 35 ++++++++++- .../sbtbiswas/AidenOnTheGo/models/AidenBot.kt | 10 +++- .../protocol/AidenRemoteProtocol.kt | 14 ++++- .../AidenOnTheGo/AidenBackgroundJobsTest.kt | 2 +- .../AidenBotAccessRequestsContractTest.kt | 2 +- .../AidenOnTheGo/AidenBotPlanContractTest.kt | 2 +- .../AidenOnTheGo/AidenRemoteClientTest.kt | 2 +- .../features/bots/AidenBotHomeBehaviorTest.kt | 36 ++++++++++- docs/aiden-on-the-go-remote-access.md | 4 ++ docs/aiden-remote-api-v1.md | 15 +++++ .../Features/Bots/AidenBotSessionModel.swift | 2 + .../Features/Bots/AidenBotsHomeView.swift | 12 ++-- .../Remote/Hosts/AidenHostConnection.swift | 1 + ios/AidenOnTheGo/Models/AidenBot.swift | 7 +++ .../Models/AidenInstallation.swift | 2 +- .../Models/AidenUnifiedInbox.swift | 7 ++- .../Networking/AidenRemoteClient.swift | 2 +- .../Networking/AidenRemoteContract.swift | 8 +++ .../AidenBackgroundJobsTests.swift | 2 +- .../AidenBotHomeProfileTests.swift | 26 +++++++- ios/AidenOnTheGoTests/AidenBotPlanTests.swift | 2 +- .../AidenBotSessionTests.swift | 2 +- .../AidenRemoteClientTests.swift | 17 ++++++ .../AidenRemotePhase0Tests.swift | 4 +- .../AidenUnifiedInboxTests.swift | 18 ++++++ ios/CHANGELOG.md | 2 + ios/CONTRACT_TESTS.md | 2 + ios/PROJECT_SPEC.md | 1 + main/services/aiden-remote-protocol.test.ts | 34 +++++++++-- main/services/aiden-remote-protocol.ts | 35 ++++++++++- main/services/aiden-remote-router.test.ts | 60 ++++++++++++++++++- main/services/aiden-remote-router.ts | 37 +++++++++++- main/services/aiden-remote-service-main.ts | 10 ++++ main/services/aiden-remote-state.test.ts | 4 +- .../aiden-remote/v1/fixtures/contract.json | 4 +- protocol/aiden-remote/v1/openapi.json | 8 +++ 41 files changed, 412 insertions(+), 40 deletions(-) diff --git a/.memory/bot-chat-activity.md b/.memory/bot-chat-activity.md index e7ec693285..618310c1f8 100644 --- a/.memory/bot-chat-activity.md +++ b/.memory/bot-chat-activity.md @@ -107,5 +107,6 @@ If `main` has moved past 29, change every `30` D introduced to the next free rev - PR 3 (desktop only, no revision): the desktop asks for `bot:cards`, `bot:access-requests` and `bot:plans` (each `own_call`, only when the host lists them) and answers them through new peer ops `botRespondRoutineProposal`, `botAnswerAccessRequest`, `botRespondPlan`. `remote-bot-session.ts` maps plan/access frames onto `snapshot.plan`/`accessRequest` (plan items get place ids; `revision` = the frame's seq) and memory/routine entries onto local rows. `RemoteBotChatView` puts access and pending plan cards in the Needs-you slot, an active plan in the body, echoes sends at once (shared `BotPendingSend` helpers from bot-chat-pane) and shows a re-pair hint group for old pairings (`remoteBotGroups`). Host: `AidenRemoteBotService.list()` leaves out a Bot whose summary fails the contract instead of failing the whole list (and the host feed). - PR 3 follow-up: `peerBotSessionCompat` dropped `accessRequest` and `plan` from session reads, so a reload lost the card; both are now kept (an unreadable one becomes null). - PR 3b (Remote revision 67, provisional; re-claim at merge): `GET /bots/{botId}/session/entries?before=&limit=` (projector `olderEntries`, same audience as the snapshot; unknown `before` = 409 operation_stale) and `POST /bots/{botId}/queued/{submissionId}/withdraw` (needs `bot:activity`; routine/intro inputs read `gone`; runtime gained `withdraw`). No feature tokens: the server feature list is at its 32-token cap, so the desktop treats a 404 as an older host. Peer ops `botSessionEntries`, `botWithdrawQueued`; the follower's `loadOlder` + `carryOlderRemoteBotEntries` keep loaded pages across same-epoch snapshots. "Every waiting approval" was dropped: the next approval already follows each answer, and a count would need a new opt-in because phone approval decoders are strict. -- Still to come: PR 4 (phones show Needs you), PR 5 (headless server sends the same Bot signals). Not planned yet: a model picker for a remote Bot with a model problem (no remote route sets a Bot's model). +- PR 4 (2026-11-24, provisional revision 68, `bot:needs-you`): `GET /bots` summaries carry `needsYou: true` only for devices holding the opt-in (Android's Bot decoder rejects unknown keys). Router dependency `botNeedsYou(botIds)` reads `botLiveProjection().needsYou` (no transcript read); a failed read sends the list without it. iOS and Android ask for it alone; home rows read "Waiting for you" and stop showing as working, an approval the phone sees keeps "Needs your OK"; iOS inbox counts it. `aiden serve` doesn't wire it yet (PR 5). +- Still to come: PR 5 (headless server sends the same Bot signals). Not planned yet: a model picker for a remote Bot with a model problem (no remote route sets a Bot's model). diff --git a/android/CHANGELOG.md b/android/CHANGELOG.md index a60c3fd748..02e92913b4 100644 --- a/android/CHANGELOG.md +++ b/android/CHANGELOG.md @@ -4,6 +4,8 @@ Aiden On The Go for Android. Earlier Android changes are recorded in the pull re ## Unreleased +- **2026-11-24 — Bots waiting on you (provisional Remote revision 68, `bot:needs-you`).** On a Mac that offers it, the app asks for `bot:needs-you` in a call of its own, after `stream:snapshot-reasons`. A Bot the Mac says waits on the person reads "Waiting for you" on its Bots row and is no longer shown as working; an approval the phone can see in the Bot's chat keeps "Needs your OK". `needsYou` decodes only as a JSON boolean and is never written back when false. Run `--tests '*AidenBotHomeBehaviorTest'`. + - **2026-11-18 — Pairing with a server; Terminal theme control removed.** The pairing steps now say that on a server, `aiden serve` shows the code in its terminal, or `aiden remote pair lan` prints one, as iOS already did. The app no longer accepts the retired `appearance.terminalTheme` chat control, which no host has sent since the interactive CLI was retired on 2026-10-30. No Remote wire or revision change. - **2026-11-11 — Continue in a new chat (Remote revision 64; written as 63, re-claimed at merge on 2026-11-17).** When a host offering `chat:continue-in-new-chat` refuses a send because the chat's workspace folder is missing and says the chat can continue elsewhere, the error gains **Continue in a new chat**. A sheet lists the host's other workspaces (never the chat's own, archived ones or any folder path); picking one forks the whole chat into that workspace with the host's `continueIn` request and opens the new chat, leaving the original as it was. Failures show the host's message; a destination whose folder is missing too keeps the action so another workspace can be picked. Without the host's offer, or on older hosts, the refusal looks as before. Bot contract-test revision assertions now expect 63. diff --git a/android/README.md b/android/README.md index 3d7b848d80..d26bde0b5e 100644 --- a/android/README.md +++ b/android/README.md @@ -24,6 +24,8 @@ On Macs at provisional Remote revision 61, the app negotiates `approval:cards`, Hosts offering Remote revision 64's `chat:continue-in-new-chat` are asked for it alone. When a send is refused because the chat's workspace folder is missing on the computer and the host says the chat can continue elsewhere, the error under the composer gains **Continue in a new chat**. It opens a sheet listing the host's other workspaces, as the new-chat list names them, without the chat's own or archived ones and never with a folder path. Picking one copies the whole conversation into a new chat there and opens it; the original chat stays as it is. A failure shows the host's own sentence, and when the chosen workspace's folder is missing too the sheet can be opened again to pick another. A refusal without that offer, or from an older host, shows only the host's reason as before. Run `--tests '*AidenContinueInNewChatTest'` for its fixture, negotiation and chat flow coverage. +Hosts offering provisional Remote revision 68's `bot:needs-you` are asked for it alone. Their `GET /bots` summaries then carry `needsYou: true` for a Bot that waits on the person on that computer, and its Bots row reads "Waiting for you" instead of looking busy; an approval the phone can see keeps "Needs your OK". See "Bots that need you on phones, revision 68" in [`docs/aiden-remote-api-v1.md`](../docs/aiden-remote-api-v1.md). + For focused allowed-list and existing Bot regressions, use the installed JDK/SDK and offline Gradle from `android/`: ```sh diff --git a/android/app/src/main/java/sbtbiswas/AidenOnTheGo/features/bots/AidenBotSessionController.kt b/android/app/src/main/java/sbtbiswas/AidenOnTheGo/features/bots/AidenBotSessionController.kt index 121fcfb979..9ee5d2f3e4 100644 --- a/android/app/src/main/java/sbtbiswas/AidenOnTheGo/features/bots/AidenBotSessionController.kt +++ b/android/app/src/main/java/sbtbiswas/AidenOnTheGo/features/bots/AidenBotSessionController.kt @@ -2412,6 +2412,8 @@ class AidenBotSessionController( */ object AidenBotSessionCopy { const val NEEDS_MODEL = "Needs an AI model" + /** Revision 68: an approval, a question, a hand-off or an open issue waits on the person. */ + const val WAITING_FOR_YOU = "Waiting for you" /** A reply that stopped before it finished (a quit, a crash, or a lifted pause). */ const val INTERRUPTED_ROW = "Interrupted — tap to resume" /** Revision 37: the person paused the Bot (G2, the same words as iOS and desktop). */ diff --git a/android/app/src/main/java/sbtbiswas/AidenOnTheGo/features/bots/AidenBotsHomeScreen.kt b/android/app/src/main/java/sbtbiswas/AidenOnTheGo/features/bots/AidenBotsHomeScreen.kt index 14f27fff51..c16e0120f9 100644 --- a/android/app/src/main/java/sbtbiswas/AidenOnTheGo/features/bots/AidenBotsHomeScreen.kt +++ b/android/app/src/main/java/sbtbiswas/AidenOnTheGo/features/bots/AidenBotsHomeScreen.kt @@ -96,13 +96,21 @@ data class AidenBotHomeRow( val bot: AidenBotSummary, val conversation: AidenBotConversationItem? ) { + /** A Bot waiting on the person (revision 68) isn't shown as working. */ val isWorking: Boolean - get() = bot.sessionState == AidenBotSessionState.RUNNING || - (conversation != null && conversation.activityState != AidenBotConversationActivityState.IDLE) + get() = !bot.needsYou && ( + bot.sessionState == AidenBotSessionState.RUNNING || + (conversation != null && conversation.activityState != AidenBotConversationActivityState.IDLE) + ) /** The line under the name: what needs the person first, then the last message, then the subtitle. */ val preview: String get() { + // Revision 68: the Mac says the Bot waits on the person. An approval this phone can + // see says more below, so it keeps its own line. + if (bot.needsYou && conversation?.activityState != AidenBotConversationActivityState.WAITING_FOR_APPROVAL) { + return AidenBotSessionCopy.WAITING_FOR_YOU + } when (bot.sessionState) { AidenBotSessionState.INTERRUPTED -> return AidenBotSessionCopy.INTERRUPTED_ROW // Revision 37: a Bot the person paused (only `bot:handoffs` phones are told). diff --git a/android/app/src/main/java/sbtbiswas/AidenOnTheGo/features/remote/AidenRemoteCoordinator.kt b/android/app/src/main/java/sbtbiswas/AidenOnTheGo/features/remote/AidenRemoteCoordinator.kt index 75c54c008f..f4ee1f2b5b 100644 --- a/android/app/src/main/java/sbtbiswas/AidenOnTheGo/features/remote/AidenRemoteCoordinator.kt +++ b/android/app/src/main/java/sbtbiswas/AidenOnTheGo/features/remote/AidenRemoteCoordinator.kt @@ -212,6 +212,13 @@ internal fun aidenShouldRequestChatContinueInNewChat(server: AidenServer, instal internal fun aidenShouldRequestStreamSnapshotReasons(server: AidenServer, installation: AidenInstallation): Boolean = aidenShouldRequestSoloCapability(AidenRemoteCapability.STREAM_SNAPSHOT_REASONS, server, installation) +/** + * Revision 68: a Mac that offers `bot:needs-you` in `serverCapabilities` is asked for it alone + * after `stream:snapshot-reasons`, unless [installation] already holds it. + */ +internal fun aidenShouldRequestBotNeedsYou(server: AidenServer, installation: AidenInstallation): Boolean = + aidenShouldRequestSoloCapability(AidenRemoteCapability.BOT_NEEDS_YOU, server, installation) + private fun aidenShouldRequestSoloCapability( capability: AidenRemoteCapability, server: AidenServer, @@ -404,6 +411,24 @@ internal suspend fun aidenRequestStreamSnapshotReasons( stillCurrent ) +/** + * Revision 68: asks [server] for `bot:needs-you` alone. A Mac that refuses it (400 or 404) leaves + * the pairing as it was; its Bot list then never says a Bot needs the person. + */ +internal suspend fun aidenRequestBotNeedsYou( + client: AidenRemoteClient, + server: AidenServer, + installation: AidenInstallation, + stillCurrent: () -> Boolean = { true } +): AidenSoloCapabilityNegotiation? = + aidenRequestCapabilitiesAlone( + if (aidenShouldRequestBotNeedsYou(server, installation)) { + listOf(AidenRemoteCapability.BOT_NEEDS_YOU) + } else emptyList(), + client, + stillCurrent + ) + internal suspend fun aidenRequestBotMessaging( client: AidenRemoteClient, server: AidenServer, @@ -828,10 +853,18 @@ class AidenRemoteCoordinator( server = continueServer, request = ::aidenRequestStreamSnapshotReasons ) + // Revision 68: `bot:needs-you` goes alone too. + val needsYouServer = negotiateSoloCapability( + generation = generation, + installation = installation, + client = newClient, + server = snapshotReasonsServer, + request = ::aidenRequestBotNeedsYou + ) // Revision 59: `bot:watches` goes alone, without another feature token. val watchesServer = negotiateSoloCapability( generation = generation, installation = installation, client = newClient, - server = snapshotReasonsServer, request = ::aidenRequestBotWatches + server = needsYouServer, request = ::aidenRequestBotWatches ) val openWorkServer = negotiateSoloCapability(generation = generation, installation = installation, client = newClient, server = watchesServer, request = ::aidenRequestBotOpenWork) diff --git a/android/app/src/main/java/sbtbiswas/AidenOnTheGo/models/AidenBot.kt b/android/app/src/main/java/sbtbiswas/AidenOnTheGo/models/AidenBot.kt index 66de266bb2..ad55292c1c 100644 --- a/android/app/src/main/java/sbtbiswas/AidenOnTheGo/models/AidenBot.kt +++ b/android/app/src/main/java/sbtbiswas/AidenOnTheGo/models/AidenBot.kt @@ -298,7 +298,15 @@ data class AidenBotSummary( val issueCount: Int? = null, @Serializable(with = InstantIso8601Serializer::class) val createdAt: Instant, @Serializable(with = InstantIso8601Serializer::class) val updatedAt: Instant, - val revision: String + val revision: String, + /** + * Revision 68 (`bot:needs-you` devices only, on `GET /bots`): an approval, a question, a + * hand-off or an open issue waits on the person. The Mac sends it only as `true`; a missing + * flag reads as false and is never written back. + */ + @OptIn(ExperimentalSerializationApi::class) + @EncodeDefault(EncodeDefault.Mode.NEVER) + @Serializable(with = AidenStrictBooleanSerializer::class) val needsYou: Boolean = false ) { init { AidenBotWire.validateIdentifier(id, "id", AidenRemoteProtocol.MAX_BOT_IDENTIFIER_LENGTH) diff --git a/android/app/src/main/java/sbtbiswas/AidenOnTheGo/protocol/AidenRemoteProtocol.kt b/android/app/src/main/java/sbtbiswas/AidenOnTheGo/protocol/AidenRemoteProtocol.kt index 344d8fe179..853fd384f4 100644 --- a/android/app/src/main/java/sbtbiswas/AidenOnTheGo/protocol/AidenRemoteProtocol.kt +++ b/android/app/src/main/java/sbtbiswas/AidenOnTheGo/protocol/AidenRemoteProtocol.kt @@ -696,6 +696,13 @@ data class AidenRemoteCapability(val rawValue: String) { */ val STREAM_SNAPSHOT_REASONS = AidenRemoteCapability("stream:snapshot-reasons") + /** + * Revision 68: `GET /bots` summaries carry `needsYou: true` for a Bot waiting on the + * person (an approval, a question, a hand-off or an open issue). It grants no authority. + * A Mac on an earlier revision refuses the name, so it is asked for alone. + */ + val BOT_NEEDS_YOU = AidenRemoteCapability("bot:needs-you") + val V1_KNOWN = listOf( SERVER_READ, CHAT_READ, CHAT_WRITE, APPROVAL_RESPOND, WORKSPACE_READ, WORKSPACE_BROWSE, WORKSPACE_MANAGE, @@ -747,11 +754,14 @@ data class AidenRemoteCapability(val rawValue: String) { /** Revision 65: negotiable when the Mac lists it in `serverCapabilities`, in its own call. */ val PHONE_STREAM_SNAPSHOT_REASONS = listOf(STREAM_SNAPSHOT_REASONS) + /** Revision 68: negotiable when the Mac lists it in `serverCapabilities`, in its own call. */ + val PHONE_BOT_NEEDS_YOU = listOf(BOT_NEEDS_YOU) + /** Every grant `POST /device/capabilities` may add. */ val NEGOTIABLE = PROGRESS + PHONE_RUNS + PHONE_SIMULATORS + PHONE_BOT_CARDS + PHONE_BOT_ACTIVITY + PHONE_BOT_HANDOFFS + PHONE_SCHEDULE_CARDS + PHONE_BOT_IMAGES + PHONE_BOT_ISSUES + PHONE_CHAT_JOBS + PHONE_ATTACHMENTS_RAW + PHONE_CHAT_NEW_WORKTREE + PHONE_CHAT_CONTINUE_IN_NEW_CHAT + - PHONE_STREAM_SNAPSHOT_REASONS + PHONE_BOT_MESSAGING + + PHONE_STREAM_SNAPSHOT_REASONS + PHONE_BOT_NEEDS_YOU + PHONE_BOT_MESSAGING + listOf(BOT_WATCHES, BOT_OPEN_WORK, BOT_ROUTINE_MODELS, BOT_PEERS, BOT_ACCESS_REQUESTS, BOT_PLANS, BOT_ALLOWED) + BOT_UX @@ -759,7 +769,7 @@ data class AidenRemoteCapability(val rawValue: String) { val PHONE_KNOWN = V1_KNOWN + PHONE_RUNS + PHONE_SIMULATORS + PHONE_BOT_CARDS + PHONE_BOT_ACTIVITY + PHONE_BOT_HANDOFFS + PHONE_SCHEDULE_CARDS + PHONE_BOT_IMAGES + PHONE_BOT_ISSUES + PHONE_CHAT_JOBS + PHONE_ATTACHMENTS_RAW + PHONE_CHAT_NEW_WORKTREE + PHONE_CHAT_CONTINUE_IN_NEW_CHAT + - PHONE_STREAM_SNAPSHOT_REASONS + PHONE_BOT_MESSAGING + + PHONE_STREAM_SNAPSHOT_REASONS + PHONE_BOT_NEEDS_YOU + PHONE_BOT_MESSAGING + listOf(BOT_WATCHES, BOT_OPEN_WORK, BOT_ROUTINE_MODELS, BOT_PEERS, BOT_ACCESS_REQUESTS, BOT_PLANS, BOT_ALLOWED) + BOT_UX } diff --git a/android/app/src/test/java/sbtbiswas/AidenOnTheGo/AidenBackgroundJobsTest.kt b/android/app/src/test/java/sbtbiswas/AidenOnTheGo/AidenBackgroundJobsTest.kt index 028384ef18..7383c9ab7f 100644 --- a/android/app/src/test/java/sbtbiswas/AidenOnTheGo/AidenBackgroundJobsTest.kt +++ b/android/app/src/test/java/sbtbiswas/AidenOnTheGo/AidenBackgroundJobsTest.kt @@ -156,7 +156,7 @@ class AidenBackgroundJobsTest { * person stopped, or a reason this version does not know, reads as plain Stopped. */ @Test fun aJobStoppedAfterTheChatWentQuietSaysSo() { - assertEquals(67, contract.getValue("contractRevision").jsonPrimitive.int) + assertEquals(68, contract.getValue("contractRevision").jsonPrimitive.int) val list = contract.getValue("backgroundJobsChatSettled").jsonObject.getValue("list") val decoded = AidenBackgroundJobs.decode(list.toString()) val labels = decoded.jobs.associate { it.id to AidenBackgroundJobCopy.status(it, start) } diff --git a/android/app/src/test/java/sbtbiswas/AidenOnTheGo/AidenBotAccessRequestsContractTest.kt b/android/app/src/test/java/sbtbiswas/AidenOnTheGo/AidenBotAccessRequestsContractTest.kt index fc732d7088..f651da3847 100644 --- a/android/app/src/test/java/sbtbiswas/AidenOnTheGo/AidenBotAccessRequestsContractTest.kt +++ b/android/app/src/test/java/sbtbiswas/AidenOnTheGo/AidenBotAccessRequestsContractTest.kt @@ -30,7 +30,7 @@ class AidenBotAccessRequestsContractTest { private fun frame(element: JsonElement) = AidenBotSessionEventStream.decodeFrame(element.toString().toByteArray(), "bot_fixture_01") @Test fun canonicalCardsSessionFramesIssuesAndLegacySettlement() { - assertEquals(67, root.getValue("contractRevision").jsonPrimitive.int) + assertEquals(68, root.getValue("contractRevision").jsonPrimitive.int) assertEquals("bot:access-requests", fixture.getValue("capability").jsonPrimitive.content) val folder = AidenBotAccessRequest.parse(fixture.getValue("folder")) val mac = AidenBotAccessRequest.parse(fixture.getValue("wholeMac")) diff --git a/android/app/src/test/java/sbtbiswas/AidenOnTheGo/AidenBotPlanContractTest.kt b/android/app/src/test/java/sbtbiswas/AidenOnTheGo/AidenBotPlanContractTest.kt index fe464b2b75..270d400ac2 100644 --- a/android/app/src/test/java/sbtbiswas/AidenOnTheGo/AidenBotPlanContractTest.kt +++ b/android/app/src/test/java/sbtbiswas/AidenOnTheGo/AidenBotPlanContractTest.kt @@ -47,7 +47,7 @@ class AidenBotPlanContractTest { assertNull(plan.items.first().used); assertNull(plan.items.first().max) } @Test fun canonicalSnapshotAndOrderedPlanFramesDecode() { - assertEquals(67, root.getValue("contractRevision").jsonPrimitive.int) + assertEquals(68, root.getValue("contractRevision").jsonPrimitive.int) val session = wire.decodeFromJsonElement(AidenBotSession.serializer(), fixture.getValue("session")) assertEquals(0L, session.seq) assertHostFolderReview(requireNotNull(session.plan)) diff --git a/android/app/src/test/java/sbtbiswas/AidenOnTheGo/AidenRemoteClientTest.kt b/android/app/src/test/java/sbtbiswas/AidenOnTheGo/AidenRemoteClientTest.kt index 8a0e416356..eb740cd188 100644 --- a/android/app/src/test/java/sbtbiswas/AidenOnTheGo/AidenRemoteClientTest.kt +++ b/android/app/src/test/java/sbtbiswas/AidenOnTheGo/AidenRemoteClientTest.kt @@ -1618,7 +1618,7 @@ class AidenRemoteClientTest { @Test fun streamSnapshotReasonsDecodeSharedFixtureRejectInvalidReasonsAndNegotiateSolo() = runBlocking { val fixture = contractFixture() - assertEquals(67, fixture.getValue("contractRevision").jsonPrimitive.int) + assertEquals(68, fixture.getValue("contractRevision").jsonPrimitive.int) val section = fixture.getValue("streamRecovery").jsonObject assertEquals("stream:snapshot-reasons", section.getValue("capability").jsonPrimitive.content) diff --git a/android/app/src/test/java/sbtbiswas/AidenOnTheGo/features/bots/AidenBotHomeBehaviorTest.kt b/android/app/src/test/java/sbtbiswas/AidenOnTheGo/features/bots/AidenBotHomeBehaviorTest.kt index a81b505235..17d7dbf943 100644 --- a/android/app/src/test/java/sbtbiswas/AidenOnTheGo/features/bots/AidenBotHomeBehaviorTest.kt +++ b/android/app/src/test/java/sbtbiswas/AidenOnTheGo/features/bots/AidenBotHomeBehaviorTest.kt @@ -1,5 +1,8 @@ package sbtbiswas.AidenOnTheGo.features.bots +import kotlinx.serialization.json.JsonObject +import kotlinx.serialization.json.JsonPrimitive +import kotlinx.serialization.json.jsonObject import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue @@ -17,7 +20,8 @@ class AidenBotHomeBehaviorTest { name: String, purpose: String = "", updated: Instant = t0, - sessionState: AidenBotSessionState? = null + sessionState: AidenBotSessionState? = null, + needsYou: Boolean = false ) = AidenBotSummary( id = id, name = name, @@ -28,7 +32,8 @@ class AidenBotHomeBehaviorTest { paused = sessionState == AidenBotSessionState.PAUSED, createdAt = t0.minusSeconds(86_400), updatedAt = updated, - revision = "r1" + revision = "r1", + needsYou = needsYou ) private fun chat( @@ -131,6 +136,33 @@ class AidenBotHomeBehaviorTest { ) } + @Test + fun aRunningBotTheMacSaysWaitsOnThePersonSaysSoInsteadOfLookingBusy() { + val waiting = bot("b", "Scout", sessionState = AidenBotSessionState.RUNNING, needsYou = true) + val running = AidenBotHomeRow(waiting, chat("c", "b", "Checking the build", state = AidenBotConversationActivityState.RUNNING)) + assertEquals(AidenBotSessionCopy.WAITING_FOR_YOU, running.preview) + assertFalse(running.isWorking) + // An approval this phone can answer keeps its own, more useful line. + assertEquals( + "Needs your OK", + AidenBotHomeRow(waiting, chat("c", "b", "old", state = AidenBotConversationActivityState.WAITING_FOR_APPROVAL, canRespond = true)).preview + ) + // Without the flag the same Bot still reads as busy. + assertTrue(AidenBotHomeRow(bot("b", "Scout", sessionState = AidenBotSessionState.RUNNING), null).isWorking) + } + + @Test + fun needsYouDecodesOnlyAsABooleanAndIsNeverWrittenWhenFalse() { + val wire = AidenBotWireJson.json + val plain = wire.encodeToJsonElement(AidenBotSummary.serializer(), bot("b", "Scout")).jsonObject + assertFalse("needsYou" in plain) + assertFalse(wire.decodeFromJsonElement(AidenBotSummary.serializer(), plain).needsYou) + assertTrue(wire.decodeFromJsonElement(AidenBotSummary.serializer(), JsonObject(plain + ("needsYou" to JsonPrimitive(true)))).needsYou) + assertTrue(runCatching { + wire.decodeFromJsonElement(AidenBotSummary.serializer(), JsonObject(plain + ("needsYou" to JsonPrimitive("true")))) + }.isFailure) + } + @Test fun activityDotShowsOnlyWhileTheBotIsBusy() { val scout = bot("b", "Scout") diff --git a/docs/aiden-on-the-go-remote-access.md b/docs/aiden-on-the-go-remote-access.md index c349c53ecb..7222dc6276 100644 --- a/docs/aiden-on-the-go-remote-access.md +++ b/docs/aiden-on-the-go-remote-access.md @@ -124,6 +124,10 @@ When a desktop host grants `bot:allowed` (contract revision 57), iPhone and Andr When the paired Mac offers it (contract revision 42, `bot:issues`), a Bot's **Needs you** cards appear in its chat on Aiden On The Go for iPhone and Android. A card says what happened in plain words ("Paused “Morning brief” after 3 failed tries", "Gmail needs reconnecting") and offers up to two actions: **Resume routine**, **Stop**, **Keep waiting**, or **Open chat**. Current Macs no longer raise the "quiet for 10 minutes" card that offered Stop and Keep waiting; a phone still answers one an older Mac left open. A card whose only action opens the Mac's own settings shows "Open on your Mac" instead of a button. The Bots list shows how many open cards a Bot has, and a phone notification says the Bot needs you when the app is not in the foreground. Only asks notify: a heads-up card shows in the chat without a phone alert, nothing alerts while that Bot's chat is open in front of the person on the Mac, and an ask still open after 4 hours sends one "Reminder: …" notification. With an older Mac the cards stay on the Mac, and the phone shows nothing for them. +## Bots waiting on you on the phone + +When the paired Mac offers it (contract revision 68, `bot:needs-you`, provisional), a Bot that waits on you there (an approval, a question, a hand-off, an access request, a plan to OK or a Needs you card) reads **Waiting for you** on the Bots list of Aiden On The Go for iPhone and Android, instead of looking busy. An approval the phone can already see in that Bot's chat keeps its own line, such as "Needs your OK". On iPhone the Inbox also lists that Bot under **Needs you**. The phone picks this up whenever it reads the Bots list again. An `aiden serve` host, or a Mac on an older Aiden, doesn't offer it yet, and the list looks as before. + ## Bot messaging on the phone With a host offering revision 59 and `bot:peers`, iPhone and Android can manage a Bot’s routing description and named pair approvals from **Profile → Bot peers**. Pair metadata needs Bot read access; exchange content and source/result evidence also need chat read access. Changes and Stop need Bot write access. Each recipient keeps its own rules and access. The phone retains the exact request after a lost reply; a pending Stop offers acknowledgement status rather than claiming cancellation. Intermediate exchange rows stay quiet, and the initiating Bot’s final update uses the existing notification feed. See [Bot peers](bot-peers.md). diff --git a/docs/aiden-remote-api-v1.md b/docs/aiden-remote-api-v1.md index 1a201be512..ecd39ff775 100644 --- a/docs/aiden-remote-api-v1.md +++ b/docs/aiden-remote-api-v1.md @@ -67,6 +67,7 @@ Initial capability IDs: | `attachments:raw` | Opt-in, no authority of its own (contract revision 50). Lets `POST /chats/{chatId}/attachments` and `POST /bots/{botId}/attachments` take one picture as its raw `image/png` or `image/jpeg` bytes instead of the JSON envelope. Each upload still needs that route's own grants. Negotiable post-pairing by any device type through `POST /device/capabilities` while the host lists it in `serverCapabilities` (any host that serves chat or Bot uploads), never issued by pairing. There is no `/server` feature token for it. A host before revision 50 refuses the name, so devices ask for it in a call of their own. See "Raw picture uploads, revision 50". | | `chat:continue-in-new-chat` | Opt-in, no authority of its own (contract revision 64). Delivers the `workspace_unavailable` refusal's `details` and opens the `continueIn` body of `POST /chats/{chatId}/fork`, which still needs `chat:write`. Negotiable post-pairing by any device type through `POST /device/capabilities` while the host lists it in `serverCapabilities` (the host lists it only where it can fork chats), never issued by pairing. There is no `/server` feature token for it. A host before revision 64 refuses the name, so devices ask for it in a call of their own. See "Continue in a new chat, revision 64". | | `stream:snapshot-reasons` | Opt-in, no authority of its own (contract revision 65). Delivers `reason` (`gap` \| `reset`) on `GET /streams/{streamId}/events` `snapshot` payloads so a client can tell a retention-gap recovery boundary apart from a provider stream reset; nonholders receive the legacy `{chatId, turnId, nextSequence}` payload. Negotiable post-pairing by any device type through `POST /device/capabilities` while the host lists it in `serverCapabilities` (`404 not_found` on a host without turn streams), never issued by pairing. There is no `/server` feature token for it. A host before revision 65 refuses the name, so devices ask for it in a call of their own. See "Stream lagging-cursor recovery and snapshot reasons, revision 65". | +| `bot:needs-you` | Opt-in, no authority of its own (contract revision 68, provisional). Delivers `needsYou: true` on `GET /bots` summaries for a Bot the person owes an answer (an approval, a question, a hand-off, an access request, a pending plan or an open issue); nonholders receive the summary without the key. Negotiable post-pairing by any device type through `POST /device/capabilities` while the host lists it in `serverCapabilities` (`404 not_found` on a host that cannot tell), never issued by pairing. There is no `/server` feature token for it. A host before revision 68 refuses the name, so devices ask for it in a call of their own. See "Bots that need you on phones, revision 68". | | `chat:new-worktree` | Opt-in (contract revision 53, provisional). Opens `POST /chats/{chatId}/worktree`, which also needs `chat:write` and `git:write`. The opt-in only says the device can show the step; making the worktree is a Git write. Negotiable post-pairing by any device type through `POST /device/capabilities` while the host lists it in `serverCapabilities` (the host lists it only where it can make worktrees), never issued by pairing. There is no `/server` feature token for it. A host before revision 53 refuses the name, so devices ask for it in a call of their own. See "New worktree from a phone, revision 53". | | `tasks:read` | Read the bounded chat task-progress projection and receive `task_update` events. Granted only after explicit client negotiation at pairing or post-pairing. | | `agents:read` | Read the bounded delegated-agent roster projection and receive `agents_update` events. Granted only after explicit client negotiation at pairing or post-pairing. | @@ -1517,3 +1518,17 @@ Revision 67 is provisional: it was written when `main` was at 65 and revision 66 **Fixtures.** The fixture carries only the new `contractRevision`; the protocol test checks both shapes against the parser and the OpenAPI schemas (`BotSessionEntriesPage`, `BotQueuedWithdrawReceipt`). +## Bots that need you on phones, revision 68 (`bot:needs-you`, provisional) + +Revision 68 is provisional: it was written when `main` was at 65 and revisions 66 and 67 were still open, and the host keeps it in one constant (`AIDEN_REMOTE_BOT_NEEDS_YOU_CONTRACT_REVISION`), so claiming the next free number at merge changes only that constant. + +**Negotiation.** The host lists `bot:needs-you` in `serverCapabilities` to a device that may hold Bot opt-ins, whenever it can tell which Bots wait on the person. A device asks for it with `POST /device/capabilities {accepts: ["bot:needs-you"]}` in a call of its **own**: a host older than revision 68 refuses the unknown name with `400 invalid_request`, and a host that cannot tell answers `404 not_found`. Pairing never issues it, and there is no `/server` feature token (the list is at its 32-token limit). + +**Audience-gated `needsYou`.** `GET /bots` summaries (`BotSummary`) carry `needsYou: true` only for a device holding `bot:needs-you`, and only for a Bot the person owes an answer: an open approval, question, hand-off, access request, pending plan or issue. That is the same signal the host's own Bots list, the host feed's revision-52 `needsYou` and the Dock badge use, read without the Bot's transcript. It is never sent as `false`, and other devices never see the key: Android's Bot decoder rejects unknown keys. If the host cannot read the signal for a list, it sends the list without it rather than failing. + +**Why phones need it.** A Bot's session state stays `running` while it waits on an approval, so a phone that reads only `sessionState` showed "Working…" for a Bot that was waiting on the person, and the waiting approval itself is visible only to a device that holds the right card opt-ins and has the chat open. + +**Clients.** Aiden On The Go for iOS and Android negotiate `bot:needs-you` alone when offered. A Bot with `needsYou` reads "Waiting for you" on its Bots home row and is not shown as working; an approval the phone can see in that Bot's chat keeps its own, more specific line ("Needs your OK"). On iOS the unified inbox also lists the Bot under Needs you, after its open-issue count, with "Waiting for you" as the reason. Phones pick the flag up each time they read the Bot list again; nothing new is pushed for it. + +**Fixtures.** The fixture carries only the new `contractRevision`; the protocol test checks that `needsYou` parses only as `true`, and the router test checks who receives it. + diff --git a/ios/AidenOnTheGo/Features/Bots/AidenBotSessionModel.swift b/ios/AidenOnTheGo/Features/Bots/AidenBotSessionModel.swift index 1725b02cc0..3ae2a59cce 100644 --- a/ios/AidenOnTheGo/Features/Bots/AidenBotSessionModel.swift +++ b/ios/AidenOnTheGo/Features/Bots/AidenBotSessionModel.swift @@ -275,6 +275,8 @@ enum AidenBotSessionCopy { /// Revision 37: the person paused the Bot. static let pausedSubtitle = "Paused" static let needsModel = "Needs an AI model" + /// Revision 68: an approval, a question or a hand-off waits on the person. + static let waitingForYou = "Waiting for you" static let needsModelHint = "Set up on your computer" static let setUp = "Set up" static let queued = "Queued" diff --git a/ios/AidenOnTheGo/Features/Bots/AidenBotsHomeView.swift b/ios/AidenOnTheGo/Features/Bots/AidenBotsHomeView.swift index 3a277db80c..a7d65c4320 100644 --- a/ios/AidenOnTheGo/Features/Bots/AidenBotsHomeView.swift +++ b/ios/AidenOnTheGo/Features/Bots/AidenBotsHomeView.swift @@ -155,10 +155,12 @@ struct AidenBotHomeRow: Equatable, Identifiable { var id: String { bot.id } - /// The durable session state comes first: an interrupted turn, a Bot the - /// person paused (revision 37) or a missing model says so; otherwise the - /// last message, or a greeting prompt. + /// A wait on the person comes first (revision 68: an approval, a question, + /// a hand-off or an open issue), then the durable session state: an + /// interrupted turn, a Bot the person paused (revision 37) or a missing + /// model says so; otherwise the last message, or a greeting prompt. var preview: String { + if bot.needsYou { return AidenBotSessionCopy.waitingForYou } switch bot.sessionState { case .interrupted: return AidenBotSessionCopy.interruptedSubtitle case .paused: return AidenBotSessionCopy.pausedSubtitle @@ -169,8 +171,10 @@ struct AidenBotHomeRow: Equatable, Identifiable { return text.isEmpty ? "Say hello" : text } - /// Shows the small activity dot on the avatar while the Bot is working. + /// Shows the small activity dot on the avatar while the Bot is working, + /// but not while it waits on the person. var isWorking: Bool { + if bot.needsYou { return false } if let state = bot.sessionState { return state == .running } guard let conversation else { return false } return conversation.activityState != .idle diff --git a/ios/AidenOnTheGo/Features/Remote/Hosts/AidenHostConnection.swift b/ios/AidenOnTheGo/Features/Remote/Hosts/AidenHostConnection.swift index dce0ad8558..3b28c243bf 100644 --- a/ios/AidenOnTheGo/Features/Remote/Hosts/AidenHostConnection.swift +++ b/ios/AidenOnTheGo/Features/Remote/Hosts/AidenHostConnection.swift @@ -619,6 +619,7 @@ final class AidenHostConnection { [.chatNewWorktree], [.chatContinueInNewChat], [.streamSnapshotReasons], + [.botNeedsYou], [.botWatches], [.botOpenWork], [.botRoutineModels], diff --git a/ios/AidenOnTheGo/Models/AidenBot.swift b/ios/AidenOnTheGo/Models/AidenBot.swift index aa50bfe49a..3c67d9b3bf 100644 --- a/ios/AidenOnTheGo/Models/AidenBot.swift +++ b/ios/AidenOnTheGo/Models/AidenBot.swift @@ -337,6 +337,10 @@ struct AidenBotSummary: Codable, Equatable, Identifiable, Sendable { /// Revision 42 (`bot:issues`): how many open "Needs you" cards the Bot /// holds. Present only for a device holding `bot:issues`, and only above zero. let issueCount: Int? + /// Revision 68 (`bot:needs-you`): an approval, a question, a hand-off or an + /// open issue waits on the person. A Mac sends it only as `true`, and only + /// on `GET /bots` to a device holding `bot:needs-you`. + let needsYou: Bool init(detail: AidenBotDetail) { id = detail.id @@ -350,6 +354,8 @@ struct AidenBotSummary: Codable, Equatable, Identifiable, Sendable { sessionState = detail.sessionState paused = detail.paused issueCount = detail.issueCount + // A detail never carries it; the next Bot list says again. + needsYou = false } init(from decoder: Decoder) throws { @@ -375,6 +381,7 @@ struct AidenBotSummary: Codable, Equatable, Identifiable, Sendable { ) paused = try AidenBotWire.pausedFlag(values, forKey: .paused, sessionState: sessionState) issueCount = try AidenBotWire.issueCount(values, forKey: .issueCount) + needsYou = try AidenBotWire.optional(Bool.self, from: values, forKey: .needsYou) ?? false // Archive was replaced by Delete in revision 25 (as the host parser). guard try decoder.container(keyedBy: AidenBotDynamicCodingKey.self) .allKeys.contains(where: { $0.stringValue == "archivedAt" }) == false else { diff --git a/ios/AidenOnTheGo/Models/AidenInstallation.swift b/ios/AidenOnTheGo/Models/AidenInstallation.swift index 73aa5334d6..992d036bc9 100644 --- a/ios/AidenOnTheGo/Models/AidenInstallation.swift +++ b/ios/AidenOnTheGo/Models/AidenInstallation.swift @@ -352,7 +352,7 @@ final class AidenInstallationStore { .botWatches, .botOpenWork, .botRoutineModels, .botPeers, .botMessaging, .botAccessRequests, .botPlans, .botAllowed, .appControlsRead, .appControlsRespond, .scheduleCards, .chatJobs, .attachmentsRaw, .chatNewWorktree, - .chatContinueInNewChat, .streamSnapshotReasons, + .chatContinueInNewChat, .streamSnapshotReasons, .botNeedsYou, ]).union(AidenRemoteCapability.botUX) let existingNonProgress = Set(installations[index].deviceCapabilities).subtracting(progress) guard existingNonProgress == Set(capabilities).subtracting(progress) else { diff --git a/ios/AidenOnTheGo/Models/AidenUnifiedInbox.swift b/ios/AidenOnTheGo/Models/AidenUnifiedInbox.swift index 20bd5c6bb8..8fa8300e92 100644 --- a/ios/AidenOnTheGo/Models/AidenUnifiedInbox.swift +++ b/ios/AidenOnTheGo/Models/AidenUnifiedInbox.swift @@ -25,9 +25,10 @@ struct AidenHostInboxSnapshot: Equatable, Sendable { /// exist, so a Bot is listed only while it needs the person, and shown in the /// accessory while it runs. enum AidenBotAttention { - /// Open "Needs you" cards, or a session that stopped and waits on the person. + /// Open "Needs you" cards, a wait the Mac reports (revision 68: an approval, + /// a question or a hand-off), or a session that stopped and waits on the person. static func needsYou(_ bot: AidenBotSummary) -> Bool { - (bot.issueCount ?? 0) > 0 || bot.sessionState == .interrupted || bot.sessionState == .needsModel + (bot.issueCount ?? 0) > 0 || bot.needsYou || bot.sessionState == .interrupted || bot.sessionState == .needsModel } static func isRunning(_ bot: AidenBotSummary) -> Bool { @@ -39,6 +40,8 @@ enum AidenBotAttention { if let issues = bot.issueCount, issues > 0 { return issues == 1 ? String(localized: "1 thing needs you") : String(localized: "\(issues) things need you") } + // Before Working: a running turn that waits on the person is waiting, not working. + if bot.needsYou { return String(localized: "Waiting for you") } switch bot.sessionState { case .interrupted: return String(localized: "Interrupted") case .needsModel: return String(localized: "Needs an AI model") diff --git a/ios/AidenOnTheGo/Networking/AidenRemoteClient.swift b/ios/AidenOnTheGo/Networking/AidenRemoteClient.swift index 264fefd470..5c32737560 100644 --- a/ios/AidenOnTheGo/Networking/AidenRemoteClient.swift +++ b/ios/AidenOnTheGo/Networking/AidenRemoteClient.swift @@ -1591,7 +1591,7 @@ final class AidenRemoteClient: @unchecked Sendable { .botWatches, .botOpenWork, .botRoutineModels, .botPeers, .botMessaging, .botAccessRequests, .botPlans, .botAllowed, .appControlsRead, .appControlsRespond, .scheduleCards, .chatJobs, .attachmentsRaw, .chatNewWorktree, - .chatContinueInNewChat, .streamSnapshotReasons, + .chatContinueInNewChat, .streamSnapshotReasons, .botNeedsYou, ]).union(AidenRemoteCapability.botUX) guard !accepts.isEmpty, Set(accepts).count == accepts.count, diff --git a/ios/AidenOnTheGo/Networking/AidenRemoteContract.swift b/ios/AidenOnTheGo/Networking/AidenRemoteContract.swift index 6270339079..e6b83c37a6 100644 --- a/ios/AidenOnTheGo/Networking/AidenRemoteContract.swift +++ b/ios/AidenOnTheGo/Networking/AidenRemoteContract.swift @@ -681,6 +681,7 @@ struct AidenRemoteCapability: RawRepresentable, Codable, Hashable, Sendable { /// Contract revision 59 adds `bot:routine-models`, asked for alone. /// Contract revision 59 adds `bot:peers`, asked for alone. /// Contract revision 64 adds `chat:continue-in-new-chat`, asked for alone. + /// Contract revision 68 adds `bot:needs-you`, asked for alone. /// Contract revision 61 adds `approval:cards`, `approvals:settings`, /// `bot:settings-changes`, `bot:suggestions` and `bot:templates`, each alone. @@ -698,6 +699,7 @@ struct AidenRemoteCapability: RawRepresentable, Codable, Hashable, Sendable { Self(rawValue: "chat:new-worktree"), Self(rawValue: "chat:continue-in-new-chat"), Self(rawValue: "stream:snapshot-reasons"), + Self(rawValue: "bot:needs-you"), Self(rawValue: "bot:watches"), Self(rawValue: "bot:open-work"), Self(rawValue: "bot:routine-models"), @@ -781,6 +783,12 @@ struct AidenRemoteCapability: RawRepresentable, Codable, Hashable, Sendable { /// resets. Asked for alone so older hosts do not reject the progress batch. static let streamSnapshotReasons = Self(rawValue: "stream:snapshot-reasons") + /// Revision 68: `GET /bots` summaries carry `needsYou: true` for a Bot + /// waiting on the person (an approval, a question, a hand-off or an open + /// issue). It grants no authority. A Mac on an earlier revision refuses the + /// name, so the device asks for it alone. + static let botNeedsYou = Self(rawValue: "bot:needs-you") + /// Revision 42: the device receives the Bot session `issues` list and /// `issues` frames, a summary `issueCount`, and issue items in the routine /// notification feed, and may answer a card through diff --git a/ios/AidenOnTheGoTests/AidenBackgroundJobsTests.swift b/ios/AidenOnTheGoTests/AidenBackgroundJobsTests.swift index 2ca18bca1f..922a368b6f 100644 --- a/ios/AidenOnTheGoTests/AidenBackgroundJobsTests.swift +++ b/ios/AidenOnTheGoTests/AidenBackgroundJobsTests.swift @@ -57,7 +57,7 @@ final class AidenBackgroundJobsTests: XCTestCase { func testAJobStoppedAfterTheChatWentQuietSaysSo() throws { let fixtureURL = try XCTUnwrap(Bundle(for: Self.self).url(forResource: "contract", withExtension: "json")) let root = try XCTUnwrap(try JSONSerialization.jsonObject(with: Data(contentsOf: fixtureURL)) as? [String: Any]) - XCTAssertEqual(root["contractRevision"] as? Int, 67) + XCTAssertEqual(root["contractRevision"] as? Int, 68) let section = try XCTUnwrap(root["backgroundJobsChatSettled"] as? [String: Any]) let data = try JSONSerialization.data(withJSONObject: try XCTUnwrap(section["list"])) let list = try AidenRemoteJSONDecoder.decode(AidenBackgroundJobs.self, from: data) diff --git a/ios/AidenOnTheGoTests/AidenBotHomeProfileTests.swift b/ios/AidenOnTheGoTests/AidenBotHomeProfileTests.swift index 3f192a9d95..98bc72d9cb 100644 --- a/ios/AidenOnTheGoTests/AidenBotHomeProfileTests.swift +++ b/ios/AidenOnTheGoTests/AidenBotHomeProfileTests.swift @@ -43,7 +43,8 @@ final class AidenBotHomeProfileTests: XCTestCase { name: String, purpose: String = "", updatedAt: String, - sessionState: String? = nil + sessionState: String? = nil, + needsYou: Bool = false ) throws -> AidenBotSummary { var object: [String: Any] = [ "id": id, @@ -58,6 +59,8 @@ final class AidenBotHomeProfileTests: XCTestCase { if let sessionState { object["sessionState"] = sessionState } // Revision 37: a paused Bot's summary also carries `paused: true`. if sessionState == "paused" { object["paused"] = true } + // Revision 68: only a `bot:needs-you` phone is told, and only as `true`. + if needsYou { object["needsYou"] = true } return try AidenRemoteJSONDecoder.decode( AidenBotSummary.self, from: JSONSerialization.data(withJSONObject: object) @@ -150,6 +153,27 @@ final class AidenBotHomeProfileTests: XCTestCase { XCTAssertEqual(rows["paused"]?.isWorking, false) } + /// Revision 68: a Bot waiting on an approval or a question says so first, + /// over its last message, and stops showing the working dot. + func testHomeRowSaysWaitingForYouWhenTheMacSaysTheBotNeedsThePerson() throws { + let bots = [ + try summary(id: "waiting", name: "Waiting", updatedAt: "2026-08-18T18:00:00.000Z", sessionState: "running", needsYou: true), + try summary(id: "busy", name: "Busy", updatedAt: "2026-08-18T17:00:00.000Z", sessionState: "running"), + ] + let conversations = [ + try conversation(botID: "waiting", preview: "Booking the flight", updatedAt: "2026-08-18T18:00:00.000Z"), + ] + let rows = Dictionary(uniqueKeysWithValues: aidenBotHomeRows( + bots: bots, + conversations: conversations, + query: "" + ).map { ($0.id, $0) }) + XCTAssertEqual(rows["waiting"]?.preview, "Waiting for you") + XCTAssertEqual(rows["waiting"]?.isWorking, false) + XCTAssertEqual(rows["busy"]?.isWorking, true) + XCTAssertEqual(rows["busy"]?.preview, "Say hello") + } + func testHomeSearchMatchesNameSubtitlePreviewAndServerMatches() throws { let bots = [ try summary(id: "chef", name: "Chef", purpose: "Meal prepping", updatedAt: "2026-08-18T18:00:00.000Z"), diff --git a/ios/AidenOnTheGoTests/AidenBotPlanTests.swift b/ios/AidenOnTheGoTests/AidenBotPlanTests.swift index 3f0dcb0e0c..eed7a92572 100644 --- a/ios/AidenOnTheGoTests/AidenBotPlanTests.swift +++ b/ios/AidenOnTheGoTests/AidenBotPlanTests.swift @@ -7,7 +7,7 @@ final class AidenBotPlanTests: XCTestCase { func section() throws -> [String: Any] { let url = try XCTUnwrap(Bundle(for: Self.self).url(forResource: "contract", withExtension: "json")) let root = try XCTUnwrap(JSONSerialization.jsonObject(with: Data(contentsOf: url)) as? [String: Any]) - XCTAssertEqual(root["contractRevision"] as? Int, 67) + XCTAssertEqual(root["contractRevision"] as? Int, 68) return try XCTUnwrap(root["botPlans"] as? [String: Any]) } func decode(_ type: T.Type, _ value: Any) throws -> T { diff --git a/ios/AidenOnTheGoTests/AidenBotSessionTests.swift b/ios/AidenOnTheGoTests/AidenBotSessionTests.swift index 87160bc618..c8018b1a07 100644 --- a/ios/AidenOnTheGoTests/AidenBotSessionTests.swift +++ b/ios/AidenOnTheGoTests/AidenBotSessionTests.swift @@ -5895,7 +5895,7 @@ final class AidenBotAccessRequestsTests: XCTestCase { private func section() throws -> [String: Any] { let url = try XCTUnwrap(Bundle(for: Self.self).url(forResource: "contract", withExtension: "json")) let root = try XCTUnwrap(JSONSerialization.jsonObject(with: Data(contentsOf: url)) as? [String: Any]) - XCTAssertEqual(root["contractRevision"] as? Int, 67) + XCTAssertEqual(root["contractRevision"] as? Int, 68) return try XCTUnwrap(root["botAccessRequests"] as? [String: Any]) } private func decode(_ type: T.Type, _ object: Any) throws -> T { diff --git a/ios/AidenOnTheGoTests/AidenRemoteClientTests.swift b/ios/AidenOnTheGoTests/AidenRemoteClientTests.swift index ad61dce922..83481cb436 100644 --- a/ios/AidenOnTheGoTests/AidenRemoteClientTests.swift +++ b/ios/AidenOnTheGoTests/AidenRemoteClientTests.swift @@ -1456,6 +1456,23 @@ final class AidenRemoteClientTests: XCTestCase { XCTAssertTrue(grants.contains(.streamSnapshotReasons)) } + /// Revision 68: `bot:needs-you` is negotiated alone, because a Mac before + /// revision 68 refuses the name, and only its holders' Bot lists carry `needsYou`. + func testBotNeedsYouIsAnOptInNegotiatedAlone() async throws { + XCTAssertEqual(AidenRemoteCapability(rawValue: "bot:needs-you"), .botNeedsYou) + XCTAssertFalse(AidenRemoteCapability.v1Known.contains(.botNeedsYou)) + XCTAssertTrue(AidenRemoteCapability.phoneNegotiable.contains(.botNeedsYou)) + let askedForAlone = await MainActor.run { AidenRemoteCoordinator.capabilitiesAskedForAlone } + XCTAssertTrue(askedForAlone.contains([.botNeedsYou])) + AidenRemoteMockURLProtocol.handler = { request in + XCTAssertEqual(request.url?.path, "/api/aiden/v1/device/capabilities") + XCTAssertEqual(try Self.jsonBody(request)["accepts"] as? [String], ["bot:needs-you"]) + return Self.response(for: request, status: 200, json: #"{"capabilities":["server:read","bot:read","bot:needs-you"]}"#) + } + let grants = try await makeClient().updateDeviceCapabilities(accepts: [.botNeedsYou]) + XCTAssertTrue(grants.contains(.botNeedsYou)) + } + /// Revision 64: Continue in a new chat posts only the destination workspace /// to the fork route, with the chat's revision and a key, and accepts only a /// new chat in that workspace that records this chat as its source. diff --git a/ios/AidenOnTheGoTests/AidenRemotePhase0Tests.swift b/ios/AidenOnTheGoTests/AidenRemotePhase0Tests.swift index e76ffc9378..945f79577c 100644 --- a/ios/AidenOnTheGoTests/AidenRemotePhase0Tests.swift +++ b/ios/AidenOnTheGoTests/AidenRemotePhase0Tests.swift @@ -171,7 +171,7 @@ final class AidenRemotePhase0Tests: XCTestCase { from: data ) - XCTAssertEqual(fixture.contractRevision, 67) + XCTAssertEqual(fixture.contractRevision, 68) XCTAssertEqual(fixture.streamRecovery?.capability, .streamSnapshotReasons) XCTAssertEqual(fixture.streamRecovery?.gapEvents.first?.payload?.reason, .gap) XCTAssertNil(fixture.streamRecovery?.legacyGapSnapshot.payload?.reason) @@ -2017,7 +2017,7 @@ final class AidenRemotePhase0Tests: XCTestCase { let url = try XCTUnwrap(sharedContractFixtureURL) let data = try Data(contentsOf: url) let fixture = try AidenRemoteJSONDecoder.decode(AidenRemoteContractFixture.self, from: data) - XCTAssertEqual(fixture.contractRevision, 67) + XCTAssertEqual(fixture.contractRevision, 68) let recovery = try XCTUnwrap(fixture.streamRecovery) XCTAssertEqual(recovery.capability, .streamSnapshotReasons) XCTAssertEqual(recovery.gapEvents.map(\.sequence), [4097, 4098, 4099]) diff --git a/ios/AidenOnTheGoTests/AidenUnifiedInboxTests.swift b/ios/AidenOnTheGoTests/AidenUnifiedInboxTests.swift index 32bab90550..cf7741edb1 100644 --- a/ios/AidenOnTheGoTests/AidenUnifiedInboxTests.swift +++ b/ios/AidenOnTheGoTests/AidenUnifiedInboxTests.swift @@ -421,6 +421,7 @@ final class AidenUnifiedInboxTests: XCTestCase { name: String? = nil, state: String? = "idle", issues: Int? = nil, + needsYou: Bool = false, minutesAgo: Double = 5 ) -> AidenBotSummary { let formatter = ISO8601DateFormatter() @@ -438,6 +439,7 @@ final class AidenUnifiedInboxTests: XCTestCase { if let state { object["sessionState"] = state } if state == "paused" { object["paused"] = true } if let issues { object["issueCount"] = issues } + if needsYou { object["needsYou"] = true } let data = try! JSONSerialization.data(withJSONObject: object) return try! AidenRemoteJSONDecoder.decode(AidenBotSummary.self, from: data) } @@ -474,6 +476,22 @@ final class AidenUnifiedInboxTests: XCTestCase { XCTAssertEqual(offline.needsYouCount, 0) } + /// Revision 68 (`bot:needs-you`): a running Bot waiting on an approval or a + /// question leaves the accessory for Needs you, and says it is waiting. + func testARunningBotWaitingOnThePersonNeedsYouInsteadOfWorking() { + let scout = bot("bot_scout", name: "Scout", state: "running", needsYou: true, minutesAgo: 9) + XCTAssertTrue(scout.needsYou) + XCTAssertTrue(AidenBotAttention.needsYou(scout)) + XCTAssertEqual(AidenBotAttention.reason(scout), "Waiting for you") + XCTAssertEqual(AidenBotAttention.reason(bot("bot_cards", needsYou: true, issues: 2)), "2 things need you", "the count says more") + let inbox = make([snapshot("mac-a", bots: [scout, bot("bot_busy", state: "running")])]) + XCTAssertEqual(labels(inbox.needsYou), ["mac-a:bot_scout"]) + XCTAssertEqual(labels(inbox.running), ["mac-a:bot_busy"]) + XCTAssertEqual(inbox.needsYouCount, 1) + // A Mac without revision 68 never sends it; the Bot reads as working. + XCTAssertFalse(bot("bot_old", state: "running").needsYou) + } + func testAnIdleOrPausedBotStaysOutOfInbox() { let quiet = [ bot("bot_idle"), diff --git a/ios/CHANGELOG.md b/ios/CHANGELOG.md index 4946cb2f4f..bb1675b0c6 100644 --- a/ios/CHANGELOG.md +++ b/ios/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- **2026-11-24 — Bots waiting on you (provisional Remote revision 68, `bot:needs-you`).** On a Mac that offers it, the app asks for `bot:needs-you` in a call of its own. A Bot the Mac says waits on the person reads "Waiting for you" on its Bots row and is no longer shown as working, and the Inbox lists it under Needs you with that reason (after an open-issue count). An approval the phone can see in the Bot's chat keeps its own line. Other Macs look as before. + - **2026-11-22 — Pairing feedback and QR framing.** Add Computer scans for QR codes inside the visible viewfinder. Manual pairing shows what to correct below the address or setup code field. Search keeps Add Computer available until a computer is paired. - **2026-11-22 — No "Sending…" in Bot chats.** A message you send to a Bot looks sent from the moment you press Send and never gains a "Sending…" caption, however long the Mac takes to take it. The status line ("Getting ready", then "Thinking" once the model starts) shows the wait; Queued and "Couldn’t send · Try again" are unchanged. Paired Macs on the next Aiden release also start a Bot's reply much sooner, because a turn no longer re-reads every provider, connector and skill a dozen times before asking the model. No Remote wire or revision change. diff --git a/ios/CONTRACT_TESTS.md b/ios/CONTRACT_TESTS.md index f9a18a7b74..beb01185cf 100644 --- a/ios/CONTRACT_TESTS.md +++ b/ios/CONTRACT_TESTS.md @@ -26,6 +26,8 @@ Background job chat-settled revision 63 adds `testAJobStoppedAfterTheChatWentQui Continue in a new chat revision 64 decodes the shared `contract.json` `continueInNewChat` fixture in three `AidenRemoteClientTests` methods. One checks the refusal's details with and without them and with an unknown reason, and that only a refusal with `canContinueInNewChat: true` offers the action. One checks the opt-in, which is asked for alone. The third checks the `{"continueIn":{"workspaceId"}}` fork body with If-Match and a key, and refuses a new chat in another workspace. Two `AidenChatTests` methods run the view model against a fixture Mac. In one, a refusal offers the action, the picker lists only the other real workspaces, the Mac's fork refusal shows in the picker, and a second attempt with a new key opens the new chat while the original stays as it was. In the other, a refusal without details, or one that declines, offers nothing and sends no fork. Android mirrors these in its own contract and view-model tests. +Bots waiting on you revision 68 adds `testBotNeedsYouIsAnOptInNegotiatedAlone` in `AidenRemoteClientTests` (the opt-in is asked for alone and only when offered), `testARunningBotWaitingOnThePersonNeedsYouInsteadOfWorking` in `AidenUnifiedInboxTests`, and `testHomeRowSaysWaitingForYouWhenTheMacSaysTheBotNeedsThePerson` in `AidenBotHomeProfileTests`. Android mirrors them in `AidenBotHomeBehaviorTest`, which also checks that `needsYou` decodes only as a JSON boolean and is not written back when false. + Phase P simulator evidence (2026-11-03): iPhone 17 / iOS 26.5, destination `D3907662-B204-4C8F-A591-7A3EDC38D048`, unsigned development XCTest. The broad run selected 464 tests: 457 passed and seven skipped, `TEST SUCCEEDED`, exit 0. After the result-only `final: true` transcript addition, 360 selected tests passed with 356 passes and four skips, `TEST SUCCEEDED`, exit 0: peer38, session48, optimistic65, watch28, notifier7 and Remote174. The additional peer skip independently confirms that this Simulator omits Data Protection metadata even for a system-written protected control file; physical verification remains required. Verbose post-test diagnostic collection stalled after the broad suite completed; only its task-owned `simctl diagnose` child was terminated before Xcode finalized successfully. The final narrow run used the supported `-collect-test-diagnostics never` option, without changing test retries or timeouts. The first new-test run exposed a GET-body helper assumption and an unsupported Simulator protection-metadata assertion, both corrected. Three initial journal-backed cases also observed an absent pending request; that original log did not capture the pre-send filesystem outcome or POST count, so their underlying cause remains unproven. The diagnostic and final tests now independently assert admission reached the host exactly once, the scoped journal retains the exact action/UUID, and replay or matching host acknowledgement settles it. Passing reruns alone are not claimed as a fix for that initial limitation. Concise logs and structured evidence are retained in `/tmp/aiden-peers-ios-summary.json` and the referenced log/summary files; task DerivedData is disposable. diff --git a/ios/PROJECT_SPEC.md b/ios/PROJECT_SPEC.md index 170f659424..b4abac88eb 100644 --- a/ios/PROJECT_SPEC.md +++ b/ios/PROJECT_SPEC.md @@ -38,6 +38,7 @@ The complete planned product includes: - Bot access requests (`bot:access-requests`, contract revision 55): negotiated in a separate call only when announced. Durable Bot chats render strict bounded cards and the host's exact offered choices. Whole-Mac access is once-only. Answers use a retained per-wait idempotency key and original body after an uncertain response. Expired cards stay dismissed; other failures restore the card unless a newer feed update superseded it. Access-needed issues and folder-grant actions are shown only to capability holders. Legacy clients receive a Mac-action notice that a settling snapshot removes. - Bot messaging (`bot:messaging`, contract revision 54): negotiated alone when the host offers it. The Bots list has a global switch, and Advanced → Other Bots has receive and send switches. Global off disables the per-Bot controls; older hosts show none. Each per-Bot patch contains only the changed messaging field and uses the current Bot revision. Labelled transcript messages retain clean text and bounded saved answers while paused. Message notification taps only navigate to that Bot's chat and preserve host preview redaction. - Bot UX on a revision 61 Mac (`approval:cards`, `approvals:settings`, `bot:settings-changes`, `bot:suggestions`, `bot:templates`, provisional contract revision 61): each negotiated in its own call when the Mac lists it. Holders render the Mac's typed approval card and send only a button's own decision and scope, answer held settings changes, skill proposals, lessons and memory tidy-ups from the Bot's chat, open versioned Templates and create a Bot from one name field, and read and set the Mac's approval mode and rules in Settings → Approvals. Answers are optimistic and roll back on refusal; a 404 means the card is gone. Without a capability the matching screen stays as before. Client-only on the same Mac: two-step Take Control, one Can message other Bots switch, Disable a Tool, and a per-device Show tool activity switch. +- Bots waiting on the person (`bot:needs-you`, provisional contract revision 68): negotiated in its own `POST /device/capabilities` call when the Mac lists it. A `GET /bots` summary with `needsYou: true` reads "Waiting for you" on its Bots row and is not shown as working; the unified inbox lists the Bot under Needs you with that reason after an open-issue count. An approval the phone can see keeps its own line. - Bot issues (`bot:issues`, contract revision 42): negotiated in its own `POST /device/capabilities` call when the Mac lists it. A Bot's **Needs you** cards appear in its chat with a title, body and up to two actions (Resume routine, Stop, Keep waiting, Open chat); a card whose only action opens the Mac's settings reads "Open on your Mac". The Bots list shows how many open cards a Bot has. Actions are sent to `POST /bots/{botId}/issues/{issueId}/act` under one request UUID, and `not_open` means the card is already answered or gone. Older Macs send no cards. - Browser recordings (`chat-browser-recordings-v1`, contract revision 46): a completed `browser_recording_stop` step may carry a display-only recap (id, type, length, size). The transcript shows a card under the step's activity line with its length and size. When the Mac announces the feature, Play reads an MP4 from `GET /chats/{chatId}/recordings/{recordingId}` only on demand, keeps it in a separate temporary file for that Play, and removes it when the player closes or the card leaves or changes, including delivery before presentation and late completion after navigation. A WebM recording or a Mac without the feature says to watch it on the Mac, and a 404 says the recording is no longer on the Mac. A malformed or misplaced recap is dropped and the step still shows. - Exactly one persistent chat per Bot. Every Bot entry point resumes it and creates it only when absent; legacy duplicate records are recoverable but not a second writable conversation. diff --git a/main/services/aiden-remote-protocol.test.ts b/main/services/aiden-remote-protocol.test.ts index 9f342315c7..a368749d18 100644 --- a/main/services/aiden-remote-protocol.test.ts +++ b/main/services/aiden-remote-protocol.test.ts @@ -3622,7 +3622,7 @@ test("revision 56 plans decode strictly, preserve absent versus null, and exclud const section = protocol.parseAidenRemoteContractFixture(raw).botPlans!; assert.deepEqual(section, raw.botPlans); assert.equal(protocol.AIDEN_REMOTE_BOT_PLANS_CONTRACT_REVISION, 56); - assert.equal(protocol.AIDEN_REMOTE_CONTRACT_REVISION, 67); + assert.equal(protocol.AIDEN_REMOTE_CONTRACT_REVISION, 68); assert.equal(section.pending.status, "pending"); assert.equal(section.active.steps[0].status, "done"); const parse = protocol.parseAidenRemoteBotPlan; @@ -3709,7 +3709,7 @@ test("revision 57 allowed fixture is strict and exposes only bounded public list const raw = await json("fixtures/contract.json") as Record; const section = protocol.parseAidenRemoteContractFixture(raw).botAllowed!; assert.deepEqual(section, raw.botAllowed); - assert.equal(protocol.AIDEN_REMOTE_BOT_ALLOWED_CONTRACT_REVISION, 57); assert.equal(protocol.AIDEN_REMOTE_CONTRACT_REVISION, 67); + assert.equal(protocol.AIDEN_REMOTE_BOT_ALLOWED_CONTRACT_REVISION, 57); assert.equal(protocol.AIDEN_REMOTE_CONTRACT_REVISION, 68); const all = [...section.paginated.firstPage.entries, ...section.paginated.nextPage.entries]; assert.equal(all.length, 53); assert.equal(all.filter(e => e.kind === "rule").length, 50); assert.equal(all.filter(e => e.kind === "folder").length, 3); assert.equal(new Set(all.map(e => e.id)).size, 53); @@ -3818,7 +3818,7 @@ test("revision 62 reads only the steps Stop cancelled as stopped, and every othe const protocol = await import("./aiden-remote-protocol.js"); const raw = await json("fixtures/contract.json") as Record; assert.equal(protocol.AIDEN_REMOTE_STOPPED_BY_USER_CONTRACT_REVISION, 62); - assert.equal(protocol.AIDEN_REMOTE_CONTRACT_REVISION, 67); + assert.equal(protocol.AIDEN_REMOTE_CONTRACT_REVISION, 68); const fixture = protocol.parseAidenRemoteContractFixture(raw).stoppedSteps; assert.ok(fixture); assert.deepEqual(fixture.stoppedStepIds, ["tool-3"]); @@ -3926,7 +3926,7 @@ test("revision 65 distinguishes gap recovery snapshots from provider resets and const protocol = await import("./aiden-remote-protocol.js"); const raw = await json("fixtures/contract.json") as Record; assert.equal(protocol.AIDEN_REMOTE_STREAM_SNAPSHOT_REASONS_CONTRACT_REVISION, 65); - assert.equal(protocol.AIDEN_REMOTE_CONTRACT_REVISION, 67); + assert.equal(protocol.AIDEN_REMOTE_CONTRACT_REVISION, 68); const parsedFixture = protocol.parseAidenRemoteContractFixture(raw); const section = parsedFixture.streamRecovery; assert.ok(section); @@ -4044,7 +4044,7 @@ test("revision 66 host feed Bot rows carry a one-line preview and refuse anythin test("revision 67 session pages and queued withdraw receipts decode strictly and match the OpenAPI contract", async () => { const protocol = await import("./aiden-remote-protocol.js"); assert.equal(protocol.AIDEN_REMOTE_BOT_SESSION_PAGES_CONTRACT_REVISION, 67); - assert.equal(protocol.AIDEN_REMOTE_CONTRACT_REVISION, 67); + assert.equal(protocol.AIDEN_REMOTE_CONTRACT_REVISION, 68); const raw = await json("fixtures/contract.json") as Record; const entries = (raw.botSession.entries as unknown[]).slice(0, 2); const page = { botId: raw.botSession.botId, epoch: raw.botSession.epoch, entries, hasOlder: true }; @@ -4071,3 +4071,27 @@ test("revision 67 session pages and queued withdraw receipts decode strictly and assert.equal(spec.paths["/bots/{botId}/session/entries"].get.operationId, "getBotSessionEntries"); assert.equal(spec.paths["/bots/{botId}/queued/{submissionId}/withdraw"].post.operationId, "withdrawBotQueuedMessage"); }); + +test("revision 68 Bot summaries carry needsYou only as true, and the opt-in is negotiable", async () => { + const protocol = await import("./aiden-remote-protocol.js"); + assert.equal(protocol.AIDEN_REMOTE_BOT_NEEDS_YOU_CONTRACT_REVISION, 68); + assert.equal(protocol.AIDEN_REMOTE_CONTRACT_REVISION, 68); + assert.ok((protocol.AIDEN_REMOTE_NEGOTIABLE_CAPABILITIES as readonly string[]).includes("bot:needs-you")); + const raw = await json("fixtures/contract.json") as Record; + const bot = raw.botList.bots[0] as Record; + assert.equal(protocol.parseAidenRemoteBotSummary(bot).needsYou, undefined, "absent unless the host says so"); + assert.equal(protocol.parseAidenRemoteBotSummary({ ...bot, needsYou: true }).needsYou, true); + assert.throws(() => protocol.parseAidenRemoteBotSummary({ ...bot, needsYou: false }), /needsYou/u); + assert.throws(() => protocol.parseAidenRemoteBotSummary({ ...bot, needsYou: "yes" }), /needsYou/u); + + const { default: Ajv2020 } = await import("ajv/dist/2020.js"); + const { default: addFormats } = await import("ajv-formats"); + const spec = await json("openapi.json") as { components: Record }; + const ajv = new Ajv2020({ strict: false }); + addFormats(ajv); + const summary = ajv.compile({ $ref: "#/components/schemas/BotSummary", components: spec.components }); + assert.equal(summary({ ...bot, needsYou: true }), true, JSON.stringify(summary.errors)); + assert.equal(summary({ ...bot, needsYou: false }), false); + const update = ajv.compile({ $ref: "#/components/schemas/DeviceCapabilitiesUpdateRequest", components: spec.components }); + assert.equal(update({ accepts: ["bot:needs-you"] }), true, JSON.stringify(update.errors)); +}); diff --git a/main/services/aiden-remote-protocol.ts b/main/services/aiden-remote-protocol.ts index 16120f80a4..6b52e7614e 100644 --- a/main/services/aiden-remote-protocol.ts +++ b/main/services/aiden-remote-protocol.ts @@ -392,7 +392,16 @@ export const AIDEN_REMOTE_BOT_FEED_PREVIEW_CONTRACT_REVISION = 66 as const; * older than this revision answers both with 404, and the client says so. */ export const AIDEN_REMOTE_BOT_SESSION_PAGES_CONTRACT_REVISION = 67 as const; -export const AIDEN_REMOTE_CONTRACT_REVISION = AIDEN_REMOTE_BOT_SESSION_PAGES_CONTRACT_REVISION; +/** + * Contract revision 68 (provisional; re-claim the next free number at merge): + * the `bot:needs-you` opt-in. A device holding it reads `needsYou: true` on a + * `GET /bots` summary while an approval, a question, a hand-off or an open + * issue waits on the person, the same signal the host feed's Bot rows carry + * (revision 52). Devices without it keep the summary shape they know, since + * Android's Bot decoder refuses unknown keys. + */ +export const AIDEN_REMOTE_BOT_NEEDS_YOU_CONTRACT_REVISION = 68 as const; +export const AIDEN_REMOTE_CONTRACT_REVISION = AIDEN_REMOTE_BOT_NEEDS_YOU_CONTRACT_REVISION; export const AIDEN_REMOTE_BASE_PATH = "/api/aiden/v1" as const; export const AIDEN_REMOTE_MAX_SSE_FRAME_BYTES = 1_048_576; export const AIDEN_REMOTE_MAX_JSON_RESPONSE_BYTES = 1_048_576; @@ -621,6 +630,12 @@ export const AIDEN_REMOTE_BOT_WATCH_CAPABILITIES = ["bot:watches"] as const; export const AIDEN_REMOTE_BOT_OPEN_WORK_CAPABILITIES = ["bot:open-work"] as const; export const AIDEN_REMOTE_BOT_ROUTINE_MODEL_CAPABILITIES = ["bot:routine-models"] as const; export const AIDEN_REMOTE_BOT_PEER_CAPABILITIES = ["bot:peers"] as const; +/** + * Contract revision 68: a device holding `bot:needs-you` reads `needsYou: true` + * on `GET /bots` summaries for a Bot waiting on the person. It grants no + * authority; any device type may hold it. + */ +export const AIDEN_REMOTE_BOT_NEEDS_YOU_CAPABILITIES = ["bot:needs-you"] as const; export type AidenRemoteBotIssueCapability = (typeof AIDEN_REMOTE_BOT_ISSUE_CAPABILITIES)[number]; @@ -650,6 +665,7 @@ export const AIDEN_REMOTE_BOT_OPT_IN_CAPABILITIES = [ ...AIDEN_REMOTE_BOT_OPEN_WORK_CAPABILITIES, ...AIDEN_REMOTE_BOT_ROUTINE_MODEL_CAPABILITIES, ...AIDEN_REMOTE_BOT_PEER_CAPABILITIES, + ...AIDEN_REMOTE_BOT_NEEDS_YOU_CAPABILITIES, ...AIDEN_REMOTE_BOT_SETTINGS_CHANGE_CAPABILITIES, ...AIDEN_REMOTE_BOT_SUGGESTION_CAPABILITIES, ...AIDEN_REMOTE_BOT_TEMPLATE_CAPABILITIES, @@ -763,6 +779,7 @@ export const AIDEN_REMOTE_NEGOTIABLE_CAPABILITIES = [ ...AIDEN_REMOTE_BOT_OPEN_WORK_CAPABILITIES, ...AIDEN_REMOTE_BOT_ROUTINE_MODEL_CAPABILITIES, ...AIDEN_REMOTE_BOT_PEER_CAPABILITIES, + ...AIDEN_REMOTE_BOT_NEEDS_YOU_CAPABILITIES, ...AIDEN_REMOTE_SCHEDULE_CARD_CAPABILITIES, ...AIDEN_REMOTE_CHAT_JOB_CAPABILITIES, ...AIDEN_REMOTE_RAW_UPLOAD_CAPABILITIES, @@ -799,6 +816,7 @@ export const AIDEN_REMOTE_CAPABILITIES = [ ...AIDEN_REMOTE_BOT_OPEN_WORK_CAPABILITIES, ...AIDEN_REMOTE_BOT_ROUTINE_MODEL_CAPABILITIES, ...AIDEN_REMOTE_BOT_PEER_CAPABILITIES, + ...AIDEN_REMOTE_BOT_NEEDS_YOU_CAPABILITIES, ...AIDEN_REMOTE_SCHEDULE_CARD_CAPABILITIES, ...AIDEN_REMOTE_CHAT_JOB_CAPABILITIES, ...AIDEN_REMOTE_RAW_UPLOAD_CAPABILITIES, @@ -1435,6 +1453,12 @@ export type AidenRemoteBotSummary = AidenRemoteBotSummaryBase & { * the Bot's card list holds. Sent only while it is above zero. */ issueCount?: number; + /** + * Contract revision 68, only on `GET /bots` for `bot:needs-you` devices: an + * approval, a question, a hand-off or an open issue waits on the person. + * Sent only as `true`. + */ + needsYou?: true; }; export interface AidenRemoteBotCustomSelection { @@ -3438,7 +3462,14 @@ export function parseAidenRemoteBotSummary(value: unknown): AidenRemoteBotSummar const issueCount = hasOwn(record, "issueCount") ? boundedIntegerValue(record.issueCount, "Bot issueCount", 0, BOT_ISSUE_LIMITS.openPerBot) : undefined; - const withIssues = issueCount === undefined ? summary : { ...summary, issueCount }; + if (hasOwn(record, "needsYou") && record.needsYou !== true) { + throw new Error("Bot summary needsYou must be true when present."); + } + const withIssues = { + ...summary, + ...(issueCount === undefined ? {} : { issueCount }), + ...(record.needsYou === true ? { needsYou: true as const } : {}), + }; if (!hasOwn(record, "paused")) { assertBotPausedAgreesWithState(summary.sessionState, false, "Bot summary"); return withIssues; diff --git a/main/services/aiden-remote-router.test.ts b/main/services/aiden-remote-router.test.ts index 8e45878215..a112ee2123 100644 --- a/main/services/aiden-remote-router.test.ts +++ b/main/services/aiden-remote-router.test.ts @@ -26,6 +26,7 @@ import { parseAidenRemoteBackgroundJobs, parseAidenRemoteChatNewWorktreeResponse, parseAidenRemoteBotCreateRequest, + parseAidenRemoteBotList, parseAidenRemoteStreamEvent, type AidenRemoteCapability, type AidenRemoteStreamInputResult, @@ -141,6 +142,8 @@ async function fixture(options: { /** With `forks`: the host can continue a chat whose folder is gone in a new chat (revision 64). */ continueInNewChat?: boolean; streamsOverride?: import("./aiden-remote-router.js").AidenRemoteRouterDependencies["streams"]; + /** Contract revision 68: which Bots wait on the person. */ + botNeedsYou?: import("./aiden-remote-router.js").AidenRemoteRouterDependencies["botNeedsYou"]; } = {}) { const logs: unknown[] = []; const calls: string[] = []; @@ -313,7 +316,8 @@ async function fixture(options: { capability !== "bot:suggestions" && capability !== "bot:templates" && capability !== "chat:continue-in-new-chat" && - capability !== "stream:snapshot-reasons", + capability !== "stream:snapshot-reasons" && + capability !== "bot:needs-you", ) ) { return null; @@ -629,6 +633,7 @@ async function fixture(options: { ...(options.providers ? { providers: options.providers } : {}), ...(options.spending ? { spending: options.spending } : {}), ...(options.backgroundJobs ? { backgroundJobs: options.backgroundJobs } : {}), + ...(options.botNeedsYou ? { botNeedsYou: options.botNeedsYou } : {}), models: { list: async () => ({ providers: [{ @@ -7819,3 +7824,56 @@ test("revision 67: a device pages back through a Bot's chat and takes back a que 'withdraw:12345678:bot-1:42:withdraw-key-00000001:{}', ]); }); + +test("revision 68: only a device holding bot:needs-you reads needsYou on its Bot list, and only where the host wires it", async () => { + const headers = { authorization: `Bearer ${"a".repeat(43)}`, "aiden-protocol-version": "1" }; + const negotiate = { + method: "POST", + headers: { ...headers, "content-type": "application/json" }, + body: JSON.stringify({ accepts: ["bot:needs-you"] }), + }; + const asked: string[][] = []; + const waiting = async (botIds: readonly string[]) => { + asked.push([...botIds]); + return new Set(["bot-1"]); + }; + for (const [label, capabilities, wired, expected] of [ + ["holder", ["server:read", "bot:read", "bot:needs-you"], true, true], + ["older phone", ["server:read", "bot:read"], true, undefined], + ["unwired host", ["server:read", "bot:read", "bot:needs-you"], false, undefined], + ] as Array<[string, AidenRemoteCapability[], boolean, true | undefined]>) { + const app = await fixture({ + capabilities, + acceptsBotCapabilities: true, + deviceType: "android", + ...(wired ? { botNeedsYou: waiting } : {}), + }); + try { + const server = await (await fetch(`${app.base}/server`, { headers })).json(); + assert.equal(server.serverCapabilities.includes("bot:needs-you"), wired, label); + assert.equal((await fetch(`${app.base}/device/capabilities`, negotiate)).status, wired ? 200 : 404, label); + const list = await (await fetch(`${app.base}/bots`, { headers })).json(); + assert.equal(list.bots[0].needsYou, expected, label); + // What the device reads still passes the shared parser. + parseAidenRemoteBotList(list); + } finally { + await app.close(); + } + } + assert.deepEqual(asked, [["bot-1"]], "only the holder's list asks which Bots wait"); + + // A failed read lists the Bots without the signal instead of failing the list. + const app = await fixture({ + capabilities: ["server:read", "bot:read", "bot:needs-you"], + acceptsBotCapabilities: true, + deviceType: "iphone", + botNeedsYou: async () => { throw new Error("projection unavailable"); }, + }); + try { + const response = await fetch(`${app.base}/bots`, { headers }); + assert.equal(response.status, 200); + assert.equal((await response.json()).bots[0].needsYou, undefined); + } finally { + await app.close(); + } +}); diff --git a/main/services/aiden-remote-router.ts b/main/services/aiden-remote-router.ts index f7418eef43..2553298126 100644 --- a/main/services/aiden-remote-router.ts +++ b/main/services/aiden-remote-router.ts @@ -72,6 +72,7 @@ import { AIDEN_REMOTE_BOT_OPEN_WORK_CAPABILITIES, AIDEN_REMOTE_BOT_ROUTINE_MODEL_CAPABILITIES, AIDEN_REMOTE_BOT_PEER_CAPABILITIES, + AIDEN_REMOTE_BOT_NEEDS_YOU_CAPABILITIES, AIDEN_REMOTE_BOT_ACTIVITY_FEATURE, AIDEN_REMOTE_BOT_ATTACHMENTS_FEATURE, AIDEN_REMOTE_BOT_CARD_CAPABILITIES, @@ -355,6 +356,12 @@ export interface AidenRemoteRouterDependencies { "listConversations" | "putAvatar" | "deleteAvatar" | "avatarContent" | "delete" | "supportsChatActivity" | "supportsBotMessaging" | "updateMessaging" >>; + /** + * Contract revision 68 (`bot:needs-you`): which of these Bots wait on the + * person (an approval, a question, a hand-off or an open issue). Absent: the + * opt-in is never offered and `GET /bots` summaries never carry `needsYou`. + */ + botNeedsYou?: (botIds: readonly string[]) => Promise>; /** * Durable Bot sessions, routines, connection requests and starter presets * (contract revision 25). Absent: those routes are `not_found` and their @@ -2318,6 +2325,25 @@ function botPeersWired(dependencies: AidenRemoteRouterDependencies): boolean { return !!port && (port.isReady === undefined || typeof port.isReady === "function" && port.isReady() === true) && (["settings", "catalog", "mutate", "exchanges", "exchange", "stop", "evidence"] as const).every((method) => typeof port[method] === "function"); } +/** Revision 68: the `needsYou` signal ships only where the host can compute it. */ +function botNeedsYouWired(dependencies: AidenRemoteRouterDependencies): boolean { + return typeof dependencies.botNeedsYou === "function" && dependencies.bots !== undefined; +} +function holdsBotNeedsYou(device: AidenRemoteRouterAuthenticatedDevice, dependencies: AidenRemoteRouterDependencies): boolean { + return device.capabilities.has("bot:needs-you") && botNeedsYouWired(dependencies); +} +/** Revision 68: `needsYou: true` on the summaries of Bots waiting on the person, for holders only. */ +async function withBotNeedsYou( + summaries: readonly AidenRemoteBotSummary[], + device: AidenRemoteRouterAuthenticatedDevice, + dependencies: AidenRemoteRouterDependencies, +): Promise { + const visible = summaries.map(({ needsYou: _hidden, ...summary }) => summary); + if (!holdsBotNeedsYou(device, dependencies) || visible.length === 0) return visible; + // A failed read leaves the list as it was, without the signal. + const waiting = await dependencies.botNeedsYou!(visible.map(({ id }) => id)).catch(() => new Set()); + return visible.map((summary) => (waiting.has(summary.id) ? { ...summary, needsYou: true as const } : summary)); +} function holdsBotPeers(device: AidenRemoteRouterAuthenticatedDevice, dependencies: AidenRemoteRouterDependencies): boolean { return device.acceptsBotCapabilities === true && device.capabilities.has("bot:peers") && botPeersWired(dependencies); } @@ -2373,6 +2399,8 @@ function advertisedServerCapabilities( : []), ...(device.acceptsBotCapabilities === true && botRoutineModelsWired(dependencies) ? AIDEN_REMOTE_BOT_ROUTINE_MODEL_CAPABILITIES : []), ...(device.acceptsBotCapabilities === true && botPeersWired(dependencies) ? AIDEN_REMOTE_BOT_PEER_CAPABILITIES : []), + // Revision 68: offered only while the host can say which Bots wait on the person. + ...(device.acceptsBotCapabilities === true && botNeedsYouWired(dependencies) ? AIDEN_REMOTE_BOT_NEEDS_YOU_CAPABILITIES : []), ...(device.acceptsBotCapabilities === true && botOpenWorkWired(dependencies) ? AIDEN_REMOTE_BOT_OPEN_WORK_CAPABILITIES : []), ...(device.acceptsBotCapabilities === true && botWatchesWired(dependencies) ? AIDEN_REMOTE_BOT_WATCH_CAPABILITIES : []), // Revision 42: offered only while the issue act route is wired. @@ -2865,6 +2893,9 @@ export function createAidenRemoteRequestHandler( if (!botIssuesWired(dependencies)) { throw new AidenRemoteServiceError("not_found", "Bot issues are unavailable on this Aiden installation.", 404); } + } else if ((AIDEN_REMOTE_BOT_NEEDS_YOU_CAPABILITIES as readonly string[]).includes(capability)) { + // Revision 68: a display opt-in, offered only while the signal is wired. + if (!botNeedsYouWired(dependencies)) throw new AidenRemoteServiceError("not_found", "Bot attention is unavailable on this Aiden installation.", 404); } else if ((AIDEN_REMOTE_BOT_MESSAGING_CAPABILITIES as readonly string[]).includes(capability)) { if (!botMessagingWired(dependencies)) throw new AidenRemoteServiceError("not_found", "Bot messaging is unavailable on this Aiden installation.", 404); } else if ((AIDEN_REMOTE_APPROVAL_CARD_CAPABILITIES as readonly string[]).includes(capability)) { @@ -2996,7 +3027,11 @@ export function createAidenRemoteRequestHandler( writeJson(response, 200, { ...list, ...(holdsBotMessaging(device, dependencies) && messaging ? {messaging} : {}), - bots: await Promise.all(list.bots.map((summary) => botSummaryForAudience(summary, device, dependencies))), + bots: await withBotNeedsYou( + await Promise.all(list.bots.map((summary) => botSummaryForAudience(summary, device, dependencies))), + device, + dependencies, + ), }); return; } diff --git a/main/services/aiden-remote-service-main.ts b/main/services/aiden-remote-service-main.ts index 1647c53faf..87e6f1e364 100644 --- a/main/services/aiden-remote-service-main.ts +++ b/main/services/aiden-remote-service-main.ts @@ -1349,6 +1349,16 @@ async function createRuntime(): Promise { botFiles, bots, botSessions, + // Revision 68 (`bot:needs-you`): the same signal this Mac's own Bot rows, the host feed + // and the Dock badge use, read without the transcript. + botNeedsYou: async (botIds: readonly string[]) => { + const { botLiveProjection } = await import("./bot-runtime/bot-session-main.js"); + const live = botLiveProjection(); + const waiting = await mapWithConcurrency(botIds, 4, async (botId) => + (await live.needsYou(botId).catch(() => false)) ? botId : null, + ); + return new Set(waiting.filter((botId): botId is string => botId !== null)); + }, botOpenWork: (await import("./bot-open-work/service-main.js")).botOpenWork, botRoutineModels: { ...(await import("./bot-routine-models-main.js")).botRoutineModels, resumeStatus: async (botId: string) => (await (await import("./bot-runtime/bot-session-main.js")).botSessionRuntime()).executionResumeStatus(botId) }, botPeers: (await import("./bot-peers/service-main.js")).botPeers, diff --git a/main/services/aiden-remote-state.test.ts b/main/services/aiden-remote-state.test.ts index da442fce8b..b0b4f21c80 100644 --- a/main/services/aiden-remote-state.test.ts +++ b/main/services/aiden-remote-state.test.ts @@ -993,8 +993,8 @@ test("bot:activity is an opt-in any paired device may negotiate and keep", async assert.equal(authenticated?.acceptsProgressCapabilities, false, "an opt-in is not a progress grant"); }); -test("bot:handoffs, schedule:cards, chat:jobs, chat:new-worktree, chat:continue-in-new-chat and stream:snapshot-reasons are opt-ins pairing never issues and any paired device may negotiate and keep", async () => { - for (const optIn of ["bot:handoffs", "schedule:cards", "chat:jobs", "chat:new-worktree", "chat:continue-in-new-chat", "stream:snapshot-reasons"] as const) { +test("bot:handoffs, schedule:cards, chat:jobs, chat:new-worktree, chat:continue-in-new-chat, stream:snapshot-reasons and bot:needs-you are opt-ins pairing never issues and any paired device may negotiate and keep", async () => { + for (const optIn of ["bot:handoffs", "schedule:cards", "chat:jobs", "chat:new-worktree", "chat:continue-in-new-chat", "stream:snapshot-reasons", "bot:needs-you"] as const) { const state = fixture(); const devices = []; for (const type of ["iphone", "android", "mac"] as const) { diff --git a/protocol/aiden-remote/v1/fixtures/contract.json b/protocol/aiden-remote/v1/fixtures/contract.json index 988b852134..2e83c0cf5f 100644 --- a/protocol/aiden-remote/v1/fixtures/contract.json +++ b/protocol/aiden-remote/v1/fixtures/contract.json @@ -1,5 +1,5 @@ { - "contractRevision": 67, + "contractRevision": 68, "peerRouteAdvertisement": { "feature": "peer-routes-v1", "routes": [ @@ -2299,7 +2299,7 @@ "instanceId": "instance_fixture_01", "displayName": "Fixture Aiden", "platform": "mac", - "contractRevision": 67, + "contractRevision": 68, "pairingRequests": true }, "hostFeedEvents": [ diff --git a/protocol/aiden-remote/v1/openapi.json b/protocol/aiden-remote/v1/openapi.json index 404bdf1303..ea19f4f3cd 100644 --- a/protocol/aiden-remote/v1/openapi.json +++ b/protocol/aiden-remote/v1/openapi.json @@ -10250,6 +10250,7 @@ "bot:open-work", "bot:routine-models", "bot:peers", + "bot:needs-you", "schedule:cards", "chat:jobs", "attachments:raw", @@ -10311,6 +10312,7 @@ "bot:open-work", "bot:routine-models", "bot:peers", + "bot:needs-you", "schedule:cards", "chat:jobs", "attachments:raw", @@ -10475,6 +10477,7 @@ "bot:open-work", "bot:routine-models", "bot:peers", + "bot:needs-you", "schedule:cards", "chat:jobs", "attachments:raw", @@ -10545,6 +10548,7 @@ "bot:open-work", "bot:routine-models", "bot:peers", + "bot:needs-you", "schedule:cards", "chat:jobs", "attachments:raw", @@ -12876,6 +12880,10 @@ "type": "integer", "minimum": 1, "maximum": 8 + }, + "needsYou": { + "const": true, + "description": "Contract revision 68, only on GET /bots for devices holding bot:needs-you: an approval, a question, a hand-off or an open issue waits on the person. Sent only as true." } }, "additionalProperties": false From 20cbdf9f101c80e65dd6aad79bf41f902cd7e296 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 08:06:18 +0000 Subject: [PATCH 2/4] iOS Bots row keeps the approval line when the Bot needs you Mirror Android: a conversation waiting on an approval reads "Needs your OK" or "Waiting for your OK on your Mac" instead of the generic waiting line. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_018VA6REg8PpdXdPfTkkCKZJ --- .../Features/Bots/AidenBotSessionModel.swift | 3 +++ .../Features/Bots/AidenBotsHomeView.swift | 11 ++++++-- .../AidenBotHomeProfileTests.swift | 27 ++++++++++++++++++- ios/CHANGELOG.md | 2 +- 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/ios/AidenOnTheGo/Features/Bots/AidenBotSessionModel.swift b/ios/AidenOnTheGo/Features/Bots/AidenBotSessionModel.swift index 3ae2a59cce..0f8b27025c 100644 --- a/ios/AidenOnTheGo/Features/Bots/AidenBotSessionModel.swift +++ b/ios/AidenOnTheGo/Features/Bots/AidenBotSessionModel.swift @@ -277,6 +277,9 @@ enum AidenBotSessionCopy { static let needsModel = "Needs an AI model" /// Revision 68: an approval, a question or a hand-off waits on the person. static let waitingForYou = "Waiting for you" + /// A run waits on an approval this phone may answer, or only the Mac can. + static let needsYourOK = "Needs your OK" + static let waitingForYourOKOnMac = "Waiting for your OK on your Mac" static let needsModelHint = "Set up on your computer" static let setUp = "Set up" static let queued = "Queued" diff --git a/ios/AidenOnTheGo/Features/Bots/AidenBotsHomeView.swift b/ios/AidenOnTheGo/Features/Bots/AidenBotsHomeView.swift index a7d65c4320..729420d003 100644 --- a/ios/AidenOnTheGo/Features/Bots/AidenBotsHomeView.swift +++ b/ios/AidenOnTheGo/Features/Bots/AidenBotsHomeView.swift @@ -158,15 +158,22 @@ struct AidenBotHomeRow: Equatable, Identifiable { /// A wait on the person comes first (revision 68: an approval, a question, /// a hand-off or an open issue), then the durable session state: an /// interrupted turn, a Bot the person paused (revision 37) or a missing - /// model says so; otherwise the last message, or a greeting prompt. + /// model says so; then an approval this phone can see, which keeps its own + /// line as on Android; otherwise the last message, or a greeting prompt. var preview: String { - if bot.needsYou { return AidenBotSessionCopy.waitingForYou } + let waitsOnApproval = conversation?.activityState == .waitingForApproval + if bot.needsYou && !waitsOnApproval { return AidenBotSessionCopy.waitingForYou } switch bot.sessionState { case .interrupted: return AidenBotSessionCopy.interruptedSubtitle case .paused: return AidenBotSessionCopy.pausedSubtitle case .needsModel: return AidenBotSessionCopy.needsModel default: break } + if let conversation, waitsOnApproval { + return conversation.canRespondToApproval + ? AidenBotSessionCopy.needsYourOK + : AidenBotSessionCopy.waitingForYourOKOnMac + } let text = (conversation?.preview ?? "").trimmingCharacters(in: .whitespacesAndNewlines) return text.isEmpty ? "Say hello" : text } diff --git a/ios/AidenOnTheGoTests/AidenBotHomeProfileTests.swift b/ios/AidenOnTheGoTests/AidenBotHomeProfileTests.swift index 98bc72d9cb..d09d02049f 100644 --- a/ios/AidenOnTheGoTests/AidenBotHomeProfileTests.swift +++ b/ios/AidenOnTheGoTests/AidenBotHomeProfileTests.swift @@ -71,6 +71,7 @@ final class AidenBotHomeProfileTests: XCTestCase { botID: String, preview: String?, state: String = "idle", + canRespond: Bool = false, updatedAt: String ) throws -> AidenBotConversationItem { var object: [String: Any] = [ @@ -78,7 +79,7 @@ final class AidenBotHomeProfileTests: XCTestCase { "botId": botID, "title": "", "activityState": state, - "canRespondToApproval": false, + "canRespondToApproval": canRespond, "createdAt": "2026-08-18T17:00:00.000Z", "updatedAt": updatedAt, "revision": "chat-rev-\(botID)", @@ -174,6 +175,30 @@ final class AidenBotHomeProfileTests: XCTestCase { XCTAssertEqual(rows["busy"]?.preview, "Say hello") } + /// An approval the phone can see keeps its own line, also while the Mac + /// says the Bot waits on the person, as on Android. + func testHomeRowKeepsTheApprovalLineWhenTheBotAlsoNeedsThePerson() throws { + let bots = [ + try summary(id: "answerable", name: "A", updatedAt: "2026-08-18T18:00:00.000Z", sessionState: "running", needsYou: true), + try summary(id: "mac-only", name: "B", updatedAt: "2026-08-18T17:00:00.000Z", sessionState: "running", needsYou: true), + try summary(id: "plain", name: "C", updatedAt: "2026-08-18T16:00:00.000Z", sessionState: "running"), + ] + let conversations = [ + try conversation(botID: "answerable", preview: "Booking", state: "waiting_for_approval", canRespond: true, updatedAt: "2026-08-18T18:00:00.000Z"), + try conversation(botID: "mac-only", preview: "Booking", state: "waiting_for_approval", updatedAt: "2026-08-18T17:00:00.000Z"), + try conversation(botID: "plain", preview: "Booking", state: "waiting_for_approval", canRespond: true, updatedAt: "2026-08-18T16:00:00.000Z"), + ] + let rows = Dictionary(uniqueKeysWithValues: aidenBotHomeRows( + bots: bots, + conversations: conversations, + query: "" + ).map { ($0.id, $0) }) + XCTAssertEqual(rows["answerable"]?.preview, "Needs your OK") + XCTAssertEqual(rows["mac-only"]?.preview, "Waiting for your OK on your Mac") + XCTAssertEqual(rows["plain"]?.preview, "Needs your OK") + XCTAssertEqual(rows["answerable"]?.isWorking, false) + } + func testHomeSearchMatchesNameSubtitlePreviewAndServerMatches() throws { let bots = [ try summary(id: "chef", name: "Chef", purpose: "Meal prepping", updatedAt: "2026-08-18T18:00:00.000Z"), diff --git a/ios/CHANGELOG.md b/ios/CHANGELOG.md index bb1675b0c6..4514b9b7f6 100644 --- a/ios/CHANGELOG.md +++ b/ios/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -- **2026-11-24 — Bots waiting on you (provisional Remote revision 68, `bot:needs-you`).** On a Mac that offers it, the app asks for `bot:needs-you` in a call of its own. A Bot the Mac says waits on the person reads "Waiting for you" on its Bots row and is no longer shown as working, and the Inbox lists it under Needs you with that reason (after an open-issue count). An approval the phone can see in the Bot's chat keeps its own line. Other Macs look as before. +- **2026-11-24 — Bots waiting on you (provisional Remote revision 68, `bot:needs-you`).** On a Mac that offers it, the app asks for `bot:needs-you` in a call of its own. A Bot the Mac says waits on the person reads "Waiting for you" on its Bots row and is no longer shown as working, and the Inbox lists it under Needs you with that reason (after an open-issue count). A Bot waiting on an approval the phone can see in its chat reads "Needs your OK" (or "Waiting for your OK on your Mac" when only the Mac may answer) instead, as on Android, with or without this capability. Other Macs look as before. - **2026-11-22 — Pairing feedback and QR framing.** Add Computer scans for QR codes inside the visible viewfinder. Manual pairing shows what to correct below the address or setup code field. Search keeps Add Computer available until a computer is paired. From 12fd02f0f462da8364b23166bd9ffb65f7f018d7 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 09:48:12 +0000 Subject: [PATCH 3/4] Fix argument order in the iOS needs-you inbox test Swift requires the helper's labelled arguments in declaration order, so issues has to come before needsYou. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_018VA6REg8PpdXdPfTkkCKZJ --- ios/AidenOnTheGoTests/AidenUnifiedInboxTests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/AidenOnTheGoTests/AidenUnifiedInboxTests.swift b/ios/AidenOnTheGoTests/AidenUnifiedInboxTests.swift index cf7741edb1..add6f83212 100644 --- a/ios/AidenOnTheGoTests/AidenUnifiedInboxTests.swift +++ b/ios/AidenOnTheGoTests/AidenUnifiedInboxTests.swift @@ -483,7 +483,7 @@ final class AidenUnifiedInboxTests: XCTestCase { XCTAssertTrue(scout.needsYou) XCTAssertTrue(AidenBotAttention.needsYou(scout)) XCTAssertEqual(AidenBotAttention.reason(scout), "Waiting for you") - XCTAssertEqual(AidenBotAttention.reason(bot("bot_cards", needsYou: true, issues: 2)), "2 things need you", "the count says more") + XCTAssertEqual(AidenBotAttention.reason(bot("bot_cards", issues: 2, needsYou: true)), "2 things need you", "the count says more") let inbox = make([snapshot("mac-a", bots: [scout, bot("bot_busy", state: "running")])]) XCTAssertEqual(labels(inbox.needsYou), ["mac-a:bot_scout"]) XCTAssertEqual(labels(inbox.running), ["mac-a:bot_busy"]) From 85e3ca9123a83c7d82d2f624397995ecab38e121 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 12:55:25 +0000 Subject: [PATCH 4/4] Keep the iOS needs-you home row fixture's Bots updated after they were made The third Bot was updated at 16:00 but created at 17:00, so the summary decoder rejected it before the test could check its row. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_018VA6REg8PpdXdPfTkkCKZJ --- ios/AidenOnTheGoTests/AidenBotHomeProfileTests.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ios/AidenOnTheGoTests/AidenBotHomeProfileTests.swift b/ios/AidenOnTheGoTests/AidenBotHomeProfileTests.swift index d09d02049f..9755b063aa 100644 --- a/ios/AidenOnTheGoTests/AidenBotHomeProfileTests.swift +++ b/ios/AidenOnTheGoTests/AidenBotHomeProfileTests.swift @@ -180,13 +180,13 @@ final class AidenBotHomeProfileTests: XCTestCase { func testHomeRowKeepsTheApprovalLineWhenTheBotAlsoNeedsThePerson() throws { let bots = [ try summary(id: "answerable", name: "A", updatedAt: "2026-08-18T18:00:00.000Z", sessionState: "running", needsYou: true), - try summary(id: "mac-only", name: "B", updatedAt: "2026-08-18T17:00:00.000Z", sessionState: "running", needsYou: true), - try summary(id: "plain", name: "C", updatedAt: "2026-08-18T16:00:00.000Z", sessionState: "running"), + try summary(id: "mac-only", name: "B", updatedAt: "2026-08-18T17:30:00.000Z", sessionState: "running", needsYou: true), + try summary(id: "plain", name: "C", updatedAt: "2026-08-18T17:00:00.000Z", sessionState: "running"), ] let conversations = [ try conversation(botID: "answerable", preview: "Booking", state: "waiting_for_approval", canRespond: true, updatedAt: "2026-08-18T18:00:00.000Z"), - try conversation(botID: "mac-only", preview: "Booking", state: "waiting_for_approval", updatedAt: "2026-08-18T17:00:00.000Z"), - try conversation(botID: "plain", preview: "Booking", state: "waiting_for_approval", canRespond: true, updatedAt: "2026-08-18T16:00:00.000Z"), + try conversation(botID: "mac-only", preview: "Booking", state: "waiting_for_approval", updatedAt: "2026-08-18T17:30:00.000Z"), + try conversation(botID: "plain", preview: "Booking", state: "waiting_for_approval", canRespond: true, updatedAt: "2026-08-18T17:00:00.000Z"), ] let rows = Dictionary(uniqueKeysWithValues: aidenBotHomeRows( bots: bots,