Where agent teams gather. Cross-platform team chat where AI agents are first-class teammates — with cloud or bring-your-own (Claude Code / Codex) brains.
TypeScript
fix(mobile): tapping an agent opened nothing when no DM existed yet
zhuangxialie932e681ae5a9
diff --git a/src/mobile/MobileAgents.tsx b/src/mobile/MobileAgents.tsxindex 529a7a1..7a6ea85 100644--- a/src/mobile/MobileAgents.tsx+++ b/src/mobile/MobileAgents.tsx@@ -1,4 +1,5 @@import { useMemo, useState } from 'react'+import { api } from '@/api/client'import { Avatar } from '@/components/Avatar'import { useMe } from '@/stores/auth'import { useApp } from '@/stores/app'@@ -47,6 +48,9 @@ export function MobileAgents() {const meId = useMe()const [editing, setEditing] = useState<Participant | null>(null)const [editorOpen, setEditorOpen] = useState(false)+ // Which agent's DM is being created right now, so a double-tap on a slow+ // network cannot fire two openDirect calls.+ const [opening, setOpening] = useState<string | null>(null)// Real roster, scoped to the active workspace via the participants store// (which is itself re-fetched on workspace switch). Drop departed agents@@ -59,15 +63,35 @@ export function MobileAgents() {}}, [byId, meId])- /** Tap an agent → jump to the direct chat with me + them. */- const goChat = (agentId: string) => {- if (!meId) return+ /** Tap an agent → jump to the direct chat with me + them, creating it if+ * this member does not have one yet.+ *+ * The server seeds the agent's DM only for whoever hired it, so every other+ * member has no row for any agent added after they joined. Without the+ * fallback the card was a dead tap for them — no navigation, no error — while+ * the same tap on desktop worked. `openDirect` is the idempotent create-or-+ * find the desktop card and MobileParticipantInfo already use. */+ const goChat = async (agentId: string) => {+ if (!meId || opening) returnconst direct = convoList.find((c) =>c.kind === 'direct' && c.members.includes(meId) && c.members.includes(agentId),)if (direct) {setView('conversations')select(direct.id)+ return+ }+ setOpening(agentId)+ try {+ const { id } = await api.openDirect(agentId)+ // Refresh so the brand-new DM is in the store before we navigate into it.+ await useConversations.getState().reload()+ setView('conversations')+ select(id)+ } catch (err) {+ console.warn('[MobileAgents] openDirect failed', err)+ } finally {+ setOpening(null)}}@@ -112,7 +136,8 @@ export function MobileAgents() {type="button"className="w-full text-left bg-cloud rounded-[14px] p-3.5 active:scale-[0.99] transition"style={{ border: '1px solid var(--ink-100)' }}- onClick={() => goChat(p.id)}+ onClick={() => { void goChat(p.id) }}+ disabled={opening === p.id}><div className="flex items-start gap-3 mb-2.5"><Avatar p={p} size={48} />diff --git a/tests/agents-card-opens-dm.test.ts b/tests/agents-card-opens-dm.test.tsnew file mode 100644index 0000000..444fd28--- /dev/null+++ b/tests/agents-card-opens-dm.test.ts@@ -0,0 +1,45 @@+/**+ * Tapping an agent in the Agents list has to open a chat with it — on both+ * surfaces, including when this member has no DM row yet.+ *+ * The server seeds an agent's 1:1 only for whoever hired it+ * ("Auto-create a 1:1 direct conversation between the creator and the new+ * agent", server/src/api/router.ts). Everyone else has no row for any agent+ * added after they joined, so the lookup finds nothing. Desktop handles that+ * with an `api.openDirect` fallback; mobile's card had the same lookup with no+ * else branch, so for those members the tap did nothing at all — no+ * navigation, no error — while the identical tap on desktop worked.+ *+ * There is no React harness in this repo, so the source is what can be+ * checked. The invariant is parity: whichever surface is edited next, both+ * must still create the conversation rather than give up when it is absent.+ */+import assert from 'node:assert/strict'+import { readFile } from 'node:fs/promises'+import { describe, it } from 'node:test'++const SURFACES = [+ { name: 'desktop', file: '../src/desktop/AgentsView.tsx' },+ { name: 'mobile', file: '../src/mobile/MobileAgents.tsx' },+] as const++/** The body from the "is there already a direct with this agent" lookup to the+ * end of the handler that owns it. */+function tapHandler(source: string): string {+ const lookup = source.indexOf("c.kind === 'direct'")+ assert.notEqual(lookup, -1, 'the existing-direct lookup moved; this guard needs updating')+ return source.slice(lookup, lookup + 1200)+}++describe('agents list opens a DM', () => {+ for (const { name, file } of SURFACES) {+ it(`${name} creates the conversation when none exists yet`, async () => {+ const source = await readFile(new URL(file, import.meta.url), 'utf8')+ assert.match(+ tapHandler(source), /api\.openDirect\(/,+ `${name}: tapping an agent with no existing DM row falls through to nothing — `+ + 'every member except the one who hired that agent gets a dead tap',+ )+ })+ }+})