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
Simplify device tab switching and sync read notifications (#445)
Deeb5bfd9d8d0b1
diff --git a/cli/scripts/device-release-check.mts b/cli/scripts/device-release-check.mtsindex 6e126b509..7ddb46b82 100644--- a/cli/scripts/device-release-check.mts+++ b/cli/scripts/device-release-check.mts@@ -125,6 +125,26 @@ await check('built-wire-codec-compatibility',()=>{for(const chunk of [1,7,512,8200]){const d=new Decoder();let seen=0;for(let i=0;i<wire.length;i+=chunk)d.feed(wire.subarray(i,i+chunk),(f:any)=>{seen++;assert.equal(f.type,CableType.Pcm);assert.deepEqual(Buffer.from(f.payload),bytes)});assert.equal(seen,1)}}})+await check('notification-read-roundtrip-and-stale-occurrences',async()=>{+ const read=nodes.find(n=>ts.isMethodDeclaration(n)&&n.name.getText(ast)==='readNotification'&&n.getText(ast).includes('this.wiring'))+ assert(read,'Built host must validate exact notification occurrences')+ const Host=vm.runInContext(`(class {${read.getText(ast)}})`,sandbox), owner=new Host(), receipts:any[]=[]+ owner.unread=[{agentId:'a',machineId:'remote',question:true,text:'May I publish?',readToken:'question-2'}]+ owner.wiring={notificationRead:(...args:any[])=>receipts.push(args)}+ const x=setup();x.host.readNotification=owner.readNotification.bind(owner)+ x.host.openAgent=()=>{throw new Error('Reading must not change focus')}+ await x.session.replaceNotifications(owner.unread)+ assert.equal(x.sent.at(-1).items[0].readToken,'question-2')+ for(const token of ['question-1','', 'x'.repeat(64)])await x.feed({t:'notif.read',agentId:'a',readToken:token},1)+ assert.equal(receipts.length,0)+ await x.feed({t:'notif.read',agentId:'a',readToken:'question-2'},1)+ assert.deepEqual(plain(receipts),[['remote','a','question-2']])+ await x.session.agentSeen('a','question-2')+ assert.deepEqual(plain(x.sent.at(-1)),{t:'notif.seen',agentId:'a',readToken:'question-2'})+ owner.unread=[];await x.session.replaceNotifications(owner.unread)+ await x.feed({t:'notif.read',agentId:'a',readToken:'question-2'},7)+ assert.equal(receipts.length,1);assert.deepEqual(plain(x.sent.at(-1)),{t:'notif.replace',items:[]})+})await check('artifact-status-wiring' ,()=>{assert(method('refreshFocusedActivity'),'Installed bridge lacks focused activity delivery')assert(method('tick')?.getText(ast).includes('refreshFocusedActivity'),'Activity recovery is never scheduled')diff --git a/cli/src/cable/cableHost.spec.ts b/cli/src/cable/cableHost.spec.tsindex 1f19d71e1..5de2de94a 100644--- a/cli/src/cable/cableHost.spec.ts+++ b/cli/src/cable/cableHost.spec.ts@@ -46,6 +46,24 @@ function fleetOf(machines: FleetMachine[]): MachineFleet {const REMOTE: FleetMachine = { machineId: 'other', name: 'office-imac', state: 'ready', authMode: 'remote' }+describe('notification read receipts', () => {+ it('routes the exact occurrence to its machine without focusing or answering', () => {+ const w = wiring({ notificationRead: vi.fn(), opened: vi.fn(), focused: vi.fn() })+ const host = new DaemonCableHost(w)+ const item = { agentId: 'a', machineId: 'other', text: 'Same words.', question: true, readToken: 'turn-2' }+ host.setUnread([item])+ for (const [agent, token] of [['a', 'turn-1'], ['b', 'turn-2'], ['a', 'x'.repeat(64)], ['a', '']]) host.readNotification(agent, token)+ expect(w.notificationRead).not.toHaveBeenCalled()+ host.readNotification('a', 'turn-2'); host.readNotification('a', 'turn-2')+ expect(w.notificationRead).toHaveBeenCalledTimes(2)+ expect(w.notificationRead).toHaveBeenLastCalledWith('other', 'a', 'turn-2')+ expect(w.opened).not.toHaveBeenCalled(); expect(w.focused).not.toHaveBeenCalled(); expect(w.answer).not.toHaveBeenCalled()+ expect(host.listUnread()).toEqual([item]) // only the window confirms the clear+ host.setUnread([]); host.readNotification('a', 'turn-2')+ expect(w.notificationRead).toHaveBeenCalledTimes(2)+ })+})+/** The window, open on one tab that holds these panes in this order. */function onTab(host: DaemonCableHost, agentIds: string[], id = 't1'): void {host.setSwarms({ active: id, swarms: [{ id, name: 'Tab', agentIds, panes: agentIds.length }], tiles: [] })diff --git a/cli/src/cable/cableHost.ts b/cli/src/cable/cableHost.tsindex 161398f89..6662c0958 100644--- a/cli/src/cable/cableHost.ts+++ b/cli/src/cable/cableHost.ts@@ -9,6 +9,7 @@// as the very `commander_event` cards the WiFi device receives — teed at the socket rather than emitted// again here, so the two device surfaces cannot drift.import { join } from 'node:path'+import { notificationReadToken, type UnreadNotification } from './notificationRead.js'import { AuthSessionManager, readAuthSession } from '../lib/authSession.js'import { registry, projectDisplayName, type RegisteredSession } from '../lib/registry.js'@@ -66,6 +67,7 @@ export interface CableHostWiring {* `'question'` it was a question screen instead, and the window only brings the agent forward.*/opened?: (machineId: string, agentId: string, reason?: OpenReason) => void+ notificationRead?: (machineId: string, agentId: string, readToken: string) => void/** A fork the dial asked for is open: the window puts it beside its source and focuses it. */forked?: (machineId: string, agentId: string, sourceAgentId: string) => void/** The dial asked for a fork of a LOCAL agent — see lib/forkAgent.ts. Resolves to the new agent's id. */@@ -403,16 +405,25 @@ export class DaemonCableHost implements CableHost {}/** What the window still has unread, newest first. Empty until a window says otherwise. */- private unread: Array<{ agentId: string; machineId: string; question: boolean; text: string }> = []+ private unread: UnreadNotification[] = []- setUnread(items: Array<{ agentId: string; machineId: string; question: boolean; text: string }>): void {+ setUnread(items: UnreadNotification[]): void {this.unread = items}- listUnread(): Array<{ agentId: string; machineId: string; question: boolean; text: string }> {+ listUnread(): UnreadNotification[] {return this.unread}+ readNotification(agentId: string, readToken: string): void {+ if (!notificationReadToken(readToken)) return+ const item = this.unread.find(n => n.agentId === agentId && n.readToken === readToken)+ if (!item?.machineId) return+ // Keep it until the window confirms through app_unread. Retrying is safe;+ // the window checks the same identity again, even across remote machines.+ this.wiring.notificationRead?.(item.machineId, agentId, readToken)+ }+listSwarms(): { selected: string; swarms: CableSwarm[]; tiles: CableTile[] } {const app = this.swarmsif (!app) return { selected: '', swarms: [], tiles: [] }diff --git a/cli/src/cable/cableSession.spec.ts b/cli/src/cable/cableSession.spec.tsindex 899699302..501163a68 100644--- a/cli/src/cable/cableSession.spec.ts+++ b/cli/src/cable/cableSession.spec.ts@@ -277,6 +277,33 @@ describe('cable session', () => {} finally { await session.stop() }})+ it('carries read tokens through snapshots and accepts only bounded read receipts', async () => {+ const readNotification = vi.fn(), openAgent = vi.fn()+ const { session, port } = await connect(makeHost({ readNotification, openAgent }))+ try {+ await session.replaceNotifications([{ agentId: 'a1', machineId: 'mac-local', question: true, text: 'Which branch?', readToken: 'question-2' }])+ expect(port.sent.at(-1)).toMatchObject({ t: 'notif.replace', items: [{ readToken: 'question-2' }] })+ port.say({ t: 'notif.read', agentId: 'a1', readToken: 'question-2' })+ for (const readToken of ['', 42, null, 'a'.repeat(64), 'line\nbreak']) port.say({ t: 'notif.read', agentId: 'a1', readToken })+ await settle()+ expect(readNotification).toHaveBeenCalledExactlyOnceWith('a1', 'question-2')+ expect(openAgent).not.toHaveBeenCalled()+ } finally { await session.stop() }+ })++ it.each(['turn-1', 'turn-2'])('a late read of %s cannot clear a newer snapshot occurrence', async readToken => {+ let finish!: (value: Array<{ recap: string; text: string }>) => void+ const history = new Promise<Array<{ recap: string; text: string }>>(resolve => { finish = resolve })+ const { session, port } = await connect(makeHost({ recentSummaries: () => history }))+ try {+ const pending = session.replaceNotifications([{ agentId: 'a1', machineId: 'mac-local', question: false, text: '', readToken: 'turn-2' }])+ await session.agentSeen('a1', readToken)+ finish([{ recap: 'Same words.', text: 'Same words.' }]); await pending+ const items = port.sent.at(-1)!.items as unknown[]+ expect(items).toHaveLength(readToken === 'turn-2' ? 0 : 1)+ } finally { await session.stop() }+ })+it('fetches the chosen agent question and submits its reviewed token once', async () => {const answerReviewed = vi.fn<NonNullable<CableHost['answerReviewed']>>(async () => ({ ok: true as const }))const { session, port } = await connect(makeHost({ answerReviewed }))diff --git a/cli/src/cable/cableSession.ts b/cli/src/cable/cableSession.tsindex dc4b25674..c4600e19a 100644--- a/cli/src/cable/cableSession.ts+++ b/cli/src/cable/cableSession.ts@@ -28,6 +28,7 @@ import { SerialLink, findDialPort } from './serial.js'import { PassageCarry, withCarriedPassage, type CarryRead } from './passageCarry.js'import { VoiceDraft, type DraftPin } from './voiceDraft.js'import { QuestionInbox, type ReviewedAnswer, type AnswerReceipt, type QuestionSpeech } from './questionInbox.js'+import { notificationReadToken, type UnreadNotification } from './notificationRead.js'/** Bumped when the VOCABULARY changes. Separate from the frame version, which is the envelope. */export const CABLE_PROTO_VERSION = 3 // 3: + question.close (a question answered on another client)@@ -284,6 +285,7 @@ export interface CableHost {* because a reconnect re-shows every unanswered question and each used to open a tab.*/openAgent(agentId: string, reason?: OpenReason): void+ readNotification?(agentId: string, readToken: string): void/** The dial asked for a fork of this agent — a second one with its history, opened in the window. */forkAgent(agentId: string): Promise<{ ok: true; agentId: string } | { ok: false; error: string; detail?: string }>/**@@ -319,7 +321,7 @@ export interface CableHost {/** One agent's last turn summaries, newest first — what a reattached dial needs to redraw its tiles. */recentSummaries(agentId: string): Promise<Array<{ recap: string; text: string }>>/** What the window still has unread, newest first — replayed to a dial that has just attached. */- listUnread(): Array<{ agentId: string; machineId: string; question: boolean; text: string }>+ listUnread(): UnreadNotification[]/*** The image to offer a dial running `runningVersion`, or null for "nothing to do" — which covers a* dial that is current, a dev build that must not be touched, and an unreachable manifest.@@ -917,6 +919,12 @@ export class CableSession {this.host.focus(agentId)}return+ case 'notif.read': {+ const agentId = str('agentId')+ const token = notificationReadToken(msg.readToken)+ if (agentId && token) this.host.readNotification?.(agentId, token)+ return+ }case 'agent.open':// Only the one reason the window knows; anything else reads as a tap, the older frame's meaning.if (str('agentId')) this.host.openAgent(str('agentId')!, str('reason') === 'question' ? 'question' : undefined)@@ -1913,7 +1921,7 @@ export class CableSession {* daemon already knows, so those never have a second source that can disagree.*/async replaceNotifications(- items: Array<{ agentId: string; machineId: string; question: boolean; text: string }>,+ items: UnreadNotification[],): Promise<void> {const replay = { seen: new Set<string>() }this.notificationReplay = replay@@ -1930,14 +1938,16 @@ export class CableSession {summary = summary ? extendShortRecap(summary, saved?.text ?? '') : saved?.recap ?? ''} catch { /* keep the supplied text if history cannot be read */ }}- return { agentId: item.agentId, name: who.name, machine: who.machine, summary, question: item.question }+ return { agentId: item.agentId, name: who.name, machine: who.machine, summary, question: item.question,+ ...(notificationReadToken(item.readToken) ? { readToken: item.readToken } : {}) }}))if (this.notificationReplay !== replay) returnthis.notificationReplay = undefinedif (this.link !== link || this.stopped) return- // Seen completion rows stay cleared even if their history arrived late.- // Questions still require an answer; looking at one cannot dismiss it.- await this.send({ t: 'notif.replace', items: rows.filter(row => row.question || !replay.seen.has(row.agentId)) })+ // Reading clears the notice, not the underlying question. Versioned clears+ // cannot eat a newer turn whose history happened to take longer to load.+ await this.send({ t: 'notif.replace', items: rows.filter(row =>+ (row.question || !replay.seen.has(row.agentId)) && !replay.seen.has(`${row.agentId}\0${row.readToken}`)) })}/**@@ -1950,10 +1960,11 @@ export class CableSession {* Fire and forget, like every other card: a dial that predates the message* counts it as unknown and drops it, which is the behaviour it has today.*/- async agentSeen(agentId: string): Promise<void> {+ async agentSeen(agentId: string, readToken?: string): Promise<void> {if (!agentId) return- this.notificationReplay?.seen.add(agentId)- await this.send({ t: 'notif.seen', agentId })+ if (readToken !== undefined && !notificationReadToken(readToken)) return+ this.notificationReplay?.seen.add(readToken ? `${agentId}\0${readToken}` : agentId)+ await this.send({ t: 'notif.seen', agentId, ...(readToken ? { readToken } : {}) })}async turnError(agentId: string, message: string): Promise<void> {this.activityReads.delete(agentId)diff --git a/cli/src/cable/notificationRead.ts b/cli/src/cable/notificationRead.tsnew file mode 100644index 000000000..bd094c13e--- /dev/null+++ b/cli/src/cable/notificationRead.ts@@ -0,0 +1,13 @@+/** The desktop owns unread state. The token identifies one occurrence, not one agent or sentence. */+export interface UnreadNotification {+ agentId: string+ machineId: string+ question: boolean+ text: string+ readToken?: string+}++/** Fixed firmware field: never truncate an identity into another valid identity. */+export function notificationReadToken(value: unknown): string | undefined {+ return typeof value === 'string' && /^[A-Za-z0-9_-]{1,63}$/.test(value) ? value : undefined+}diff --git a/cli/src/cli.ts b/cli/src/cli.tsindex 5f49b6d0b..b278a0236 100644--- a/cli/src/cli.ts+++ b/cli/src/cli.ts@@ -4689,7 +4689,7 @@ async function runForeground(session: AuthSession | null): Promise<void> {// The window looked at a harness, so the dial's drawer row for it is stale.// The dial's own tap already reaches the window (`agent.open`); this is the// return leg, and the pair is what keeps the badge and the pill equal.- onAgentSeen: (agentId) => { void cableRef?.agentSeen(agentId) },+ onAgentSeen: (agentId, readToken) => { void cableRef?.agentSeen(agentId, readToken) },// Agents the window has a tile for. A finished turn on one of these is// already in front of the person, so the dial updates its tile in silence// rather than beeping about something being looked at.@@ -6733,6 +6733,8 @@ async function runForeground(session: AuthSession | null): Promise<void> {// than opening a tab, and an older window that does not know the field opens one as before.opened: (machineId, agentId, reason) =>backend.sendLocal({ type: 'dial_open', payload: { machineId, agentId, ...(reason ? { reason } : {}) } }),+ notificationRead: (machineId, agentId, readToken) =>+ backend.sendLocal({ type: 'dial_notification_read', payload: { machineId, agentId, readToken } }),forked: (machineId, agentId, sourceAgentId) => backend.sendLocal({ type: 'dial_forked', payload: { machineId, agentId, sourceAgentId } }),// The dial's Fork: the same path the window's `agent_fork` takes, then `forked` above lands on it.forkAgent: async (agentId) => {diff --git a/cli/src/localWsServer.spec.ts b/cli/src/localWsServer.spec.tsindex 9e115b92e..51733e142 100644--- a/cli/src/localWsServer.spec.ts+++ b/cli/src/localWsServer.spec.ts@@ -77,6 +77,23 @@ describe('local CLI WebSocket', () => {return `ws://127.0.0.1:${port}/api/local-ws`}+ it('keeps notification identities on the local read and snapshot paths', async () => {+ const backend = new FakeBackend(), seen = vi.fn(), unread = vi.fn()+ const ws = new WebSocket(await start(backend, { onAgentSeen: seen, onAppUnread: unread }))+ await onceOpen(ws)+ const connected = onceMessage(ws)+ ws.send(JSON.stringify({ type: 'machine_select', payload: { machineId, localProtocolVersion: 1 } }))+ await connected+ const item = { agentId: 'a', machineId: 'remote', question: true, text: 'Publish?', readToken: 'question-1' }+ ws.send(JSON.stringify({ type: 'app_unread', payload: { items: [item] } }))+ ws.send(JSON.stringify({ type: 'agent_seen', payload: { agentId: 'a', readToken: item.readToken } }))+ for (const readToken of ['', 42, 'x'.repeat(64)]) ws.send(JSON.stringify({ type: 'agent_seen', payload: { agentId: 'a', readToken } }))+ await vi.waitFor(() => expect(seen).toHaveBeenCalledExactlyOnceWith('a', 'question-1'))+ expect(unread).toHaveBeenCalledExactlyOnceWith([item])+ expect(backend.frames).toEqual([])+ ws.close()+ })+it('serves the same endpoint over the daemon socket, with no Host to name and no Origin allowed', async () => {const dir = mkdtempSync('/tmp/hsock-')const socketPath = join(dir, 'daemon.sock')diff --git a/cli/src/localWsServer.ts b/cli/src/localWsServer.tsindex 815d6adcd..f792d5683 100644--- a/cli/src/localWsServer.ts+++ b/cli/src/localWsServer.ts@@ -1,6 +1,7 @@import { SharingEndedError, type HarnessShareRelay } from './sharing/relay.js'import { randomUUID } from 'node:crypto'import type { AppSwarms } from './cable/cableSession.js'+import { notificationReadToken, type UnreadNotification } from './cable/notificationRead.js'import type http from 'node:http'import type { Socket } from 'node:net'import { WebSocket, WebSocketServer, type RawData } from 'ws'@@ -68,9 +69,9 @@ export interface LocalWsServerOptions {/** Every agent the window currently has a tile for, across all its machines. */onAppPanes?: (agentIds: string[], foreground: boolean) => void/** The window has looked at this harness — see the `agent_seen` case below. */- onAgentSeen?: (agentId: string) => void+ onAgentSeen?: (agentId: string, readToken?: string) => void/** Everything the window still has unread, newest first — see the `app_unread` case below. */- onAppUnread?: (items: Array<{ agentId: string; machineId: string; question: boolean; text: string }>) => void+ onAppUnread?: (items: UnreadNotification[]) => void/*** The window's swarms — its named groups of agents, one of them on screen. The whole list each time,* and `null` when the window goes away, so the daemon never keeps describing tabs nobody can see.@@ -521,7 +522,11 @@ export function attachLocalWsServer(server: http.Server, options: LocalWsServerOif (!isBinary && options.onAgentSeen) {if (parsed?.type === 'agent_seen') {const agentId = (parsed.payload as Record<string, unknown> | undefined)?.agentId- if (typeof agentId === 'string' && agentId) options.onAgentSeen(agentId)+ const rawToken = (parsed.payload as Record<string, unknown> | undefined)?.readToken+ const readToken = notificationReadToken(rawToken)+ // Invalid versioned receipts must not become unversioned clears.+ if (rawToken !== undefined && !readToken) return+ if (typeof agentId === 'string' && agentId) options.onAgentSeen(agentId, readToken)return}}@@ -541,7 +546,8 @@ export function attachLocalWsServer(server: http.Server, options: LocalWsServerOconst machineId = item?.machineIdconst text = typeof item?.text === 'string' ? item.text : ''return typeof agentId === 'string' && agentId && typeof machineId === 'string'- ? [{ agentId, machineId, question: item?.question === true, text }]+ ? [{ agentId, machineId, question: item?.question === true, text,+ ...(notificationReadToken(item?.readToken) ? { readToken: notificationReadToken(item?.readToken) } : {}) }]: []}): []diff --git a/desktop/lib/notify/agent_alerts.dart b/desktop/lib/notify/agent_alerts.dartindex 9d7ea4ed4..0caaae078 100644--- a/desktop/lib/notify/agent_alerts.dart+++ b/desktop/lib/notify/agent_alerts.dart@@ -1,6 +1,7 @@library;import 'dart:async';+import 'dart:math';import 'package:flutter/foundation.dart';@@ -158,6 +159,16 @@ class AgentUnread extends ChangeNotifier {static const capacity = 256;final _unread = <String, AlertKind>{};+ final _tokens = <String, String>{};+ final _epoch = List.generate(+ 12,+ (_) => Random.secure().nextInt(256),+ ).map((n) => n.toRadixString(16).padLeft(2, '0')).join();+ int _sequence = 0;++ /// Identity of the notification, not its text. Two turns can say the same thing.+ String? readTokenFor(String machineId, String agentId) =>+ _tokens[keyFor(machineId, agentId)];static String keyFor(String machineId, String agentId) =>'$machineId/$agentId';@@ -192,9 +203,15 @@ class AgentUnread extends ChangeNotifier {/// Record that an agent did something. The NEWEST kind wins: an agent that/// finished and then asked a question is waiting on a person, and that is the/// mark worth showing.- void mark(String machineId, String agentId, AlertKind kind) {+ void mark(+ String machineId,+ String agentId,+ AlertKind kind, {+ bool fresh = false,+ }) {final key = keyFor(machineId, agentId);- if (_unread[key] == kind) return;+ if (!fresh && _unread[key] == kind) return;+ _tokens[key] = '$_epoch-${(++_sequence).toRadixString(36)}';// Re-inserted, not updated in place: an agent that moved is the newest// again, which is what makes the first key the oldest for the eviction// below. `notif_push` on the dial does exactly this — it lifts an existing@@ -203,6 +220,7 @@ class AgentUnread extends ChangeNotifier {..remove(key)..[key] = kind;while (_unread.length > capacity) {+ _tokens.remove(_unread.keys.first);_unread.remove(_unread.keys.first);}notifyListeners();@@ -211,7 +229,9 @@ class AgentUnread extends ChangeNotifier {/// The person went and looked. Silent when there was nothing to clear, so a/// pane being focused for any other reason does not rebuild the window.void clear(String machineId, String agentId) {- if (_unread.remove(keyFor(machineId, agentId)) == null) return;+ final key = keyFor(machineId, agentId);+ if (_unread.remove(key) == null) return;+ _tokens.remove(key);notifyListeners();}@@ -222,6 +242,7 @@ class AgentUnread extends ChangeNotifier {void clearAll() {if (_unread.isEmpty) return;_unread.clear();+ _tokens.clear();notifyListeners();}}diff --git a/desktop/lib/notify/system_notifications.dart b/desktop/lib/notify/system_notifications.dartindex bd8ccb25e..690b3c163 100644--- a/desktop/lib/notify/system_notifications.dart+++ b/desktop/lib/notify/system_notifications.dart@@ -298,6 +298,24 @@ class SystemNotifications {final DesktopNotificationStore store;final SystemNotifier notifier;+ final _pending = <String, Future<void>>{};++ // Posting may wait for an OS permission callback. Keep a read/withdraw+ // behind that post, and a later notification behind the withdraw, so an old+ // asynchronous post cannot bring back a message that was already read.+ void _ordered(String id, Future<void> Function() operation) {+ final previous = _pending[id];+ late final Future<void> current;+ current =+ (previous == null+ ? Future<void>.sync(operation)+ : previous.then((_) => operation()))+ .catchError((_) {})+ .whenComplete(() {+ if (identical(_pending[id], current)) _pending.remove(id);+ });+ _pending[id] = current;+ }/// What the platform last answered. Settings reads it to explain a switch that/// is on but cannot do anything.@@ -328,8 +346,9 @@ class SystemNotifications {void post(AgentAlert alert) {if (!store.value || !supported) return;if (permission.value == NotificationPermission.unavailable) return;- unawaited(- notifier+ _ordered(+ idFor(alert.machineId, alert.agentId),+ () => notifier.show(id: idFor(alert.machineId, alert.agentId),title: alert.title,@@ -349,7 +368,8 @@ class SystemNotifications {/// The person got to this agent some other way. Its notification is old news.void withdraw(String machineId, String agentId) {if (!supported) return;- unawaited(notifier.withdraw(idFor(machineId, agentId)).catchError((_) {}));+ final id = idFor(machineId, agentId);+ _ordered(id, () => notifier.withdraw(id));}/// Where a click on a notification goes. Null stops listening.diff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dartindex cff7aa044..56203e0f2 100644--- a/desktop/lib/screens/swarm_screen.dart+++ b/desktop/lib/screens/swarm_screen.dart@@ -5247,14 +5247,20 @@ class _SwarmScreenState extends State<SwarmScreen> {).firstOrNull;if (destination == null) return false;+ final readToken = app.agentUnread.readTokenFor(row.machineId, row.agentId);+ final questionId = app.questionFor(row.machineId, row.agentId)?.requestId;final opened = await activateSwarmDestination(app,destination,destinationSwarmId: app.activeSwarmId,);- // Only successful navigation acknowledges a result. Questions remain- // pending until the daemon confirms they have been answered.- if (opened) app.markAgentSeen(row.machineId, row.agentId);+ // Opening acknowledges this notification. Its question stays pending+ // until the daemon confirms an answer, independently of unread state.+ if (opened &&+ app.agentUnread.readTokenFor(row.machineId, row.agentId) == readToken &&+ app.questionFor(row.machineId, row.agentId)?.requestId == questionId) {+ app.readAgentNotification(row.machineId, row.agentId, readToken: readToken);+ }return opened;},);diff --git a/desktop/lib/state/app_state.dart b/desktop/lib/state/app_state.dartindex bfabb4c7a..688955c26 100644--- a/desktop/lib/state/app_state.dart+++ b/desktop/lib/state/app_state.dart@@ -558,6 +558,10 @@ class AppNotifier extends ChangeNotifier {// Delivery deduplication only. The daemon owns notification eligibility for// both desktop and device; a raw turn_ended is not a completed result.final Set<String> _deliveredNotifications = {};+ // Read receipts suppress a restored question's notification, never the+ // question itself. A matching close or replacement gives the next one a+ // fresh identity; reconnecting the same question keeps it read.+ final Map<String, String> _readQuestionNotifications = {};AppConfig config;late ApiClient api;@@ -2566,6 +2570,7 @@ class AppNotifier extends ChangeNotifier {'agentId': mark.agentId,'machineId': mark.machineId,'question': mark.kind == AlertKind.needsYou,+ 'readToken': agentUnread.readTokenFor(mark.machineId, mark.agentId),// A QUESTION'S OWN WORDS, because nobody else has them. The daemon// fills in the recap for a finished turn from what it summarised, but// an open question lives here — in `blockedAgents` — and a dial that@@ -7538,25 +7543,57 @@ class AppNotifier extends ChangeNotifier {/// row for it too. Silent when there was no mark.void _forgetUnread(String machineId, String agentId) {if (agentUnread.kindFor(machineId, agentId) == null) return;+ final readToken = agentUnread.readTokenFor(machineId, agentId);agentUnread.clear(machineId, agentId);// Notification Center would otherwise keep saying "Finished" about an agent// the person has already gone and looked at.systemNotifications.withdraw(machineId, agentId);- _announceAgentSeen(machineId, agentId);+ agentAlerts.dismiss(+ AgentAlert(+ machineId: machineId, agentId: agentId,+ title: '', kind: AlertKind.done, at: DateTime.now(),+ ),+ );+ _announceAgentSeen(machineId, agentId, readToken);+ }++ /// Reading is not answering. A device receipt clears only the exact message+ /// it displayed; the pending question and all pane/focus state remain intact.+ void readAgentNotification(String machineId, String agentId, {String? readToken}) {+ if (readToken != null &&+ agentUnread.readTokenFor(machineId, agentId) != readToken) {+ return;+ }+ final question = questionFor(machineId, agentId);+ if (question != null) {+ final key = AgentUnread.keyFor(machineId, agentId);+ _readQuestionNotifications+ ..remove(key)+ ..[key] = question.requestId;+ while (_readQuestionNotifications.length > AgentUnread.capacity) {+ _readQuestionNotifications.remove(_readQuestionNotifications.keys.first);+ }+ }+ _forgetUnread(machineId, agentId);+ if (question != null) notifyListeners();+ }++ bool questionNotificationRead(String machineId, String agentId) {+ final question = questionFor(machineId, agentId);+ return question != null &&+ _readQuestionNotifications[AgentUnread.keyFor(machineId, agentId)] ==+ question.requestId;}/// Tell the daemon this harness has been looked at, so the dial drops its/// drawer row for it.///- /// The two screens take a notification away on different gestures — a tap on- /// the dial, a tab coming to the front here — and each has to reach the other- /// or the two numbers part company the first time either is used. The dial's- /// half already travels: a tap sends `agent.open`, which brings the harness- /// forward here, and the sweep above clears it as anything else would.+ /// Device reads arrive separately from pane-open actions. Both converge on+ /// the same unread state, which is broadcast to every attached dial.////// Guarded by the caller on "there was a mark", so an ordinary tab switch/// does not put a frame on every socket.- void _announceAgentSeen(String machineId, String agentId) {+ void _announceAgentSeen(String machineId, String agentId, String? readToken) {// No transport at all — a window still booting, or a plain `test()` with no// live pool. `_conn` asserts one exists rather than answering null, which// is right for the paths that cannot proceed without it and wrong for a@@ -7568,7 +7605,9 @@ class AppNotifier extends ChangeNotifier {try {unawaited(_conn(machineId)- .sendTerminalFrame('agent_seen', {'agentId': agentId})+ .sendTerminalFrame('agent_seen', {+ 'agentId': agentId, 'readToken': ?readToken,+ }).catchError((_) => false),);} on StateError {@@ -7614,7 +7653,7 @@ class AppNotifier extends ChangeNotifier {final agent = machine.agents.where((a) => a.id == agentId).firstOrNull;// Before the banner and outside its switch: the mark is what the window can// still say when somebody has turned the interrupting halves off.- agentUnread.mark(machine.machine.machineId, agentId, kind);+ agentUnread.mark(machine.machine.machineId, agentId, kind, fresh: true);alerts.play(kind);final alert = AgentAlert(machineId: machine.machine.machineId,@@ -7644,7 +7683,7 @@ class AppNotifier extends ChangeNotifier {/// Only an agent with no view at all is placed, on the current Swarm, in the/// same order [placeFork] uses for the same reason.Future<void> revealAgentFromAlert(String machineId, String agentId) async {- markAgentSeen(machineId, agentId);+ readAgentNotification(machineId, agentId);systemNotifications.withdraw(machineId, agentId);agentAlerts.dismiss(AgentAlert(@@ -13010,6 +13049,15 @@ class AppNotifier extends ChangeNotifier {}());}break;+ case 'dial_notification_read':+ final readId = payload['agentId'];+ final readMachine = payload['machineId'];+ final readToken = payload['readToken'];+ if (readId is String && readMachine is String &&+ readToken is String && readToken.isNotEmpty) {+ readAgentNotification(readMachine, readId, readToken: readToken);+ }+ break;case 'dial_open':// A notification was tapped on the dial. Unlike `dial_focus` this asks for a tile of its own —// see openAgentFromDial for why a finished turn is not a replacement for what is on screen.@@ -13121,7 +13169,10 @@ class AppNotifier extends ChangeNotifier {break;case 'agent_deleted':final goneId = _eventAgentId(machine, event, payload);- if (goneId != null) agentUnread.forget(machineId, goneId);+ if (goneId != null) {+ agentUnread.forget(machineId, goneId);+ _readQuestionNotifications.remove(AgentUnread.keyFor(machineId, goneId));+ }final agentId = _eventAgentId(machine, event, payload);if (agentId != null) {await _removeAgent(machine, agentId);@@ -13166,7 +13217,10 @@ class AppNotifier extends ChangeNotifier {// Only a NEW question earns a sound. The daemon re-announces every open one after a// reconnect and when attaching to a turn that was already mid-dialog, and a window// that beeped at those would sound an alarm every time the network hiccuped.- if (!repeat) _raiseAlert(machine, agentId, AlertKind.needsYou);+ if (!repeat && !questionNotificationRead(machineId, agentId)) {+ _readQuestionNotifications.remove(AgentUnread.keyFor(machineId, agentId));+ _raiseAlert(machine, agentId, AlertKind.needsYou);+ }}}break;@@ -13180,6 +13234,7 @@ class AppNotifier extends ChangeNotifier {final open = machine.blockedAgents[agentId];if (open != null && open.requestId == requestId) {machine.blockedAgents.remove(agentId);+ _readQuestionNotifications.remove(AgentUnread.keyFor(machineId, agentId));// An old question close cannot erase a newer completed result.if (agentUnread.kindFor(machineId, agentId) == AlertKind.needsYou) {_forgetUnread(machineId, agentId);diff --git a/desktop/lib/state/notification_inbox.dart b/desktop/lib/state/notification_inbox.dartindex 43c6942ff..8443844ee 100644--- a/desktop/lib/state/notification_inbox.dart+++ b/desktop/lib/state/notification_inbox.dart@@ -38,7 +38,8 @@ List<InboxNotification> notificationInbox(AppNotifier app) {// Questions survive a reconnect and remain actionable even if an old unread// mark was evicted. Merely opening this list never acknowledges a question.for (final row in harnessSessions(app)) {- if (row.needsInput) {+ if (row.needsInput &&+ !app.questionNotificationRead(row.machineId, row.agent.id)) {kinds[(row.machineId, row.agent.id)] = AlertKind.needsYou;}}diff --git a/desktop/lib/widgets/agent_alert_banners.dart b/desktop/lib/widgets/agent_alert_banners.dartindex 51e1769bd..f5e3a1b54 100644--- a/desktop/lib/widgets/agent_alert_banners.dart+++ b/desktop/lib/widgets/agent_alert_banners.dart@@ -137,7 +137,13 @@ class _Banner extends StatelessWidget {splashRadius: 14,visualDensity: VisualDensity.compact,tooltip: 'Dismiss',- onPressed: () => notifier.agentAlerts.dismiss(alert),+ onPressed: () {+ notifier.readAgentNotification(+ alert.machineId,+ alert.agentId,+ );+ notifier.agentAlerts.dismiss(alert);+ },),],),diff --git a/desktop/test/agent_unread_test.dart b/desktop/test/agent_unread_test.dartindex aa1208953..88a045067 100644--- a/desktop/test/agent_unread_test.dart+++ b/desktop/test/agent_unread_test.dart@@ -16,6 +16,26 @@ void main() {expect(unread.kindFor('m1', 'a1'), isNull);});+ test(+ 'fresh same-kind events and app instances cannot reuse a read token',+ () {+ unread.mark('m1', 'a', AlertKind.done);+ final first = unread.readTokenFor('m1', 'a');+ unread.mark('m1', 'a', AlertKind.done);+ expect(unread.readTokenFor('m1', 'a'), first);+ unread.mark('m1', 'a', AlertKind.done, fresh: true);+ final second = unread.readTokenFor('m1', 'a')!;+ expect(second, isNot(first));+ expect(second.length, lessThan(64));+ expect(RegExp(r'^[A-Za-z0-9_-]+$').hasMatch(second), isTrue);+ final other = AgentUnread()..mark('m1', 'a', AlertKind.done);+ expect(other.readTokenFor('m1', 'a'), isNot(second));+ other.dispose();+ unread.clear('m1', 'a');+ expect(unread.readTokenFor('m1', 'a'), isNull);+ },+ );+test('a mark says WHICH kind of news it is', () {unread.mark('m1', 'a1', AlertKind.done);expect(unread.kindFor('m1', 'a1'), AlertKind.done);diff --git a/desktop/test/notification_inbox_test.dart b/desktop/test/notification_inbox_test.dartindex bdf5efea3..c123de495 100644--- a/desktop/test/notification_inbox_test.dart+++ b/desktop/test/notification_inbox_test.dart@@ -238,12 +238,14 @@ void main() {await tester.pumpAndSettle();expect(inbox, findsNothing);expect(app.focusedPane?.agentId, 'a9');- expect(app.agentUnread.kindFor('m', 'a9'), AlertKind.needsYou);+ expect(app.agentUnread.kindFor('m', 'a9'), isNull);+ expect(app.questionFor('m', 'a9'), isNotNull);+ expect(notificationInbox(app), isEmpty);await open();await tester.sendKeyEvent(LogicalKeyboardKey.escape);await tester.pumpAndSettle();expect(inbox, findsNothing);- expect(app.agentUnread.count, 1);+ expect(app.agentUnread.count, 0);await tester.pump(const Duration(milliseconds: 350));await tester.pumpWidget(const SizedBox());app.dispose();diff --git a/desktop/test/notification_parity_test.dart b/desktop/test/notification_parity_test.dartindex 2a81b3b0e..0d0d8595d 100644--- a/desktop/test/notification_parity_test.dart+++ b/desktop/test/notification_parity_test.dart@@ -11,6 +11,7 @@import 'package:flutter_test/flutter_test.dart';import 'package:harness/notify/alert_sounds.dart';import 'package:harness/state/app_state.dart';+import 'package:harness/state/notification_inbox.dart';import 'package:harness/ws/ws_conn.dart';import 'swarm_state_test.dart' show createApp;@@ -52,7 +53,16 @@ void main() {});tearDown(() => app.dispose());- Future<void> completed(String agentId, {bool? subagent}) =>+ Future<void> readFromDial(+ String agentId,+ String token, {+ String machine = 'm',+ }) => app.handleEventForTest('m', {+ 'type': 'dial_notification_read',+ 'payload': {'machineId': machine, 'agentId': agentId, 'readToken': token},+ });++ Future<void> completed(String agentId, {bool? subagent, int turn = 0}) =>app.handleEventForTest('m', {'type': 'turn_summary','agentId': agentId,@@ -60,7 +70,7 @@ void main() {'payload': <String, dynamic>{'summary': 'A real final answer',if (subagent != true)- 'notification': {'id': 'result-$agentId', 'kind': 'done'},+ 'notification': {'id': 'result-$agentId-$turn', 'kind': 'done'},},});@@ -85,6 +95,49 @@ void main() {'payload': <String, dynamic>{'requestId': 'req-$agentId'},});+ test('device reads clear only their exact occurrence without changing the workspace', () async {+ await completed('a1');+ final old = app.agentUnread.readTokenFor('m', 'a1')!;+ await completed('a1', turn: 1);+ final current = app.agentUnread.readTokenFor('m', 'a1')!;+ expect(current, isNot(old));+ final tab = app.activeSwarmId;+ final panes = app.activeSwarm.panes.toList();+ await readFromDial('a1', old);+ await readFromDial('a1', current, machine: 'wrong');+ expect(app.agentUnread.count, 1);+ await readFromDial('a1', current);+ await readFromDial('a1', current);+ expect(app.agentUnread.count, 0);+ expect(app.activeSwarmId, tab);+ expect(app.activeSwarm.panes, panes);+ });++ test(+ 'reading a question notification does not answer the pending question',+ () async {+ await question('a1');+ final pending = app.machineStates['m']!.blockedAgents['a1'];+ expect(pending, isNotNull);+ final token = app.agentUnread.readTokenFor('m', 'a1')!;+ await readFromDial('a1', token);+ expect(app.agentUnread.count, 0);+ expect(app.machineStates['m']!.blockedAgents['a1'], same(pending));+ expect(notificationInbox(app), isEmpty);+ await question('a1');+ expect(notificationInbox(app), isEmpty);+ app.machineStates['m']!.blockedAgents.clear(); // Reconnect restores it.+ await question('a1');+ expect(app.agentUnread.count, 0);+ expect(notificationInbox(app), isEmpty);+ await answered('a1');+ await question('a1'); // A later occurrence can ask the same words.+ expect(app.agentUnread.count, 1);+ expect(notificationInbox(app), hasLength(1));+ expect(app.agentUnread.readTokenFor('m', 'a1'), isNot(token));+ },+ );+group('a sub-agent is not news on either screen', () {test('a verified final result is counted', () async {await completed('a1');@@ -270,6 +323,7 @@ void main() {},});expect(wired.agentUnread.count, 1);+ final token = wired.agentUnread.readTokenFor('m', 'a1');wired.markAgentSeen('m', 'a1');await Future<void>.delayed(Duration.zero);@@ -278,7 +332,7 @@ void main() {expect(conn.sent.where((f) => f.type == 'agent_seen').map((f) => f.payload),[- {'agentId': 'a1'},+ {'agentId': 'a1', 'readToken': token},],);},diff --git a/desktop/test/system_notifications_test.dart b/desktop/test/system_notifications_test.dartindex 674375d02..110406b77 100644--- a/desktop/test/system_notifications_test.dart+++ b/desktop/test/system_notifications_test.dart@@ -1,6 +1,7 @@// The third alert channel: news the operating system delivers, so it reaches somebody whose window// is somewhere else. When it is posted, what replaces what, what takes it down, what a click does,// and how each platform's notifier is driven.+import 'dart:async';import 'dart:io' show ProcessException, ProcessResult;import 'package:flutter/material.dart';@@ -47,6 +48,7 @@ class _Recorder implements SystemNotifier {>[];final withdrawn = <String>[];int authorizations = 0;+ Completer<void>? showGate;void Function(String machineId, String agentId)? tap;@override@@ -76,6 +78,7 @@ class _Recorder implements SystemNotifier {machineId: machineId,agentId: agentId,));+ await showGate?.future;return answer;}@@ -142,6 +145,21 @@ void main() {});group('posting', () {+ test('a delayed OS post cannot resurrect a message already read', () async {+ final os = _Recorder()..showGate = Completer<void>();+ final system = SystemNotifications(store: store(), notifier: os);+ system.post(_alert('a'));+ system.withdraw('m1', 'a');+ system.post(_alert('a', title: 'New turn'));+ expect(os.shown, hasLength(1));+ expect(os.withdrawn, isEmpty);+ os.showGate!.complete();+ await Future<void>.delayed(Duration.zero);+ expect(os.withdrawn, [SystemNotifications.idFor('m1', 'a')]);+ expect(os.shown, hasLength(2));+ expect(os.shown.last.title, 'New turn');+ });+test('nothing while the switch is off', () async {final os = _Recorder();SystemNotifications(@@ -161,14 +179,13 @@ void main() {system.post(_alert('a', kind: AlertKind.needsYou, title: 'Fix login'));system.post(_alert('b'));await Future<void>.delayed(Duration.zero);- expect(os.shown.map((s) => s.body), [- 'Finished',- 'Waiting on you',- 'Finished',- ]);+ final a = os.shown.where((s) => s.agentId == 'a').toList();+ final b = os.shown.where((s) => s.agentId == 'b').single;+ expect(a.map((s) => s.body), ['Finished', 'Waiting on you']);+ expect(b.body, 'Finished');expect(os.shown.first.title, 'Fix login');- expect(os.shown[0].id, os.shown[1].id);- expect(os.shown[0].id, isNot(os.shown[2].id));+ expect(a[0].id, a[1].id);+ expect(a[0].id, isNot(b.id));expect(os.shown.first.machineId, 'm1');expect(os.shown.first.agentId, 'a');},@@ -272,6 +289,23 @@ void main() {addTearDown(app.dispose);await finish(app);app.markAgentSeen('m1', 'a1');+ await Future<void>.delayed(Duration.zero);+ expect(os.withdrawn, [SystemNotifications.idFor('m1', 'a1')]);+ });++ test('reading on the dial withdraws the banner and system notification', () async {+ final app = wired();+ addTearDown(app.dispose);+ await finish(app);+ await Future<void>.delayed(Duration.zero);+ expect(app.agentAlerts.alerts, hasLength(1));+ final token = app.agentUnread.readTokenFor('m1', 'a1')!;+ await app.handleMachineEventForTest('m1', {+ 'type': 'dial_notification_read',+ 'payload': {'machineId': 'm1', 'agentId': 'a1', 'readToken': token},+ });+ expect(app.agentUnread.count, 0);+ expect(app.agentAlerts.alerts, isEmpty);expect(os.withdrawn, [SystemNotifications.idFor('m1', 'a1')]);});});diff --git a/devices/harness-device/firmware/main/cable_client.c b/devices/harness-device/firmware/main/cable_client.cindex 4bef34c27..2091babb0 100644--- a/devices/harness-device/firmware/main/cable_client.c+++ b/devices/harness-device/firmware/main/cable_client.c@@ -236,6 +236,16 @@ void cable_client_send_open(const char *agent_id, const char *reason)send_json(root);}+bool cable_client_notification_read(const char *agent_id, const char *read_token)+{+ if (!agent_id || !agent_id[0] || strlen(agent_id) >= ID_MAX ||+ !read_token || !read_token[0] || strlen(read_token) >= CABLE_READ_TOKEN_MAX) return false;+ cJSON *root = msg("notif.read");+ msg_string(&root, "agentId", agent_id);+ msg_string(&root, "readToken", read_token);+ return send_json(root);+}+void cable_client_send_scroll(cable_scroll_phase_t phase, int dy, int velocity){_Static_assert(CABLE_SCROLL_DOWN == 0 && CABLE_SCROLL_MOVE == 1 && CABLE_SCROLL_UP == 2,@@ -954,6 +964,9 @@ static void handle_notifications(const cJSON *p)snprintf(rows[n].summary, sizeof(rows[n].summary), "%s", str_of(it, "summary") ? str_of(it, "summary") : "");rows[n].question = bool_of(it, "question");rows[n].failed = bool_of(it, "failed");+ const char *token = str_of(it, "readToken");+ if (token && token[0] && strlen(token) < sizeof rows[n].read_token)+ snprintf(rows[n].read_token, sizeof rows[n].read_token, "%s", token);n++;}ui_notif_replace(rows, n);@@ -1087,7 +1100,12 @@ static void handle_message(const cJSON *root)// empty — see ui_notif_replace.if (strcmp(t, "notif.replace") == 0) { handle_notifications(p); return; }if (strcmp(t, "notif.seen") == 0) {- if (agent_id) ui_notif_seen(agent_id);+ const cJSON *token = cJSON_GetObjectItemCaseSensitive(p, "readToken");+ if (agent_id && token) {+ if (cJSON_IsString(token) && token->valuestring[0] &&+ strlen(token->valuestring) < CABLE_READ_TOKEN_MAX)+ ui_notif_read(agent_id, token->valuestring);+ } else if (agent_id) ui_notif_seen(agent_id);return;}if (strcmp(t, "turn.error") == 0) {diff --git a/devices/harness-device/firmware/main/cable_client.h b/devices/harness-device/firmware/main/cable_client.hindex 19464a2df..c3f1d59bb 100644--- a/devices/harness-device/firmware/main/cable_client.h+++ b/devices/harness-device/firmware/main/cable_client.h@@ -197,11 +197,14 @@ typedef struct {// One row of the window's unread list, as `notif.replace` carries it. `summary` is// the finished turn's recap or the question's own words. Match the home preview's// byte capacity so an 80-character recap with UTF-8 punctuation arrives intact.+// Opaque desktop notification identity, including terminator.+#define CABLE_READ_TOKEN_MAX 64typedef struct {char agent_id[ID_MAX];char name[CABLE_NAME_MAX];char machine[CABLE_NAME_MAX];char summary[240];+ char read_token[CABLE_READ_TOKEN_MAX];bool question;bool failed; // Optional explicit host metadata; never inferred from prose.// Local display bookkeeping. Incoming snapshots never supply these values.@@ -209,6 +212,8 @@ typedef struct {uint32_t display_revision;} cable_notif_t;+bool cable_client_notification_read(const char *agent_id, const char *read_token);+// The user tapped a swarm. Not answered — see above.void cable_client_select_swarm(const char *swarm_id);// Re-ask for the list (a screen that just opened wants it fresh).diff --git a/devices/harness-device/firmware/main/ui/habitat/character_layout.c b/devices/harness-device/firmware/main/ui/habitat/character_layout.cindex f36bd7f27..dd3da933c 100644--- a/devices/harness-device/firmware/main/ui/habitat/character_layout.c+++ b/devices/harness-device/firmware/main/ui/habitat/character_layout.c@@ -60,7 +60,7 @@ static void lines(ht_scene_t *s, int y, int width, int count, const ht_font_t *fconst char *rest = text;for (int row = 0; row < count; row++) {int w = widths ? widths[row] : width;- const char *begin = rest, *end = ht_take_line(&rest, w / font->width);+ const char *begin = rest, *end = ht_take_display_line(&rest, w / font->width, font);char line[HT_TEXT_BYTES];size_t n = (size_t)(end - begin);if (n >= sizeof line) n = sizeof line - 1;@@ -91,16 +91,10 @@ static void recap_lines(ht_scene_t *s, int y, int width, int rows, bool centered// Summary text has no action glyph. Only incomplete prose gets an ellipsis;// the desktop action lives in the inbox footer. Bound cached UTF-8 input.char marked[7 * HT_TEXT_BYTES + 4];- size_t used = 0;- const char *p = recap ? recap : "";- while (*p) {- const char *start = p;- ht_utf8_next(&p);- size_t bytes = (size_t)(p - start);- if (used + bytes + 4 > sizeof marked) break;- memcpy(marked + used, start, bytes);- used += bytes;- }+ // Normalize before the character budget and round-screen line wrapping.+ // The stored message remains untouched; ⅓ occupies three display cells.+ ht_display_text(marked,sizeof marked - 3,recap,font);+ size_t used = strlen(marked);while (used && marked[used - 1] == ' ') used--;marked[used] = 0;if (used >= 2 && !strcmp(marked + used - 2, " +"))diff --git a/devices/harness-device/firmware/main/ui/habitat/display_fallbacks.inc b/devices/harness-device/firmware/main/ui/habitat/display_fallbacks.incnew file mode 100644index 000000000..f9789d263--- /dev/null+++ b/devices/harness-device/firmware/main/ui/habitat/display_fallbacks.inc@@ -0,0 +1,1711 @@+// Generated by scripts/gen_display_fallbacks.py; Unicode 16.0.0.+// Display-only equivalents. Original messages and identities stay unchanged.+static const struct { uint32_t first, last; int32_t delta; } display_ranges[] = {+ {0x1d33,0x1d3a,-7404},+ {0x2119,0x211b,-8393},+ {0x2460,0x2468,-9263},+ {0x24b6,0x24cf,-9333},+ {0x24d0,0x24e9,-9327},+ {0xff01,0xff5e,-65248},+ {0x1ccd6,0x1ccef,-117909},+ {0x1ccf0,0x1ccf9,-117952},+ {0x1d400,0x1d419,-119743},+ {0x1d41a,0x1d433,-119737},+ {0x1d434,0x1d44d,-119795},+ {0x1d44e,0x1d454,-119789},+ {0x1d456,0x1d467,-119789},+ {0x1d468,0x1d481,-119847},+ {0x1d482,0x1d49b,-119841},+ {0x1d4a9,0x1d4ac,-119899},+ {0x1d4ae,0x1d4b5,-119899},+ {0x1d4b6,0x1d4b9,-119893},+ {0x1d4bd,0x1d4c3,-119893},+ {0x1d4c5,0x1d4cf,-119893},+ {0x1d4d0,0x1d4e9,-119951},+ {0x1d4ea,0x1d503,-119945},+ {0x1d507,0x1d50a,-120003},+ {0x1d50d,0x1d514,-120003},+ {0x1d516,0x1d51c,-120003},+ {0x1d51e,0x1d537,-119997},+ {0x1d53b,0x1d53e,-120055},+ {0x1d540,0x1d544,-120055},+ {0x1d54a,0x1d550,-120055},+ {0x1d552,0x1d56b,-120049},+ {0x1d56c,0x1d585,-120107},+ {0x1d586,0x1d59f,-120101},+ {0x1d5a0,0x1d5b9,-120159},+ {0x1d5ba,0x1d5d3,-120153},+ {0x1d5d4,0x1d5ed,-120211},+ {0x1d5ee,0x1d607,-120205},+ {0x1d608,0x1d621,-120263},+ {0x1d622,0x1d63b,-120257},+ {0x1d63c,0x1d655,-120315},+ {0x1d656,0x1d66f,-120309},+ {0x1d670,0x1d689,-120367},+ {0x1d68a,0x1d6a3,-120361},+ {0x1d7ce,0x1d7d7,-120734},+ {0x1d7d8,0x1d7e1,-120744},+ {0x1d7e2,0x1d7eb,-120754},+ {0x1d7ec,0x1d7f5,-120764},+ {0x1d7f6,0x1d7ff,-120774},+ {0x1f130,0x1f149,-127215},+ {0x1fbf0,0x1fbf9,-129984},+};+static const char display_pool[] =+ " \000"+ "GBP\000"+ "JPY\000"+ "(C)\000"+ "a\000"+ "\000"+ "(R)\000"+ "+/-\000"+ "^2\000"+ "^3\000"+ "^1\000"+ "o\000"+ "1/4\000"+ "1/2\000"+ "3/4\000"+ "A\000"+ "C\000"+ "E\000"+ "I\000"+ "N\000"+ "O\000"+ "x\000"+ "U\000"+ "Y\000"+ "c\000"+ "e\000"+ "i\000"+ "n\000"+ "u\000"+ "y\000"+ "D\000"+ "d\000"+ "G\000"+ "g\000"+ "H\000"+ "h\000"+ "IJ\000"+ "ij\000"+ "J\000"+ "j\000"+ "K\000"+ "k\000"+ "L\000"+ "l\000"+ "R\000"+ "r\000"+ "S\000"+ "s\000"+ "T\000"+ "t\000"+ "W\000"+ "w\000"+ "Z\000"+ "z\000"+ "DZ\000"+ "Dz\000"+ "dz\000"+ "LJ\000"+ "Lj\000"+ "lj\000"+ "NJ\000"+ "Nj\000"+ "nj\000"+ ";\000"+ "pi\000"+ "B\000"+ "P\000"+ "b\000"+ "m\000"+ "p\000"+ "v\000"+ "f\000"+ "F\000"+ "M\000"+ "V\000"+ "X\000"+ "`\000"+ "-\000"+ "'\000"+ "\"\000"+ "*\000"+ ".\000"+ "..\000"+ "...\000"+ "[!]\000"+ "/\000"+ "??\000"+ "?!\000"+ "!?\000"+ "^0\000"+ "^i\000"+ "^4\000"+ "^5\000"+ "^6\000"+ "^7\000"+ "^8\000"+ "^9\000"+ "^+\000"+ "^=\000"+ "^(\000"+ "^)\000"+ "^n\000"+ "_0\000"+ "_1\000"+ "_2\000"+ "_3\000"+ "_4\000"+ "_5\000"+ "_6\000"+ "_7\000"+ "_8\000"+ "_9\000"+ "_+\000"+ "_=\000"+ "_(\000"+ "_)\000"+ "_a\000"+ "_e\000"+ "_o\000"+ "_x\000"+ "_h\000"+ "_k\000"+ "_l\000"+ "_m\000"+ "_n\000"+ "_p\000"+ "_s\000"+ "_t\000"+ "Rs\000"+ "EUR\000"+ "a/c\000"+ "a/s\000"+ "c/o\000"+ "c/u\000"+ "No\000"+ "SM\000"+ "TEL\000"+ "(TM)\000"+ "FAX\000"+ "1/7\000"+ "1/9\000"+ "1/10\000"+ "1/3\000"+ "2/3\000"+ "1/5\000"+ "2/5\000"+ "3/5\000"+ "4/5\000"+ "1/6\000"+ "5/6\000"+ "1/8\000"+ "3/8\000"+ "5/8\000"+ "7/8\000"+ "1/\000"+ "II\000"+ "III\000"+ "IV\000"+ "VI\000"+ "VII\000"+ "VIII\000"+ "IX\000"+ "XI\000"+ "XII\000"+ "ii\000"+ "iii\000"+ "iv\000"+ "vi\000"+ "vii\000"+ "viii\000"+ "ix\000"+ "xi\000"+ "xii\000"+ "0/3\000"+ "<-\000"+ "^\000"+ "->\000"+ "<->\000"+ "<^\000"+ "^>\000"+ "v>\000"+ "<v\000"+ "[return]\000"+ "=>\000"+ "<=>\000"+ "sum\000"+ "-/+\000"+ "sqrt\000"+ "infinity\000"+ "~=\000"+ "!=\000"+ "<=\000"+ ">=\000"+ "!<\000"+ "!>\000"+ "!<=\000"+ "!>=\000"+ "10\000"+ "11\000"+ "12\000"+ "13\000"+ "14\000"+ "15\000"+ "16\000"+ "17\000"+ "18\000"+ "19\000"+ "20\000"+ "(1)\000"+ "(2)\000"+ "(3)\000"+ "(4)\000"+ "(5)\000"+ "(6)\000"+ "(7)\000"+ "(8)\000"+ "(9)\000"+ "(10)\000"+ "(11)\000"+ "(12)\000"+ "(13)\000"+ "(14)\000"+ "(15)\000"+ "(16)\000"+ "(17)\000"+ "(18)\000"+ "(19)\000"+ "(20)\000"+ "1.\000"+ "2.\000"+ "3.\000"+ "4.\000"+ "5.\000"+ "6.\000"+ "7.\000"+ "8.\000"+ "9.\000"+ "10.\000"+ "11.\000"+ "12.\000"+ "13.\000"+ "14.\000"+ "15.\000"+ "16.\000"+ "17.\000"+ "18.\000"+ "19.\000"+ "20.\000"+ "(a)\000"+ "(b)\000"+ "(c)\000"+ "(d)\000"+ "(e)\000"+ "(f)\000"+ "(g)\000"+ "(h)\000"+ "(i)\000"+ "(j)\000"+ "(k)\000"+ "(l)\000"+ "(m)\000"+ "(n)\000"+ "(o)\000"+ "(p)\000"+ "(q)\000"+ "(r)\000"+ "(s)\000"+ "(t)\000"+ "(u)\000"+ "(v)\000"+ "(w)\000"+ "(x)\000"+ "(y)\000"+ "(z)\000"+ "0\000"+ "[ok]\000"+ "[heart]\000"+ "[settings]\000"+ "[x]\000"+ "[?]\000"+ "::=\000"+ "==\000"+ "===\000"+ "PTE\000"+ "21\000"+ "22\000"+ "23\000"+ "24\000"+ "25\000"+ "26\000"+ "27\000"+ "28\000"+ "29\000"+ "30\000"+ "31\000"+ "32\000"+ "33\000"+ "34\000"+ "35\000"+ "36\000"+ "37\000"+ "38\000"+ "39\000"+ "40\000"+ "41\000"+ "42\000"+ "43\000"+ "44\000"+ "45\000"+ "46\000"+ "47\000"+ "48\000"+ "49\000"+ "50\000"+ "Hg\000"+ "erg\000"+ "eV\000"+ "LTD\000"+ "hPa\000"+ "da\000"+ "AU\000"+ "bar\000"+ "oV\000"+ "pc\000"+ "dm\000"+ "dm2\000"+ "dm3\000"+ "IU\000"+ "pA\000"+ "nA\000"+ "mA\000"+ "kA\000"+ "KB\000"+ "MB\000"+ "GB\000"+ "cal\000"+ "kcal\000"+ "pF\000"+ "nF\000"+ "mg\000"+ "kg\000"+ "Hz\000"+ "kHz\000"+ "MHz\000"+ "GHz\000"+ "THz\000"+ "ml\000"+ "dl\000"+ "kl\000"+ "fm\000"+ "nm\000"+ "mm\000"+ "cm\000"+ "km\000"+ "mm2\000"+ "cm2\000"+ "m2\000"+ "km2\000"+ "mm3\000"+ "cm3\000"+ "m3\000"+ "km3\000"+ "Pa\000"+ "kPa\000"+ "MPa\000"+ "GPa\000"+ "rad\000"+ "ps\000"+ "ns\000"+ "ms\000"+ "pV\000"+ "nV\000"+ "mV\000"+ "kV\000"+ "MV\000"+ "pW\000"+ "nW\000"+ "mW\000"+ "kW\000"+ "MW\000"+ "a.m.\000"+ "Bq\000"+ "cc\000"+ "cd\000"+ "Co.\000"+ "dB\000"+ "Gy\000"+ "ha\000"+ "HP\000"+ "in\000"+ "KK\000"+ "KM\000"+ "kt\000"+ "lm\000"+ "ln\000"+ "log\000"+ "lx\000"+ "mb\000"+ "mil\000"+ "mol\000"+ "PH\000"+ "p.m.\000"+ "PPM\000"+ "PR\000"+ "sr\000"+ "Sv\000"+ "Wb\000"+ "gal\000"+ "Q\000"+ "ff\000"+ "fi\000"+ "fl\000"+ "ffi\000"+ "ffl\000"+ "st\000"+ "+\000"+ ",\000"+ ":\000"+ "!\000"+ "?\000"+ "_\000"+ "(\000"+ ")\000"+ "{\000"+ "}\000"+ "[\000"+ "]\000"+ "#\000"+ "&\000"+ "<\000"+ ">\000"+ "=\000"+ "\\\000"+ "$\000"+ "%\000"+ "@\000"+ "q\000"+ "0.\000"+ "0,\000"+ "1,\000"+ "2,\000"+ "3,\000"+ "4,\000"+ "5,\000"+ "6,\000"+ "7,\000"+ "8,\000"+ "9,\000"+ "(A)\000"+ "(B)\000"+ "(D)\000"+ "(E)\000"+ "(F)\000"+ "(G)\000"+ "(H)\000"+ "(I)\000"+ "(J)\000"+ "(K)\000"+ "(L)\000"+ "(M)\000"+ "(N)\000"+ "(O)\000"+ "(P)\000"+ "(Q)\000"+ "(S)\000"+ "(T)\000"+ "(U)\000"+ "(V)\000"+ "(W)\000"+ "(X)\000"+ "(Y)\000"+ "(Z)\000"+ "CD\000"+ "WZ\000"+ "HV\000"+ "SD\000"+ "SS\000"+ "PPV\000"+ "WC\000"+ "MC\000"+ "MD\000"+ "MR\000"+ "DJ\000"+ "[celebrate]\000"+ "[bug]\000"+ "[up]\000"+ "[down]\000"+ "[idea]\000"+ "[computer]\000"+ "[folder]\000"+ "[file]\000"+ "[pin]\000"+ "[note]\000"+ "[locked]\000"+ "[unlocked]\000"+ "[bell]\000"+ "[fire]\000"+ "[tool]\000"+ "[launch]\000"+ "[stop]\000"+ "[test]\000"+;+enum { DISPLAY_OFFSET_BITS = 11, DISPLAY_OFFSET_MASK = 2047 };+static const uint32_t display_entries[] = {+ 0x50000,+ 0x51802,+ 0x52806,+ 0x5480a,+ 0x5500e,+ 0x56810,+ 0x57011,+ 0x58815,+ 0x59019,+ 0x5981c,+ 0x5c81f,+ 0x5d022,+ 0x5e024,+ 0x5e828,+ 0x5f02c,+ 0x60030,+ 0x60830,+ 0x61030,+ 0x61830,+ 0x62030,+ 0x62830,+ 0x63832,+ 0x64034,+ 0x64834,+ 0x65034,+ 0x65834,+ 0x66036,+ 0x66836,+ 0x67036,+ 0x67836,+ 0x68838,+ 0x6903a,+ 0x6983a,+ 0x6a03a,+ 0x6a83a,+ 0x6b03a,+ 0x6b83c,+ 0x6c83e,+ 0x6d03e,+ 0x6d83e,+ 0x6e03e,+ 0x6e840,+ 0x7000e,+ 0x7080e,+ 0x7100e,+ 0x7180e,+ 0x7200e,+ 0x7280e,+ 0x73842,+ 0x74044,+ 0x74844,+ 0x75044,+ 0x75844,+ 0x76046,+ 0x76846,+ 0x77046,+ 0x77846,+ 0x78848,+ 0x79022,+ 0x79822,+ 0x7a022,+ 0x7a822,+ 0x7b022,+ 0x7c84a,+ 0x7d04a,+ 0x7d84a,+ 0x7e04a,+ 0x7e84c,+ 0x7f84c,+ 0x80030,+ 0x8080e,+ 0x81030,+ 0x8180e,+ 0x82030,+ 0x8280e,+ 0x83032,+ 0x83842,+ 0x84032,+ 0x84842,+ 0x85032,+ 0x85842,+ 0x86032,+ 0x86842,+ 0x8704e,+ 0x87850,+ 0x89034,+ 0x89844,+ 0x8a034,+ 0x8a844,+ 0x8b034,+ 0x8b844,+ 0x8c034,+ 0x8c844,+ 0x8d034,+ 0x8d844,+ 0x8e052,+ 0x8e854,+ 0x8f052,+ 0x8f854,+ 0x90052,+ 0x90854,+ 0x91052,+ 0x91854,+ 0x92056,+ 0x92858,+ 0x94036,+ 0x94846,+ 0x95036,+ 0x95846,+ 0x96036,+ 0x96846,+ 0x97036,+ 0x97846,+ 0x98036,+ 0x9905a,+ 0x9985d,+ 0x9a060,+ 0x9a862,+ 0x9b064,+ 0x9b866,+ 0x9c868,+ 0x9d06a,+ 0x9d868,+ 0x9e06a,+ 0x9e868,+ 0x9f06a,+ 0xa1838,+ 0xa2048,+ 0xa2838,+ 0xa3048,+ 0xa3838,+ 0xa4048,+ 0xa603a,+ 0xa6822,+ 0xa703a,+ 0xa7822,+ 0xa803a,+ 0xa8822,+ 0xaa06c,+ 0xaa86e,+ 0xab06c,+ 0xab86e,+ 0xac06c,+ 0xac86e,+ 0xad070,+ 0xad872,+ 0xae070,+ 0xae872,+ 0xaf070,+ 0xaf872,+ 0xb0070,+ 0xb0872,+ 0xb1074,+ 0xb1876,+ 0xb2074,+ 0xb2876,+ 0xb403e,+ 0xb484a,+ 0xb503e,+ 0xb584a,+ 0xb603e,+ 0xb684a,+ 0xb703e,+ 0xb784a,+ 0xb803e,+ 0xb884a,+ 0xb903e,+ 0xb984a,+ 0xba078,+ 0xba87a,+ 0xbb040,+ 0xbb84c,+ 0xbc040,+ 0xbc87c,+ 0xbd07e,+ 0xbd87c,+ 0xbe07e,+ 0xbe87c,+ 0xbf07e,+ 0xbf872,+ 0xd003a,+ 0xd0822,+ 0xd783e,+ 0xd804a,+ 0xe2080,+ 0xe2883,+ 0xe3086,+ 0xe3889,+ 0xe408c,+ 0xe488f,+ 0xe5092,+ 0xe5895,+ 0xe6098,+ 0xe6830,+ 0xe700e,+ 0xe7836,+ 0xe8046,+ 0xe883a,+ 0xe9022,+ 0xe983e,+ 0xea04a,+ 0xea83e,+ 0xeb04a,+ 0xeb83e,+ 0xec04a,+ 0xec83e,+ 0xed04a,+ 0xed83e,+ 0xee04a,+ 0xef030,+ 0xef80e,+ 0xf0030,+ 0xf080e,+ 0xf3052,+ 0xf3854,+ 0xf4064,+ 0xf4866,+ 0xf503a,+ 0xf5822,+ 0xf603a,+ 0xf6822,+ 0xf8062,+ 0xf8880,+ 0xf9083,+ 0xf9886,+ 0xfa052,+ 0xfa854,+ 0xfc038,+ 0xfc848,+ 0xfd030,+ 0xfd80e,+ 0x100030,+ 0x10080e,+ 0x101030,+ 0x10180e,+ 0x102034,+ 0x102844,+ 0x103034,+ 0x103844,+ 0x104036,+ 0x104846,+ 0x105036,+ 0x105846,+ 0x10603a,+ 0x106822,+ 0x10703a,+ 0x107822,+ 0x10806c,+ 0x10886e,+ 0x10906c,+ 0x10986e,+ 0x10a03e,+ 0x10a84a,+ 0x10b03e,+ 0x10b84a,+ 0x10c070,+ 0x10c872,+ 0x10d074,+ 0x10d876,+ 0x10f056,+ 0x10f858,+ 0x113030,+ 0x11380e,+ 0x114034,+ 0x114844,+ 0x11503a,+ 0x115822,+ 0x11603a,+ 0x116822,+ 0x11703a,+ 0x117822,+ 0x11803a,+ 0x118822,+ 0x119040,+ 0x11984c,+ 0x158058,+ 0x159062,+ 0x15986e,+ 0x15b87a,+ 0x15c04c,+ 0x17086a,+ 0x171072,+ 0x17183c,+ 0x1bf09b,+ 0x1e009d,+ 0xb40000,+ 0xe96030,+ 0xe970a0,+ 0xe9804e,+ 0xe98834,+ 0xe9e03a,+ 0xe9f0a2,+ 0xe9f86c,+ 0xea0074,+ 0xea083e,+ 0xea1078,+ 0xea180e,+ 0xea38a4,+ 0xea4050,+ 0xea4844,+ 0xea6854,+ 0xea7866,+ 0xea80a6,+ 0xea9022,+ 0xeab0a8,+ 0xeab876,+ 0xeac04a,+ 0xead8aa,+ 0xeb1046,+ 0xeb186e,+ 0xeb204a,+ 0xeb28aa,+ 0xece042,+ 0xed00ac,+ 0xedd87e,+ 0xf00030,+ 0xf0080e,+ 0xf010a0,+ 0xf018a4,+ 0xf020a0,+ 0xf028a4,+ 0xf030a0,+ 0xf038a4,+ 0xf04032,+ 0xf04842,+ 0xf0504e,+ 0xf05850,+ 0xf0604e,+ 0xf06850,+ 0xf0704e,+ 0xf07850,+ 0xf0804e,+ 0xf08850,+ 0xf0904e,+ 0xf09850,+ 0xf0a034,+ 0xf0a844,+ 0xf0b034,+ 0xf0b844,+ 0xf0c034,+ 0xf0c844,+ 0xf0d034,+ 0xf0d844,+ 0xf0e034,+ 0xf0e844,+ 0xf0f0ae,+ 0xf0f8ac,+ 0xf10052,+ 0xf10854,+ 0xf11056,+ 0xf11858,+ 0xf12056,+ 0xf12858,+ 0xf13056,+ 0xf13858,+ 0xf14056,+ 0xf14858,+ 0xf15056,+ 0xf15858,+ 0xf16036,+ 0xf16846,+ 0xf17036,+ 0xf17846,+ 0xf18064,+ 0xf18866,+ 0xf19064,+ 0xf19866,+ 0xf1a064,+ 0xf1a866,+ 0xf1b068,+ 0xf1b86a,+ 0xf1c068,+ 0xf1c86a,+ 0xf1d068,+ 0xf1d86a,+ 0xf1e068,+ 0xf1e86a,+ 0xf1f0b0,+ 0xf1f8a6,+ 0xf200b0,+ 0xf208a6,+ 0xf210b0,+ 0xf218a6,+ 0xf22038,+ 0xf22848,+ 0xf23038,+ 0xf23848,+ 0xf24038,+ 0xf24848,+ 0xf25038,+ 0xf25848,+ 0xf2603a,+ 0xf26822,+ 0xf2703a,+ 0xf27822,+ 0xf2803a,+ 0xf28822,+ 0xf2903a,+ 0xf29822,+ 0xf2a0a2,+ 0xf2a8a8,+ 0xf2b0a2,+ 0xf2b8a8,+ 0xf2c06c,+ 0xf2c86e,+ 0xf2d06c,+ 0xf2d86e,+ 0xf2e06c,+ 0xf2e86e,+ 0xf2f06c,+ 0xf2f86e,+ 0xf30070,+ 0xf30872,+ 0xf31070,+ 0xf31872,+ 0xf32070,+ 0xf32872,+ 0xf33070,+ 0xf33872,+ 0xf34070,+ 0xf34872,+ 0xf35074,+ 0xf35876,+ 0xf36074,+ 0xf36876,+ 0xf37074,+ 0xf37876,+ 0xf38074,+ 0xf38876,+ 0xf3903e,+ 0xf3984a,+ 0xf3a03e,+ 0xf3a84a,+ 0xf3b03e,+ 0xf3b84a,+ 0xf3c03e,+ 0xf3c84a,+ 0xf3d03e,+ 0xf3d84a,+ 0xf3e0b2,+ 0xf3e8aa,+ 0xf3f0b2,+ 0xf3f8aa,+ 0xf40078,+ 0xf4087a,+ 0xf41078,+ 0xf4187a,+ 0xf42078,+ 0xf4287a,+ 0xf43078,+ 0xf4387a,+ 0xf44078,+ 0xf4487a,+ 0xf450b4,+ 0xf4583c,+ 0xf460b4,+ 0xf4683c,+ 0xf47040,+ 0xf4784c,+ 0xf4807c,+ 0xf4887e,+ 0xf4907c,+ 0xf4987e,+ 0xf4a07c,+ 0xf4a87e,+ 0xf4b058,+ 0xf4b876,+ 0xf4c07a,+ 0xf4c84c,+ 0xf4d872,+ 0xf50030,+ 0xf5080e,+ 0xf51030,+ 0xf5180e,+ 0xf52030,+ 0xf5280e,+ 0xf53030,+ 0xf5380e,+ 0xf54030,+ 0xf5480e,+ 0xf55030,+ 0xf5580e,+ 0xf56030,+ 0xf5680e,+ 0xf57030,+ 0xf5780e,+ 0xf58030,+ 0xf5880e,+ 0xf59030,+ 0xf5980e,+ 0xf5a030,+ 0xf5a80e,+ 0xf5b030,+ 0xf5b80e,+ 0xf5c034,+ 0xf5c844,+ 0xf5d034,+ 0xf5d844,+ 0xf5e034,+ 0xf5e844,+ 0xf5f034,+ 0xf5f844,+ 0xf60034,+ 0xf60844,+ 0xf61034,+ 0xf61844,+ 0xf62034,+ 0xf62844,+ 0xf63034,+ 0xf63844,+ 0xf64036,+ 0xf64846,+ 0xf65036,+ 0xf65846,+ 0xf6603a,+ 0xf66822,+ 0xf6703a,+ 0xf67822,+ 0xf6803a,+ 0xf68822,+ 0xf6903a,+ 0xf69822,+ 0xf6a03a,+ 0xf6a822,+ 0xf6b03a,+ 0xf6b822,+ 0xf6c03a,+ 0xf6c822,+ 0xf6d03a,+ 0xf6d822,+ 0xf6e03a,+ 0xf6e822,+ 0xf6f03a,+ 0xf6f822,+ 0xf7003a,+ 0xf70822,+ 0xf7103a,+ 0xf71822,+ 0xf7203e,+ 0xf7284a,+ 0xf7303e,+ 0xf7384a,+ 0xf7403e,+ 0xf7484a,+ 0xf7503e,+ 0xf7584a,+ 0xf7603e,+ 0xf7684a,+ 0xf7703e,+ 0xf7784a,+ 0xf7803e,+ 0xf7884a,+ 0xf79040,+ 0xf7984c,+ 0xf7a040,+ 0xf7a84c,+ 0xf7b040,+ 0xf7b84c,+ 0xf7c040,+ 0xf7c84c,+ 0xff78b6,+ 0x1000000,+ 0x1000800,+ 0x1001000,+ 0x1001800,+ 0x1002000,+ 0x1002800,+ 0x1003000,+ 0x1003800,+ 0x1004000,+ 0x1004800,+ 0x1005000,+ 0x1005810,+ 0x1006010,+ 0x1006810,+ 0x10080b8,+ 0x10088b8,+ 0x10090b8,+ 0x10098b8,+ 0x100a0b8,+ 0x100a8b8,+ 0x100c0ba,+ 0x100c8ba,+ 0x100d0ba,+ 0x100d8ba,+ 0x100e0bc,+ 0x100e8bc,+ 0x100f0bc,+ 0x100f8bc,+ 0x10110be,+ 0x10118be,+ 0x10120c0,+ 0x10128c2,+ 0x10130c5,+ 0x1014000,+ 0x1014800,+ 0x1017800,+ 0x10190ba,+ 0x10198bc,+ 0x101e0c9,+ 0x10218be,+ 0x10220cd,+ 0x10238cf,+ 0x10240d2,+ 0x10248d5,+ 0x102f800,+ 0x1030010,+ 0x10380d8,+ 0x10388db,+ 0x103a0de,+ 0x103a8e1,+ 0x103b0e4,+ 0x103b8e7,+ 0x103c0ea,+ 0x103c8ed,+ 0x103d0f0,+ 0x103e0f3,+ 0x103e8f6,+ 0x103f0f9,+ 0x103f8fc,+ 0x10400ff,+ 0x1040902,+ 0x1041105,+ 0x1041908,+ 0x104210b,+ 0x104290e,+ 0x1043111,+ 0x1043914,+ 0x1044117,+ 0x104491a,+ 0x104511d,+ 0x1046120,+ 0x1046923,+ 0x1047126,+ 0x1048129,+ 0x104892c,+ 0x104912f,+ 0x1049932,+ 0x104a935,+ 0x104b138,+ 0x104b93b,+ 0x104c13e,+ 0x104c941,+ 0x104d144,+ 0x104d947,+ 0x104e14a,+ 0x105414d,+ 0x1056150,+ 0x1080154,+ 0x1080958,+ 0x1081032,+ 0x108295c,+ 0x1083160,+ 0x1085054,+ 0x1085856,+ 0x1086056,+ 0x1086856,+ 0x1087058,+ 0x1088036,+ 0x1088836,+ 0x1089068,+ 0x108986a,+ 0x108a838,+ 0x108b164,+ 0x108e06c,+ 0x108e86c,+ 0x1090167,+ 0x109096a,+ 0x109116e,+ 0x109207c,+ 0x109407c,+ 0x1095064,+ 0x10960a0,+ 0x1096832,+ 0x1097844,+ 0x1098034,+ 0x10988ae,+ 0x10998b0,+ 0x109a022,+ 0x109c846,+ 0x109d973,+ 0x10a284e,+ 0x10a3050,+ 0x10a3844,+ 0x10a4046,+ 0x10a4862,+ 0x10a8177,+ 0x10a897b,+ 0x10a917f,+ 0x10a9984,+ 0x10aa188,+ 0x10aa98c,+ 0x10ab190,+ 0x10ab994,+ 0x10ac198,+ 0x10ac99c,+ 0x10ad1a0,+ 0x10ad9a4,+ 0x10ae1a8,+ 0x10ae9ac,+ 0x10af1b0,+ 0x10af9b4,+ 0x10b0036,+ 0x10b09b7,+ 0x10b11ba,+ 0x10b19be,+ 0x10b20b2,+ 0x10b29c1,+ 0x10b31c4,+ 0x10b39c8,+ 0x10b41cd,+ 0x10b48b4,+ 0x10b51d0,+ 0x10b59d3,+ 0x10b6068,+ 0x10b6832,+ 0x10b704e,+ 0x10b78b0,+ 0x10b8046,+ 0x10b89d7,+ 0x10b91da,+ 0x10b99de,+ 0x10ba0aa,+ 0x10ba9e1,+ 0x10bb1e4,+ 0x10bb9e8,+ 0x10bc1ed,+ 0x10bc83c,+ 0x10bd1f0,+ 0x10bd9f3,+ 0x10be06a,+ 0x10be842,+ 0x10bf050,+ 0x10bf8a6,+ 0x10c49f7,+ 0x10c81fb,+ 0x10c89fe,+ 0x10c9200,+ 0x10c98aa,+ 0x10ca203,+ 0x10cb207,+ 0x10cba0a,+ 0x10cc20d,+ 0x10cca10,+ 0x10daa13,+ 0x10e81fb,+ 0x10e921c,+ 0x10ea21f,+ 0x10f1200,+ 0x10f39fe,+ 0x10f48aa,+ 0x1108a23,+ 0x11090b8,+ 0x1109a27,+ 0x110a8cd,+ 0x110c8be,+ 0x110d22b,+ 0x110f230,+ 0x1121a39,+ 0x1122a39,+ 0x1124239,+ 0x113023c,+ 0x113223f,+ 0x1132a42,+ 0x113323f,+ 0x1133a42,+ 0x1137245,+ 0x1137a48,+ 0x113824b,+ 0x1138a4f,+ 0x11628be,+ 0x11e7213,+ 0x1234a53,+ 0x1235256,+ 0x1235a59,+ 0x123625c,+ 0x1236a5f,+ 0x1237262,+ 0x1237a65,+ 0x1238268,+ 0x1238a6b,+ 0x123926e,+ 0x1239a71,+ 0x123a274,+ 0x123aa78,+ 0x123b27c,+ 0x123ba80,+ 0x123c284,+ 0x123ca88,+ 0x123d28c,+ 0x123da90,+ 0x123e294,+ 0x123ea98,+ 0x123f29d,+ 0x123faa2,+ 0x12402a7,+ 0x1240aac,+ 0x12412b1,+ 0x1241ab6,+ 0x12422bb,+ 0x1242ac0,+ 0x12432c5,+ 0x1243aca,+ 0x12442cf,+ 0x1244ad2,+ 0x12452d5,+ 0x1245ad8,+ 0x12462db,+ 0x1246ade,+ 0x12472e1,+ 0x1247ae4,+ 0x12482e7,+ 0x1248aea,+ 0x12492ee,+ 0x1249af2,+ 0x124a2f6,+ 0x124aafa,+ 0x124b2fe,+ 0x124bb02,+ 0x124c306,+ 0x124cb0a,+ 0x124d30e,+ 0x124db12,+ 0x124e316,+ 0x124eb1a,+ 0x124f31e,+ 0x124fb22,+ 0x1250326,+ 0x1250b2a,+ 0x125132e,+ 0x1251b32,+ 0x1252336,+ 0x1252b3a,+ 0x125333e,+ 0x1253b42,+ 0x1254346,+ 0x1254b4a,+ 0x125534e,+ 0x1255b52,+ 0x1256356,+ 0x1256b5a,+ 0x125735e,+ 0x1257b62,+ 0x1258366,+ 0x1258b6a,+ 0x125936e,+ 0x1259b72,+ 0x125a376,+ 0x125ab7a,+ 0x127537e,+ 0x1308b80,+ 0x1332b85,+ 0x134cb8d,+ 0x13500c9,+ 0x1382b80,+ 0x1389b80,+ 0x138a380,+ 0x138a83c,+ 0x138bb98,+ 0x138c398,+ 0x13a6398,+ 0x13a7398,+ 0x13a9b9c,+ 0x13aa39c,+ 0x13ab8c9,+ 0x13b2385,+ 0x13ca200,+ 0x13ce200,+ 0x13cea00,+ 0x13cf200,+ 0x13cfa00,+ 0x13d0200,+ 0x13d0a00,+ 0x13d2200,+ 0x13d2a00,+ 0x13d3200,+ 0x13d3a00,+ 0x13d4200,+ 0x13d4a00,+ 0x13d5200,+ 0x13d5a00,+ 0x13d6200,+ 0x13d6a00,+ 0x13d7200,+ 0x13d7a00,+ 0x13d8a00,+ 0x153a3a0,+ 0x153aba4,+ 0x153b3a7,+ 0x163e062,+ 0x163e8b2,+ 0x1800000,+ 0x19283ab,+ 0x1928baf,+ 0x19293b2,+ 0x1929bb5,+ 0x192a3b8,+ 0x192abbb,+ 0x192b3be,+ 0x192bbc1,+ 0x192c3c4,+ 0x192cbc7,+ 0x192d3ca,+ 0x192dbcd,+ 0x192e3d0,+ 0x192ebd3,+ 0x192f3d6,+ 0x192fbd9,+ 0x1958bdc,+ 0x19593df,+ 0x1959be2,+ 0x195a3e5,+ 0x195abe8,+ 0x195b3eb,+ 0x195bbee,+ 0x195c3f1,+ 0x195cbf4,+ 0x195d3f7,+ 0x195dbfa,+ 0x195e3fd,+ 0x195ec00,+ 0x195f403,+ 0x195fc06,+ 0x1966409,+ 0x1966c0c,+ 0x1967410,+ 0x1967c13,+ 0x19b8c17,+ 0x19b941b,+ 0x19b9c1e,+ 0x19ba421,+ 0x19bac25,+ 0x19bb428,+ 0x19bbc2b,+ 0x19bc42e,+ 0x19bcc32,+ 0x19bd436,+ 0x19c0439,+ 0x19c0c3c,+ 0x19c1c3f,+ 0x19c2442,+ 0x19c2c45,+ 0x19c3448,+ 0x19c3c4b,+ 0x19c444e,+ 0x19c4c52,+ 0x19c5457,+ 0x19c5c5a,+ 0x19c745d,+ 0x19c7c60,+ 0x19c8463,+ 0x19c8c66,+ 0x19c946a,+ 0x19c9c6e,+ 0x19ca472,+ 0x19cb476,+ 0x19cbc79,+ 0x19cc47c,+ 0x19ccc7f,+ 0x19cd482,+ 0x19ce485,+ 0x19cec88,+ 0x19cf48b,+ 0x19cfc8e,+ 0x19d0492,+ 0x19d0c96,+ 0x19d1499,+ 0x19d1c9d,+ 0x19d24a1,+ 0x19d2ca5,+ 0x19d34a8,+ 0x19d4cac,+ 0x19d54af,+ 0x19d5cb3,+ 0x19d64b7,+ 0x19d6cbb,+ 0x19d84bf,+ 0x19d8cc2,+ 0x19d9cc5,+ 0x19da4c8,+ 0x19daccb,+ 0x19dbcce,+ 0x19dc4d1,+ 0x19dccd4,+ 0x19dd4d7,+ 0x19ddcda,+ 0x19decdd,+ 0x19df4e0,+ 0x19dfce3,+ 0x19e14e6,+ 0x19e1ceb,+ 0x19e24ee,+ 0x19e2cf1,+ 0x19e3cf4,+ 0x19e44f8,+ 0x19e4cfb,+ 0x19e54fe,+ 0x19e5d01,+ 0x19e6504,+ 0x19e6d07,+ 0x19e750a,+ 0x19e7d0d,+ 0x19e8510,+ 0x19e8d13,+ 0x19e9516,+ 0x19e9d1a,+ 0x19ea51d,+ 0x19ead20,+ 0x19eb524,+ 0x19ebd28,+ 0x19ec52b,+ 0x19ecd30,+ 0x19ed534,+ 0x19edd37,+ 0x19ee53a,+ 0x19eed3d,+ 0x19ffd40,+ 0x53f9032,+ 0x53f98ae,+ 0x53fa544,+ 0x7d80546,+ 0x7d80d49,+ 0x7d8154c,+ 0x7d81d4f,+ 0x7d82553,+ 0x7d82d57,+ 0x7d83557,+ 0x7d94d5a,+ 0x7f0855c,+ 0x7f09d5e,+ 0x7f0a09b,+ 0x7f0ad60,+ 0x7f0b562,+ 0x7f0c8c5,+ 0x7f180c2,+ 0x7f19d64,+ 0x7f1a564,+ 0x7f1ad66,+ 0x7f1b568,+ 0x7f1bd6a,+ 0x7f1c56c,+ 0x7f23d6e,+ 0x7f24570,+ 0x7f26d64,+ 0x7f27564,+ 0x7f27d64,+ 0x7f2855c,+ 0x7f290c0,+ 0x7f2a09b,+ 0x7f2ad5e,+ 0x7f2b562,+ 0x7f2bd60,+ 0x7f2cd66,+ 0x7f2d568,+ 0x7f2dd6a,+ 0x7f2e56c,+ 0x7f2fd72,+ 0x7f30574,+ 0x7f308be,+ 0x7f3155a,+ 0x7f318b8,+ 0x7f32576,+ 0x7f32d78,+ 0x7f3357a,+ 0x7f3457c,+ 0x7f34d7e,+ 0x7f35580,+ 0x7f35d82,+ 0x7f7f810,+ 0x83d2d84,+ 0xea4e030,+ 0xea4f032,+ 0xea4f84e,+ 0xea51052,+ 0xea52860,+ 0xea53064,+ 0xea5d8ac,+ 0xea82030,+ 0xea828a0,+ 0xea9c030,+ 0xea9c8a0,+ 0xeaa303a,+ 0xf880586,+ 0xf880d89,+ 0xf88158c,+ 0xf881d8f,+ 0xf882592,+ 0xf882d95,+ 0xf883598,+ 0xf883d9b,+ 0xf88459e,+ 0xf884da1,+ 0xf8855a4,+ 0xf8885a7,+ 0xf888dab,+ 0xf88900a,+ 0xf889daf,+ 0xf88a5b3,+ 0xf88adb7,+ 0xf88b5bb,+ 0xf88bdbf,+ 0xf88c5c3,+ 0xf88cdc7,+ 0xf88d5cb,+ 0xf88ddcf,+ 0xf88e5d3,+ 0xf88edd7,+ 0xf88f5db,+ 0xf88fddf,+ 0xf8905e3,+ 0xf890811,+ 0xf8915e7,+ 0xf891deb,+ 0xf8925ef,+ 0xf892df3,+ 0xf8935f7,+ 0xf893dfb,+ 0xf8945ff,+ 0xf894e03,+ 0xf895832,+ 0xf89606c,+ 0xf896e07,+ 0xf89760a,+ 0xf8a560d,+ 0xf8a5cd4,+ 0xf8a6610,+ 0xf8a6e13,+ 0xf8a7616,+ 0xf8a7e1a,+ 0xf8b561d,+ 0xf8b5e20,+ 0xf8b6623,+ 0xf8c8626,+ 0xf9c4e29,+ 0xfa0de35,+ 0xfa26e3b,+ 0xfa27640,+ 0xfa50e47,+ 0xfa5de4e,+ 0xfa60e59,+ 0xfa61659,+ 0xfa62662,+ 0xfa66669,+ 0xfa6ee6f,+ 0xfa89676,+ 0xfa89e7f,+ 0xfa8a68a,+ 0xfa92e91,+ 0xfa93e98,+ 0xfb4069f,+ 0xfb68ea8,+ 0xfcf56af,+};diff --git a/devices/harness-device/firmware/main/ui/habitat/fonts.c b/devices/harness-device/firmware/main/ui/habitat/fonts.cindex 7c0b02d1e..477cf597d 100644--- a/devices/harness-device/firmware/main/ui/habitat/fonts.c+++ b/devices/harness-device/firmware/main/ui/habitat/fonts.c@@ -6003,6 +6003,33 @@ static const uint8_t ht_failed_28_pixels[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,};const ht_font_t ht_failed_28 = {10007,10007,17,38,ht_failed_28_pixels};+static const uint8_t ht_right_20_pixels[] = {+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,+ 0,0,0,0,0,0,0,20,0,0,46,0,0,11,128,0,2,224,0,0,184,191,255,254,+ 106,170,189,0,0,244,0,3,208,0,15,64,0,61,0,0,0,0,0,0,0,0,0,0,+ 0,0,0,0,0,0,0,0,0,0,0,0,+};+const ht_font_t ht_right_20 = {8594,8594,12,28,ht_right_20_pixels};+static const uint8_t ht_right_28_pixels[] = {+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,+ 0,0,0,0,0,0,0,0,0,0,0,0,0,20,0,0,0,15,192,0,0,0,252,0,+ 0,0,15,192,0,0,0,252,0,0,0,15,192,0,0,0,252,47,255,255,255,203,255,255,+ 255,244,0,0,7,244,0,0,2,244,0,0,2,244,0,0,2,244,0,0,2,244,0,0,+ 2,244,0,0,1,84,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,+};+const ht_font_t ht_right_28 = {8594,8594,17,38,ht_right_28_pixels};+static const uint8_t ht_open_28_pixels[] = {+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,+ 255,255,240,7,255,255,252,0,0,1,255,0,0,0,255,192,0,0,253,240,0,0,252,60,+ 0,0,252,15,0,0,252,3,192,0,252,0,240,0,252,0,60,0,252,0,15,0,252,0,+ 3,64,252,0,0,64,28,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,+};+const ht_font_t ht_open_28 = {8599,8599,17,38,ht_open_28_pixels};const uint8_t ht_mono_20_ink[224][4] = {{0,0,0,0},{5,8,6,21},@@ -6235,3 +6262,6 @@ const uint8_t ht_open_20_ink[1][4] = {const uint8_t ht_bell_20_ink[1][4] = {{0,6,10,23},};+const uint8_t ht_right_20_ink[1][4] = {+ {0,10,11,20},+};diff --git a/devices/harness-device/firmware/main/ui/habitat/terminal.c b/devices/harness-device/firmware/main/ui/habitat/terminal.cindex 3677d3049..d9435acd6 100644--- a/devices/harness-device/firmware/main/ui/habitat/terminal.c+++ b/devices/harness-device/firmware/main/ui/habitat/terminal.c@@ -1,6 +1,8 @@#include "terminal.h"+#include <stdio.h>#include <string.h>#include "arc_geometry.inc"+#include "display_fallbacks.inc"static int imin(int a, int b) { return a < b ? a : b; }static int imax(int a, int b) { return a > b ? a : b; }@@ -39,14 +41,12 @@ static const ht_font_t *glyph_font(const ht_font_t *font, uint32_t cp)if (cp == 0x2713) return &ht_done_28;if (cp == 0x2717) return &ht_failed_28;}- // Authored arrows in a recap use the same precomputed glyph as its marker.- // Identical cell metrics: no scaling, allocation, or extra text runs.- // ht_open_20's cell is 12 x 28 — mono_20's exactly, which is what made this free. The recap now- // draws in mono_28 (17 x 38) and there is no open_28, so an authored arrow there renders a 12 px- // glyph in a 17 px cell: readable, visibly smaller than the words beside it, and better than the- // '?' the alternative gives. A precomputed 17 x 38 ↗ would settle it properly.+ // Inline arrows use exactly the parent font's cell metrics. The raster+ // indexes each cell by that width/height; a smaller atlas would overread.+ // Three extra immutable glyphs, no scaling, allocation or extra text runs.if (font == &ht_mono_20 || font == &ht_mono_28) {- if (cp == 0x2197) return &ht_open_20;+ if (cp == 0x2197) return font == &ht_mono_28 ? &ht_open_28 : &ht_open_20;+ if (cp == 0x2192) return font == &ht_mono_28 ? &ht_right_28 : &ht_right_20;if (cp == 0xe000) return font == &ht_mono_28 ? &ht_bell_28 : &ht_bell_20;}return font;@@ -75,18 +75,144 @@ uint32_t ht_utf8_next(const char **p)uint32_t v = c & ((1u << (6 - n)) - 1);for (int i = 0; i < n; i++) {if ((s[i] & 0xc0) != 0x80) {- *p = (const char *)s;- return '?';+ *p = (const char *)(s + i);+ return 0xfffd;}v = (v << 6) | (s[i] & 63);}s += n;c = v;+ if (c < (n == 1 ? 0x80u : n == 2 ? 0x800u : 0x10000u) ||+ c > 0x10ffff || (c >= 0xd800 && c <= 0xdfff)) c = 0xfffd;} else if (c >= 128)- c = '?';+ c = 0xfffd;*p = (const char *)s;return c;}++static bool native_glyph(const ht_font_t *font, uint32_t cp)+{+ if (cp < 32 || (cp >= 127 && cp < 160)) return false;+ const ht_font_t *face = glyph_font(font, cp);+ cp = punctuation_alias(cp);+ return cp >= face->first && cp <= face->last;+}+static const char *display_fallback(uint32_t cp, char scratch[12])+{+ // Styling/joining controls carry no ink. Unknown text itself is never lost.+ if ((cp >= 0xfe00 && cp <= 0xfe0f) || (cp >= 0xe0100 && cp <= 0xe01ef)) return "";+ size_t lo = 0, hi = sizeof display_ranges / sizeof display_ranges[0];+ while (lo < hi) {+ size_t mid = lo + (hi - lo) / 2;+ if (cp < display_ranges[mid].first) hi = mid;+ else if (cp > display_ranges[mid].last) lo = mid + 1;+ else {+ scratch[0] = (char)((int32_t)cp + display_ranges[mid].delta);+ scratch[1] = 0;+ return scratch;+ }+ }+ lo = 0; hi = sizeof display_entries / sizeof display_entries[0];+ while (lo < hi) {+ size_t mid = lo + (hi - lo) / 2;+ uint32_t key = display_entries[mid] >> DISPLAY_OFFSET_BITS;+ if (cp < key) hi = mid;+ else if (cp > key) lo = mid + 1;+ else return display_pool + (display_entries[mid] & DISPLAY_OFFSET_MASK);+ }+ // An explicit, lossless identifier is preferable to inventing a meaning or+ // showing '?' (which could be part of the author's actual message).+ snprintf(scratch, 12, "[U+%04lX]", (unsigned long)cp);+ return scratch;+}+typedef struct {+ const char *text;+ size_t bytes;+ unsigned cells;+ bool fraction, digit, space;+ char scratch[12];+} display_token_t;+static void display_token(const char **cursor, const ht_font_t *font, display_token_t *t)+{+ const char *start = *cursor;+ uint32_t cp = (unsigned char)*start;+ if (cp < 128) (*cursor)++; // Keep ordinary terminal text on the cheap path.+ else cp = ht_utf8_next(cursor);+ *t = (display_token_t){.text=start,.bytes=(size_t)(*cursor-start),.cells=1};+ if (font->first > 32 || font->last < 126 || (cp >= 32 && cp < 127)) {+ // Compact artwork/icon atlases retain their one-cell contract. They+ // cannot render fallback words. ASCII prose needs no Unicode lookup.+ t->digit = cp >= '0' && cp <= '9'; t->space = cp == ' ';+ return;+ }+ t->fraction = (cp >= 0xbc && cp <= 0xbe) || (cp >= 0x2150 && cp < 0x215f) || cp == 0x2189;+ if (cp >= 9 && cp <= 13) { t->text=" "; t->bytes=1; }+ else if (cp == 0xa0 || cp == 0xad || t->fraction || !native_glyph(font,cp)) {+ t->text = display_fallback(cp,t->scratch);+ t->bytes = t->cells = (unsigned)strlen(t->text); // fallback pool is ASCII only+ }+ t->digit = t->bytes && t->text[t->bytes-1] >= '0' && t->text[t->bytes-1] <= '9';+ t->space = t->bytes == 1 && t->text[0] == ' ';+}+static bool token_gap(const display_token_t *t, bool digit, bool fraction)+{+ // Mixed/adjacent fractions must read '1 1/3', never '11/3' or '1/32/3'.+ return t->bytes && ((t->fraction && digit) ||+ (fraction && t->text[0] >= '0' && t->text[0] <= '9'));+}+static bool display_copy(char *dst, size_t cap, const char *src, const char *end,+ const ht_font_t *font, int columns)+{+ if (!cap || !font) return false;+ const char *p = src ? src : "";+ size_t used = 0;+ bool digit = false, fraction = false, complete = true;+ while (*p && (!end || p < end)) {+ bool newline = *p == '\n';+ display_token_t t; display_token(&p,font,&t);+ bool gap = token_gap(&t,digit,fraction);+ if (t.cells + gap > (unsigned)columns || t.bytes + gap >= cap - used) {+ complete = false; break;+ }+ if (gap) dst[used++] = ' ';+ if (newline) dst[used++] = '\n';+ else { memcpy(dst+used,t.text,t.bytes); used += t.bytes; }+ columns -= t.cells + gap;+ if (t.bytes) { digit=t.digit; fraction=t.fraction; }+ }+ dst[used] = 0;+ return complete;+}+bool ht_display_text(char *dst, size_t cap, const char *src, const ht_font_t *font)+{+ // Byte capacity also bounds cell count, avoiding unbounded size_t -> int.+ return display_copy(dst,cap,src,NULL,font,(int)(cap < 32768 ? cap : 32768));+}+const char *ht_take_display_line(const char **cursor, int cols, const ht_font_t *font)+{+ const char *p = *cursor, *start = p, *space = NULL, *after_space = NULL, *end = p;+ unsigned used = 0;+ bool digit = false, fraction = false;+ while (*p && *p != '\n') {+ const char *before = p;+ display_token_t t; display_token(&p,font,&t);+ unsigned cells = t.cells + token_gap(&t,digit,fraction);+ if (used + cells > (unsigned)(cols > 0 ? cols : 0)) {+ // A single replacement larger than the entire viewport still has+ // to make progress. ht_text will safely omit that indivisible token.+ if (before == start) end = p;+ else p = before;+ break;+ }+ if (t.space) { space=before; after_space=p; }+ used += cells; end = p;+ if (t.bytes) { digit=t.digit; fraction=t.fraction; }+ }+ if (*p && *p != '\n' && space && space > start) { end=space; p=after_space; }+ else if (*p == '\n') p++;+ *cursor = p;+ return end;+}uint8_t ht_shimmer_phase(uint32_t now){unsigned step = (now / 64) % 32;@@ -105,7 +231,7 @@ void ht_scene_clear(ht_scene_t *s, uint16_t bg)bool ht_text(ht_scene_t *s, int x, int y, int w, const ht_font_t *font, uint16_t fg, uint16_t bg,const char *text){- if (s->count >= HT_RUNS || !font || w <= 0)+ if (s->count >= HT_RUNS || !font || !font->width || w <= 0)return false;ht_run_t *r = &s->runs[s->count++];memset(r, 0, sizeof(*r));@@ -115,19 +241,9 @@ bool ht_text(ht_scene_t *s, int x, int y, int w, const ht_font_t *font, uint16_tr->font = font;r->fg = fg;r->bg = bg;- const char *p = text ? text : "";- size_t n = 0;- int cells = w / font->width;- while (*p && cells-- > 0) {- const char *start = p;- ht_utf8_next(&p);- size_t len = (size_t)(p - start);- if (n + len >= sizeof(r->text))- break;- memcpy(r->text + n, start, len);- n += len;- }- r->text[n] = 0;+ display_copy(r->text,sizeof r->text,text,NULL,font,w / font->width);+ // A run is one line. Multi-line callers split before constructing runs.+ for (char *p=r->text; *p; p++) if (*p=='\n') *p=' ';return true;}bool ht_ascii_text(ht_scene_t *s, int x, int y, int w, const ht_font_t *font,@@ -145,23 +261,27 @@ bool ht_ascii_text(ht_scene_t *s, int x, int y, int w, const ht_font_t *font,}void ht_center(ht_scene_t *s, int y, const ht_font_t *font, uint16_t fg, const char *text){- const char *p = text;+ char visible[HT_TEXT_BYTES];+ ht_display_text(visible,sizeof visible,text,font);+ const char *p = visible;int n = 0;while (*p) {ht_utf8_next(&p);n++;}int w = imin(n * font->width, HT_WIDTH - 80);- ht_text(s, (HT_WIDTH - w) / 2, y, w, font, fg, s->background, text);+ ht_text(s, (HT_WIDTH - w) / 2, y, w, font, fg, s->background, visible);}static void arc_text(ht_scene_t *s, uint16_t fg, const char *text, bool bottom){if (!text || !*text) return;+ char visible[HT_TEXT_BYTES];+ bool complete = ht_display_text(visible,sizeof visible,text,&ht_mono_20);if (!ht_text(s, HT_ARC_X, HT_ARC_Y, HT_ARC_COLS * ht_mono_20.width,- &ht_mono_20, fg, s->background, text)) return;+ &ht_mono_20, fg, s->background, visible)) return;ht_run_t *r = &s->runs[s->count - 1];// A long name ends at a word boundary; the pane list retains its full name.- if (strlen(text ? text : "") > strlen(r->text)) {+ if (!complete || strlen(visible) > strlen(r->text)) {char *last = strrchr(r->text, ' ');if (last && last - r->text >= HT_ARC_COLS / 2) *last = 0;}@@ -195,7 +315,7 @@ int ht_text_rows(const char *text, const ht_font_t *font, int width)if (!font || !font->width || width < font->width) return 0;const char *p = text ? text : "";int rows = 0;- while (*p) { ht_take_line(&p, width / font->width); rows++; }+ while (*p) { ht_take_display_line(&p, width / font->width, font); rows++; }return rows;}bool ht_can_display(const char *text, const ht_font_t *font, int width, int lines)@@ -204,18 +324,24 @@ bool ht_can_display(const char *text, const ht_font_t *font, int width, int linereturn false;const char *p = text ? text : "";while (*p) {+ const char *start = p;uint32_t cp = ht_utf8_next(&p);const ht_font_t *glyph = glyph_font(font, cp);if (cp < glyph->first || cp > glyph->last) cp = punctuation_alias(cp);if (cp != '\n' && cp != ' ' && (cp < glyph->first || cp > glyph->last || (cp >= 127 && cp < 160)))return false;+ // Even native fractions expand to several cells. Never approve text+ // whose indivisible display equivalent cannot fit in the viewport.+ display_token_t token;+ display_token(&start,font,&token);+ if (token.cells > (unsigned)(width / font->width)) return false;}p = text ? text : "";int rows = 0;while (*p) {if (++rows > lines)return false;- ht_take_line(&p, width / font->width);+ ht_take_display_line(&p, width / font->width, font);}return true;}@@ -228,15 +354,11 @@ int ht_wrap(ht_scene_t *s, int x, int y, int w, int lines, int skip, const ht_foint row = 0, shown = 0, cols = w / f->width;while (*p && shown < lines) {const char *start = p;- const char *end = ht_take_line(&p, cols);+ const char *end = ht_take_display_line(&p, cols, f);if (row++ < skip)continue;char line[HT_TEXT_BYTES];- size_t len = (size_t)(end - start);- if (len >= sizeof(line))- len = sizeof(line) - 1;- memcpy(line, start, len);- line[len] = 0;+ display_copy(line,sizeof line,start,end,f,cols);ht_text(s, x, y + shown * f->height, w, f, fg, s->background, line);shown++;}@@ -680,6 +802,7 @@ static void arc_prepare(const ht_run_t *r, arc_cache_t *cache)#endif{const uint8_t *ink = f == &ht_open_20 ? ht_open_20_ink[0] :+ f == &ht_right_20 ? ht_right_20_ink[0] :f == &ht_bell_20 ? ht_bell_20_ink[0] : ht_mono_20_ink[c - f->first];// Source pixels outside this box are transparent. Include a full// bilinear halo and two destination pixels for fixed-point rounding.diff --git a/devices/harness-device/firmware/main/ui/habitat/terminal.h b/devices/harness-device/firmware/main/ui/habitat/terminal.hindex e463b3b3c..725322d27 100644--- a/devices/harness-device/firmware/main/ui/habitat/terminal.h+++ b/devices/harness-device/firmware/main/ui/habitat/terminal.h@@ -27,6 +27,8 @@ extern const ht_font_t ht_mono_16, ht_mono_20, ht_mono_24, ht_mono_28, ht_pixel_// Precomputed curved-label and larger inbox navigation glyphs.extern const ht_font_t ht_open_20, ht_nav_32;extern const uint8_t ht_mono_20_ink[224][4], ht_open_20_ink[1][4];+extern const ht_font_t ht_right_20, ht_right_28, ht_open_28;+extern const uint8_t ht_right_20_ink[1][4];// One authored outline bell in a normal terminal cell, not an emoji font.#define HT_BELL "\xee\x80\x80"extern const ht_font_t ht_bell_20, ht_bell_28;@@ -95,6 +97,10 @@ uint32_t ht_glyph_cache_builds(void);size_t ht_glyph_cache_bytes(void);// Consume one word-wrapped UTF-8 line; shared by rectangular and round reading areas.const char *ht_take_line(const char **cursor, int cells);+// Display-only normalization, before measuring/wrapping. Bounded, no allocation;+// false means the destination was truncated. Source and destination must differ.+bool ht_display_text(char *dst, size_t capacity, const char *src, const ht_font_t *font);+const char *ht_take_display_line(const char **cursor, int cells, const ht_font_t *font);int ht_wrap(ht_scene_t *scene, int x, int y, int width, int lines, int skip, const ht_font_t *font,uint16_t fg, const char *text);void ht_damage(const ht_scene_t *before, const ht_scene_t *after, ht_damage_t *out);diff --git a/devices/harness-device/firmware/main/ui/habitat/ui_habitat.c b/devices/harness-device/firmware/main/ui/habitat/ui_habitat.cindex 5253da351..1650b518e 100644--- a/devices/harness-device/firmware/main/ui/habitat/ui_habitat.c+++ b/devices/harness-device/firmware/main/ui/habitat/ui_habitat.c@@ -119,7 +119,7 @@ typedef enum {A_SELECT_BEGIN, A_SELECT_FIND, A_SELECT_EXTEND, A_SELECT_SEND, A_RETURN, A_LATEST, A_VISIT_SEND,A_CARRY, A_CARRY_DROP, A_CARRY_SEND,A_DRAFT_EDIT, A_DRAFT_APPEND, A_DRAFT_UNDO, A_DRAFT_SEND, A_DRAFT_DISCARD,- A_DRAFT_STATE, A_DRAFT_OPTIONS, A_DRAFT_BACK, A_DRAFT_COMMAND+ A_DRAFT_STATE, A_DRAFT_OPTIONS, A_DRAFT_BACK, A_DRAFT_COMMAND, A_NOTICE_READ} action_kind_t;typedef struct {action_kind_t kind;@@ -173,6 +173,9 @@ typedef struct {} question_submit_t;typedef struct {char id[ID_MAX], summary[240];+ char token[CABLE_READ_TOKEN_MAX];+ uint32_t sent_at;+ bool pending;bool question, failed;} notice_receipt_t;static EXT_RAM_BSS_ATTR struct {@@ -238,8 +241,6 @@ static EXT_RAM_BSS_ATTR struct {int hit_count, pressed;bool touch_down, touch_cancelled;bool touch_brake, coasting;- bool quick_open;- int quick_choice;uint32_t coast_until;uint32_t character_activity;uint8_t status_phase;@@ -257,6 +258,7 @@ static bool scroll_reversed;static ht_scroll_t scroll;static ht_selection_t selection;static ht_workspace_t workspace;+static ht_tab_carousel_t tab_carousel;static ht_carry_t carry;static ht_visit_t visit;static ht_form_t form;@@ -351,7 +353,8 @@ static bool notice_was_read(const cable_notif_t *n)for (int i = 0; i < NOTICES; i++) {const notice_receipt_t *r = &s.notice_reads[i];if (!strcmp(r->id, n->agent_id) && r->question == n->question &&- r->failed == n->failed && !strcmp(r->summary, n->summary)) return true;+ r->failed == n->failed && !strcmp(r->token, n->read_token) &&+ !strcmp(r->summary, n->summary)) return true;}return false;}@@ -360,6 +363,19 @@ static void notice_forget_read(const char *id)for (int i = 0; i < NOTICES; i++)if (!strcmp(s.notice_reads[i].id, id)) s.notice_reads[i].id[0] = 0;}+static void notice_flush_reads(uint32_t now)+{+ if (!s.connected) return;+ for (int i = 0; i < NOTICES; i++) {+ notice_receipt_t *r = &s.notice_reads[i];+ if (!r->pending || !r->id[0] || !r->token[0] ||+ (r->sent_at && now - r->sent_at < 2000)) continue;+ action_t a = {.kind = A_NOTICE_READ}; COPY(a.id, r->id); COPY(a.text, r->token);+ if (queue(a)) r->sent_at = now ? now : 1;+ // At most one tiny receipt per tick; touch/audio retain queue capacity.+ break;+ }+}static void notice_mark_read(cable_notif_t *n){if (n->read_on_dial) return;@@ -371,8 +387,10 @@ static void notice_mark_read(cable_notif_t *n)if (slot < 0) { slot = s.notice_read_next; s.notice_read_next = (slot + 1) % NOTICES; }notice_receipt_t *r = &s.notice_reads[slot];COPY(r->id, n->agent_id); COPY(r->summary, n->summary);+ COPY(r->token, n->read_token); r->sent_at = 0; r->pending = r->token[0] != 0;r->question = n->question; r->failed = n->failed;n->read_on_dial = true;+ notice_flush_reads(ms());// Read is not answered, removed or focused. Keep this exact card in place.change();}@@ -495,7 +513,7 @@ static void input_cancel(void)ht_workspace_cancel_touch(&workspace);ht_scroll_cancel(&scroll);s.coasting = false;- s.quick_open = false;+ ht_tab_carousel_cancel(&tab_carousel);s.voice_review_preview = false;if (s.touch_down) s.touch_cancelled = true;s.pressed = -1;@@ -533,6 +551,12 @@ static int workspace_index(const char *id)for (int i=0;i<s.tab_count;i++) if (!strcmp(id,s.tabs[i].id)) return i;return -1;}+static void tabs_open(void)+{+ view(TABS);+ if (s.view != TABS) return;+ ht_tab_carousel_reset(&tab_carousel, s.tab_count, workspace_index(s.selected_tab));+}static void workspace_failed(const char *message){ht_workspace_cancel_request(&workspace);@@ -733,7 +757,7 @@ static bool home_caption_rotates(void)const agent_t *a = active();return (s.view == HOME || s.view == AGENT) && a && a->busy && s.connected &&!s.loading && !s.nap && !s.quiet && !s.locked && !display_is_asleep() &&- !s.quick_open && !s.voice_retry_until && !carry.active && !carry.error[0] && !visit.available;+ !s.voice_retry_until && !carry.active && !carry.error[0] && !visit.available;}static bool home_caption_tick(uint32_t now){@@ -745,7 +769,7 @@ static bool home_caption_tick(uint32_t now)}static bool status_animated(void){- if (s.nap || s.quiet || s.locked || display_is_asleep() || s.touch_down || s.quick_open)+ if (s.nap || s.quiet || s.locked || display_is_asleep() || s.touch_down)return false;if (s.view == VOICE) return !s.voice_review_preview && voice_status()[0];return home_caption_rotates() && home_caption.activity && !s.straight_title;@@ -762,6 +786,8 @@ static uint32_t status_wake_ms(uint32_t now)}static void surface_tick(uint32_t now){+ notice_flush_reads(now);+ if (s.view == TABS && !s.locked && !display_is_asleep() && ht_tab_carousel_tick(&tab_carousel, now)) change();if (home_caption_tick(now)) change();uint8_t phase = status_animated() ? ht_shimmer_phase(now * status_speed()) : 0;if (phase != s.status_phase) { s.status_phase = phase; change(); }@@ -776,39 +802,21 @@ static void surface_tick(uint32_t now)s.touch_down && !s.touch_cancelled && gesture.live && !gesture.moved && !gesture.guarded &&pressed_action.kind == A_PET && held >= 650 && held <= 1800;if (review_preview != s.voice_review_preview) { s.voice_review_preview = review_preview; change(); }- if (visible && main && s.touch_down && !s.touch_cancelled && gesture.live && !gesture.guarded) {- uint32_t held = now - s.touch_started;- if (!s.quick_open && pressed_action.kind == A_PET && !gesture.moved && held >= 650 && held < 5000) {- s.quick_open = true;- s.quick_choice = 0;- ht_scroll_cancel(&scroll);- change();- } else if (s.quick_open && held >= 5000) {- input_cancel(); // resting a hand cannot eventually open a menu or start voice- change();- }+ if (visible && main && s.touch_down && !s.touch_cancelled && gesture.live && !gesture.guarded &&+ pressed_action.kind == A_PET && !gesture.moved && held >= 650 && held < 5000) {+ // Enter directly. The opening contact is consumed until a real release,+ // so lifting or sliding after the hold cannot also select a tab.+ tabs_open();+ return;}ht_character_mood_t mood = s.view == VOICE ?(!s.voice_start_pending && !s.voice_waiting && audio_client_recording() ? HT_CHARACTER_LISTENING : HT_CHARACTER_WORKING) :character_mood();- if (ht_character_tick(&character, now, mood, s.quiet, visible && !s.quick_open,+ if (ht_character_tick(&character, now, mood, s.quiet, visible,s.touch_down && !s.touch_cancelled, s.last_x,mood == HT_CHARACTER_LISTENING ? audio_client_input_level() : 0, s.character_activity))change();}-static void render_quick(ht_scene_t *f)-{- static const char *destinations[] = {"release to stay", "release for panes", "release for inbox", "release for tabs", "release for controls"};- ht_arc_title(f, DIM, "slide, then release");- ht_center(f, 125, &ht_mono_20, s.quick_choice == 1 ? ACCENT : DIM, "panes");- ht_text(f, 62, 224, 108, &ht_mono_20, s.quick_choice == 3 ? ACCENT : DIM, BG, "tabs");- ht_text(f, 326, 224, 84, &ht_mono_20, s.quick_choice == 2 ? ACCENT : DIM, BG, "inbox");- ht_character_face_t face = {.mood=HT_CHARACTER_IDLE, .dim=DIM, .pose=character.motion.reaction.pose};- face.pose.look = s.quick_choice == 3 ? -1 : s.quick_choice == 2 ? 1 : 0;- ht_character_portrait(f, &character, &face, ACCENT, HT_CHARACTER_QUICK, 180);- ht_center(f, 322, &ht_mono_20, s.quick_choice == 4 ? ACCENT : DIM, "controls");- ht_arc_status(f, FG, destinations[s.quick_choice]);-}static void page_controls(ht_scene_t *f, int count){control(f, 111, 390, 60, "<", A_UP, 0, s.offset > 0);@@ -954,7 +962,6 @@ static void render_home(ht_scene_t *f){s.caption_arc = (ht_rect_t){0};if (!s.connected || s.loading) { render_brand(f); return; }- if (s.quick_open) { render_quick(f); return; }if (workspace.touching && workspace.moved && !workspace.cancelled) { render_workspace_preview(f); return; }#if HT_FACE_PX >= 720pro_tab_strip(f); // the first line is the whole switcher on this face@@ -973,6 +980,7 @@ static void render_home(ht_scene_t *f)const char *caption = rotating && home_caption.activity ? activity : a ? a->name : "Choose a pane";bool bell = !s.voice_retry_until && !carry.active && !carry.error[0] && !visit.available;unsigned unread = notice_unread();+ bell = bell && unread > 0;char status[100];if (s.voice_retry_until) COPY(status, "Try again");else status[0] = 0;@@ -988,7 +996,7 @@ static void render_home(ht_scene_t *f).straight_title = s.straight_title,#endif.footer_action = carry.active || carry.error[0] || visit.available,- .ink = bell && !unread ? DIM : FG, .foreground = FG, .dim = DIM,+ .ink = FG, .foreground = FG, .dim = DIM,.primary_title = true, .roomy_reading = true};char carried[128];if (carry.active) {@@ -1042,7 +1050,7 @@ static void render_home(ht_scene_t *f)s.hits[s.hit_count++] = (hit_t){{83, 382, 300, 84}, A_INBOX, 0, unread > 0};#endif// The bell and the creature never share a target, even when the bell is- // dimmed or its count changes under a finger. Centre always starts voice.+ // hidden or its count changes under a finger. Centre always starts voice.#if HT_FACE_PX >= 720// The font_16 companion exactly: 54*8 x 27*16 at x=(720-432)/2, y=140.s.hits[s.hit_count++] = (hit_t){{144, 140, 432, 432}, A_PET, 0, true};@@ -1408,27 +1416,70 @@ static void tabs_move(int dy)if (next != s.offset) { s.offset = next; change(); }else s.tab_drag = 0; // Overscroll never builds up travel to undo on reversal.}+static void tab_name(ht_scene_t *f, const char *name, int center_x, uint16_t ink)+{+ int first = f->count;+ const int width = 12 * UI_FONT->width;+ ht_wrap(f, 0, 0, width, 6, 0, UI_FONT, ink, name[0] ? name : "Untitled");+ while (f->count > first && !f->runs[f->count - 1].text[0]) f->count--;+ int rows = f->count - first;+ for (int i = first; i < f->count; i++) {+ ht_run_t *r = &f->runs[i];+ const char *p = r->text;+ int cells = 0;+ while (*p) { ht_utf8_next(&p); cells++; }+ int dx = center_x - 233;+ if (dx < -HT_TAB_PITCH) dx = -HT_TAB_PITCH;+ if (dx > HT_TAB_PITCH) dx = HT_TAB_PITCH;+ // Center the chosen name. Neighbors align toward the visible edge of+ // their own page so even a short name peeks in. Alignment moves smoothly+ // with the page and never crosses the 24 px gap between names.+ int x = center_x - cells * UI_FONT->width / 2 -+ dx * (width - cells * UI_FONT->width) / (2 * HT_TAB_PITCH);+ p = r->text;+ // The moving names stay inside a central, round-screen-safe viewport.+ // Discard whole cells at its edges; no framebuffer or scissor allocation.+ while (*p && x < 42) { ht_utf8_next(&p); x += UI_FONT->width; cells--; }+ memmove(r->text, p, strlen(p) + 1);+ int room = x >= 424 ? 0 : (424 - x) / UI_FONT->width;+ if (room < cells) cells = room;+ p = r->text;+ for (int n = 0; n < cells; n++) ht_utf8_next(&p);+ r->text[p - r->text] = 0;+ r->x = x; r->y = 233 - rows * UI_FONT->height / 2 + (i - first) * UI_FONT->height;+ r->w = cells * UI_FONT->width;+ }+}static void render_tabs(ht_scene_t *f){- heading(f, "tabs");- int last = s.tab_count > TAB_ROWS ? s.tab_count - TAB_ROWS : 0;- if (s.offset > last) s.offset = last;- if (s.offset < 0) s.offset = 0;- if (!s.tab_count) {- center(f, 218, "No tabs yet.", DIM);- return;- }- for (int row = 0; row < TAB_ROWS && s.offset + row < s.tab_count; row++) {- int i = s.offset + row, y = TAB_TOP + row * TAB_ROW_HEIGHT;- int hit = s.hit_count++;- s.hits[hit] = (hit_t){{59, y, 348, TAB_ROW_HEIGHT}, A_TAB, i, s.connected};- bool selected = !strcmp(s.selected_tab, s.tabs[i].id);- char label[HT_TEXT_BYTES];- snprintf(label, sizeof label, " %s", s.tabs[i].name);- ht_text(f, 71, y + 14, 324, UI_FONT,- !s.connected ? DIM : selected || hit == s.pressed ? ACCENT : FG,- selected || hit == s.pressed ? SEL : BG, label);+ ht_arc_title(f, DIM, "tabs");+ int current = ht_tab_carousel_index(&tab_carousel);+ if (current < 0) center(f, 214, "No tabs yet.", DIM);+ else {+ for (int i = current - 1; i <= current + 1; i++) {+ if (i < 0 || i >= s.tab_count) continue;+ int dx = i * HT_TAB_PITCH - tab_carousel.position;+ uint16_t ink = !s.connected ? DIM : !strcmp(s.tabs[i].id, s.selected_tab) ? ACCENT : FG;+ int fade = abs(dx) * 140 / HT_TAB_PITCH;+ ink = ht_character_caption_ink(ink, BG, fade < 210 ? 255 - fade : 45);+ tab_name(f, s.tabs[i].name, 233 + dx, ink);+ }+ // Each visible name owns its tap; a swipe from any page only browses.+ // Keep the centered page first for stable accessibility/test ordering.+ for (int n = 0; n < 3; n++) {+ int i = current + (n == 1 ? -1 : n == 2 ? 1 : 0);+ if (i < 0 || i >= s.tab_count) continue;+ int cx = 233 + i * HT_TAB_PITCH - tab_carousel.position;+ int left = i ? cx - HT_TAB_PITCH / 2 : 33;+ int right = i + 1 < s.tab_count ? cx + HT_TAB_PITCH / 2 : 433;+ if (left < 33) left = 33;+ if (right > 433) right = 433;+ if (right > left) s.hits[s.hit_count++] = (hit_t){{left, 110, right - left, 252},+ A_TAB, i, s.connected && !s.loading};+ }}+ ht_text(f, 223, 400, 20, &ht_nav_32, DIM, BG, "←");+ s.hits[s.hit_count++] = (hit_t){{83, 392, 300, 74}, A_HOME, 0, true};}static void render_notice(ht_scene_t *f){@@ -1758,6 +1809,10 @@ static bool queue(action_t a)(void)a;return false; // Never enqueue a desktop or audio action in the visual study.#endif+ // Background read receipts must never occupy the last touch/audio slot or+ // replace the screen with a cable-busy warning. Retry quietly next tick.+ if (a.kind == A_NOTICE_READ)+ return actions && uxQueueSpacesAvailable(actions) > 1 && xQueueSend(actions, &a, 0) == pdPASS;// A live scroll owns the final slot, so a stalled USB writer cannot drop its UP.if (actions && ((!scroll.live && !selection.active && !visit.id[0]) || uxQueueSpacesAvailable(actions) > 1) &&xQueueSend(actions, &a, 0) == pdPASS)@@ -2087,14 +2142,9 @@ static void dispatch(action_t a)COPY(s.title,"Return"); COPY(s.message,"The cable is busy. Try again."); view(MESSAGE);}break;- case A_TABS: {- view(TABS);- int index=workspace_index(s.selected_tab);- int last=s.tab_count>TAB_ROWS ? s.tab_count-TAB_ROWS : 0;- int first=index-TAB_ROWS/2;- s.offset=first<0 ? 0 : first>last ? last : first;+ case A_TABS:+ tabs_open();break;- }#if HT_FACE_PX >= 720case A_TAB_STRIP_LEFT:case A_TAB_STRIP_RIGHT:@@ -2397,6 +2447,7 @@ static void dispatch(action_t a)}break;case A_QUESTION_READ:+ case A_NOTICE_READ:case A_TAB_REFRESH:case A_NONE:case A_SELECT_SEND:@@ -2458,6 +2509,9 @@ static void worker(void *unused)case A_DESKTOP:cable_client_send_open(a.id, NULL);break;+ case A_NOTICE_READ:+ cable_client_notification_read(a.id, a.text);+ break;case A_TAB: {display_lock();bool valid=s.connected && workspace.phase==HT_WORKSPACE_WAIT_TAB &&@@ -2604,7 +2658,13 @@ void habitat_touch(bool down, int x, int y, uint32_t now)return;}bool surface = s.view == HOME || s.view == AGENT;- if (s.touch_down && !s.touch_cancelled) surface_tick(now);+ if (s.touch_down && !s.touch_cancelled) {+ // Classify this sample before the hold deadline. A delayed MOVE/UP+ // must not turn a long swipe into a stationary hold.+ ht_gesture_move(&gesture, x, y);+ surface_tick(now);+ }+ surface = s.view == HOME || s.view == AGENT;if (down && !s.touch_down) {s.touch_cancelled = false;s.touch_brake = s.coasting && (int32_t)(now - s.coast_until) < 0;@@ -2639,6 +2699,7 @@ void habitat_touch(bool down, int x, int y, uint32_t now)s.tab_strip_held = (s.view == HOME || s.view == AGENT || s.view == AGENTS) && y < 96;s.tab_strip_drag = 0;#endif+ if (s.view == TABS && pressed_action.kind == A_TAB) ht_tab_carousel_begin(&tab_carousel, x, now);ht_gesture_begin(&gesture, x, y, now, ((uint32_t)s.view << 8) | pressed_action.kind);if (pressed_action.kind != A_PET && pressed_action.kind != A_FORM_MAIN && pressed_action.kind != A_FORM_SAY &&pressed_action.kind != A_ANSWER && pressed_action.kind != A_DRAFT_SEND && pressed_action.kind != A_DRAFT_EDIT &&@@ -2658,13 +2719,9 @@ void habitat_touch(bool down, int x, int y, uint32_t now)ht_gesture_move(&gesture, x, y);if (surface && home_footer(pressed_action.kind)) {if (pressed_action.kind==A_TABS && ht_workspace_move(&workspace,x,y,gesture.axis,now)) change();- } else if (s.quick_open) {- int dx = x - s.start_x, dy = y - s.start_y;- int choice = 0;- if (dx * dx + dy * dy > 54 * 54)- choice = abs(dx) > abs(dy) ? (dx < 0 ? 3 : 2) : (dy < 0 ? 1 : 4);- if (choice != s.quick_choice) { s.quick_choice = choice; change(); }- } else if ((s.view == TABS || s.view == AGENTS || s.view == SETTINGS) && gesture.axis == 1) {+ } else if (s.view == TABS) {+ if (gesture.axis == 2 && ht_tab_carousel_move(&tab_carousel, x, now)) change();+ } else if ((s.view == AGENTS || s.view == SETTINGS) && gesture.axis == 1) {tabs_move((s.last_y - y) * (scroll_reversed ? -1 : 1));} else if (s.view == DRAFT && gesture.axis == 1) {draft_move((s.last_y - y) * (scroll_reversed ? -1 : 1), now);@@ -2705,8 +2762,10 @@ void habitat_touch(bool down, int x, int y, uint32_t now)}if (!down && s.touch_down) {ht_touch_result_t result = ht_gesture_end(&gesture, x, y, now);- if (!s.touch_cancelled && (s.view == TABS || s.view == AGENTS || s.view == SETTINGS) && gesture.axis == 1)+ if (!s.touch_cancelled && (s.view == AGENTS || s.view == SETTINGS) && gesture.axis == 1)tabs_move((s.last_y - y) * (scroll_reversed ? -1 : 1));+ bool tab_contact = s.view == TABS && tab_carousel.touching;+ bool tab_tap = tab_contact && ht_tab_carousel_end(&tab_carousel, x, gesture.axis == 2, now);bool scrolled = ht_scroll_end(&scroll, x, y, now);if (scrolled) {uint32_t coast = ht_scroll_coast_ms(scroll.velocity);@@ -2715,20 +2774,10 @@ void habitat_touch(bool down, int x, int y, uint32_t now)}int dx = x - s.start_x, dy = y - s.start_y;s.pressed = -1;- if (s.quick_open && !s.touch_cancelled) {- // Use the release coordinates too: lifting after sliding back to- // the center cancels, even if no final MOVE sample was delivered.- int choice = 0;- if (dx * dx + dy * dy > 54 * 54)- choice = abs(dx) > abs(dy) ? (dx < 0 ? 3 : 2) : (dy < 0 ? 1 : 4);- static const action_kind_t destinations[] = {A_NONE, A_AGENTS, A_INBOX, A_TABS, A_SETTINGS};- s.quick_open = false;- if (choice) dispatch((action_t){.kind = destinations[choice]});- change();#if HT_FACE_PX >= 720- } else if (s.tab_strip_held && gesture.moved && gesture.axis == 2) {+ if (s.tab_strip_held && gesture.moved && gesture.axis == 2) {// The strip consumed this contact while it was moving; its end is not a choice.- } else if (pro_written_control(pressed_action.kind) &&+ } else if (!tab_contact && pro_written_control(pressed_action.kind) &&x >= pressed_rect.x && x < pressed_rect.x + pressed_rect.w &&y >= pressed_rect.y && y < pressed_rect.y + pressed_rect.h) {/*@@ -2748,9 +2797,15 @@ void habitat_touch(bool down, int x, int y, uint32_t now)*/ht_gesture_cancel(&gesture);dispatch(pressed_action);+ } else#endif- } else if (scrolled || s.touch_cancelled) {- // Motion owns this entire contact, even if the finger returns to its starting point.+ if (scrolled || s.touch_cancelled) {+ // Motion owns this entire contact, even if it returns to its start.+ } else if (tab_contact) {+ int index = pressed_action.value;+ if (tab_tap && result == HT_TOUCH_TAP && pressed_action.kind == A_TAB && index >= 0 &&+ index < s.tab_count && !strcmp(pressed_action.id, s.tabs[index].id)) dispatch(pressed_action);+ change();} else if (result == HT_TOUCH_TAP && s.touch_brake) {// DOWN already stopped desktop inertia. This entire tap is only a brake.} else if (surface && pressed_action.kind==A_TABS) {@@ -2784,8 +2839,8 @@ void habitat_touch(bool down, int x, int y, uint32_t now)dispatch((action_t){.kind = A_VOICE_STOP, .value = 1});} else if (s.view == DRAFT && pressed_action.kind == A_DRAFT_EDIT) {pressed_action.kind = A_DRAFT_OPTIONS; dispatch(pressed_action);- } else if ((surface && pressed_action.kind == A_PET) || pressed_action.kind == A_HOME || pressed_action.kind == A_TABS)- dispatch((action_t){.kind = A_SETTINGS});+ } else if (surface && pressed_action.kind == A_PET)+ tabs_open();} else if (result == HT_TOUCH_TAP) {if (pressed_action.kind == A_PET) {if (surface) dispatch(pressed_action); // immediate, harmless acknowledgement@@ -2824,7 +2879,9 @@ void habitat_touch(bool down, int x, int y, uint32_t now)if (next >= 0 && next < count) s.offset = next;}} else if (gesture.axis == 2 && abs(dx) > 60 && abs(dx) > abs(dy)) {- if (s.view == DRAFT || s.view == DRAFT_OPTIONS) {+ if (s.view == TABS) {+ // The carousel owns horizontal motion, including contacts that began on its footer.+ } else if (s.view == DRAFT || s.view == DRAFT_OPTIONS) {if (dx > 0) {action_t a = make_action((hit_t){.action = s.view == DRAFT ? A_DRAFT_OPTIONS : A_DRAFT_BACK});dispatch(a);@@ -2875,6 +2932,7 @@ uint32_t habitat_next_wake_ms(void)return delay;if (s.voice_open)delay = 125;+ if (s.view == TABS && tab_carousel.animating && !s.locked && !display_is_asleep()) delay = 16;if (selection.pending && delay > 100) delay = 100;if (visit.pending && delay > 100) delay = 100;if (s.view == FORM && delay > 100) delay = 100;@@ -2888,7 +2946,7 @@ uint32_t habitat_next_wake_ms(void)if ((s.view == HOME || s.view == AGENT) && pressed_action.kind == A_PET && s.touch_down && !s.touch_cancelled &&gesture.live && !gesture.moved && !gesture.guarded) {uint32_t elapsed = now - s.touch_started;- uint32_t due = s.quick_open ? 5000 : 650;+ uint32_t due = 650;uint32_t left = elapsed >= due ? 1 : due - elapsed;if (left < delay) delay = left;}@@ -3665,16 +3723,60 @@ void ui_notif_seen(const char *id)// change. That acknowledgement also completes the requested inbox open.if (opened) ui_focus_project(id);}+void ui_notif_read(const char *id, const char *token)+{+ if (!id || !token || !token[0]) return;+ display_lock();+ for (int i = 0; i < NOTICES; i++)+ if (!strcmp(s.notice_reads[i].id, id) && !strcmp(s.notice_reads[i].token, token))+ s.notice_reads[i].pending = false;+ bool opened = false;+ for (int i = 0; i < s.notice_count; i++) {+ cable_notif_t *n = &s.notice[i];+ if (strcmp(n->agent_id, id) || strcmp(n->read_token, token)) continue;+ n->read_on_dial = true;+ opened = !strcmp(s.opening_notice, id);+ if (s.view != INBOX || i != s.offset || opened) {+ notice_remove(id, true); notice_sync_view();+ }+ change(); break;+ }+ display_unlock();+ if (opened) ui_focus_project(id);+}void ui_notif_replace(const cable_notif_t *rows, int count){display_lock();char selected[ID_MAX]; notice_selection(selected, sizeof selected);+ cable_notif_t held = {0};+ if (selected[0] && s.notice[s.offset].read_on_dial && s.notice[s.offset].read_token[0])+ held = s.notice[s.offset];if (!rows || count < 0) count = 0;if (count > NOTICES) count = NOTICES;s.notice_count = 0;- for (int i = count - 1; i >= 0; i--)+ for (int i = count - 1; i >= 0; i--) {notice_add(rows[i].agent_id, rows[i].name, rows[i].machine, rows[i].summary,rows[i].question, rows[i].failed);+ for (int j = 0; j < s.notice_count; j++) if (!strcmp(s.notice[j].agent_id, rows[i].agent_id)) {+ COPY(s.notice[j].read_token, rows[i].read_token);+ s.notice[j].read_on_dial = notice_was_read(&s.notice[j]);+ break;+ }+ }+ // An authoritative absence acknowledges the read. It must not make the+ // card disappear while the person is still reading it.+ for (int i = 0; i < NOTICES; i++) if (s.notice_reads[i].pending) {+ bool present = false;+ for (int j = 0; j < count; j++)+ if (!strcmp(rows[j].agent_id, s.notice_reads[i].id) &&+ !strcmp(rows[j].read_token, s.notice_reads[i].token)) present = true;+ if (!present) s.notice_reads[i].pending = false;+ }+ bool retained = false;+ for (int i = 0; i < s.notice_count; i++) if (!strcmp(s.notice[i].agent_id, selected)) retained = true;+ if (held.agent_id[0] && !retained && s.notice_count < NOTICES) {+ s.notice[s.notice_count++] = held;+ }notice_restore_selection(selected);notice_sync_view();change();@@ -3816,14 +3918,21 @@ void ui_swarms_replace(const cable_swarm_t *rows, int count, const char *selectedisplay_lock();int bounded=count<0 ? 0 : count>SWARMS_MAX ? SWARMS_MAX : count;if (!rows) bounded=0;+ char focused[ID_MAX] = "";+ int focused_index = ht_tab_carousel_index(&tab_carousel);+ if (s.view == TABS && focused_index >= 0 && focused_index < s.tab_count) COPY(focused, s.tabs[focused_index].id);bool changed=bounded!=s.tab_count || strcmp(s.selected_tab,selected ? selected : "");for (int i=0;!changed && i<bounded;i++) {- changed=strcmp(rows[i].id,s.tabs[i].id) || strcmp(rows[i].name,s.tabs[i].name) || rows[i].panes!=s.tabs[i].panes;+ changed=strcmp(rows[i].id,s.tabs[i].id) || strcmp(rows[i].name,s.tabs[i].name);}if (changed && (workspace.touching || s.view == TABS)) input_cancel();s.tab_count=bounded;if (bounded) memcpy(s.tabs,rows,(size_t)bounded*sizeof *rows);COPY(s.selected_tab,selected);+ if (changed && s.view == TABS) {+ int index = workspace_index(focused);+ ht_tab_carousel_reset(&tab_carousel, bounded, index >= 0 ? index : workspace_index(s.selected_tab));+ }if (workspace.phase!=HT_WORKSPACE_IDLE && workspace_index(workspace.pending)<0) {workspace_failed("That workspace is gone. Choose another.");} else if (ht_workspace_selected(&workspace,s.selected_tab)) {diff --git a/devices/harness-device/firmware/main/ui/habitat/workspace.c b/devices/harness-device/firmware/main/ui/habitat/workspace.cindex 1a94782eb..72c38b203 100644--- a/devices/harness-device/firmware/main/ui/habitat/workspace.c+++ b/devices/harness-device/firmware/main/ui/habitat/workspace.c@@ -71,3 +71,86 @@ bool ht_workspace_tick(ht_workspace_t *w, uint32_t now)if (w->phase == HT_WORKSPACE_IDLE || (int32_t)(now - w->deadline) < 0) return false;ht_workspace_cancel_request(w); return true;}++static int bounded(int value, int low, int high)+{+ return value < low ? low : value > high ? high : value;+}+int ht_tab_carousel_index(const ht_tab_carousel_t *c)+{+ return c->count ? bounded((c->position + HT_TAB_PITCH / 2) / HT_TAB_PITCH, 0, c->count - 1) : -1;+}+void ht_tab_carousel_reset(ht_tab_carousel_t *c, int count, int index)+{+ count = bounded(count, 0, 24);+ *c = (ht_tab_carousel_t){.count=count};+ c->position = c->target = count ? bounded(index, 0, count - 1) * HT_TAB_PITCH : 0;+}+void ht_tab_carousel_cancel(ht_tab_carousel_t *c)+{+ ht_tab_carousel_reset(c, c->count, ht_tab_carousel_index(c));+}+bool ht_tab_carousel_tick(ht_tab_carousel_t *c, uint32_t now)+{+ if (!c->animating) return false;+ int previous = c->position;+ uint32_t elapsed = now - c->animation_at;+ if (elapsed >= HT_TAB_SETTLE_MS) {+ c->position = c->target; c->animating = false;+ } else {+ int left = HT_TAB_SETTLE_MS - (int)elapsed;+ c->position = c->target + (c->from - c->target) * left * left /+ (HT_TAB_SETTLE_MS * HT_TAB_SETTLE_MS);+ }+ return previous != c->position;+}+void ht_tab_carousel_begin(ht_tab_carousel_t *c, int x, uint32_t now)+{+ bool moving = c->animating;+ ht_tab_carousel_tick(c, now);+ c->braking = moving;+ c->animating = c->moved = false;+ c->touching = c->count > 0;+ c->origin = c->position;+ c->x = c->last_x = x;+ c->began = c->sampled = now;+ c->velocity = 0;+}+bool ht_tab_carousel_move(ht_tab_carousel_t *c, int x, uint32_t now)+{+ if (!c->touching) return false;+ int travel = bounded(c->x - x, -466, 466);+ if (!c->moved && abs(travel) < 12) return false;+ c->moved = true;+ // A slow 57 px swipe reaches the next page; no need to cross the dial.+ int old = c->position, position = c->origin + travel * HT_TAB_DRAG_GAIN;+ int end = (c->count - 1) * HT_TAB_PITCH;+ // Soft edges, with no accumulated overscroll to undo on reversal.+ c->position = position < 0 ? position / 4 : position > end ? end + (position - end) / 4 : position;+ uint32_t dt = now - c->sampled;+ if (dt) {+ int speed = dt > 100 ? 0 : bounded((c->last_x - x) * 1000 / (int)dt, -3000, 3000) * HT_TAB_DRAG_GAIN;+ c->velocity = dt > 100 ? 0 : (speed * 3 + c->velocity * 2) / 5;+ c->last_x = x; c->sampled = now;+ }+ return old != c->position;+}+bool ht_tab_carousel_end(ht_tab_carousel_t *c, int x, bool horizontal, uint32_t now)+{+ if (!c->touching) return false;+ if (horizontal) ht_tab_carousel_move(c, x, now);+ c->touching = false;+ bool open = !c->moved && !c->braking;+ int projected = c->position;+ if (c->moved && now - c->began >= 25) {+ int momentum = now - c->sampled < 100 ?+ bounded(c->velocity * 120 / 1000, -HT_TAB_PITCH / 2, HT_TAB_PITCH / 2) : 0;+ projected += momentum;+ }+ int index = bounded((projected + HT_TAB_PITCH / 2) / HT_TAB_PITCH, 0, c->count - 1);+ c->target = index * HT_TAB_PITCH;+ c->from = c->position;+ c->animation_at = now;+ c->animating = c->position != c->target;+ return open && !c->animating;+}diff --git a/devices/harness-device/firmware/main/ui/habitat/workspace.h b/devices/harness-device/firmware/main/ui/habitat/workspace.hindex d20d4a53f..a81ada64e 100644--- a/devices/harness-device/firmware/main/ui/habitat/workspace.h+++ b/devices/harness-device/firmware/main/ui/habitat/workspace.h@@ -24,3 +24,19 @@ bool ht_workspace_refresh(ht_workspace_t *, uint32_t serial, uint32_t generationbool ht_workspace_applied(ht_workspace_t *, const char *id, uint32_t generation);void ht_workspace_cancel_request(ht_workspace_t *);bool ht_workspace_tick(ht_workspace_t *, uint32_t now);++// Thumb-driven tab pages. Position is in glass pixels; all easing is integer.+// Browsing never sends a request. Only a subsequent, settled tap may open a tab.+enum { HT_TAB_PITCH = 228, HT_TAB_DRAG_GAIN = 2, HT_TAB_SETTLE_MS = 192 };+typedef struct {+ int count, position, from, target, origin, x, last_x, velocity;+ uint32_t began, sampled, animation_at;+ bool touching, moved, animating, braking;+} ht_tab_carousel_t;+void ht_tab_carousel_reset(ht_tab_carousel_t *, int count, int index);+int ht_tab_carousel_index(const ht_tab_carousel_t *);+void ht_tab_carousel_cancel(ht_tab_carousel_t *);+void ht_tab_carousel_begin(ht_tab_carousel_t *, int x, uint32_t now);+bool ht_tab_carousel_move(ht_tab_carousel_t *, int x, uint32_t now);+bool ht_tab_carousel_end(ht_tab_carousel_t *, int x, bool horizontal, uint32_t now);+bool ht_tab_carousel_tick(ht_tab_carousel_t *, uint32_t now);diff --git a/devices/harness-device/firmware/main/ui/ui_screens.c b/devices/harness-device/firmware/main/ui/ui_screens.cindex a609c41f7..29799024c 100644--- a/devices/harness-device/firmware/main/ui/ui_screens.c+++ b/devices/harness-device/firmware/main/ui/ui_screens.c@@ -7344,6 +7344,12 @@ void ui_notif_replace(const cable_notif_t *rows, int count)display_unlock();}+void ui_notif_read(const char *project_id, const char *read_token)+{+ // The legacy renderer does not keep notification identities.+ (void)project_id; (void)read_token;+}+void ui_notif_seen(const char *project_id){if (!project_id || !project_id[0]) return;diff --git a/devices/harness-device/firmware/main/ui/ui_screens.h b/devices/harness-device/firmware/main/ui/ui_screens.hindex a99546329..18fd92c0e 100644--- a/devices/harness-device/firmware/main/ui/ui_screens.h+++ b/devices/harness-device/firmware/main/ui/ui_screens.h@@ -337,6 +337,7 @@ void ui_notify_task_done(const char *project_id, const char *name, const char *m// first time either is used. The tap's half already travels (cable_client_send_open); this is the// return leg. No-op when no row names this agent. Safe from the reader task.void ui_notif_seen(const char *project_id);+void ui_notif_read(const char *project_id, const char *read_token);// Replace the WHOLE drawer with what the window still has unread, newest first.//// Sent once per attach, because that is the one moment this dial is known to have nothing: the rowsdiff --git a/devices/harness-device/firmware/scripts/gen_display_fallbacks.py b/devices/harness-device/firmware/scripts/gen_display_fallbacks.pynew file mode 100644index 000000000..edb3c52cc--- /dev/null+++ b/devices/harness-device/firmware/scripts/gen_display_fallbacks.py@@ -0,0 +1,106 @@+#!/usr/bin/env python3+"""Bake small display fallbacks; no Unicode library runs on the device.++Generated with Python's Unicode 16.0.0 data. Compatibility decomposition gives+text equivalents for fractions, ligatures, fullwidth and styled letters/digits.+Only ASCII results are admitted. Never strip a combining negation from math.+Regeneration requires the same Unicode data version; ordinary builds use the+checked-in table. https://www.unicode.org/reports/tr15/+"""+from pathlib import Path+import argparse+import json+import unicodedata as ud++parser = argparse.ArgumentParser(description=__doc__)+parser.add_argument('--check', action='store_true')+args = parser.parse_args()+if ud.unidata_version != '16.0.0':+ raise SystemExit('Regeneration requires Unicode 16.0.0 (Python 3.14).')++values = {}+for cp in range(160, 0x110000):+ source = chr(cp)+ text = ud.normalize('NFKD', source).replace('⁄', '/')+ # Latin-letter accents may fall back to the base letter if absent from the+ # atlas. Marks on operators, numbers and other scripts are never removed.+ if ud.name(source, '').startswith('LATIN '):+ text = ''.join(c for c in text if not ud.combining(c))+ if text != source and text and all(32 <= ord(c) <= 126 for c in text):+ if cp in (0xb2, 0xb3, 0xb9) or 0x2070 <= cp <= 0x207f:+ text = '^' + text+ elif 0x2080 <= cp <= 0x209f:+ text = '_' + text+ values[cp] = text++# Semantic equivalents not supplied by compatibility decomposition. Existing+# native glyphs win, so the proper arrows/check/cross remain visible on the dial.+groups = {+ ' ': '\u00a0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u2028\u2029\u202f\u205f\u3000',+ '': '\u00ad\u200b\u200c\u200d\u2060\ufeff',+ '-': '‐‑‒–—―−', "'": '‘’‚‛′', '"': '“”„‟″',+ '...': '…', '*': '•‣⁃∙⋅', '/': '⁄∕', 'x': '×✕',+ '<=': '≤≦', '>=': '≥≧', '!=': '≠', '!<': '≮', '!>': '≯',+ '!<=': '≰', '!>=': '≱', '~=': '≈≃≅', '+/-': '±', '-/+': '∓',+ 'infinity': '∞', 'sqrt': '√', 'sum': '∑', 'pi': 'π',+ '<-': '←⇐', '->': '→➜➔➝➞➟➠➡➤➥➦➧➨➩➪➫➬➭➮➯➱⇢',+ '=>': '⇒', '<->': '↔', '<=>': '⇔', '^': '↑⇧', 'v': '↓⇩',+ '^>': '↗', '<^': '↖', 'v>': '↘', '<v': '↙', '[return]': '↵⏎',+ '(C)': '©', '(R)': '®', '(TM)': '™', 'EUR': '€', 'GBP': '£', 'JPY': '¥',+ '[ok]': '✓✔✅☑', '[x]': '✗✘❌❎', '[!]': '⚠❗‼', '[?]': '❓❔',+ '[bell]': '🔔', '[locked]': '🔒', '[unlocked]': '🔓', '[pin]': '📌',+ '[idea]': '💡', '[bug]': '🐛', '[test]': '🧪', '[tool]': '🔧',+ '[settings]': '⚙', '[note]': '📝', '[file]': '📄', '[folder]': '📁📂',+ '[launch]': '🚀', '[celebrate]': '🎉', '[fire]': '🔥', '[stop]': '🛑',+ '[up]': '👍', '[down]': '👎', '[heart]': '♥❤', '[computer]': '💻',+}+for text, chars in groups.items():+ for ch in chars:+ values[ord(ch)] = text++# Consecutive one-character folds (e.g. fullwidth A-Z) need one range, not 26+# entries. Remaining strings are pooled/deduplicated. All arrays stay in flash.+ranges, entries = [], []+points = sorted(values)+i = 0+while i < len(points):+ cp = points[i]+ text = values[cp]+ end = i + 1+ if len(text) == 1:+ while end < len(points) and points[end] == points[end - 1] + 1 and \+ len(values[points[end]]) == 1 and ord(values[points[end]]) - points[end] == ord(text) - cp:+ end += 1+ if end - i >= 3:+ ranges.append((cp, points[end - 1], ord(text) - cp))+ i = end+ else:+ entries.append((cp, text))+ i += 1++pool, offsets = '', {}+for _, text in entries:+ if text not in offsets:+ offsets[text] = len(pool)+ pool += text + '\0'+offset_bits = len(pool).bit_length()+assert (max(cp for cp, _ in entries) << offset_bits) <= 0xffffffff+output = ['// Generated by scripts/gen_display_fallbacks.py; Unicode 16.0.0.\n',+ '// Display-only equivalents. Original messages and identities stay unchanged.\n',+ 'static const struct { uint32_t first, last; int32_t delta; } display_ranges[] = {\n']+output += [f' {{0x{a:x},0x{b:x},{delta}}},\n' for a,b,delta in ranges]+output += ['};\nstatic const char display_pool[] =\n']+for text in offsets:+ output.append(' ' + json.dumps(text + '\0', ensure_ascii=True).replace('\\u0000', '\\000') + '\n')+output += [f';\nenum {{ DISPLAY_OFFSET_BITS = {offset_bits}, DISPLAY_OFFSET_MASK = {(1 << offset_bits)-1} }};\n',+ 'static const uint32_t display_entries[] = {\n']+output += [f' 0x{(cp << offset_bits) | offsets[text]:x},\n' for cp,text in entries]+output += ['};\n']+data = ''.join(output)+path = Path(__file__).resolve().parents[1] / 'main/ui/habitat/display_fallbacks.inc'+if args.check:+ if path.read_text() != data:+ raise SystemExit('Display fallback table is stale')+else:+ path.write_text(data)+print(f'{len(values)} equivalents: {len(ranges)} ranges, {len(entries)} entries, {len(pool)} pooled bytes')diff --git a/devices/harness-device/firmware/scripts/gen_habitat_fonts.py b/devices/harness-device/firmware/scripts/gen_habitat_fonts.pyindex dd9494693..2b4c4afad 100644--- a/devices/harness-device/firmware/scripts/gen_habitat_fonts.py+++ b/devices/harness-device/firmware/scripts/gen_habitat_fonts.py@@ -16,7 +16,9 @@ fonts = [('ht_mono_16',mono,16,10,22,17),('ht_mono_20',mono,20,12,28,22),('ht_nav_32',mono,32,20,44,35),('ht_lock_dot',pixel,40,40,48,40),('ht_bell_20',mono,20,12,28,22),('ht_bell_28',mono,28,17,38,31),('ht_bell_footer',mono,28,26,38,31),- ('ht_done_28',mono,28,17,38,31),('ht_failed_28',mono,28,17,38,31)]+ ('ht_done_28',mono,28,17,38,31),('ht_failed_28',mono,28,17,38,31),+ ('ht_right_20',mono,20,12,28,22),('ht_right_28',mono,28,17,38,31),+ ('ht_open_28',mono,28,17,38,31)]with dest.open('w') as out:out.write('// Generated by scripts/gen_habitat_fonts.py. Do not edit.\n#include "terminal.h"\n')curved_bounds=[]@@ -25,7 +27,7 @@ with dest.open('w') as out:data=[]bounds=[]# Latin-1 keeps common names readable; unknown Unicode renders ?, never changes wire text.- first,last=(0xe000,0xe000) if name.startswith('ht_bell_') else (0x2713,0x2713) if name=='ht_done_28' else (0x2717,0x2717) if name=='ht_failed_28' else (0x2190,0x2197) if name=='ht_nav_32' else (0x2197,0x2197) if name=='ht_open_20' else (ord('o'),ord('o')) if name=='ht_lock_dot' else (32,255 if name!='ht_pixel_40' else 126)+ first,last=(0xe000,0xe000) if name.startswith('ht_bell_') else (0x2713,0x2713) if name=='ht_done_28' else (0x2717,0x2717) if name=='ht_failed_28' else (0x2190,0x2197) if name=='ht_nav_32' else (0x2197,0x2197) if name.startswith('ht_open_') else (0x2192,0x2192) if name.startswith('ht_right_') else (ord('o'),ord('o')) if name=='ht_lock_dot' else (32,255 if name!='ht_pixel_40' else 126)for cp in range(first,last+1):im=Image.new('L',(width,height));ImageDraw.Draw(im).text((0,baseline),chr(cp),font=font,fill=255,anchor='ls',stroke_width=0)if name.startswith('ht_bell_'):@@ -54,7 +56,7 @@ with dest.open('w') as out:stroke([(14,17),(3,28)])im=hi.resize((width,height),Image.Resampling.LANCZOS)values=[min(3,(v+42)//85) for v in im.get_flattened_data()]- if name in ('ht_mono_20','ht_open_20','ht_bell_20'):+ if name in ('ht_mono_20','ht_open_20','ht_right_20','ht_bell_20'):ink=[(i%width,i//width) for i,a in enumerate(values) if a]bounds.append((min(x for x,y in ink),min(y for x,y in ink),max(x for x,y in ink),max(y for x,y in ink)) if ink else (0,0,0,0))diff --git a/devices/harness-device/firmware/test/bridge_flow_replay.py b/devices/harness-device/firmware/test/bridge_flow_replay.pyindex 3e9d5a786..2226f236e 100644--- a/devices/harness-device/firmware/test/bridge_flow_replay.py+++ b/devices/harness-device/firmware/test/bridge_flow_replay.py@@ -53,7 +53,7 @@ static void audio_notify_done(void) {} // no real speaker or audio hardware in textra += 'assert(!decoder.corrupt_frames && !decoder.discarded_bytes && !s_bad && !s_unknown && s_last_rx_us);scene_take();\n'extra += f'assert(active()->busy=={str(wanted["busy"]).lower()});assert(result_visible()=={str(wanted["recap"]).lower()});\n'extra += 'assert(!strcmp(active()->tool,' + json.dumps(wanted['status']) + '));\n'- extra += 'assert(title_is(active()->name));char bell[24];if(s.notice_count)snprintf(bell,sizeof bell,HT_BELL \" %d\",s.notice_count);else strcpy(bell,HT_BELL);assert(status_is(bell));\n'+ extra += 'assert(title_is(active()->name));char bell[24];unsigned unread=notice_unread();if(unread)snprintf(bell,sizeof bell,HT_BELL \" %u\",unread);else bell[0]=0;assert(status_is(bell));\n'display_status = wanted.get('display_status', wanted['status'])if display_status:extra += 'fake_ms+=3400;surface_tick(fake_ms);scene_take();\n'diff --git a/devices/harness-device/firmware/test/test_cable_identity.py b/devices/harness-device/firmware/test/test_cable_identity.pyindex 2c7cbb855..1c204a57f 100644--- a/devices/harness-device/firmware/test/test_cable_identity.py+++ b/devices/harness-device/firmware/test/test_cable_identity.py@@ -119,6 +119,15 @@ int main(void) {notices[1].question && !notices[1].failed && !notices[2].question && !notices[2].failed);p=cJSON_Parse("{\"items\":[{\"agentId\":\"failed\"}]}");assert(p);handle_notifications(p);cJSON_Delete(p);assert(notice_count==1&&!notices[0].failed);+ for(int len=0;len<=65;len++) {+ char token[66];memset(token,'t',len);token[len]=0;+ p=cJSON_CreateObject();assert(p);cJSON *entries=cJSON_AddArrayToObject(p,"items");+ cJSON *row=cJSON_CreateObject();assert(cJSON_AddItemToArray(entries,row));+ assert(cJSON_AddStringToObject(row,"agentId","receipt"));+ assert(cJSON_AddStringToObject(row,"readToken",token));handle_notifications(p);+ assert(notice_count==1 && strlen(notices[0].read_token)==(len>0&&len<64?(size_t)len:0));+ cJSON_Delete(p);bounds();+ }char profile[sizeof models[0].id],bad_profile[sizeof models[0].id+1];memset(profile,'p',sizeof profile-1);profile[sizeof profile-1]=0;snprintf(bad_profile,sizeof bad_profile,"%sx",profile);diff --git a/devices/harness-device/firmware/test/test_cable_outbound.py b/devices/harness-device/firmware/test/test_cable_outbound.pyindex d93761644..ed6c3f228 100644--- a/devices/harness-device/firmware/test/test_cable_outbound.py+++ b/devices/harness-device/firmware/test/test_cable_outbound.py@@ -4,6 +4,7 @@ import osimport reimport subprocessimport tempfile+from native_shapes import definesmain = Path(__file__).resolve().parent / '../main'source = Path(os.environ.get('CABLE_OUTBOUND_SOURCE', main / 'cable_client.c')).read_text()@@ -67,18 +68,19 @@ static void audio_client_copy_selection(char *out,size_t n,unsigned *revision) {}static bool audio_client_review_requested(void) {return review;}'''+code += defines('ID_MAX', 'CABLE_READ_TOKEN_MAX')for name in ['cable_client_supports', 'send_json', 'msg']:code += function(name)for name in ['msg_check', 'msg_string', 'msg_number', 'msg_bool', 'msg_array', 'msg_item']:code += function(name, optional=True)for name in ['select_machine', 'select_swarm', 'send_turn', 'stop_turn', 'send_focus', 'send_open',- 'send_scroll', 'answer', 'question_read', 'answer_reviewed', 'agent_update',+ 'notification_read', 'send_scroll', 'answer', 'question_read', 'answer_reviewed', 'agent_update','voice_begin', 'carry', 'form', 'visit', 'select_text', 'draft', 'voice_end','voice_abort', 'voice_cancel', 'voice_confirm', 'fw_error', 'fw_progress']:code += function('cable_client_' + name)code += function('cable_client_request_agents')code += r'''-enum { CASES=25 };+enum { CASES=26 };static void run(unsigned which) {static const uint8_t choices[]={1,2,4,8};static const char drafts[4][48]={"Keep the quoted \"text\".","", "Line 1\nLine 2", "é ↗"};@@ -108,6 +110,7 @@ static void run(unsigned which) {case 22:cable_client_fw_progress(UINT32_MAX);break;case 23:cable_client_carry("carry-1234",NULL,NULL,0,0,true);break;case 24:cable_client_voice_begin(NULL,NULL,NULL,16000);break;+ case 25:cable_client_notification_read("target-agent","notice-42");break;default:assert(false);}}diff --git a/devices/harness-device/firmware/test/test_question_ui.py b/devices/harness-device/firmware/test/test_question_ui.pyindex 13f0f6951..bb61887f5 100644--- a/devices/harness-device/firmware/test/test_question_ui.py+++ b/devices/harness-device/firmware/test/test_question_ui.py@@ -27,7 +27,7 @@ code = r'''#include "../../cable_features.h"static bool cable_client_supports(uint32_t features) { (void)features; return true; }'''-code += defines('ID_MAX','CABLE_NAME_MAX')+code += defines('ID_MAX','CABLE_NAME_MAX','CABLE_READ_TOKEN_MAX')code += defines('QUESTION_MAX','OPTION_MAX','PANE_RESULT_BYTES','UI_FONT','Q_ROWS',source=source)code += source[source.index('typedef enum {'):source.index('typedef struct {\n char id[ID_MAX], name[CABLE_NAME_MAX]')]code += source[source.index('typedef struct {\n char key[256]'):source.index('static EXT_RAM_BSS_ATTR struct {')]diff --git a/devices/harness-device/firmware/test/test_terminal.c b/devices/harness-device/firmware/test/test_terminal.cindex 5efa63fd1..d48bf955b 100644--- a/devices/harness-device/firmware/test/test_terminal.c+++ b/devices/harness-device/firmware/test/test_terminal.c@@ -56,19 +56,24 @@ static void punctuation_checks(void)static void inline_arrow_checks(void){- const int x = 80, y = 100, cell = ht_mono_20.width;+ const ht_font_t *fonts[]={&ht_mono_20,&ht_mono_28};+ const ht_font_t *arrows[][2]={{&ht_right_20,&ht_open_20},{&ht_right_28,&ht_open_28}};+ const char *marks[]={"→","↗"};+ for(unsigned size=0;size<2;size++) for(unsigned mark=0;mark<2;mark++) {+ const int x = 80, y = 100, cell = fonts[size]->width;+ assert(arrows[size][mark]->width==cell && arrows[size][mark]->height==fonts[size]->height);ht_scene_t inline_text, separate, question;ht_scene_clear(&inline_text, 0);ht_scene_clear(&separate, 0);ht_scene_clear(&question, 0);- const char *text = "Open \xe2\x86\x97 now";- ht_text(&inline_text, x, y, cell * 10, &ht_mono_20, 0xffff, 0, text);- ht_text(&separate, x, y, cell * 5, &ht_mono_20, 0xffff, 0, "Open ");- ht_text(&separate, x + cell * 5, y, cell, &ht_open_20, 0xffff, 0, "\xe2\x86\x97");- ht_text(&separate, x + cell * 6, y, cell * 4, &ht_mono_20, 0xffff, 0, " now");- ht_text(&question, x, y, cell * 10, &ht_mono_20, 0xffff, 0, "Open ? now");+ char text[32]; snprintf(text,sizeof text,"Open %s now",marks[mark]);+ ht_text(&inline_text, x, y, cell * 10, fonts[size], 0xffff, 0, text);+ ht_text(&separate, x, y, cell * 5, fonts[size], 0xffff, 0, "Open ");+ ht_text(&separate, x + cell * 5, y, cell, arrows[size][mark], 0xffff, 0, marks[mark]);+ ht_text(&separate, x + cell * 6, y, cell * 4, fonts[size], 0xffff, 0, " now");+ ht_text(&question, x, y, cell * 10, fonts[size], 0xffff, 0, "Open ? now");assert(!strcmp(inline_text.runs[0].text, text));- assert(ht_can_display(text, &ht_mono_20, cell * 10, 1));+ assert(ht_can_display(text, fonts[size], cell * 10, 1));ht_raster(&inline_text, (ht_rect_t){0, 0, HT_WIDTH, HT_HEIGHT}, full);ht_raster(&separate, (ht_rect_t){0, 0, HT_WIDTH, HT_HEIGHT}, scratch);assert(!memcmp(full, scratch, sizeof full));@@ -76,7 +81,7 @@ static void inline_arrow_checks(void)assert(memcmp(full, scratch, sizeof full));// The damage pass must not mistake the arrow for the old fallback glyph.ht_damage_t d; ht_damage(&question, &inline_text, &d);- assert(d.count && d.pixels == (uint32_t)(cell * ht_mono_20.height));+ assert(d.count && d.pixels >= (uint32_t)(cell * fonts[size]->height));transition(NULL, &question);transition(&question, &inline_text);transition(&inline_text, &question);@@ -85,6 +90,15 @@ static void inline_arrow_checks(void)ht_raster(&inline_text, clip, full);ht_raster(&separate, clip, scratch);assert(!memcmp(full, scratch, (size_t)clip.w * clip.h * sizeof *full));+ }+ // Curved titles have a separate cached-mask path and must accept → too.+ ht_scene_t a,b; ht_scene_clear(&a,0); ht_scene_clear(&b,0);+ ht_arc_title(&a,0xffff,"Egg → Tim"); ht_arc_title(&b,0xffff,"Egg ? Tim");+ transition(NULL,&a); memcpy(scratch,full,sizeof full);+ ht_raster(&b,(ht_rect_t){0,0,HT_WIDTH,HT_HEIGHT},full);+ assert(memcmp(full,scratch,sizeof full));+ transition(&a,&b); transition(&b,&a);+ puts("Inline arrows: right/diagonal, native 20/28 px cells, curved label, no fallback or atlas overread PASS");}@@ -240,6 +254,85 @@ static void lock_dot_checks(void)puts("lock dot: exact old glyph bytes and nine-dot screen; 45120 unused font bytes removed");}+static size_t utf8_encode(char *p, unsigned cp)+{+ if(cp<0x80) { p[0]=(char)cp; return 1; }+ if(cp<0x800) { p[0]=(char)(0xc0|(cp>>6));p[1]=(char)(0x80|(cp&63));return 2; }+ if(cp<0x10000) { p[0]=(char)(0xe0|(cp>>12));p[1]=(char)(0x80|((cp>>6)&63));p[2]=(char)(0x80|(cp&63));return 3; }+ p[0]=(char)(0xf0|(cp>>18));p[1]=(char)(0x80|((cp>>12)&63));p[2]=(char)(0x80|((cp>>6)&63));p[3]=(char)(0x80|(cp&63));return 4;+}+static void display_text_checks(void)+{+ const char *cases[][2]={+ {"Swipes need about ⅓ the previous travel.","Swipes need about 1/3 the previous travel."},+ {"1⅓ + ⅔ = 2", "1 1/3 + 2/3 = 2"}, {"⅓⅔", "1/3 2/3"}, {"⅓2", "1/3 2"},+ {"½ ¼ ¾ ⅐ ⅑ ⅒ ⅕ ⅖ ⅗ ⅘ ⅙ ⅚ ⅛ ⅜ ⅝ ⅞", "1/2 1/4 3/4 1/7 1/9 1/10 1/5 2/5 3/5 4/5 1/6 5/6 1/8 3/8 5/8 7/8"},+ {"≤ ≥ ≠ ≮ ≯ ≰ ≱ ≈", "<= >= != !< !> !<= !>= ~="},+ {"⇒ ↔ ⇔", "=> <-> <=>"}, {"Egg → Tim ↗", "Egg → Tim ↗"},+ {"x₂ xⁿ 𝟠 ① ABC fix ffi", "x_2 x^n 8 1 ABC fix ffi"},+ {"“café”—naïve ✓ ✗", "“café”—naïve ✓ ✗"},+ {"✅ ❌ ⚠️ 🔔", "[ok] [x] [!] [bell]"},+ {"a\u00a0b\u2009c\u200bd", "a b cd"},+ {"👾 猫", "[U+1F47E] [U+732B]"},+ {"Literal ? stays ?", "Literal ? stays ?"},+ {"\xed\xa0\x80", "[U+FFFD]"}, {"\xf4\x90\x80\x80", "[U+FFFD]"},+ {"\xe0\x80\x80", "[U+FFFD]"}, {"\xf0\x9f", "[U+FFFD]"},+ };+ char actual[256];+ for(unsigned i=0;i<sizeof cases/sizeof cases[0];i++) {+ assert(ht_display_text(actual,sizeof actual,cases[i][0],&ht_mono_28));+ if(strcmp(actual,cases[i][1])) { fprintf(stderr,"Fallback mismatch: %s -> %s (wanted %s)\n",cases[i][0],actual,cases[i][1]); abort(); }+ assert(ht_can_display(actual,&ht_mono_28,400,256));+ char again[256]; ht_display_text(again,sizeof again,actual,&ht_mono_28);+ assert(!strcmp(actual,again)); // normalization is idempotent+ for(size_t cap=1;cap<100;cap++) {+ unsigned char guarded[104]; memset(guarded,0xa5,sizeof guarded);+ ht_display_text((char *)guarded+1,cap,cases[i][0],&ht_mono_28);+ assert(guarded[0]==0xa5 && guarded[cap+1]==0xa5);+ assert(strlen((char *)guarded+1)<cap);+ assert(ht_can_display((char *)guarded+1,&ht_mono_28,400,256));+ }+ ht_scene_t raw,converted;+ ht_scene_clear(&raw,0); ht_scene_clear(&converted,0);+ ht_wrap(&raw,63,100,340,6,0,&ht_mono_28,0xffff,cases[i][0]);+ ht_wrap(&converted,63,100,340,6,0,&ht_mono_28,0xffff,cases[i][1]);+ ht_raster(&raw,(ht_rect_t){0,0,HT_WIDTH,HT_HEIGHT},full);+ ht_raster(&converted,(ht_rect_t){0,0,HT_WIDTH,HT_HEIGHT},scratch);+ assert(!memcmp(full,scratch,sizeof full));+ transition(NULL,&raw); transition(&raw,&converted);+ ht_scene_clear(&raw,0); ht_scene_clear(&converted,0);+ ht_arc_title(&raw,0xffff,cases[i][0]); ht_arc_title(&converted,0xffff,cases[i][1]);+ ht_raster(&raw,(ht_rect_t){0,0,HT_WIDTH,HT_HEIGHT},full);+ ht_raster(&converted,(ht_rect_t){0,0,HT_WIDTH,HT_HEIGHT},scratch);+ assert(!memcmp(full,scratch,sizeof full));+ }+ assert(!ht_display_text(NULL,0,"⅓",&ht_mono_28));+ assert(ht_text_rows("a ⅓ b",&ht_mono_28,3*ht_mono_28.width)==3);+ // A readable fallback never makes unsupported approval labels approvable.+ assert(!ht_can_display("Approve ≤ ⅓?",&ht_mono_28,340,4));+ assert(!ht_can_display("¼",&ht_mono_28,ht_mono_28.width,1));+ assert(ht_can_display("¼",&ht_mono_28,3*ht_mono_28.width,1));+ assert(!ht_can_display("\xed\xa0\x80",&ht_mono_28,340,4));+ for(unsigned cp=1;cp<=0x10ffff;cp++) {+ if(cp>=0xd800 && cp<=0xdfff) continue;+ char source[5];source[utf8_encode(source,cp)]=0;+ assert(ht_display_text(actual,sizeof actual,source,&ht_mono_28));+ assert(ht_can_display(actual,&ht_mono_28,340,8));+ // Question-mark presentation/fullwidth forms legitimately normalize+ // to '?'; no unrelated scalar may silently turn into that glyph.+ assert(cp=='?' || cp==0xfe16 || cp==0xfe56 || cp==0xff1f || strcmp(actual,"?"));+ }+ // Random bytes exercise invalid/truncated UTF-8 and very small line widths.+ for(unsigned trial=0;trial<3000;trial++) {+ char source[64];for(unsigned i=0;i<sizeof source-1;i++)source[i]=(char)(1+next()%255);+ source[sizeof source-1]=0;+ ht_display_text(actual,sizeof actual,source,&ht_mono_28);+ assert(ht_can_display(actual,&ht_mono_28,340,256));+ assert(ht_text_rows(source,&ht_mono_28,17*(1+trial%24))<=63);+ }+ puts("Display fallback: all Unicode scalars, 3000 malformed-byte strings, bounded copies, fraction/math meaning, wrap/arc pixels and strict approvals PASS");+}+int main(void){lock_dot_checks();@@ -249,6 +342,7 @@ int main(void)bell_checks();notification_marks();shimmer_checks();+ display_text_checks();ht_scene_t a = {0}, b = {0};assert(ht_text_rows("one\ntwo\nthree",&ht_mono_20,348)==3);assert(ht_text_rows("abcdefghi",&ht_mono_20,ht_mono_20.width*3)==3);@@ -284,7 +378,7 @@ int main(void)assert(ht_wrap(&b, 0, 0, 1, 10, 0, &ht_mono_20, 0xffff, "no infinite loop") == 0);assert(ht_wrap(&b, 0, 0, 36, 3, 1, &ht_mono_20, 0xffff, "one two three four") > 0);const char *truncated = "\xf0\x9f";- assert(ht_utf8_next(&truncated) == '?');+ assert(ht_utf8_next(&truncated) == 0xfffd);for (int i=0; i<3 && *truncated; i++) ht_utf8_next(&truncated);assert(*truncated == 0);assert(ht_can_display("A short answer",&ht_mono_20,348,6));diff --git a/devices/harness-device/firmware/test/test_touch_ui.py b/devices/harness-device/firmware/test/test_touch_ui.pyindex cb6b34bc9..2e15a6120 100644--- a/devices/harness-device/firmware/test/test_touch_ui.py+++ b/devices/harness-device/firmware/test/test_touch_ui.py@@ -38,7 +38,7 @@ code = r'''#include <stdio.h>'''# Keep real protocol capacities: a larger fake buffer can hide target truncation.-code += defines('ID_MAX','CABLE_NAME_MAX','SWARM_ID_MAX','SWARMS_MAX','CABLE_MAX_AGENTS','MAX_PROJECTS')+code += defines('CABLE_READ_TOKEN_MAX','ID_MAX','CABLE_NAME_MAX','SWARM_ID_MAX','SWARMS_MAX','CABLE_MAX_AGENTS','MAX_PROJECTS')code += defines('NOTICES','QUESTION_MAX','OPTION_MAX','PANE_MEMORY_MAX','UI_FONT','Q_ROWS','DRAFT_ROWS',source=source)if '#define PANE_RESULT_BYTES ' in source:code += defines('PANE_RESULT_BYTES', source=source)@@ -48,11 +48,11 @@ code += typedef('cable_swarm_t') + typedef('cable_notif_t')code += r'''static struct {bool ready, locked, connected, loading, voice_open, voice_start_pending, voice_waiting, voice_carry, voice_review, voice_draft_append, voice_review_preview, voice_search;- bool quick_open, coasting, touch_brake, touch_down, touch_cancelled, pattern_error, lock_armed, quiet, nap, rim_enabled, focus_face, straight_title, muted;+ bool coasting, touch_brake, touch_down, touch_cancelled, pattern_error, lock_armed, quiet, nap, rim_enabled, focus_face, straight_title, muted;int brightness;char pattern[32], voice_target[CABLE_NAME_MAX];int pattern_mask, pattern_len, view, voice_return, offset, active, count, pressed, hit_count;- int draft_drag, tab_drag, quick_choice, start_x, start_y, last_x, last_y, tab_count, machine_count, model_count, notice_count, pet_pose;+ int draft_drag, tab_drag, start_x, start_y, last_x, last_y, tab_count, machine_count, model_count, notice_count, pet_pose;uint32_t touch_started, coast_until, character_activity, pet_until, last_celebration;uint32_t notice_sequence, voice_retry_until;uint8_t status_phase;@@ -76,6 +76,7 @@ static ht_character_t character;static ht_character_caption_t home_caption;static ht_character_id_t test_character;static int character_saves, saved_character;+static unsigned notice_reads_sent; static action_t notice_read_queued;static ht_scroll_t scroll;static ht_selection_t selection;static ht_carry_t carry;@@ -88,6 +89,7 @@ static bool visit_emit(const ht_visit_command_t *c,void *ctx);static ht_form_t form;static ht_draft_t draft;static ht_workspace_t workspace;+static ht_tab_carousel_t tab_carousel;static int tab_switches;static char tab_target[64];static action_t tab_queued;@@ -172,6 +174,7 @@ static bool queue(action_t a) {if (a.kind==A_ANSWER) question_sends++;if (a.kind==A_TAB) { tab_switches++; COPY(tab_target,a.id); tab_queued=a; }if (a.kind==A_TAB_REFRESH) tab_queued=a;+ if (a.kind==A_NOTICE_READ) { notice_reads_sent++; notice_read_queued=a; }if (a.kind==A_DESKTOP) { desktop_opens++; COPY(opened_agent,a.id); }return true;}@@ -187,12 +190,12 @@ static bool scroll_emit(ht_scroll_phase_t phase, int dy, int velocity, void *ctxcode += function('color')code += function('settings_item') + function('settings_count') + function('hit_contains')code += function('find')-for name in ['copy', 'recap_preview', 'notice_unread', 'notice_was_read', 'notice_forget_read', 'notice_mark_read', 'habitat_scene_receipt', 'habitat_scene_presented', 'pane_memory', 'pane_memory_apply', 'dismiss_result', 'activity_text', 'ensure', 'input_cancel', 'view', 'notice_open', 'workspace_index', 'workspace_failed', 'ui_scroll_reportable', 'control', 'home_footer', 'footer_control', 'text', 'center', 'render_brand', 'heading', 'render_companion', 'choose_character', 'question_view', 'question_rows', 'question_move', 'question_text', 'render_question', 'render_choices', 'render_answer_review', 'question_answer', 'send_answer', 'make_action', 'character_mood', 'voice_status', 'home_caption_rotates', 'home_caption_tick', 'status_animated', 'status_speed', 'status_wake_ms', 'surface_tick', 'render_quick', 'command_face', 'render_workspace_preview', 'render_home', 'render_voice', 'render_selection', 'render_form', 'draft_move', 'render_draft', 'render_draft_options', 'ui_swarms_replace', 'ui_workspace_applied', 'ui_land_after_reload']:+for name in ['copy', 'recap_preview', 'notice_unread', 'notice_was_read', 'notice_forget_read', 'notice_flush_reads', 'notice_mark_read', 'habitat_scene_receipt', 'habitat_scene_presented', 'pane_memory', 'pane_memory_apply', 'dismiss_result', 'activity_text', 'ensure', 'input_cancel', 'view', 'notice_open', 'workspace_index', 'tabs_open', 'workspace_failed', 'ui_scroll_reportable', 'control', 'home_footer', 'footer_control', 'text', 'center', 'render_brand', 'heading', 'render_companion', 'choose_character', 'question_view', 'question_rows', 'question_move', 'question_text', 'render_question', 'render_choices', 'render_answer_review', 'question_answer', 'send_answer', 'make_action', 'character_mood', 'voice_status', 'home_caption_rotates', 'home_caption_tick', 'status_animated', 'status_speed', 'status_wake_ms', 'surface_tick', 'command_face', 'render_workspace_preview', 'render_home', 'render_voice', 'render_selection', 'render_form', 'draft_move', 'render_draft', 'render_draft_options', 'ui_swarms_replace', 'ui_workspace_applied', 'ui_land_after_reload']:code += function(name)code += function('render_settings') + function('ui_visit_state')code += function('ui_project_known') + function('ui_focus_project') + function('ui_apply_pending_focus')-code += function('render_agents') + function('tabs_move') + function('render_tabs') + function('page_controls') + function('render_notice') + function('render_list')-for name in ['notice_remove', 'notice_sync_view', 'notice_selection', 'notice_restore_selection', 'notice_add', 'ui_notify_task_done', 'ui_notif_seen', 'ui_notif_replace', 'ui_notif_open', 'ui_question_close', 'ui_answer_receipt']:+code += function('render_agents') + function('tabs_move') + function('tab_name') + function('render_tabs') + function('page_controls') + function('render_notice') + function('render_list')+for name in ['notice_remove', 'notice_sync_view', 'notice_selection', 'notice_restore_selection', 'notice_add', 'ui_notify_task_done', 'ui_notif_seen', 'ui_notif_read', 'ui_notif_replace', 'ui_notif_open', 'ui_question_close', 'ui_answer_receipt']:code += function(name)for name in ['event', 'ui_project_emit', 'ui_project_restore_event', 'ui_project_clear_event', 'ui_project_set_name', 'ui_project_remove', 'ui_project_clear_all', 'ui_project_apply_order']:code += function(name)@@ -275,6 +278,7 @@ static void scene_take(void) {static void reset(void) {host_features=31; fake_ms=0; fake_asleep=false; present_scene=true;memset(&visit,0,sizeof visit); visit_sends=visit_wire=returns=0; question_pending=false;+ memset(&tab_carousel,0,sizeof tab_carousel);memset(&workspace,0,sizeof workspace); tab_switches=0; tab_target[0]=0;memset(&selection,0,sizeof(selection)); selections=0;memset(&carry,0,sizeof(carry)); carry_prepares=carry_drops=0; voice_context[0]=0;@@ -286,7 +290,7 @@ static void reset(void) {strcpy(s.agents[0].name, "Deploy latest firmware"); strcpy(s.agents[1].name, "Agent B");recording = congestion = false; starts = stops = boops = switches = question_sends = 0;down_reports = moves = ups = travel = waiting_count = 0; target[0] = 0;- desktop_opens=0; opened_agent[0]=0;+ desktop_opens=0; opened_agent[0]=0; notice_reads_sent=0;scene_take();}static void workspace_setup(void) {@@ -309,6 +313,10 @@ static bool action_enabled(action_kind_t action) {return false;}static bool status_is(const char *text) {+ if (!text[0]) {+ for(int i=0;i<scene.count;i++) if(scene.runs[i].arc==2 || scene.runs[i].y==385 || scene.runs[i].y==HT_NOTIFICATION_Y) return false;+ return true;+ }char footer[32]="";for (int i=0;i<scene.count;i++) if(scene.runs[i].y==HT_NOTIFICATION_Y) {if(footer[0]) strcat(footer," ");@@ -446,6 +454,9 @@ static bool result_visible(void) {scene_take(); portrait(dir,"long-reading-inbox");ui_project_emit("a","session-a","summary","\xe2\x80\x9cReady\xe2\x80\x9d \xe2\x80\x94 don\xe2\x80\x99t change the \xe2\x80\x9c" "cache\xe2\x80\x9d.","\xe2\x80\x9cReady\xe2\x80\x9d \xe2\x80\x94 don\xe2\x80\x99t change the \xe2\x80\x9c" "cache\xe2\x80\x9d.");scene_take(); portrait(dir,"punctuation");+ const char *growth="Egg → developing cracks → hatch → baby Tim → growing Tim → adult Tim.";+ ui_project_emit("a","session-a","summary",growth,growth);+ scene_take(); portrait(dir,"growth-arrows");reset();ui_project_emit("a","session-a","processing",NULL,NULL);@@ -604,7 +615,9 @@ static void notice_checks(const char *dir) {"“Yes” means “go”; “no” means “stop”. Keep “A”, “B”, “C”, “D”, “E”, “F”.","All three dials are working now: Tim, Tux seed 1363, and the production UI.","Harness Pro board support: committed by 0xdiego25, commit",- "Fixed and merged into main: PR #436. All 62 relevant tests and static analysis passed."+ "Fixed and merged into main: PR #436. All 62 relevant tests and static analysis passed.",+ "Swipes need about ⅓ the previous travel.",+ "Fixed: 1⅓ seconds → ½ second; x ≠ y. Tests ✅"};for(unsigned i=0;i<sizeof recaps/sizeof recaps[0];i++) {reset();@@ -622,6 +635,18 @@ static void notice_checks(const char *dir) {strcpy(active()->name,"Investigate firmware harness");scene_take(); portrait(dir,"photo-summary-spacing");}+ if(i>=9) {+ bool fraction=false;+ assert(!strcmp(active()->preview,recaps[i])); // wire/source stays original UTF-8+ for(int j=0;j<scene.count;j++) {+ const ht_run_t *r=&scene.runs[j];+ if(r->font!=&ht_mono_28) continue;+ assert(!strchr(r->text,'?'));+ if(strstr(r->text,"1/3")) fraction=true;+ }+ assert(fraction);+ portrait(dir,i==9?"summary-fraction":"summary-symbols");+ }// Notifications may name a pane outside the device's current tab.ui_notify_task_done("off-tab","Other pane","Another Mac",recaps[i]);ui_notif_open(); scene_take();@@ -644,6 +669,16 @@ static void notice_checks(const char *dir) {if(i==1) portrait(dir,"notification-short");if(i==3) portrait(dir,"notification-clipped");if(i==5) { assert(strlen(recaps[i])>100); portrait(dir,"notification-punctuation"); }+ if(i>=9) {+ bool fraction=false;+ for(int j=0;j<scene.count;j++) {+ const ht_run_t *r=&scene.runs[j];+ assert(!strchr(r->text,'?'));+ if(strstr(r->text,"1/3")) fraction=true;+ }+ assert(fraction);+ portrait(dir,i==9?"notification-fraction":"notification-symbols");+ }tap(1000,233,340);assert(desktop_opens==1 && !strcmp(opened_agent,"off-tab") && !starts);assert(s.notice_count==1); // Opening is reconciled by the host's seen event.@@ -830,7 +865,7 @@ static void pane_memory_checks(const char *dir) {assert(pane_memory("wrap",false) && pane_memory("b",false));reset(); ui_project_emit("a",NULL,"processing","",NULL); scene_take();assert(!active()->tool[0] && !result_visible());- assert(title_is("Deploy latest firmware") && status_is(HT_BELL));+ assert(title_is("Deploy latest firmware") && status_is(""));fake_ms+=3400; surface_tick(fake_ms); scene_take();assert(title_is("Working")); portrait(dir,"working-without-footer");s.straight_title=true; scene_take(); assert(title_is("Working"));@@ -894,10 +929,10 @@ static void bell_checks(const char *dir) {reset(); scene_take();bool found=false;for(int i=0;i<scene.count;i++) if(!strcmp(scene.runs[i].text,HT_BELL)) {- assert(scene.runs[i].fg==DIM && scene.runs[i].font==&ht_bell_footer && !scene.runs[i].shimmer);+ assert(false); // An empty inbox has no bell run.found=true;}- assert(found && !action_enabled(A_INBOX));+ assert(!found && !action_enabled(A_INBOX));// A restored host failure is distinct from a completed task. Questions// keep priority; an ordinary fresh result must clear any old failure mark.cable_notif_t failed={.agent_id="b",.name="Website",.failed=true,@@ -957,6 +992,31 @@ static void bell_checks(const char *dir) {}static void notification_read_checks(const char *dir) {+ // Exact occurrence receipts: no focus, no answering, idempotent retries.+ cable_notif_t synced={.agent_id="a",.name="Build",.summary="The build passed. All checks are green.",.read_token="turn-1"};+ reset(); ui_notif_replace(&synced,1); ui_notif_open(); scene_take();+ assert(notice_reads_sent==1 && !notice_unread() && !strcmp(notice_read_queued.text,"turn-1"));+ assert(!desktop_opens && !starts && !question_sends);+ notice_flush_reads(ms()); assert(notice_reads_sent==1);+ fake_ms=10000; notice_flush_reads(ms()); assert(notice_reads_sent==2);+ ui_notif_replace(NULL,0); assert(s.view==INBOX && s.notice_count==1 && !notice_unread());+ fake_ms+=3000; notice_flush_reads(ms()); assert(notice_reads_sent==2); // app acknowledged, keep reading+ view(HOME); ui_notif_replace(NULL,0); assert(!s.notice_count);+ strcpy(synced.read_token,"turn-2"); ui_notif_replace(&synced,1); assert(notice_unread()==1);+ ui_notif_read("a","turn-1"); assert(notice_unread()==1); // stale, identical text+ ui_notif_read("a","turn-2"); assert(!s.notice_count); // desktop clear+ synced.question=true; strcpy(synced.read_token,"question-1");+ ui_notif_replace(&synced,1); ui_notif_open(); congestion=true; scene_take();+ assert(!notice_unread() && s.view==INBOX && !question_sends);+ unsigned before=notice_reads_sent; congestion=false; fake_ms+=3000; notice_flush_reads(ms());+ assert(notice_reads_sent==before+1 && !strcmp(notice_read_queued.text,"question-1"));+ ui_notif_read("a","question-1"); ui_notif_replace(NULL,0);+ assert(s.view==INBOX && s.notice_count==1 && !question_sends); // reading never answers+ reset(); ui_notif_replace(&synced,1); ui_notif_open(); present_scene=false; scene_take();+ uint32_t old_frame=habitat_scene_receipt(); strcpy(synced.read_token,"question-2");+ ui_notif_replace(&synced,1); habitat_scene_presented(old_frame);+ assert(notice_unread()==1 && !notice_reads_sent); // late DMA cannot read a new occurrence+cable_notif_t rows[2]={{.agent_id="a",.name="Build",.summary="The build passed. All checks are green."},{.agent_id="b",.name="Release",.summary="May I publish this release?",.question=true}};@@ -974,11 +1034,11 @@ static void notification_read_checks(const char *dir) {ui_notif_open(); assert(!strcmp(s.notice[s.offset].agent_id,"a")); scene_take();assert(!notice_unread() && s.notice_count==2 && s.view==INBOX);portrait(dir,"inbox-read-stays");- tap(1000,233,430); assert(s.view==HOME && status_is(HT_BELL) && !action_enabled(A_INBOX));- for(int i=0;i<scene.count;i++) if(scene.runs[i].font==&ht_bell_footer) assert(scene.runs[i].fg==DIM);+ tap(1000,233,430); assert(s.view==HOME && status_is("") && !action_enabled(A_INBOX));+ for(int i=0;i<scene.count;i++) assert(scene.runs[i].font!=&ht_bell_footer);portrait(dir,"bell-all-read");ui_notif_replace(NULL,0); ui_notif_replace(rows,2); scene_take();- assert(!notice_unread() && status_is(HT_BELL)); // Late/reconnect snapshot stays read.+ assert(!notice_unread() && status_is("")); // Late/reconnect snapshot stays read.strcpy(rows[0].summary,"The next build is ready.");ui_notif_replace(rows,2); assert(notice_unread()==1);ui_notif_open(); scene_take(); assert(!notice_unread());@@ -1015,10 +1075,34 @@ static void notification_read_checks(const char *dir) {assert(s.notice_read_next<NOTICES && s.notice_count<=NOTICES);}assert(!starts && !question_sends && !desktop_opens);- puts("Notification read: post-DMA only, sleep/lock, stale/identical replacements, read/open idempotence, questions, muted bell, reconnect snapshots and bounded receipt history PASS");+ puts("Notification read: post-DMA only, sleep/lock, stale/identical replacements, read/open idempotence, questions, hidden empty bell, reconnect snapshots and bounded receipt history PASS");reset();}+static void tab_frame_checks(void) {+ static uint16_t full[466*466], delta[466*466], patch[466*466];+ ht_scene_t previous={0};+ workspace_setup();+ strcpy(s.tabs[1].name,"Device firmware and voice interaction experiments");+ strcpy(s.tabs[2].name,"Caf\xc3\xa9 / infrastructure");+ dispatch((action_t){.kind=A_TABS});+ for(int position=-80;position<=3*HT_TAB_PITCH+80;position+=17) {+ tab_carousel.position=position; scene_take();+ ht_damage_t damage; ht_damage(position==-80 ? NULL : &previous,&scene,&damage);+ for(int i=0;i<damage.count;i++) {+ ht_rect_t r=damage.rect[i]; ht_raster(&scene,r,patch);+ for(int y=0;y<r.h;y++) memcpy(delta+(r.y+y)*466+r.x,patch+y*r.w,(size_t)r.w*2);+ }+ ht_raster(&scene,(ht_rect_t){0,0,466,466},full);+ assert(!memcmp(full,delta,sizeof full));+ uint16_t bg=(uint16_t)((BG>>8)|(BG<<8));+ for(int y=0;y<466;y++) for(int x=0;x<466;x++) if(full[y*466+x]!=bg)+ assert((x-233)*(x-233)+(y-233)*(y-233)<232*232);+ previous=scene;+ }+ puts("tab frames: long/UTF-8 names, rim bounds, clipped movement and exact partial redraw PASS");+ reset();+}int main(int argc, char **argv) {test_character = getenv("HABITAT_TEST_TUX") ? HT_CHARACTER_TUX : HT_CHARACTER_TIM;notification_read_checks(argc>1 ? argv[1] : NULL);@@ -1164,18 +1248,19 @@ int main(int argc, char **argv) {reset(); s.view=SETTINGS; s.offset=6; scene_take(); congestion=true;tap(1000,233,336); assert(!visit.pending && !visit_sends && s.view==MESSAGE);reset(); s.connected=false; s.view=SETTINGS; scene_take(); assert(!action_enabled(A_LATEST));+ tab_frame_checks();workspace_setup(); assert(!action_enabled(A_TABS)); portrait(dir,"workspace-home");for(int i=0;i<scene.count;i++) assert(!strstr(scene.runs[i].text,"Product") && !strstr(scene.runs[i].text,"[ tabs ]"));- assert(action_enabled(A_AGENTS) && title_is(active()->name) && status_is(HT_BELL));+ assert(action_enabled(A_AGENTS) && title_is(active()->name) && status_is(""));tap(1000,233,41); assert(s.view==AGENTS && !starts && !tab_switches);workspace_setup();habitat_touch(true,233,230,2000); habitat_touch(true,233,230,2700);habitat_touch(true,233,100,2800); habitat_touch(false,233,100,2900);- assert(s.view==AGENTS && !starts && !tab_switches); // Idle still has the hold-up gesture.- // Hold-left reveals Tabs before release, without scrolling or opening a mic.+ assert(s.view==TABS && !starts && !tab_switches); // Hold opens Tabs; later motion is consumed.+ // Hold reveals Tabs before release, without scrolling or opening a mic.workspace_setup(); habitat_touch(true,233,230,2000);habitat_touch(true,233,230,2700); habitat_touch(true,100,230,2800); scene_take();- assert(s.quick_open && s.quick_choice==3 && s.view==HOME && !starts && !moves && !tab_switches);+ assert(s.view==TABS && s.touch_cancelled && !starts && !moves && !tab_switches);portrait(dir,"shortcut-tabs");habitat_touch(false,100,230,2900); scene_take();assert(s.view==TABS && !starts && !tab_switches && !moves);@@ -1213,15 +1298,14 @@ int main(int argc, char **argv) {habitat_touch(true,233,41,1000); habitat_touch(true,233,140,1100);habitat_touch(false,233,140,1200);assert(s.view==HOME && !tab_switches && !starts); // drag never opens the inbox or microphone- // Hold-right opens the inbox deliberately from the companion.- workspace_setup(); s.notice_count=1; scene_take(); habitat_touch(true,233,230,2000);- habitat_touch(true,233,230,2700); habitat_touch(true,350,230,2800);- habitat_touch(false,350,230,2900); assert(s.view==INBOX && !starts && !tab_switches);+ // The bell opens the inbox; hold no longer has a directional action.+ workspace_setup(); s.notice_count=1; scene_take(); tap(2000,233,420);+ assert(s.view==INBOX && !starts && !tab_switches);// A host clear during contact leaves the caption action unchanged.workspace_setup(); s.notice_count=1; active()->busy=true; scene_take(); habitat_touch(true,233,41,1000);s.notice_count=0; scene_take(); habitat_touch(false,233,41,1080);assert(s.view==AGENTS && !tab_switches && !starts);- // The existing hold-left gesture still reaches workspaces while updates wait.+ // Hold still reaches workspaces while updates wait.workspace_setup(); s.notice_count=1; scene_take(); habitat_touch(true,233,230,1000);habitat_touch(true,233,230,1700); habitat_touch(true,100,230,1800);habitat_touch(false,100,230,1900); assert(s.view==TABS && !starts && !tab_switches);@@ -1313,60 +1397,83 @@ int main(int argc, char **argv) {}ui_notif_seen(NULL);assert(s.notice_count==NOTICES);ui_notif_replace(NULL,1000);assert(s.view==HOME&&!s.notice_count);- // Four larger names fit; the fifth and sixth remain reachable before UP.+ // Centered name plus previous/next previews; all six remain reachable.workspace_setup(); s.tab_count=6;strcpy(s.tabs[4].id,"tab-4"); strcpy(s.tabs[4].name,"Tools");strcpy(s.tabs[5].id,"tab-5"); strcpy(s.tabs[5].name,"Notes");dispatch((action_t){.kind=A_TABS}); scene_take(); portrait(dir,"tabs-names");- assert(s.view==TABS && s.hit_count==5 && !action_enabled(A_UP) && !action_enabled(A_DOWN));- assert(!action_enabled(A_MACHINES));- int highlighted=0;+ assert(s.view==TABS && s.hit_count==4 && !action_enabled(A_UP) && !action_enabled(A_DOWN));+ assert(action_enabled(A_HOME) && !action_enabled(A_SETTINGS) && !action_enabled(A_MACHINES));+ assert(ht_tab_carousel_index(&tab_carousel)==1);for(int i=0;i<scene.count;i++) {assert(!strstr(scene.runs[i].text,"panes") && !strstr(scene.runs[i].text,"selected"));- assert(!strchr(scene.runs[i].text,':') && strcmp(scene.runs[i].text,">"));- if(scene.runs[i].bg==SEL) { highlighted++; assert(!strcmp(scene.runs[i].text," Product")); }+ assert(scene.runs[i].bg==BG); // no list boxes or alternating row fills}- assert(highlighted==1);- for(int i=1;i<s.hit_count;i++) {- assert(s.hits[i].action==A_TAB && s.hits[i].rect.h>=48);- if(i>1) assert(s.hits[i].rect.y>=s.hits[i-1].rect.y+s.hits[i-1].rect.h);+ bool previous_visible=false,next_visible=false;+ for(int i=0;i<scene.count;i++) if(scene.runs[i].font==UI_FONT && !scene.runs[i].arc && scene.runs[i].w) {+ const ht_run_t *r=&scene.runs[i];+ if(r->x+r->w<=119) previous_visible=true;+ if(r->x>=347) next_visible=true;+ assert(strcmp(r->text,"controls"));}- habitat_touch(true,233,300,3000); habitat_touch(true,233,220,3060); scene_take();- assert(s.offset==1 && s.view==TABS && !tab_switches && !starts && !moves);- habitat_touch(false,233,160,3120); scene_take();- assert(s.offset==2 && s.view==TABS && !tab_switches && !starts);- portrait(dir,"tabs-scrolled");- tap(3300,233,360); assert(tab_switches==1 && !strcmp(tab_target,"tab-5") && !starts);- // A short list never scrolls into an empty page; out-and-back is not a tap.+ assert(previous_visible && next_visible);+ habitat_touch(true,300,233,3000); habitat_touch(true,240,233,3120); scene_take();+ assert(tab_carousel.position==HT_TAB_PITCH+120 && !tab_switches && !starts && !moves);+ portrait(dir,"tabs-dragging");+ habitat_touch(false,220,233,3150); scene_take();+ assert(tab_carousel.animating && !tab_switches && !starts);+ surface_tick(3250); scene_take(); portrait(dir,"tabs-settling");+ // A touch brakes a moving page. It must never also open the old rendered target.+ tap(3260,233,233); assert(s.view==TABS && !tab_switches && !starts);+ surface_tick(3650); scene_take();+ int chosen=ht_tab_carousel_index(&tab_carousel);+ char chosen_id[ID_MAX]; COPY(chosen_id,s.tabs[chosen].id);+ tap(3900,233,233); assert(tab_switches==1 && !strcmp(tab_target,chosen_id));+ // Tapping a visible neighbor opens that exact tab, never the centered name.+ workspace_setup(); dispatch((action_t){.kind=A_TABS}); scene_take();+ tap(4000,80,233); assert(tab_switches==1 && !strcmp(tab_target,"tab-0") && !starts);+ workspace_setup(); dispatch((action_t){.kind=A_TABS}); scene_take();+ tap(4000,386,233); assert(tab_switches==1 && !strcmp(tab_target,"tab-2") && !starts);+ // Vertical/out-and-back motion stays in the picker and never opens a tab.workspace_setup(); dispatch((action_t){.kind=A_TABS}); scene_take();habitat_touch(true,233,300,4000); habitat_touch(true,233,120,4100);habitat_touch(false,233,300,4200); scene_take();- assert(s.offset==0 && !tab_switches && !starts && s.view==TABS);- // All 24 supported tabs remain reachable, including the last current tab.+ assert(ht_tab_carousel_index(&tab_carousel)==1 && !tab_switches && !starts && s.view==TABS);+ habitat_touch(true,233,233,4400); habitat_touch(true,120,233,4500);+ habitat_touch(true,233,233,4700); habitat_touch(false,233,233,4900);+ surface_tick(5200); scene_take(); assert(ht_tab_carousel_index(&tab_carousel)==1 && !tab_switches);+ // All 24 tabs remain reachable. Physical left/right is independent of desktop scroll preference.workspace_setup(); s.tab_count=24;for(int i=4;i<24;i++) {snprintf(s.tabs[i].id,sizeof s.tabs[i].id,"tab-%d",i);snprintf(s.tabs[i].name,sizeof s.tabs[i].name,"Workspace %d",i);}strcpy(s.selected_tab,"tab-23"); dispatch((action_t){.kind=A_TABS}); scene_take();- assert(s.offset==20 && s.hit_count==5 && s.hits[4].value==23);+ assert(ht_tab_carousel_index(&tab_carousel)==23 && s.hits[0].value==23);portrait(dir,"tabs-last");- habitat_touch(true,233,180,5000); habitat_touch(true,233,308,5060); scene_take();- assert(s.offset==18 && !tab_switches && !starts);- habitat_touch(false,233,308,5120); assert(s.offset==18);- // Reversing the scroll preference only changes direction, never the target.- scroll_reversed=true; scene_take();- habitat_touch(true,233,180,5300); habitat_touch(true,233,308,5360);- habitat_touch(false,233,308,5420); scene_take();- assert(s.offset==20 && !tab_switches && !starts); scroll_reversed=false;- // A changed roster during contact cancels the stale choice and clamps view.- habitat_touch(true,233,360,5600); ui_swarms_replace(s.tabs,2,"tab-1");- habitat_touch(false,233,360,5675); scene_take();- assert(s.offset==0 && !tab_switches && !starts && s.hit_count==3);+ scroll_reversed=true;+ for(int wanted=22;wanted>=0;wanted--) {+ uint32_t t=6000+(22-wanted)*1000;+ habitat_touch(true,203,233,t); habitat_touch(true,263,233,t+300);+ habitat_touch(false,263,233,t+450); surface_tick(t+700); scene_take();+ assert(ht_tab_carousel_index(&tab_carousel)==wanted && !tab_switches && !starts);+ }+ scroll_reversed=false;+ // Changed identities cancel stale contacts; only pane-count changes preserve motion.+ habitat_touch(true,233,233,30000);+ s.tabs[0].panes++; ui_swarms_replace(s.tabs,24,"tab-23");+ assert(!s.touch_cancelled);+ ui_swarms_replace(s.tabs,2,"tab-1");+ habitat_touch(false,233,233,30075); scene_take();+ assert(!tab_switches && !starts && s.hit_count==3 && ht_tab_carousel_index(&tab_carousel)==0);ui_swarms_replace(NULL,0,NULL); scene_take(); portrait(dir,"tabs-empty");assert(s.hit_count==1 && action_enabled(A_HOME) && !action_enabled(A_TAB));workspace_setup(); s.connected=false; dispatch((action_t){.kind=A_TABS}); scene_take();- assert(!action_enabled(A_TAB)); tap(5800,233,140); assert(!tab_switches && !starts);+ assert(!action_enabled(A_TAB)); tap(32000,233,233); assert(!tab_switches && !starts);+ // Long names wrap without painting into the rim. The only footer is Back.+ workspace_setup(); strcpy(s.tabs[1].name,"A workspace with a longer name for device development");+ dispatch((action_t){.kind=A_TABS}); scene_take(); portrait(dir,"tabs-long-name");+ tap(33000,233,420); assert(s.view==HOME && !tab_switches && !starts);reset(); s.view=INBOX; dispatch((action_t){.kind=A_NOTICE,.id="off-tab-agent"});assert(desktop_opens==1 && !strcmp(opened_agent,"off-tab-agent") && s.view==INBOX);assert(!visit.pending && !visit_sends && !starts); // Works with the shipping agent.open protocol.@@ -1377,7 +1484,10 @@ int main(int argc, char **argv) {workspace_setup(); habitat_touch(true,233,230,1000);habitat_touch(true,233,230,1700); habitat_touch(true,100,230,1800);habitat_touch(false,100,230,1900); scene_take(); portrait(dir,"tabs-from-gesture");- tap(2100,233,336); // Fourth row: Research. The normal switch receipt still applies.+ habitat_touch(true,263,233,2000); habitat_touch(true,203,233,2300); habitat_touch(false,203,233,2450);+ surface_tick(2700); scene_take();+ habitat_touch(true,263,233,3000); habitat_touch(true,203,233,3300); habitat_touch(false,203,233,3450);+ surface_tick(3700); scene_take(); tap(4000,233,233); // Research. The normal switch receipt still applies.assert(tab_switches==1 && !strcmp(tab_target,"tab-3") && s.loading && s.view==MESSAGE);uint32_t serial=workspace.serial;ui_land_after_reload(); assert(s.loading); // A periodic refresh is not a switch receipt.@@ -1395,7 +1505,7 @@ int main(int argc, char **argv) {assert(!s.loading && s.view==HOME && !active() && !starts);workspace_setup(); habitat_touch(true,233,230,1000); habitat_touch(true,233,230,1700);habitat_touch(true,100,230,1800); habitat_touch_cancel(); habitat_touch(false,100,230,1900);- assert(!tab_switches && !starts && s.view==HOME);+ assert(!tab_switches && !starts && s.view==TABS);// The same gesture works on the smaller completed-turn portrait.workspace_setup(); s.agents[0].recap_ready=true; s.agents[0].has_event=true;strcpy(s.agents[0].preview,"Installed. The device reconnected."); scene_take(); portrait(dir,"completed-quiet-footer");@@ -1525,7 +1635,7 @@ int main(int argc, char **argv) {habitat_touch(false,233,220,1270); assert(!starts);tap(1390,233,220); assert(starts==1);reset(); habitat_touch(true,233,220,1000); habitat_touch(false,233,220,1700);- assert(s.view==HOME && !starts);+ assert(s.view==TABS && !starts);reset(); active()->busy=true; scene_take(); tap(1000,233,41); assert(s.view==AGENTS && !starts);reset(); s.connected=false; scene_take(); portrait(dir,"offline");assert(scene.count==1 && !strcmp(scene.runs[0].text,"Harness") && !s.hit_count);@@ -1551,21 +1661,19 @@ int main(int argc, char **argv) {s.voice_retry_until=0; scene_take(); assert(result_visible());s.voice_retry_until=4000; scene_take(); tap(1000,233,220);assert(starts==1 && s.view==VOICE && !s.voice_retry_until && !strcmp(target,"a"));- // Hold previews do not execute. A later slide chooses a destination, never scrolls or talks.- reset(); s.notice_count=1; habitat_touch(true,233,220,1000); surface_tick(1650);- assert(s.quick_open && s.view==HOME && !starts); scene_take(); portrait(dir,"shortcuts");- habitat_touch(true,330,220,1700); assert(!moves && s.view==HOME);- scene_take(); portrait(dir,"shortcut-attention");- habitat_touch(false,330,220,1800); assert(s.view==INBOX && !starts);- reset(); habitat_touch(true,233,220,1000); surface_tick(1650);- habitat_touch(true,130,220,1700); habitat_touch(false,130,220,1800);- assert(s.view==TABS && !starts && !moves);- reset(); habitat_touch(true,233,220,1000); surface_tick(1650);- habitat_touch(true,233,130,1700); habitat_touch(false,233,130,1800);- assert(s.view==AGENTS && !starts && !moves);- reset(); habitat_touch(true,233,220,1000); surface_tick(1650);- habitat_touch(true,233,320,1700); habitat_touch(false,233,320,1800);- assert(s.view==SETTINGS && !starts && !moves); scene_take(); portrait(dir,"controls");+ // Hold opens one destination immediately; every direction of the opening contact is consumed.+ const int hold_ends[][2]={{233,220},{330,220},{130,220},{233,130},{233,320}};+ for(unsigned i=0;i<sizeof hold_ends/sizeof hold_ends[0];i++) {+ workspace_setup(); habitat_touch(true,233,220,1000); surface_tick(1650);+ assert(s.view==TABS && s.touch_cancelled && !starts); scene_take();+ habitat_touch(true,hold_ends[i][0],hold_ends[i][1],1700);+ habitat_touch(false,hold_ends[i][0],hold_ends[i][1],1800);+ assert(s.view==TABS && !starts && !moves && !tab_switches && ht_tab_carousel_index(&tab_carousel)==1);+ }+ scene_take(); portrait(dir,"hold-tabs");+ tap(2000,233,420); assert(s.view==HOME && !starts);+ // Legacy controls remain covered without a Controls entry in the picker.+ dispatch((action_t){.kind=A_SETTINGS}); scene_take(); portrait(dir,"controls");dispatch((action_t){.kind=A_SELECT_BEGIN});assert(s.view==SELECTION && !starts && selected_command.op==HT_SELECT_BEGIN);assert(ht_selection_reply(&selection,selection.request,"pick-test",true,1,"Which part should change?",1,false,NULL,1810));@@ -1592,12 +1700,16 @@ int main(int argc, char **argv) {assert(!strcmp(selected_action.text,"pick-test") && selected_action.dy==1);tap(2700,233,220); assert(starts==1 && s.view==VOICE && !strcmp(target,"a"));reset(); habitat_touch(true,233,220,1000); surface_tick(1650); habitat_touch_cancel();- habitat_touch(false,233,220,1800); assert(s.view==HOME && !s.quick_open && !starts);+ habitat_touch(false,233,220,1800); assert(s.view==TABS && !starts);reset(); habitat_touch(true,233,220,1000); surface_tick(1650); surface_tick(6000);- habitat_touch(false,233,220,6100); assert(s.view==HOME && !starts); // resting hand+ habitat_touch(false,233,220,6100); assert(s.view==TABS && !starts); // resting hand never selects a tabreset(); habitat_touch(true,233,220,1000); habitat_touch(true,233,170,1100);surface_tick(1650); habitat_touch(false,233,170,1800);- assert(!s.quick_open && s.view==HOME && !starts); // a drag can never become a hold+ assert(s.view==HOME && !starts); // a drag can never become a hold+ reset(); habitat_touch(true,233,220,1000); habitat_touch(false,53,220,1700);+ assert(s.view!=TABS && switches==1 && !starts); // delayed final motion is classified before hold+ reset(); habitat_touch(true,233,220,1000); habitat_touch(true,233,80,1700);+ habitat_touch(false,233,80,1800); assert(s.view==HOME && moves && !starts);reset(); s.rim_enabled=true; tap(1000,433,233); assert(!starts && !switches);habitat_touch(true,433,233,2000); habitat_touch(true,418,310,2100);habitat_touch(true,374,374,2200); habitat_touch(true,310,418,2300);@@ -1614,10 +1726,8 @@ int main(int argc, char **argv) {reset(); s.pet_pose=1; scene_take(); portrait(dir,"booped");reset(); waiting_count=1; s.notice_count=1; scene_take(); portrait(dir,"attention");tap(1000,233,375); assert(s.view==VOICE && starts==1);- dispatch((action_t){.kind=A_VOICE_ABORT}); starts=0;- habitat_touch(true,233,230,2000); surface_tick(2700);- habitat_touch(true,350,230,2800); habitat_touch(false,350,230,2900);- assert(s.view==INBOX && !starts);+ dispatch((action_t){.kind=A_VOICE_ABORT}); starts=0; scene_take();+ tap(2700,233,420); assert(s.view==INBOX && !starts);reset(); visit.available=true; scene_take(); portrait(dir,"return");tap(1000,233,409); assert(returns==1 && !starts); visit.available=false;reset(); COPY(s.agents[0].name,"A very long recipient name that still needs to be readable on a tiny circular display");@@ -1728,12 +1838,8 @@ int main(int argc, char **argv) {scene_take(); portrait(dir,"output-search-empty");tap(4400,233,220); assert(starts==2); // Nothing to quote.tap(5100,233,362); assert(starts==3 && s.voice_search); // Search remains usable.- // The compass uses the final release coordinates and its center cancels.- reset(); habitat_touch(true,233,220,1000); surface_tick(1650);- habitat_touch(true,330,220,1700); assert(s.quick_choice==2);- habitat_touch(false,233,220,1800); assert(s.view==HOME && !s.quick_open && !starts && !moves);- reset(); habitat_touch(true,233,220,1000); surface_tick(1650);- habitat_touch(false,233,130,1800); assert(s.view==AGENTS && !starts && !moves);+ // Pane navigation remains available from the home caption.+ reset(); tap(1000,233,41); assert(s.view==AGENTS && !starts && !moves);scene_take(); portrait(dir,"panes");reset(); s.count=8; s.active=7;for(int i=0;i<8;i++) { snprintf(s.agents[i].id,sizeof s.agents[i].id,"pane-%d",i); snprintf(s.agents[i].name,sizeof s.agents[i].name,"Pane %d",i); }diff --git a/devices/harness-device/firmware/test/test_voice_ui.py b/devices/harness-device/firmware/test/test_voice_ui.pyindex fce338d92..8ef730cfe 100644--- a/devices/harness-device/firmware/test/test_voice_ui.py+++ b/devices/harness-device/firmware/test/test_voice_ui.py@@ -47,6 +47,7 @@ static ht_visit_t visit;static ht_form_t form;static ht_draft_t draft;static ht_workspace_t workspace;+static ht_tab_carousel_t tab_carousel;static struct {bool quick_open, coasting, ready, connected, loading, nap, voice_open, voice_start_pending, voice_waiting, voice_carry, voice_review, voice_review_preview, voice_draft_append, voice_search, touch_down, touch_cancelled;int pet_pose, view, voice_return, offset, pressed, active;@@ -118,6 +119,7 @@ for name in ['habitat_tick', 'ui_set_connected', 'ui_show_error', 'ui_cable_toasharness += r'''static void reset(void) {memset(&workspace,0,sizeof workspace);+ memset(&tab_carousel,0,sizeof tab_carousel);host_features=31; memset(&draft,0,sizeof draft); reviews=0; memset(&s, 0, sizeof(s)); memset(&visit, 0, sizeof(visit)); memset(&carry,0,sizeof(carry)); now = 1000;s.ready = s.connected = true; s.view = HOME;strcpy(s.agents[0].name, "Agent");diff --git a/devices/harness-device/firmware/test/test_workspace.c b/devices/harness-device/firmware/test/test_workspace.cindex 0261faf7f..98a6240fe 100644--- a/devices/harness-device/firmware/test/test_workspace.c+++ b/devices/harness-device/firmware/test/test_workspace.c@@ -3,8 +3,73 @@#include <stdio.h>#include <string.h>+static void carousel(void)+{+ ht_tab_carousel_t c={0};+ ht_tab_carousel_reset(&c,0,0);+ ht_tab_carousel_begin(&c,233,100);+ assert(!c.touching && !ht_tab_carousel_end(&c,233,false,175));+ for (int count=1;count<=24;count++) for(int i=0;i<count;i++) {+ ht_tab_carousel_reset(&c,count,i);+ assert(ht_tab_carousel_index(&c)==i);+ ht_tab_carousel_begin(&c,233,100);+ assert(ht_tab_carousel_end(&c,233,false,175)); // settled tap may select+ // A 114 px drag moves one page, with no flick speed required.+ ht_tab_carousel_begin(&c,290,1000);+ ht_tab_carousel_move(&c,176,1300);+ assert(c.position==(i+1<count ? (i+1)*HT_TAB_PITCH : i*HT_TAB_PITCH+57));+ assert(!ht_tab_carousel_end(&c,176,true,1500));+ int previous=c.position;+ for(uint32_t t=1500;t<=1500+HT_TAB_SETTLE_MS;t+=16) {+ ht_tab_carousel_tick(&c,t);+ assert(c.position<=previous); previous=c.position;+ }+ assert(!c.animating && ht_tab_carousel_index(&c)==(i+1<count ? i+1 : i));+ assert(!ht_tab_carousel_tick(&c,10000)); // no idle animation work+ }+ // Small, slow swipes must work in both directions, without stale momentum.+ for(int direction=-1;direction<=1;direction+=2) for(int travel=0;travel<=65;travel++) {+ ht_tab_carousel_reset(&c,24,10);+ ht_tab_carousel_begin(&c,233,1000);+ ht_tab_carousel_move(&c,233-direction*travel,1300);+ ht_tab_carousel_end(&c,233-direction*travel,true,1500);+ ht_tab_carousel_tick(&c,1800);+ // At the exact midpoint the nearest-page tie goes to the higher index.+ int advance = direction>0 ? travel>=57 : travel>57;+ assert(ht_tab_carousel_index(&c)==10+(advance?direction:0));+ }+ ht_tab_carousel_reset(&c,24,10);+ ht_tab_carousel_begin(&c,390,UINT32_MAX-100);+ ht_tab_carousel_move(&c,230,UINT32_MAX-40);+ assert(!ht_tab_carousel_end(&c,130,true,20));+ assert(c.animating && c.target>10*HT_TAB_PITCH && c.target<=13*HT_TAB_PITCH);+ ht_tab_carousel_tick(&c,100);+ // First touch is a brake, even if the settle deadline has just passed.+ ht_tab_carousel_begin(&c,233,250);+ assert(c.braking && !ht_tab_carousel_end(&c,233,false,325));+ ht_tab_carousel_tick(&c,600);+ ht_tab_carousel_begin(&c,233,700);+ assert(ht_tab_carousel_end(&c,233,false,775));+ ht_tab_carousel_begin(&c,233,1000);+ ht_tab_carousel_move(&c,33,1080);+ ht_tab_carousel_cancel(&c);+ assert(!c.touching && !c.animating && !ht_tab_carousel_end(&c,33,true,1200));+ // Reversing a drag cancels its travel; waiting removes stale fling velocity.+ ht_tab_carousel_reset(&c,24,10);+ ht_tab_carousel_begin(&c,233,2000);+ ht_tab_carousel_move(&c,33,2080);+ ht_tab_carousel_move(&c,233,2380);+ assert(!ht_tab_carousel_end(&c,233,true,2600));+ ht_tab_carousel_tick(&c,3000);+ assert(ht_tab_carousel_index(&c)==10);+ ht_tab_carousel_reset(&c,100,999);+ assert(c.count==24 && ht_tab_carousel_index(&c)==23);+ puts("tab carousel: short slow swipes, 2:1 tracking, bounded flicks, soft edges, settled taps, brake, cancel and clock wrap PASS");+}+int main(void){+ carousel();ht_workspace_t w={0};ht_workspace_touch(&w,1,4,233,410,100);assert(w.touching && w.choice==1);diff --git a/devices/harness-device/prototype/habitat/TUX.md b/devices/harness-device/prototype/habitat/TUX.mdindex 96ad21ca0..ded2cf518 100644--- a/devices/harness-device/prototype/habitat/TUX.md+++ b/devices/harness-device/prototype/habitat/TUX.md@@ -1,8 +1,8 @@# Characters in Habitat-Tim and Tux run the same Habitat application. Tap the character to talk; hold,-then slide down to **controls → Companion / gestures → Character** to switch.-The choice is saved on the dial and survives a restart. Swapping artwork keeps+Tim and Tux run the same Habitat application. Tap the character to talk; hold+to open Tabs. The simplified picker has no Controls entry. The existing character+preference is saved on the dial and survives a restart. Swapping artwork keepsthe current pane, voice session, unread results, preferences and navigation.`firmware/main/ui/habitat/character.h` is the application interface. Characters@@ -47,8 +47,7 @@ Activity retains the existing 2.048-second highlight cycle: 20 steps at 64 msand a 768 ms rest. A completed result replaces the full-size creature with thefixed small portrait and recap. Old results never appear during live work.A held caption stays still through a phase boundary, keeping its curved end-letters tappable. Both phases open the pane picker. Hold and slide up also-opens panes. Quiet mode, sleeping and touches stop the highlight sweep.+letters tappable. Both phases open the pane picker. Holding the creature opens Tabs directly. Quiet mode, sleeping and touches stop the highlight sweep.Curved glyph masks remain cached between caption changes, including duringcolour fades; highlight updates redraw only the affected bands.@@ -58,10 +57,10 @@ neutral text and a matching monochrome bell. This is a compile-time palette;normal builds keep purple.Notifications use a separate bottom bell with a broad 300 × 84 px target,-starting below the central voice target. When empty, the bell is dim, has no-zero count and does nothing on a tap. New unread messages make it bright with-the unread count alongside. Tapping it opens the inbox; hold and slide right remains-available for retained cards, including ones already read. Opening the inbox+starting below the central voice target. When empty, the bell is absent and has+no hit target. New unread messages make it visible with the unread count+alongside. Tapping it opens the inbox, which retains cards that were already+read until the host removes them. Opening the inboxchooses its first unread message. Completed and question messages use the sameread-count rule, separate from whether a question remains unresolved. Tim and Tux no longer hold an envelope on any daily screen.The old letter art stays available to historical experiment renders.@@ -366,3 +365,119 @@ Actual native-renderer output for the centered inbox cards and empty bell inbell is planned as a separate follow-up.++## Hold to switch tabs — 2026-09-28++Orange revision `.orange.8` removes the four-direction hold menu. A stationary+650 ms hold on the home creature opens Tabs immediately. That opening contact is+consumed through release; it never also selects, starts voice or scrolls the app.+Movement is classified before the hold deadline, including a delayed final sample.++Tabs is a horizontal name carousel: drag with the finger, flick to advance, then+tap the centered name to open. It has no row numbers, pane counts or list boxes.+Long names wrap in the center. The active desktop tab uses the companion accent;+other names use neutral text. Back and controls remain in a separate bottom row.+The top home caption still opens panes, and the bell still opens unread messages.++A 360 px page follows the finger directly, with soft bounded ends and a 224 ms+integer ease on release. Fling projection is bounded. A contact during settling+only brakes; a later stationary tap confirms. The 16 ms animation wake stops once+settled. No floating point, heap allocation or extra framebuffer is introduced.+Roster changes cancel stale contacts and preserve the centered tab by ID where+possible; pane-count-only updates do not disturb browsing. All 24 tabs are+reachable, independent of the desktop vertical-scroll direction preference.++The bell is absent when there are no unread messages. An unread bell and its+number keep their existing foreground and separate lower touch target. The pane+name and activity remain visible even when Harness is behind another app.++### Read once, clear everywhere++The desktop assigns an opaque `readToken` to each new notification, including a+new turn with identical text. `app_unread` and `notif.replace` carry it unchanged.+After a card actually finishes rendering, the dial sends `notif.read` with its+agent ID and that exact token through the existing background USB worker. The+host validates against the latest unread list and emits `dial_notification_read`+locally; the app checks the token again, clears its unread mark and withdraws its+banner/system notification. It publishes the updated list to every connected+machine and dial. Desktop reads/explicit dismissals use the same state.++`agent_seen` / `notif.seen` also carry the token. A stale receipt cannot clear a+new occurrence. Reading a question does not answer it or change focus. The card+stays visible on the dial while being read, even after the app confirms removal;+leaving the inbox drops that retained card on the next snapshot. Automatic+expiry of a desktop banner is not a read. Pending question state remains separate.++The dial holds at most 24 receipts in RAM, retries each at most every two seconds (one enqueue per tick),+and reserves the last action slot for touch/audio. It writes neither flash nor+extra frames when idle. Reconnect snapshots recover a lost receipt. This protocol+requires the matching desktop and CLI update; older hosts keep local-only reads.++The desktop also remembers which pending question notification was explicitly+read. A reconnect can restore the question without bringing back its bell entry;+a matching answer or a new question resets that receipt. Both the native and+Flutter desktop inbox acknowledge a successful Open the same way as a device+read, while stale navigation and read tokens leave a newer message unread.++Actual native renderer output, using test fixture content:+++++## Short swipes and neighboring tabs — 2026-09-28++Orange revision `.orange.9` brings the previous and next names into view on+either side of the centered tab. Neighboring names are dimmer and clipped to+the safe central viewport. Short names align toward the visible edge of their+page, moving smoothly into centered alignment as they approach the middle.+Names wrap in a 12-cell column with up to six rows. Each visible name owns its+tap, so tapping a neighbor opens that tab. There is no Controls entry; only a+single centered Back arrow below the names.++Page spacing is 228 px with 2:1 drag tracking. A slow 58 px swipe reliably+advances one tab in either direction, down from 180–181 px. Flick projection+is capped at half a page and release settles in 192 ms. Touching during a settle+still only brakes it; roster changes still cancel stale contacts. Browsing sends+no desktop requests. The previous hold, voice, scrolling and read-sync rules stay+in place.++The renderer now supports authored `→` in both normal recap text and curved+labels. The recap-size `↗` also has its own correctly sized atlas instead of+using the smaller title glyph. The three new glyphs occupy 408 pixel bytes,+plus four bytes of curved ink bounds; no font engine, heap or framebuffer is+added. The exact example `Egg → developing cracks → hatch → baby Tim → growing+Tim → adult Tim.` is part of the native rendering fixtures.+++++## Readable Unicode fallbacks — 2026-09-28++Orange revision `.orange.10` normalizes display text before measuring, wrapping+and centering it. Existing supported glyphs keep their pixels; fractions use+readable ASCII, so `⅓` becomes `1/3` and `1⅓` becomes `1 1/3`. Unsupported+compatibility letters, ligatures, math operators, arrows and common emoji get+text equivalents. Negation is preserved: `≠` becomes `!=`, never `=`.++A scalar without an equivalent displays its explicit `[U+XXXX]` identifier+instead of a misleading question mark. Malformed UTF-8 uses `[U+FFFD]`. This+is a bounded display fallback, not a full Unicode font or language renderer.+The source message, pane IDs and notification receipts stay untouched. Approval+labels retain strict native-glyph and complete-fit checks; a transliteration+does not make an unsupported question safe to answer from the dial.++The shared path covers summaries, inbox cards, ordinary labels and curved text.+The existing 90-character recap budget applies after expansion. The table holds+2,080 equivalents in 49 ranges, 1,152 packed entries and 1,718 string bytes+(about 6.8 KiB of flash data). It adds no heap allocation, framebuffer or runtime+Unicode library. Creature artwork keeps its direct ASCII path. Regenerate with+Python 3.14 / Unicode 16.0.0 using+`firmware/scripts/gen_display_fallbacks.py`; `--check` verifies the committed table.+Ordinary builds do not require that Python version.++Validation covers every valid Unicode scalar, 3,000 randomized byte strings,+bounded copies, mixed fractions, math meaning, raw-versus-normalized wrap/arc+pixels, incremental redraws and unmodified notification text. The exact `⅓`+report is exercised in both home and inbox layouts for both characters.++diff --git a/devices/harness-device/prototype/habitat/assets/tabs-notifications-20260928.png b/devices/harness-device/prototype/habitat/assets/tabs-notifications-20260928.pngnew file mode 100644index 000000000..d032a7b97Binary files /dev/null and b/devices/harness-device/prototype/habitat/assets/tabs-notifications-20260928.png differdiff --git a/devices/harness-device/prototype/habitat/assets/tabs-peek-arrows-20260928.png b/devices/harness-device/prototype/habitat/assets/tabs-peek-arrows-20260928.pngnew file mode 100644index 000000000..9b79f6363Binary files /dev/null and b/devices/harness-device/prototype/habitat/assets/tabs-peek-arrows-20260928.png differdiff --git a/devices/harness-device/prototype/habitat/assets/unicode-fallbacks-20260928.png b/devices/harness-device/prototype/habitat/assets/unicode-fallbacks-20260928.pngnew file mode 100644index 000000000..afac4aeceBinary files /dev/null and b/devices/harness-device/prototype/habitat/assets/unicode-fallbacks-20260928.png differ