Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.
Rust acpagent-client-protocolai-agentsai-assistantclaudeclaude-codecodexcoding-agentscursorgeminigemini-cligrok-bot-alternativeiosiphonelinuxmacosmcpopen-sourcerustself-hosted
fix(apps): scroll a long queue so every message stays in reach
leepokai688fcf787ab8
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/AppStore.kt b/apps/android/app/src/main/kotlin/com/codync/android/AppStore.ktindex f52d783e..b0d4e734 100644--- a/apps/android/app/src/main/kotlin/com/codync/android/AppStore.kt+++ b/apps/android/app/src/main/kotlin/com/codync/android/AppStore.kt@@ -61,6 +61,8 @@ class AppStore internal constructor(internal var callWait: Job? = nullinternal val transportRequired: Boolean get() = foreground || state.value.voice != nullinternal val sends = mutableSetOf<String>()+ /** The message sent from here last: its row in the queue scrolls into view ([QueuedMessages]). */+ internal var lastSentNonce: String? = nullinternal val actions = mutableMapOf<String, Job>()/** The bots as the mirror last had them; the state shows them with [pendingSectionMoves] laid over (`withMoves`). */internal var mirrorBots: List<Bot> = emptyList()diff --git a/apps/android/app/src/main/kotlin/com/codync/android/AppStoreDrafts.kt b/apps/android/app/src/main/kotlin/com/codync/android/AppStoreDrafts.ktindex 475ef4b1..04e2240b 100644--- a/apps/android/app/src/main/kotlin/com/codync/android/AppStoreDrafts.kt+++ b/apps/android/app/src/main/kotlin/com/codync/android/AppStoreDrafts.kt@@ -86,6 +86,7 @@ fun AppStore.sendDraft(key: String, botId: String, text: String, replyTo: ReplyQdraftWriter?.join()check(savedDrafts[key] == draft) { "Couldn't save this draft. Retry to send it." }val send = PendingSend(draft.nonce, botId, draft.text.trim(), System.currentTimeMillis(), files = draft.files, replyTo = replyTo)+ lastSentNonce = send.noncesavePending(send)mutableState.update { it.copy(drafts = it.drafts - key) }persistDrafts()diff --git a/apps/android/app/src/main/kotlin/com/codync/android/QueuedMessages.kt b/apps/android/app/src/main/kotlin/com/codync/android/QueuedMessages.ktindex e8286cbc..b7680782 100644--- a/apps/android/app/src/main/kotlin/com/codync/android/QueuedMessages.kt+++ b/apps/android/app/src/main/kotlin/com/codync/android/QueuedMessages.kt@@ -11,14 +11,19 @@ import androidx.compose.foundation.layout.Arrangementimport androidx.compose.foundation.layout.Columnimport androidx.compose.foundation.layout.Rowimport androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.heightInimport androidx.compose.foundation.layout.padding+import androidx.compose.foundation.rememberScrollState+import androidx.compose.foundation.verticalScrollimport androidx.compose.material3.Textimport androidx.compose.runtime.Composable+import androidx.compose.runtime.LaunchedEffectimport androidx.compose.runtime.getValueimport androidx.compose.runtime.keyimport androidx.compose.runtime.mutableStateOfimport androidx.compose.runtime.rememberimport androidx.compose.runtime.setValue+import androidx.compose.runtime.withFrameNanosimport androidx.compose.ui.Alignmentimport androidx.compose.ui.Modifierimport androidx.compose.ui.draw.clip@@ -49,10 +54,20 @@ internal val AppState.supportsQueueActions: Booleanvar shown by remember { mutableStateOf(entries) }if (entries.isNotEmpty() && entries != shown) shown = entriesval actions = state.supportsQueueActions+ val scroll = rememberScrollState()+ val newest = entries.lastOrNull()+ // It stays where it is, the oldest (next to go) in view; a message sent from here shows that it arrived.+ LaunchedEffect(newest?.id) {+ if (newest?.clientNonce != null && newest.clientNonce == store.lastSentNonce) {+ withFrameNanos {} // Its row is laid out by then, so the scroll takes it in.+ scroll.animateScrollTo(scroll.maxValue)+ }+ }AnimatedVisibility(entries.isNotEmpty(), modifier, enter = fadeIn(Motion.fade()) + expandVertically(Motion.layoutSize),exit = fadeOut(Motion.fade()) + shrinkVertically(Motion.layoutSize)) {+ // A long queue scrolls, so every row stays in reach and the chat keeps its room.Column(Modifier.fillMaxWidth().clip(RoundedRectangle(18.dp)).background(Palette.surface).animateContentSize(Motion.layoutSize)- .padding(vertical = 2.dp)) {+ .heightIn(max = 190.dp).verticalScroll(scroll).padding(vertical = 2.dp)) {for (entry in shown) key(entry.id) {QueuedRow(entry, actions, steering = "steer:" + entry.id in state.busy, steer = { store.steer(entry) }, remove = { store.unqueue(entry) })}diff --git a/apps/desktop/e2e/queue.spec.ts b/apps/desktop/e2e/queue.spec.tsindex 7aa51c52..42ef03ea 100644--- a/apps/desktop/e2e/queue.spec.ts+++ b/apps/desktop/e2e/queue.spec.ts@@ -19,6 +19,51 @@ async function type(page: Page, text: string) {await page.locator('.composer textarea').press('Enter')}+test('a long queue scrolls, with its oldest message in reach', async () => {+ const { browser, page } = await attach()+ const name = `Long queue e2e ${Date.now()}`+ let botId: string | undefined+ try {+ const { bot } = await api<{ bot: { id: string } }>(page, 'createBot', {+ name, backend: 'custom', command: `python3 -X utf8 -u '${agent}' steer 120`, connectors: [], skills: [], notify: false,+ })+ botId = bot.id+ await page.locator('.roster-row', { hasText: name }).click()+ await api(page, 'send', { botId, text: 'first' })+ await expect.poll(() => started(page, bot.id, 'first')).toBe(true)+ for (let i = 1; i <= 40; i++) await api(page, 'send', { botId, text: `Waiting ${i}` })+ const queued = page.locator('.queued-row')+ await expect(queued).toHaveCount(40)++ await expect(page.locator('.composer textarea')).toBeInViewport()+ const list = page.locator('.queued-list')+ const box = await list.boundingBox()+ expect(box!.y).toBeGreaterThan(0)+ expect(box!.height).toBeLessThan(260)+ const row = (text: string) => queued.filter({ hasText: new RegExp(`^${text}$`) })+ await expect(row('Waiting 1')).toBeInViewport()+ await expect(row('Waiting 40')).not.toBeInViewport()++ await list.hover()+ await page.mouse.wheel(0, 2000)+ await expect(row('Waiting 40')).toBeInViewport()+ await row('Waiting 40').getByRole('button', { name: 'Remove' }).click()+ await expect(queued).toHaveCount(39)+ await page.mouse.wheel(0, -2000)+ await expect(row('Waiting 1')).toBeInViewport()++ // One typed here scrolls into view; the ones the computer got from elsewhere didn't.+ await type(page, 'typed here')+ await expect(row('typed here')).toBeInViewport()+ } finally {+ if (botId) {+ await api(page, 'stop', { botId }).catch(() => {})+ await api(page, 'deleteBot', { botId }).catch(() => {})+ }+ await browser.close()+ }+})+test('a message sent while the bot works waits above the composer, then goes out now or is taken back', async () => {const { browser, page } = await attach()const name = `Queue e2e ${Date.now()}`diff --git a/apps/desktop/src/renderer/store/bot-store.ts b/apps/desktop/src/renderer/store/bot-store.tsindex b68db17b..395549bd 100644--- a/apps/desktop/src/renderer/store/bot-store.ts+++ b/apps/desktop/src/renderer/store/bot-store.ts@@ -56,9 +56,13 @@ export class BotStore extends BotSync {private outgoingFiles = new Map<string, OutgoingFile[]>()+ /** The message sent from here last: its row in the queue scrolls into view (`QueuedMessages`). */+ lastSentNonce: string | null = null+send(text: string, botId: string, { files = [], nonce = crypto.randomUUID(), pasted = [], replyTo = null, call = null }: SendOptions = {}) {const trimmed = text.trim()if ((!trimmed && !files.length) || this.retired) return+ this.lastSentNonce = nonceconst data: Entry['data'] = { text: trimmed, status: 'sending', clientNonce: nonce }if (call) data.call = callif (replyTo) data.replyTo = replyTodiff --git a/apps/desktop/src/renderer/views/thread/QueuedMessages.tsx b/apps/desktop/src/renderer/views/thread/QueuedMessages.tsxindex 652a2aa0..04ad4db3 100644--- a/apps/desktop/src/renderer/views/thread/QueuedMessages.tsx+++ b/apps/desktop/src/renderer/views/thread/QueuedMessages.tsx@@ -1,4 +1,4 @@-import { useEffect, useState } from 'react'+import { useEffect, useRef, useState } from 'react'import { hidingCalls } from '@shared/calls'import { isWorking, quoteOf, type Entry } from '@shared/models'import { IconButton } from '../../components/Controls'@@ -23,13 +23,14 @@ export function QueuedMessages({ botId }: { botId: string }) {const bot = store.bots.get(botId)const waiting = waitingMessages(hidingCalls(store.allEntries(botId)), !!bot && isWorking(bot))const rows = useLeaving(waiting)+ const list = useRevealSent(waiting.at(-1), store.lastSentNonce)const tray = usePresence(waiting.length > 0, EXIT_MS)const actions = canSteer(store.hostVersion?.version)if (!tray.mounted) return nullreturn (<div className={`queued-tray ${tray.shown ? 'shown' : ''}`} inert={waiting.length === 0}><div>- <div className="queued-list" role="list" aria-label="Queued messages">+ <div ref={list} className="queued-list" role="list" aria-label="Queued messages">{rows.map(({ entry, leaving }) => (<QueuedRow key={entry.id} entry={entry} leaving={leaving} actions={actions} />))}@@ -59,6 +60,17 @@ function QueuedRow({ entry, leaving, actions }: { entry: Entry; leaving: boolean)}+/** The list stays where it is, the oldest (next to go) in view; a message sent from here shows that it arrived. */+function useRevealSent(newest: Entry | undefined, lastSentNonce: string | null) {+ const list = useRef<HTMLDivElement>(null)+ useEffect(() => {+ if (!newest?.data.clientNonce || newest.data.clientNonce !== lastSentNonce) return+ // Once its row has opened, so the scroll takes it in.+ return afterExit(EXIT_MS, () => list.current?.scrollTo({ top: list.current.scrollHeight, behavior: 'smooth' }))+ }, [newest?.id])+ return list+}+/** `items` plus the ones that just left, kept in their places until their row has folded away. */function useLeaving(items: Entry[]): { entry: Entry; leaving: boolean }[] {const [previous, setPrevious] = useState(items)diff --git a/apps/desktop/src/renderer/views/thread/queued-messages.css b/apps/desktop/src/renderer/views/thread/queued-messages.cssindex 120e48e1..925d768a 100644--- a/apps/desktop/src/renderer/views/thread/queued-messages.css+++ b/apps/desktop/src/renderer/views/thread/queued-messages.css@@ -25,6 +25,9 @@background: var(--surface);border-radius: var(--radius-l) var(--radius-l) 0 0;padding: 4px 6px calc(var(--queued-tuck) + 2px) 14px;+ /* A long queue scrolls, so every row stays in reach: about four and a half rows, plus the padding. */+ max-height: calc(4.5 * 32px + var(--queued-tuck) + 6px);+ overflow-y: auto;}.queued-row-body {min-height: 32px;diff --git a/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Sending.swift b/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Sending.swiftindex f371adfd..f22a6734 100644--- a/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Sending.swift+++ b/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Sending.swift@@ -72,6 +72,7 @@ extension BotStore {pasted: [String] = [], call: String? = nil) -> Task<SendProgress, Never>? {let trimmed = text.trimmingCharacters(in: .whitespacesAndNewlines)guard !trimmed.isEmpty || !files.isEmpty, !retired else { return nil }+ lastSentNonce = nonceif call == nil { ReviewInvitation.shared.sent(nonce) }var data = EntryData(text: trimmed, status: "sending", clientNonce: nonce)data.call = calldiff --git a/apps/ios/Kit/Sources/CodyncUI/Store/BotStore.swift b/apps/ios/Kit/Sources/CodyncUI/Store/BotStore.swiftindex 2f97f829..1e1da537 100644--- a/apps/ios/Kit/Sources/CodyncUI/Store/BotStore.swift+++ b/apps/ios/Kit/Sources/CodyncUI/Store/BotStore.swift@@ -111,6 +111,8 @@ public final class BotStore {var retired = false/// Files of messages not delivered yet (by client nonce), kept for a retry.@ObservationIgnored var outgoingFiles: [String: [OutgoingFile]] = [:]+ /// The message sent from here last: its row in the queue scrolls into view (`QueuedMessages`).+ @ObservationIgnored var lastSentNonce: String?/// Section moves shown but not answered yet, oldest first.@ObservationIgnored var pendingSectionMoves: [SectionMove] = []diff --git a/apps/ios/Kit/Sources/CodyncUI/Thread/QueuedMessages.swift b/apps/ios/Kit/Sources/CodyncUI/Thread/QueuedMessages.swiftindex 910bc394..7bbaad1a 100644--- a/apps/ios/Kit/Sources/CodyncUI/Thread/QueuedMessages.swift+++ b/apps/ios/Kit/Sources/CodyncUI/Thread/QueuedMessages.swift@@ -9,13 +9,28 @@ struct QueuedMessages: View {@Environment(\.accessibilityReduceMotion) private var reduceMotionvar body: some View {- VStack(spacing: 0) {- ForEach(entries) { entry in- row(entry).transition(.move(edge: .bottom).combined(with: .opacity))+ // A long queue scrolls, so every row stays in reach and the chat keeps its room.+ ScrollViewReader { proxy in+ CappedHeight(max: 190) {+ ScrollView {+ VStack(spacing: 0) {+ ForEach(entries) { entry in+ row(entry).id(entry.id).transition(.move(edge: .bottom).combined(with: .opacity))+ }+ }+ .padding(.vertical, 2)+ }+ .scrollIndicators(.hidden)+ .scrollBounceBehavior(.basedOnSize)+ }+ // It stays where it is, the oldest (next to go) in view; a message sent from here shows that it arrived.+ .onChange(of: entries.last?.id) {+ guard let newest = entries.last, let nonce = newest.data.clientNonce, nonce == model.lastSentNonce else { return }+ withAnimation(Motion.reduced(Motion.layout, reduceMotion)) { proxy.scrollTo(newest.id, anchor: .bottom) }}}- .padding(.vertical, 2)- .background(Palette.surface, in: RoundedRectangle(cornerRadius: 18, style: .continuous))+ .background(Palette.surface)+ .clipShape(RoundedRectangle(cornerRadius: 18, style: .continuous)).animation(Motion.reduced(Motion.layout, reduceMotion), value: entries.map(\.id))}diff --git a/apps/ios/Kit/Tests/CodyncUITests/ChatItemTests.swift b/apps/ios/Kit/Tests/CodyncUITests/ChatItemTests.swiftindex 2e94abde..f3641886 100644--- a/apps/ios/Kit/Tests/CodyncUITests/ChatItemTests.swift+++ b/apps/ios/Kit/Tests/CodyncUITests/ChatItemTests.swift@@ -107,3 +107,25 @@ import Testing#expect(height(100) == 100)#expect(height(1000) == 280)}++/// The queue's card hugs its rows, and past its cap they scroll instead of pushing the chat away.+@MainActor @Test func theQueueCardHugsItsRowsAndScrollsPastTheCap() {+ let suite = "ChatItemTests.\(UUID().uuidString)"+ defer { UserDefaults(suiteName: suite)?.removePersistentDomain(forName: suite) }+ let storage = SharedStore.Context(accountID: UUID().uuidString, suite: suite)+ let store = BotStore(computer: Computer(id: "queue", name: "Mac", signKey: ""), storage: storage) { _ in+ throw HostError.unreachable+ }+ defer { store.retire() }+ func height(_ rows: Int) -> CGFloat {+ let entries = (0..<rows).map {+ Entry(id: "e\($0)", seq: Int64($0), botId: "b", rev: 0, kind: "user", turn: 1,+ data: EntryData(text: "Waiting \($0)", status: "queued"), createdAt: 0, updatedAt: 0)+ }+ return UIHostingController(rootView: QueuedMessages(entries: entries).environment(store))+ .sizeThatFits(in: CGSize(width: 390, height: 2000)).height+ }+ #expect(height(1) < 60)+ #expect(height(3) > height(1) && height(3) < 190)+ #expect(height(25) == 190)+}diff --git a/apps/maestro/queue.js b/apps/maestro/queue.jsindex 20cad010..5a19a2e2 100644--- a/apps/maestro/queue.js+++ b/apps/maestro/queue.js@@ -1,7 +1,7 @@// Makes the bot `queue.yaml` opens and starts its first turn, on the host the phone is paired with (HOST_PORT and// HOST_TOKEN, passed with `-e`). Its agent is host/tests/fixtures/steer_agent.py (STEER_AGENT, its full path), whose turn-// waits until a steered message joins it. `SEND` instead starts another turn with that text, and `CLEANUP`, when the flow-// completes, deletes the bot again.+// waits until a steered message joins it. `SEND` instead starts another turn with that text, `FILL` queues that many+// messages behind it, and `CLEANUP`, when the flow completes, deletes the bot again.const api = (method, body) => {const res = http.post(`http://127.0.0.1:${HOST_PORT}/api/${method}`, {headers: { Authorization: `Bearer ${HOST_TOKEN}`, 'Content-Type': 'application/json' },@@ -15,10 +15,12 @@ if (typeof CLEANUP !== 'undefined') {if (output.bot) api('deleteBot', { botId: output.bot.id })} else if (typeof SEND !== 'undefined') {api('send', { botId: output.bot.id, text: SEND })+} else if (typeof FILL !== 'undefined') {+ for (let i = 1; i <= Number(FILL); i++) api('send', { botId: output.bot.id, text: `Waiting ${i}` })} else {const name = `Queue check ${Math.random().toString(36).slice(2, 6)}`const bot = api('createBot', {- name, backend: 'custom', command: `python3 -X utf8 -u '${STEER_AGENT}' steer 120`, connectors: [], skills: [], notify: false,+ name, backend: 'custom', command: `python3 -X utf8 -u '${STEER_AGENT}' steer 600`, connectors: [], skills: [], notify: false,}).botapi('send', { botId: bot.id, text: 'first' })output.bot = { name, id: bot.id }diff --git a/apps/maestro/queue.yaml b/apps/maestro/queue.yamlindex d9464e8c..f76cd6f8 100644--- a/apps/maestro/queue.yaml+++ b/apps/maestro/queue.yaml@@ -47,3 +47,42 @@ onFlowComplete:- tapOn: "Remove"- assertNotVisible: "never sent"- assertNotVisible: "Remove"+# A long queue scrolls: its oldest message and the box both stay on screen, and every row can be reached.+# Swipes start on the second row under the bot's status: the iPhone reports rows scrolled out of the box at their places+# up and down the screen, where a swipe down from the first one pulls down Notification Center.+- runScript:+ file: queue.js+ env:+ FILL: "25"+- assertVisible: "Waiting 1"+- assertVisible: "Queue a message for.*"+- takeScreenshot: queue-long+- repeat:+ while:+ notVisible: "Waiting 25"+ times: 8+ commands:+ - swipe:+ from:+ text: "Waiting .*"+ below: "Writing a reply.*"+ index: 1+ direction: UP+- assertVisible: "Waiting 25"+- repeat:+ while:+ notVisible: "Waiting 1"+ times: 8+ commands:+ - swipe:+ from:+ text: "Waiting .*"+ below: "Writing a reply.*"+ index: 1+ direction: DOWN+- assertVisible: "Waiting 1"+# One typed here scrolls into view; the ones the computer got from elsewhere didn't.+- tapOn: "Queue a message for.*"+- inputText: "typed here"+- tapOn: "Send"+- assertVisible: "typed here"diff --git a/docs/guides/composer.md b/docs/guides/composer.mdindex 0cc63d84..f96631e8 100644--- a/docs/guides/composer.md+++ b/docs/guides/composer.md@@ -55,8 +55,12 @@ placeholder reads "Reply…", and leaving the chat cancels the reply. SeeWhile the bot works anywhere (its own chat, a room, a routine), the user's queued messages leave the transcript andwait above the box, oldest first, one line each: the desktop's tray tucked under the composer's top edge(`views/thread/QueuedMessages.tsx`), the phones' card past the + button (`Thread/QueuedMessages.swift`,-`QueuedMessages.kt`), the terminal's band over its input (`view/queue.rs`, at most three rows). An idle bot takes the-next message at once, so the chat keeps showing that one.+`QueuedMessages.kt`), the terminal's band over its input (`view/queue.rs`). An idle bot takes the next message at once,+so the chat keeps showing that one.++A long queue stays bounded, so the chat keeps its room. The desktop's tray stops at about four and a half rows and the+phones' card at 190 pt/dp, and they scroll, staying where they are with the oldest row (next to go) in view, except+that a message sent from that device scrolls to its new row. The terminal shows at most three rows and counts the rest.Each row has icon-only Send now (`arrow.turn.down.right`) and Remove (`trash`); the terminal has `S` (send the oldestnow) and `D` (take back the newest). A host older than 2.39.0 has neither, so the rows only show. Remove hides thediff --git a/web/content/docs/conversations.mdx b/web/content/docs/conversations.mdxindex 56a5d743..cd047d32 100644--- a/web/content/docs/conversations.mdx+++ b/web/content/docs/conversations.mdx@@ -24,7 +24,7 @@ Type in the box at the bottom and send.Each chat keeps its own draft on each device, and the draft comes back when you return to the chat or reopen the app. Drafts aren't synced between devices.-**While the bot works**, the box reads "Queue a message for" followed by the bot's name. Messages you send then wait in a list just above the box, and they reach the agent together as its next turn. Each waiting message has two buttons:+**While the bot works**, the box reads "Queue a message for" followed by the bot's name. Messages you send then wait in a list just above the box, which scrolls once it gets long, and they reach the agent together as its next turn. Each waiting message has two buttons:- **Send now** (the turning arrow) hands it to the bot right away. Claude, Codex and omp bots take it into the reply they're working on, which then answers it too; with other agents, that reply stops and the bot starts on your message. While the bot is busy with something else, such as a routine, a group or another bot's request, the message goes first in line.- **Remove** (the trash can) takes it back: neither it nor its files reach the bot.