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
feat(apps): list a group's members one per row when typing @
leepokai77721b13bfaa
diff --git a/apps/android/WhatsNew.md b/apps/android/WhatsNew.mdindex 896fe602..0233930e 100644--- a/apps/android/WhatsNew.md+++ b/apps/android/WhatsNew.md@@ -12,11 +12,13 @@ else a generic "Bug fixes and improvements" line. Delete old sections.- 不登入也能用了:在歡迎畫面選擇「不登入繼續」,手機掃電腦的 QR 碼就能配對,透過 Wi-Fi 或 Tailscale 連線。之後登入,配對會留在手機上;到「管理電腦」按「加入帳號」,電腦確認後就能從任何地方連線。- 電腦可以不加入帳號。配對時電腦會詢問;不加入的話,手機只能用 Wi-Fi 或 Tailscale 連線,之後也能在「管理電腦」加入帳號。- 遠端畫面會照連線設定換路:自動是先直連再走 Cloudflare,Cloudflare 優先則相反。+- 群組裡輸入 @ 會列出成員,一排一個,和 / 指令選單一樣。### en-US-- Use Codync without an account: choose Continue without an account on the welcome screen, then scan your computer's QR code. It connects over Wi-Fi or Tailscale. Sign in later and your computers stay paired; Add to account in Manage computers brings each into your account once the computer confirms.-- A computer can stay out of your account. It asks when you pair; without it, your phone connects only over Wi-Fi or Tailscale, and you can add it later in Manage computers.+- No account needed: choose Continue without an account, then scan your computer's QR code to connect over Wi-Fi or Tailscale. Sign in later and your computers stay paired.+- A computer can stay out of your account: it asks when you pair, and Manage computers can add it later.- Remote screen now follows the Connection setting: Auto tries direct first, then Cloudflare, and Cloudflare first does the reverse.+- Typing @ in a group lists its members one per row, like the / command list.## 2.40.2### zh-Hantdiff --git a/apps/android/app/src/main/kotlin/com/codync/android/ComposerList.kt b/apps/android/app/src/main/kotlin/com/codync/android/ComposerList.ktnew file mode 100644index 00000000..fbdfaf24--- /dev/null+++ b/apps/android/app/src/main/kotlin/com/codync/android/ComposerList.kt@@ -0,0 +1,59 @@+package com.codync.android++import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.heightIn+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.width+import androidx.compose.foundation.rememberScrollState+import androidx.compose.foundation.verticalScroll+import androidx.compose.material3.Text+import androidx.compose.runtime.Composable+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.semantics.contentDescription+import androidx.compose.ui.semantics.semantics+import androidx.compose.ui.text.style.TextOverflow+import androidx.compose.ui.unit.dp+import com.codync.android.core.Bot+import com.codync.android.design.*+import com.kyant.shapes.RoundedRectangle++/** A list above the box: hugs its rows, scrolls past 280 dp (iOS `ComposerList`). */+@Composable private fun ComposerList(modifier: Modifier, rows: @Composable () -> Unit) {+ Column(modifier.fillMaxWidth().heightIn(max = 280.dp).glass(RoundedRectangle(20.dp)).verticalScroll(rememberScrollState())+ .padding(vertical = 6.dp)) { rows() }+}++/** A row of a list above the box: its icon, name and what it is; tapping it picks it (iOS `ComposerListRow`). */+@Composable private fun ComposerListRow(title: String, detail: String, pick: () -> Unit, warning: Boolean = false, icon: @Composable () -> Unit) {+ Row(Modifier.fillMaxWidth().plainButton(action = pick)+ .semantics(mergeDescendants = true) { contentDescription = title }.padding(horizontal = 14.dp, vertical = 10.dp),+ verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(10.dp)) {+ Box(Modifier.width(20.dp), contentAlignment = Alignment.Center) { icon() }+ Text(title, style = Type.subheadline, color = Palette.text, maxLines = 1, overflow = TextOverflow.Ellipsis)+ Text(detail, Modifier.weight(1f), style = Type.subheadline, color = if (warning) Palette.warning else Palette.secondary,+ maxLines = 1, overflow = TextOverflow.Ellipsis)+ }+}++/** The `/` list: each command's icon, name and what it does; tapping one runs it (iOS `CommandList`). */+@Composable internal fun CommandList(commands: List<SlashCommand>, pick: (SlashCommand) -> Unit, modifier: Modifier = Modifier) {+ ComposerList(modifier) {+ for (command in commands) ComposerListRow(command.title, command.detail, { pick(command) }, command.warning) {+ Symbol(command.icon, size = 17.dp, tint = Palette.secondary)+ }+ }+}++/** The `@` list in a group: each member's face, name and description; tapping one mentions it (iOS `MentionList`). */+@Composable internal fun MentionList(members: List<Bot>, bots: List<Bot>, mention: (Bot) -> Unit, modifier: Modifier = Modifier) {+ ComposerList(modifier) {+ for (member in members) ComposerListRow(member.name, member.description, { mention(member) }) {+ BotAvatar(member, bots, 18.dp)+ }+ }+}diff --git a/apps/android/app/src/main/kotlin/com/codync/android/MessageComposer.kt b/apps/android/app/src/main/kotlin/com/codync/android/MessageComposer.ktindex cde760d0..55a31192 100644--- a/apps/android/app/src/main/kotlin/com/codync/android/MessageComposer.kt+++ b/apps/android/app/src/main/kotlin/com/codync/android/MessageComposer.kt@@ -156,10 +156,11 @@ private enum class Trailing { Interrupt, Stop, Call, Send }val startingCommand = typed == "/"LaunchedEffect(startingCommand) { if (startingCommand && online) store.refreshPlugins() }// The one way a group's box differs: @ asks one of its bots.- val mentions = if (bot.kind != "group") emptyList() else mentionQuery(typed)?.let { query ->+ val mentions = if (bot.kind != "group") emptyList() else mentionQuery(typed, members)?.let { query ->members.filter { query.isEmpty() || it.name.contains(query, true) }}.orEmpty()fun clear() = text.edit { replace(0, length, "") }+ fun mention(member: Bot) = text.setTextAndPlaceCursorAtEnd(typed.substring(0, typed.lastIndexOf('@')) + "@${member.name} ")fun run(command: SlashCommand) {val skill = command.skillwhen {@@ -180,8 +181,9 @@ private enum class Trailing { Interrupt, Stop, Call, Send }exit = fadeOut(Motion.fade()) + shrinkVertically(Motion.layoutSize)) {CommandList(commands, ::run, Modifier.padding(horizontal = 16.dp))}- AnimatedVisibility(mentions.isNotEmpty(), enter = fadeIn(Motion.fade()), exit = fadeOut(Motion.fade())) {- MentionChips(mentions, state.bots) { member -> text.setTextAndPlaceCursorAtEnd(typed.substring(0, typed.lastIndexOf('@')) + "@${member.name} ") }+ AnimatedVisibility(mentions.isNotEmpty(), enter = fadeIn(Motion.fade()) + expandVertically(Motion.layoutSize),+ exit = fadeOut(Motion.fade()) + shrinkVertically(Motion.layoutSize)) {+ MentionList(mentions, state.bots, ::mention, Modifier.padding(horizontal = 16.dp))}Row(Modifier.fillMaxWidth().padding(start = 16.dp, end = 16.dp, top = 6.dp, bottom = 16.dp), verticalAlignment = Alignment.Bottom,horizontalArrangement = Arrangement.spacedBy(8.dp)) {diff --git a/apps/android/app/src/main/kotlin/com/codync/android/SlashCommands.kt b/apps/android/app/src/main/kotlin/com/codync/android/SlashCommands.ktindex cab1f937..d302bf88 100644--- a/apps/android/app/src/main/kotlin/com/codync/android/SlashCommands.kt+++ b/apps/android/app/src/main/kotlin/com/codync/android/SlashCommands.kt@@ -1,35 +1,11 @@package com.codync.android-import androidx.compose.foundation.background-import androidx.compose.foundation.horizontalScroll-import androidx.compose.foundation.layout.Arrangement-import androidx.compose.foundation.layout.Box-import androidx.compose.foundation.layout.Column-import androidx.compose.foundation.layout.Row-import androidx.compose.foundation.layout.fillMaxWidth-import androidx.compose.foundation.layout.heightIn-import androidx.compose.foundation.layout.padding-import androidx.compose.foundation.layout.width-import androidx.compose.foundation.rememberScrollState-import androidx.compose.foundation.verticalScroll-import androidx.compose.material3.Text-import androidx.compose.runtime.Composable-import androidx.compose.ui.Alignment-import androidx.compose.ui.Modifier-import androidx.compose.ui.draw.clip-import androidx.compose.ui.semantics.contentDescription-import androidx.compose.ui.semantics.semantics-import androidx.compose.ui.text.style.TextOverflow-import androidx.compose.ui.unit.dpimport com.codync.android.core.Botimport com.codync.android.core.FastModeStateimport com.codync.android.core.GroupFastModeimport com.codync.android.core.InstalledSkillimport com.codync.android.core.fastModeDetailimport com.codync.android.core.fastModeState-import com.codync.android.design.*-import com.kyant.shapes.Capsule-import com.kyant.shapes.RoundedRectangle/** A command in the composer's `/` list (iOS `SlashCommand`): Fast mode, or one of the bot's skills. */internal data class SlashCommand(val name: String, val icon: String, val title: String, val detail: String, val warning: Boolean,@@ -69,36 +45,14 @@ internal object SlashCommands {}}-/** The `/` list above the box: each command's icon, name and what it does; tapping one runs it (iOS `CommandList`). */-@Composable internal fun CommandList(commands: List<SlashCommand>, pick: (SlashCommand) -> Unit, modifier: Modifier = Modifier) {- Column(modifier.fillMaxWidth().heightIn(max = 280.dp).glass(RoundedRectangle(20.dp)).verticalScroll(rememberScrollState())- .padding(vertical = 6.dp)) {- for (command in commands) Row(Modifier.fillMaxWidth().plainButton { pick(command) }- .semantics(mergeDescendants = true) { contentDescription = command.title }.padding(horizontal = 14.dp, vertical = 10.dp),- verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(10.dp)) {- Box(Modifier.width(20.dp), contentAlignment = Alignment.Center) { Symbol(command.icon, size = 17.dp, tint = Palette.secondary) }- Text(command.title, style = Type.subheadline, color = Palette.text, maxLines = 1, overflow = TextOverflow.Ellipsis)- Text(command.detail, Modifier.weight(1f), style = Type.subheadline, color = if (command.warning) Palette.warning else Palette.secondary,- maxLines = 1, overflow = TextOverflow.Ellipsis)- }- }-}--/** The bots to @mention above a group's box: chips with their faces (iOS `SuggestionChip`). */-@Composable internal fun MentionChips(members: List<Bot>, bots: List<Bot>, mention: (Bot) -> Unit) {- Row(Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()).padding(horizontal = 16.dp), horizontalArrangement = Arrangement.spacedBy(6.dp)) {- for (member in members) Row(Modifier.clip(Capsule()).background(Palette.surface).plainButton { mention(member) }- .padding(horizontal = 10.dp, vertical = 6.dp), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(6.dp)) {- BotAvatar(member, bots, 18.dp)- Text(member.name, style = Type.subheadline, color = Palette.text, maxLines = 1, overflow = TextOverflow.Ellipsis)- }- }-}--/** The `@partial` being typed at the end of a group's draft, if any. */-internal fun mentionQuery(draft: String): String? {+/**+ * The `@partial` being typed at the end of a group's draft, if any. A member's full name and its space end it, so the list+ * doesn't stay up for a longer name that holds this one.+ */+internal fun mentionQuery(draft: String, members: List<Bot>): String? {val at = draft.lastIndexOf('@')if (at < 0 || at > 0 && !draft[at - 1].isWhitespace()) return nullval query = draft.substring(at + 1)- return if (query.contains('\n') || query.length > 24) null else query+ if (query.firstOrNull()?.isWhitespace() == true || query.contains('\n') || query.length > 24) return null+ return query.takeUnless { members.any { query.equals("${it.name} ", ignoreCase = true) } }}diff --git a/apps/android/app/src/test/kotlin/com/codync/android/SlashCommandsTest.kt b/apps/android/app/src/test/kotlin/com/codync/android/SlashCommandsTest.ktindex 66bffe74..a3d8385c 100644--- a/apps/android/app/src/test/kotlin/com/codync/android/SlashCommandsTest.kt+++ b/apps/android/app/src/test/kotlin/com/codync/android/SlashCommandsTest.kt@@ -49,9 +49,15 @@ class SlashCommandsTest {assertEquals(FastModeState.Off, GroupFastMode(emptyList()).state)}- @Test fun `mentions start after a space and stay short`() {- assertEquals("Re", mentionQuery("hi @Re"))- assertNull(mentionQuery("mail@host"))- assertNull(mentionQuery("@" + "x".repeat(25)))+ @Test fun `mentions start after a space, stay short, and end with a member's full name`() {+ val members = listOf(Bot("a", "Alpha"), Bot("t", "Alpha Two"))+ assertEquals("", mentionQuery("@", members))+ assertEquals("Re", mentionQuery("hi @Re", members))+ assertNull(mentionQuery("mail@host", members))+ assertNull(mentionQuery("@" + "x".repeat(25), members))+ assertNull(mentionQuery("@Alpha\nnext", members))+ assertNull("an @ and a space is ordinary text", mentionQuery("meet @ home", members))+ assertNull(mentionQuery("@alpha ", members))+ assertEquals("a longer name can still be typed", "Alpha T", mentionQuery("@Alpha T", members))}}diff --git a/apps/desktop/e2e/command-menu.spec.ts b/apps/desktop/e2e/command-menu.spec.tsnew file mode 100644index 00000000..305be008--- /dev/null+++ b/apps/desktop/e2e/command-menu.spec.ts@@ -0,0 +1,82 @@+import { test, expect } from '@playwright/test'+import { api, attach } from './sandbox.ts'++test('typing / lists the bot\'s commands, and the keyboard moves, picks and hides', async () => {+ const { browser, page } = await attach()+ const run = Date.now().toString(36)+ const name = `Command Bot ${run}`+ const { skill } = await api<{ skill: { id: string } }>(page, 'installSkill', { name: `Menu Skill ${run}`, description: 'Checks the list', instructions: 'Say hi.' })+ let botId: string | undefined+ const field = page.locator('.composer textarea')+ const list = page.getByRole('listbox', { name: 'Commands' })+ const rows = list.getByRole('option')+ const sent = async () => {+ const { entries } = await api<{ entries: { kind: string }[] }>(page, 'history', { botId })+ return entries.filter((e) => e.kind === 'user').length+ }+ try {+ const { bot } = await api<{ bot: { id: string } }>(page, 'createBot', { name, backend: 'custom', command: 'unused', connectors: [], skills: [skill.id], permission: 'auto' })+ botId = bot.id+ await page.locator('.roster-row', { hasText: name }).click()++ // Fast mode first, then the bot's skill.+ await field.fill('/')+ await expect(rows).toHaveCount(2)+ await expect(rows.nth(0)).toContainText('Fast mode')+ await expect(rows.nth(1)).toContainText('Checks the list')+ // The outline every floating layer has.+ expect(await page.locator('.composer-menu').evaluate((el) => getComputedStyle(el, '::after').borderTopWidth)).toBe('1px')++ // ↑/↓ move the highlight, wrapping around the ends.+ await expect(rows.nth(0)).toHaveAttribute('aria-selected', 'true')+ await field.press('ArrowDown')+ await expect(rows.nth(1)).toHaveAttribute('aria-selected', 'true')+ await field.press('ArrowDown')+ await expect(rows.nth(0)).toHaveAttribute('aria-selected', 'true')+ await field.press('ArrowUp')+ await expect(rows.nth(1)).toHaveAttribute('aria-selected', 'true')++ // Return fills in the skill and sends nothing.+ await field.press('Enter')+ await expect(field).toHaveValue(`/${skill.id} `)+ await expect(list).toHaveCount(0)+ expect(await sent()).toBe(0)++ // Tab picks a partly typed one.+ await field.fill(`/${skill.id.slice(0, -1)}`)+ await expect(rows).toHaveCount(1)+ await field.press('Tab')+ await expect(field).toHaveValue(`/${skill.id} `)++ // Escape hides the list and leaves the draft, until the draft changes.+ await field.fill('/')+ await expect(rows).toHaveCount(2)+ await field.press('Escape')+ await expect(list).toHaveCount(0)+ await expect(field).toHaveValue('/')+ await field.fill('')+ await field.fill('/')+ await expect(rows).toHaveCount(2)++ // Return runs Fast mode here: the box empties and the row now offers the opposite.+ await field.fill('/fa')+ await expect(rows).toHaveCount(1)+ const before = await rows.nth(0).textContent()+ await field.press('Enter')+ await expect(field).toHaveValue('')+ expect(await sent()).toBe(0)+ await field.fill('/fa')+ await expect(rows.nth(0)).not.toHaveText(before!)++ // Return on a skill whose name is typed out sends the message.+ await field.fill(`/${skill.id}`)+ await expect(rows).toHaveCount(1)+ await field.press('Enter')+ await expect(field).toHaveValue('')+ await expect.poll(sent).toBe(1)+ } finally {+ if (botId) await api(page, 'deleteBot', { botId }).catch(() => {})+ await api(page, 'removeSkill', { id: skill.id }).catch(() => {})+ await browser.close()+ }+})diff --git a/apps/desktop/e2e/mention-menu.spec.ts b/apps/desktop/e2e/mention-menu.spec.tsnew file mode 100644index 00000000..a61a3e41--- /dev/null+++ b/apps/desktop/e2e/mention-menu.spec.ts@@ -0,0 +1,146 @@+import { test, expect, type Page } from '@playwright/test'+import { api, attach } from './sandbox.ts'++/** How many messages the user has sent to `botId`. */+async function sent(page: Page, botId: string) {+ const { entries } = await api<{ entries: { kind: string }[] }>(page, 'history', { botId })+ return entries.filter((e) => e.kind === 'user').length+}++/** Opens a new group of these members (`[name, description]`), runs `body` in it, and deletes it all again. */+async function inGroup(members: [string, string][], body: (page: Page, groupId: string) => Promise<void>) {+ const { browser, page } = await attach()+ const made: string[] = []+ const create = async (body: object) => {+ const { bot } = await api<{ bot: { id: string } }>(page, 'createBot', body)+ made.push(bot.id)+ return bot.id+ }+ try {+ const ids: string[] = []+ for (const [name, description] of members) {+ ids.push(await create({ name, description, backend: 'custom', command: 'unused', connectors: [], permission: 'auto' }))+ }+ const name = `Mention Group ${Date.now()}`+ const groupId = await create({ name, kind: 'group', members: ids })+ await page.locator('.roster-row', { hasText: name }).click()+ await body(page, groupId)+ await page.locator('.composer textarea').fill('')+ } finally {+ for (const botId of made.reverse()) await api(page, 'deleteBot', { botId }).catch(() => {})+ await browser.close()+ }+}++// Short enough that a whole name still counts as a mention being typed (24 characters).+const stamp = () => Date.now().toString(36)++test('typing @ in a group lists its members one per row, and the keyboard or the mouse picks one', async () => {+ const alpha = `Mention Alpha ${stamp()}`+ const beta = `Mention Beta ${stamp()}`+ await inGroup([[alpha, 'Reviews the code'], [beta, 'Writes the docs']], async (page, groupId) => {+ const field = page.locator('.composer textarea')+ const list = page.getByRole('listbox', { name: 'Members' })+ const rows = list.getByRole('option')++ // One row per member, under each other, with its description.+ await field.fill('@')+ await expect(rows).toHaveCount(2)+ await expect(rows.nth(0)).toContainText('Reviews the code')+ const [top, bottom] = [await rows.nth(0).boundingBox(), await rows.nth(1).boundingBox()]+ expect(bottom!.y).toBeGreaterThanOrEqual(top!.y + top!.height)+ expect(bottom!.x).toBe(top!.x)++ // ↑/↓ move the highlight, wrapping around the ends.+ await expect(rows.nth(0)).toHaveAttribute('aria-selected', 'true')+ await field.press('ArrowDown')+ await expect(rows.nth(1)).toHaveAttribute('aria-selected', 'true')+ await field.press('ArrowDown')+ await expect(rows.nth(0)).toHaveAttribute('aria-selected', 'true')+ await field.press('ArrowUp')+ await expect(rows.nth(1)).toHaveAttribute('aria-selected', 'true')++ // Return picks it and sends nothing; the next Return sends.+ await field.press('Enter')+ await expect(field).toHaveValue(`@${beta} `)+ await expect(list).toHaveCount(0)+ expect(await sent(page, groupId)).toBe(0)+ await field.press('Enter')+ await expect(field).toHaveValue('')+ await expect.poll(() => sent(page, groupId)).toBe(1)++ // Return picks even with the whole name typed.+ await field.fill(`@${alpha}`)+ await expect(rows).toHaveCount(1)+ await field.press('Enter')+ await expect(field).toHaveValue(`@${alpha} `)+ expect(await sent(page, groupId)).toBe(1)++ // Typing filters the list, after earlier words too, and Tab picks.+ await field.fill('hello @alp')+ await expect(rows).toHaveCount(1)+ await field.press('Tab')+ await expect(field).toHaveValue(`hello @${alpha} `)++ // An input method's Return confirms its candidate, not a member.+ await field.fill('@')+ await expect(rows).toHaveCount(2)+ await field.evaluate((el) => el.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', keyCode: 229, bubbles: true, cancelable: true })))+ await expect(field).toHaveValue('@')+ await expect(rows).toHaveCount(2)++ // Escape hides the list and leaves the draft, until the draft changes.+ await field.press('Escape')+ await expect(list).toHaveCount(0)+ await expect(field).toHaveValue('@')+ await field.fill('')+ await field.fill('@')+ await expect(rows).toHaveCount(2)++ // The mouse works too: hovering moves the highlight, and the caret stays in the field.+ await rows.nth(1).hover()+ await expect(rows.nth(1)).toHaveAttribute('aria-selected', 'true')+ await rows.nth(1).click()+ await expect(field).toHaveValue(`@${beta} `)+ await expect(field).toBeFocused()+ })+})++test('Return sends once the mention is whole, even with a longer name or @all in reach', async () => {+ const nest = `Nest ${stamp()}`+ const allen = `Allen ${stamp()}`+ await inGroup([[nest, ''], [`${nest} Two`, ''], [allen, '']], async (page, groupId) => {+ const field = page.locator('.composer textarea')+ const list = page.getByRole('listbox', { name: 'Members' })+ const rows = list.getByRole('option')++ // A picked name that a longer one holds: the list is gone, so the next Return sends.+ await field.fill(`@${nest}`)+ await expect(rows).toHaveCount(2)+ await field.press('Enter')+ await expect(field).toHaveValue(`@${nest} `)+ await expect(list).toHaveCount(0)+ await field.press('Enter')+ await expect(field).toHaveValue('')+ await expect.poll(() => sent(page, groupId)).toBe(1)++ // Typing on can still reach the longer name.+ await field.fill(`@${nest} T`)+ await expect(rows).toHaveCount(1)++ // @all sends to the room although a member's name holds "all"; Tab can still pick that member.+ await field.fill('thanks @all')+ await expect(rows).toHaveCount(1)+ await field.press('Tab')+ await expect(field).toHaveValue(`thanks @${allen} `)+ await field.fill('thanks @all')+ await expect(rows).toHaveCount(1)+ await field.press('Enter')+ await expect(field).toHaveValue('')+ await expect.poll(() => sent(page, groupId)).toBe(2)++ // An @ and a space is ordinary text.+ await field.fill('meet @ two')+ await expect(list).toHaveCount(0)+ })+})diff --git a/apps/desktop/src/renderer/components/overlay.css b/apps/desktop/src/renderer/components/overlay.cssindex 3dd17fbd..ebc354d8 100644--- a/apps/desktop/src/renderer/components/overlay.css+++ b/apps/desktop/src/renderer/components/overlay.css@@ -85,7 +85,7 @@.anchored-panel::after,.account-panel::after,.action-menu::after,-.command-menu::after {+.composer-menu::after {content: '';position: absolute;inset: 0;diff --git a/apps/desktop/src/renderer/views/thread/CommandMenu.tsx b/apps/desktop/src/renderer/views/thread/CommandMenu.tsxdeleted file mode 100644index 9749e83e..00000000--- a/apps/desktop/src/renderer/views/thread/CommandMenu.tsx+++ /dev/null@@ -1,78 +0,0 @@-import { useEffect, useRef, useState, type KeyboardEvent } from 'react'-import { Icon } from '../../components/Icon'-import { usePresence } from '../../components/Overlay'-import { useTr } from '../../lib/use-language'-import { returnRuns, type SlashCommand } from './slash-commands'--/**- * The `/` list's highlight and keys: ↑/↓ move, Tab or Return picks, Escape hides the list until- * the draft changes.- */-export function useCommandMenu(draft: string, commands: SlashCommand[], run: (command: SlashCommand) => void) {- const [pick, setPick] = useState({ draft: '', index: 0 })- const [dismissed, setDismissed] = useState<string | null>(null)- const shown = dismissed === draft ? [] : commands- const index = pick.draft === draft ? Math.min(pick.index, shown.length - 1) : 0-- /** Handles a key in the field while the list is up; returns whether it did. */- const onKey = (e: KeyboardEvent, composing: boolean): boolean => {- const picked = shown[index]- if (!picked || composing || e.altKey || e.metaKey || e.ctrlKey) return false- const step = e.key === 'ArrowDown' ? 1 : e.key === 'ArrowUp' ? -1 : 0- const runs = (e.key === 'Tab' && !e.shiftKey) || (e.key === 'Enter' && !e.shiftKey && returnRuns(picked, draft))- if (!step && !runs && e.key !== 'Escape') return false- e.preventDefault()- e.stopPropagation()- if (step) setPick({ draft, index: (index + step + shown.length) % shown.length })- else if (runs) run(picked)- else setDismissed(draft)- return true- }-- return { shown, index, hover: (i: number) => setPick({ draft, index: i }), onKey }-}--/** The `/` list over the transcript, above the box: each command's icon, name and what it does. */-export function CommandMenu({ commands, index, hover, pick }: {- commands: SlashCommand[]- index: number- hover: (index: number) => void- pick: (command: SlashCommand) => void-}) {- const open = commands.length > 0- const tr = useTr()- const { mounted, shown } = usePresence(open)- const last = useRef(commands)- if (open) last.current = commands- const list = open ? commands : last.current- const rows = useRef<(HTMLButtonElement | null)[]>([])- // Braces: newer Chromium returns a promise from `scrollIntoView`, which an effect mustn't return.- useEffect(() => {- void rows.current[index]?.scrollIntoView({ block: 'nearest' })- }, [index, list])- if (!mounted) return null- return (- <div className={`command-menu ${shown ? 'shown' : ''}`} inert={!open}>- <div className="menu-panel" role="listbox" aria-label={tr('Commands')}>- {list.map((c, i) => (- <button- key={`${c.action.kind}:${c.name}`}- ref={(el) => { rows.current[i] = el }}- role="option"- aria-selected={i === index}- className={`menu-row ${i === index ? 'highlight' : ''}`}- title={tr(c.detail || c.title)}- onMouseEnter={() => hover(i)}- // Keep the caret in the field.- onMouseDown={(e) => e.preventDefault()}- onClick={() => pick(c)}- >- <span className="menu-icon"><Icon name={c.icon} size={12} color="var(--secondary)" /></span>- <span className="command-title">{tr(c.title)}</span>- <span className={`command-detail ${c.warning ? 'warning' : ''}`}>{tr(c.detail)}</span>- </button>- ))}- </div>- </div>- )-}diff --git a/apps/desktop/src/renderer/views/thread/Composer.tsx b/apps/desktop/src/renderer/views/thread/Composer.tsxindex 78b1a7b4..edce5238 100644--- a/apps/desktop/src/renderer/views/thread/Composer.tsx+++ b/apps/desktop/src/renderer/views/thread/Composer.tsx@@ -3,14 +3,12 @@ import { groupFastMode } from '@shared/fast-mode'import { artifactDraftKey, artifactQuote, type Artifact } from '@shared/artifacts'import { isGroup, isWorkingIn, quoteOf, type Bot, type Entry } from '@shared/models'import type { PickedFile } from '@shared/ipc'-import { BotAvatar } from '../../components/Avatar'import { Icon } from '../../components/Icon'import { IconButton } from '../../components/Controls'import { RecordingPill } from '../../components/RecordingPill'import { Sheet, usePresence } from '../../components/Overlay'import { VoiceChatSettingsView } from '../settings/VoiceChatSettingsView'import { HStack, VStack } from '../../components/Stack'-import { Text } from '../../components/Text'import { useModel } from '../../lib/observable'import { useTr } from '../../lib/use-language'import { useStore } from '../../store/context'@@ -18,19 +16,20 @@ import { MAX_FILE_SIZE, type OutgoingFile } from '../../store/bot-store'import { pluginsFor } from '../marketplace/plugins'import { pastedFiles, readPicked } from './composer-files'import { composerEnter } from './composer-keyboard'-import { CommandMenu, useCommandMenu } from './CommandMenu'+import { CommandMenu, MentionMenu, useComposerMenu } from './ComposerMenu'import { ComposerAttachment } from './ComposerAttachment'import { QuoteRow } from './ChatRows'import { useDictation } from './dictation-platform'import { DictationEngineMenu } from './DictationEngineMenu'-import { builtInCommand, slashCommands, slashQuery, type SlashCommand } from './slash-commands'+import { mentionSuggestions, returnMentions, withMention } from './mentions'+import { builtInCommand, returnRuns, slashCommands, slashQuery, type SlashCommand } from './slash-commands'import { useVoiceShortcut } from './voice-shortcut-keys'type Trailing = 'interrupt' | 'stop' | 'call' | 'send'/*** The message box under a chat: send, or stop while the bot (or the group) is working there. A leading `/` lists- * the commands (a group's are its bots'); in a group, typing `@` suggests its bots. While `reply` is set, the+ * the commands (a group's are its bots'); in a group, typing `@` lists its bots. While `reply` is set, the* message it quotes sits at the top of the box and goes out with the next send. Under an artifact, `about` is the* artifact: the box keeps a draft of its own, and every message replies to the artifact's card.*/@@ -111,23 +110,12 @@ function DestinationComposer({ botId, reply, about, cancelReply, onCall, onInterreturn () => observer.disconnect()}, [])- const mentionQuery = (() => {- if (!bot || !isGroup(bot)) return null- const at = draft.lastIndexOf('@')- if (at < 0) return null- if (at > 0 && !/\s/.test(draft[at - 1]!)) return null- const query = draft.slice(at + 1)- return /\n/.test(query) || query.length > 24 ? null : query- })()- const suggestions: Bot[] =- mentionQuery !== null ? members.filter((m) => !mentionQuery || m.name.toLowerCase().includes(mentionQuery.toLowerCase())) : []-+ const suggestions = mentionSuggestions(draft, members)const mention = (member: Bot) => {- const at = draft.lastIndexOf('@')- if (at < 0) return- setDraft(`${draft.slice(0, at)}@${member.name} `)+ setDraft(withMention(draft, member))field.current?.focus()}+ const mentionMenu = useComposerMenu(draft, suggestions, mention, returnMentions)const slash = slashQuery(draft)const commands = slash === null ? [] : slashCommands(bot, slash, plugins.installedSkills, members)@@ -151,7 +139,7 @@ function DestinationComposer({ botId, reply, about, cancelReply, onCall, onInter}field.current?.focus()}- const menu = useCommandMenu(draft, commands, run)+ const commandMenu = useComposerMenu(draft, commands, run, returnRuns)const append = (incoming: PickedFile[]) => {if (!canAttach) return@@ -192,16 +180,6 @@ function DestinationComposer({ botId, reply, about, cancelReply, onCall, onInterreturn (<VStack>- <ComposerReveal open={suggestions.length > 0}>- <div className="mentions">- {suggestions.map((m) => (- <button key={m.id} className="press mention" onClick={() => mention(m)}>- <BotAvatar bot={m} size={18} animated={false} />- <Text size="subheadline" tone="text">{m.name}</Text>- </button>- ))}- </div>- </ComposerReveal><divclassName="composer"onDragOver={(e) => {@@ -214,7 +192,8 @@ function DestinationComposer({ botId, reply, about, cancelReply, onCall, onInter}}><div className="composer-surface">- <CommandMenu commands={menu.shown} index={menu.index} hover={menu.hover} pick={run} />+ <CommandMenu menu={commandMenu} />+ <MentionMenu menu={mentionMenu} /><ComposerReveal open={!!reply}>{reply ? (<HStack gap={4} className="composer-reply">@@ -255,7 +234,8 @@ function DestinationComposer({ botId, reply, about, cancelReply, onCall, onInterif (bot && e.target.value === '/') void plugins.refresh()}}onKeyDown={(e) => {- if (menu.onKey(e, composing.current || e.nativeEvent.isComposing || e.keyCode === 229)) return+ const inInputMethod = composing.current || e.nativeEvent.isComposing || e.keyCode === 229+ if (commandMenu.onKey(e, inInputMethod) || mentionMenu.onKey(e, inInputMethod)) returnif (e.key === 'Escape' && reply) {e.preventDefault()cancelReply?.()diff --git a/apps/desktop/src/renderer/views/thread/ComposerMenu.tsx b/apps/desktop/src/renderer/views/thread/ComposerMenu.tsxnew file mode 100644index 00000000..a27d446f--- /dev/null+++ b/apps/desktop/src/renderer/views/thread/ComposerMenu.tsx@@ -0,0 +1,113 @@+import { useEffect, useRef, useState, type KeyboardEvent, type ReactNode } from 'react'+import type { Bot } from '@shared/models'+import { BotAvatar } from '../../components/Avatar'+import { Icon } from '../../components/Icon'+import { usePresence } from '../../components/Overlay'+import { Text } from '../../components/Text'+import { useTr } from '../../lib/use-language'+import type { SlashCommand } from './slash-commands'++interface ComposerMenuState<T> {+ shown: T[]+ index: number+ hover: (index: number) => void+ pick: (item: T) => void+}++/**+ * The highlight and keys of a list above the box (`/` commands, `@` members): ↑/↓ move, Tab or Return picks,+ * Escape hides the list until the draft changes. `returnPicks` lets Return fall through to sending for a row.+ */+export function useComposerMenu<T>(draft: string, items: T[], pick: (item: T) => void, returnPicks: (item: T, draft: string) => boolean = () => true) {+ const [highlight, setHighlight] = useState({ draft: '', index: 0 })+ const [dismissed, setDismissed] = useState<string | null>(null)+ if (dismissed !== null && dismissed !== draft) setDismissed(null)+ const shown = dismissed === draft ? [] : items+ const index = highlight.draft === draft ? Math.min(highlight.index, shown.length - 1) : 0++ /** Handles a key in the field while the list is up; returns whether it did. */+ const onKey = (e: KeyboardEvent, composing: boolean): boolean => {+ const picked = shown[index]+ if (!picked || composing || e.altKey || e.metaKey || e.ctrlKey) return false+ const step = e.key === 'ArrowDown' ? 1 : e.key === 'ArrowUp' ? -1 : 0+ const picks = (e.key === 'Tab' && !e.shiftKey) || (e.key === 'Enter' && !e.shiftKey && returnPicks(picked, draft))+ if (!step && !picks && e.key !== 'Escape') return false+ e.preventDefault()+ e.stopPropagation()+ if (step) setHighlight({ draft, index: (index + step + shown.length) % shown.length })+ else if (picks) pick(picked)+ else setDismissed(draft)+ return true+ }++ return { shown, index, hover: (i: number) => setHighlight({ draft, index: i }), pick, onKey }+}++/** A list over the transcript, above the box: each row's icon, name and what it is. */+function ComposerMenu<T>({ menu, label, row }: {+ menu: ComposerMenuState<T>+ label: string+ row: (item: T) => { key: string; icon: ReactNode; title: string; detail: string; warning?: boolean }+}) {+ const open = menu.shown.length > 0+ const { mounted, shown } = usePresence(open)+ const last = useRef(menu.shown)+ if (open) last.current = menu.shown+ const list = open ? menu.shown : last.current+ const rows = useRef<(HTMLButtonElement | null)[]>([])+ // Braces: newer Chromium returns a promise from `scrollIntoView`, which an effect mustn't return.+ useEffect(() => {+ void rows.current[menu.index]?.scrollIntoView({ block: 'nearest' })+ }, [menu.index, list])+ if (!mounted) return null+ return (+ <div className={`composer-menu ${shown ? 'shown' : ''}`} inert={!open}>+ <div className="menu-panel" role="listbox" aria-label={label}>+ {list.map((item, i) => {+ const { key, icon, title, detail, warning } = row(item)+ return (+ <button+ key={key}+ ref={(el) => { rows.current[i] = el }}+ role="option"+ aria-selected={i === menu.index}+ className={`menu-row ${i === menu.index ? 'highlight' : ''}`}+ title={detail || title}+ onMouseEnter={() => menu.hover(i)}+ // Keep the caret in the field.+ onMouseDown={(e) => e.preventDefault()}+ onClick={() => menu.pick(item)}+ >+ <span className="menu-icon">{icon}</span>+ <Text truncate>{title}</Text>+ <Text truncate grow tone={warning ? 'attention' : 'secondary'}>{detail}</Text>+ </button>+ )+ })}+ </div>+ </div>+ )+}++/** The `/` list: each command's icon, name and what it does. */+export function CommandMenu({ menu }: { menu: ComposerMenuState<SlashCommand> }) {+ const tr = useTr()+ return <ComposerMenu menu={menu} label={tr('Commands')} row={(c) => ({+ key: `${c.action.kind}:${c.name}`,+ icon: <Icon name={c.icon} size={12} color="var(--secondary)" />,+ title: tr(c.title),+ detail: tr(c.detail),+ warning: c.warning,+ })} />+}++/** The `@` list in a group: each member's face, name and description. */+export function MentionMenu({ menu }: { menu: ComposerMenuState<Bot> }) {+ const tr = useTr()+ return <ComposerMenu menu={menu} label={tr('Members')} row={(m) => ({+ key: m.id,+ icon: <BotAvatar bot={m} size={18} animated={false} />,+ title: m.name,+ detail: m.description,+ })} />+}diff --git a/apps/desktop/src/renderer/views/thread/composer.css b/apps/desktop/src/renderer/views/thread/composer.cssindex 2a8b2191..ebe88321 100644--- a/apps/desktop/src/renderer/views/thread/composer.css+++ b/apps/desktop/src/renderer/views/thread/composer.css@@ -1,11 +1,4 @@-/* The box, its mentions row and its attachments. */-.mentions {- display: flex;- gap: 6px;- padding: 0 16px 6px;- overflow-x: auto;-}-.mention,+/* The box and its attachments. */.file-chip {display: flex;align-items: center;@@ -217,8 +210,8 @@color: var(--tertiary);}-/* The `/` command list, floating over the transcript above the box. */-.command-menu {+/* The `/` and `@` lists, floating over the transcript above the box. */+.composer-menu {position: absolute;left: 0;right: 0;@@ -232,25 +225,10 @@transform: translateY(4px);transition: opacity var(--fade), transform var(--layout);}-.command-menu.shown {+.composer-menu.shown {opacity: 1;transform: none;}-.command-menu .menu-panel {+.composer-menu .menu-panel {max-height: 300px;}-.command-title {- flex: none;-}-.command-detail {- flex: 1;- min-width: 0;- overflow: hidden;- text-overflow: ellipsis;- white-space: nowrap;- text-align: left;- color: var(--secondary);-}-.command-detail.warning {- color: var(--attention);-}diff --git a/apps/desktop/src/renderer/views/thread/mentions.test.ts b/apps/desktop/src/renderer/views/thread/mentions.test.tsnew file mode 100644index 00000000..f816441c--- /dev/null+++ b/apps/desktop/src/renderer/views/thread/mentions.test.ts@@ -0,0 +1,41 @@+import assert from 'node:assert/strict'+import { test } from 'node:test'+import { normalizeBot } from '../../../shared/models.ts'+import { mentionSuggestions, returnMentions, withMention } from './mentions.ts'++const member = (name: string) => normalizeBot({ id: name, name })+const suggested = (draft: string, ...names: string[]) => mentionSuggestions(draft, names.map(member)).map((m) => m.name)++test('a mention starts after a space and stays short and on one line', () => {+ assert.deepEqual(suggested('@', 'Ada', 'Bo'), ['Ada', 'Bo'])+ assert.deepEqual(suggested('hi @AD', 'Ada', 'Bo'), ['Ada'])+ assert.deepEqual(suggested('mail@host', 'host'), [])+ assert.deepEqual(suggested(`@${'x'.repeat(25)}`, 'x'.repeat(30)), [])+ assert.deepEqual(suggested('@Ada\nnext', 'Ada\nnext'), [])+})++test('an @ followed by a space is ordinary text', () => {+ assert.deepEqual(suggested('meet @ home', 'My Home'), [])+ assert.deepEqual(suggested('meet @ ', 'My Home'), [])+})++test('a full name and its space end the list, but a longer name can still be typed', () => {+ assert.deepEqual(suggested('@Alpha ', 'Alpha', 'Alpha Two'), [])+ assert.deepEqual(suggested('@alpha ', 'Alpha', 'Alpha Two'), [])+ assert.deepEqual(suggested('@Review ', 'Review', 'Code Review Bot'), [])+ assert.deepEqual(suggested('@Alpha', 'Alpha', 'Alpha Two'), ['Alpha', 'Alpha Two'])+ assert.deepEqual(suggested('@Alpha T', 'Alpha', 'Alpha Two'), ['Alpha Two'])+ assert.deepEqual(suggested('@Code ', 'Codex', 'Code Review'), ['Code Review'], 'no member is called just Code')+})++test('picking replaces the @partial and leaves room for the message', () => {+ assert.equal(withMention('@', member('Ada')), '@Ada ')+ assert.equal(withMention('ask me@home then @ad', member('Ada')), 'ask me@home then @Ada ')+})++test('Return picks a member, but sends a whole @all or @everyone', () => {+ const allen = member('Allen')+ assert.equal(returnMentions(allen, '@al'), true)+ assert.equal(returnMentions(allen, '@allen'), true)+ for (const draft of ['@all', 'thanks @ALL', '@everyone', '@all ']) assert.equal(returnMentions(allen, draft), false, draft)+})diff --git a/apps/desktop/src/renderer/views/thread/mentions.ts b/apps/desktop/src/renderer/views/thread/mentions.tsnew file mode 100644index 00000000..5ed7a660--- /dev/null+++ b/apps/desktop/src/renderer/views/thread/mentions.ts@@ -0,0 +1,34 @@+// The composer's `@` list in a group: who it offers, and what picking one writes. The rules for who+// a message reaches are the host's: docs/features/groups-and-replies.md.+import type { Bot } from '../../../shared/models.ts'++/**+ * The `@partial` being typed at the end of the draft, lowercased, if any. A member's full name and+ * its space end it, so the next Return sends instead of offering a longer name that holds this one.+ */+function mentionQuery(draft: string, members: Bot[]): string | null {+ const at = draft.lastIndexOf('@')+ if (at < 0 || (at > 0 && !/\s/.test(draft[at - 1]!))) return null+ const query = draft.slice(at + 1).toLowerCase()+ if (/^\s|\n/.test(query) || query.length > 24) return null+ return members.some((m) => query === `${m.name.toLowerCase()} `) ? null : query+}++/** The group's `members` whose name holds the `@partial` at the end of the draft. */+export function mentionSuggestions(draft: string, members: Bot[]): Bot[] {+ const query = mentionQuery(draft, members)+ return query === null ? [] : members.filter((m) => m.name.toLowerCase().includes(query))+}++/** The draft with the `@partial` at its end replaced by `member`'s name, ready for the message. */+export function withMention(draft: string, member: Bot): string {+ return `${draft.slice(0, draft.lastIndexOf('@'))}@${member.name} `+}++/**+ * What Return does with a member highlighted: pick it, except on a whole `@all` or `@everyone`,+ * which the list doesn't offer and which sends to the room.+ */+export function returnMentions(_picked: Bot, draft: string): boolean {+ return !/(^|\s)@(all|everyone)\s*$/i.test(draft)+}diff --git a/apps/ios/Kit/Sources/CodyncUI/Thread/CommandList.swift b/apps/ios/Kit/Sources/CodyncUI/Thread/CommandList.swiftdeleted file mode 100644index f31f2a84..00000000--- a/apps/ios/Kit/Sources/CodyncUI/Thread/CommandList.swift+++ /dev/null@@ -1,47 +0,0 @@-import CodyncKit-import SwiftUI--/// The `/` list above the box: each command's icon, name and what it does; tapping one runs it.-struct CommandList: View {- let commands: [SlashCommand]- let pick: (SlashCommand) -> Void-- var body: some View {- // Hugs its rows; scrolls only once they're taller than 280 points.- CappedHeight(max: 280) {- ViewThatFits(in: .vertical) {- rows- ScrollView { rows }.scrollIndicators(.hidden)- }- }- .glass(in: RoundedRectangle(cornerRadius: 20, style: .continuous))- }-- private var rows: some View {- VStack(spacing: 0) {- ForEach(commands) { command in- Button { pick(command) } label: {- HStack(spacing: 10) {- Image(systemName: command.icon)- .font(.subheadline)- .foregroundStyle(Palette.secondary)- .frame(width: 20)- Text(command.title).font(.subheadline).foregroundStyle(Palette.text)- Text(command.detail)- .font(.subheadline)- .foregroundStyle(command.warning ? Palette.warning : Palette.secondary)- .lineLimit(1)- Spacer(minLength: 0)- }- .padding(.horizontal, 14)- .padding(.vertical, 10)- .contentShape(Rectangle())- }- .buttonStyle(PressScale())- .accessibilityLabel(command.title)- .accessibilityHint(command.detail)- }- }- .padding(.vertical, 6)- }-}diff --git a/apps/ios/Kit/Sources/CodyncUI/Thread/Composer.swift b/apps/ios/Kit/Sources/CodyncUI/Thread/Composer.swiftindex c93b43af..30cd8e93 100644--- a/apps/ios/Kit/Sources/CodyncUI/Thread/Composer.swift+++ b/apps/ios/Kit/Sources/CodyncUI/Thread/Composer.swift@@ -5,7 +5,7 @@ import UniformTypeIdentifiers/// The message box under a chat: send, or stop while the bot (or the group) is working/// there. A leading `/` lists commands (a group's act on its bots); in a group, typing `@`-/// suggests its bots.+/// lists its bots.struct Composer: View {let botId: String/// The message the next send quotes, shown above the field until sent or cancelled.@@ -61,19 +61,10 @@ struct Composer: View {return L10n.tr(key).replacingOccurrences(of: "{name}", with: name)}- /// The `@partial` being typed at the end, if any.- private var mentionQuery: String? {- guard bot?.isGroup == true, let at = draft.lastIndex(of: "@") else { return nil }- let query = draft[draft.index(after: at)...]- if at > draft.startIndex, !draft[draft.index(before: at)].isWhitespace { return nil }- return query.contains(where: \.isNewline) || query.count > 24 ? nil : String(query)- }-+ /// The group's bots whose name holds the `@partial` at the end of the draft.private var suggestions: [Bot] {- guard let query = mentionQuery else { return [] }- return members.filter {- query.isEmpty || $0.name.localizedCaseInsensitiveContains(query)- }+ guard bot?.isGroup == true, let query = mentionQuery(draft, members: members) else { return [] }+ return members.filter { query.isEmpty || $0.name.localizedCaseInsensitiveContains(query) }}/// A group's bots, which its commands act on.@@ -100,19 +91,9 @@ struct Composer: View {.transition(.move(edge: .bottom).combined(with: .opacity))}if !suggestions.isEmpty {- ScrollView(.horizontal, showsIndicators: false) {- HStack(spacing: 6) {- ForEach(suggestions) { member in- SuggestionChip(title: member.name) {- CharacterAvatar(bot: member, size: 18, animated: false)- } action: {- mention(member)- }- }- }+ MentionList(members: suggestions, pick: mention).padding(.horizontal, 16)- }- .transition(.move(edge: .bottom).combined(with: .opacity))+ .transition(.move(edge: .bottom).combined(with: .opacity))}field}@@ -425,23 +406,3 @@ struct Composer: View {}}}--/// One suggestion above the box: a bot to @mention.-private struct SuggestionChip<Icon: View>: View {- let title: String- @ViewBuilder let icon: Icon- let action: () -> Void-- var body: some View {- Button(action: action) {- HStack(spacing: 6) {- icon- Text(title).font(.subheadline).foregroundStyle(Palette.text)- }- .padding(.horizontal, 10)- .padding(.vertical, 6)- .background(Palette.surface, in: Capsule())- }- .buttonStyle(PressScale())- }-}diff --git a/apps/ios/Kit/Sources/CodyncUI/Thread/ComposerList.swift b/apps/ios/Kit/Sources/CodyncUI/Thread/ComposerList.swiftnew file mode 100644index 00000000..7595d54f--- /dev/null+++ b/apps/ios/Kit/Sources/CodyncUI/Thread/ComposerList.swift@@ -0,0 +1,93 @@+import CodyncKit+import SwiftUI++/// A list above the box, not a menu (the system-menu rule doesn't apply): hugs its rows and scrolls only once they're+/// taller than 280 points.+private struct ComposerList<Rows: View>: View {+ @ViewBuilder let rows: Rows++ var body: some View {+ CappedHeight(max: 280) {+ ViewThatFits(in: .vertical) {+ stack+ ScrollView { stack }.scrollIndicators(.hidden)+ }+ }+ .glass(in: RoundedRectangle(cornerRadius: 20, style: .continuous))+ }++ private var stack: some View {+ VStack(spacing: 0) { rows }.padding(.vertical, 6)+ }+}++/// A row of a list above the box: its icon, name and what it is; a tap picks it.+private struct ComposerListRow<Icon: View>: View {+ let title: String+ let detail: String+ var warning = false+ let pick: () -> Void+ @ViewBuilder let icon: Icon++ var body: some View {+ Button(action: pick) {+ HStack(spacing: 10) {+ icon.frame(width: 20)+ Text(title)+ .font(.subheadline)+ .foregroundStyle(Palette.text)+ .lineLimit(1)+ .layoutPriority(1)+ Text(detail)+ .font(.subheadline)+ .foregroundStyle(warning ? Palette.warning : Palette.secondary)+ .lineLimit(1)+ Spacer(minLength: 0)+ }+ .padding(.horizontal, 14)+ .padding(.vertical, 10)+ .contentShape(Rectangle())+ }+ .buttonStyle(PressScale())+ .accessibilityLabel(title)+ .accessibilityValue(detail)+ }+}++/// The `/` list: each command's icon, name and what it does; a tap runs it.+struct CommandList: View {+ let commands: [SlashCommand]+ let pick: (SlashCommand) -> Void++ var body: some View {+ ComposerList {+ ForEach(commands) { command in+ ComposerListRow(title: command.title, detail: command.detail, warning: command.warning) {+ pick(command)+ } icon: {+ Image(systemName: command.icon)+ .font(.subheadline)+ .foregroundStyle(Palette.secondary)+ }+ }+ }+ }+}++/// The `@` list in a group: each member's face, name and description; a tap mentions it.+struct MentionList: View {+ let members: [Bot]+ let pick: (Bot) -> Void++ var body: some View {+ ComposerList {+ ForEach(members) { member in+ ComposerListRow(title: member.name, detail: member.description) {+ pick(member)+ } icon: {+ CharacterAvatar(bot: member, size: 18, animated: false)+ }+ }+ }+ }+}diff --git a/apps/ios/Kit/Sources/CodyncUI/Thread/SlashCommands.swift b/apps/ios/Kit/Sources/CodyncUI/Thread/SlashCommands.swiftindex 0b59bfb8..a531bc1c 100644--- a/apps/ios/Kit/Sources/CodyncUI/Thread/SlashCommands.swift+++ b/apps/ios/Kit/Sources/CodyncUI/Thread/SlashCommands.swift@@ -59,3 +59,13 @@ enum SlashCommands {warning: fast.state == .refused, action: .fast)]}}++/// The `@partial` being typed at the end of a group's draft, if any. A member's full name and its space end it, so the+/// list doesn't stay up for a longer name that holds this one.+func mentionQuery(_ draft: String, members: [Bot]) -> String? {+ guard let at = draft.lastIndex(of: "@") else { return nil }+ if at > draft.startIndex, !draft[draft.index(before: at)].isWhitespace { return nil }+ let query = String(draft[draft.index(after: at)...])+ if query.first?.isWhitespace == true || query.contains(where: \.isNewline) || query.count > 24 { return nil }+ return members.contains { query.lowercased() == "\($0.name.lowercased()) " } ? nil : query+}diff --git a/apps/ios/Kit/Tests/CodyncUITests/SlashCommandsTests.swift b/apps/ios/Kit/Tests/CodyncUITests/SlashCommandsTests.swiftindex 0c71915d..74f50d4a 100644--- a/apps/ios/Kit/Tests/CodyncUITests/SlashCommandsTests.swift+++ b/apps/ios/Kit/Tests/CodyncUITests/SlashCommandsTests.swift@@ -67,6 +67,18 @@ private let installed = [("pdf", "PDF"), ("code-review", "Code Review"), ("xlsx"#expect(SlashCommands.builtIn(for: try bot(#"{"id":"b","fastModeSupport":"unsupported"}"#), draft: "/fast") == nil, "without Fast mode it reaches the agent")}+@Test func aMentionStartsAfterASpaceAndAFullNameEndsIt() throws {+ let members = [try bot(#"{"id":"a","name":"Alpha"}"#), try bot(#"{"id":"t","name":"Alpha Two"}"#)]+ #expect(mentionQuery("@", members: members) == "")+ #expect(mentionQuery("hi @Re", members: members) == "Re")+ #expect(mentionQuery("mail@host", members: members) == nil)+ #expect(mentionQuery("@" + String(repeating: "x", count: 25), members: members) == nil)+ #expect(mentionQuery("@Alpha\nnext", members: members) == nil)+ #expect(mentionQuery("meet @ home", members: members) == nil, "an @ and a space is ordinary text")+ #expect(mentionQuery("@alpha ", members: members) == nil)+ #expect(mentionQuery("@Alpha T", members: members) == "Alpha T", "a longer name can still be typed")+}+@MainActor @Test func theCommandListHugsItsRowsAndScrollsPastItsCap() {func height(_ count: Int) -> CGFloat {let commands = (0..<count).map {diff --git a/apps/ios/WhatsNew.md b/apps/ios/WhatsNew.mdindex 5765cd6d..094197a8 100644--- a/apps/ios/WhatsNew.md+++ b/apps/ios/WhatsNew.md@@ -11,11 +11,13 @@ a version without one gets a generic "Bug fixes and improvements" line. Delete o- 不登入也能用了:在歡迎畫面選擇「不登入繼續」,手機掃電腦的 QR 碼就能配對,透過 Wi-Fi 或 Tailscale 連線。之後登入,配對會留在手機上;到「管理電腦」按「加入帳號」,電腦確認後就能從任何地方連線。- 電腦可以不加入帳號。配對時電腦會詢問;不加入的話,手機只能用 Wi-Fi 或 Tailscale 連線,之後也能在「管理電腦」加入帳號。- 遠端畫面會照連線設定換路:自動是先直連再走 Cloudflare,Cloudflare 優先則相反。+- 群組裡輸入 @ 會列出成員,一排一個,和 / 指令選單一樣。### en-US- Use Codync without an account: choose Continue without an account on the welcome screen, then scan your computer's QR code. It connects over Wi-Fi or Tailscale. Sign in later and your computers stay paired; Add to account in Manage computers brings each into your account once the computer confirms.- A computer can stay out of your account. It asks when you pair; without it, your phone connects only over Wi-Fi or Tailscale, and you can add it later in Manage computers.- Remote screen now follows the Connection setting: Auto tries direct first, then Cloudflare, and Cloudflare first does the reverse.+- Typing @ in a group lists its members one per row, like the / command list.## 2.40.3### zh-Hantdiff --git a/apps/maestro/mentions.js b/apps/maestro/mentions.jsnew file mode 100644index 00000000..54502bd6--- /dev/null+++ b/apps/maestro/mentions.js@@ -0,0 +1,25 @@+// Makes the group `mentions.yaml` opens, on the host the phone is paired with (HOST_PORT and HOST_TOKEN, passed with+// `-e`). `CLEANUP`, when the flow completes, deletes it and its members 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' },+ body: JSON.stringify(body),+ })+ if (res.status !== 200) throw new Error(`${method}: ${res.status} ${res.body}`)+ return json(res.body)+}++if (typeof CLEANUP !== 'undefined') {+ for (const id of output.made || []) api('deleteBot', { botId: id })+} else {+ const run = Math.random().toString(36).slice(2, 6)+ const member = (name, description) =>+ api('createBot', { name, description, backend: 'custom', command: 'unused', connectors: [], permission: 'auto' }).bot+ const alpha = member(`Mention Alpha ${run}`, 'Reviews the code')+ const beta = member(`Mention Beta ${run}`, 'Writes the docs')+ const group = api('createBot', { name: `Mention Group ${run}`, kind: 'group', members: [alpha.id, beta.id] }).bot+ output.made = [group.id, alpha.id, beta.id]+ output.group = group.name+ output.alpha = alpha.name+ output.beta = beta.name+}diff --git a/apps/maestro/mentions.yaml b/apps/maestro/mentions.yamlnew file mode 100644index 00000000..587a377d--- /dev/null+++ b/apps/maestro/mentions.yaml@@ -0,0 +1,43 @@+# Typing @ in a group lists its members one per row, with their descriptions, and a tap fills in the name. The phone must+# already be signed in and paired with the host (a worktree's sandbox, docs/guides/dev-app.md#worktree-sandboxes), so run it+# apart from `welcome`, whose clearState undoes that; the flow makes its own group there:+# maestro --device "<simulator udid>,<adb serial>" test --shard-all 2 --include-tags composer \+# -e HOST_PORT=<sandbox port> -e HOST_TOKEN="$(cat ~/.codync-dev-<sandbox name>/token)" \+# -e STEER_AGENT="$PWD/host/tests/fixtures/steer_agent.py" apps/maestro+appId: com.pokai.Codync.ios.dev+tags:+ - composer+onFlowComplete:+ - runScript:+ file: mentions.js+ env:+ CLEANUP: "true"+---+- runScript: mentions.js+- runFlow:+ when:+ platform: iOS+ commands:+ - launchApp:+ appId: com.pokai.Codync.ios.dev+ arguments:+ "-reviewInvitationOff": true+- runFlow:+ when:+ platform: Android+ commands:+ - launchApp:+ appId: com.pokai.Codync.android.dev+- tapOn: ${output.group}+- tapOn: "Ask everyone.*"+- inputText: "@"+- assertVisible: ${output.alpha}+- assertVisible:+ text: ${output.beta}+ below:+ text: ${output.alpha}+- assertVisible: "Reviews the code"+- takeScreenshot: mention-list+- tapOn: ${output.beta}+- assertNotVisible: "Reviews the code"+- assertVisible: "@${output.beta}.*"diff --git a/docs/features/groups-and-replies.md b/docs/features/groups-and-replies.mdindex d184d0d2..641b6594 100644--- a/docs/features/groups-and-replies.md+++ b/docs/features/groups-and-replies.md@@ -49,6 +49,13 @@ quotes itself.- Who answers the first round: the members the user @-mentioned (full name, name withoutspaces, or first word; `@all` / `@everyone`) or replied to, or everyone if none is. A reply toa member's message counts like `@`-mentioning it.+- Typing `@` lists the group's members above the box, filtered by what follows it: each row shows+ the face, name and description, in the same list as the `/` commands+ ([marketplace](marketplace.md#commands)). On the desktop ↑/↓ move the highlight, Tab or Return+ picks it, and Escape hides the list until the draft changes; on the phones a tap picks. A+ member's full name and its space end the list, so the next Return sends, and Return on a whole+ `@all` / `@everyone` sends, since the list doesn't offer them. The terminal has no `@` list: you+ type the name.- Who answers a later round: only the members another member @-mentioned in this room turn(a member's `@all` / `@everyone`: all the others) and who haven't spoken or been asked since(one that passed after seeing the mention isn't asked again). Nobody named,diff --git a/web/content/docs/groups.mdx b/web/content/docs/groups.mdxindex 8e832aed..6891fdac 100644--- a/web/content/docs/groups.mdx+++ b/web/content/docs/groups.mdx@@ -40,7 +40,7 @@ Each member's reply is the one message the room sees. Its tool calls, thoughts a### @-mentions-To ask just one bot, mention it: its full name, its name without spaces, or its first word all work, in any letter case. On the desktop and iPhone, typing `@` in a group suggests its members.+To ask just one bot, mention it: its full name, its name without spaces, or its first word all work, in any letter case. On the desktop, iPhone and Android, typing `@` in a group lists its members. On the desktop, ↑ and ↓ move through the list, Return or Tab picks a member, and Esc hides it. Return after `@all` or `@everyone` sends the message.Replying to a member's message counts as mentioning it. To reply, long-press the message on iPhone, use **Reply** below the message on the desktop, or press `r` in the terminal UI.