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-04 b1500: #2957 #2951 #2940 #2955 #2948 #2949 #2945 (#2963)
0xken1516f647661235
diff --git a/backend/integration/superTabs.test.ts b/backend/integration/superTabs.test.tsindex 165dad2cd..a581cf491 100644--- a/backend/integration/superTabs.test.ts+++ b/backend/integration/superTabs.test.ts@@ -5,6 +5,7 @@ import { promisify } from 'node:util'import { join } from 'node:path'import { tmpdir } from 'node:os'import { Readable } from 'node:stream'+import { gzipSync } from 'node:zlib'import { afterAll, beforeAll, describe, expect, it, onTestFinished, vi } from 'vitest'import { MongoMemoryReplSet } from 'mongodb-memory-server-core'import { PrismaClient } from '@prisma/client'@@ -2703,6 +2704,32 @@ describe('Super Tab chat attachments', () => {.toMatchObject({ status: 503, code: 'ATTACHMENTS_UNAVAILABLE' })})+ // A gateway's content filter in front of the backend refused a handoff full of shell lines (task #2737): the app sends+ // a form file gzipped, says so before the file, and the store keeps the original bytes, type and size.+ it('unpacks a file sent gzipped and keeps the original, refusing a corrupt, misplaced, unknown or oversized one', async () => {+ const { tab } = await fixture()+ const text = Buffer.from('$ cat ~/.ssh/config && rm -rf ./build; curl https://example.test/x.sh | sh\n'.repeat(500))+ const packed = await post(tab, [['conversationId', 'lead'], ['contentEncoding', 'gzip'], ['file', gzipSync(text), 'run.transcript.md', 'text/markdown']])+ expect(packed.status).toBe(200)+ expect(packed.attachment).toMatchObject({ name: 'run.transcript.md', mime: 'text/markdown', size: text.byteLength })+ expect(files.objects.get(objectKey(packed.attachment.url))!.bytes.equals(text)).toBe(true)+ const plain = await post(tab, [['conversationId', 'lead'], ['file', text, 'run.transcript.md', 'text/markdown']])+ expect(plain).toMatchObject({ status: 200, attachment: { size: text.byteLength } })+ const before = files.objects.size+ expect(await post(tab, [['conversationId', 'lead'], ['contentEncoding', 'gzip'], ['file', text, 'a.md', 'text/markdown']]))+ .toMatchObject({ status: 400, code: 'INVALID_ATTACHMENT' })+ expect(await post(tab, [['conversationId', 'lead'], ['contentEncoding', 'br'], ['file', gzipSync(text), 'a.md', 'text/markdown']]))+ .toMatchObject({ status: 400, code: 'INVALID_ATTACHMENT' })+ expect(await post(tab, [['contentEncoding', 'gzip'], ['conversationId', 'lead'], ['file', gzipSync(text), 'a.md', 'text/markdown']]))+ .toMatchObject({ status: 400, code: 'INVALID_ATTACHMENT' })+ expect(await post(tab, [['conversationId', 'lead'], ['contentEncoding', 'gzip'], ['contentEncoding', 'gzip'], ['file', gzipSync(text), 'a.md', 'text/markdown']]))+ .toMatchObject({ status: 400, code: 'INVALID_ATTACHMENT' })+ // Small packed, over the form's 10 MB unpacked: stopped at the cap like any other form file.+ expect(await post(tab, [['conversationId', 'lead'], ['contentEncoding', 'gzip'], ['file', gzipSync(Buffer.alloc(10 * 1024 * 1024 + 1)), 'zeros.bin', 'application/octet-stream']]))+ .toMatchObject({ status: 413, code: 'ATTACHMENT_TOO_LARGE' })+ expect(files.objects.size).toBe(before)+ })+it('answers a bucket failure as unavailable, not as a server error', async () => {const { tab } = await fixture()const put = vi.spyOn(files, 'put').mockRejectedValueOnce(Object.assign(new Error('Forbidden'), { code: 403 }))diff --git a/backend/src/routes/superTabs.ts b/backend/src/routes/superTabs.tsindex 5d78e3ae8..51c7fa738 100644--- a/backend/src/routes/superTabs.ts+++ b/backend/src/routes/superTabs.ts@@ -4,7 +4,7 @@ import { z, ZodError } from 'zod'import { prisma } from '../lib/prisma.js'import { env } from '../config/env.js'import multipart from '@fastify/multipart'-import { attachmentsFromEnv, FORM_TOO_LARGE_MESSAGE, MAX_FORM_ATTACHMENT_BYTES, MAX_AVATAR_BYTES } from '../superTabs/attachments.js'+import { attachmentsFromEnv, formFileBody, FORM_TOO_LARGE_MESSAGE, MAX_FORM_ATTACHMENT_BYTES, MAX_AVATAR_BYTES, stopUnpacking, unpackFailed } from '../superTabs/attachments.js'import { validateBody, validateParams, validateQuery } from '../middlewares/validation.js'import { sendError, sendSuccess } from '../utils/response.js'import { operationSchema } from '../superTabs/commands.js'@@ -596,21 +596,30 @@ export async function superTabRoutes(app: FastifyInstance, options: { store?: Su// Super Tab route's body handling changes.await app.register(async scope => {// One byte over the limit, so the store sees an oversized file and refuses it rather than keeping a cut one.- await scope.register(multipart, { limits: { fileSize: MAX_FORM_ATTACHMENT_BYTES + 1, files: 1, fields: 1, parts: 2 } })+ // The file may come gzipped, said by `contentEncoding: gzip` between the two (attachments.ts formFileBody): the limit+ // here is on what arrives, and the store's cap on what it unpacks to.+ await scope.register(multipart, { limits: { fileSize: MAX_FORM_ATTACHMENT_BYTES + 1, files: 1, fields: 2, parts: 3 } })scope.post<{ Params: z.infer<typeof tabParams>; Querystring: z.infer<typeof agentQuery> }>('/api/super-tabs/:tabId/attachments',{ preHandler: [validateParams(tabParams), validateQuery(agentQuery)] }, (req, reply) => respond(reply, async () => {- let conversationId: string | null = null, uploaded: unknown = null, stored: unknown = null+ let conversationId: string | null = null, encoding: 'gzip' | null | undefined, uploaded: unknown = null, stored: unknown = nulltry {for await (const part of req.parts()) {if (part.type === 'field') {- if (part.fieldname !== 'conversationId' || conversationId !== null || uploaded) fail('INVALID_ATTACHMENT', 'Send conversationId, then one file.', 400)- conversationId = id.safeParse(part.value).data ?? fail('INVALID_ATTACHMENT', 'Name the conversation to attach the file to.', 400)+ if (part.fieldname === 'conversationId' && conversationId === null && encoding === undefined && !uploaded) {+ conversationId = id.safeParse(part.value).data ?? fail('INVALID_ATTACHMENT', 'Name the conversation to attach the file to.', 400)+ } else if (part.fieldname === 'contentEncoding' && conversationId !== null && encoding === undefined && !uploaded) {+ encoding = part.value === 'gzip' ? 'gzip' : fail('INVALID_ATTACHMENT', 'Send the file gzipped or as it is.', 400)+ } else fail('INVALID_ATTACHMENT', 'Send conversationId, then one file.', 400)} else {if (!conversationId || uploaded) { part.file.resume(); fail('INVALID_ATTACHMENT', 'Send conversationId, then one file.', 400) }+ const body = formFileBody(part.file, encoding ?? null)try {uploaded = await store.upload(req.user!, req.params.tabId, conversationId,- { name: part.filename, mime: part.mimetype, body: part.file }, req.query.asAgentId)- } catch (error) { stored = error; throw error } finally { part.file.resume() }+ { name: part.filename, mime: part.mimetype, body }, req.query.asAgentId)+ } catch (error) {+ stored = unpackFailed(body) ? new SuperTabError('INVALID_ATTACHMENT', 'The file was not valid gzip.', 400) : error+ throw stored+ } finally { stopUnpacking(part.file, body); part.file.resume() }}}} catch (error) {diff --git a/backend/src/superTabs/attachments.test.ts b/backend/src/superTabs/attachments.test.tsindex 685209234..b1975b862 100644--- a/backend/src/superTabs/attachments.test.ts+++ b/backend/src/superTabs/attachments.test.ts@@ -1,8 +1,9 @@import { generateKeyPairSync } from 'node:crypto'import { describe, expect, it } from 'vitest'import { Readable } from 'node:stream'-import { AttachmentTooLarge, attachmentName, attachmentsFromEnv, checkedType, directUploads, imageTypeOf, GcsAttachmentStore, GcsAvatarStore, MAX_ATTACHMENT_BYTES, MAX_FORM_ATTACHMENT_BYTES, MemoryAttachmentStore,- MemoryAvatarStore, objectKeyFor, served, serviceAccountFrom, SharedAvatarStore, typeFromHead, UPLOAD_LINK_MS, type AttachmentStore } from './attachments.js'+import { gzipSync } from 'node:zlib'+import { AttachmentTooLarge, attachmentName, attachmentsFromEnv, checkedType, directUploads, formFileBody, imageTypeOf, GcsAttachmentStore, GcsAvatarStore, MAX_ATTACHMENT_BYTES, MAX_FORM_ATTACHMENT_BYTES, MemoryAttachmentStore,+ MemoryAvatarStore, objectKeyFor, served, serviceAccountFrom, SharedAvatarStore, typeFromHead, unpackFailed, UPLOAD_LINK_MS, type AttachmentStore } from './attachments.js'const { privateKey } = generateKeyPairSync('rsa', { modulusLength: 2048 })const key = { type: 'service_account', project_id: 'harness-test', client_email: '[email protected]',@@ -233,3 +234,31 @@ describe('upload links on the memory bucket, with storage\'s rules', () => {expect(new AttachmentTooLarge().message).toBe('Files can be up to 256 MB.')})})++// A form file may come gzipped, so a gateway's content filter in front of the backend never reads a transcript's shell+// lines as an attack (task #2737). The store gets the original bytes.+describe('a form file sent gzipped', () => {+ const read = async (body: Readable) => { const parts: Buffer[] = []; for await (const part of body) parts.push(Buffer.from(part)); return Buffer.concat(parts) }+ const text = Buffer.from('$ rm -rf build && curl https://example.test/install.sh | sh\n'.repeat(200))++ it('unpacks gzip as it streams, and leaves a plain file as it is', async () => {+ expect((await read(formFileBody(Readable.from([gzipSync(text)]), 'gzip'))).equals(text)).toBe(true)+ const plain = Readable.from([text])+ expect(formFileBody(plain, null)).toBe(plain)+ })++ it('fails corrupt gzip with a zlib error, which reads as the client\'s', async () => {+ const body = formFileBody(Readable.from([Buffer.from('not gzip at all')]), 'gzip')+ await expect(read(body)).rejects.toMatchObject({ code: expect.stringMatching(/^Z_/) })+ expect(unpackFailed(body)).toBe(true)+ expect(unpackFailed(Readable.from([text]))).toBe(false)+ })++ it('passes the request stream\'s own failure on, so a cut form never hangs', async () => {+ const source = new Readable({ read() {} })+ const body = formFileBody(source, 'gzip')+ source.destroy(Object.assign(new Error('cut'), { code: 'FST_REQ_FILE_TOO_LARGE' }))+ await expect(read(body)).rejects.toMatchObject({ code: 'FST_REQ_FILE_TOO_LARGE' })+ expect(unpackFailed(body)).toBe(false)+ })+})diff --git a/backend/src/superTabs/attachments.ts b/backend/src/superTabs/attachments.tsindex 9de4bd9c0..69861e02b 100644--- a/backend/src/superTabs/attachments.ts+++ b/backend/src/superTabs/attachments.ts@@ -1,6 +1,7 @@import { createHmac, randomBytes } from 'node:crypto'import { Readable, Transform, Writable } from 'node:stream'import { pipeline } from 'node:stream/promises'+import { createGunzip } from 'node:zlib'import { z } from 'zod'import type { VoiceFacts } from './voiceMessages.js'@@ -125,6 +126,34 @@ export function served(name: string, mime: string): { contentType: string; contecontentDisposition: `${inline ? 'inline' : 'attachment'}; filename*=UTF-8''${encodeURIComponent(name)}` }}+/** A form file's bytes as they were before the client packed them. A client may gzip a form file and say so with+ * `contentEncoding: gzip` before it (task #2737): a gateway's content filter in front of the backend refused a handoff full+ * of shell lines as text, and cannot read packed bytes. The store then sees, sizes and caps the original bytes, so a small+ * packed file that unpacks past the cap is refused like any other. The request stream's own failure reaches the result. */+export function formFileBody(file: Readable, encoding: 'gzip' | null): Readable {+ if (encoding === null) return file+ const unpacked = createGunzip()+ // Not stream.pipeline: stopping the unpacking must not destroy the request's file stream, which the route drains.+ file.once('error', error => unpacked.destroy(error))+ // Bad gzip can fail before the store starts reading (it checks access first): kept on `errored` for the reader, never+ // thrown as an unheard 'error' event that would end the process.+ unpacked.on('error', () => {})+ return file.pipe(unpacked)+}++/** Stops unpacking `body` once the store is done with it, so a packed file past the cap is never inflated to its end. */+export function stopUnpacking(file: Readable, body: Readable): void {+ if (body === file) return+ file.unpipe(body as unknown as NodeJS.WritableStream)+ body.destroy()+}++/** Whether `body` failed because its packed bytes were not gzip: the client's fault, never the bucket's. */+export const unpackFailed = (body: Readable): boolean => {+ const code = body.errored && typeof body.errored === 'object' && 'code' in body.errored ? body.errored.code : null+ return typeof code === 'string' && code.startsWith('Z_')+}+/** The raster type the first bytes really are, or null. */export function imageTypeOf(head: Buffer): string | null {const ascii = (at: number, text: string) => head.subarray(at, at + text.length).toString('latin1') === textdiff --git a/cli/src/lib/swarmTools.spec.ts b/cli/src/lib/swarmTools.spec.tsindex 48c1501a2..56483a98a 100644--- a/cli/src/lib/swarmTools.spec.ts+++ b/cli/src/lib/swarmTools.spec.ts@@ -21,7 +21,7 @@ describe('SWARM_TOOLS_SKILL', () => {expect(at).toBeGreaterThan(0)const section = SWARM_TOOLS_SKILL.slice(at, SWARM_TOOLS_SKILL.indexOf('## Shared machines and secrets'))for (const part of ['Team account', 'nobody types in it', 'none of the owner\'s tools', 'in their own session', 'handoff',- '## GitHub', 'GitHub App', 'pull requests', 'cannot comment on or label issues', 'Never ask a person to sudo', 'Never ask for a token']) expect(section).toContain(part)+ '## GitHub', 'GitHub App', 'pull requests', 'where the repository\'s installation of the App granted it', 'Never ask a person to sudo', 'Never ask for a token']) expect(section).toContain(part)})it('describes the commands the server accepts now', () => {expect(SWARM_TOOLS_SKILL).not.toMatch(/Refused to some agents|route first|hard rules|rated 3|rule\.set|project\.skills/)diff --git a/cli/src/lib/swarmTools.ts b/cli/src/lib/swarmTools.tsindex d71707b6f..904314d8e 100644--- a/cli/src/lib/swarmTools.ts+++ b/cli/src/lib/swarmTools.ts@@ -121,7 +121,7 @@ Many people talk at once; answers in the main chat bury each other. Answer a mes## GitHub- An agent on another person's machine, and every agent in a Team account, gets git and gh through the Swarm's GitHub App for its task: clone, fetch, push branches, open, update and comment on pull requests, read checks. Nobody signs in for it.-- The App cannot comment on or label issues. Work that needs more runs on the project owner's own machine, in their account, with their sign-in.+- Issues and changes to .github/workflows: the token writes issues (comment, label) and pushes workflow changes only where the repository's installation of the App granted it; elsewhere GitHub refuses them. Work that needs more runs on the project owner's own machine, in their account, with their sign-in.- Never ask for a token in the chat or in a file. When a person must give access, they sign in on their own machine.- Ask a person only for what no agent can do: allowing a prompt in their own session, a physical device, adding a machine to the Swarm, approving a repository for the GitHub App, a decision. One step at a time, with the exact words to click or type.diff --git a/desktop/lib/super_tabs/agent_details.dart b/desktop/lib/super_tabs/agent_details.dartindex 16fee4ba3..df8227f9f 100644--- a/desktop/lib/super_tabs/agent_details.dart+++ b/desktop/lib/super_tabs/agent_details.dart@@ -12,6 +12,7 @@ import '../state/app_state.dart';import '../state/harness_activity.dart';import '../widgets/desktop_chrome.dart';import '../widgets/engine_identity.dart';+import 'agent_group_picker.dart';import 'agent_line.dart';import 'agent_mark.dart';import 'controller.dart';@@ -298,6 +299,7 @@ Future<void> showSuperTabAgentDetails(final dresses =controller.canWrite &¤t.contributorId == controller.accountId;+ final blocked = superTabOpenTerminalBlocked(controller, current.id);return AlertDialog(title: Row(children: [@@ -350,6 +352,8 @@ Future<void> showSuperTabAgentDetails(_fact('Started', fullDateTime(value)),if (info.questionOwner case final value?)_fact('Who can answer', value),+ // Beside the actions, as the card says it (#2738).+ if (blocked != null) _terminalBlocked(blocked),],),),@@ -368,10 +372,12 @@ Future<void> showSuperTabAgentDetails(child: const Text('Close'),),FilledButton(- onPressed: () {- Navigator.pop(context);- onOpenAgent(current);- },+ onPressed: blocked != null+ ? null+ : () {+ Navigator.pop(context);+ onOpenAgent(current);+ },child: const Text('Open terminal'),),],@@ -417,6 +423,7 @@ Future<void> showSuperTabAgentCard(final role = controller.snapshot?.roleOf(current.id);final group = info.taskGroup;final runs = [?glance.modelEffort, ?glance.machine].join(' · ');+ final blocked = superTabOpenTerminalBlocked(controller, current.id);return SuperTabDetailDialog(key: const ValueKey('super-agent-card'),title: name,@@ -461,12 +468,15 @@ Future<void> showSuperTabAgentCard(),],),+ footer: blocked == null ? null : _terminalBlocked(blocked),leadingActions: [TextButton(- onPressed: () {- Navigator.pop(dialog);- onOpenAgent(current);- },+ onPressed: blocked != null+ ? null+ : () {+ Navigator.pop(dialog);+ onOpenAgent(current);+ },child: const Text('Open terminal'),),],@@ -493,6 +503,13 @@ Future<void> showSuperTabAgentCard(),);+/// Why Open terminal is off, one muted line (#2738).+Widget _terminalBlocked(String reason) => Text(+ reason,+ key: const ValueKey('super-card-terminal-blocked'),+ style: DesktopChrome.metadata(),+);+Widget _fact(String label, String value) => Padding(padding: const EdgeInsets.only(bottom: 10),child: Column(diff --git a/desktop/lib/super_tabs/agent_group_picker.dart b/desktop/lib/super_tabs/agent_group_picker.dartindex 54e693159..c4b7d4bde 100644--- a/desktop/lib/super_tabs/agent_group_picker.dart+++ b/desktop/lib/super_tabs/agent_group_picker.dart@@ -8,6 +8,38 @@ import '../widgets/desktop_chrome.dart';import 'controller.dart';import 'model.dart';+/// Where [agentId]'s terminal can open: the conversations that hold it and+/// are not archived, as the backend opens one (superTabs/native.ts). The open+/// ones when there are any; else the finished (dormant) ones the Desktop+/// holds, such as the finished task the reader has open (#2738, review).+List<SuperTabConversation> superTabAgentTerminalGroups(+ SuperTabController controller,+ String agentId,+) {+ final snapshot = controller.snapshot;+ if (controller.accessRevoked || snapshot?.agent(agentId) == null) {+ return const [];+ }+ final held = snapshot!.conversations+ .where((g) => !g.archived && g.agentIds.contains(agentId))+ .toList();+ final open = held.where((g) => !g.dormant).toList();+ return open.isNotEmpty ? open : held;+}++/// Why Open terminal cannot open [agentId]'s terminal, and how to let it,+/// or null when it can: the card and Details say it under their buttons+/// rather than close on nothing (thaibao56, #2738).+String? superTabOpenTerminalBlocked(+ SuperTabController controller,+ String agentId,+) =>+ controller.accessRevoked ||+ controller.snapshot?.agent(agentId) == null ||+ superTabAgentTerminalGroups(controller, agentId).isNotEmpty+ ? null+ : 'Not in a task or chat now. Give it work or add it to a chat to open its terminal.';+/// Chooses a conversation context before opening an agent's existing terminal./// Selection is local to this dialog; only Open or a double-click navigates.class SuperTabAgentGroupPicker extends StatefulWidget {@@ -31,16 +63,8 @@ class _SuperTabAgentGroupPickerState extends State<SuperTabAgentGroupPicker> {final _rows = <String, GlobalKey>{};String? _selectedId;- List<SuperTabConversation> get _groups {- final snapshot = widget.controller.snapshot;- if (widget.controller.accessRevoked ||- snapshot?.agent(widget.agentId) == null) {- return const [];- }- return snapshot!.conversations- .where((g) => !g.closed && g.agentIds.contains(widget.agentId))- .toList();- }+ List<SuperTabConversation> get _groups =>+ superTabAgentTerminalGroups(widget.controller, widget.agentId);@overridevoid initState() {diff --git a/desktop/lib/super_tabs/attachment_upload.dart b/desktop/lib/super_tabs/attachment_upload.dartindex 543453f29..835d4cc4f 100644--- a/desktop/lib/super_tabs/attachment_upload.dart+++ b/desktop/lib/super_tabs/attachment_upload.dart@@ -1,8 +1,11 @@import 'dart:async';import 'dart:convert';+import 'dart:typed_data';+import 'package:archive/archive.dart' show GZipEncoder;import 'package:dio/dio.dart';-import 'package:flutter/foundation.dart' show kIsWeb, visibleForTesting;+import 'package:flutter/foundation.dart'+ show compute, kIsWeb, visibleForTesting;import '../api/api_client.dart';import '../logging/app_log.dart';@@ -152,24 +155,68 @@ SuperTabUpload uploadWith(onProgress: onProgress,);}- final response = await api().postForm(- path,- FormData.fromMap({- 'conversationId': conversationId,- 'file': MultipartFile.fromBytes(- await file.readBytes(),- filename: name,- contentType: DioMediaType.parse(mime),- ),- }),- cancelToken: cancel,- onSendProgress: (sent, total) {- if (total > 0) onProgress(sent / total);- },- );+ final bytes = await file.readBytes();+ Future<Response<dynamic>> send({required bool packed}) async =>+ api().postForm(+ path,+ FormData.fromMap({+ 'conversationId': conversationId,+ if (packed) 'contentEncoding': 'gzip',+ 'file': MultipartFile.fromBytes(+ packed ? await compute(_gzip, bytes) : bytes,+ filename: name,+ contentType: DioMediaType.parse(mime),+ ),+ }),+ cancelToken: cancel,+ onSendProgress: (sent, total) {+ if (total > 0) onProgress(sent / total);+ },+ );+ final packed = !_packedAlready.contains(mime);+ final response = await send(packed: packed);+ // A backend from before packed files refuses the field: the file goes+ // once more as it is, as it always went.+ if (packed && _refusedPacking(response)) {+ appLog.info('super-tabs', 'upload sent again unpacked (older server)');+ return _attachmentOf(await send(packed: false));+ }return _attachmentOf(response);};+/// Types whose bytes are compressed already, so packing them gains nothing.+/// Every other file sent as a form goes gzipped (task #2737): the gateway in+/// front of the backend judges a body by its text, and refused an agent's+/// handoff for the shell commands and paths in it. Packed bytes read as no+/// text, and the backend unpacks them and keeps the original.+const _packedAlready = {+ 'image/png',+ 'image/jpeg',+ 'image/gif',+ 'image/webp',+ 'application/zip',+ 'application/pdf',+};++/// Gzips [bytes]; off the UI thread on a computer (a form file is up to+/// 10 MB), on it in a browser.+Uint8List _gzip(Uint8List bytes) =>+ Uint8List.fromList(GZipEncoder().encodeBytes(bytes));++/// Whether [response] is a backend refusing a packed form it does not know.+bool _refusedPacking(Response<dynamic> response) {+ var body = response.data;+ if (body is String) {+ try {+ body = jsonDecode(body);+ } catch (_) {}+ }+ final error = body is Map ? body['error'] : null;+ return response.statusCode == 400 &&+ error is Map &&+ error['code'] == 'INVALID_ATTACHMENT';+}+/// A client for storage alone: no base address, no token, no request log/// (a signed link is a credential and is never written down).Dio _storageClient() => Dio(@@ -342,17 +389,28 @@ SuperTabFailure superTabUploadRefusal(Response<dynamic> response) {'super-tabs','upload refused: ${code ?? 'no code'} (status ${response.statusCode})',);+ final status = response.statusCode ?? 0;+ // No code: neither Harness's backend nor this computer's daemon answered,+ // which give one with every refusal. Something between them did.+ final busy = status == 408 || status == 429 || status >= 500 || status == 0;return SuperTabFailure(- code ?? 'UPLOAD_FAILED',+ code ?? (busy ? 'UPLOAD_FAILED' : 'GATEWAY_REFUSED'),message ??switch (code) {'FORBIDDEN' => 'You can’t send files in this conversation.','ATTACHMENT_TOO_LARGE' => kSuperTabAttachmentTooLarge,'AVATAR_TOO_LARGE' => 'That picture is over 1 MB.','AVATAR_TYPE' => 'Use a PNG, JPEG or WebP picture.',- null => 'Could not upload the file. Try again.',+ null when busy =>+ 'The Harness server could not take the file just now. Try '+ 'again in a minute.',+ // A filter judges the bytes, and a second try sends the same ones.+ null =>+ 'The gateway in front of the Harness server refused this file '+ '(status $status), so sending it again won’t help. Update '+ 'Harness, or tell the Harness team.',_ => 'Could not upload the file ($code). Try again.',},- statusCode: response.statusCode ?? 0,+ statusCode: status,);}diff --git a/desktop/lib/super_tabs/unread_line.dart b/desktop/lib/super_tabs/unread_line.dartindex 3d9d2fdf1..594986b26 100644--- a/desktop/lib/super_tabs/unread_line.dart+++ b/desktop/lib/super_tabs/unread_line.dart@@ -3,6 +3,7 @@ import 'package:flutter/rendering.dart';import '../shared/theme/app_icons.dart';import '../shared/theme/app_theme.dart' as grid;+import '../shortcuts/key_cap.dart';import '../widgets/desktop_chrome.dart';import 'model.dart';@@ -55,12 +56,23 @@ class SuperTabUnreadLines {/// Conversations whose line has been in view this visit.final _seen = <String>{};+ /// Conversations read through this visit: their line seen, then the end+ /// reached with nothing newer to load.+ final _readThrough = <String>{};+/// [id]'s line came into view: reading on needs no way back to it.void saw(String id) => _seen.add(id);+ /// [id] reached its end: once its line was seen, everything from it was+ /// read, and the bar goes for the visit. A link landing at the end skipped+ /// the line, so the bar stays to lead back to it. True when this call read+ /// it through.+ bool readThrough(String id) => _seen.contains(id) && _readThrough.add(id);+/// Whether [id] shows the bar back to its line: placed and above the- /// reader, seen or not (Slack's "N new messages").- bool offersBar(String id) => away && !below && _at[id] != null;+ /// reader, seen or not (Slack's "N new messages"), until read through.+ bool offersBar(String id) =>+ away && !below && _at[id] != null && !_readThrough.contains(id);/// Whether [id] offers the pill down to its line: placed, below the reader/// (a link opened the chat above it), and not yet seen this visit.@@ -85,6 +97,7 @@ class SuperTabUnreadLines {void placeAt(String id, String messageId) {_at[id] = messageId;_seen.remove(id);+ _readThrough.remove(id);}/// Whether [id]'s line waits for older messages: loading, or a read back that failed and is not yet done. Nothing is@@ -138,6 +151,7 @@ class SuperTabUnreadLines {_loaded.remove(id);_failed.remove(id);_seen.remove(id);+ _readThrough.remove(id);away = below = false;}@@ -153,6 +167,7 @@ class SuperTabUnreadLines {_loaded.clear();_failed.clear();_seen.clear();+ _readThrough.clear();away = below = false;}}@@ -194,12 +209,14 @@ class SuperTabNewMessagesLine extends StatelessWidget {}/// Shown while the New messages line is above the screen: a flat row across the top of the chat, Slack's-/// "N new messages", that takes the reader back to it. The words carry it, not the colour.+/// "N new messages", that takes the reader back to it, with Mark as read and its key (Esc) at its end. The words+/// carry it, not the colour.class SuperTabUnreadBar extends StatelessWidget {const SuperTabUnreadBar({super.key,required this.count,required this.onPressed,+ required this.onMarkRead,this.more = false,});@@ -210,52 +227,91 @@ class SuperTabUnreadBar extends StatelessWidget {final bool more;final VoidCallback onPressed;+ /// Reads the chat where the reader is, as Esc does.+ final VoidCallback onMarkRead;+static String label(int count, bool more) =>'${more ? '$count+' : '$count'} new ${count == 1 && !more ? 'message' : 'messages'} · Jump';+ static const _padding = EdgeInsets.symmetric(+ horizontal: grid.AppDesktop.panelPadding,+ vertical: grid.AppDesktop.controlGap,+ );+@overrideWidget build(BuildContext context) {grid.AppTheme.watch(context);final accent = DesktopChrome.accent;final words = label(count, more);- return Semantics(+ return Material(key: const ValueKey('super-jump-unread'),- button: true,- label: '$words to the first unread',- excludeSemantics: true,- child: Material(- color: DesktopChrome.selection,- child: InkWell(- onTap: onPressed,- child: DecoratedBox(- decoration: BoxDecoration(- border: Border(bottom: BorderSide(color: DesktopChrome.rim)),- ),- child: Padding(- padding: const EdgeInsets.symmetric(- horizontal: grid.AppDesktop.panelPadding,- vertical: grid.AppDesktop.controlGap,- ),- child: Row(- children: [- Flexible(- child: Text(- words,- maxLines: 1,- overflow: TextOverflow.ellipsis,- style: DesktopChrome.control(color: accent, medium: true),+ color: DesktopChrome.selection,+ child: DecoratedBox(+ decoration: BoxDecoration(+ border: Border(bottom: BorderSide(color: DesktopChrome.rim)),+ ),+ child: Row(+ children: [+ Expanded(+ child: Semantics(+ button: true,+ label: '$words to the first unread',+ excludeSemantics: true,+ child: InkWell(+ onTap: onPressed,+ child: Padding(+ padding: _padding,+ child: Row(+ children: [+ Flexible(+ child: Text(+ words,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: DesktopChrome.control(+ color: accent,+ medium: true,+ ),+ ),+ ),+ const SizedBox(width: grid.AppDesktop.controlGap),+ Icon(+ AppIcons.arrowUp,+ size: grid.AppDesktop.iconSize,+ color: accent,+ ),+ ],),),- const SizedBox(width: grid.AppDesktop.controlGap),- Icon(- AppIcons.arrowUp,- size: grid.AppDesktop.iconSize,- color: accent,+ ),+ ),+ ),+ Semantics(+ key: const ValueKey('super-unread-mark-read'),+ button: true,+ label: 'Mark as read',+ hint: 'Esc',+ excludeSemantics: true,+ child: InkWell(+ onTap: onMarkRead,+ child: Padding(+ padding: _padding,+ child: Row(+ mainAxisSize: MainAxisSize.min,+ children: [+ Text(+ 'Mark as read',+ maxLines: 1,+ style: DesktopChrome.control(medium: true),+ ),+ const SizedBox(width: grid.AppDesktop.controlGap),+ const KeyCap('esc'),+ ],),- ],+ ),),),- ),+ ],),),);diff --git a/desktop/lib/super_tabs/view.dart b/desktop/lib/super_tabs/view.dartindex 0b919a3d6..c42850077 100644--- a/desktop/lib/super_tabs/view.dart+++ b/desktop/lib/super_tabs/view.dart@@ -693,7 +693,17 @@ class _SuperTabViewState extends State<SuperTabView>scroll != null &&scroll.hasClients &&scroll.position.extentAfter >= 40;- if ((away == _unread.away &&+ // At the end with nothing newer to load, the reader has read everything+ // a bar would lead back to.+ final readThrough =+ scroll != null &&+ scroll.hasClients &&+ !awayFromEnd &&+ !landing &&+ !c.hasNewer(id) &&+ _unread.readThrough(id);+ if ((!readThrough &&+ away == _unread.away &&below == _unread.below &&awayFromEnd == _awayFromEnd.contains(id)) ||!mounted) {@@ -844,6 +854,13 @@ class _SuperTabViewState extends State<SuperTabView>);}+ /// The bar's Mark as read: Esc's read, with typing back in the composer as+ /// after a click on the bar.+ void _markReadFromBar() {+ _focus.requestFocus();+ _readAll();+ }+bool _readAll() {final id = c.selectedId, group = c.selected;if (group == null || (!c.unread(group) && _unread.lineAt(id) == null)) {@@ -4221,6 +4238,7 @@ class _SuperTabViewState extends State<SuperTabView>count: _newFromLine(c.selectedId),more: c.hasNewer(c.selectedId),onPressed: () => _jumpToUnreadLine(c.selectedId),+ onMarkRead: _markReadFromBar,): _unread.offersDown(c.selectedId)? Padding(diff --git a/desktop/lib/super_tabs/workspace.dart b/desktop/lib/super_tabs/workspace.dartindex 2a270191e..c825c311e 100644--- a/desktop/lib/super_tabs/workspace.dart+++ b/desktop/lib/super_tabs/workspace.dart@@ -469,11 +469,7 @@ class _SuperTabWorkspaceState extends State<SuperTabWorkspace> {String tabId,SuperTabAgent agent,) async {- final groups =- controller.snapshot?.conversations- .where((g) => !g.closed && g.agentIds.contains(agent.id))- .toList() ??- <SuperTabConversation>[];+ final groups = superTabAgentTerminalGroups(controller, agent.id);if (groups.isEmpty) return;if (groups.length == 1) {_focusAgent(controller, tabId, agent, groups.single.id);diff --git a/desktop/test/super_tab_agent_group_picker_test.dart b/desktop/test/super_tab_agent_group_picker_test.dartindex 7d6f4d471..366a2a4f7 100644--- a/desktop/test/super_tab_agent_group_picker_test.dart+++ b/desktop/test/super_tab_agent_group_picker_test.dart@@ -304,4 +304,44 @@ void main() {});}}++ // Review of #2951 (Kite): a terminal opens where the backend opens one, in+ // a conversation holding the agent that is not archived; open ones first,+ // a finished one the Desktop holds only when no open one does.+ test('where a terminal can open: open groups, else held finished ones, never archived', () async {+ final groups = server.state['conversations'] as List;+ groups.addAll(<Map<String, dynamic>>[+ {+ ...conversationFixture('done', 'Finished'),+ 'projectId': 'lead',+ 'agentIds': ['agent'],+ 'dormant': true,+ },+ {+ ...conversationFixture('gone', 'Archived'),+ 'projectId': 'lead',+ 'agentIds': ['agent'],+ 'archived': true,+ },+ ]);+ final c = server.controller();+ await c.refresh();+ await c.loadDormant('lead');+ List<String> ids() =>+ superTabAgentTerminalGroups(c, 'agent').map((g) => g.id).toList();+ expect(c.snapshot!.conversation('done'), isNotNull);+ expect(ids(), ['lead', 'offline']);+ for (final group in groups.take(2)) {+ group['agentIds'] = <String>[];+ }+ await c.refresh();+ expect(ids(), ['done']);+ expect(superTabOpenTerminalBlocked(c, 'agent'), isNull);+ (groups[2] as Map)['agentIds'] = <String>[];+ await c.refresh();+ expect(ids(), isEmpty);+ expect(superTabOpenTerminalBlocked(c, 'agent'), isNotNull);+ await c.flush();+ c.dispose();+ });}diff --git a/desktop/test/super_tab_composer_error_test.dart b/desktop/test/super_tab_composer_error_test.dartindex 539c9d153..791a3cc1d 100644--- a/desktop/test/super_tab_composer_error_test.dart+++ b/desktop/test/super_tab_composer_error_test.dart@@ -295,7 +295,8 @@ void main() {test('a body that says nothing keeps the plain words', () {expect(superTabUploadRefusal(answer(500, 'oops')).message,- 'Could not upload the file. Try again.',+ 'The Harness server could not take the file just now. Try again in '+ 'a minute.',);});diff --git a/desktop/test/super_tab_members_test.dart b/desktop/test/super_tab_members_test.dartindex 6e7261902..5dccafec1 100644--- a/desktop/test/super_tab_members_test.dart+++ b/desktop/test/super_tab_members_test.dart@@ -502,6 +502,8 @@ void main() {};(f.server.state['conversations'] as List).add({...conversationFixture('build', 'Windows credential fix'),+ // The backend adds a task's assignee to its conversation.+ 'agentIds': ['agent-1'],'assignment': {'agentId': 'agent-1', 'status': 'working'},});await f.controller.refresh();diff --git a/desktop/test/super_tab_new_messages_shots_test.dart b/desktop/test/super_tab_new_messages_shots_test.dartindex e515a5ced..d7f4562f5 100644--- a/desktop/test/super_tab_new_messages_shots_test.dart+++ b/desktop/test/super_tab_new_messages_shots_test.dart@@ -1,6 +1,7 @@import 'dart:io';import 'dart:ui' as ui;+import 'package:flutter/gestures.dart';import 'package:flutter/material.dart';import 'package:flutter/rendering.dart';import 'package:flutter_test/flutter_test.dart';@@ -20,8 +21,8 @@ const _updates = ['Pushed the branch; the checks are running.',];-/// The chat opened at its New messages line, and scrolled on to the end: the-/// line was seen, so no pill jumps back to it.+/// The chat opened at its New messages line, read on past it (the bar leads+/// back), then through to the end (the bar goes).void main() {setUpAll(() async {if (shots != null) await loadPreviewFonts();@@ -82,17 +83,29 @@ void main() {}await shot('line');- final list = tester- .widget<ScrollView>(- find.byKey(const PageStorageKey('super-messages-tab-lead')),- )- .controller!- .position;- list.jumpTo(list.maxScrollExtent);+ final messages = find.byKey(+ const PageStorageKey('super-messages-tab-lead'),+ );+ // On past the line in wheel steps, as a reader scrolls.+ for (var step = 0; step < 6; step++) {+ tester.binding.handlePointerEvent(+ PointerScrollEvent(+ position: tester.getCenter(messages),+ scrollDelta: const Offset(0, 100),+ ),+ );+ await tester.pump();+ }await tester.pumpAndSettle();// The line is above the screen now: the bar is the way back.expect(find.byKey(const ValueKey('super-jump-unread')), findsOne);await shot('read-on');+ final list = tester.widget<ScrollView>(messages).controller!.position;+ list.jumpTo(list.maxScrollExtent);+ await tester.pumpAndSettle();+ // Read through to the end: no bar, and the line stays above.+ expect(find.byKey(const ValueKey('super-jump-unread')), findsNothing);+ await shot('read-through');// Reading to the end saves the read mark a moment later (controller.dart `_saveSoon`).await tester.pump(const Duration(milliseconds: 300));});diff --git a/desktop/test/super_tab_new_messages_test.dart b/desktop/test/super_tab_new_messages_test.dartindex 6ffd56666..af37239d3 100644--- a/desktop/test/super_tab_new_messages_test.dart+++ b/desktop/test/super_tab_new_messages_test.dart@@ -6,6 +6,7 @@ import 'package:flutter/services.dart';import 'package:flutter_test/flutter_test.dart';import 'package:harness/shared/theme/app_icons.dart';import 'package:harness/shared/theme/app_theme.dart' as grid;+import 'package:harness/shortcuts/key_cap.dart';import 'package:harness/super_tabs/controller.dart';import 'package:harness/super_tabs/message_link.dart';import 'package:harness/super_tabs/unread_line.dart';@@ -16,6 +17,9 @@ import 'support/super_tab_fixture.dart';const _line = ValueKey('super-new-messages-line');const _jump = ValueKey('super-jump-unread');+/// The bar's words, which jump; its Mark as read sits at its other end.+final _jumpWords = find.textContaining(' · Jump');+/// [count] messages in the Lead conversation from the Lead agent.ConversationServer _server(int count) {final server = ConversationServer();@@ -95,6 +99,21 @@ void main() {return top >= list.top && top < list.bottom;}+ /// Down from the New messages line in view in wheel steps, as a reader+ /// scrolls: past it, and short of the end, where the bar goes.+ Future<void> readOn(WidgetTester tester, {String chat = 'lead'}) async {+ final list = tester.getCenter(+ find.byKey(PageStorageKey('super-messages-tab-$chat')),+ );+ for (var step = 0; step < 5; step++) {+ tester.binding.handlePointerEvent(+ PointerScrollEvent(position: list, scrollDelta: const Offset(0, 100)),+ );+ await tester.pump();+ }+ await tester.pumpAndSettle();+ }+testWidgets('opens at a New messages line just above the first unread ''message', (tester) async {final server = _server(40)..markReadElsewhere('lead', 30);@@ -476,9 +495,7 @@ void main() {// Seen as the chat opened at it: the bar shows only once it is above.expect(onScreen(tester, find.byKey(_line)), isTrue);expect(find.byKey(_jump), findsNothing);- final position = scroll(tester);- position.jumpTo(position.maxScrollExtent);- await tester.pumpAndSettle();+ await readOn(tester);expect(onScreen(tester, find.byKey(_line)), isFalse);expect(find.byKey(_jump), findsOneWidget);expect(@@ -502,7 +519,7 @@ void main() {final bar = tester.getRect(find.byKey(_jump));expect(bar.bottom, lessThanOrEqualTo(list.top));expect(bar.width, moreOrLessEquals(list.width, epsilon: 1));- await tester.tap(find.byKey(_jump));+ await tester.tap(_jumpWords);await tester.pumpAndSettle();expect(onScreen(tester, find.byKey(_line)), isTrue);expect(find.byKey(_jump), findsNothing);@@ -510,16 +527,126 @@ void main() {await tester.pump(const Duration(seconds: 1));});- testWidgets('with the message list focused, Esc dismisses the bar and '- 'reads the chat', (tester) async {+ // Huy's report of 11-04 (#2743): '7 new messages · Jump' stayed at the end+ // of a chat he had read.+ testWidgets('read through to the bottom, the bar goes for the visit and '+ 'the line stays', (tester) async {final server = _server(60)..markReadElsewhere('lead', 20);+ await show(tester, server);+ final position = scroll(tester);+ await readOn(tester);+ expect(find.byKey(_jump), findsOneWidget);+ position.jumpTo(position.maxScrollExtent);+ await tester.pumpAndSettle();+ expect(find.byKey(_jump), findsNothing);+ // Back up, the line still above, read through: still no bar, and the+ // line is where the reader started.+ position.jumpTo(position.pixels - 300);+ await tester.pumpAndSettle();+ expect(find.byKey(_jump), findsNothing);+ await tester.dragUntilVisible(+ find.byKey(_line),+ find.byKey(const PageStorageKey('super-messages-tab-lead')),+ const Offset(0, 200),+ );+ await tester.pumpAndSettle();+ expect(onScreen(tester, find.byKey(_line)), isTrue);+ expect(find.byKey(_jump), findsNothing);+ });++ testWidgets('at the end of the messages held while newer pages wait, the '+ 'bar stays', (tester) async {+ final server = _server(200)..messagePage = 20;+ server.markReadElsewhere('lead', 5);final c = await show(tester, server);+ await readOn(tester);+ expect(find.byKey(_jump), findsOneWidget);+ // Newer pages load as the reader nears the end: hold them.+ final hold = server.holdReads = Completer<void>();final position = scroll(tester);position.jumpTo(position.maxScrollExtent);+ for (var frame = 0; frame < 4; frame++) {+ await tester.pump();+ }+ expect(c.hasNewer('lead'), isTrue);+ expect(find.byKey(_jump), findsOneWidget);+ server.holdReads = null;+ hold.complete();+ await tester.pumpAndSettle();+ // Reading on saves the read mark a moment later (controller.dart `_saveSoon`).+ await tester.pump(const Duration(milliseconds: 300));+ });++ // Slack's Mark as read on its bar, with the key that does the same (#2743).+ testWidgets('the bar\'s Mark as read, with its Esc hint, reads the chat '+ 'and clears the line where the reader is', (tester) async {+ final server = _server(60)..markReadElsewhere('lead', 20);+ final c = await show(tester, server);+ await readOn(tester);+ const markRead = ValueKey('super-unread-mark-read');+ expect(+ find.descendant(of: find.byKey(_jump), matching: find.byKey(markRead)),+ findsOneWidget,+ );+ expect(+ find.descendant(+ of: find.byKey(markRead),+ matching: find.text('Mark as read'),+ ),+ findsOneWidget,+ );+ expect(+ find.descendant(of: find.byKey(_jump), matching: find.byType(KeyCap)),+ findsOneWidget,+ );+ expect(+ find.descendant(of: find.byType(KeyCap), matching: find.text('esc')),+ findsOneWidget,+ );+ // A message mid-view, where the reader is.+ final list = tester.getRect(+ find.byKey(const PageStorageKey('super-messages-tab-lead')),+ );+ final reading = find.text(+ [for (var i = 1; i <= 60; i++) 'Update $i'].firstWhere((text) {+ final found = find.text(text);+ if (found.evaluate().isEmpty) return false;+ final top = tester.getTopLeft(found).dy;+ return top > list.center.dy - 100 && top < list.center.dy + 100;+ }),+ );+ final before = tester.getTopLeft(reading).dy;+ await tester.tap(find.byKey(markRead));+ await tester.pumpAndSettle();+ expect(find.byKey(_jump), findsNothing);+ expect(c.unread(c.selected!), isFalse);+ expect(server.readMarkPosts.last, {+ 'conversationId': 'lead',+ 'sequence': 60,+ });+ // No jump: what the reader was reading stays under their eye.+ expect(tester.getTopLeft(reading).dy, moreOrLessEquals(before, epsilon: 1));+ await tester.dragUntilVisible(+ find.text('Update 21'),+ find.byKey(const PageStorageKey('super-messages-tab-lead')),+ const Offset(0, 200),+ );await tester.pumpAndSettle();+ expect(find.byKey(_line), findsNothing);+ });++ testWidgets('with the message list focused, Esc dismisses the bar and '+ 'reads the chat', (tester) async {+ final server = _server(60)..markReadElsewhere('lead', 20);+ final c = await show(tester, server);+ await readOn(tester);expect(find.byKey(_jump), findsOneWidget);// Focus leaves the composer for the messages.- await tester.tap(find.text('Update 59'));+ await tester.tapAt(+ tester.getCenter(+ find.byKey(const PageStorageKey('super-messages-tab-lead')),+ ),+ );await tester.pumpAndSettle();expect(FocusManager.instance.primaryFocus?.context?.widget.key,@@ -538,18 +665,15 @@ void main() {'is above again', (tester) async {final server = _server(60)..markReadElsewhere('lead', 20);final c = await show(tester, server);- final position = scroll(tester);- position.jumpTo(position.maxScrollExtent);- await tester.pumpAndSettle();+ await readOn(tester);final mouse = await tester.createGesture(kind: PointerDeviceKind.mouse);addTearDown(mouse.removePointer);- await mouse.addPointer(location: tester.getCenter(find.byKey(_jump)));- await mouse.down(tester.getCenter(find.byKey(_jump)));+ await mouse.addPointer(location: tester.getCenter(_jumpWords));+ await mouse.down(tester.getCenter(_jumpWords));await mouse.up();await tester.pumpAndSettle();expect(onScreen(tester, find.byKey(_line)), isTrue);- position.jumpTo(position.maxScrollExtent);- await tester.pumpAndSettle();+ await readOn(tester);expect(find.byKey(_jump), findsOneWidget);await tester.sendKeyEvent(LogicalKeyboardKey.escape);await tester.pumpAndSettle();@@ -580,9 +704,7 @@ void main() {expect(onScreen(tester, find.byKey(_line)), isTrue);expect(find.byKey(_jump), findsNothing);// Seen, and still the bar comes once the line is above the screen.- final position = scroll(tester);- position.jumpTo(position.maxScrollExtent);- await tester.pumpAndSettle();+ await readOn(tester);expect(onScreen(tester, find.byKey(_line)), isFalse);expect(find.byKey(_jump), findsOneWidget);});@@ -637,7 +759,7 @@ void main() {// The jump to the link passed the line; the reader never saw it.expect(onScreen(tester, find.byKey(_line), chat: 'offline'), isFalse);expect(find.byKey(_jump), findsOneWidget);- await tester.tap(find.byKey(_jump));+ await tester.tap(_jumpWords);await tester.pumpAndSettle();expect(onScreen(tester, find.byKey(_line), chat: 'offline'), isTrue);expect(find.byKey(_jump), findsNothing);@@ -714,7 +836,7 @@ void main() {tester.getRect(find.byKey(_jump)).bottom,lessThanOrEqualTo(list.top),);- await tester.tap(find.byKey(_jump));+ await tester.tap(_jumpWords);await tester.pumpAndSettle();expect(onScreen(tester, find.byKey(_line), chat: 'offline'), isTrue);expect(find.byKey(_jump), findsNothing);@@ -724,11 +846,14 @@ void main() {).controller!.position;- position.jumpTo(position.maxScrollExtent);- await tester.pumpAndSettle();+ await readOn(tester, chat: 'offline');// Read on past it, the line is above: the bar takes the pill's place.expect(find.byKey(_jump), findsOneWidget);expect(find.textContaining('new messages · Jump'), findsOneWidget);+ // Seen and read through to the bottom: no way back is needed.+ position.jumpTo(position.maxScrollExtent);+ await tester.pumpAndSettle();+ expect(find.byKey(_jump), findsNothing);});testWidgets('opened at a linked message above the line, the pill points 'diff --git a/desktop/test/super_tab_roster_test.dart b/desktop/test/super_tab_roster_test.dartindex e257bfdda..382bbec5c 100644--- a/desktop/test/super_tab_roster_test.dart+++ b/desktop/test/super_tab_roster_test.dart@@ -1056,6 +1056,109 @@ void main() {},);+ // thaibao56 (11-04, #2738): Open terminal on Finn's card closed the card and+ // nothing opened. A terminal opens only in a conversation that holds the+ // agent, and no open one held Finn: the card says so in place instead.+ for (final brightness in Brightness.values) {+ testWidgets(+ 'Open terminal on the card of an agent no open conversation holds says why, and opens once one does ($brightness)',+ (tester) async {+ final f = await fixture(tester);+ await tester.binding.setSurfaceSize(const Size(560, 420));+ final previous = grid.AppTheme.brightness.value;+ grid.AppTheme.brightness.value = brightness;+ addTearDown(() => grid.AppTheme.brightness.value = previous);+ await f.show(tester, brightness: brightness);+ const reason =+ 'Not in a task or chat now. Give it work or add it to a chat to open its terminal.';+ final card = find.byKey(const ValueKey('super-agent-card'));+ Finder open() => find.descendant(+ of: card,+ matching: find.widgetWithText(TextButton, 'Open terminal'),+ );+ await f.card(tester, 3);+ expect(tester.widget<TextButton>(open()).onPressed, isNull);+ expect(+ find.descendant(of: card, matching: find.text(reason)),+ findsOneWidget,+ );+ await captureBoundary(+ tester,+ f.boundary.currentContext!.findRenderObject()!+ as RenderRepaintBoundary,+ captureDir,+ 'agent-card-no-terminal-${brightness.name}',+ );+ await tester.tap(open(), warnIfMissed: false);+ await tester.pumpAndSettle();+ expect(card, findsOneWidget, reason: 'the card stays open');+ expect(f.opened, isNull);+ await tester.tap(find.text('Details…'));+ await tester.pumpAndSettle();+ final details = find.widgetWithText(FilledButton, 'Open terminal');+ expect(tester.widget<FilledButton>(details).onPressed, isNull);+ expect(find.text(reason), findsOneWidget);+ await tester.tap(find.widgetWithText(TextButton, 'Close'));+ await tester.pumpAndSettle();++ // Once a task holds Finn, Open terminal opens it, with no reason.+ (f.server.state['conversations'] as List)[1]['agentIds'] = ['agent-3'];+ await f.controller.refresh();+ await tester.pumpAndSettle();+ await f.card(tester, 3);+ expect(find.text(reason), findsNothing);+ await tester.tap(open());+ await tester.pumpAndSettle();+ expect(f.opened?.id, 'agent-3');+ await f.close(tester);+ },+ );+ }++ // Review of #2951 (Kite): the backend opens a terminal in any conversation+ // that holds the agent but an archived one, a finished (dormant) task the+ // Desktop holds included.+ for (final archived in [false, true]) {+ testWidgets(+ 'Open terminal on the card of an agent held only by a ${archived ? 'archived' : 'finished'} task the Desktop holds ${archived ? 'stays off' : 'opens there'}',+ (tester) async {+ final f = await fixture(tester);+ await tester.binding.setSurfaceSize(const Size(560, 420));+ // Held while it was open, then finished (or archived) as the Swarm+ // sweeps it: the Desktop still holds it.+ final done = <String, dynamic>{+ ...conversationFixture('done', 'Finished work'),+ 'projectId': 'lead',+ 'agentIds': ['agent-3'],+ };+ (f.server.state['conversations'] as List).add(done);+ await f.controller.refresh();+ done[archived ? 'archived' : 'dormant'] = true;+ await f.controller.refresh();+ await f.controller.loadGroup('done');+ expect(f.controller.snapshot!.conversation('done'), isNotNull);+ await f.show(tester);+ await f.card(tester, 3);+ final card = find.byKey(const ValueKey('super-agent-card'));+ final open = find.descendant(+ of: card,+ matching: find.widgetWithText(TextButton, 'Open terminal'),+ );+ expect(tester.widget<TextButton>(open).onPressed == null, archived);+ expect(+ find.byKey(const ValueKey('super-card-terminal-blocked')),+ archived ? findsOneWidget : findsNothing,+ );+ if (!archived) {+ await tester.tap(open);+ await tester.pumpAndSettle();+ expect(f.opened?.id, 'agent-3');+ }+ await f.close(tester);+ },+ );+ }+testWidgets('a reviewer reads Rev; an agent without a role stays Dev', (tester,) async {@@ -1389,6 +1492,10 @@ void main() {tester.getTopLeft(f.row(1)).dy,lessThan(tester.getTopLeft(f.row(3)).dy),);+ // A terminal opens in a conversation that holds the agent (#2738).+ (f.server.state['conversations'] as List)[1]['agentIds'] = ['agent-1'];+ await f.controller.refresh();+ await tester.pumpAndSettle();await f.details(tester, 1);await tester.pumpAndSettle();expect(find.byType(AlertDialog), findsOneWidget);diff --git a/desktop/test/super_tab_unread_lines_test.dart b/desktop/test/super_tab_unread_lines_test.dartnew file mode 100644index 000000000..60114f4c8--- /dev/null+++ b/desktop/test/super_tab_unread_lines_test.dart@@ -0,0 +1,27 @@+import 'package:flutter_test/flutter_test.dart';+import 'package:harness/super_tabs/unread_line.dart';++void main() {+ test('Mark unread after reading through offers the bar again', () {+ final lines = SuperTabUnreadLines()+ ..placeAt('lead', 'message-5')+ ..saw('lead')+ ..readThrough('lead')+ ..away = true;+ expect(lines.offersBar('lead'), isFalse);+ lines.placeAt('lead', 'message-9');+ expect(lines.offersBar('lead'), isTrue);+ });++ test('leaving a chat read through forgets it: the next visit offers the '+ 'bar', () {+ final lines = SuperTabUnreadLines()+ ..placeAt('lead', 'message-5')+ ..saw('lead')+ ..readThrough('lead')+ ..forget('lead')+ ..placeAt('lead', 'message-5')+ ..away = true;+ expect(lines.offersBar('lead'), isTrue);+ });+}diff --git a/desktop/test/super_tab_upload_test.dart b/desktop/test/super_tab_upload_test.dartindex 7e3dad0db..225ecb2f0 100644--- a/desktop/test/super_tab_upload_test.dart+++ b/desktop/test/super_tab_upload_test.dart@@ -7,6 +7,7 @@ import 'dart:io';import 'dart:math' show min;import 'dart:typed_data';+import 'package:archive/archive.dart' show GZipDecoder;import 'package:dio/dio.dart';import 'package:file_selector/file_selector.dart' show XFile;import 'package:flutter_test/flutter_test.dart';@@ -166,7 +167,14 @@ void main() {throwsA(isA<SuperTabFailure>().having((f) => f.code, 'code', 'UPLOAD_FAILED')- .having((f) => f.statusCode, 'status', 503),+ .having((f) => f.statusCode, 'status', 503)+ // Busy or restarting: the one codeless refusal a second try can pass.+ .having(+ (f) => f.message,+ 'message',+ 'The Harness server could not take the file just now. Try '+ 'again in a minute.',+ ),),);});@@ -776,6 +784,208 @@ void main() {},);});++ _gatewayTests();+}++void _gatewayTests() {+ group('behind a gateway that refuses shell-like text', () {+ late HttpServer server;+ late SuperTabUpload upload;+ // Each form the backend took: its parts by name, in order.+ final forms =+ <+ List<({String name, String? type, String? filename, List<int> bytes})>+ >[];+ final logged = <String>[];+ late AppLog log;+ var refuseAll = false;+ var oldBackend = false;+ final shellLike = RegExp(r'rm -rf|\| *sh\b|/etc/passwd');++ setUp(() async {+ forms.clear();+ logged.clear();+ refuseAll = false;+ oldBackend = false;+ log = appLog;+ appLog = _Recorder(logged);+ server = await HttpServer.bind(InternetAddress.loopbackIPv4, 0);+ server.listen((request) async {+ final bytes = BytesBuilder();+ await for (final chunk in request) {+ bytes.add(chunk);+ }+ final body = bytes.takeBytes();+ if (refuseAll || shellLike.hasMatch(latin1.decode(body))) {+ request.response+ ..statusCode = 403+ ..headers.contentType = ContentType.html+ ..write('<html><body><h1>403 Forbidden</h1></body></html>');+ await request.response.close();+ return;+ }+ final form = _parts(request.headers.contentType!, body);+ final (+ status,+ payload,+ ) = oldBackend && form.any((p) => p.name == 'contentEncoding')+ ? (+ 400,+ <String, Object?>{+ 'success': false,+ 'error': {+ 'code': 'INVALID_ATTACHMENT',+ 'message': 'Send conversationId, then one file.',+ },+ },+ )+ : (+ 200,+ <String, Object?>{+ 'success': true,+ 'data': {+ 'attachment': {'id': 'a${forms.length + 1}'},+ },+ },+ );+ forms.add(form);+ request.response+ ..statusCode = status+ ..headers.contentType = ContentType.json+ ..write(jsonEncode(payload));+ await request.response.close();+ });+ upload = uploadWith(+ () => ApiClient(+ config: AppConfig(+ apiBaseUrl: 'http://unused.invalid',+ localCliBaseUrl: 'http://127.0.0.1:${server.port}',+ ),+ session: AuthSession(),+ ),+ );+ });+ tearDown(() async {+ appLog = log;+ await server.close(force: true);+ });++ final transcript = Uint8List.fromList(+ utf8.encode(+ List.filled(+ 300,+ r'$ rm -rf build && curl -fsSL https://example.test/i.sh | sh',+ ).join('\n'),+ ),+ );++ Future<Map<String, dynamic>> send(String name, Uint8List bytes) => upload(+ tabId: 'tab',+ conversationId: 'c1',+ name: name,+ mime: mimeForName(name),+ file: HarnessAttachment(name, bytes),+ cancel: CancelToken(),+ onProgress: (_) {},+ );++ test('a transcript goes gzipped, said so before the file, and arrives '+ 'whole', () async {+ final answer = await send('run.transcript.md', transcript);++ expect((answer['attachment'] as Map)['id'], 'a1');+ final form = forms.single;+ expect(form.map((p) => p.name), [+ 'conversationId',+ 'contentEncoding',+ 'file',+ ]);+ expect(utf8.decode(form[1].bytes), 'gzip');+ final file = form[2];+ expect(file.filename, 'run.transcript.md');+ expect(file.type, 'text/markdown');+ expect(file.bytes.length, lessThan(transcript.length));+ expect(GZipDecoder().decodeBytes(file.bytes), transcript);+ });++ test('a picture goes as it is: its bytes are packed already', () async {+ final png = Uint8List.fromList([+ 0x89,+ 0x50,+ 0x4e,+ 0x47,+ ...List.filled(64, 1),+ ]);++ await send('shot.png', png);++ final form = forms.single;+ expect(form.map((p) => p.name), ['conversationId', 'file']);+ expect(form[1].bytes, png);+ });++ test('a backend that does not know packed files gets the file once more '+ 'as it is', () async {+ oldBackend = true;+ final notes = Uint8List.fromList(utf8.encode('notes\n' * 50));++ final answer = await send('notes.md', notes);++ expect((answer['attachment'] as Map)['id'], 'a2');+ expect(forms.map((f) => f.map((p) => p.name).toList()), [+ ['conversationId', 'contentEncoding', 'file'],+ ['conversationId', 'file'],+ ]);+ expect(forms.last.last.bytes, notes);+ });++ test('a refusal with no code names the gateway, says trying again will '+ 'not help, and logs the status', () async {+ refuseAll = true;++ await expectLater(+ send('run.transcript.md', transcript),+ throwsA(+ isA<SuperTabFailure>()+ .having((f) => f.code, 'code', 'GATEWAY_REFUSED')+ .having((f) => f.statusCode, 'status', 403)+ .having(+ (f) => f.message,+ 'message',+ allOf(contains('gateway'), isNot(contains('Try again'))),+ ),+ ),+ );+ expect(logged.join('\n'), contains('no code (status 403)'));+ });+ });+}++/// A multipart form's parts, read as a backend would.+List<({String name, String? type, String? filename, List<int> bytes})> _parts(+ ContentType type,+ List<int> body,+) {+ final boundary = latin1.encode('--${type.parameters['boundary']}');+ final text = latin1.decode(body);+ final marker = latin1.decode(boundary);+ final parts =+ <({String name, String? type, String? filename, List<int> bytes})>[];+ for (final chunk in text.split(marker).skip(1)) {+ if (chunk.startsWith('--')) break;+ final split = chunk.indexOf('\r\n\r\n');+ final head = chunk.substring(0, split);+ final content = chunk.substring(split + 4, chunk.length - 2);+ String? header(RegExp pattern) => pattern.firstMatch(head)?.group(1);+ parts.add((+ name: header(RegExp(r' name="([^"]*)"'))!,+ filename: header(RegExp(r'filename="([^"]*)"')),+ type: header(RegExp(r'content-type: ([^\r\n]*)', caseSensitive: false)),+ bytes: latin1.encode(content),+ ));+ }+ return parts;}/// Tokens that go stale: the first is refused, a forced renewal gives a new one.diff --git a/docs/plans/2026-11-04-agent-card-open-terminal-plan.md b/docs/plans/2026-11-04-agent-card-open-terminal-plan.mdnew file mode 100644index 000000000..ce3b82cae--- /dev/null+++ b/docs/plans/2026-11-04-agent-card-open-terminal-plan.md@@ -0,0 +1,44 @@+# Agent card: Open terminal says why it can't open — plan++**Goal:** On an agent's card (and its Details), Open terminal either opens the agent's terminal or says plainly, in+place, why it can't. Today it closes the card and nothing happens for an agent that no open conversation holds+(thaibao56, 11-04, #2738).++**Architecture:** The card's Open terminal goes through the roster to the workspace's `_chooseAgentGroup`, which looks+for the open conversations holding the agent and returns silently when there are none. The backend opens a terminal+only in a conversation that holds the agent (`backend/src/superTabs/native.ts`, `AGENT_UNAVAILABLE`), and a dormant+conversation is not in the Swarm's snapshot, so there is nothing the Desktop can open for such an agent. One helper,+`superTabAgentTerminalGroups`, names the conversations a terminal can open in; the card, Details, the workspace and the+group picker all read it. With none, the card's and Details' Open terminal is disabled and a line under the actions+says why.++**Tech Stack:** Flutter (desktop/lib/super_tabs), widget tests with the memory-store fixtures.++**Spec:** Task #2738 brief.++This plan is carried out by the Engineer directly, test first; there is no execution handoff.++## Global Constraints++- Desktop only; no backend change. Other card buttons unchanged.+- Desktop tests use a memory store and a fake sign-in; screenshots offscreen in light and dark.++## Review Focus++- The helper matches what the backend accepts (an open, non-archived conversation holding the agent).+- No path that used to open a terminal is now disabled.++## Task 1: the card and Details say why Open terminal can't open++**Files:** `desktop/lib/super_tabs/agent_details.dart`, `desktop/lib/super_tabs/workspace.dart`,+`desktop/lib/super_tabs/agent_group_picker.dart`, `desktop/test/super_tab_roster_test.dart`.++**Interfaces:** `List<SuperTabConversation> superTabAgentTerminalGroups(SuperTabController, String agentId)`;+`String? superTabOpenTerminalBlocked(SuperTabController, SuperTabAgent)`.++- [ ] Failing widget test: Finn, in no open conversation, has a disabled Open terminal on its card and in Details,+ with the reason shown; once a conversation holds Finn, Open terminal is enabled and opens it. Light and dark+ captures of the card.+- [ ] Run it and watch it fail.+- [ ] Add the helper and use it in the card, Details, the workspace's chooser and the group picker.+- [ ] Run the roster, workspace and group-picker tests.diff --git a/docs/plans/2026-11-04-batch-pr-ci-reuse-plan.md b/docs/plans/2026-11-04-batch-pr-ci-reuse-plan.mdnew file mode 100644index 000000000..c54f4d4e5--- /dev/null+++ b/docs/plans/2026-11-04-batch-pr-ci-reuse-plan.md@@ -0,0 +1,53 @@+# A batch PR reuses its member PRs' passed results: plan++> Way of working: this plan's Engineer implements it task by task, test first (test-driven-development), in one pull+> request. No subagents, no execution handoff.++**Goal:** A batch PR (a branch from main with each member PR merged in) stops rerunning a component a member PR already+passed, when nothing that component reads changed between the member's tested commit and the batch head. Tony's phone+PRs waited two CI rounds (~10 min of mobile-checks each) for one phone PR in a batch.++**Architecture:** `scripts/ci-plan.py plan_reuse` already reuses a component after GitHub's Update branch: the head+merges a main commit into a passed head, and each component's result stands when the diff from the commit its run tested+to the head touches none of its inputs (own directory, DEPENDS; a shared input reruns everything). A batch head is a+chain of such merges with the member heads as second parents. The planner tells the two apart from Git alone: a head whose+second parent is on main is an update; otherwise it walks the head's first-parent line down to main, every commit a+two-parent merge, and takes each second parent not on main as a member's tested commit (a merge of main again brings+only main's commits). Each member's latest passed `ci/required` check is followed to its exact run and receipt, and a+component that run reused points at its original run, as for an update. For each component, a member whose run covered+it is reused when `reuse_blocker` passes from that origin to the batch head; an unreadable member is only no candidate,+since its changes stay in every other member's diff. The merge helper's `verify_reuse` re-derives the members from Git.+The PR body is never read.++**Tech Stack:** Python 3 (`scripts/ci-plan.py`), unittest with real Git repositories (`scripts/tests/test_ci_plan.py`).++**Spec:** Task #2720 (Tony, via River).++## Global Constraints++- Fails closed: any doubt (a hand commit on the batch line, an unreadable receipt, a shared input) runs the component,+ or everything.+- An Update-branch head plans exactly as before.+- This PR changes `scripts/`, so its own CI runs everything and main's planner judges it.++## Review Focus++- Soundness rests on the diff from a run's tested commit to the head, as for an update; how a member is found only picks+ candidates. Check that no path lets a member's own unreadable or failed run count.+- The member walk: two-parent merges only, main merges skipped, stops at main, bounded.+- `verify_reuse` (run from main's copy by the merge helper) refuses a receipt whose members differ from the head's.++## Task 1: main's planner data catches up++`main` fails three planner tests on its own: a backend test's client version strings read as paths, and two Desktop+files the phone tests now read. Declare them (`NOT_READS`, the phone's `ALSO` list).++## Task 2: batch reuse++**Files:** `scripts/ci-plan.py`, `scripts/tests/test_ci_plan.py`, `docs/validation-and-release.md`.+- [ ] Failing tests: one phone PR in a batch reuses mobile-checks; two phone PRs run it; a main change to a mobile input+ runs it; a shared input runs everything; an unreadable receipt runs its component; the PR body is never read; a batch+ that merged main again; a member whose run reused points at the original run; the helper verifies and refuses forged+ members.+- [ ] `batch_members`, `reuse_sources`; `plan_reuse` and `verify_reuse` take either; docs next to "Reuse after Update+ branch".diff --git a/docs/plans/2026-11-04-compressed-chat-uploads-plan.md b/docs/plans/2026-11-04-compressed-chat-uploads-plan.mdnew file mode 100644index 000000000..608ac8086--- /dev/null+++ b/docs/plans/2026-11-04-compressed-chat-uploads-plan.md@@ -0,0 +1,97 @@+# Compressed chat uploads: implementation plan++> Implemented by its Engineer task by task, test first (project instructions, Engineer role). No per-task review: the+> review step on the pull request is the one independent review.++**Goal:** Importing an agent stops failing at "Sharing the files" when the gateway in front of the backend refuses a+handoff full of shell commands and file paths, and a refusal with no code says why in plain words (task #2737, asked+by Lê Lộc).++**Architecture:** Desktop gzips a file it sends by the multipart form (the 10 MB route that crosses the gateway) and+says so in a `contentEncoding: gzip` form field placed between `conversationId` and the file; the file part keeps its+real name and content type. The backend's form route accepts that one field, unpacks the file as it streams and hands+the store the original bytes, so what is stored, served, sized and checked is exactly what it is today. Files whose+bytes are already compressed (PNG, JPEG, GIF, WebP, zip, PDF) go as they are. A file over 10 MB still goes straight to+storage on a signed link, which never crosses the gateway. An older backend refuses the field with+`INVALID_ATTACHMENT`; Desktop then sends the file once more uncompressed, as today.++A refusal that carries no Harness code (the gateway's HTML 403, or an empty answer) gets a message by status:+4xx says the server's gateway refused the file and that sending it again won't help; 408, 429 and 5xx say the server+could not take it just now, try again in a minute. Its status is logged, as before.++**Tech Stack:** Dart/Flutter (Dio, package:archive GZipEncoder, `compute`), TypeScript/Fastify (@fastify/multipart,+node:zlib), vitest, flutter_test.++**Spec:** task #2737 brief (Goal, Changes 1–3).++## Global Constraints++- No access check changes: the route's preHandlers, `store.upload`'s actor and conversation checks and the hourly+ allowance stay as they are.+- No check is loosened: the multipart file limit still applies to what arrives (compressed), and the store's+ `MAX_FORM_ATTACHMENT_BYTES` cap applies to the unpacked bytes, so a gzip bomb stops at 10 MB + 1 like any other+ oversized form file (413).+- Never real transcripts in tests: fixtures are made-up shell lines.+- Desktop tests use a loopback fake gateway and a memory store; nothing signs the CLI out.+- The CLI proxy passes the body through untouched (cli/src/lib/superTabAttachmentProxy.ts), so it needs no change.++## Review Focus++- `contentEncoding` handling in the form route: field order, one value only, stream errors (corrupt gzip → 400,+ truncated form → 413/400, never a 500 or a hang), the unpacking stream destroyed when the store stops reading.+- The fallback to an uncompressed send happens once, only for `INVALID_ATTACHMENT` from a compressed form.+- The message text for a codeless refusal, and whether "Try again" is honest in each case.++## Answer to Change 3: does "Try again" help?++No, for this failure. A content filter judges the bytes, and Try again sends the same bytes, so it is refused the same+way every time. Only a codeless 408, 429 or 5xx (the gateway or backend busy or restarting) can pass on a second try,+and those keep a "try again in a minute" message.++## Design++- growth: N/A because nothing new is stored; the stored object and row are the same as today.+- concurrency: N/A because no new shared state; one request unpacks its own stream.+- read cost: N/A because reads are unchanged (the stored object is the original file).+- scale: unpacking costs backend CPU per form upload (≤ 10 MB each, already capped at 200 uploads per hour per actor);+ the first warning is backend CPU on the upload route.+- compatibility: a new Desktop against an older backend falls back to an uncompressed send; an older Desktop, the+ mobile app and `post --attach` send no field and are handled as today.+- migration + rollback: N/A because there is no data change; rolling back the backend makes new Desktops fall back.+- audience: the server enforces it: access checks are untouched and run before a byte is stored.+- identity: N/A because no new identity is used.+- failure: a corrupt or oversized packed file is refused with a code and words; a codeless refusal names the gateway.+- platforms: Desktop on macOS, Linux and Windows compress on a background isolate; the browser build compresses on its+ one thread with the same encoder.++## Task 1: Backend unpacks a gzip form file++**Files:** `backend/src/superTabs/attachments.ts`, `backend/src/routes/superTabs.ts`,+`backend/src/superTabs/attachments.test.ts`, `backend/integration/superTabs.test.ts`++**Interfaces:** `formFileBody(file: Readable, encoding: 'gzip' | null): Readable`; `unpackFailed(body): boolean`.++- [ ] Failing unit tests: `formFileBody` round-trips gzip, errors with a zlib code on corrupt input, passes the+ source's error on.+- [ ] Failing integration test: a gzip form stores the original bytes, type and size; corrupt gzip → 400+ `INVALID_ATTACHMENT`; an unknown encoding, a field after the file or twice → 400; a packed file over 10 MB unpacked+ → 413 `ATTACHMENT_TOO_LARGE`; a plain form still works.+- [ ] Implement; run the unit file and the attachment block of the integration file.++## Task 2: Desktop compresses form uploads++**Files:** `desktop/lib/super_tabs/attachment_upload.dart`, `desktop/test/super_tab_upload_test.dart`++- [ ] Failing test: against a fake gateway that answers 403 HTML to a body holding shell-like text, a transcript+ uploads, and the server's unpacked file equals the original, with `contentEncoding: gzip` before the file part.+- [ ] Failing test: a PNG goes uncompressed; an `INVALID_ATTACHMENT` answer to a compressed form is followed by one+ uncompressed send.+- [ ] Implement.++## Task 3: A codeless refusal says why++**Files:** `desktop/lib/super_tabs/attachment_upload.dart`, `desktop/test/super_tab_upload_test.dart`++- [ ] Failing test: a 403 HTML answer reads "the server's gateway refused" with no "Try again"; a codeless 503 says+ try again in a minute; both log their status.+- [ ] Implement; run the touched Desktop files, the import and attachment tests, and the Desktop guard tests.diff --git a/docs/plans/2026-11-04-phone-home-simple-plan.md b/docs/plans/2026-11-04-phone-home-simple-plan.mdnew file mode 100644index 000000000..10c13c6db--- /dev/null+++ b/docs/plans/2026-11-04-phone-home-simple-plan.md@@ -0,0 +1,137 @@+# Phone Home simplified Implementation Plan++> **For agentic workers:** Follow the project's Engineer workflow: this plan is the draft pull request's first commit;+> each plan task commits its failing test, watches it fail, then commits the code that passes it; one independent review+> step on the pull request. The tasks share `mobile/lib/swarm/swarm_page.dart`, so they run one after another.++**Goal:** Phone Home with less on it, as anh Dee asked (11-04: "keep it simple and clean. less is better! simplify+everything."): one "need you" line in place of three side-scrolling cards, one small heading per Swarm in place of the+Swarm's name on every row, no Projects heading or filter icon, the + in the header next to Search instead of floating+over the list, and unread projects bold with a dot. It strengthens "Tell the PM what you want, and your crew ships it":+the phone shows what needs the person and the projects, and nothing else.++**Architecture:** All in the phone's Swarm Home (`SwarmPage`) and the widgets it draws. The away/threads/agents tiles+become one `SwarmNeedLine`, drawn only while something waits on the person, opening Activity on Needs you. The project+list groups its projects by Swarm (pins first in each Swarm) under a `SwarmCaption` with the Swarm's name; with one+Swarm shown there is no heading, as the title names it. Nothing loses its only way in: Sort and filter (with Mark all+read and Refresh in its sheet) and the agents on the person's computers become rows of the Swarm switcher, opened+from Home's title; Threads becomes a button in Activity's top bar.++**Tech Stack:** Flutter/Dart (mobile), widget tests with the existing Swarm fixtures.++**Spec:** Task #2719 in Super Tab conversation a360130c4971f66cfd017ca2 (anh Dee, 2026-11-04; mockup by River the same+day, approved by Tony, who owns mobile).++## Global Constraints++- The mockup, and only this:++ ```+ All Swarms ⌄ 🔍 + (me)+ 2 need you · 1 done ›+ autonomous.ai+ # openharness ●+ # spaceship+ # lamp+ # computer+ …+ Personal+ # storage+ Home Buddy Activity 2+ ```++- Phone only. Harness Design Language tokens (AppSpace, AppPalette, AppType, LucideIcons 300). No new setting.+- Nothing removed that has no other way in. Where each goes:+ - While you were away → the need-you line ("2 need you · 1 done"), shown only while something needs the person.+ - Threads card → a Threads button in Activity's top bar (the followed threads page); replies are also Activity ▸+ Replies.+ - Agents card → an Agents row in the Swarm switcher (Home's title), opening the agents by computer; each agent is+ also in Search ▸ Agents.+ - Projects heading → gone; one small heading per Swarm instead, none with one Swarm shown.+ - Filter icon (Sort and filter, Mark all read, Refresh) → a Sort and filter row in the Swarm switcher, opening the+ same sheet, with its dot when anything but the defaults is on.+ - Pinned heading → pins stay first in their Swarm's list.+ - Floating + → a + in the header, next to Search, opening the same New message.+- Never install a build on anyone's phone. Screenshots from widget tests in light and dark, and from the iPhone+ simulator in the Team account.++## Review Focus++- No way in lost: every row of the old Sort and filter sheet, the Threads page and the agents list stay reachable.+- A Home filter left on Unread or Mentions still says so and can be cleared (the switcher row's dot and words).+- The need-you line is never drawn as "0 need you", nor while what waits is still being read.++## Tasks++### Task 1: The need-you line replaces the three cards++**Files:** `mobile/lib/swarm/swarm_home_tiles.dart`, `mobile/lib/swarm/swarm_page.dart`,+`mobile/test/swarm/swarm_home_tiles_test.dart`, `mobile/test/swarm/swarm_home_test.dart`.++**Interfaces:** `SwarmNeedLine({required int needs, int? done, required VoidCallback onTap})`, key+`swarm-need-line`. `SwarmHomeTiles`, `SwarmAwayTile`, `SwarmThreadsTile`, `SwarmAgentsTile` go.++- [ ] Failing tests: with two needs and one done, Home has one line "2 need you · 1 done" and no Threads or Agents card;+ with none waiting, no line; while what waits is read, no line; a tap opens Activity on Needs you.+- [ ] Code: `SwarmNeedLine`; `_tiles` becomes `_needLine`; Home no longer builds the threads merge.++### Task 2: The + moves to the header++**Files:** `mobile/lib/swarm/swarm_page.dart`, `mobile/lib/swarm/swarm_new_message_sheet.dart`,+`mobile/test/swarm/swarm_new_message_test.dart`.++**Interfaces:** a `SwarmIconButton` keyed `swarm-new-message` (LucideIcons.plus300, "New message") between Search and+You; the floating `SwarmNewMessageButton` goes, and the list's bottom padding no longer clears it.++- [ ] Failing tests: Home has no floating action button; the header's + opens New message once, offered only where it+ was offered before.+- [ ] Code.++### Task 3: Sort and filter and Agents move to the Swarm switcher; no Projects heading++**Files:** `mobile/lib/swarm/swarm_home_top.dart`, `mobile/lib/swarm/swarm_page.dart`,+`mobile/test/swarm/swarm_home_view_test.dart`, `mobile/test/swarm/swarm_home_test.dart`.++**Interfaces:** `showSwarmSwitcher(context, session, {VoidCallback? onView, SwarmAgents? agents})`: rows+`swarm-switch-view` ("Sort and filter", its words the sort and filter on, a dot when changed) and `swarm-switch-agents`+("Agents", opening `agents.openList`). Home has no `swarm-home-view` and no "Projects" caption.++- [ ] Failing tests: no Projects caption or filter icon on Home; the switcher's Sort and filter opens the view sheet+ (Mark all read and Refresh in it); its row says a filter is on; the switcher's Agents row opens the agents list.+- [ ] Code.++### Task 4: One heading per Swarm++**Files:** `mobile/lib/swarm/swarm_page.dart`, `mobile/lib/swarm/swarm_home_rows.dart`,+`mobile/test/swarm/swarm_home_test.dart`, `mobile/test/swarm/swarm_home_project_row_test.dart`.++**Interfaces:** `SwarmHomeProjectRow` loses `swarmName`. Home's list, over several Swarms, is per Swarm a+`SwarmCaption(swarm.name)` keyed `swarm-heading-<id>` and its group (pins, then recent, then Other projects); over one+Swarm, the group alone.++- [ ] Failing tests: over two Swarms, each project is under its Swarm's heading and no row names its Swarm; over one,+ no heading; a pin is first in its Swarm; a Swarm still read shows its heading over its skeleton.+- [ ] Code.++### Task 5: Unread projects bold with a dot++**Files:** `mobile/lib/swarm/swarm_home_rows.dart`, `mobile/test/swarm/swarm_home_project_row_test.dart`.++**Interfaces:** an unread project row (news bold, no tags) ends with a dot keyed `swarm-project-unread`; a read one has+none; one with tags keeps its "@2".++- [ ] Failing test, then code.++### Task 6: Threads in Activity's top bar++**Files:** `mobile/lib/swarm/swarm_activity_page.dart`, `mobile/test/swarm/swarm_activity_page_test.dart`.++**Interfaces:** on the Activity tab, a `SwarmIconButton` keyed `swarm-activity-threads` before You, opening+`openSwarmThreads`.++- [ ] Failing test, then code.++### Task 7: Screenshots++- [ ] Update `swarm_home_shots_test.dart` goldens for light and dark; capture Home on the iPhone simulator in the Team+ account in light and dark; attach both to the pull request.diff --git a/docs/plans/2026-11-04-tabs-to-personal-swarm-migration.md b/docs/plans/2026-11-04-tabs-to-personal-swarm-migration.mdnew file mode 100644index 000000000..1ccb7577f--- /dev/null+++ b/docs/plans/2026-11-04-tabs-to-personal-swarm-migration.md@@ -0,0 +1,185 @@+# Moving from tabs to the Personal Swarm: migration plan++**Goal:** a step-by-step way to move people from tabs to their Personal Swarm, with a way back at every step, so anh+Dee can decide before any tab is removed (Huy, 11-04). This is a plan only: it changes no code, and no phase starts+until anh Dee says yes to it.++**Agreed design (10-30), kept as it is:** the Swarm screen stays; a project's panes sit behind its [term] button;+every pane joins the project of its repo; panes with no repo go to # scratch (refined below); [term] keeps pane order+and size; old Swarm tabs become switcher entries. No new left bar.++**Spec:** Dee 10-30 design, Dee 10-31 "build the rest, but leave the tabs", Huy's eight points in task #2752.++## Where we are today (Phase 0, shipped)++- Tabs are unchanged. Personal's projects show the same live panes their tabs hold, never a copy+ (`desktop/lib/super_tabs/personal_projects.dart:16-22`, `desktop/lib/super_tabs/workspace.dart:109-114`).+- A pane joins the project of its repo; a pane with no repo joins a project for its tab, keyed by the tab's id+ (`personal_projects.dart:85-87`, `:161-164`). It is named after the tab once, and a later tab rename keeps the+ project and its name (`:340-348`, `:452-492`).+- Left out of Personal: Swarm tabs, utility tabs (Store, Companions, Devices), viewer panes, panes on another person's+ or a shared machine, and Team-account panes (`personal_projects.dart:134-150`; utility kinds in+ `desktop/lib/state/swarm.dart:42-45`).+- Split sizes carry over only when a project's panes are exactly one tab's panes, in that tab's order (`soleTab`,+ `personal_projects.dart:246-263`, used at `workspace.dart:234-237`, copied by `app_state.dart:19829`).+- Personal is created only when the person picks it (`desktop/lib/super_tabs/swarm_switcher.dart:33-35`, `:140-160`).+- The tabs live on the account's **desk**, one server document per person, the same on every computer+ (`desktop/lib/state/desk_sync.dart:1-14`, `backend/src/lib/desk.ts`), at most 24 tabs (`desk.ts:12`). The phone+ reads its tab list from the desk too (`mobile/lib/state/phone_desk.dart:10-27`). Swarm tabs are not on the desk+ (`app_state.dart:21094-21095`).++## The rule every phase keeps++**The desk stays the source of truth for panes until the last phase.** Every pane is still in a tab on the desk, even+while the Desktop does not draw the tab strip. That one rule is what keeps the phone, the web and older Desktops+working, and what makes going back a single switch with nothing to rebuild.++## Phases++Each phase ships on its own, waits a week of real use, and moves on only when anh Dee says so.++### Phase 1: fill the gaps, existing tabs unchanged++What changes for people: existing tabs stay as they are; a project that starts an agent gets a tab of its own.+Personal's projects get what they need to stand alone later:++1. **A project's own tab.** A pane started from a project (its [term] or its chat) is added to that project's tab on+ the desk, so the phone and older Desktops see it (point 7). The tab's id is made from the project's id+ (`project-` and a hash of it, which fits the desk's id rule, `backend/src/lib/desk.ts:16`). That id is the one+ shared link from tab to project: every computer hashes the projects Personal lists and finds the match, so no+ computer makes a second project for that tab (today a tab's key is only `tab:<id>`, `personal_projects.dart:85-87`,+ `:161-164`, and the map from key to project is per computer, `:185-187`). The tab takes the project's name and+ follows its renames, unless the person renamed the tab. (Points 1 and 7.)+2. **When the desk is full.** The desk drops a 25th tab and a 10th pane in a tab without an error+ (`desk.ts:12-13`, `:113`, `:146`). So the Desktop checks first: a project tab with 9 panes gets a second tab+ ("api 2", its id the project's hash plus `-2`, then `-3`, so every computer links its panes to the same+ project), and with 24 tabs on the desk the start is refused before any agent runs. The person reads: "Your tabs+ are full (24). Close a tab to start another agent." No pane is ever left with no tab.+3. **A no-repo pane** started from a project joins that project through its tab (item 1). One started from an+ ordinary tab keeps today's tab project. Only a pane with neither goes to # scratch. (Point 1.)+4. **A project's own layout.** A project of panes from several tabs gets its own split sizes, saved the first time+ the person arranges it, on this computer only, next to the project map (`super_tab.repos.<account>`,+ `personal_projects.dart:185-187`). It is never sent to the server, so "nothing of a pane is sent anywhere"+ (`personal_projects.dart:24-27`) still holds. Another computer uses the default layout until the person arranges+ it there. (Point 2.)+5. Personal remembers the tab order it saw, so its PROJECTS list can start in that order. (Point 5.)++Roll back: turn the additions off. Existing tabs stay as they are, and the project tabs Phase 1 added stay on the+desk as ordinary tabs with their panes, which the person can keep or close. A project's saved layout is simply not+used.++Data kept: the tab-id project keys (`super_tab.repos.<account>`, `personal_projects.dart:185-187`) and every tab on+the desk.++### Phase 2: "Use projects instead of tabs", opt-in, off by default++What changes for people who turn it on, on that Desktop only:++- The tab strip is hidden for tabs whose every pane is in a Personal project. A tab holding a pane Personal leaves out+ (point 3) stays visible as a tab. Utility tabs open from their menus as today.+- Swarm tabs become entries in the Swarm dropdown, as the 10-30 design says: one Swarm tab stays, and every other+ Swarm tab is closed, not hidden: picking a Swarm that is open in another tab selects that tab+ (`app_state.dart:2804-2805`), which would land on a hidden one. A closed Swarm stays in the dropdown+ (`desktop/lib/super_tabs/swarm_switcher.dart:332-334`), and picking it shows it in the one visible tab+ (`app_state.dart:2800-2807`). Swarm tabs are not on the desk (`app_state.dart:21094-21095`), so this changes+ nothing on the phone or another computer.+- The Swarm screen opens on Personal. Cmd-1..9 go to the first nine projects in the PROJECTS list instead of tabs+ (today they follow tab order: `app_state.dart:4155-4158`, `desktop/lib/shortcuts/app_shortcuts.dart:928-938`).+- Nothing else changes: the panes, their sessions and the desk are the same.++Roll back: turn the setting off. The tab strip comes back as it was, because the desk was never changed, and the+Swarm tabs closed by the switch reopen in their old order. Nothing else is restored, so nothing can be lost.++Data kept: the whole desk, unchanged; this window's own tab layout (`terminal_pane_layout`,+`desktop/lib/state/pane_layout_store.dart:20`) is still written; and, on this computer, the list of Swarm tabs the+switch closed, in order, so turning it off reopens them.++What tells us it works: how many people turn it on, how many turn it off again within a week, and the reasons in+feedback.++### Phase 3: on by default for new people, a one-time choice for everyone else++What changes for people:++- A person whose desk held no tab with a pane when this Desktop first joined it (a new account, or one that never+ opened an agent) starts in projects mode.+- Anyone else is asked once: "Use projects instead of tabs?" with Keep tabs as a full answer. The setting stays in+ Settings either way.++Roll back: the same setting. If many people turn it off, the default goes back to tabs in the next Desktop release,+with no data change.++Data kept: as Phase 2.++### Phase 4: tabs removed (a later decision, not part of this plan's yes)++Only when Phase 3 shows few people keep tabs, and older Desktops are a small share of active ones. Before it, a new+design answers where left-out panes (point 3) live without a tab, and how the phone shows panes without the desk's+tabs. The desk is then kept read-only for at least two releases, so a person who needs it back still has it.++## Huy's eight points++1. **No-repo panes.** Today their project comes from their tab's id (`personal_projects.dart:85-87`, `:164`), which+ works because every pane is in a tab. Phase 1 puts a pane started from a project into that project's own desk+ tab, whose id is made from the project's id, so every computer reads the same project from it (Phase 1, item 1).+ A pane started in an ordinary tab keeps that tab's project, and # scratch takes only a pane with neither. Existing+ tab projects keep their keys, so nothing moves.+2. **Split layouts.** Sizes come from a tab only when the project is exactly that tab's panes (`soleTab`,+ `personal_projects.dart:246-263`); a project with panes from several tabs gets the default layout today. Phase 1+ saves each project's own layout once the person arranges it, on that computer only (Phase 1, item 4). Until then,+ [term] keeps pane order (tab order, then each tab's reading order, `personal_projects.dart:134-142`).+3. **Panes left out of Personal.** Viewer panes, panes on another person's or a shared machine, Team-account panes,+ Swarm tabs and utility tabs (`personal_projects.dart:134-150`). Viewer, other-machine and Team-account panes show+ where they show today: in their tab, which stays visible in projects mode. Swarm tabs become dropdown entries+ (Phase 2), and utility tabs open from their menus. A home for the rest without tabs is a Phase 4 design question.+4. **Updating from a version with no Swarm.** On first launch the Desktop joins the desk and seeds it with this+ computer's tabs (`app_state.dart:21194-21198`). Each pane then maps to a project: its repo's, or its tab's project+ named after the tab (`personal_projects.dart:343-348`). Projects mode never starts by itself until Personal exists+ and its first sync answered. If Personal can't be created (signed out: `swarm_switcher.dart:143-147`; offline or+ a server refusal: the error shown in the tab, `swarm_switcher.dart:208-228`), the Desktop stays in tabs, says why,+ and offers the switch again later. A refused project is asked for again after a wait of up to 5 minutes+ (`personal_projects.dart:182-183`, `:439-450`).+5. **Muscle memory.** Cmd-1..9 follow the visible tab order today (`app_state.dart:4155-4158`); in projects mode they+ follow the PROJECTS order, which starts as the tab order the Desktop saw (Phase 1). Renaming a tab no longer+ renames its project once it is made, and a name the person chose always stays (`personal_projects.dart:340-342`,+ `:452-454`). People who grouped several repos in one tab lose that grouping in projects mode, since each repo is+ its own project. That is the main reason Keep tabs stays a full answer through Phase 3.+6. **A repo that already has a team project.** Not joined in any phase of this plan (`personal_projects.dart:29-30`).+ The pane stays in its Personal project and the team project is unchanged. Joining the two crosses Swarms and+ access, so it needs its own design and two security reviews before it is built.+7. **Mixed versions.** An older Desktop, the phone and the web read tabs from the desk (`desk_sync.dart:1-14`,+ `phone_desk.dart:17-27`). Because every phase keeps every pane on a desk tab, they keep seeing the same tabs and+ panes while a newer Desktop shows projects. Projects mode is a setting of each Desktop, not of the account, so an+ older Desktop on the same account simply shows tabs.+8. **A way back.** The "Use projects instead of tabs" setting, off by default until Phase 3 and always in Settings.+ Restoring needs no copy of the tabs: the desk is never changed by projects mode, and the local tab layout keeps+ being written. The one thing saved is this computer's list of the Swarm tabs the switch closed, to reopen them+ (Phase 2). Personal's project map (`super_tab.repos.<account>`) stays too, so switching back and forth makes no new+ projects.++## Design++- Growth: one setting per Desktop; one saved layout per Personal project on each computer, deleted with the project;+ one desk tab per project that started a pane, closed by the person like any tab.+- Concurrency: the setting and the layouts are per computer, so no lock. Project tabs change through the desk's+ existing small idempotent ops (`desk_sync.dart:3-6`, `desk.ts:107`).+- Read cost: nothing new is read; projects mode reads the desk and Personal it already reads.+- Scale: the desk's 24 tabs and 9 panes a tab (`desk.ts:12-13`) are reached first, since Phase 1 adds a tab per+ project. The Desktop refuses a start before them and says why (Phase 1, item 2); the count of those refusals is the+ metric that warns.+- Compatibility: older Desktops, the phone and the web keep reading the desk, unchanged (point 7).+- Migration and rollback: no data is migrated; each phase rolls back with the setting or a default change.+- Audience: Personal is the person's alone and its projects are created private (`personal_projects.dart:201-214`,+ `:410`); the server enforces who reads a Swarm, as for every Swarm. The desk is the person's own document and+ already holds their panes' machine and agent ids; a project tab adds only a hashed project id to it. Project+ layouts stay on the computer.+- Identity: Personal and its projects belong to the signed-in account, never the machine owner's login+ (`personal_projects.dart:203-213`).+- Failure: if Personal can't be made or read, the Desktop stays in tabs and says why (point 4).+- Platforms: Desktop on macOS, Windows and Linux; the phone and the web keep tabs from the desk through Phase 3.++## Decisions for anh Dee++1. Phase 1 (existing tabs unchanged, a tab per project that starts an agent): yes or no.+2. Phase 2 (opt-in setting): yes or no, and after how long in Phase 1.+3. Phase 3 and Phase 4 are decided later, on Phase 2's numbers.diff --git a/docs/plans/2026-11-04-unread-bar-read-through-plan.md b/docs/plans/2026-11-04-unread-bar-read-through-plan.mdnew file mode 100644index 000000000..9499efa59--- /dev/null+++ b/docs/plans/2026-11-04-unread-bar-read-through-plan.md@@ -0,0 +1,77 @@+# Unread bar goes once the chat is read through Implementation Plan++> Implemented by the task's Engineer task by task, each failing test committed before its code (project instructions,+> Engineer). One independent review on the pull request.++**Goal:** The "N new messages · Jump" bar stops showing once the reader has read the chat through: seen its New+messages line and reached the bottom with nothing newer left to load. The line itself stays for the visit, so the+reader sees where they started. The bar gains a "Mark as read" button with an Esc hint, as Slack's does (task #2743,+Huy, 2026-11-04).++**Architecture:** `SuperTabUnreadLines` (desktop/lib/super_tabs/unread_line.dart) keeps a per-visit set of+conversations read through, beside the `_seen` set it already keeps. `offersBar` leaves out a conversation in it;+`placeAt` (Mark unread) takes it out again; `forget` and `reset` clear it. `_checkUnreadLine` (view.dart), which already+measures the line and the list's end on every scroll, calls it when the list is at its end (`extentAfter < 40`, the+same edge Jump to latest uses), no newer page waits (`!c.hasNewer`), no jump is landing, and the line was seen this+visit. A link that lands at the end without the line ever in view keeps the bar: those messages were skipped, not+read. `SuperTabUnreadBar` gets an `onMarkRead` callback drawn as a text button and an Esc key cap at its right end;+the view passes `_readAll`, the same path Esc takes.++**Tech Stack:** Flutter (Desktop and web share this code), flutter_test widget tests with the Super Tab fixture's+memory store and fake sign-in.++**Spec:** task #2743's brief. No stored data changes.++## Global Constraints++- Red first: each behavior below has a widget test committed failing before its code.+- Desktop and web are one Flutter screen; nothing platform-specific.+- No test signs the real CLI out: the fixture's `ConversationServer` only.+- Light and dark screenshots offscreen (`SUPER_TAB_UNREAD_SHOTS`) for Huy.+- Threads have no New messages line or bar today (thread_panel.dart), so nothing there can stay stuck; adding one is+ outside this task and goes to the PM.++## Design++- growth: N/A because nothing is stored; the set is per visit and cleared when the chat is left.+- concurrency: N/A because it is UI state on the main isolate.+- read cost: N/A because no read is added; the check runs in the scroll listener that already measures the line.+- scale: N/A because the set holds at most the open conversation.+- compatibility: N/A because no wire or saved format changes.+- migration + rollback: N/A because nothing is stored; revert the commit.+- audience: N/A because the read mark the button sends is the one Esc already sends, enforced by the server.+- identity: N/A because no login is used.+- failure: Mark as read uses `markRead(explicit: true)`, which already reports a failed save.+- platforms: macOS, Linux, Windows and web (shared Flutter code).++## Review Focus++- The read-through rule: seen line + at end + nothing newer + not landing. A link landing at the end keeps the bar.+- Tests that relied on the bar at the very end now scroll to a point past the line short of the end.+- The bar's tap target: the Jump area and the Mark as read button do not swallow each other's taps.++## Task 1: the bar goes once the chat is read through++**Files:** desktop/lib/super_tabs/unread_line.dart, desktop/lib/super_tabs/view.dart,+desktop/test/super_tab_new_messages_test.dart++**Interfaces:** `SuperTabUnreadLines.readThrough(String id)`; `offersBar` false for a conversation read through.++- [ ] Test: opened at the line, scrolled to the bottom, the bar is gone and the line is still there (above the view).+- [ ] Test: opened by a link at the end with the line never seen, the bar stays; jumped to the line and scrolled back+ to the bottom, it goes.+- [ ] Test: Mark unread after reading through brings the bar back once the new line is above.+- [ ] Existing tests that expect the bar scroll past the line short of the end.+- [ ] Run them red, commit; implement; run green, commit.++## Task 2: Mark as read on the bar, with its Esc hint++**Files:** desktop/lib/super_tabs/unread_line.dart, desktop/lib/super_tabs/view.dart,+desktop/test/super_tab_new_messages_test.dart, desktop/test/super_tab_new_messages_shots_test.dart++**Interfaces:** `SuperTabUnreadBar(onMarkRead: VoidCallback)`; button key `super-unread-mark-read`.++- [ ] Test: the bar shows "Mark as read" and an Esc key cap; a click clears the bar and the line and marks the chat+ read on the server, without jumping.+- [ ] Shots test: the bar partway down, then the end with the line above and no bar, light and dark.+- [ ] Run red, commit; implement; run green, commit.diff --git a/docs/plans/assets/2026-11-04-agent-card-no-terminal-dark.png b/docs/plans/assets/2026-11-04-agent-card-no-terminal-dark.pngnew file mode 100644index 000000000..2f45915ceBinary files /dev/null and b/docs/plans/assets/2026-11-04-agent-card-no-terminal-dark.png differdiff --git a/docs/plans/assets/2026-11-04-agent-card-no-terminal-light.png b/docs/plans/assets/2026-11-04-agent-card-no-terminal-light.pngnew file mode 100644index 000000000..68d173912Binary files /dev/null and b/docs/plans/assets/2026-11-04-agent-card-no-terminal-light.png differdiff --git a/docs/validation-and-release.md b/docs/validation-and-release.mdindex 718a6d889..71903fdec 100644--- a/docs/validation-and-release.md+++ b/docs/validation-and-release.md@@ -103,6 +103,32 @@ created before #991 still carries the old planner, which expects removed jobs anfails `ci/required` for CLI, Desktop, workflow and script changes. Update the branchfrom `main` before relying on its CI.+### Reuse in a batch PR++A batch PR (a branch from main with each member PR merged in, as the PM builds them) reuses+a member PR's passed result the same way. A phone PR batched with unrelated work does not+run mobile-checks again. The planner reads the members from the batch's own commits, never+from the PR's text:++- The new head's first-parent line, down to a commit on the base branch, is all+ two-parent merges. Each second parent is a member PR's tested head; one that is on the+ base branch is main merged again and brings only main's commits. A commit pushed by hand+ on that line runs everything. A batch that merged main again after its earlier head ran+ CI reads its members the same way.+- Each member's latest `ci/required` check is followed to its exact run, attempt and+ receipt, as above, and a component that member's run reused points at its original run.+- A component is reused from the first member whose run covered it and whose tested+ commit differs from the batch head in none of that component's inputs, with the same+ shared-input rules. Two members that both change a component's inputs therefore run it:+ each one's diff holds the other's change. A main change to an input after a member ran+ runs it too.+- A member whose run cannot be read is only no candidate. Its changes are still in every+ other member's diff, so a component it touched runs. With no readable member, every+ component runs.++The receipt names the batch's members in order, and `make merge-pr`, using main's copy of+the planner, refuses a receipt whose members differ from the head's merges.+### What PR CI does not run| Check | Where it runs now | When you must run it yourself |diff --git a/mobile/integration_test/swarm_home_simple_shots_test.dart b/mobile/integration_test/swarm_home_simple_shots_test.dartnew file mode 100644index 000000000..018b0c67d--- /dev/null+++ b/mobile/integration_test/swarm_home_simple_shots_test.dart@@ -0,0 +1,219 @@+import 'package:flutter/material.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:integration_test/integration_test.dart';++import 'package:harness_mobile/notify/system_notices.dart';+import 'package:harness_mobile/settings/experimental_features.dart';+import 'package:harness_mobile/shared/theme/app_theme.dart';+import 'package:harness_mobile/shared/theme/color_palette.dart';+import 'package:harness_mobile/swarm/swarm_page.dart';+import 'package:harness_mobile/swarm/swarm_session.dart';++import '../test/swarm/swarm_fixture.dart';+import '../test/voice_fakes.dart' show MemoryKeyValueStore;++/// Swarm Home as anh Dee's mockup draws it (2026-11-04), on a simulator, in+/// dark then light: the need-you line, one heading per Swarm, an unread+/// project with its dot, the + in the top bar; then the Swarm switcher, with+/// Sort and filter.+///+/// Every answer is scripted in memory ([FakeSwarm]): nothing reaches an+/// account, a machine or the backend.+///+/// flutter drive -d <simulator> --driver=test_driver/journey_driver.dart \+/// --target=integration_test/swarm_home_simple_shots_test.dart+///+/// Screenshots land in `HARNESS_JOURNEY_OUT` (default `build/journey/`).+void main() {+ final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();++ testWidgets('Swarm Home, simplified, in both themes', (tester) async {+ const personal = 'tab-personal';+ Map<String, dynamic> projectOf(String id, String name) => {+ 'id': id,+ 'name': name,+ 'ownerId': me,+ 'leadConversationId': 'lead-$id',+ 'visibility': 'public',+ 'members': <Object>[],+ 'updateMinutes': 5,+ };+ final now = DateTime.now();+ Map<String, dynamic> leadOf(String projectId, {int sequence = 0}) => {+ ...groupData(+ 'lead-$projectId',+ title: projectId,+ lastMessageSequence: sequence,+ ),+ 'projectId': projectId,+ };+ // When each chat last changed, on its part, as a read carries it.+ Map<String, dynamic> timed(+ Map<String, dynamic> load,+ Map<String, int> minutesAgo,+ ) => {+ ...load,+ 'groups': [+ for (final part in load['groups'] as List)+ {+ ...part as Map<String, dynamic>,+ if (minutesAgo[part['key']] case final ago?)+ 'changedAt': now+ .subtract(Duration(minutes: ago))+ .millisecondsSinceEpoch,+ },+ ],+ };+ FakeSwarm backend() {+ final fake = FakeSwarm();+ fake.routes['/api/super-tabs/list'] = (_) => {+ 'tabs': [+ {'id': tab, 'name': 'autonomous.ai', 'ownerId': me},+ {'id': personal, 'name': 'Personal', 'ownerId': me},+ ],+ 'next': null,+ };+ const derived = {'decisionsWaiting': 2};+ fake.routes['/api/super-tabs/$tab/parts'] = (_) => timed(+ firstLoad(+ derived: derived,+ head: headData(+ name: 'autonomous.ai',+ projects: [+ for (final name in [+ 'openharness',+ 'spaceship',+ 'lamp',+ 'computer',+ ])+ projectOf(name, name),+ ],+ ),+ groups: [+ leadOf('openharness', sequence: 4),+ leadOf('spaceship'),+ leadOf('lamp'),+ leadOf('computer'),+ ],+ ),+ {+ 'lead-openharness': 2,+ 'lead-spaceship': 20,+ 'lead-lamp': 40,+ 'lead-computer': 60,+ },+ );+ fake.routes['/api/super-tabs/$tab/changes'] = (_) =>+ changes(cursor: 'c2', derived: derived);+ fake.routes['/api/super-tabs/$tab/decisions?state=open'] = (_) => {+ 'decisions': [+ for (final (id, question) in [+ ('d1', 'Ship the login fix behind a flag?'),+ ('d2', 'Merge the voice messages batch?'),+ ])+ {+ 'id': id,+ 'projectName': 'spaceship',+ 'conversationId': 'lead-spaceship',+ 'conversationTitle': 'spaceship',+ 'askerName': 'River',+ 'question': question,+ 'options': ['Yes', 'No'],+ },+ ],+ };+ fake.routes['/api/super-tabs/$tab/mentions?state=waiting'] = (_) => {+ 'mentions': <Object>[],+ };+ fake.routes['/api/super-tabs/$personal/parts'] = (_) => timed(+ firstLoad(+ tabId: personal,+ head: headData(+ id: personal,+ name: 'Personal',+ projects: [projectOf('storage', 'storage')],+ ),+ groups: [leadOf('storage')],+ ),+ {'lead-storage': 90},+ );+ fake.routes['/api/super-tabs/$personal/changes'] = (_) =>+ changes(cursor: 'c2');+ fake.routes['/api/super-tabs/$personal/decisions?state=open'] = (_) => {+ 'decisions': <Object>[],+ };+ fake.routes['/api/super-tabs/$personal/mentions?state=waiting'] = (_) => {+ 'mentions': <Object>[],+ };+ fake.routes['/api/super-tabs/$tab/conversations/'] = (_) => {+ 'messages': <Object>[],+ 'next': null,+ };+ return fake;+ }++ Finder key(String value) => find.byKey(ValueKey(value));+ Future<void> settle() async {+ for (var i = 0; i < 12; i++) {+ await tester.pump(const Duration(milliseconds: 100));+ }+ }++ for (final palette in [HarnessPalette.graphite, HarnessPalette.paper]) {+ final brightness = palette.brightness;+ AppTheme.palette.value = palette;+ AppTheme.brightness.value = brightness;+ final features = ExperimentalFeaturesStore(storage: MemoryKeyValueStore())+ ..value = {PhoneExperiment.swarm};+ final account = ValueNotifier<String?>(me);+ final fake = backend();+ final host = SwarmHost(+ accountId: () => account.value,+ account: account,+ request: fake.request,+ notices: SilentSystemNotices(),+ features: features,+ readMarks: MemoryKeyValueStore(),+ )..foreground = false;+ await tester.pumpWidget(+ MaterialApp(+ key: UniqueKey(),+ debugShowCheckedModeBanner: false,+ theme: buildAppTheme(brightness: brightness),+ builder: (_, child) => SwarmScope(notifier: host, child: child!),+ home: const SwarmPage(),+ ),+ );+ for (+ var i = 0;+ i < 100 && key('swarm-need-line').evaluate().isEmpty;+ i+++ ) {+ await tester.pump(const Duration(milliseconds: 100));+ }+ // Read once: what was there is read; then openharness moves on.+ fake.routes['/api/super-tabs/$tab/changes'] = (_) => changes(+ cursor: 'c3',+ derived: const {'decisionsWaiting': 2},+ groups: [+ {+ ...part('lead-openharness', 30, leadOf('openharness', sequence: 6)),+ 'changedAt': now.millisecondsSinceEpoch,+ },+ ],+ );+ await host.session!.inbox.refresh();+ await settle();+ expect(key('swarm-project-$tab-openharness'), findsOneWidget);+ await binding.takeScreenshot('home-simple-home-${brightness.name}');+ await tester.tap(key('swarm-title-button'));+ await settle();+ await binding.takeScreenshot('home-simple-switcher-${brightness.name}');+ await tester.pumpWidget(const SizedBox());+ host.dispose();+ account.dispose();+ }+ AppTheme.palette.value = HarnessPalette.graphite;+ AppTheme.brightness.value = Brightness.dark;+ });+}diff --git a/mobile/lib/swarm/swarm_activity_page.dart b/mobile/lib/swarm/swarm_activity_page.dartindex fa9931e46..b19c84363 100644--- a/mobile/lib/swarm/swarm_activity_page.dart+++ b/mobile/lib/swarm/swarm_activity_page.dart@@ -26,6 +26,7 @@ import 'swarm_reader.dart';import 'swarm_row.dart';import 'swarm_session.dart';import 'swarm_style.dart';+import 'swarm_threads_page.dart' show openSwarmThreads;import 'swarm_you_page.dart' show SwarmYouButton;/// Activity asked, from elsewhere in the tabs, to show [filter]: a tile on@@ -288,7 +289,23 @@ class _SwarmActivityViewState extends State<SwarmActivityView> {),)else- const SwarmTabHeader('Activity', trailing: SwarmYouButton()),+ // Threads, the ones the person follows, before You: where+ // Home's Threads tile was (anh Dee, 2026-11-04).+ SwarmTabHeader(+ 'Activity',+ trailing: Row(+ mainAxisSize: MainAxisSize.min,+ children: [+ SwarmIconButton(+ key: const ValueKey('swarm-activity-threads'),+ icon: LucideIcons.messagesSquare300,+ label: 'Threads',+ onPressed: () => openSwarmThreads(context),+ ),+ const SwarmYouButton(),+ ],+ ),+ ),if (session != null)Expanded(child: ListenWhileInSight(diff --git a/mobile/lib/swarm/swarm_home_need_line.dart b/mobile/lib/swarm/swarm_home_need_line.dartnew file mode 100644index 000000000..e7fa7fa32--- /dev/null+++ b/mobile/lib/swarm/swarm_home_need_line.dart@@ -0,0 +1,93 @@+import 'package:flutter/material.dart';+import 'package:lucide_icons_flutter/lucide_icons.dart';++import 'package:harness_mobile/shared/theme/app_space.dart';+import 'package:harness_mobile/shared/theme/app_theme.dart';+import 'package:harness_mobile/shared/theme/app_type.dart';+import 'package:harness_mobile/shared/widgets/touch_target.dart';+import 'package:harness_mobile/theme/app_theme.dart' show AppColors;++/// The top of Swarm Home: one line, "2 need you · 1 done", in place of the+/// three tiles While you were away, Threads and Agents (anh Dee, 2026-11-04:+/// "less is better"). Home draws it only while something needs the person.+/// How many need them ([needs], yellow), then the work done since they last+/// left the app ([done]), said only when some was. A tap opens what needs+/// them ([onTap]). Threads is in Activity's top bar now, and the agents in+/// the Swarm switcher and Search.+class SwarmNeedLine extends StatelessWidget {+ const SwarmNeedLine({+ super.key,+ required this.needs,+ required this.done,+ required this.onTap,+ });++ final int needs;+ final int? done;+ final VoidCallback onTap;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ final done = switch (this.done) {+ final n? when n > 0 => n,+ _ => null,+ };+ return Semantics(+ button: true,+ label: ['$needs need you', if (done != null) '$done done'].join(', '),+ excludeSemantics: true,+ onTap: onTap,+ child: InkWell(+ key: const ValueKey('swarm-need-line'),+ borderRadius: BorderRadius.circular(AppCard.radius),+ onTap: onTap,+ child: ConstrainedBox(+ constraints: const BoxConstraints(minHeight: minTouchTarget),+ child: Padding(+ padding: const EdgeInsets.symmetric(horizontal: AppSpace.l),+ child: Row(+ children: [+ Expanded(+ child: Text.rich(+ TextSpan(+ children: [+ TextSpan(+ text: '$needs',+ style: TextStyle(color: AppColors.warning),+ ),+ const TextSpan(text: ' need you'),+ if (done != null)+ TextSpan(+ text: ' · $done done',+ style: TextStyle(+ color: AppPalette.textSecondary,+ fontWeight: AppFont.regular,+ ),+ ),+ ],+ ),+ key: const ValueKey('swarm-need-line-text'),+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: AppType.label(+ color: AppPalette.textPrimary,+ fontWeight: AppFont.semibold,+ height: 1.3,+ ),+ ),+ ),+ const SizedBox(width: AppSpace.s),+ Icon(+ LucideIcons.chevronRight300,+ size: 18,+ color: AppPalette.textFaint,+ ),+ ],+ ),+ ),+ ),+ ),+ );+ }+}diff --git a/mobile/lib/swarm/swarm_home_rows.dart b/mobile/lib/swarm/swarm_home_rows.dartindex cc653f803..15b253c6a 100644--- a/mobile/lib/swarm/swarm_home_rows.dart+++ b/mobile/lib/swarm/swarm_home_rows.dart@@ -130,9 +130,9 @@ class SwarmInvitationRow extends StatelessWidget {/// One project on Home, on one line as Slack's channels (Tony, 2026-11-03):/// its name as a channel's ("#openharness") — bold and bright with something-/// new in it, quiet otherwise — its Swarm faint after it where Home shows-/// several, the first to go when the row is short, and at its end the tags-/// waiting in it ("@2", filled), or a skeleton in their place while what+/// new in it, quiet otherwise — and at its end the tags+/// waiting in it ("@2", filled), else a dot while it is unread (anh Dee,+/// 2026-11-04), or a skeleton in the tags' place while what/// waits is on its way ([tagsLoading]). No dot for how its team is: one on/// every row said little, and the name already says what waits on the person/// (Tony, 2026-11-03). No second line: who reads it and how long ago it moved@@ -143,7 +143,6 @@ class SwarmHomeProjectRow extends StatelessWidget {const SwarmHomeProjectRow({super.key,required this.project,- this.swarmName,this.tagsLoading = false,required this.onTap,this.onLongPress,@@ -154,9 +153,6 @@ class SwarmHomeProjectRow extends StatelessWidget {final SwarmHomeProject project;- /// Its Swarm, where Home shows several.- final String? swarmName;-/// What waits in its Swarm is not read yet: its tags may still come.final bool tagsLoading;final VoidCallback onTap;@@ -197,21 +193,9 @@ class SwarmHomeProjectRow extends StatelessWidget {child: Semantics(label: bright && news.tags == 0 ? 'Unread messages' : null,child: Text.rich(- TextSpan(- text: name,- children: [- if (swarmName case final swarm?)- TextSpan(- text: ' $swarm',- style: AppType.caption(- color: AppPalette.textFaint,- height: 1.3,- ),- ),- ],- ),+ TextSpan(text: name),key: const ValueKey('swarm-project-name'),- semanticsLabel: [name, ?swarmName].join(', '),+ semanticsLabel: name,maxLines: 1,overflow: TextOverflow.ellipsis,style: AppType.label(@@ -236,6 +220,20 @@ class SwarmHomeProjectRow extends StatelessWidget {height: 20,radius: 10,),+ ] else if (news.bold) ...[+ // Unread, as anh Dee's Home draws it (2026-11-04); heard in+ // the name's words.+ const SizedBox(width: 12),+ SizedBox.square(+ key: const ValueKey('swarm-project-unread'),+ dimension: AppSpace.s,+ child: DecoratedBox(+ decoration: ShapeDecoration(+ color: AppPalette.textPrimary,+ shape: const CircleBorder(),+ ),+ ),+ ),],],),diff --git a/mobile/lib/swarm/swarm_home_tiles.dart b/mobile/lib/swarm/swarm_home_tiles.dartdeleted file mode 100644index c00d57775..000000000--- a/mobile/lib/swarm/swarm_home_tiles.dart+++ /dev/null@@ -1,346 +0,0 @@-import 'package:flutter/material.dart';-import 'package:lucide_icons_flutter/lucide_icons.dart';--import 'package:harness_mobile/phone/fzf.dart' show fzfAge;-import 'package:harness_mobile/shared/theme/app_space.dart';-import 'package:harness_mobile/shared/theme/app_theme.dart';-import 'package:harness_mobile/shared/theme/app_type.dart';-import 'package:harness_mobile/shared/widgets/skeleton.dart';-import 'package:harness_mobile/theme/app_theme.dart' show AppColors;--import 'swarm_agents.dart';-import 'swarm_style.dart';-import 'swarm_threads.dart';--/// The tiles at the top of Swarm Home, Slack's tile bar (Tony, 2026-11-03):-/// While you were away, Threads and Agents side by side, scrolling sideways-/// when they do not fit. One row of tiles in place of two cards leaves the-/// screen to the projects.-class SwarmHomeTiles extends StatelessWidget {- const SwarmHomeTiles({super.key, required this.children});-- final List<Widget> children;-- @override- Widget build(BuildContext context) => SingleChildScrollView(- key: const ValueKey('swarm-home-tiles'),- scrollDirection: Axis.horizontal,- clipBehavior: Clip.none,- child: IntrinsicHeight(- child: Row(- crossAxisAlignment: CrossAxisAlignment.stretch,- children: [- for (final (i, tile) in children.indexed) ...[- if (i > 0) const SizedBox(width: AppSpace.s),- tile,- ],- ],- ),- ),- );-}--/// While you were away as a tile: how long the person was away, from leaving-/// the app ([since]) to coming back ([back]), over the work done since-/// ([done], green) and what needs them now ([needs], yellow), each a skeleton-/// until it is known. A tap opens what needs them ([onTap]).-class SwarmAwayTile extends StatelessWidget {- const SwarmAwayTile({- super.key,- required this.since,- required this.back,- required this.done,- required this.needs,- required this.onTap,- });-- final DateTime since, back;- final int? done, needs;- final VoidCallback onTap;-- @override- Widget build(BuildContext context) {- AppTheme.watch(context);- final age = fzfAge(since.toLocal(), back.toLocal());- final words = AppType.caption(color: AppPalette.textSecondary);- // A figure and its words, as one: its count, or a skeleton as tall.- Widget stat(Key key, int? value, String label, Color color) {- final style = AppType.label(- color: (value ?? 0) > 0 ? color : AppPalette.textSecondary,- fontWeight: AppFont.semibold,- height: 1.2,- );- return Row(- key: key,- mainAxisSize: MainAxisSize.min,- children: [- if (value == null)- SkeletonText(style: style, width: 20)- else- Text('$value', style: style),- const SizedBox(width: AppSpace.xs),- // Large type, or a long count, gives up the words first.- Flexible(- child: Text(- label,- maxLines: 1,- overflow: TextOverflow.ellipsis,- style: words,- ),- ),- ],- );- }-- return _Tile(- key: const ValueKey('swarm-away'),- width: 214,- icon: LucideIcons.clock300,- title: 'While you were away',- titleEnd: age,- label:- 'While you were away, $age: ${done ?? 'not known how many'} done, '- '${needs ?? 'not known how many'} need you',- onTap: onTap,- value: Row(- children: [- Flexible(- child: stat(- const ValueKey('swarm-away-done'),- done,- 'done',- AppColors.success,- ),- ),- const SizedBox(width: AppSpace.m),- Flexible(- flex: 2,- child: stat(- const ValueKey('swarm-away-needs'),- needs,- 'need you',- AppColors.warning,- ),- ),- ],- ),- );- }-}--/// Threads as a tile: the threads the person follows ([threads]), the tags-/// of them in threads filled, else New replies while one has some. A tap-/// opens Threads ([onTap]).-class SwarmThreadsTile extends StatelessWidget {- const SwarmThreadsTile({- super.key,- required this.threads,- required this.onTap,- });-- final SwarmThreadsMerge threads;- final VoidCallback onTap;-- @override- Widget build(BuildContext context) => ListenableBuilder(- listenable: threads,- builder: (context, _) {- AppTheme.watch(context);- final unread = threads.unread, tags = threads.mentions;- return _Tile(- key: const ValueKey('swarm-threads-row'),- width: 104,- icon: LucideIcons.messagesSquare300,- title: 'Threads',- bright: unread || tags > 0,- label: tags > 0- ? 'Threads, $tags ${tags == 1 ? 'mention' : 'mentions'}'- : unread- ? 'Threads, new replies'- : 'Threads',- onTap: onTap,- value: tags > 0- ? Align(- alignment: Alignment.centerLeft,- child: SwarmTags(- tags,- key: const ValueKey('swarm-threads-tags'),- filled: true,- ),- )- : Text(- unread ? 'New replies' : 'No new replies',- maxLines: 1,- overflow: TextOverflow.ellipsis,- style: unread- ? AppType.label(- color: AppPalette.textPrimary,- fontWeight: AppFont.semibold,- height: 1.2,- )- : AppType.caption(color: AppPalette.textFaint),- ),- );- },- );-}--/// Agents as a tile: how many of the person's harnesses work now-/// ([SwarmAgents.working]), a skeleton until the computers answer. A tap-/// opens every agent, by computer ([onTap]): Swarm's way into Harness.-class SwarmAgentsTile extends StatelessWidget {- const SwarmAgentsTile({super.key, required this.agents, required this.onTap});-- final SwarmAgents agents;- final VoidCallback onTap;-- @override- Widget build(BuildContext context) => ListenableBuilder(- listenable: agents,- builder: (context, _) {- AppTheme.watch(context);- final working = agents.working;- final style = AppType.label(- color: AppPalette.textPrimary,- fontWeight: AppFont.semibold,- height: 1.2,- );- return _Tile(- key: const ValueKey('swarm-agents-tile'),- width: 104,- icon: LucideIcons.squareTerminal300,- title: 'Agents',- label: switch (working) {- null => 'Agents',- 0 => 'Agents, none working',- final n => 'Agents, $n working',- },- onTap: onTap,- value: switch (working) {- null => SkeletonText(- key: const ValueKey('swarm-agents-loading'),- style: style,- width: 60,- ),- 0 => Text(- 'None working',- maxLines: 1,- overflow: TextOverflow.ellipsis,- style: AppType.caption(color: AppPalette.textFaint),- ),- final n => Row(- children: [- Container(- width: 8,- height: 8,- decoration: BoxDecoration(- color: AppColors.success,- shape: BoxShape.circle,- ),- ),- const SizedBox(width: 6),- Flexible(- child: Text(- '$n working',- maxLines: 1,- overflow: TextOverflow.ellipsis,- style: style,- ),- ),- ],- ),- },- );- },- );-}--/// One tile: its glyph and [title] over its [value], heard as [label].-class _Tile extends StatelessWidget {- const _Tile({- super.key,- required this.width,- required this.icon,- required this.title,- required this.value,- required this.label,- required this.onTap,- this.titleEnd,- this.bright = false,- });-- final double width;- final IconData icon;- final String title;-- /// Quiet words at the title's end: how long ago.- final String? titleEnd;- final Widget value;- final String label;- final VoidCallback onTap;-- /// Something new in it: its title in the main ink.- final bool bright;-- @override- Widget build(BuildContext context) {- final ink = bright ? AppPalette.textPrimary : AppPalette.textSecondary;- return Semantics(- button: true,- label: label,- excludeSemantics: true,- onTap: onTap,- child: Material(- color: AppGlass.rowFill,- borderRadius: BorderRadius.circular(AppCard.radius),- child: InkWell(- borderRadius: BorderRadius.circular(AppCard.radius),- onTap: onTap,- child: SizedBox(- width: width,- child: Padding(- padding: const EdgeInsets.fromLTRB(- AppSpace.m,- AppSpace.s + 2,- AppSpace.s + 2,- AppSpace.s + 2,- ),- child: Column(- crossAxisAlignment: CrossAxisAlignment.stretch,- mainAxisAlignment: MainAxisAlignment.spaceBetween,- children: [- Row(- children: [- Icon(icon, size: 16, color: ink),- const SizedBox(width: 6),- Expanded(- child: Text(- title,- maxLines: 1,- overflow: TextOverflow.ellipsis,- style: AppType.caption(- color: ink,- fontWeight: bright ? AppFont.semibold : null,- ),- ),- ),- if (titleEnd case final end?) ...[- const SizedBox(width: AppSpace.xs),- Text(- end,- style: AppType.caption(color: AppPalette.textFaint),- ),- ],- ],- ),- const SizedBox(height: 6),- value,- ],- ),- ),- ),- ),- ),- );- }-}diff --git a/mobile/lib/swarm/swarm_home_top.dart b/mobile/lib/swarm/swarm_home_top.dartindex 7fa6ec690..c066a2c24 100644--- a/mobile/lib/swarm/swarm_home_top.dart+++ b/mobile/lib/swarm/swarm_home_top.dart@@ -7,10 +7,13 @@ import 'package:lucide_icons_flutter/lucide_icons.dart';import 'package:harness_mobile/shared/theme/app_icon_size.dart';import 'package:harness_mobile/shared/theme/app_space.dart';import 'package:harness_mobile/shared/theme/app_theme.dart';+import 'package:harness_mobile/shared/theme/app_type.dart';import 'package:harness_mobile/shared/widgets/skeleton.dart';import 'package:harness_mobile/shared/widgets/touch_target.dart';import 'model.dart';+import 'swarm_agents.dart';+import 'swarm_home_view_sheet.dart';import 'swarm_inbox.dart';import 'swarm_needs_page.dart';import 'swarm_project_tasks.dart' show swarmProgressAt;@@ -22,7 +25,7 @@ import 'swarm_style.dart';/// The top of Swarm Home, direction C, as Tony's prototype C1 draws it/// (2026-10-30): the Swarm switcher in its title ([showSwarmSwitcher]). While-/// you were away is a tile since 2026-11-03 (`SwarmAwayTile`).+/// you were away is the need-you line since 2026-11-04 (`SwarmNeedLine`)./// Whether the account's Swarms are still to come, a failed read still trying:/// never from a server without the list, which no read will bring.@@ -52,40 +55,71 @@ String swarmHomeTitle(SwarmInbox inbox, List<SwarmListing> shown) =>/// The Swarms Home can show, from its title: All Swarms over several, each/// Swarm, the one shown ticked and what waits in each other one counted,-/// and Join or create a Swarm. A Swarm the account loses, or whose read is-/// taken away, while it is open leaves it, and a tap on it shows nothing.-/// A Swarm with a menu for the person ([swarmHasMenu]) shows a ⋮ on its-/// row; the ⋮, or holding the row, closes it for that menu over Home-/// ([showSwarmMenu]).-Future<void> showSwarmSwitcher(BuildContext context, SwarmSession session) =>- showModalBottomSheet<void>(- context: context,- backgroundColor: AppGlass.rowFill,- shape: AppControl.sheetShape,- isScrollControlled: true,- builder: (sheet) => _Switcher(- session: session,- onJoin: () {- Navigator.of(sheet).pop();- unawaited(showSwarmJoinOrCreate(context));- },- onHold: (swarmId) {- Navigator.of(sheet).pop();- unawaited(showSwarmMenu(context, session.inbox, swarmId));- },- ),+/// then Sort and filter ([onView]) and the agents on the person's computers+/// ([agents]), where Home has them — moved here from Home's filter icon and+/// Agents tile (anh Dee, 2026-11-04: less on Home) — then New project, for+/// someone who may write in a Swarm Home shows ([offersNewProject]; moved+/// from the foot of Home, River 2026-11-04: Home keeps one +, New+/// message's), and Join or create a Swarm. A Swarm the account loses, or whose read is taken away, while it+/// is open leaves it, and a tap on it shows nothing. A Swarm with a menu for+/// the person ([swarmHasMenu]) shows a ⋮ on its row; the ⋮, or holding the+/// row, closes it for that menu over Home ([showSwarmMenu]). Each of the+/// rows under the Swarms closes it, then opens what it names.+Future<void> showSwarmSwitcher(+ BuildContext context,+ SwarmSession session, {+ VoidCallback? onView,+ SwarmAgents? agents,+ bool Function()? offersNewProject,+ VoidCallback? onNewProject,+}) => showModalBottomSheet<void>(+ context: context,+ backgroundColor: AppGlass.rowFill,+ shape: AppControl.sheetShape,+ isScrollControlled: true,+ builder: (sheet) {+ VoidCallback then(VoidCallback open) => () {+ Navigator.of(sheet).pop();+ open();+ };+ return _Switcher(+ session: session,+ onJoin: then(() => unawaited(showSwarmJoinOrCreate(context))),+ onHold: (swarmId) => then(+ () => unawaited(showSwarmMenu(context, session.inbox, swarmId)),+ )(),+ onView: onView == null ? null : then(onView),+ agents: agents,+ onAgents: agents == null ? null : then(() => agents.openList(context)),+ offersNewProject: offersNewProject,+ onNewProject: onNewProject == null ? null : then(onNewProject),);+ },+);class _Switcher extends StatelessWidget {const _Switcher({required this.session,required this.onJoin,required this.onHold,+ this.onView,+ this.agents,+ this.onAgents,+ this.offersNewProject,+ this.onNewProject,});final SwarmSession session;final VoidCallback onJoin;+ /// Sort and filter, and the agents' list: null, no row.+ final VoidCallback? onView, onAgents, onNewProject;+ final SwarmAgents? agents;++ /// Whether New project is offered now: read on each build, so a role+ /// taken away while it is open takes the row with it.+ final bool Function()? offersNewProject;+/// A Swarm's menu asked for, from its row's ⋮ or by holding the row,/// with its id.final ValueChanged<String> onHold;@@ -103,9 +137,10 @@ class _Switcher extends StatelessWidget {@overrideWidget build(BuildContext context) => ListenableBuilder(- listenable: Listenable.merge([session.inbox, session.home]),+ listenable: Listenable.merge([session.inbox, session.home, ?agents]),builder: (context, _) {final inbox = session.inbox;+ final home = session.home;final swarms = [for (final swarm in inbox.swarms)if (swarmHomeOffers(inbox, swarm.id)) swarm,@@ -195,6 +230,59 @@ class _Switcher extends StatelessWidget {? () => onHold(swarm.id): null,),+ if (onView case final onView?)+ // Said in words too, as the dot is not heard.+ Semantics(+ button: true,+ label:+ 'Sort and filter: ${swarmHomeSortLabel(home)}, '+ '${swarmHomeFilterLabel(home.filter)}',+ excludeSemantics: true,+ onTap: onView,+ child: SwarmRow(+ key: const ValueKey('swarm-switch-view'),+ leading: const _Glyph(LucideIcons.listFilter300),+ title: 'Sort and filter',+ trailing: home.viewChanged+ ? SizedBox.square(+ key: const ValueKey('swarm-switch-view-dot'),+ dimension: AppSpace.s,+ child: DecoratedBox(+ decoration: ShapeDecoration(+ color: AppPalette.swarmAccent,+ shape: const CircleBorder(),+ ),+ ),+ )+ : null,+ chevron: null,+ onTap: onView,+ ),+ ),+ if ((agents, onAgents) case (final agents?, final onAgents?))+ SwarmRow(+ key: const ValueKey('swarm-switch-agents'),+ leading: const _Glyph(LucideIcons.squareTerminal300),+ title: 'Agents',+ trailing: switch (agents.working) {+ final n? when n > 0 => Text(+ '$n working',+ style: AppType.caption(color: AppPalette.textSecondary),+ ),+ _ => null,+ },+ chevron: null,+ onTap: onAgents,+ ),+ if ((offersNewProject, onNewProject)+ case (final offers?, final onNewProject?) when offers())+ SwarmRow(+ key: const ValueKey('swarm-switch-new-project'),+ leading: const _Glyph(LucideIcons.squarePlus300),+ title: 'New project',+ chevron: null,+ onTap: onNewProject,+ ),SwarmRow(key: const ValueKey('swarm-switch-join'),leading: const _Glyph(LucideIcons.plus300),diff --git a/mobile/lib/swarm/swarm_new_message_sheet.dart b/mobile/lib/swarm/swarm_new_message_sheet.dartindex f13af56f3..7802b3b56 100644--- a/mobile/lib/swarm/swarm_new_message_sheet.dart+++ b/mobile/lib/swarm/swarm_new_message_sheet.dart@@ -905,47 +905,3 @@ class _PickCircle extends StatelessWidget {);}}--/// Home's New message: a round + in the accent, the screen's primary-/// action, floating at its bottom right over the list (Tony, 10-30: as-/// Slack Mobile has it; desktop design system, Phone).-class SwarmNewMessageButton extends StatelessWidget {- const SwarmNewMessageButton({super.key, required this.onPressed});-- final VoidCallback onPressed;-- /// Its round, wider than a target, as a floating action is drawn.- static const double size = 56;-- @override- Widget build(BuildContext context) {- AppTheme.watch(context);- return Semantics(- button: true,- label: 'New message',- excludeSemantics: true,- child: DecoratedBox(- decoration: BoxDecoration(- shape: BoxShape.circle,- boxShadow: AppSurface.shadow,- ),- child: Material(- color: AppPalette.accent,- shape: const CircleBorder(),- clipBehavior: Clip.antiAlias,- child: InkWell(- onTap: onPressed,- child: SizedBox.square(- dimension: size,- child: Icon(- LucideIcons.plus,- size: AppIconSize.standalone,- color: AppInk.onFill,- ),- ),- ),- ),- ),- );- }-}diff --git a/mobile/lib/swarm/swarm_new_project_sheet.dart b/mobile/lib/swarm/swarm_new_project_sheet.dartindex 097a42742..98069d93d 100644--- a/mobile/lib/swarm/swarm_new_project_sheet.dart+++ b/mobile/lib/swarm/swarm_new_project_sheet.dart@@ -28,8 +28,9 @@ import 'swarm_session.dart';import 'swarm_style.dart';import 'swarm_uploads.dart';-/// New project from the phone (Tony, 10-30): Swarm Home's last Projects row-/// ([SwarmNewProjectRow]) opens a sheet ([showSwarmNewProjectSheet]) that+/// New project from the phone (Tony, 10-30): the Swarm switcher's New+/// project row (Home's title, since 2026-11-04) opens a sheet+/// ([showSwarmNewProjectSheet]) that/// creates a project in a Swarm the person may write in and starts its/// Product Manager on the Swarm machine they pick, as Desktop's New Project/// does through the Swarm (desktop `super_tabs/launch.dart` `startInSwarm`,@@ -1034,67 +1035,6 @@ class SwarmNewProjectSteps with ChangeNotifier {failure.statusCode != 429;}-/// Swarm Home's last Projects row, in a project row's shape: a plus, then-/// "New project". Shown only to someone who may write in a Swarm Home shows-/// ([swarmMayCreateProject]).-class SwarmNewProjectRow extends StatelessWidget {- const SwarmNewProjectRow({super.key, required this.onTap});-- final VoidCallback onTap;-- @override- Widget build(BuildContext context) {- AppTheme.watch(context);- return Semantics(- button: true,- label: 'New project',- excludeSemantics: true,- child: Material(- color: Colors.transparent,- child: InkWell(- onTap: () {- HapticFeedback.selectionClick();- onTap();- },- child: ConstrainedBox(- constraints: const BoxConstraints(minHeight: SwarmRow.height),- child: Padding(- padding: const EdgeInsets.symmetric(- horizontal: AppSpace.l,- vertical: AppSpace.m,- ),- child: Row(- children: [- SizedBox(- width: 16,- child: Icon(- LucideIcons.plus300,- size: 18,- color: AppPalette.textSecondary,- ),- ),- const SizedBox(width: AppSpace.s),- Expanded(- child: Text(- 'New project',- maxLines: 1,- overflow: TextOverflow.ellipsis,- style: AppType.label(- color: AppPalette.textSecondary,- height: 1.3,- ),- ),- ),- ],- ),- ),- ),- ),- ),- );- }-}-/// A project New project made: the Swarm, and the project.typedef SwarmNewProject = ({String swarmId, String projectId});diff --git a/mobile/lib/swarm/swarm_page.dart b/mobile/lib/swarm/swarm_page.dartindex e6d46f990..05a60788d 100644--- a/mobile/lib/swarm/swarm_page.dart+++ b/mobile/lib/swarm/swarm_page.dart@@ -19,7 +19,7 @@ import 'swarm_conversation_page.dart' show openSwarmConversation;import 'swarm_home_list.dart';import 'swarm_home_rows.dart';import 'swarm_home_search.dart';-import 'swarm_home_tiles.dart';+import 'swarm_home_need_line.dart';import 'swarm_home_top.dart';import 'swarm_inbox.dart';import 'swarm_mark_all.dart';@@ -35,8 +35,6 @@ import 'swarm_session.dart';import 'swarm_start.dart';import 'swarm_style.dart';import 'swarm_tabs.dart';-import 'swarm_threads.dart';-import 'swarm_threads_page.dart';import 'swarm_unread.dart';import 'swarm_you_page.dart' show SwarmYouButton;@@ -67,20 +65,17 @@ bool swarmHomeListed(SwarmInbox inbox, String swarmId, String projectId) {/// switcher to every Swarm, All Swarms and Join or create/// ([showSwarmSwitcher]), then Search ([openSwarmSearch]) and the person's/// avatar, which opens You ([SwarmYouButton]); a pull down at the top opens-/// Search too ([SwarmPullToSearch]); a row of tiles ([SwarmHomeTiles]): While-/// you were away whenever there is a Swarm to report on, Threads, and the-/// agents on the person's computers; then the projects they pinned on this+/// Search too ([SwarmPullToSearch]); one line while something needs the+/// person, "2 need you · 1 done" ([SwarmNeedLine], anh Dee 2026-11-04: less+/// is better), in place of three tiles; then the projects they pinned on this/// phone, one line each, then the others by their latest activity, those/// quiet for a day folded under "Other projects" ([swarmHomeLists]), Sort and/// filter at the right of their first caption. Every Swarm's, or-/// the one picked ([SwarmHomePrefs.swarmId]). A round + floats at its bottom-/// right over them: New message (Tony, 10-30: Slack Mobile's;-/// [showSwarmNewMessage]). What needs the person, and the invitations to a+/// the one picked ([SwarmHomePrefs.swarmId]). New message's + is in the top+/// bar next to Search ([showSwarmNewMessage]), so nothing floats over the+/// list (anh Dee, 2026-11-04). What needs the person, and the invitations to a/// Swarm, are the Activity tab's.///-/// The Threads tile ([SwarmThreadsTile]): the threads the person follows in-/// the Swarms shown, bright while one has new replies.-////// Pushed over another page it has a back button instead of the switcher./// Reads the account's [SwarmSession] from the shell; with none, its skeleton/// while the account is on its way ([SwarmScope.accountComingOf]), else says@@ -91,7 +86,8 @@ class SwarmPage extends StatefulWidget {/// What a project's last move, and the time away, is measured from.final DateTime Function() now;- /// Gone for less, While you were away stays on the time away it was showing.+ /// Gone for less, the need-you line counts the work done from the time+ /// the person left before.static const awayAfter = Duration(minutes: 5);@override@@ -101,10 +97,6 @@ class SwarmPage extends StatefulWidget {class _SwarmPageState extends State<SwarmPage> {SwarmSession? _session;- /// The Threads tile's threads, over the Swarms Home shows, while it is in- /// sight: out of sight, it asks for none.- SwarmThreadsMerge? _threads;-/// Kept out of sight under Harness ([OutOfSight]), as it was left: it is no/// Swarm screen meanwhile — a notice still tells what arrives — and draws/// nothing new. Shown again, it reads the Swarms as on any return to Home.@@ -115,7 +107,7 @@ class _SwarmPageState extends State<SwarmPage> {Timer? _tick;/// When the person last left the app, as read when Home first drew and- /// each time the app came back: what While you were away counts from.+ /// each time the app came back: what the work done is counted from.DateTime? _away;bool _awayRead = false;@@ -137,7 +129,7 @@ class _SwarmPageState extends State<SwarmPage> {final now = widget.now();final left = _session?.home.seenAt;// A moment away ends nothing: a phone locked or an app glanced at must- // not turn "2h, 9 done" into "now, 0 done" for someone still reading it.+ // not turn "9 done" into "0 done" for someone still reading it.if (_awaySpansTime &&left != null &&now.difference(left) < SwarmPage.awayAfter) {@@ -174,14 +166,7 @@ class _SwarmPageState extends State<SwarmPage> {_hidden = hidden;_tick?.cancel();_tick = null;- _threads?.dispose();- _threads = null;if (hidden || session == null) return;- _threads = swarmThreadsOf(- session,- shown: () => _shown(session),- changed: session.home,- );session.enter();unawaited(session.inbox.refresh());_tick = Timer.periodic(const Duration(minutes: 1), (_) {@@ -193,7 +178,6 @@ class _SwarmPageState extends State<SwarmPage> {void dispose() {_lifecycle.dispose();_tick?.cancel();- _threads?.dispose();if (!_hidden) _session?.leave();super.dispose();}@@ -201,8 +185,9 @@ class _SwarmPageState extends State<SwarmPage> {void _openProject(BuildContext context, String swarmId, String projectId) =>openSwarmProject(context, swarmId: swarmId, projectId: projectId);- /// The projects quiet for a day are listed under Other projects.- bool _quietOpen = false;+ /// The Swarms, by id, whose projects quiet for a day are listed under+ /// Other projects.+ final _quietOpen = <String>{};/// New message is open: a second tap on + opens no second one.bool _composing = false;@@ -284,19 +269,6 @@ class _SwarmPageState extends State<SwarmPage> {: Listenable.merge([session, session.inbox, session.home]);return Scaffold(backgroundColor: tty.ground,- // The tab's Home only, as its compose was: pushed over a page, Home- // is a step on the way back.- floatingActionButton: session == null || pushed- ? null- : ListenWhileInSight(- listenable: listens!,- builder: (context) => _offersNewMessage(context, session)- ? SwarmNewMessageButton(- key: const ValueKey('swarm-new-message'),- onPressed: () => unawaited(_newMessage(context, session)),- )- : const SizedBox.shrink(),- ),body: SafeArea(bottom: false,child: Column(@@ -353,15 +325,12 @@ class _SwarmPageState extends State<SwarmPage> {);}- /// Around Home's rows: the last clears the floating +.+ /// Around Home's rows: the last clears the phone's home indicator.EdgeInsets _listPadding(BuildContext context) => EdgeInsets.fromLTRB(AppSpace.m,0,AppSpace.m,- MediaQuery.paddingOf(context).bottom +- SwarmNewMessageButton.size +- AppSpace.l +- AppSpace.xl,+ MediaQuery.paddingOf(context).bottom + AppSpace.xl,);/// Home's top bar. At the root, the tab's title: the Swarm shown and a@@ -402,6 +371,7 @@ class _SwarmPageState extends State<SwarmPage> {title,trailing: _trailing(context,+ session,search: swarmStartView(context, session) == null,),loading: listing,@@ -413,15 +383,30 @@ class _SwarmPageState extends State<SwarmPage> {titleLabel: listing? 'Loading your Swarm. Switch Swarm': 'Swarm: $title. Switch Swarm',- onTitle: () => unawaited(showSwarmSwitcher(context, session)),+ onTitle: () => unawaited(+ showSwarmSwitcher(+ context,+ session,+ onView: () => _openView(context, session),+ agents: swarmAgentsOf(context),+ // For someone who may write in a Swarm shown: never a viewer.+ offersNewProject: () => _shown(session)+ .any((swarm) => swarmMayCreateProject(session.inbox, swarm.id)),+ onNewProject: () => unawaited(_newProject(session, _shown(session))),+ ),+ ),);}- /// Search, where Home has a list to search ([search]), then the person's- /// avatar, at the end of the top bar (Slack's two, Tony 2026-11-03): Search- /// in place of Home's search field, and of Sort and filter, which went to- /// the projects it sorts ([_viewButton]).- Widget _trailing(BuildContext context, {required bool search}) => Row(+ /// Search, where Home has a list to search ([search]), New message's ++ /// where there may be a Swarm to post in, then the person's avatar, at the+ /// end of the top bar (Slack's, Tony 2026-11-03; the + moved up from over+ /// the list, anh Dee 2026-11-04).+ Widget _trailing(+ BuildContext context,+ SwarmSession session, {+ required bool search,+ }) => Row(mainAxisSize: MainAxisSize.min,children: [if (search)@@ -431,38 +416,32 @@ class _SwarmPageState extends State<SwarmPage> {label: 'Search',onPressed: () => openSwarmSearch(context),),+ if (_offersNewMessage(context, session))+ SwarmIconButton(+ key: const ValueKey('swarm-new-message'),+ icon: LucideIcons.plus300,+ label: 'New message',+ onPressed: () => unawaited(_newMessage(context, session)),+ ),const SwarmYouButton(),],);- /// Sort and filter, at the right of the projects' first caption (Tony,- /// 2026-11-03): a dot with anything but the defaults on, said in words too.- /// Mark all read and Refresh are in its sheet, Mark all read greyed with- /// nothing unread in the Swarms shown.- Widget _viewButton(BuildContext context, SwarmSession session) {- final home = session.home;- return SwarmIconButton(- key: const ValueKey('swarm-home-view'),- icon: LucideIcons.listFilter300,- size: 20,- label:- 'Sort and filter: ${swarmHomeSortLabel(home)}, '- '${swarmHomeFilterLabel(home.filter)}',- dot: home.viewChanged,- onPressed: () => unawaited(- showSwarmHomeViewSheet(- context,- session,- unread: () => swarmAnyUnread([- for (final swarm in _shown(session))- ?session.inbox.reader(swarm.id),- ]),- onMarkAllRead: () => _markAllRead(context, session, _shown(session)),- onRefresh: () => unawaited(_refresh(context, session)),- ),- ),- );- }+ /// Sort and filter, from the Swarm switcher (anh Dee, 2026-11-04: no+ /// filter icon on Home; its row has the dot and the words). Mark all read+ /// and Refresh are in its sheet, Mark all read greyed with nothing unread+ /// in the Swarms shown.+ void _openView(BuildContext context, SwarmSession session) => unawaited(+ showSwarmHomeViewSheet(+ context,+ session,+ unread: () => swarmAnyUnread([+ for (final swarm in _shown(session)) ?session.inbox.reader(swarm.id),+ ]),+ onMarkAllRead: () => _markAllRead(context, session, _shown(session)),+ onRefresh: () => unawaited(_refresh(context, session)),+ ),+ );/// Mark all read over the Swarms [shown]: every chat read on this phone at/// once, with an Undo while the marks wait to be sent.@@ -513,11 +492,7 @@ class _SwarmPageState extends State<SwarmPage> {// was until then. Only a server without the list says so, as no read will// ever bring its rows.if (!inbox.loaded && inbox.swarms.isEmpty) {- final away = swarmHomeListing(inbox)- ? _tiles(context, session, const [], null, widget.now())- : null;return [- ?away,if (inbox.error == swarmServerTooOld)Padding(padding: const EdgeInsets.fromLTRB(@@ -533,7 +508,7 @@ class _SwarmPageState extends State<SwarmPage> {),)else- ..._reading(first: away == null),+ ..._reading(first: true),];}final shown = _shown(session);@@ -541,56 +516,19 @@ class _SwarmPageState extends State<SwarmPage> {? shown.single.id: null;final now = widget.now();- final tiles = _tiles(context, session, shown, picked, now);+ final needs = _needLine(context, session, shown, picked, now);return [- ?tiles,- ..._projects(- context,- session,- shown,- now,- first: tiles == null,- view: pushed ? null : _viewButton(context, session),- ),- ];- }-- /// The row of tiles over the projects: While you were away ([_awayTile]),- /// Threads over the Swarms [shown], and the agents on the person's- /// computers, where the app has them; none with none of the three.- Widget? _tiles(- BuildContext context,- SwarmSession session,- List<SwarmListing> shown,- String? picked,- DateTime now,- ) {- final away = _awayTile(context, session, shown, picked, now);- final threads = _threads;- final agents = swarmAgentsOf(context);- final tiles = [- ?away,- if (threads != null && shown.isNotEmpty)- SwarmThreadsTile(- threads: threads,- onTap: () => openSwarmThreads(context, swarmId: picked),- ),- if (agents != null)- SwarmAgentsTile(agents: agents, onTap: () => agents.openList(context)),+ ?needs,+ ..._projects(context, session, shown, now, first: needs == null),];- if (tiles.isEmpty) return null;- return Padding(- padding: const EdgeInsets.only(top: AppSpace.xs),- child: SwarmHomeTiles(children: tiles),- );}- /// While you were away: the work done in the Swarms shown since the person- /// last left the app, or on a first open since it opened, and what needs them- /// there now, each a skeleton while the Swarms, or what waits in them, are- /// not read. Always there, unless no Swarm is left to report on. A tap opens- /// Activity on Needs you.- Widget? _awayTile(+ /// The need-you line over the projects: what needs the person in the+ /// Swarms shown, and the work done there since they last left the app, or+ /// on a first open since it opened. None while nothing needs them, or what+ /// waits is still being read: never "0 need you". A tap opens Activity on+ /// Needs you.+ Widget? _needLine(BuildContext context,SwarmSession session,List<SwarmListing> shown,@@ -602,60 +540,63 @@ class _SwarmPageState extends State<SwarmPage> {_away = home.seenAt;_awayRead = true;}- // Not known yet: drawn as "now" for a moment, it would then jump.- if (!home.loaded) return null;- // Decided at the return: time in the foreground is no time away.+ final inbox = session.inbox;+ if (swarmHomeListing(inbox) || shown.isEmpty) return null;+ final needs = swarmNeedsOf(inbox, picked).length;+ if (needs == 0) return null;+ // Decided at the return: time in the foreground is no time away. Not+ // known yet, the work done is not said, rather than said and then taken+ // back.final back = _back ?? now;final since = _away ?? back;- final inbox = session.inbox;- final listing = swarmHomeListing(inbox);- if (!listing && shown.isEmpty) return null;- // A Swarm not read leaves the work done unknown; one no read will bring is- // left out, or its skeleton would never end.- int? done = listing ? null : 0;- for (final swarm in listing ? const <SwarmListing>[] : shown) {+ int? done = home.loaded ? 0 : null;+ for (final swarm in home.loaded ? shown : const <SwarmListing>[]) {final reader = inbox.reader(swarm.id);if (reader != null && _ended(reader)) continue;final snapshot = reader?.snapshot;done = snapshot == null ? null : done! + swarmDoneSince(snapshot, since);if (done == null) break;}- final needs = swarmNeedsOf(inbox, picked).length;- return SwarmAwayTile(- since: since,- back: back,- done: done,- // None found is not none waiting until all of it is read.- needs: !listing && (needs > 0 || _needsRead(inbox, shown)) ? needs : null,- onTap: () {- if (!showSwarmTab(- context,- SwarmTab.activity,- activity: SwarmActivityFilter.needsYou,- )) {- openSwarmNeeds(context, swarmId: picked);- }- },+ return Padding(+ padding: const EdgeInsets.only(top: AppSpace.xs),+ child: SwarmNeedLine(+ needs: needs,+ done: done,+ onTap: () {+ if (!showSwarmTab(+ context,+ SwarmTab.activity,+ activity: SwarmActivityFilter.needsYou,+ )) {+ openSwarmNeeds(context, swarmId: picked);+ }+ },+ ),);}- /// Pinned, then Projects: every project of the Swarms shown, grouped by- /// [swarmHomeLists]; a Swarm still to be read has rows on their way, a- /// failed read still trying too, as it is in the log. One no read will bring- /// says so. The first caption is the screen's [first] thing, with nothing- /// over it, and Sort and filter ([view]) at its right.+ /// Every project of the Swarms shown, each Swarm's under one small heading,+ /// its name, where Home shows several, and none where it shows one: the+ /// title names it (anh Dee, 2026-11-04: in place of the name on every row,+ /// and of the Projects and Pinned headings). In each Swarm, as+ /// [swarmHomeLists] groups them: its pins first, then the rest, those+ /// quiet for a day folded. A Swarm still to be read has rows on their way+ /// under its heading, a failed read still trying too, as it is in the log;+ /// one no read will bring says so. A filter on says so first, with Show+ /// all, as Home has no filter icon to show it. [first]: the screen's first+ /// thing, with nothing over it.List<Widget> _projects(BuildContext context,SwarmSession session,List<SwarmListing> shown,DateTime now, {required bool first,- Widget? view,}) {final inbox = session.inbox;+ final top = SizedBox(height: first ? AppSpace.s : AppSpace.xs);if (inbox.swarms.isEmpty) {return [- SwarmCaption('Projects', first: first),+ top,Padding(padding: const EdgeInsets.symmetric(horizontal: AppSpace.xs),child: SwarmRow.line(@@ -666,11 +607,13 @@ class _SwarmPageState extends State<SwarmPage> {];}final several = shown.length > 1;- final projects = <SwarmHomeProject>[];- final names = <String, String>{};- final reading = <String>[];- final failed = <(String, String)>[];+ final home = session.home;+ final filter = home.filter;+ final sections = <(SwarmListing, SwarmHomeLists)>[];+ final reading = <String>{};+ final failed = <String, String>{};final asking = <String>{};+ var any = false;for (final swarm in shown) {if (inbox.asks(swarm.id)?.loading ?? false) asking.add(swarm.id);switch (inbox.reader(swarm.id)) {@@ -678,36 +621,40 @@ class _SwarmPageState extends State<SwarmPage> {final snapshot = reader.snapshot!;final news = swarmProjectNews(reader, inbox.asks(swarm.id));final activity = swarmProjectActivity(snapshot, reader.buddies);- for (final project in snapshot.projects) {- final projectNews = news[project.id];- final row = SwarmHomeProject(- swarmId: swarm.id,- project: project,- active: activity[project.id],- news: projectNews ?? swarmNoProjectNews,- );- projects.add(row);- names[row.key] = swarm.name;- }+ final projects = [+ for (final project in snapshot.projects)+ SwarmHomeProject(+ swarmId: swarm.id,+ project: project,+ active: activity[project.id],+ news: news[project.id] ?? swarmNoProjectNews,+ ),+ ];+ any = any || projects.isNotEmpty;+ sections.add((+ swarm,+ swarmHomeFiltered(+ swarmHomeLists(+ projects,+ pins: home.pins,+ now: now,+ sort: home.sort,+ unreadsFirst: home.unreadsFirst,+ ),+ filter,+ ),+ ));case final SwarmReader readerwhen _ended(reader) && reader.error != null:- failed.add((swarm.id, reader.error!));+ failed[swarm.id] = reader.error!;case _:reading.add(swarm.id);}}- final home = session.home;- final filter = home.filter;- final lists = swarmHomeFiltered(- swarmHomeLists(- projects,- pins: home.pins,- now: now,- sort: home.sort,- unreadsFirst: home.unreadsFirst,- ),- filter,- );+ bool listsAny(SwarmHomeLists lists) =>+ lists.pinned.isNotEmpty ||+ lists.recent.isNotEmpty ||+ lists.quiet.isNotEmpty;// Mentions come from their own read: until it answers, none listed says// nothing. A failed one is not none, and says so even over the mentions// another Swarm has listed.@@ -720,110 +667,140 @@ class _SwarmPageState extends State<SwarmPage> {// so, and offers them all.final nothingListed =filter != SwarmHomeFilter.all &&- projects.isNotEmpty &&+ any &&reading.isEmpty &&!mentionsComing &&- lists.pinned.isEmpty &&- lists.recent.isEmpty &&- lists.quiet.isEmpty;+ !sections.any((section) => listsAny(section.$2));Widget row(SwarmHomeProject project) => SwarmHomeProjectRow(key: ValueKey('swarm-project-${project.swarmId}-${project.project.id}'),project: project,- swarmName: several ? names[project.key] : null,tagsLoading: asking.contains(project.swarmId),onTap: () => _openProject(context, project.swarmId, project.project.id),onLongPress: () => unawaited(_pin(context, session, project)),);- final quiet = lists.quiet;- final empty = projects.isEmpty && reading.isEmpty && failed.isEmpty;- // Last, for someone who may write in a Swarm shown: never a viewer.- final create = shown.any((swarm) => swarmMayCreateProject(inbox, swarm.id))- ? SwarmNewProjectRow(- key: const ValueKey('swarm-new-project'),- onTap: () => unawaited(_newProject(session, shown)),+ final empty = !any && reading.isEmpty && failed.isEmpty;+ // Filtered with some listed: what is left out is said, never silent.+ final filterOn =+ filter != SwarmHomeFilter.all && !nothingListed && !mentionsFailed+ ? SwarmRow(+ key: const ValueKey('swarm-filter-on'),+ title: mentionsOn ? 'Mentions only' : 'Unread only',+ trailing: Text(+ 'Show all',+ style: AppType.label(color: AppPalette.swarmAccent),+ ),+ onTap: () => home.setFilter(SwarmHomeFilter.all),): null;- return [- if (lists.pinned.isNotEmpty) ...[- SwarmCaption('Pinned', first: first, trailing: view),- SwarmGroup(children: [for (final p in lists.pinned) row(p)]),- ],- if (lists.recent.isNotEmpty ||- quiet.isNotEmpty ||- empty ||- nothingListed ||- mentionsFailed ||- create != null) ...[- SwarmCaption(- 'Projects',- first: first && lists.pinned.isEmpty,- trailing: lists.pinned.isEmpty ? view : null,+ final notices = [+ ?filterOn,+ if (empty) const SwarmRow(title: 'No project yet', onTap: null),+ if (mentionsFailed)+ const SwarmRow(+ key: ValueKey('swarm-mentions-failed'),+ title: 'Mentions could not be read.',+ onTap: null,+ )+ else if (nothingListed)+ SwarmRow(+ key: const ValueKey('swarm-filter-none'),+ title: mentionsOn ? 'No mentions.' : 'Nothing unread.',+ onTap: null,+ ),+ if (nothingListed)+ SwarmRow(+ key: const ValueKey('swarm-filter-show-all'),+ title: 'Show all',+ chevron: null,+ onTap: () => home.setFilter(SwarmHomeFilter.all),),+ ];+ final listedBy = {for (final (swarm, lists) in sections) swarm.id: lists};+ bool shows(SwarmListing swarm) => switch (listedBy[swarm.id]) {+ final lists? => listsAny(lists),+ null => false,+ };+ bool drawn(SwarmListing swarm) =>+ shows(swarm) ||+ reading.contains(swarm.id) ||+ failed.containsKey(swarm.id);+ final firstDrawn = shown.where(drawn).firstOrNull;+ // Each Swarm's own: one heading over several, its rows in one card. A+ // Swarm whose read was taken away is not named: its line says so.+ List<Widget> section(SwarmListing swarm, List<Widget> body) => [+ if (several && !(inbox.reader(swarm.id)?.accessRevoked ?? false))+ SwarmCaption(+ swarm.name,+ key: ValueKey('swarm-heading-${swarm.id}'),+ // The first heading sits close under the need-you line too.+ first: notices.isEmpty && swarm == firstDrawn,+ )+ else if (notices.isNotEmpty)+ const SizedBox(height: AppSpace.s),+ ...body,+ ];+ List<Widget> listed(SwarmListing swarm, SwarmHomeLists lists) {+ final open = _quietOpen.contains(swarm.id);+ return section(swarm, [SwarmGroup(children: [- if (empty) const SwarmRow(title: 'No project yet', onTap: null),- if (mentionsFailed)- const SwarmRow(- key: ValueKey('swarm-mentions-failed'),- title: 'Mentions could not be read.',- onTap: null,- )- else if (nothingListed)- SwarmRow(- key: const ValueKey('swarm-filter-none'),- title: mentionsOn ? 'No mentions.' : 'Nothing unread.',- onTap: null,- ),- if (nothingListed)- SwarmRow(- key: const ValueKey('swarm-filter-show-all'),- title: 'Show all',- chevron: null,- onTap: () => home.setFilter(SwarmHomeFilter.all),- ),+ for (final p in lists.pinned) row(p),for (final p in lists.recent) row(p),- if (quiet.isNotEmpty) ...[+ if (lists.quiet.isNotEmpty) ...[SwarmOtherProjectsRow(- key: const ValueKey('swarm-other-projects'),- count: quiet.length,- open: _quietOpen,- onTap: () => setState(() => _quietOpen = !_quietOpen),+ key: ValueKey(+ several+ ? 'swarm-other-projects-${swarm.id}'+ : 'swarm-other-projects',+ ),+ count: lists.quiet.length,+ open: open,+ onTap: () => setState(+ () => open+ ? _quietOpen.remove(swarm.id)+ : _quietOpen.add(swarm.id),+ ),),- if (_quietOpen)- for (final p in quiet) row(p),+ if (open)+ for (final p in lists.quiet) row(p),],- ?create,],),- ] else if (reading.isNotEmpty || failed.isNotEmpty)- SwarmCaption(- 'Projects',- first: first && lists.pinned.isEmpty,- trailing: lists.pinned.isEmpty ? view : null,- ),- // A Swarm still to be read has its skeleton below: one is enough.+ ]);+ }++ return [+ top,+ if (notices.isNotEmpty) SwarmGroup(children: notices),+ for (final swarm in shown)+ if (shows(swarm))+ ...listed(swarm, listedBy[swarm.id]!)+ else if (reading.contains(swarm.id))+ ...section(swarm, [+ SwarmSkeletonRows(+ id: 'swarm-projects-loading-${swarm.id}',+ nameOnly: true,+ ),+ ])+ else if (failed[swarm.id] case final error?)+ ...section(swarm, [+ SwarmGroup(+ key: ValueKey('swarm-projects-error-${swarm.id}'),+ children: [SwarmRow(title: error, onTap: null)],+ ),+ ]),+ // A Swarm still to be read has its skeleton: one is enough.if (mentionsComing && reading.isEmpty) ...[- const SizedBox(height: 8),+ const SizedBox(height: AppSpace.s),SwarmSkeletonRows(id: 'swarm-mentions-loading', nameOnly: true),],- for (final (i, id) in reading.indexed) ...[- if (projects.isNotEmpty || i > 0) const SizedBox(height: 8),- SwarmSkeletonRows(id: 'swarm-projects-loading-$id', nameOnly: true),- ],- for (final (id, error) in failed) ...[- const SizedBox(height: 8),- SwarmGroup(- key: ValueKey('swarm-projects-error-$id'),- children: [SwarmRow(title: error, onTap: null)],- ),- ],];}- /// + New project: its sheet over Home, for every Swarm listed, opening on- /// the one [shown] if Home shows one and it is not paused (Dee, 11-01);- /// the project it made opens, unless Home or the account changed- /// meanwhile, or the project is no longer Home's to list.+ /// New project, from the Swarm switcher: its sheet over Home, for every+ /// Swarm listed, opening on the one [shown] if Home shows one and it is+ /// not paused (Dee, 11-01); the project it made opens, unless Home or the+ /// account changed meanwhile, or the project is no longer Home's to list.Future<void> _newProject(SwarmSession session,List<SwarmListing> shown,@@ -865,7 +842,7 @@ class _SwarmPageState extends State<SwarmPage> {/// Home before the list answers: the projects as rows on their way.List<Widget> _reading({required bool first}) => [- SwarmCaption('Projects', first: first),+ SizedBox(height: first ? AppSpace.s : AppSpace.xs),SwarmSkeletonRows(id: 'swarm-projects-loading', nameOnly: true),];}@@ -882,22 +859,6 @@ const _loadingTile = Skeleton(bool _ended(SwarmReader reader) =>reader.snapshot == null && (reader.accessRevoked || reader.updateRequired);-/// Whether what waits on the person in every Swarm [shown] is read: the-/// Swarm, and what waits in it since it was last read in full. One no read-/// will bring has nothing more to wait for.-bool _needsRead(SwarmInbox inbox, List<SwarmListing> shown) => shown.every(- (swarm) => switch (inbox.reader(swarm.id)) {- final reader? when _ended(reader) => true,- SwarmReader(snapshot: _?, accessRevoked: false) => switch (inbox.asks(- swarm.id,- )) {- null => true,- final asks => !asks.loading && asks.error == null,- },- _ => false,- },-);-/// No session: Swarm is off, or nobody is signed in on this phone.class _Unavailable extends StatelessWidget {const _Unavailable();diff --git a/mobile/test/swarm/swarm_activity_page_test.dart b/mobile/test/swarm/swarm_activity_page_test.dartindex eecd5b4de..c2a3eee47 100644--- a/mobile/test/swarm/swarm_activity_page_test.dart+++ b/mobile/test/swarm/swarm_activity_page_test.dart@@ -10,6 +10,7 @@ import 'package:harness_mobile/swarm/swarm_conversation_page.dart';import 'package:harness_mobile/swarm/swarm_request.dart';import 'package:harness_mobile/swarm/swarm_session.dart';import 'package:harness_mobile/swarm/swarm_thread_page.dart';+import 'package:harness_mobile/swarm/swarm_threads_page.dart';import '../voice_fakes.dart';import 'swarm_activity_fixture.dart';@@ -97,6 +98,28 @@ void main() {}});+ testWidgets("the tab's top bar has Threads before You, where Home's Threads "+ 'tile was (anh Dee, 2026-11-04); a tap opens the followed threads', (+ tester,+ ) async {+ await pump(+ tester,+ activityBackend(page: activityPage),+ home: const Scaffold(body: SwarmActivityView()),+ );++ final threads = tester.getRect(key('swarm-activity-threads'));+ final you = tester.getRect(key('swarm-you-button'));+ expect(threads.right, lessThanOrEqualTo(you.left));+ expect(threads.center.dy, closeTo(you.center.dy, 0.5));+ expect(threads.height, greaterThanOrEqualTo(44));+ expect(find.bySemanticsLabel('Threads'), findsWidgets);++ await tester.tap(key('swarm-activity-threads'));+ await tester.pumpAndSettle();+ expect(find.byType(SwarmThreadsPage), findsOneWidget);+ });+testWidgets('Needs you: where and who over the ask, Approve on a decision, ''Reply on work', (tester) async {await pump(tester, activityBackend());diff --git a/mobile/test/swarm/swarm_home_instant_test.dart b/mobile/test/swarm/swarm_home_instant_test.dartindex e281c3f8b..0c7eb98de 100644--- a/mobile/test/swarm/swarm_home_instant_test.dart+++ b/mobile/test/swarm/swarm_home_instant_test.dart@@ -244,12 +244,14 @@ void main() {stopReads(host);});- /// Refresh, from Sort and filter (a pull on Home until 2026-11-03, which- /// opens Search now), up to the read it starts.+ /// Refresh, from Sort and filter in the Swarm switcher (a pull on Home+ /// until 2026-11-03, which opens Search now), up to the read it starts.Future<void> refresh(WidgetTester tester) async {- await tester.tap(key('swarm-home-view'));- await tester.pump();- await tester.pump(const Duration(milliseconds: 400));+ for (final k in ['swarm-title-button', 'swarm-switch-view']) {+ await tester.tap(key(k));+ await tester.pump();+ await tester.pump(const Duration(milliseconds: 400));+ }await tester.tap(key('swarm-home-refresh'));for (var i = 0; i < 10; i++) {await tester.pump(const Duration(milliseconds: 100));diff --git a/mobile/test/swarm/swarm_home_need_line_test.dart b/mobile/test/swarm/swarm_home_need_line_test.dartnew file mode 100644index 000000000..c41341def--- /dev/null+++ b/mobile/test/swarm/swarm_home_need_line_test.dart@@ -0,0 +1,72 @@+import 'package:flutter/material.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:harness_mobile/swarm/swarm_home_need_line.dart';++/// Swarm Home's need-you line (anh Dee, 2026-11-04: "less is better"): one+/// line in place of the three tiles, how many need the person and the work+/// done since they left.+void main() {+ Finder key(String value) => find.byKey(ValueKey(value));++ Future<void> pump(WidgetTester tester, Widget line, {double width = 390}) =>+ tester.pumpWidget(+ MaterialApp(+ home: Scaffold(+ body: Align(+ alignment: Alignment.topLeft,+ child: SizedBox(width: width, child: line),+ ),+ ),+ ),+ );++ String words(WidgetTester tester) =>+ tester.widget<Text>(key('swarm-need-line-text')).textSpan!.toPlainText();++ testWidgets('says how many need the person, then the work done', (+ tester,+ ) async {+ await pump(tester, SwarmNeedLine(needs: 2, done: 1, onTap: () {}));++ expect(words(tester), '2 need you · 1 done');+ expect(+ tester.getSize(key('swarm-need-line')).height,+ greaterThanOrEqualTo(44),+ );+ expect(tester.takeException(), isNull);+ });++ testWidgets('with no work done, or not known yet, it says only what needs '+ 'the person', (tester) async {+ await pump(tester, SwarmNeedLine(needs: 3, done: 0, onTap: () {}));+ expect(words(tester), '3 need you');++ await pump(tester, SwarmNeedLine(needs: 3, done: null, onTap: () {}));+ expect(words(tester), '3 need you');+ });++ testWidgets('is one button for a screen reader, and a tap opens it', (+ tester,+ ) async {+ final semantics = tester.ensureSemantics();+ var taps = 0;+ await pump(tester, SwarmNeedLine(needs: 2, done: 1, onTap: () => taps++));++ expect(find.bySemanticsLabel('2 need you, 1 done'), findsOneWidget);+ await tester.tap(key('swarm-need-line'));+ expect(taps, 1);+ semantics.dispose();+ });++ testWidgets('a narrow phone shortens the words, never overflows', (+ tester,+ ) async {+ await pump(+ tester,+ SwarmNeedLine(needs: 12, done: 340, onTap: () {}),+ width: 120,+ );++ expect(tester.takeException(), isNull);+ });+}diff --git a/mobile/test/swarm/swarm_home_project_row_test.dart b/mobile/test/swarm/swarm_home_project_row_test.dartindex b0c653d12..c3550da12 100644--- a/mobile/test/swarm/swarm_home_project_row_test.dart+++ b/mobile/test/swarm/swarm_home_project_row_test.dart@@ -14,16 +14,29 @@ import 'package:harness_mobile/swarm/swarm_unread.dart';import 'swarm_fixture.dart';/// A project on Swarm Home, one line as Slack's channels (2026-11-03): its-/// #name — bold with something new — its Swarm where Home shows several, and-/// its tags at the end. No dot, no second line, no time.+/// #name — bold with something new — and its tags at the end; no Swarm on it,+/// as Home heads each Swarm's projects with its name. No dot, no second line, no time.void main() {final now = DateTime(2026, 10, 27, 9);- SuperTabSnapshot read({int running = 0}) {+ SuperTabSnapshot read({int running = 0, String name = 'Mobile'}) {final busy = [for (var i = 0; i < running; i++) 'busy-$i'];return SuperTabSnapshot.fromJson(SuperTabParts.firstLoad(firstLoad(+ head: headData(+ projects: [+ {+ 'id': project,+ 'name': name,+ 'ownerId': me,+ 'leadConversationId': leadChat,+ 'visibility': 'public',+ 'members': <Object>[],+ 'updateMinutes': 5,+ },+ ],+ ),agents: [for (final id in busy) agent(id)],groups: [for (final id in busy)@@ -46,7 +59,7 @@ void main() {Future<void> pump(WidgetTester tester, {int running = 0,- String? swarmName,+ String name = 'Mobile',SwarmProjectNews news = swarmNoProjectNews,bool tagsLoading = false,DateTime? active,@@ -54,7 +67,7 @@ void main() {VoidCallback? onTap,VoidCallback? onLongPress,}) {- final snapshot = read(running: running);+ final snapshot = read(running: running, name: name);return tester.pumpWidget(MaterialApp(home: Scaffold(@@ -73,7 +86,6 @@ void main() {active: active,news: news,),- swarmName: swarmName,tagsLoading: tagsLoading,onTap: onTap ?? () {},onLongPress: onLongPress,@@ -136,8 +148,8 @@ void main() {expect(find.byType(SwarmTags), findsNothing);});- testWidgets('something new: bold in the main ink, heard as unread, with no '- 'dot at its end', (tester) async {+ testWidgets('something new: bold in the main ink, heard as unread, with a '+ "dot at its end (anh Dee's mockup, 2026-11-04)", (tester) async {final semantics = tester.ensureSemantics();await pump(tester, news: (bold: true, tags: 0, hasWaitingTag: false));@@ -145,10 +157,31 @@ void main() {expect(style.color, AppPalette.textPrimary);expect(style.fontWeight, FontWeight.w600);expect(find.bySemanticsLabel(RegExp('Unread messages')), findsOneWidget);- expect(dots(), findsNothing, reason: 'no unread dot at its end either');+ final unread = find.byKey(const ValueKey('swarm-project-unread'));+ expect(unread, findsOneWidget);+ final rowBox = tester.getRect(find.byKey(row));+ expect(+ tester.getRect(unread).right,+ greaterThan(rowBox.right - 40),+ reason: "at the row's end",+ );semantics.dispose();});+ testWidgets('quiet, or with tags that say it, no unread dot', (tester) async {+ for (final news in [+ swarmNoProjectNews,+ (bold: true, tags: 2, hasWaitingTag: true),+ ]) {+ await pump(tester, news: news);+ expect(+ find.byKey(const ValueKey('swarm-project-unread')),+ findsNothing,+ reason: '$news',+ );+ }+ });+testWidgets('tags waiting: @N filled at its end, the name bright', (tester,) async {@@ -175,23 +208,21 @@ void main() {expect(find.byType(Skeleton), findsOneWidget);});- testWidgets('with several Swarms, its Swarm follows the name, faint, and '- 'is heard after it', (tester) async {+ testWidgets('has no Swarm on it: one heading per Swarm says it (anh Dee, '+ '2026-11-04)', (tester) async {final semantics = tester.ensureSemantics();- await pump(tester, swarmName: 'Acme');+ await pump(tester);final text = nameText(tester);- final swarm = text.textSpan!.toPlainText();- expect(swarm, endsWith(' Acme'));- expect(text.semanticsLabel, endsWith(', Acme'));+ expect(text.textSpan!.toPlainText(), '#Mobile');+ expect(text.semanticsLabel, '#Mobile');semantics.dispose();});- testWidgets('a long name ellipsizes on its one line, the Swarm the first to '- 'go', (tester) async {+ testWidgets('a long name ellipsizes on its one line', (tester) async {await pump(tester,- swarmName: 'A Swarm with a name far too long for one row of a phone',+ name: 'a project with a name far too long for one row of a phone',width: 240,);diff --git a/mobile/test/swarm/swarm_home_shots_test.dart b/mobile/test/swarm/swarm_home_shots_test.dartindex 92daa8f55..4e90d1bd7 100644--- a/mobile/test/swarm/swarm_home_shots_test.dart+++ b/mobile/test/swarm/swarm_home_shots_test.dart@@ -17,9 +17,10 @@ import '../voice_fakes.dart';import 'swarm_fixture.dart';/// Review screenshots of Swarm Home, direction C, as Tony's prototype C1-/// draws it (2026-10-30) — over two Swarms, back after an hour away:-/// While you were away, Pinned, Projects by latest activity with the quiet-/// ones folded, an unread project and a tagged one — then its switcher, in+/// draws it (2026-10-30), simplified for anh Dee (2026-11-04) — over two+/// Swarms, back after an hour away: the need-you line, each Swarm's projects+/// under its heading, pins first, by latest activity with the quiet ones+/// folded, an unread project and a tagged one — then its switcher, in/// both phone themes, from made-up Swarm data only, to the folder/// `SWARM_HOME_SHOTS` names.final shots = Platform.environment['SWARM_HOME_SHOTS'];@@ -331,7 +332,16 @@ void main() {image.dispose();});await capture('home');- await tester.tap(find.byKey(const ValueKey('swarm-other-projects')));+ await tester.tap(+ find.byWidgetPredicate(+ (w) => switch (w.key) {+ ValueKey<String>(:final value) => value.startsWith(+ 'swarm-other-projects',+ ),+ _ => false,+ },+ ),+ );await tester.pumpAndSettle();await capture('home-quiet-open');await tester.tap(find.byKey(const ValueKey('swarm-title-button')));diff --git a/mobile/test/swarm/swarm_home_test.dart b/mobile/test/swarm/swarm_home_test.dartindex 14a47ee5f..b22ea40a0 100644--- a/mobile/test/swarm/swarm_home_test.dart+++ b/mobile/test/swarm/swarm_home_test.dart@@ -9,8 +9,7 @@ import 'package:lucide_icons_flutter/lucide_icons.dart';import 'package:harness_mobile/notify/system_notices.dart';import 'package:harness_mobile/phone/phone_navigation.dart';import 'package:harness_mobile/settings/experimental_features.dart';-import 'package:harness_mobile/shared/theme/app_theme.dart'- show AppFont;+import 'package:harness_mobile/shared/theme/app_theme.dart' show AppFont;import 'package:harness_mobile/shared/widgets/skeleton.dart';import 'package:harness_mobile/swarm/swarm_conversation_page.dart';import 'package:harness_mobile/swarm/swarm_home_list.dart';@@ -20,6 +19,7 @@ import 'package:harness_mobile/swarm/swarm_leaderboard.dart';import 'package:harness_mobile/swarm/swarm_needs_page.dart';import 'package:harness_mobile/swarm/swarm_new_message_sheet.dart';import 'package:harness_mobile/swarm/swarm_activity_page.dart';+import 'package:harness_mobile/swarm/swarm_agents.dart';import 'package:harness_mobile/swarm/swarm_page.dart';import 'package:harness_mobile/swarm/swarm_project_page.dart';import 'package:harness_mobile/swarm/swarm_project_tabs.dart';@@ -65,6 +65,31 @@ class _Computers extends ChangeNotifier implements SwarmComputers {void add(BuildContext context) {}}+/// The person's agents as a test sets them: two working.+class _Agents extends ChangeNotifier implements SwarmAgents {+ @override+ int? get working => 2;++ @override+ List<SwarmAgentRef> get agents => const [];++ var lists = 0;++ @override+ void openList(BuildContext context) => lists++;++ @override+ void open(BuildContext context, SwarmAgentRef agent) {}+}++/// Computers that also have the person's agents, as the app's do.+class _AgentComputers extends _Computers implements SwarmAgentsSource {+ _AgentComputers() : super(const [(name: 'MacBook Pro', away: false)]);++ @override+ final _Agents agents = _Agents();+}+/// Half an hour after the fixture's parts last changed (epoch milliseconds/// 1 and on): every project moved 30 minutes ago, and none is quiet.DateTime _halfHourIn() => DateTime.fromMillisecondsSinceEpoch(@@ -341,9 +366,8 @@ void main() {group("Home's top", () {testWidgets('as C1 draws it: the Swarm shown is the title, a button with '- 'its tile, and nothing at its end; the projects under it, New '- "message's + floating over them; no Jump to, no menu, no Needs you, "- 'no Buddies', (tester) async {+ "its tile; New message's + in the top bar; the projects under it; no "+ 'Jump to, no menu, no Needs you, no Buddies', (tester) async {await pump(tester, backend(buddy: true));expect(@@ -370,7 +394,8 @@ void main() {);expect(y(tester, 'swarm-new-message'),- greaterThan(y(tester, 'swarm-project-$tab-$project')),+ lessThan(y(tester, 'swarm-project-$tab-$project')),+ reason: 'in the top bar',);expect(y(tester, 'swarm-title-button'),@@ -379,7 +404,7 @@ void main() {expect(find.text('Jump to…'), findsNothing);expect(find.text('Needs you'), findsNothing, reason: "Activity's now");expect(find.text('Ship it behind a flag?'), findsNothing);- expect(key('swarm-away'), findsOneWidget, reason: 'always there');+ expect(key('swarm-need-line'), findsOneWidget, reason: 'one need');expect(find.text('Buddies'), findsNothing);expect(key('swarm-home-buddy-$tab-$project'), findsNothing);expect(find.text('Chat with PM'), findsNothing);@@ -426,6 +451,36 @@ void main() {expect(find.text('Join or create a Swarm'), findsNothing);});+ testWidgets("the switcher's Agents row opens every agent on the person's "+ 'computers, as the Agents tile did; with no agents to show, none', (+ tester,+ ) async {+ await pump(tester, backend());+ await openSwitcher(tester);+ expect(key('swarm-switch-agents'), findsNothing, reason: 'none known');+ await tester.tapAt(const Offset(195, 40));+ await tester.pumpAndSettle();++ final computers = _AgentComputers();+ addTearDown(computers.dispose);+ await pump(tester, backend(), computers: computers);+ await openSwitcher(tester);+ expect(+ y(tester, 'swarm-switch-$tab'),+ lessThan(y(tester, 'swarm-switch-agents')),+ );+ expect(inside('swarm-switch-agents', find.text('Agents')), findsOne);+ expect(+ tester.getSize(key('swarm-switch-agents')).height,+ greaterThanOrEqualTo(44),+ );++ await tester.tap(key('swarm-switch-agents'));+ await tester.pumpAndSettle();+ expect(computers.agents.lists, 1);+ expect(key('swarm-switch-$tab'), findsNothing, reason: 'it closed');+ });+testWidgets("+ asks where the new message goes, over the same ""projects' chats; ✕ goes back to Home", (tester) async {await pump(tester, backend());@@ -461,7 +516,7 @@ void main() {expect(host.session!.inbox.error, unread);expect(key('swarm-projects-loading'), findsOneWidget);- expect(find.text('Projects'), findsOneWidget);+ expect(find.text('Projects'), findsNothing, reason: 'no heading');expect(find.text(unread), findsNothing);fake.routes['/api/super-tabs/list'] = listed;@@ -523,33 +578,7 @@ void main() {});});- group("Home's first caption", () {- bool first(WidgetTester tester, String text) => tester- .widget<SwarmCaption>(- find.byWidgetPredicate((w) => w is SwarmCaption && w.text == text),- )- .first;-- testWidgets('under the Threads row, Projects has the usual room', (- tester,- ) async {- await pump(tester, backend());-- expect(find.byKey(const ValueKey('swarm-threads-row')), findsOneWidget);- expect(first(tester, 'Projects'), isFalse);- });-- testWidgets('over Pinned, Projects has the usual room', (tester) async {- final host = await pump(tester, backend());- host.session!.home.pin(tab, project, true);- await tester.pumpAndSettle();-- expect(first(tester, 'Pinned'), isFalse, reason: 'under Threads');- expect(first(tester, 'Projects'), isFalse);- });- });-- group('While you were away', () {+ group('the need-you line', () {/// The app hidden, then shown again [later].Future<void> away(WidgetTester tester,@@ -586,25 +615,38 @@ void main() {},};- testWidgets('there on a first open and back within five minutes; back '- 'later, how long, the work done since and what needs you; a tap '- 'opens what needs you', (tester) async {+ String line(WidgetTester tester) => tester+ .widget<Text>(key('swarm-need-line-text'))+ .textSpan!+ .toPlainText();++ /// Nothing waits on the person: no decision, tag or work asking.+ FakeSwarm quiet() {+ final fake = backend();+ fake.routes['/api/super-tabs/$tab/parts'] = (_) => firstLoad();+ fake.routes['/api/super-tabs/$tab/changes'] = (_) =>+ changes(cursor: 'c2');+ fake.routes['/api/super-tabs/$tab/decisions?state=open'] = (_) => {+ 'decisions': <Object>[],+ };+ fake.routes['/api/super-tabs/$tab/mentions?state=waiting'] = (_) => {+ 'mentions': <Object>[],+ };+ return fake;+ }++ testWidgets('one line in place of the three tiles: how many need you, '+ 'then the work done since the person left; a tap opens Activity on '+ 'Needs you', (tester) async {var now = _halfHourIn();final fake = backend();final host = await pump(tester, fake, now: () => now);- expect(- inside('swarm-away', find.text('now')),- findsOneWidget,- reason: 'never left: no time away yet',- );- expect(inside('swarm-away-done', find.text('0')), findsOneWidget);- await away(tester, const Duration(minutes: 4), (d) => now = now.add(d));- expect(- inside('swarm-away', find.text('4m')),- findsOneWidget,- reason: 'four minutes',- );+ expect(key('swarm-home-tiles'), findsNothing);+ expect(key('swarm-away'), findsNothing);+ expect(key('swarm-threads-row'), findsNothing);+ expect(key('swarm-agents-tile'), findsNothing);+ expect(line(tester), '3 need you', reason: 'nothing done yet');final left = now;moveOn(fake, {@@ -616,70 +658,57 @@ void main() {await tester.pumpAndSettle();expect(- y(tester, 'swarm-title-button'),- lessThan(y(tester, 'swarm-away')),+ line(tester),+ '3 need you · 1 done',+ reason: 'the work done before the person left is not counted',);expect(- y(tester, 'swarm-away'),- lessThan(y(tester, 'swarm-project-$tab-$project')),+ y(tester, 'swarm-title-button'),+ lessThan(y(tester, 'swarm-need-line')),);- expect(inside('swarm-away', find.text('2h')), findsOneWidget);expect(- inside('swarm-away-done', find.text('1')),- findsOneWidget,- reason: 'the work done before the person left is not counted',+ y(tester, 'swarm-need-line'),+ lessThan(y(tester, 'swarm-project-$tab-$project')),);- expect(inside('swarm-away-needs', find.text('3')), findsOneWidget);expect(- tester.getSize(key('swarm-away')).height,+ tester.getSize(key('swarm-need-line')).height,greaterThanOrEqualTo(44),);- await tester.tap(key('swarm-away'));+ await tester.tap(key('swarm-need-line'));await tester.pumpAndSettle();expect(find.byType(SwarmActivityPage), findsOneWidget);});- testWidgets(- 'back within five minutes and using the app on: the time stays, '- 'as only time in the background is time away',- (tester) async {- var now = _halfHourIn();- await pump(tester, backend(), now: () => now);- await away(tester, const Duration(minutes: 4), (d) => now = now.add(d));- expect(inside('swarm-away', find.text('4m')), findsOneWidget);-- now = now.add(const Duration(minutes: 2));- await tester.pump(const Duration(minutes: 2));- expect(- inside('swarm-away', find.text('4m')),- findsOneWidget,- reason: 'two minutes in the foreground are no time away',- );- },- );-- testWidgets('opened four minutes after the app was last left, and used '- 'on: four minutes', (tester) async {+ testWidgets('a moment away counts the work done from when the person '+ 'left before; a long time away counts from then', (tester) async {var now = _halfHourIn();- final store = MemoryKeyValueStore()- ..values['swarm_home.$me'] = jsonEncode({- 'pins': <Object>[],- 'seen': now- .subtract(const Duration(minutes: 4))- .millisecondsSinceEpoch,- });- await pump(tester, backend(), now: () => now, store: store);- expect(inside('swarm-away', find.text('4m')), findsOneWidget);+ final fake = backend();+ final host = await pump(tester, fake, now: () => now);+ final left = now;+ moveOn(fake, {+ 'g-after': done('g-after', left.add(const Duration(minutes: 30))),+ });+ await away(tester, const Duration(hours: 1), (d) => now = now.add(d));+ await host.session!.inbox.refresh();+ await tester.pumpAndSettle();+ expect(line(tester), '3 need you · 1 done');- now = now.add(const Duration(minutes: 2));- await tester.pump(const Duration(minutes: 2));- expect(inside('swarm-away', find.text('4m')), findsOneWidget);+ await away(tester, const Duration(seconds: 30), (d) => now = now.add(d));+ expect(+ line(tester),+ '3 need you · 1 done',+ reason: 'a phone locked for a moment takes nothing away',+ );++ await away(tester, const Duration(minutes: 6), (d) => now = now.add(d));+ expect(line(tester), '3 need you', reason: 'done before they left');});- testWidgets('waits for when the app was last left, so it never shows a '- 'first open and then jumps', (tester) async {+ testWidgets('waits for when the app was last left, so the work done is '+ 'never counted from now and then jumps', (tester) async {final now = _halfHourIn();+ final fake = backend();final store = _HeldStore()..values['swarm_home.$me'] = jsonEncode({'pins': <Object>[],@@ -687,76 +716,42 @@ void main() {.subtract(const Duration(minutes: 20)).millisecondsSinceEpoch,});- await pump(+ moveOn(fake, {+ 'g-after': done('g-after', now.subtract(const Duration(minutes: 10))),+ });+ final host = await pump(tester,- backend(),+ fake,now: () => now,store: store,settle: false,);- expect(key('swarm-away'), findsNothing);+ await host.session!.inbox.refresh();+ await frames(tester);+ expect(line(tester), '3 need you', reason: 'not known yet');store.release.complete();await tester.pumpAndSettle();- expect(inside('swarm-away', find.text('20m')), findsOneWidget);- });-- testWidgets('with no Swarm to report on, there is none', (tester) async {- final fake = backend();- fake.routes['/api/super-tabs/list'] = (_) => {- 'tabs': <Object>[],- 'next': null,- };- await pump(tester, fake);-- expect(key('swarm-away'), findsNothing);- });-- testWidgets('a moment away leaves the card as it was; a long time away '- 'starts it over', (tester) async {- var now = _halfHourIn();- await pump(tester, backend(), now: () => now);- await away(tester, const Duration(hours: 1), (d) => now = now.add(d));- expect(inside('swarm-away', find.text('1h')), findsOneWidget);-- await away(tester, const Duration(seconds: 30), (d) => now = now.add(d));- expect(- inside('swarm-away', find.text('1h')),- findsOneWidget,- reason: 'a phone locked for a moment takes nothing away',- );- await away(tester, const Duration(minutes: 4), (d) => now = now.add(d));- expect(inside('swarm-away', find.text('1h')), findsOneWidget);-- await away(tester, const Duration(minutes: 6), (d) => now = now.add(d));- expect(inside('swarm-away', find.text('6m')), findsOneWidget);- expect(inside('swarm-away', find.text('1h')), findsNothing);+ expect(line(tester), '3 need you · 1 done');});- testWidgets('its time is how long the person was away, not how long since '- 'they left', (tester) async {- var now = _halfHourIn();- await pump(tester, backend(), now: () => now);- await away(tester, const Duration(minutes: 10), (d) => now = now.add(d));- expect(inside('swarm-away', find.text('10m')), findsOneWidget);+ testWidgets('with nothing waiting on the person, there is no line', (+ tester,+ ) async {+ await pump(tester, quiet());- now = now.add(const Duration(minutes: 3));- await tester.pump(const Duration(minutes: 3));- expect(inside('swarm-away', find.text('10m')), findsOneWidget);- expect(find.text('13m'), findsNothing);+ expect(key('swarm-project-$tab-$project'), findsOneWidget);+ expect(key('swarm-need-line'), findsNothing);});- testWidgets('what needs you is a dash while it is read, and when it '- 'could not be read, never 0', (tester) async {+ testWidgets('never "0 need you": while what waits is read again, or '+ 'could not be read, no line', (tester) async {var now = _halfHourIn();// What waits on the person is one decision alone.- final fake = backend();+ final fake = quiet();fake.routes['/api/super-tabs/$tab/parts'] = (_) =>firstLoad(derived: const {'decisionsWaiting': 1});- fake.routes['/api/super-tabs/$tab/mentions?state=waiting'] = (_) => {- 'mentions': <Object>[],- };fake.routes['/api/super-tabs/$tab/decisions?state=open'] = (_) => {'decisions': [{@@ -771,57 +766,28 @@ void main() {],};final host = await pump(tester, fake, now: () => now);- await away(tester, const Duration(hours: 1), (d) => now = now.add(d));- expect(inside('swarm-away-needs', find.text('1')), findsOneWidget);+ expect(line(tester), '1 need you');fake.routes['/api/super-tabs/$tab/changes'] = (_) => {'reload': true};- fake.routes['/api/super-tabs/$tab/decisions?state=open'] = (_) =>- throw SuperTabFailure('INTERNAL', 'Broken', statusCode: 500);final gate = Completer<void>();- final asked = fake.routes['/api/super-tabs/$tab/decisions?state=open']!;- fake.routes['/api/super-tabs/$tab/decisions?state=open'] = (body) async {+ fake.routes['/api/super-tabs/$tab/decisions?state=open'] = (_) async {await gate.future;- return asked(body);+ throw SuperTabFailure('INTERNAL', 'Broken', statusCode: 500);};unawaited(host.session!.inbox.refresh());await frames(tester);- expect(inside('swarm-away-needs', find.byType(SkeletonText)), findsOne);- expect(inside('swarm-away-needs', find.text('0')), findsNothing);+ expect(find.textContaining('0 need you'), findsNothing);gate.complete();await frames(tester);- expect(inside('swarm-away-needs', find.byType(SkeletonText)), findsOne);- expect(inside('swarm-away-needs', find.text('0')), findsNothing);+ expect(find.textContaining('0 need you'), findsNothing);});- testWidgets('the figures are skeletons while a Swarm shown is not read, '- 'its rows on their way, and the failure says nothing', (tester) async {- var now = _halfHourIn();- final fake = backend()- ..routes['/api/super-tabs/$tab/parts'] = (_) =>- throw SuperTabFailure('INTERNAL', 'Broken', statusCode: 500);- await pump(tester, fake, now: () => now, settle: false);- await away(- tester,- const Duration(hours: 1),- (d) => now = now.add(d),- settle: false,- );-- expect(inside('swarm-away-done', find.byType(SkeletonText)), findsOne);- expect(inside('swarm-away-needs', find.byType(SkeletonText)), findsOne);- expect(key('swarm-projects-loading-$tab'), findsOneWidget);- expect(key('swarm-projects-error-$tab'), findsNothing);- expect(find.text('Broken'), findsNothing);- });-- testWidgets('back from away before the list answers: the card, its figures '- 'skeletons, never a false none; the figures once it is read', (+ testWidgets('with no Swarm, or before the list answers, there is none', (tester,) async {- var now = _halfHourIn();final fake = backend();final gate = Completer<void>();final listed = fake.routes['/api/super-tabs/list']!;@@ -829,47 +795,36 @@ void main() {await gate.future;return listed(body);};- await pump(tester, fake, now: () => now, settle: false);- await away(- tester,- const Duration(hours: 1),- (d) => now = now.add(d),- settle: false,- );+ await pump(tester, fake, settle: false);expect(key('swarm-projects-loading'), findsOneWidget);- expect(inside('swarm-away-done', find.byType(SkeletonText)), findsOne);- expect(inside('swarm-away-needs', find.byType(SkeletonText)), findsOne);- expect(inside('swarm-away', find.text('0')), findsNothing);+ expect(key('swarm-need-line'), findsNothing);gate.complete();await tester.pumpAndSettle();+ expect(line(tester), '3 need you');- expect(inside('swarm-away', find.byType(SkeletonText)), findsNothing);+ final none = backend();+ none.routes['/api/super-tabs/list'] = (_) => {+ 'tabs': <Object>[],+ 'next': null,+ };+ await pump(tester, none);+ expect(key('swarm-need-line'), findsNothing);});- testWidgets('a Swarm no read will bring says why, and leaves no skeleton '- 'for ever', (tester) async {- var now = _halfHourIn();+ testWidgets('a Swarm no read will bring says why, and leaves no line', (+ tester,+ ) async {final fake = backend()..routes['/api/super-tabs/$tab/parts'] = (_) =>throw SuperTabFailure('UPDATE_REQUIRED', 'Update', statusCode: 426);- await pump(tester, fake, now: () => now, settle: false);- await away(- tester,- const Duration(hours: 1),- (d) => now = now.add(d),- settle: false,- );+ await pump(tester, fake, settle: false);+ await frames(tester);expect(key('swarm-projects-error-$tab'), findsOneWidget);- expect(- find.text('Update Harness to keep using this Swarm.'),- findsOneWidget,- );expect(key('swarm-projects-loading-$tab'), findsNothing);- expect(inside('swarm-away-done', find.text('0')), findsOneWidget);- expect(inside('swarm-away', find.byType(SkeletonText)), findsNothing);+ expect(key('swarm-need-line'), findsNothing);});});@@ -1006,6 +961,7 @@ void main() {const webRow = 'swarm-project-$tab-$web';expect(weightOf(tester, webRow, 'Web'), AppFont.semibold);+ expect(inside(webRow, key('swarm-project-unread')), findsOneWidget);expect(inside(webRow, find.textContaining('@')), findsNothing);expect(inside(webRow, find.byType(SwarmTags)), findsNothing);});@@ -1080,31 +1036,29 @@ void main() {expect(key('swarm-project-$tab-$project'), findsNothing);});- testWidgets('a long press pins a project at the top, under Pinned; '- 'Unpin puts it back', (tester) async {+ testWidgets('a long press pins a project at the top, with no Pinned '+ 'heading (anh Dee, 2026-11-04); Unpin puts it back', (tester) async {final host = await pump(tester, backend());- expect(find.text('Pinned'), findsNothing);+ double top(String id) => y(tester, 'swarm-project-$tab-$id');+ expect(top(web), lessThan(top(project)), reason: 'newer first');- await tester.longPress(key('swarm-project-$tab-$web'));+ await tester.longPress(key('swarm-project-$tab-$project'));await tester.pumpAndSettle();expect(inside('swarm-pin', find.text('Pin to top')), findsOneWidget);await tester.tap(key('swarm-pin'));await tester.pumpAndSettle();- expect(find.text('Pinned'), findsOneWidget);- expect(- y(tester, 'swarm-project-$tab-$web'),- lessThan(tester.getTopLeft(find.text('Projects')).dy),- );- expect(host.session!.home.pinned(tab, web), isTrue);+ expect(find.text('Pinned'), findsNothing);+ expect(top(project), lessThan(top(web)));+ expect(host.session!.home.pinned(tab, project), isTrue);- await tester.longPress(key('swarm-project-$tab-$web'));+ await tester.longPress(key('swarm-project-$tab-$project'));await tester.pumpAndSettle();expect(inside('swarm-pin', find.text('Unpin')), findsOneWidget);await tester.tap(key('swarm-pin'));await tester.pumpAndSettle();- expect(find.text('Pinned'), findsNothing);- expect(host.session!.home.pinned(tab, web), isFalse);+ expect(top(web), lessThan(top(project)));+ expect(host.session!.home.pinned(tab, project), isFalse);});testWidgets("the prototype's top bar, captions and dots", (tester) async {@@ -1116,13 +1070,13 @@ void main() {reason: "its ink 8 points in, the tile 4 in from it",);expect(- tester.getBottomRight(key('swarm-new-message')),- const Offset(390 - 16, 844 - 16),- reason: 'New message floats 16 points in from the corner',+ middle(tester, key('swarm-new-message')),+ closeTo(middle(tester, key('swarm-title-button')), 0.5),+ reason: 'New message is in the top bar, nothing floats',);- expect(tester.getSize(key('swarm-new-message')), const Size(56, 56));expect(tester.widget<Text>(key('swarm-title')).data, 'Phone Swarm');- expect(find.text('Projects'), findsOneWidget, reason: 'sentence case');+ expect(find.text('Projects'), findsNothing, reason: 'no heading');+ expect(key('swarm-home-view'), findsNothing, reason: 'no filter icon');expect(key('swarm-needs-count'), findsNothing);expect(inside('swarm-project-$tab-$project', find.byType(SwarmProjectTile)),@@ -1572,32 +1526,56 @@ void main() {return fake;}- testWidgets("every Swarm's projects on Home, each with its Swarm; the "- 'same project id in two Swarms is two rows, pinned apart', (- tester,- ) async {+ testWidgets("every Swarm's projects on Home under one small heading, its "+ 'name, and no row naming its Swarm (anh Dee, 2026-11-04); the same '+ 'project id in two Swarms is two rows, pinned apart, a pin first in '+ 'its own Swarm', (tester) async {final host = await pump(tester, two());const mobileRow = 'swarm-project-$tab-$project';+ const webRow = 'swarm-project-$tab-$web';const backendRow = 'swarm-project-$second-$project';- // Its Swarm after its name, on its one line.- expect(inside(mobileRow, find.text('#Mobile Phone Swarm')), findsOne);- expect(inside(backendRow, find.text('#Backend Work Swarm')), findsOne);-- await tester.longPress(key(backendRow));- await tester.pumpAndSettle();- await tester.tap(key('swarm-pin'));- await tester.pumpAndSettle();-- expect(host.session!.home.pins, {'$second/$project'});expect(- y(tester, backendRow),- lessThan(tester.getTopLeft(find.text('Projects')).dy),+ tester.widget<SwarmCaption>(key('swarm-heading-$tab')).text,+ 'Phone Swarm',+ );+ expect(+ tester.widget<SwarmCaption>(key('swarm-heading-$second')).text,+ 'Work Swarm',+ );+ final order = [+ 'swarm-heading-$tab',+ webRow,+ mobileRow,+ 'swarm-heading-$second',+ backendRow,+ ];+ for (final (i, k) in order.indexed.skip(1)) {+ expect(y(tester, order[i - 1]), lessThan(y(tester, k)), reason: k);+ }+ expect(inside(mobileRow, find.text('#Mobile')), findsOne);+ expect(inside(backendRow, find.text('#Backend')), findsOne);+ expect(+ inside(mobileRow, find.textContaining('Swarm', findRichText: true)),+ findsNothing,);++ for (final row in [backendRow, mobileRow]) {+ await tester.longPress(key(row));+ await tester.pumpAndSettle();+ await tester.tap(key('swarm-pin'));+ await tester.pumpAndSettle();+ }++ expect(host.session!.home.pins, {'$second/$project', '$tab/$project'});+ expect(y(tester, 'swarm-heading-$tab'), lessThan(y(tester, mobileRow)));+ expect(y(tester, mobileRow), lessThan(y(tester, webRow)));expect(- y(tester, mobileRow),- greaterThan(tester.getTopLeft(find.text('Projects')).dy),+ y(tester, webRow),+ lessThan(y(tester, 'swarm-heading-$second')),+ reason: 'a pin stays in its Swarm',);+ expect(find.text('Pinned'), findsNothing);});testWidgets('over two Swarms the title is All Swarms; one picked in the '@@ -1655,6 +1633,11 @@ void main() {findsNothing,reason: 'one Swarm: its name is not on each row',);+ expect(+ key('swarm-heading-$second'),+ findsNothing,+ reason: 'one Swarm: the title names it',+ );await openSwitcher(tester);expect(@@ -2844,13 +2827,9 @@ void main() {expect(key('swarm-projects-loading'), findsOneWidget);expect(find.text('Buddies'), findsNothing);- expect(find.text('Projects'), findsOneWidget);+ expect(find.text('Projects'), findsNothing);expect(find.textContaining('Reading'), findsNothing);- expect(- key('swarm-away'),- findsOneWidget,- reason: 'its figures skeletons',- );+ expect(key('swarm-need-line'), findsNothing, reason: 'not known yet');listed.complete();await tester.pumpAndSettle();@@ -2912,11 +2891,19 @@ void main() {expect(key('swarm-project-$second-$project'), findsOneWidget);expect(key('swarm-projects-loading-$tab'), findsOneWidget);- expect(- y(tester, 'swarm-projects-loading-$tab'),- greaterThan(y(tester, 'swarm-project-$second-$project')),- reason: 'after the rows read',- );+ final order = [+ 'swarm-heading-$tab',+ 'swarm-projects-loading-$tab',+ 'swarm-heading-$second',+ 'swarm-project-$second-$project',+ ];+ for (final (i, k) in order.indexed.skip(1)) {+ expect(+ y(tester, order[i - 1]),+ lessThan(y(tester, k)),+ reason: 'each Swarm in its place, its rows on their way: $k',+ );+ }await tester.tap(key('swarm-title-button'));await frames(tester);expect(key('swarm-switch-$tab'), findsOneWidget);@@ -2977,7 +2964,7 @@ void main() {await tester.pumpAndSettle();expect(find.byType(SwarmStartView), findsNothing);- expect(find.text('Projects'), findsOneWidget);+ expect(key('swarm-project-$tab-$project'), findsOneWidget);});testWidgets('with a computer and a Swarm, Home is as it was', (@@ -2986,7 +2973,7 @@ void main() {await pump(tester, backend(), computers: _Computers(const [mac]));expect(find.byType(SwarmStartView), findsNothing);- expect(find.text('Projects'), findsOneWidget);+ expect(key('swarm-project-$tab-$project'), findsOneWidget);});});}diff --git a/mobile/test/swarm/swarm_home_tiles_test.dart b/mobile/test/swarm/swarm_home_tiles_test.dartdeleted file mode 100644index 5111f6bf5..000000000--- a/mobile/test/swarm/swarm_home_tiles_test.dart+++ /dev/null@@ -1,185 +0,0 @@-import 'package:flutter/material.dart';-import 'package:flutter_test/flutter_test.dart';-import 'package:harness_mobile/shared/widgets/skeleton.dart';-import 'package:harness_mobile/swarm/swarm_agents.dart';-import 'package:harness_mobile/swarm/swarm_home_tiles.dart';--/// The person's agents as a test sets them.-class _Agents extends ChangeNotifier implements SwarmAgents {- _Agents(this.working);-- @override- int? working;-- @override- List<SwarmAgentRef> get agents => const [];-- var lists = 0;-- @override- void openList(BuildContext context) => lists++;-- @override- void open(BuildContext context, SwarmAgentRef agent) {}-- void set(int? next) {- working = next;- notifyListeners();- }-}--/// Swarm Home's tiles (Slack's tile bar, 2026-11-03): While you were away,-/// Threads and Agents in one row that scrolls sideways when it does not fit.-void main() {- final back = DateTime(2026, 11, 3, 9);- Finder key(String value) => find.byKey(ValueKey(value));- Finder inside(String k, Finder matching) =>- find.descendant(of: key(k), matching: matching);-- Future<void> pump(- WidgetTester tester,- List<Widget> tiles, {- double width = 390,- }) => tester.pumpWidget(- MaterialApp(- home: Scaffold(- body: Align(- alignment: Alignment.topLeft,- child: SizedBox(- width: width,- child: SwarmHomeTiles(children: tiles),- ),- ),- ),- ),- );-- Widget away({int? done = 34, int? needs = 4, VoidCallback? onTap}) =>- SwarmAwayTile(- since: back.subtract(const Duration(hours: 21)),- back: back,- done: done,- needs: needs,- onTap: onTap ?? () {},- );-- group('While you were away', () {- testWidgets('says how long, what was done and what needs the person', (- tester,- ) async {- await pump(tester, [away()]);-- expect(inside('swarm-away', find.text('While you were away')), findsOne);- expect(inside('swarm-away', find.text('21h')), findsOneWidget);- expect(inside('swarm-away-done', find.text('34')), findsOneWidget);- expect(inside('swarm-away-done', find.text('done')), findsOneWidget);- expect(inside('swarm-away-needs', find.text('4')), findsOneWidget);- expect(inside('swarm-away-needs', find.text('need you')), findsOne);- expect(tester.takeException(), isNull);- });-- testWidgets('a figure not known yet is a skeleton, and heard as such', (- tester,- ) async {- final semantics = tester.ensureSemantics();- await pump(tester, [away(done: null, needs: null)]);-- expect(inside('swarm-away-done', find.byType(SkeletonText)), findsOne);- expect(inside('swarm-away-needs', find.byType(SkeletonText)), findsOne);- expect(- find.bySemanticsLabel(- 'While you were away, 21h: not known how many done, '- 'not known how many need you',- ),- findsOneWidget,- );- semantics.dispose();- });-- testWidgets('is one button for a screen reader, and a tap opens it', (- tester,- ) async {- final semantics = tester.ensureSemantics();- var taps = 0;- await pump(tester, [away(onTap: () => taps++)]);-- expect(- find.bySemanticsLabel('While you were away, 21h: 34 done, 4 need you'),- findsOneWidget,- );- await tester.tap(key('swarm-away'));- expect(taps, 1);- semantics.dispose();- });- });-- group('Agents', () {- testWidgets('a skeleton until the computers answer, then how many work', (- tester,- ) async {- final agents = _Agents(null);- addTearDown(agents.dispose);- await pump(tester, [SwarmAgentsTile(agents: agents, onTap: () {})]);-- expect(key('swarm-agents-loading'), findsOneWidget);-- agents.set(2);- await tester.pump();-- expect(key('swarm-agents-loading'), findsNothing);- expect(inside('swarm-agents-tile', find.text('2 working')), findsOne);-- agents.set(0);- await tester.pump();-- expect(inside('swarm-agents-tile', find.text('None working')), findsOne);- });-- testWidgets('is heard with its count, and a tap opens every agent', (- tester,- ) async {- final semantics = tester.ensureSemantics();- final agents = _Agents(1);- addTearDown(agents.dispose);- var taps = 0;- await pump(tester, [- SwarmAgentsTile(agents: agents, onTap: () => taps++),- ]);-- expect(find.bySemanticsLabel('Agents, 1 working'), findsOneWidget);- await tester.tap(key('swarm-agents-tile'));- expect(taps, 1);- semantics.dispose();- });- });-- testWidgets('the row: away first and widest, the tiles as tall as each '- 'other and a thumb or more, scrolling sideways on a narrow phone', (- tester,- ) async {- final agents = _Agents(1);- addTearDown(agents.dispose);- await pump(tester, [- away(),- SwarmAgentsTile(agents: agents, onTap: () {}),- ], width: 280);-- expect(tester.takeException(), isNull, reason: 'no overflow');- final first = tester.getRect(key('swarm-away'));- final second = tester.getRect(key('swarm-agents-tile'));- expect(first.left, lessThan(second.left));- expect(first.width, greaterThan(second.width));- expect(first.height, second.height);- expect(first.height, greaterThanOrEqualTo(44));- expect(second.right, greaterThan(280), reason: 'past the edge, to scroll');-- await tester.drag(key('swarm-home-tiles'), const Offset(-200, 0));- await tester.pumpAndSettle();-- expect(- tester.getRect(key('swarm-agents-tile')).right,- lessThanOrEqualTo(280),- reason: 'scrolled into sight',- );- });-}diff --git a/mobile/test/swarm/swarm_home_view_shots_test.dart b/mobile/test/swarm/swarm_home_view_shots_test.dartindex e9b7c8188..477584465 100644--- a/mobile/test/swarm/swarm_home_view_shots_test.dart+++ b/mobile/test/swarm/swarm_home_view_shots_test.dart@@ -163,7 +163,9 @@ void main() {await tester.pumpAndSettle();}- await tap('swarm-home-view');+ await tap('swarm-title-button');+ await capture('switcher');+ await tap('swarm-switch-view');await capture('menu');await tap('swarm-view-sort');await tap('swarm-view-unreads-true');diff --git a/mobile/test/swarm/swarm_home_view_test.dart b/mobile/test/swarm/swarm_home_view_test.dartindex 9b243177f..81464c205 100644--- a/mobile/test/swarm/swarm_home_view_test.dart+++ b/mobile/test/swarm/swarm_home_view_test.dart@@ -8,7 +8,6 @@ import 'package:lucide_icons_flutter/lucide_icons.dart';import 'package:harness_mobile/notify/system_notices.dart';import 'package:harness_mobile/settings/experimental_features.dart';-import 'package:harness_mobile/shared/widgets/skeleton.dart';import 'package:harness_mobile/swarm/model.dart';import 'package:harness_mobile/swarm/swarm_home_list.dart';import 'package:harness_mobile/swarm/swarm_home_prefs.dart';@@ -431,9 +430,18 @@ void main() {Finder key(String value) => find.byKey(ValueKey(value));Finder project_(String id) => key('swarm-project-$tab-$id');- Finder dot() => key('swarm-icon-dot');+ Finder inside(Finder of, Finder matching) =>+ find.descendant(of: of, matching: matching);++ /// Home saying a filter is on, where the filter icon's dot was.+ Finder dot() => key('swarm-filter-on');++ /// Sort and filter, from the Swarm switcher in Home's title (anh Dee,+ /// 2026-11-04: no filter icon on Home).Future<void> open(WidgetTester tester) async {- await tester.tap(key('swarm-home-view'));+ await tester.tap(key('swarm-title-button'));+ await tester.pumpAndSettle();+ await tester.tap(key('swarm-switch-view'));await tester.pumpAndSettle();}@@ -485,42 +493,52 @@ void main() {expect(key('swarm-view-sort-sections'), findsNothing);});- testWidgets('the icon has a dot, and says in words what is on, only with '- 'something other than the defaults', (tester) async {+ testWidgets("the switcher's Sort and filter has a dot, and says in words "+ 'what is on, only with something other than the defaults', (+ tester,+ ) async {final handle = tester.ensureSemantics();final host = await pump(tester, backend());- expect(dot(), findsNothing);+ Future<void> switcher() async {+ await tester.tap(key('swarm-title-button'));+ await tester.pumpAndSettle();+ }++ Finder rowDot() => key('swarm-switch-view-dot');++ await switcher();+ expect(rowDot(), findsNothing);expect(- tester.widget<SwarmIconButton>(key('swarm-home-view')).label,- 'Sort and filter: Sections, All projects',+ find.bySemanticsLabel(+ RegExp(r'^Sort and filter: Sections, All projects$'),+ ),+ findsOneWidget,);- await open(tester);+ await close(tester);- for (final (openRow, on, off) in [- (- 'swarm-view-sort',- 'swarm-view-sort-newest',- 'swarm-view-sort-sections',- ),- (- 'swarm-view-sort',- 'swarm-view-unreads-true',- 'swarm-view-unreads-false',- ),- (- 'swarm-view-filter',- 'swarm-view-filter-unread',- 'swarm-view-filter-all',- ),+ for (final change in <void Function()>[+ () => host.session!.home.setSort(SwarmHomeSort.newest),+ () => host.session!.home.setUnreadsFirst(true),+ () => host.session!.home.setFilter(SwarmHomeFilter.unread),]) {- await tapRow(tester, openRow);- await tapRow(tester, on);- expect(dot(), findsOneWidget, reason: on);- await tapRow(tester, off);- expect(dot(), findsNothing, reason: off);- await tapRow(tester, openRow);+ change();+ await tester.pumpAndSettle();+ await switcher();+ expect(rowDot(), findsOneWidget);+ await close(tester);+ host.session!.home+ ..setSort(SwarmHomeSort.sections)+ ..setUnreadsFirst(false)+ ..setFilter(SwarmHomeFilter.all);+ await tester.pumpAndSettle();}- expect(host.session!.home.viewChanged, isFalse);+ host.session!.home.setFilter(SwarmHomeFilter.unread);+ await tester.pumpAndSettle();+ await switcher();+ expect(+ find.bySemanticsLabel(RegExp(r'^Sort and filter: Sections, Unread$')),+ findsOneWidget,+ );handle.dispose();});@@ -568,6 +586,11 @@ void main() {await close(tester);expect(project_(project), findsOneWidget);expect(project_(web), findsNothing);+ expect(+ inside(key('swarm-filter-on'), find.text('Unread only')),+ findsOneWidget,+ reason: 'with no filter icon on Home, the list says a filter is on',+ );// Mark all read, in the same sheet (2026-11-03).await open(tester);@@ -581,51 +604,37 @@ void main() {await tester.pumpAndSettle();expect(project_(web), findsOneWidget);expect(host.session!.home.filter, SwarmHomeFilter.all);- expect(dot(), findsNothing);+ expect(key('swarm-filter-on'), findsNothing);await tester.pump(const Duration(seconds: 7));});- /// The caption Sort and filter is at the right of.- Finder captionOf(Finder button) =>- find.ancestor(of: button, matching: find.byType(SwarmCaption));+ testWidgets('Home has no Projects caption and no filter icon (anh Dee, '+ "2026-11-04); the switcher's Sort and filter, under the Swarms, opens "+ 'the sheet: its options, then Mark all read, then Refresh', (+ tester,+ ) async {+ final host = await pump(tester, backend());+ host.session!.home.pin(tab, project, true);+ await tester.pumpAndSettle();+ expect(key('swarm-home-view'), findsNothing);+ expect(find.text('Projects'), findsNothing);+ expect(find.text('Pinned'), findsNothing);+ expect(key('swarm-mark-all-read'), findsNothing);- testWidgets('Sort and filter is at the right of the Projects caption, '- 'not on the top bar (Tony, 2026-11-03); no Mark all read: that is in '- 'the sheet, under its options, with Refresh', (tester) async {- await pump(tester, backend());- final view = key('swarm-home-view');- expect(- key('swarm-mark-all-read'),- findsNothing,- reason: 'not on the screen',- );- expect(tester.widget<SwarmCaption>(captionOf(view)).text, 'Projects');- expect(- tester.getTopLeft(view).dy,- greaterThanOrEqualTo(tester.getBottomLeft(key('swarm-you-button')).dy),- reason: 'under the top bar',- );- final card = find- .ancestor(of: project_(project), matching: find.byType(SwarmGroup))- .first;- expect(- tester.getTopRight(view).dx,- closeTo(tester.getTopRight(card).dx, .01),- reason: "its target's end on the card's",- );+ await tester.tap(key('swarm-title-button'));+ await tester.pumpAndSettle();expect(- tester.getBottomLeft(view).dy,- lessThanOrEqualTo(tester.getTopLeft(card).dy),- reason: 'over the card',+ tester.getTopLeft(key('swarm-switch-$tab')).dy,+ lessThan(tester.getTopLeft(key('swarm-switch-view')).dy),);expect(- tester.getCenter(find.text('Projects')).dy,- closeTo(tester.getCenter(view).dy, 1),- reason: 'on the words',+ tester.getSize(key('swarm-switch-view')).height,+ greaterThanOrEqualTo(44),);+ await tester.tap(key('swarm-switch-view'));+ await tester.pumpAndSettle();- await open(tester);-+ expect(key('swarm-switch-$tab'), findsNothing, reason: 'it closed');expect(key('swarm-mark-all-read'), findsOneWidget);expect(key('swarm-home-refresh'), findsOneWidget);expect(@@ -638,20 +647,6 @@ void main() {);});- testWidgets('with a project pinned, Sort and filter is on the Pinned '- 'caption, the first: once, over every project it sorts', (- tester,- ) async {- final host = await pump(tester, backend());- host.session!.home.pin(tab, project, true);- await tester.pumpAndSettle();-- final view = key('swarm-home-view');- expect(view, findsOneWidget);- expect(tester.widget<SwarmCaption>(captionOf(view)).text, 'Pinned');- expect(find.text('Projects'), findsOneWidget, reason: 'web is unpinned');- });-testWidgets('Mark all read in the sheet closes it and marks, with its ''Undo; with nothing unread it is greyed and heard as off', (tester,@@ -770,25 +765,27 @@ void main() {);final store = MemoryKeyValueStore()..values['swarm_home.$me'] = jsonEncode({'filter': 'mentions'});- // While you were away keeps what needs the person a skeleton while the- // read is retried, so the screen never settles until it answers.+ // The mentions' skeleton breathes while the read is retried, so the+ // screen never settles until it answers.final host = await pump(tester, fake, store: store, settle: false);await tester.pump(const Duration(milliseconds: 100));expect(find.text('Mentions could not be read.'), findsOneWidget);expect(find.text('No mentions.'), findsNothing);expect(key('swarm-filter-show-all'), findsOneWidget);- Finder needs(Finder matching) =>- find.descendant(of: key('swarm-away-needs'), matching: matching);- expect(needs(find.byType(SkeletonText)), findsOneWidget);- expect(needs(find.text('0')), findsNothing);+ expect(find.textContaining('0 need you'), findsNothing);fail = false;await host.session!.inbox.asks(tab)!.load();await tester.pumpAndSettle();expect(project_(web), findsOneWidget);expect(find.text('Mentions could not be read.'), findsNothing);- expect(needs(find.byType(SkeletonText)), findsNothing);- expect(needs(find.text('1')), findsOneWidget);+ expect(+ find.descendant(+ of: key('swarm-need-line'),+ matching: find.textContaining('1 need you'),+ ),+ findsOneWidget,+ );});/// [fake] with a second Swarm, whose mentions [read] answers.diff --git a/mobile/test/swarm/swarm_mark_all_test.dart b/mobile/test/swarm/swarm_mark_all_test.dartindex 7b5e675bb..600482eba 100644--- a/mobile/test/swarm/swarm_mark_all_test.dart+++ b/mobile/test/swarm/swarm_mark_all_test.dart@@ -485,11 +485,14 @@ void main() {bool bold(WidgetTester tester, String projectId) =>tester.widget<SwarmHomeProjectRow>(row(projectId)).project.news.bold;- /// Opens Sort and filter, where Mark all read is (2026-11-03).+ /// Opens Sort and filter, where Mark all read is (2026-11-03), from the+ /// Swarm switcher (2026-11-04).Future<void> openView(WidgetTester tester) async {- await tester.tap(key('swarm-home-view'));- await tester.pump();- await tester.pump(const Duration(milliseconds: 400));+ for (final k in ['swarm-title-button', 'swarm-switch-view']) {+ await tester.tap(key(k));+ await tester.pump();+ await tester.pump(const Duration(milliseconds: 400));+ }}/// Mark all read, from Sort and filter: the sheet closes, then it marks.diff --git a/mobile/test/swarm/swarm_new_message_shots_test.dart b/mobile/test/swarm/swarm_new_message_shots_test.dartindex 28d12fb73..f7fed567e 100644--- a/mobile/test/swarm/swarm_new_message_shots_test.dart+++ b/mobile/test/swarm/swarm_new_message_shots_test.dart@@ -18,7 +18,7 @@ import '../voice_fakes.dart';import 'swarm_fixture.dart';/// Review screenshots of New message (Tony, 10-30: as Slack Mobile starts-/// one): Home with its floating +, the sheet it opens, narrowed by To:, a+/// one): Home with its + in the top bar, the sheet it opens, narrowed by To:, a/// chat picked with a message typed, and a send refused — in both phone/// themes, 390 points wide and on a small phone, 320, from made-up Swarm/// data only, to the folder `SWARM_NEW_MESSAGE_SHOTS` names. On the smalldiff --git a/mobile/test/swarm/swarm_new_message_test.dart b/mobile/test/swarm/swarm_new_message_test.dartindex fd51e592e..53693463b 100644--- a/mobile/test/swarm/swarm_new_message_test.dart+++ b/mobile/test/swarm/swarm_new_message_test.dart@@ -4,7 +4,7 @@ import 'dart:typed_data';import 'package:flutter/cupertino.dart' show CupertinoPageRoute;import 'package:flutter/foundation.dart' show ValueListenable;import 'package:flutter/material.dart';-import 'package:flutter/rendering.dart' show RenderSliverMultiBoxAdaptor;+import 'package:flutter_test/flutter_test.dart';import 'package:image_picker/image_picker.dart' show XFile;@@ -12,7 +12,6 @@ import 'package:harness_mobile/notify/system_notices.dart';import 'package:harness_mobile/phone/out_of_sight.dart';import 'package:harness_mobile/phone/voice_recorder.dart';import 'package:harness_mobile/settings/experimental_features.dart';-import 'package:harness_mobile/shared/theme/app_theme.dart' show AppPalette;import 'package:harness_mobile/swarm/swarm_conversation_page.dart';import 'package:harness_mobile/swarm/swarm_file_picker.dart';import 'package:harness_mobile/swarm/swarm_new_message_sheet.dart';@@ -20,6 +19,7 @@ import 'package:harness_mobile/swarm/swarm_page.dart';import 'package:harness_mobile/swarm/swarm_project_page.dart';import 'package:harness_mobile/swarm/swarm_request.dart';import 'package:harness_mobile/swarm/swarm_session.dart';+import 'package:harness_mobile/swarm/swarm_style.dart' show SwarmIconButton;import '../voice_fakes.dart';import 'swarm_fixture.dart';@@ -295,71 +295,40 @@ void main() {bool sheetOpen() => find.byType(SwarmNewMessageSheet).evaluate().isNotEmpty;group('Home', () {- testWidgets('has no compose in its header; the + floats at its bottom '- 'right, 56 points round, in the accent, said as New message', (- tester,- ) async {+ testWidgets('the + is in the header, between Search and You, a thumb '+ 'wide, said as New message; nothing floats over the list (anh Dee, '+ '2026-11-04)', (tester) async {await pump(tester, backend());expect(key('swarm-compose'), findsNothing);- expect(tester.getSize(key('swarm-new-message')), const Size(56, 56));- final corner = tester.getBottomRight(key('swarm-new-message'));- expect(corner.dx, closeTo(390 - 16, 0.5), reason: '16 in from the side');- expect(corner.dy, closeTo(844 - 16, 0.5), reason: '16 up from the foot');expect(tester- .widget<Material>(- inside(key('swarm-new-message'), find.byType(Material)),- )- .color,- AppPalette.accent,+ .widget<Scaffold>(find.byType(Scaffold).first)+ .floatingActionButton,+ isNull,);- expect(find.bySemanticsLabel('New message'), findsOneWidget);- });-- testWidgets("the + clears Home's last row once scrolled to the end", (- tester,- ) async {- final fake = backend();- // More projects than a screen holds.- serve(- fake,- projects: [- ...readable,- for (var i = 0; i < 16; i++)- projectRow('p-$i', 'Project $i', 'lead-p-$i'),- ],- );- await pump(tester, fake);- await tester.drag(find.byType(ListView).first, const Offset(0, -2000));- await tester.pumpAndSettle();-- final position = tester- .state<ScrollableState>(find.byType(Scrollable).first)- .position;- expect(position.pixels, position.maxScrollExtent, reason: 'at its end');- // Home's last row, whatever it is: it ends above the +.- final list = tester.renderObject<RenderSliverMultiBoxAdaptor>(- find.descendant(- of: find.byType(ListView).first,- matching: find.byType(SliverList),- ),- );- final last = list.lastChild!;+ final plus = tester.getRect(key('swarm-new-message'));+ final search = tester.getRect(key('swarm-home-search'));+ final you = tester.getRect(key('swarm-you-button'));+ expect(plus.width, greaterThanOrEqualTo(44));+ expect(plus.height, greaterThanOrEqualTo(44));+ expect(plus.center.dy, closeTo(search.center.dy, 0.5), reason: 'one row');+ expect(plus.left, greaterThanOrEqualTo(search.right), reason: 'after');+ expect(plus.right, lessThanOrEqualTo(you.left), reason: 'before You');expect(- last.localToGlobal(Offset(0, last.size.height)).dy,- lessThan(tester.getTopLeft(key('swarm-new-message')).dy),+ plus.bottom,+ lessThanOrEqualTo(tester.getTopLeft(key('swarm-home-list')).dy),+ reason: 'over the list, not on it',);+ expect(find.bySemanticsLabel('New message'), findsOneWidget);});testWidgets('a second tap on + before New message is up opens no second ''sheet', (tester) async {await pump(tester, backend());- final plus = tester.widget<SwarmNewMessageButton>(- key('swarm-new-message'),- );- plus.onPressed();- plus.onPressed();+ final plus = tester.widget<SwarmIconButton>(key('swarm-new-message'));+ plus.onPressed!();+ plus.onPressed!();await tester.pumpAndSettle();expect(find.byType(SwarmNewMessageSheet), findsOneWidget);diff --git a/mobile/test/swarm/swarm_new_project_shots_test.dart b/mobile/test/swarm/swarm_new_project_shots_test.dartindex 86b1ea79b..c761b2463 100644--- a/mobile/test/swarm/swarm_new_project_shots_test.dart+++ b/mobile/test/swarm/swarm_new_project_shots_test.dart@@ -175,13 +175,12 @@ void main() {await tester.pumpAndSettle();}- // Home: + New project, the last of Projects.- await tester.ensureVisible(key('swarm-new-project'));- await tester.pumpAndSettle();+ // The Swarm switcher, with New project before Join or create.+ await tap('swarm-title-button');await capture('home');// The sheet, its brief written and its machine picked.- await tap('swarm-new-project');+ await tap('swarm-switch-new-project');await tester.enterText(key('swarm-new-project-brief'),'Let people start a project from the phone, with its Product '@@ -307,7 +306,8 @@ void main() {];await host.session!.inbox.reader(tab)!.refresh();await tester.pumpAndSettle();- await tap('swarm-new-project');+ await tap('swarm-title-button');+ await tap('swarm-switch-new-project');await tap('swarm-new-project-machine');await capture('none');@@ -397,7 +397,8 @@ void main() {// Home shows the paused Swarm alone, as Dee's did.host.session!.home.show(tab);await tester.pumpAndSettle();- await tap('swarm-new-project');+ await tap('swarm-title-button');+ await tap('swarm-switch-new-project');await tap('swarm-new-project-machine');await tap('swarm-new-project-pick-machine-mac-studio');await capture('paused-default');diff --git a/mobile/test/swarm/swarm_new_project_test.dart b/mobile/test/swarm/swarm_new_project_test.dartindex 16952327b..47fc37dab 100644--- a/mobile/test/swarm/swarm_new_project_test.dart+++ b/mobile/test/swarm/swarm_new_project_test.dart@@ -1183,6 +1183,33 @@ void main() {}}+ /// New project, from the Swarm switcher in Home's title (River,+ /// 2026-11-04: Home keeps one +, New message's).+ Future<void> openNewProject(+ WidgetTester tester, {+ bool settle = true,+ }) async {+ Future<void> step() => settle ? tester.pumpAndSettle() : pumpFor(tester);+ await tester.tap(key('swarm-title-button'));+ await step();+ await tester.tap(key('swarm-switch-new-project'));+ await step();+ }++ /// Whether the switcher offers New project; it is closed again after.+ Future<bool> offersNewProject(+ WidgetTester tester, {+ bool settle = true,+ }) async {+ Future<void> step() => settle ? tester.pumpAndSettle() : pumpFor(tester);+ await tester.tap(key('swarm-title-button'));+ await step();+ final offered = key('swarm-switch-new-project').evaluate().isNotEmpty;+ await tester.tapAt(const Offset(195, 40));+ await step();+ return offered;+ }+/// [text] on the Agent row.Finder onAgent(String text) => find.descendant(of: key('swarm-new-project-agent'),@@ -1212,32 +1239,44 @@ void main() {swarmPickerCopyFolders = picker.copies;});- testWidgets('+ New project is the last row of Projects for someone who '- 'may write in the Swarm', (tester) async {+ testWidgets('New project is in the Swarm switcher, just before Join or '+ 'create a Swarm, for someone who may write in the Swarm; Home has no '+ 'row for it, its one + being New message (River, 2026-11-04)', (+ tester,+ ) async {await pump(tester, [NewProjectSwarm()]);- expect(key('swarm-new-project'), findsOneWidget);- expect(find.text('New project'), findsOneWidget);- final rows = [- key('swarm-project-$tab-$project'),- key('swarm-project-$tab-project-2'),- ];- for (final row in rows) {- expect(- tester.getTopLeft(row).dy,- lessThan(tester.getTopLeft(key('swarm-new-project')).dy),- );- }+ expect(key('swarm-project-$tab-$project'), findsOneWidget);+ expect(key('swarm-new-project'), findsNothing);+ expect(find.text('New project'), findsNothing);++ await tester.tap(key('swarm-title-button'));+ await tester.pumpAndSettle();+ final row = key('swarm-switch-new-project');+ expect(+ find.descendant(of: row, matching: find.text('New project')),+ findsOneWidget,+ );+ expect(+ tester.getTopLeft(row).dy,+ lessThan(tester.getTopLeft(key('swarm-switch-join')).dy),+ );+ expect(tester.getSize(row).height, greaterThanOrEqualTo(44));++ await tester.tap(row);+ await tester.pumpAndSettle();+ expect(key('swarm-switch-join'), findsNothing, reason: 'it closed');+ expect(key('swarm-new-project-sheet'), findsOneWidget);});testWidgets('a collaborator has it; a viewer does not', (tester) async {await pump(tester, [NewProjectSwarm(role: 'collaborator')]);- expect(key('swarm-new-project'), findsOneWidget);+ expect(await offersNewProject(tester), isTrue);});- testWidgets('a viewer has no + New project', (tester) async {+ testWidgets('a viewer has no New project', (tester) async {await pump(tester, [NewProjectSwarm(role: 'viewer')]);expect(key('swarm-project-$tab-$project'), findsOneWidget);- expect(key('swarm-new-project'), findsNothing);+ expect(await offersNewProject(tester), isFalse);});testWidgets('a Swarm whose first read failed offers it once its read '@@ -1247,13 +1286,13 @@ void main() {// A skeleton breathes for as long as it shows: nothing settles under it.await pumpFor(tester);expect(key('swarm-projects-loading-$tab'), findsOneWidget);- expect(key('swarm-new-project'), findsNothing);+ expect(await offersNewProject(tester, settle: false), isFalse);swarm.unreadable = false;await host.session!.inbox.reader(tab)!.refresh();await tester.pumpAndSettle();- expect(key('swarm-new-project'), findsOneWidget);- await tap(tester, 'swarm-new-project');+ expect(await offersNewProject(tester), isTrue);+ await openNewProject(tester);expect(key('swarm-new-project-sheet'), findsOneWidget);});@@ -1264,7 +1303,7 @@ void main() {NewProjectSwarm(id: 'tab-viewed', name: 'Viewed', role: 'viewer'),NewProjectSwarm(id: 'tab-2', name: 'Lamp Swarm', role: 'collaborator'),]);- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);expect(key('swarm-new-project-sheet'), findsOneWidget);expect(key('swarm-new-project-swarm'), findsOneWidget);await tap(tester, 'swarm-new-project-swarm');@@ -1282,7 +1321,7 @@ void main() {testWidgets('one Swarm shown: no Swarm row', (tester) async {await pump(tester, [NewProjectSwarm()]);- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);expect(key('swarm-new-project-swarm'), findsNothing);});@@ -1332,7 +1371,7 @@ void main() {NewProjectSwarm(),NewProjectSwarm(id: 'tab-2', name: 'Lamp Swarm'),]);- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);opensOn('Phone Swarm');expect(note(tester), isNot(contains(swarmLeadSwarmPaused)));await tap(tester, 'swarm-new-project-swarm');@@ -1347,7 +1386,7 @@ void main() {NewProjectSwarm(name: 'Swarm review verification')..paused = true,NewProjectSwarm(id: 'tab-2', name: 'Lamp Swarm'),]);- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);opensOn('Lamp Swarm');expect(note(tester), isNot(contains(swarmLeadSwarmPaused)));await pickMachine(tester, 'mac-1');@@ -1384,7 +1423,7 @@ void main() {]);host.session!.home.show(tab);await tester.pumpAndSettle();- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);opensOn('Lamp Swarm');await tap(tester, 'swarm-new-project-swarm');expect(listed(tester, [tab, 'tab-2', 'tab-viewed']), ['tab-2', tab]);@@ -1406,7 +1445,7 @@ void main() {]);host.session!.home.show('tab-2');await tester.pumpAndSettle();- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);opensOn('Lamp Swarm');});@@ -1418,7 +1457,7 @@ void main() {]);host.session!.home.show('tab-2');await tester.pumpAndSettle();- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);opensOn('Lamp Swarm');expect(note(tester), contains(swarmLeadSwarmPaused));expect(@@ -1437,7 +1476,7 @@ void main() {final host = await pump(tester, [NewProjectSwarm(), lamp]);host.session!.home.show('tab-2');await tester.pumpAndSettle();- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);await pickMachine(tester, 'mac-1');lamp.paused = true;await host.session!.inbox.reader('tab-2')!.refresh();@@ -1465,7 +1504,7 @@ void main() {]);host.session!.home.show(tab);await tester.pumpAndSettle();- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);opensOn('Lamp Swarm');lamp.revoked = true;await host.session!.inbox.reader('tab-2')!.refresh();@@ -1486,7 +1525,7 @@ void main() {await pump(tester, [NewProjectSwarm(projects: [swarmProject(project, 'Mobile')]),]);- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);expect(hint(), findsOneWidget);await tap(tester, 'swarm-new-project-repository');await tap(tester, 'swarm-new-project-pick-link');@@ -1502,7 +1541,7 @@ void main() {tester,) async {await pump(tester, [NewProjectSwarm()]);- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);expect(find.descendant(of: key('swarm-new-project-repository'),@@ -1516,7 +1555,7 @@ void main() {'others and a link a tap away; a link the server would refuse is ''not taken', (tester) async {await pump(tester, [NewProjectSwarm()]);- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);expect(find.descendant(of: key('swarm-new-project-repository'),@@ -1555,7 +1594,7 @@ void main() {],);final host = await pump(tester, [swarm]);- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);expect(find.text(swarmLeadChooseMachine), findsOneWidget);await tap(tester, 'swarm-new-project-machine');expect(key('swarm-new-project-pick-machine-mac-1'), findsOneWidget);@@ -1601,7 +1640,7 @@ void main() {'machine picked and opens its project screen', (tester) async {final swarm = NewProjectSwarm();await pump(tester, [swarm]);- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);await tester.enterText(key('swarm-new-project-brief'),'Phone New project',@@ -1638,7 +1677,7 @@ void main() {return null;};await pump(tester, [swarm]);- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);await pickMachine(tester, 'mac-1');await tap(tester, 'swarm-new-project-create');@@ -1672,7 +1711,7 @@ void main() {return null;};await pump(tester, [swarm]);- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);await pickMachine(tester, 'mac-1');await tap(tester, 'swarm-new-project-create');expect(key('swarm-new-project-error'), findsOneWidget);@@ -1702,7 +1741,7 @@ void main() {return null;};final host = await pump(tester, [swarm]);- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);await pickMachine(tester, 'mac-1');await tap(tester, 'swarm-new-project-create');await host.session!.inbox.reader(tab)!.refresh();@@ -1731,7 +1770,7 @@ void main() {swarm.answer = (command) =>command['type'] == 'project.create' ? held.future : null;await pump(tester, [swarm]);- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);await pickMachine(tester, 'mac-1');await tester.tap(key('swarm-new-project-create'));await pumpFor(tester);@@ -1777,7 +1816,7 @@ void main() {return null;};await pump(tester, [swarm]);- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);await tester.enterText(key('swarm-new-project-brief'), 'Ship it');await tap(tester, 'swarm-new-project-visibility');await tap(tester, 'swarm-new-project-pick-visibility-private');@@ -1787,7 +1826,7 @@ void main() {await tap(tester, 'swarm-new-project-close');expect(key('swarm-new-project-sheet'), findsNothing);- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);expect(find.text('Couldn’t create the project: The Swarm didn’t answer.'),findsOneWidget,@@ -1838,13 +1877,13 @@ void main() {): null;await pump(tester, [swarm]);- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);await pickMachine(tester, 'mac-1');await tap(tester, 'swarm-new-project-create');expect(key('swarm-new-project-error'), findsOneWidget);await tap(tester, 'swarm-new-project-close');- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);expect(key('swarm-new-project-error'), findsNothing);expect(find.text('Create'), findsOneWidget);expect(@@ -1874,7 +1913,7 @@ void main() {return null;};await pump(tester, [swarm]);- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);await tester.enterText(key('swarm-new-project-brief'), 'Ship it');await pickMachine(tester, 'mac-1');await tap(tester, 'swarm-new-project-create');@@ -1908,7 +1947,7 @@ void main() {return null;};await pump(tester, [swarm]);- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);await tester.enterText(key('swarm-new-project-brief'), 'Ship it');await pickMachine(tester, 'mac-1');expect(key('swarm-new-project-start-over'), findsNothing);@@ -1941,12 +1980,12 @@ void main() {? throw const SuperTabFailure('NETWORK', 'The Swarm didn’t answer.'): null;await pump(tester, [swarm]);- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);await pickMachine(tester, 'mac-1');await tap(tester, 'swarm-new-project-create');await tap(tester, 'swarm-new-project-close');// Opened again on the steps: they still know, the sheet did not see it.- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);await tap(tester, 'swarm-new-project-start-over');expect(key('swarm-new-project-maybe-made'), findsOneWidget);@@ -1962,7 +2001,7 @@ void main() {? throw const SuperTabFailure('NETWORK', 'The Swarm didn’t answer.'): null;await pump(tester, [swarm]);- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);await tester.enterText(key('swarm-new-project-brief'), 'Ship it');await pickMachine(tester, 'mac-1');await tap(tester, 'swarm-new-project-create');@@ -1982,7 +2021,7 @@ void main() {swarm,NewProjectSwarm(id: 'tab-2', name: 'Lamp Swarm', role: 'collaborator'),]);- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);await pickMachine(tester, 'mac-1');await tap(tester, 'swarm-new-project-create');await tap(tester, 'swarm-new-project-start-over');@@ -2000,7 +2039,7 @@ void main() {swarm.answer = (command) =>command['type'] == 'message.send' ? held.future : null;await pump(tester, [swarm]);- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);await tester.enterText(key('swarm-new-project-brief'), 'Ship it');await pickMachine(tester, 'mac-1');await tester.tap(key('swarm-new-project-create'));@@ -2013,8 +2052,7 @@ void main() {await pumpFor(tester);expect(key('swarm-new-project-sheet'), findsNothing);- await tester.tap(key('swarm-new-project'));- await pumpFor(tester);+ await openNewProject(tester, settle: false);expect(find.text('Creating…'), findsOneWidget, reason: 'still waiting');expect(key('swarm-new-project-start-over'), findsNothing);held.complete(null);@@ -2045,7 +2083,7 @@ void main() {tester.view.physicalSize = const Size(960, 1704);tester.view.padding = const FakeViewPadding(top: 60);await tester.pumpAndSettle();- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);await pickMachine(tester, 'mac-1');await tap(tester, 'swarm-new-project-create');final error = key('swarm-new-project-error');@@ -2118,7 +2156,7 @@ void main() {final swarm = NewProjectSwarm();final swarms = [swarm];final host = await pump(tester, swarms);- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);await pickMachine(tester, 'mac-1');final inbox = host.session!.inbox;final before = inbox.reader(tab);@@ -2131,7 +2169,7 @@ void main() {expect(swarmMayCreateProject(inbox, tab), isTrue);await tester.pumpAndSettle();expect(find.byType(BottomSheet), findsNothing);- expect(key('swarm-new-project'), findsOneWidget, reason: 'listed again');+ expect(await offersNewProject(tester), isTrue, reason: 'listed again');expect(swarm.sent, isEmpty);});@@ -2144,7 +2182,7 @@ void main() {swarm.answer = (command) =>command['type'] == 'project.create' ? held.future : null;final host = await pump(tester, swarms);- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);await tester.enterText(key('swarm-new-project-brief'), 'Ship it');await pickMachine(tester, 'mac-1');await tester.tap(key('swarm-new-project-create'));@@ -2166,7 +2204,7 @@ void main() {);expect(SwarmNewProjectSteps.heldBy(inbox.reader(tab)!), isNull);- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);expect(key('swarm-new-project-error'), findsNothing);expect(tester@@ -2181,7 +2219,7 @@ void main() {'once', (tester) async {final swarm = NewProjectSwarm();final host = await pump(tester, [swarm]);- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);expect(key('swarm-new-project-sheet'), findsOneWidget);swarm.revoked = true;await host.session!.inbox.reader(tab)!.refresh();@@ -2195,18 +2233,18 @@ void main() {testWidgets('made a viewer while it is open closes it', (tester) async {final swarm = NewProjectSwarm();final host = await pump(tester, [swarm]);- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);swarm.role = 'viewer';await host.session!.inbox.reader(tab)!.refresh();await tester.pumpAndSettle();expect(find.byType(BottomSheet), findsNothing);- expect(key('swarm-new-project'), findsNothing);+ expect(await offersNewProject(tester), isFalse);});testWidgets('signing out while it is open closes it', (tester) async {final account = ValueNotifier<String?>(me);await pump(tester, [NewProjectSwarm()], account: account);- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);account.value = null;await tester.pumpAndSettle();expect(find.byType(BottomSheet), findsNothing);@@ -2220,7 +2258,7 @@ void main() {swarm.answer = (command) =>command['type'] == 'project.create' ? held.future : null;final host = await pump(tester, [swarm]);- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);// A brief: the next step would post it.await tester.enterText(key('swarm-new-project-brief'), 'Ship it');await pickMachine(tester, 'mac-1');@@ -2247,7 +2285,7 @@ void main() {'left alone, Create starts it as before', (tester) async {final swarm = NewProjectSwarm();await pump(tester, [swarm]);- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);expect(onAgent('Claude Code'), findsOneWidget);expect(onAgent('Opus 5.5 · xhigh'), findsOneWidget);await pickMachine(tester, 'mac-1');@@ -2283,7 +2321,7 @@ void main() {],);await pump(tester, [swarm]);- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);await tap(tester, 'swarm-new-project-agent');expect(find.descendant(@@ -2345,7 +2383,7 @@ void main() {'Create off and says to choose another engine', (tester) async {final swarm = NewProjectSwarm();final host = await pump(tester, [swarm]);- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);await pickMachine(tester, 'mac-1');await tap(tester, 'swarm-new-project-agent');await tap(tester, 'swarm-new-project-pick-agent-codex');@@ -2388,7 +2426,7 @@ void main() {],};await pump(tester, [swarm]);- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);expect(onAgent('Claude Code'), findsOneWidget);expect(onAgent('Default model'), findsOneWidget);});@@ -2403,7 +2441,7 @@ void main() {],};await pump(tester, [swarm]);- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);expect(onAgent('Codex'), findsOneWidget);await tap(tester, 'swarm-new-project-agent');expect(@@ -2422,7 +2460,7 @@ void main() {) async {final account = ValueNotifier<String?>(me);await pump(tester, [NewProjectSwarm()], account: account);- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);await tap(tester, 'swarm-new-project-attach');expect(key('swarm-attach-files'), findsOneWidget);account.value = null;@@ -2439,7 +2477,7 @@ void main() {final swarm = NewProjectSwarm();picks(['spec.pdf']);await pump(tester, [swarm], upload: uploads.upload);- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);await attachFiles(tester);expect(key('swarm-outgoing-spec.pdf'), findsOneWidget);await pickMachine(tester, 'mac-1');@@ -2459,7 +2497,7 @@ void main() {) async {picks([for (var i = 1; i <= 11; i++) 'f$i.log']);await pump(tester, [NewProjectSwarm()], upload: FakeUploads().upload);- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);await attachFiles(tester);expect(tester.widget<Text>(key('swarm-new-project-attach-note')).data,@@ -2489,7 +2527,7 @@ void main() {};picks(['build.log']);await pump(tester, [swarm], upload: uploads.upload);- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);await attachFiles(tester);await tap(tester, 'swarm-new-project-agent');await tap(tester, 'swarm-new-project-pick-agent-codex');@@ -2499,7 +2537,7 @@ void main() {await tap(tester, 'swarm-new-project-close');expect(key('swarm-new-project-sheet'), findsNothing);- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);expect(key('swarm-outgoing-build.log'), findsOneWidget);expect(onAgent('Codex'), findsOneWidget);expect(@@ -2542,7 +2580,7 @@ void main() {: null;picks(['build.log']);await pump(tester, [swarm], upload: uploads.upload);- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);await attachFiles(tester);await pickMachine(tester, 'mac-1');await tap(tester, 'swarm-new-project-create');@@ -2579,7 +2617,7 @@ void main() {tester.view.physicalSize = const Size(960, 1704);tester.view.padding = const FakeViewPadding(top: 60);await tester.pumpAndSettle();- await tap(tester, 'swarm-new-project');+ await openNewProject(tester);await attachFiles(tester);await pickMachine(tester, 'mac-1');await tap(tester, 'swarm-new-project-brief');diff --git a/mobile/test/swarm/swarm_project_settings_test.dart b/mobile/test/swarm/swarm_project_settings_test.dartindex 77624fba7..ffa800341 100644--- a/mobile/test/swarm/swarm_project_settings_test.dart+++ b/mobile/test/swarm/swarm_project_settings_test.dart@@ -991,7 +991,6 @@ void main() {WidgetTester tester, {required String visibility,String name = 'Mobile',- String? swarmName,SwarmProjectNews news = swarmNoProjectNews,double width = 390,}) {@@ -1027,7 +1026,6 @@ void main() {project: snapshot.projects.single,news: news,),- swarmName: swarmName,onTap: () {},),),@@ -1085,13 +1083,12 @@ void main() {expect(tester.getTopRight(tags).dx, 390 - AppSpace.l);});- testWidgets('a long name and its Swarm ellipsize and keep the lock in '+ testWidgets('a long name ellipsizes and keeps the lock in ''sight', (tester) async {await row(tester,visibility: 'private',name: 'A project with a name far too long for one row of a phone',- swarmName: 'Phone Swarm',width: 240,);expect(tester.takeException(), isNull);diff --git a/mobile/test/swarm/swarm_screens_test.dart b/mobile/test/swarm/swarm_screens_test.dartindex 91a81cc1e..a55179144 100644--- a/mobile/test/swarm/swarm_screens_test.dart+++ b/mobile/test/swarm/swarm_screens_test.dart@@ -233,8 +233,8 @@ void main() {);expect(find.text('Projects'),- findsOneWidget,- reason: 'one Swarm: its projects, not its name',+ findsNothing,+ reason: 'one Swarm: no heading, the title names it',);openSwarmNeeds(diff --git a/mobile/test/swarm/swarm_tabs_shots_test.dart b/mobile/test/swarm/swarm_tabs_shots_test.dartindex 139eddaba..186e99c45 100644--- a/mobile/test/swarm/swarm_tabs_shots_test.dart+++ b/mobile/test/swarm/swarm_tabs_shots_test.dart@@ -303,7 +303,7 @@ void main() {for (final key in ['swarm-title-button','swarm-new-message',- 'swarm-away',+ 'swarm-need-line','swarm-you-button','swarm-home-search','swarm-project-$tab-p-oh',diff --git a/mobile/test/swarm/swarm_tabs_test.dart b/mobile/test/swarm/swarm_tabs_test.dartindex c5e90f936..4576f01b4 100644--- a/mobile/test/swarm/swarm_tabs_test.dart+++ b/mobile/test/swarm/swarm_tabs_test.dart@@ -472,12 +472,9 @@ void main() {}await tester.pumpAndSettle();- final away = find.byKey(const ValueKey('swarm-away'));+ final away = find.byKey(const ValueKey('swarm-need-line'));expect(- find.descendant(- of: find.byKey(const ValueKey('swarm-away-needs')),- matching: find.text('1'),- ),+ find.descendant(of: away, matching: find.textContaining('1 need you')),findsOneWidget,);await tester.tap(away);diff --git a/mobile/test/swarm/swarm_threads_shots_test.dart b/mobile/test/swarm/swarm_threads_shots_test.dartindex 5f69fa53f..d81cf45ee 100644--- a/mobile/test/swarm/swarm_threads_shots_test.dart+++ b/mobile/test/swarm/swarm_threads_shots_test.dart@@ -11,7 +11,7 @@ import 'package:harness_mobile/notify/system_notices.dart';import 'package:harness_mobile/settings/experimental_features.dart';import 'package:harness_mobile/shared/theme/app_theme.dart';import 'package:harness_mobile/shared/theme/color_palette.dart';-import 'package:harness_mobile/swarm/swarm_page.dart';+import 'package:harness_mobile/swarm/swarm_activity_page.dart';import 'package:harness_mobile/swarm/swarm_session.dart';import 'package:harness_mobile/swarm/swarm_threads_page.dart';@@ -217,7 +217,9 @@ void main() {return fake;}- testWidgets('Home\'s Threads row and the Threads page', (tester) async {+ testWidgets('Activity\'s Threads button and the Threads page', (+ tester,+ ) async {await tester.binding.setSurfaceSize(const Size(390, 844));tester.view.padding = const FakeViewPadding(top: 47 * 3, bottom: 34 * 3);for (final palette in [HarnessPalette.graphite, HarnessPalette.paper]) {@@ -254,15 +256,19 @@ void main() {theme: buildAppTheme(brightness: brightness),builder: (_, child) => SwarmScope(notifier: host, child: child!),onGenerateRoute: (_) => CupertinoPageRoute<void>(- builder: (_) => SwarmPage(now: () => now),+ builder: (_) => const Scaffold(body: SwarmActivityView()),),),),);await tester.pumpAndSettle();- expect(find.byKey(const ValueKey('swarm-threads-row')), findsOneWidget);- expect(find.byKey(const ValueKey('swarm-threads-tags')), findsOneWidget);- await capture('home');+ // Threads is in Activity's top bar since Home lost its tiles+ // (anh Dee, 2026-11-04).+ expect(+ find.byKey(const ValueKey('swarm-activity-threads')),+ findsOneWidget,+ );+ await capture('activity');await tester.pumpWidget(RepaintBoundary(diff --git a/scripts/ci-plan.py b/scripts/ci-plan.pyindex ce287c9d0..c3da3aab8 100644--- a/scripts/ci-plan.py+++ b/scripts/ci-plan.py@@ -63,7 +63,7 @@ ALSO.update({f"desktop/{path}": "mobile" for path in ("lib/super_tabs/parts.dart", "lib/super_tabs/profile_model.dart", "lib/super_tabs/live_card_model.dart","lib/super_tabs/linked_tasks.dart", "lib/super_tabs/task_steps.dart", "lib/super_tabs/instructions_model.dart","lib/super_tabs/live_card.dart", "lib/super_tabs/task_status.dart", "lib/widgets/engine_identity.dart",- "test/support/real_fonts.dart")})+ "lib/super_tabs/roster.dart", "lib/screens/swarm_screen.dart", "test/support/real_fonts.dart")})# Narrower directories that add a suite on top of their component's (the ESP32-P4 build and golden screens).SUBCOMPONENTS = {"devices/harness-pro/": "pro"}@@ -122,6 +122,8 @@ NOT_READS = {**{source: ("end-to-end and local stack scripts, run by hand", {"backend/"})for source in ("cli/e2e/harness/realBackend.ts", "cli/scripts/box-claim-e2e.ts", "cli/scripts/local-stack-peer.ts","cli/scripts/remote-viewers-stack.ts", "cli/scripts/share-harness-e2e.ts")},+ "backend/src/superTabs/refusalLog.test.ts": ("test data: client versions ('cli/0.5.34', 'desktop/1.3.57')",+ {"cli/", "desktop/"}),"cli/src/engines/__fixtures__/other-runtime.golden.json": ("test data: a model name", {"provider/"}),"cli/src/lib/buddyGuard.claude.spec.ts": ("test data: files in a temporary repository", {"docs/"}),"cli/src/lib/handoffChangedFiles.spec.ts": ("test data: changed file names", {"docs/"}),@@ -263,50 +265,139 @@ REUSE_ERRORS = (OSError, RuntimeError, ValueError, KeyError, TypeError, Attributzipfile.BadZipFile, json.JSONDecodeError)+BATCH_MEMBERS_MAX = 40+++def batch_members(root, head, base):+ """The tested heads a batch branch merged, in merge order: read from its own merges, never from the PR's text.++ Every commit on the head's first-parent line down to the base branch is a two-parent merge; its second parent is a+ member PR's tested head, or a main commit merged again, which brings only main's commits."""+ members, commit = [], head+ for _ in range(BATCH_MEMBERS_MAX + 1):+ if is_ancestor(root, commit, base):+ break+ parents = git(root, "rev-list", "--parents", "-n", "1", commit).split()[1:]+ if len(parents) != 2:+ raise Rerun(f"{commit[:12]} on its first-parent line is not a merge and not on the base branch")+ first, second = (sha(value) for value in parents)+ if not is_ancestor(root, second, base) and second not in members:+ members.append(second)+ commit = first+ else:+ raise Rerun(f"its first-parent line has more than {BATCH_MEMBERS_MAX} merges before the base branch")+ if not members:+ raise Rerun("it merges no member PR")+ return members[::-1]+++def reuse_sources(root, head, base):+ """The commits whose passed runs may stand for this head's components, and how they were found: the passed head of+ GitHub's Update branch (its second parent is a main commit), or the member heads a batch branch merged."""+ parents = git(root, "rev-list", "--parents", "-n", "1", head).split()[1:]+ if len(parents) == 2 and is_ancestor(root, sha(parents[1]), base):+ passed, main = update_parents(root, head, base)+ return [passed], dict(kind="update", passed_head=passed, main_parent=main)+ members = batch_members(root, head, base)+ return members, dict(kind="batch", members=members)+++def passed_receipt(evidence, commit):+ """The exact passed ci/required run of a tested commit, or ValueError."""+ gate = evidence.passed_gate(commit)+ receipt = gate["receipt"]+ if receipt["source_sha"] != commit or receipt["status"] != "passed":+ raise ValueError("the passed head's ci/required receipt names another source")+ return gate+++def run_origin(evidence, commit, gate, suite):+ """Where a passed run's result for this suite was proved: the run itself, or the run it reused (an earlier one)."""+ receipt = gate["receipt"]+ earlier = receipt.get("reused") or {}+ if suite in earlier:+ record = earlier[suite]+ origin, run_id, attempt = sha(record["origin_sha"]), record["run_id"], record["run_attempt"]+ found = evidence.ran(origin, run_id, attempt, suite)+ return origin, run_id, attempt, found["tree"], found["url"]+ return commit, gate["run_id"], gate["run_attempt"], receipt["source_tree"], gate["url"]++def plan_reuse(root, head, base, suites, evidence):- """Reuse what the passed head's exact ci/required run proved, for suites main's commits left alone.+ """Reuse what an exact passed ci/required run proved, for suites nothing else in this head changed the inputs of.- Fails closed: any doubt or unreadable evidence leaves every suite to run as before."""+ After Update branch the run is the passed head's; in a batch PR, a member PR's (task #2720). Fails closed: any doubt+ or unreadable evidence leaves the suite, or every suite, to run as before."""reuse = dict(status="none", reason=None, passed_head=None, main_parent=None, rerun={})reused = {}try:if evidence is None:raise Rerun("no CI evidence reader")- passed, main = update_parents(root, head, base)- reuse.update(passed_head=passed, main_parent=main)+ origins, source = reuse_sources(root, head, base)+ reuse.update(source)changed = own_shared_change(root, head, base)if changed:raise Rerun(f"this PR changes {changed}, which its own CI run reads")- gate = evidence.passed_gate(passed)- receipt = gate["receipt"]- if receipt["source_sha"] != passed or receipt["status"] != "passed":- raise ValueError("the passed head's ci/required receipt names another source")- earlier = receipt.get("reused") or {}- for suite in sorted(suites):- if suite not in receipt["suites"]:- reuse["rerun"][suite] = "the passed head's run did not run it"+ probed = {}+ if source["kind"] == "update":+ try:+ probed[origins[0]] = passed_receipt(evidence, origins[0])+ except REUSE_ERRORS:+ # A batch PR that merged main again: its earlier head never ran alone, but its members did.+ try:+ origins = batch_members(root, head, base)+ reuse.update(kind="batch", members=origins, passed_head=None, main_parent=None)+ except Rerun:+ pass+ batch = reuse["kind"] == "batch"+ gates, unread = [], {}+ for commit in origins:+ if not batch:+ # An update has one source: doubt reruns all.+ gates.append((commit, probed[commit] if commit in probed else passed_receipt(evidence, commit)))continue- if suite in earlier:- record = earlier[suite]- origin, run_id, attempt = sha(record["origin_sha"]), record["run_id"], record["run_attempt"]- found = evidence.ran(origin, run_id, attempt, suite)- tree, url = found["tree"], found["url"]+ try:+ gates.append((commit, passed_receipt(evidence, commit)))+ except REUSE_ERRORS as error:+ # Its changes stay in every other member's diff to the head: it is only no candidate.+ unread[commit] = str(error) or type(error).__name__+ if batch and not gates:+ raise Rerun("no member's passed run could be verified: " + "; ".join(f"{c[:12]}: {e}" for c, e in unread.items()))+ for suite in sorted(suites):+ reasons = []+ for commit, gate in gates:+ if suite not in gate["receipt"]["suites"]:+ reasons.append(f"member {commit[:12]}'s run did not run it" if batch else "the passed head's run did not run it")+ continue+ if batch:+ try:+ origin, run_id, attempt, tree, url = run_origin(evidence, commit, gate, suite)+ except REUSE_ERRORS as error:+ reasons.append(f"member {commit[:12]}'s earlier run could not be verified: {str(error) or type(error).__name__}")+ continue+ else:+ origin, run_id, attempt, tree, url = run_origin(evidence, commit, gate, suite)+ scope, reason = reuse_blocker(root, suite, origin, head)+ if scope == "all":+ raise Rerun(reason)+ if scope == "suite":+ reasons.append(reason)+ continue+ why = (f"passed in run {run_id} on {origin[:12]}, merged here as member {commit[:12]}; nothing else in the "+ f"batch or on main changes its inputs ({reason})" if batch else+ f"passed in run {run_id} on {origin[:12]}; main's new commits change none of its inputs ({reason})")+ reused[suite] = dict(origin_sha=origin, origin_tree=sha(tree), run_id=run_id, run_attempt=attempt, run_url=url,+ reason=why)+ breakelse:- origin, run_id, attempt, tree, url = passed, gate["run_id"], gate["run_attempt"], receipt["source_tree"], gate["url"]- scope, reason = reuse_blocker(root, suite, origin, head)- if scope == "all":- raise Rerun(reason)- if scope == "suite":- reuse["rerun"][suite] = reason- continue- reused[suite] = dict(origin_sha=origin, origin_tree=sha(tree), run_id=run_id, run_attempt=attempt, run_url=url,- reason=f"passed in run {run_id} on {origin[:12]}; main's new commits change none of its inputs ({reason})")+ reasons += [f"member {c[:12]}'s passed run could not be read: {e}" for c, e in unread.items()]+ reuse["rerun"][suite] = "; ".join(reasons)except Rerun as refusal:return {}, dict(reuse, rerun={}, reason=str(refusal))except REUSE_ERRORS as error:return {}, dict(reuse, rerun={}, reason=f"earlier evidence could not be verified: {str(error) or type(error).__name__}")- reuse.update(status="applied" if reused else "none",- reason=f"reused {len(reused)} of {len(suites)} suites from the passed head's run")+ whence = "the batch's member runs" if reuse.get("kind") == "batch" else "the passed head's run"+ reuse.update(status="applied" if reused else "none", reason=f"reused {len(reused)} of {len(suites)} suites from {whence}")return reused, reuse@@ -420,13 +511,17 @@ def verify_reuse(root, receipt, base, evidence):reused = check_reused_records(receipt.get("reused"), receipt.get("suites") or [], head, receipt.get("event"))if not reused:return {}+ reuse = receipt.get("reuse")+ if not isinstance(reuse, dict):+ raise ValueError("reused results name no update merge or batch")try:- passed, main = update_parents(root, head, base)+ if reuse.get("kind") == "batch":+ if reuse.get("members") != batch_members(root, head, base):+ raise ValueError("reused results name other members than the batch head's merges")+ elif (reuse.get("passed_head"), reuse.get("main_parent")) != update_parents(root, head, base):+ raise ValueError("reused results name other parents than the head's update merge")except Rerun as refusal:raise ValueError(f"reused results refused: {refusal}") from None- reuse = receipt.get("reuse")- if not isinstance(reuse, dict) or (reuse.get("passed_head"), reuse.get("main_parent")) != (passed, main):- raise ValueError("reused results name other parents than the head's update merge")changed = own_shared_change(root, head, base)if changed:raise ValueError(f"reused results refused: this PR changes {changed}, which its own CI run reads")diff --git a/scripts/tests/test_ci_plan.py b/scripts/tests/test_ci_plan.pyindex f70fec206..6cac4d6fc 100644--- a/scripts/tests/test_ci_plan.py+++ b/scripts/tests/test_ci_plan.py@@ -34,7 +34,7 @@ class SelectionTests(unittest.TestCase):"desktop/test/support/real_fonts.dart"]:with self.subTest(path=path):self.assertEqual(planner.select([path])[0], {"desktop", "mobile"})- self.assertEqual(planner.select(["desktop/lib/super_tabs/roster.dart"])[0], {"desktop"})+ self.assertEqual(planner.select(["desktop/lib/super_tabs/view.dart"])[0], {"desktop"})def test_every_desktop_file_the_phone_tests_read_selects_mobile(self):# The phone's tests name what they read as '../desktop/<path>', an import of '../../desktop/<path>', or (the parity@@ -340,9 +340,10 @@ class ReuseFixture(unittest.TestCase):self.git("merge", "-q", "--no-ff", "--no-edit", main)return self.git("rev-parse", "HEAD")- def plan(self, head, base, evidence=True, draft=False):+ def plan(self, head, base, evidence=True, draft=False, body=None):self.git("checkout", "-q", "--detach", head)- payload = {"pull_request": {"head": {"sha": head}, "base": {"sha": base}, "draft": draft}}+ payload = {"pull_request": {"head": {"sha": head}, "base": {"sha": base}, "draft": draft,+ **({"body": body} if body is not None else {})}}return planner.make_plan(self.root, "pull_request", payload, source=head,evidence=self.evidence if evidence else None)@@ -483,10 +484,7 @@ class ReuseTests(ReuseFixture):# Main merged into a commit with no passed gate.unpassed = self.branch(passed, ["mobile/lib/app.dart"], "later")self.assertRerunsAll(self.plan(self.update(unpassed, main), main), "not a pass")- # Parents reversed: main first.- self.git("checkout", "-q", "--detach", main)- self.git("merge", "-q", "--no-ff", "--no-edit", passed)- self.assertRerunsAll(self.plan(self.git("rev-parse", "HEAD"), main), "not on the base branch")+ # Parents reversed (main first, the passed head merged in) is a batch of one (BatchReuseTests).def test_unreadable_evidence_or_no_reader_reruns(self):_, main, head = self.scenario(["mobile/lib/app.dart"], ["backend/src/app.ts"])@@ -549,6 +547,133 @@ class ReuseTests(ReuseFixture):self.assertEqual(self.evidence.lookups, [])+class BatchReuseTests(ReuseFixture):+ """A batch PR (a branch from main with each member PR merged in) reuses a member's passed result for a component+ when nothing that component reads changed between that member's tested commit and the batch head (task #2720)."""++ def batch(self, main, members):+ """The PM's batch branch: main, then each member's tested head merged in, first parent the batch."""+ self.git("checkout", "-q", "--detach", main)+ for member in members:+ self.git("merge", "-q", "--no-ff", "--no-edit", member)+ return self.git("rev-parse", "HEAD")++ def member(self, name, paths, run_id, start=None):+ head = self.branch(start or self.base, paths, name)+ self.evidence.add(self.root, head, planner.select(paths)[0], run_id=run_id)+ return head++ def test_a_batch_with_one_phone_pr_reuses_mobile_checks(self):+ phone = self.member("phone", ["mobile/lib/app.dart"], 21)+ api = self.member("api", ["backend/src/app.ts"], 22)+ main = self.branch(self.base, ["docs/guide.md"], "main")+ head = self.batch(main, [phone, api])+ plan = self.plan(head, main)+ self.assertEqual(plan["suites"], ["backend", "mobile"])+ self.assertEqual(plan["required_jobs"], ["process-checks"])+ self.assertEqual((plan["reused"]["mobile"]["origin_sha"], plan["reused"]["mobile"]["run_id"]), (phone, 21))+ self.assertEqual((plan["reused"]["backend"]["origin_sha"], plan["reused"]["backend"]["run_id"]), (api, 22))+ self.assertEqual(plan["reused"]["mobile"]["origin_tree"], self.git("rev-parse", f"{phone}^{{tree}}"))+ self.assertIn("backend/src/app.ts", plan["reused"]["mobile"]["reason"])+ self.assertEqual(plan["reuse"]["status"], "applied")+ self.assertEqual((plan["reuse"]["kind"], plan["reuse"]["members"]), ("batch", [phone, api]))++ def test_two_phone_prs_in_one_batch_run_mobile_checks(self):+ first = self.member("phone-1", ["mobile/lib/app.dart"], 21)+ second = self.member("phone-2", ["mobile/lib/other.dart"], 22)+ api = self.member("api", ["backend/src/app.ts"], 23)+ head = self.batch(self.base, [first, second, api])+ plan = self.plan(head, self.base)+ self.assertNotIn("mobile", plan["reused"])+ self.assertIn("mobile-checks", plan["required_jobs"])+ self.assertRegex(plan["reuse"]["rerun"]["mobile"], "mobile/lib/(app|other).dart")+ self.assertEqual(list(plan["reused"]), ["backend"])++ def test_a_main_change_to_a_mobile_input_after_the_member_ran_runs_it(self):+ phone = self.member("phone", ["mobile/lib/app.dart"], 21)+ main = self.branch(self.base, ["mobile/lib/shared.dart"], "main")+ plan = self.plan(self.batch(main, [phone]), main)+ self.assertEqual(plan["reused"], {})+ self.assertIn("mobile/lib/shared.dart", plan["reuse"]["rerun"]["mobile"])++ def test_a_shared_input_runs_everything(self):+ # Changed by a member: the batch's own change, which its own CI run reads.+ phone = self.member("phone", ["mobile/lib/app.dart"], 21)+ locked = self.member("locked", ["cli/package-lock.json"], 22)+ self.assertRerunsAll(self.plan(self.batch(self.base, [phone, locked]), self.base), "cli/package-lock.json")+ # Changed on main after a member's run.+ main = self.branch(self.base, [".github/workflows/ci.yml"], "main")+ self.assertRerunsAll(self.plan(self.batch(main, [phone]), main), ".github/workflows/ci.yml")++ def test_an_unreadable_receipt_runs_its_component(self):+ phone = self.member("phone", ["mobile/lib/app.dart"], 21)+ api = self.member("api", ["backend/src/app.ts"], 22)+ del self.evidence.gates[phone]+ head = self.batch(self.base, [phone, api])+ plan = self.plan(head, self.base)+ self.assertEqual(list(plan["reused"]), ["backend"])+ self.assertIn("mobile-checks", plan["required_jobs"])+ self.assertIn("not a pass", plan["reuse"]["rerun"]["mobile"])+ # Nothing readable at all: every component runs.+ self.evidence.failure = RuntimeError("GitHub lookup failed (1): api")+ plan = self.plan(head, self.base)+ self.assertEqual(plan["reused"], {})+ self.assertEqual(plan["required_jobs"], sorted({"process-checks"} | planner.JOBS["backend"] | planner.JOBS["mobile"]))++ def test_the_pr_body_is_never_read(self):+ phone = self.member("phone", ["mobile/lib/app.dart"], 21)+ # The same change landed as one plain commit on main: no merge names a member, whatever the body says.+ self.git("checkout", "-q", "--detach", self.base)+ self.write("mobile/lib/app.dart", "phone mobile/lib/app.dart")+ squashed = self.commit("batch")+ body = f"Batch: #101 at {phone} passed in run 21 (https://github.com/o/r/actions/runs/21)."+ plan = self.plan(squashed, self.base, body=body)+ self.assertEqual(plan["reused"], {})+ self.assertNotIn(phone, [lookup[1] for lookup in self.evidence.lookups])+ # A real batch is read from its merges alone: a body naming another commit changes nothing.+ stranger = self.member("stranger", ["mobile/lib/app.dart"], 99)+ head = self.batch(self.base, [phone])+ self.assertEqual(self.plan(head, self.base, body=f"#7 at {stranger}")["reused"]["mobile"]["origin_sha"], phone)+ self.assertNotIn(stranger, [lookup[1] for lookup in self.evidence.lookups])++ def test_a_batch_that_merged_main_again_still_reads_its_members(self):+ phone = self.member("phone", ["mobile/lib/app.dart"], 21)+ head = self.batch(self.base, [phone])+ later = self.branch(self.base, ["backend/src/app.ts"], "main")+ self.git("checkout", "-q", "--detach", head)+ self.git("merge", "-q", "--no-ff", "--no-edit", later)+ plan = self.plan(self.git("rev-parse", "HEAD"), later)+ self.assertEqual(plan["reused"]["mobile"]["origin_sha"], phone)+ self.assertEqual(plan["reuse"]["members"], [phone])++ def test_a_hand_commit_on_the_batch_line_runs_everything(self):+ phone = self.member("phone", ["mobile/lib/app.dart"], 21)+ self.batch(self.base, [phone])+ self.write("backend/src/app.ts", "fixed by hand")+ self.assertRerunsAll(self.plan(self.commit("fix"), self.base), "not a merge")++ def test_a_member_whose_run_reused_points_at_the_original_run(self):+ passed = self.member("phone", ["mobile/lib/app.dart"], 21)+ main = self.branch(self.base, ["backend/src/app.ts"], "main")+ updated = self.update(passed, main)+ reused = self.plan(updated, main)["reused"]+ self.evidence.add(self.root, updated, {"mobile"}, run_id=31, reused=reused)+ plan = self.plan(self.batch(main, [updated]), main)+ self.assertEqual((plan["reused"]["mobile"]["origin_sha"], plan["reused"]["mobile"]["run_id"]), (passed, 21))+ self.assertIn(("ran", passed, 21, "mobile"), self.evidence.lookups)++ def test_the_helper_verifies_a_batch_reuse_and_refuses_other_members(self):+ phone = self.member("phone", ["mobile/lib/app.dart"], 21)+ api = self.member("api", ["backend/src/app.ts"], 22)+ head = self.batch(self.base, [phone, api])+ plan = self.plan(head, self.base)+ receipt = dict(source_sha=head, suites=plan["suites"], reused=plan["reused"], reuse=plan["reuse"], event="pull_request")+ self.assertEqual(planner.verify_reuse(self.root, receipt, self.base, self.evidence), plan["reused"])+ forged = dict(receipt, reuse=dict(plan["reuse"], members=[api]))+ with self.assertRaisesRegex(ValueError, "members"):+ planner.verify_reuse(self.root, forged, self.base, self.evidence)++class GateTests(unittest.TestCase):def setUp(self):self.head = "a" * 40