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
Merge batch 11-03 bg: #2676 (#2682)
0xken15cc0a661e75b3
diff --git a/backend/integration/superTabFollowedThreads.test.ts b/backend/integration/superTabFollowedThreads.test.tsindex 74589221b..3033d8832 100644--- a/backend/integration/superTabFollowedThreads.test.ts+++ b/backend/integration/superTabFollowedThreads.test.ts@@ -21,6 +21,7 @@ import { buddyChatId } from '../src/superTabs/buddies.js'import { resetInboxReads } from '../src/superTabs/read/inbox.js'import { MAX_READ_THREADS, resetThreadsReads, TAGGED_THREADS, THREADS_READS, THREADS_WINDOW_MS } from '../src/superTabs/read/followedThreads.js'import type { Author, Conversation, SuperTabState } from '../src/superTabs/model.js'+import { stableId } from '../src/superTabs/model.js'import { THREAD_MARK_CAP, writeThreadFollow, writeThreadMark } from '../src/superTabs/readMarks.js'import { writeLegacySwarm } from '../scripts/swarm-parts/legacy.js'import { NOW, outsider as outsiderActor, owner as ownerActor, peer as peerActor, swarm } from '../src/superTabs/read/fixture.test-support.js'@@ -621,3 +622,49 @@ describe('a thread the person is tagged in, in a chat they never opened (GET /thexpect(JSON.stringify(body.data)).not.toMatch(/Newer/)})})++// Task #2265 (Diego): a person's own message from the phone, the web or the dial left the chat bold on their other apps, and a chat+// set to All could tell them of it, as a send never moved its author's mark.+describe('a person\'s own message leaves the chat read for them', () => {+ const send = async (tabId: string, conversationId: string, as: AuthUser, text: string, more: Record<string, unknown> = {}) => {+ const answer = await call('POST', `/api/super-tabs/${tabId}/commands`, as, { operationId: randomUUID(),+ command: { type: 'message.send', conversationId, text, replyTo: null, recipientIds: [], ...more } })+ expect(answer.status).toBe(200)+ return answer.body.data.result.messageId as string+ }+ const markOf = async (tabId: string, conversationId: string, as: AuthUser) =>+ (await db.superTabReadMark.findUnique({ where: { id: stableId(tabId, conversationId, as.sub) }, select: { sequence: true } }))?.sequence ?? 0++ it('moves their mark to their message, and nobody else\'s', async () => {+ const s = await scene()+ const id = await send(s.tabId, s.web, owner, 'From my phone')+ expect(await markOf(s.tabId, s.web, owner)).toBe(await sequenceOf(id))+ expect(await markOf(s.tabId, s.web, peer)).toBe(0)+ })++ it('tells their other apps in the same read that says the chat moved', async () => {+ const s = await scene()+ const id = await send(s.tabId, s.web, owner, 'From my phone')+ const derived = (await call('GET', `/api/super-tabs/${s.tabId}/parts`, owner)).body.data.derived+ expect(derived.readMarks[s.web]).toBe(await sequenceOf(id))+ })++ it('leaves the mark for a reply only in a thread, and moves it for one also sent to the chat', async () => {+ const s = await scene()+ const root = await send(s.tabId, s.web, owner, 'Root')+ const at = await markOf(s.tabId, s.web, owner)+ await send(s.tabId, s.web, owner, 'Only in the thread', { replyTo: root })+ expect(await markOf(s.tabId, s.web, owner)).toBe(at)+ const also = await send(s.tabId, s.web, owner, 'Also in the chat', { replyTo: root, alsoSend: true })+ expect(await markOf(s.tabId, s.web, owner)).toBe(await sequenceOf(also))+ })++ it('never reads a thread for them: a teammate\'s reply it passes still counts in the inbox', async () => {+ const s = await scene()+ const [root] = await insert(s.tabId, s.web, [{ text: 'Owner root', author: personAuthor(owner) }])+ await markRead(s.tabId, s.web, await sequenceOf(root!), owner)+ await insert(s.tabId, s.web, [{ text: 'Worker reply', author: agentAuthor(s.worker), thread: root }])+ await send(s.tabId, s.web, owner, 'From my phone')+ expect(roots((await inbox(s.tabId, owner)).body.data.threads)).toEqual(['Owner root'])+ })+})diff --git a/backend/src/superTabs/read/service.ts b/backend/src/superTabs/read/service.tsindex ce519b04f..ac84b360b 100644--- a/backend/src/superTabs/read/service.ts+++ b/backend/src/superTabs/read/service.ts@@ -9,8 +9,8 @@ import { isTeamSession, TEAM_SESSION_LIMITED, TEAM_SESSION_MESSAGE } from '../..import { agentOnly, author, fail, groupForBuddy, isLeads, seenMachineIds, stableId, SuperTabError, visibleState, type Actor, type AgentStart, type SuperTabState } from '../model.js'import { mentionsDigest, swarmsWithTags, waitingMentions, waitingTagConversations } from '../mentions.js'import { decisionsWaiting } from '../decisions.js'-import { readMarks, readThreadMarks, writeReadMark, writeThreadFollow, writeThreadMark } from '../readMarks.js'-import { activityDigest, listActivity, markActivityChatRead, markActivityRead, markActivityThreadRead, type ActivityItem } from '../activity.js'+import { readMarks, readThreadMarks, writeThreadFollow, writeThreadMark } from '../readMarks.js'+import { activityDigest, listActivity, markActivityRead, markActivityThreadRead, type ActivityItem } from '../activity.js'import { readChatSettings, writeChatSetting, type NotifyLevel } from '../chatSettings.js'import { deliveredCopies } from '../pageReads.js'import { readBy } from '../parts/indexed.js'@@ -36,7 +36,7 @@ import { cursorFor, readCursor } from './cursor.js'import { changesFor } from './changes.js'import { envelope, groupView, readerView, seenIn, type ReaderView } from './views.js'import { decodeDormantPage, encodeDormantPage } from './dormantPage.js'-import { seedThreadMarks } from './threadMarkSeeds.js'+import { moveChatMark } from './threadMarkSeeds.js'import { memberSwarms } from '../swarmRows.js'type LoadOptions = NonNullable<Parameters<typeof parts.loadActive>[2]>@@ -233,12 +233,7 @@ export class SwarmReads {if (isTeamSession(user)) fail(TEAM_SESSION_LIMITED, TEAM_SESSION_MESSAGE, 403)const { group, state } = await this.readGroup(user, tabId, conversationId)const next = Math.min(sequence, group.data!.lastMessageSequence), now = this.now()- const held = await this.db.superTabReadMark.findUnique({ where: { id: stableId(tabId, conversationId, user.sub) }, select: { sequence: true } })- const safe = await seedThreadMarks(this.db, { tabId, state, personId: user.sub, conversationId, old: held?.sequence ?? 0, next, now })- const stored = await writeReadMark(this.db, { tabId, personId: user.sub, conversationId, sequence: safe, now })- // The replies also in the chat that the mark passes are read in Activity too (activity.ts).- await markActivityChatRead(this.db, { tabId, personId: user.sub, conversationId, sequence: stored, now })- return { sequence: stored }+ return { sequence: await moveChatMark(this.db, { tabId, state, personId: user.sub, conversationId, next, now }) }}/** Moves the person's mark of thread `threadId` in a conversation they can read forward, never past the conversation'sdiff --git a/backend/src/superTabs/read/threadMarkSeeds.ts b/backend/src/superTabs/read/threadMarkSeeds.tsindex 68f4d15a4..91b7753e4 100644--- a/backend/src/superTabs/read/threadMarkSeeds.ts+++ b/backend/src/superTabs/read/threadMarkSeeds.ts@@ -19,7 +19,8 @@import type { PrismaClient } from '@prisma/client'import { logger } from '../../utils/logger.js'import { stableId, type Author, type SuperTabState } from '../model.js'-import { seedThreadMark } from '../readMarks.js'+import { seedThreadMark, writeReadMark } from '../readMarks.js'+import { markActivityChatRead } from '../activity.js'import { readBy } from '../parts/indexed.js'import { BEHIND_THREADS, groupBy, isReply, MEMBER_SCAN, newestInThreads, readable, row, SCAN_FIELDS, UNREAD_SCAN, type Row } from './inbox.js'@@ -35,6 +36,17 @@ export interface SeedInput { tabId: string; state: SuperTabState; personId: stri/** A row is a thread reply: the root is another row. */const REPLY = { $and: [{ $ne: [{ $ifNull: ['$thread', null] }, null] }, { $ne: ['$thread', '$_id'] }] }+/** Moves the person's mark of a chat forward to `next`, as a read or their own message does: threads it passes keep what they had+ * (above), and the replies also in the chat that it passes are read in Activity too (activity.ts). The mark as stored. */+export async function moveChatMark(db: PrismaClient, input: Omit<SeedInput, 'old'>): Promise<number> {+ const { tabId, personId, conversationId, now } = input+ const held = await db.superTabReadMark.findUnique({ where: { id: stableId(tabId, conversationId, personId) }, select: { sequence: true } })+ const safe = await seedThreadMarks(db, { ...input, old: held?.sequence ?? 0 })+ const stored = await writeReadMark(db, { tabId, personId, conversationId, sequence: safe, now })+ await markActivityChatRead(db, { tabId, personId, conversationId, sequence: stored, now })+ return stored+}+/** Marks the threads described above and answers the safe next chat mark. */export async function seedThreadMarks(db: PrismaClient, input: SeedInput): Promise<number> {const { tabId, state, personId, conversationId, old, next } = inputdiff --git a/backend/src/superTabs/store.ts b/backend/src/superTabs/store.tsindex 2033cb020..9bfaa6a03 100644--- a/backend/src/superTabs/store.ts+++ b/backend/src/superTabs/store.ts@@ -44,6 +44,7 @@ import { confidentialSessions, otherRegistrations, recordConfidential } from './import { answersRequest, dirtyGroups, noteWorkChanges, projectUpdateRequest, UNANSWERED_REQUEST_MS } from './projectUpdates.js'import { cloneData } from './cloneData.js'import { digestDue, digestMessageId, digestOf, digestRequest, digestSince } from './digest.js'+import { moveChatMark } from './read/threadMarkSeeds.js'import { closedAgents, nextRemovalAt, removeClosedAgents, reopened, restoreRefusal, restoreSessions } from './closedAgents.js'import { sessionRows } from './memberRows.js'import { judgedMachines, loseTasks, nextLossAt, sweepForLead, sweepLiveness, SWEEP_EVERY_MS, unpurgedNotice } from './liveness.js'@@ -1751,6 +1752,14 @@ export class SuperTabStore {if (ledId && leadAt(effects.state) !== undefined && leadAt(effects.state) !== leadAt(original)) await dropHeldTags(tx, tabId, ledId, context.now)await writeMentions(tx, tabId, effects.state, effects.messages, context.now)await writeReplyActivity(tx, tabId, effects.messages, sequences, context.now)+ // Their own message leaves the chat read for them on every app, in the same commit its read answers from (task #2265). A reply+ // only in a thread is not in the chat, and a Team session has no marks (read/service.ts markRead).+ if (command.type === 'message.send' && actor.kind === 'person' && !isTeamSession(user)) {+ const own = effects.messages.filter(m => m.conversationId === command.conversationId && m.author.kind === 'person'+ && m.author.id === actor.userId && (!m.thread || m.thread === m.id || m.alsoInChat))+ const next = Math.max(0, ...own.map(m => sequences.get(m.id) ?? 0))+ if (next) await moveChatMark(tx as unknown as PrismaClient, { tabId, state: effects.state, personId: actor.userId, conversationId: command.conversationId, next, now: context.now })+ }if (command.type === 'mention.done') await markDone(tx, tabId, command.mentionId, context.mention!.personId, context.now)if (command.type === 'message.react') await this.writeReaction(tx, tabId, actor, command, context.now)if (context.avatarUpload) {diff --git a/desktop/test/super_tab_activity_test.dart b/desktop/test/super_tab_activity_test.dartindex a38ae7ed1..38fa7d62d 100644--- a/desktop/test/super_tab_activity_test.dart+++ b/desktop/test/super_tab_activity_test.dart@@ -434,6 +434,25 @@ void main() {expect(told, isEmpty);});+ // Task #2265: the server moves its author's mark in the commit that wrote it.+ test('their own message, with the mark the server moved, is no news: no '+ 'notice, not bold, and no read to find out whose it was', () async {+ final (c, server, told) = await chatSetToAll();+ server.append('From my phone', conversationId: 'offline');+ ((server.state['readMarks'] ??= <String, dynamic>{}) as Map).update(+ 'owner',+ (marks) => {...marks as Map, 'offline': server.revision},+ ifAbsent: () => {'offline': server.revision},+ );+ final reads = <String>[];+ server.onRead = reads.add;+ await c.refresh();+ await settle();+ expect(told, isEmpty);+ expect(c.unread(c.snapshot!.conversation('offline')!), isFalse);+ expect(reads.where((p) => p.contains('offline/messages')), isEmpty);+ });+test('a message whose author can\'t be read is told about, never lost',() async {