The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
fix(super-tabs): count waiting tags in quiet conversations too, as the tag list shows them (#1838)
0xken150fe077844c4a
diff --git a/backend/integration/superTabs.test.ts b/backend/integration/superTabs.test.tsindex 5971cd6d7..5b2cc52df 100644--- a/backend/integration/superTabs.test.ts+++ b/backend/integration/superTabs.test.ts@@ -2690,6 +2690,30 @@ describe('Lead mentions', () => {expect(await list(tab, peer, 'earlier')).toEqual([expect.objectContaining({ messageId, resolvedBy: 'reply' })])})+ it('counts a tag in a conversation gone quiet, as the list shows it, on every read, and never once the person cannot read it', async () => {+ const { tab, lead, group } = await tagged()+ const other = (await run(tab, { type: 'conversation.create', title: 'Pricing page', brief: '', checks: [] })).result.conversationId as string+ await run(tab, { type: 'conversation.agent', conversationId: other, agentId: lead, present: true, lead: true })+ await run(tab, { type: 'message.send', conversationId: other, text: 'Check the prices.', replyTo: null, recipientIds: [], mentions: [peer.sub] }, host, lead)+ // Ordinary loads no longer read it (sweeps.ts puts quiet conversations to sleep).+ await db.swarmGroup.updateMany({ where: { tabId: tab, key: group }, data: { dormant: true } })+ const derived = async (url: string) => {+ const response = await app.inject({ method: 'GET', url: `/api/super-tabs/${tab}/${url}`, headers: { authorization: `Bearer ${peer.sub}` } })+ expect(response.statusCode, response.body).toBe(200)+ return response.json().data as { cursor: string; derived: { mentionsWaiting?: number } }+ }+ const first = await derived('parts')+ expect((await list(tab, peer, 'waiting')).map(m => m.conversationId).sort()).toEqual([group, other].sort())+ expect(first.derived.mentionsWaiting).toBe(2)+ expect((await derived(`changes?cursor=${first.cursor}`)).derived.mentionsWaiting).toBe(2)+ expect((await waiting(tab, peer)).mentionsWaiting).toBe(2)+ await run(tab, { type: 'project.sharing', projectId: 'lead', visibility: 'private', memberIds: [] })+ expect(await db.swarmGroup.findFirst({ where: { tabId: tab, key: group }, select: { dormant: true } })).toEqual({ dormant: true })+ expect(await list(tab, peer, 'waiting')).toEqual([])+ expect((await derived('parts')).derived.mentionsWaiting).toBe(0)+ expect((await waiting(tab, peer)).mentionsWaiting).toBe(0)+ })+it('lets a tagged viewer mark it done', async () => {const { tab } = await tagged('viewer')const [mention] = await list(tab, peer, 'waiting')diff --git a/backend/src/superTabs/mentions.ts b/backend/src/superTabs/mentions.tsindex 536e35234..8df0db9b8 100644--- a/backend/src/superTabs/mentions.ts+++ b/backend/src/superTabs/mentions.ts@@ -60,15 +60,24 @@ export async function markDone(tx: Tx, tabId: string, id: string, personId: striawait tx.superTabMention.updateMany({ where: { id, tabId, personId, ...waiting }, data: { resolvedAt: new Date(now), resolvedBy: 'done' } })}-/** The person's own unexpired tags in conversations they can still read, newest first. The badge counts this same list.+/** The person's own unexpired tags in conversations they can still read, newest first, each with its conversation. The badge+ * counts this same list. Ordinary loads leave quiet (dormant) conversations out of the state, so the ones a tag is in are+ * read here: the count and the list check the same conversations whichever state they get.* ponytail: capped at 500 per state; page it if a person ever gets more in 30 days. */async function readable(tx: Tx, tabId: string, state: SuperTabState, actor: Extract<Actor, { kind: 'person' }>, now: number, open: boolean) {person(state, actor.userId)const rows = await tx.superTabMention.findMany({ where: { tabId, personId: actor.userId, createdAt: { gt: new Date(now - MENTION_EXPIRY_MS) },...(open ? waiting : { resolvedAt: { not: null } }) }, orderBy: { createdAt: 'desc' }, take: 500 })- return rows.filter(row => {- const group = state.conversations.find(c => c.id === row.conversationId)- return !!group && !isLeads(group) && canReadGroup(state, actor, group)+ const groups = new Map(state.conversations.map(c => [c.id, c]))+ const missing = [...new Set(rows.map(r => r.conversationId))].filter(id => !groups.has(id))+ if (missing.length) {+ for (const row of await tx.swarmGroup.findMany({ where: { tabId, deleted: false, key: { in: missing } }, select: { key: true, data: true } })) {+ groups.set(row.key, row.data as unknown as Conversation)+ }+ }+ return rows.flatMap(row => {+ const group = groups.get(row.conversationId)+ return group && !isLeads(group) && canReadGroup(state, actor, group) ? [{ row, group }] : []})}@@ -77,11 +86,10 @@ export async function mentionsWaiting(tx: Tx, tabId: string, state: SuperTabStat}export async function listMentions(tx: Tx, tabId: string, state: SuperTabState, actor: Extract<Actor, { kind: 'person' }>, now: number, open: boolean) {- const rows = await readable(tx, tabId, state, actor, now, open)- const messages = rows.length ? await tx.superTabMessage.findMany({ where: { tabId, id: { in: rows.map(r => r.messageId) } },+ const tagged = await readable(tx, tabId, state, actor, now, open)+ const messages = tagged.length ? await tx.superTabMessage.findMany({ where: { tabId, id: { in: tagged.map(t => t.row.messageId) } },select: { id: true, text: true, author: true } }) : []- return rows.map(row => {- const group = state.conversations.find(c => c.id === row.conversationId)!+ return tagged.map(({ row, group }) => {const message = messages.find(m => m.id === row.messageId)const author = message?.author as { name?: string; displayName?: string } | undefinedreturn { id: row.id, projectId: row.projectId, projectName: projectOf(state, group.projectId ?? 'lead').name,