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
"""Replay physical contacts through the production Habitat handler and render its actual scenes."""
from pathlib import Path
import os
import re
import subprocess
import tempfile
from native_shapes import defines, face_geometry, typedef
here = Path(__file__).resolve().parent
native = here / '../main/ui/habitat'
source = Path(os.environ.get('UI_SOURCE', native / 'ui_habitat.c')).read_text()
def function(name):
m = re.search(r'^[^\n]*\b' + name + r'\([^;]*?\)\n\{.*?^\}', source, re.M | re.S)
assert m, name
body = m.group(0)
if name == 'control':
body = body.replace('{', "{\n if (label[0] == '[') assert(ht_can_display(label, UI_FONT, w, 1));", 1)
return body + '\n'
code = r'''
#include "runtime.h"
#include "../../cable_features.h"
#include "../../elapsed.h"
#include "gestures.h"
#include "scroll.h"
#include "selection.h"
#include "carry.h"
#include "visit.h"
#include "form.h"
#include "draft.h"
#include "octopus.h"
#include "character.h"
#include "focus.h"
#include "focus_faces.h"
#include "pets.h"
#include "workspace.h"
#include "supertab.h"
#include "command_face.h"
#include "arc_geometry.inc"
#include <assert.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <math.h>
'''
# Keep real protocol capacities: a larger fake buffer can hide target truncation.
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)
code += defines('FACE_CX', 'BUDDY_LILAC', source=source)
code += '#define NOTICE_TTL_MS 21600000u\n#define ERROR_VIEW_MS 8000u\nstatic void ui_cable_toast(const char *message) { (void)message; }\n'
if '#define PANE_RESULT_BYTES ' in source:
code += defines('PANE_RESULT_BYTES', source=source)
code += face_geometry(source)
code += source[source.index('typedef enum {'):source.index('static EXT_RAM_BSS_ATTR struct {')]
code += typedef('cable_swarm_t') + typedef('cable_notif_t')
code += r'''
static struct {
bool ready, connected, loading, voice_open, voice_start_pending, voice_waiting, voice_carry, voice_review, voice_draft_append, voice_review_preview, voice_search, voice_swarm;
bool coasting, touch_brake, touch_down, touch_cancelled, quiet, nap, focus_face, straight_title, muted;
ht_rect_t pressed_rect;
int brightness;
char voice_target[CABLE_NAME_MAX], voice_engine[12];
int pattern_mask, pattern_len, view, voice_return, offset, active, count, pressed, hit_count;
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, nap_until, last_celebration;
uint32_t notice_sequence, voice_retry_until, error_until;
uint8_t status_phase;
unsigned bell_unread;
uint32_t notice_ms;
ht_focus_working_pick_t working_pick;
uint32_t pet_next_ms;
uint32_t timer_at;
uint32_t pick_until;
cable_swarm_t tabs[SWARMS_MAX];
struct { char id[64], name[96], state[16]; bool local; } machines[2];
char selected_tab[ID_MAX], pending_focus[ID_MAX], opening_notice[ID_MAX], title[80], message[256], stop_agent[ID_MAX];
cable_notif_t notice[NOTICES];
notice_receipt_t notice_reads[NOTICES];
uint8_t notice_read_next;
uint32_t notice_revision, notice_frame;
pane_memory_t memory[PANE_MEMORY_MAX];
uint32_t memory_serial;
struct { char id[192]; } models[2];
char model_agent[64];
question_t q;
agent_t agents[MAX_PROJECTS]; hit_t hits[24];
ht_rect_t caption_arc;
ht_rect_t recap_card;
} s;
static ht_gesture_t gesture;
static ht_character_t character;
static bool companion_celebrating, follow_companion=true;
static uint32_t celebration_began;
static char celebration_label[64];
static ht_character_id_t desktop_companion=HT_CHARACTER_COUNT;
static struct { char name[25]; } desktop_identity;
static void select_companion(void) {}
static ht_character_caption_t home_caption;
static ht_character_id_t test_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;
static ht_visit_t visit;
static action_t visit_queued;
static int visit_sends,visit_wire;
static char visit_wire_op[16];
static bool question_pending;
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 ht_tab_carousel_t pane_carousel;
static ht_tab_carousel_t inbox_carousel;
static int tab_switches;
static char tab_target[64];
static action_t tab_queued;
static int draft_actions, reviews;
static ht_draft_command_t draft_command;
static bool draft_emit(const ht_draft_command_t *c, void *ctx) { (void)ctx; draft_command=*c; draft_actions++; return true; }
static ht_select_command_t selected_command;
static int selections;
static int carry_prepares, carry_drops, question_sends, desktop_opens;
static char opened_agent[64];
static char voice_context[48];
static bool scroll_reversed, congestion, recording;
static uint32_t host_features = 31;
static bool cable_client_supports(uint32_t features) { return (host_features & features) == features; }
typedef struct cJSON { const char *string,*valuestring; int type; struct cJSON *child,*next; } cJSON;
enum { JSTRING=1,JTRUE=2 };
static bool cJSON_IsString(const cJSON *v) { return v && v->type==JSTRING; }
static bool cJSON_IsTrue(const cJSON *v) { return v && v->type==JTRUE; }
static const cJSON *cJSON_GetObjectItemCaseSensitive(const cJSON *v,const char *key) {
for(const cJSON *p=v?v->child:NULL;p;p=p->next) if(p->string && !strcmp(p->string,key)) return p;
return NULL;
}
static action_t pressed_action;
static int returns, form_actions;
static ht_form_command_t form_command;
static bool form_emit(const ht_form_command_t *c, void *ctx) {
(void)ctx; form_command=*c; form_actions++; return true;
}
static int starts, stops, boops, switches, down_reports, moves, ups, travel, waiting_count;
static char target[64];
#define COPY(dst, src) snprintf(dst, sizeof(dst), "%s", src)
#include "theme.h"
static uint16_t color(unsigned rgb);
static unsigned preview_brightness = 100;
// Kept in step with ui_habitat.c by hand: the Focus skin stands on its own black ground.
#define BG color(character.id == HT_CHARACTER_FOCUS ? HT_THEME_FOCUS_CANVAS : HT_THEME_CANVAS)
#define FG color(HT_THEME_TEXT)
#define DIM color(HT_THEME_SECONDARY)
#define ACCENT color(HT_THEME_ACCENT)
#define ERROR color(HT_THEME_ERROR)
#define SEL color(HT_THEME_SELECTION)
#define ESP_LOGI(...) ((void)0)
#define EXT_RAM_BSS_ATTR
static unsigned changes;
static void change(void) { changes++; }
static void display_lock(void) {}
static void display_unlock(void) {}
static int wakes;
static void display_wake(void) { wakes++; }
static bool fake_asleep, present_scene=true;
static bool display_is_asleep(void) { return fake_asleep; }
static bool audio_client_active(void) { return recording; }
static bool audio_client_recording(void) { return recording; }
static unsigned audio_client_input_level(void) { return 3; }
static agent_t *active(void) { return s.active >= 0 && s.active < s.count ? &s.agents[s.active] : NULL; }
static int find(const char *id);
static bool is_question(const char *id) { (void)id; return question_pending; }
static void open_question(void) { s.view=QUESTION; }
static bool visit_emit(const ht_visit_command_t *c,void *ctx) {
(void)ctx; if(congestion)return false;
visit_queued=(action_t){.kind=A_VISIT_SEND,.value=c->op,.revision=c->request};
COPY(visit_queued.id,c->agent); COPY(visit_queued.text,c->id); visit_sends++; return true;
}
static void cable_client_visit(const char *id,uint32_t request,const char *op,const char *agent) {
assert(id[0] && request); (void)agent; COPY(visit_wire_op,op); visit_wire++;
}
static int waiting(void) { return waiting_count; }
static int working(void) { return s.agents[0].busy + s.agents[1].busy; }
static bool select_emit(const ht_select_command_t *c, void *ctx) {
(void)ctx; if (congestion) return false; selected_command=*c; selections++; return true;
}
static bool carry_emit(const ht_carry_command_t *c, void *ctx) {
(void)ctx; if (congestion) return false;
if (c->cancel) carry_drops++;
else { carry_prepares++; assert(!strcmp(c->selection,"pick-test") && !strcmp(c->agent,"a")); }
return true;
}
static uint32_t fake_ms;
static char swarm_wire[64][128], stopped_agent[64]; static int swarm_sent;
static uint32_t ms(void) { return fake_ms ? fake_ms : gesture.began+75; }
static uint32_t fake_random; // even: the chef, odd: the builder (focus.c ht_focus_pick_working)
static uint32_t esp_random(void) { return fake_random; }
static bool queue(action_t a) {
if (congestion) return false;
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); }
if (a.kind==A_SUPERTAB && swarm_sent<64) {
static const char *ops[]={"recap.get","open","select","side","side-kept","thread-leave"};
snprintf(swarm_wire[swarm_sent++],sizeof swarm_wire[0],"%s %s %s",ops[a.value],a.text,a.id);
}
if (a.kind==A_STOP_YES) COPY(stopped_agent,a.id);
return true;
}
static bool scroll_emit(ht_scroll_phase_t phase, int dy, int velocity, void *ctx) {
(void)velocity; (void)ctx;
if (congestion) return false;
if (phase == HT_SCROLL_DOWN) down_reports++;
if (phase == HT_SCROLL_MOVE) { moves++; travel += dy; }
if (phase == HT_SCROLL_UP) { ups++; travel += dy; }
return true;
}
'''
code += function('color')
code += function('settings_item') + function('settings_count') + function('hit_contains')
code += function('find')
code += 'static void notice_expire(uint32_t now);\n'
swarm_core = source[source.index('/*\n * THE SWARMS'):source.index('static void tabs_open(void)')]
swarm_parts = {
'swarm_core': swarm_core,
'render_swarm_face': 'static void render_focus_panes(ht_scene_t *f);\n' + function('render_swarm_face'),
# with the last `swarms` list it keeps beside it
'swarms_apply': source[source.index('// The last `swarms` list as it came'):source.index('void ui_swarms_replace(')],
}
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', 'swarm_core', 'swarm_voice_id', 'voice_lead', 'tabs_open', 'face_hold', 'workspace_failed', 'tab_request', 'tabs_sync', 'ui_scroll_reportable', 'focus_skin', 'focus_face_for', 'focus_chord', 'focus_put', 'focus_span', 'focus_take', 'focus_rows', 'ui_rows', 'ui_can_display', 'ui_wrap', 'text_in', 'control', 'home_footer', 'footer_control', 'text', 'center', 'render_brand', 'heading', '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', 'question_prompt', 'focus_bell', 'mix_black', 'face_buddy_disc', 'face_buddy_ring', 'companion_box', 'notice_badge', 'pill2', 'swarm_pair', 'pick_icon', 'pick_row', 'render_swarm_pick', 'face_buddy_avatar', 'render_buddy_empty', 'thread_line', 'thread_rest', 'face_thread', 'render_swarm_face', 'render_home', 'render_voice', 'render_selection', 'render_form', 'draft_move', 'render_draft', 'render_draft_options', 'swarms_apply', 'ui_swarms_replace', 'ui_workspace_applied', 'ui_land_after_reload']:
code += swarm_parts[name] if name in swarm_parts else 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('focus_centred') + function('focus_header') + function('focus_clipped') + function('tabs_move') + function('tab_name') + function('tab_split') + function('tab_fade') + function('tab_neighbour') + function('focus_carousel') + function('tab_label') + function('render_focus_tabs') + function('pane_label') + function('render_focus_panes') + function('render_agents') + function('render_tabs') + function('page_controls') + function('render_notice') + function('css_line') + function('inbox_line') + function('inbox_page') + function('render_focus_inbox') + function('render_list')
for name in ['notice_remove', 'notice_sync_view', 'notice_selection', 'notice_restore_selection', 'notice_add', 'notice_expire', 'on_face', 'notice_read_now', 'ui_notify_summary', 'ui_turn_error', 'ui_notif_seen', 'ui_notif_read', 'ui_notif_replace', 'ui_notif_open', 'ui_question_close', 'ui_answer_receipt',
'utf8_trim', 'swarm_notice', 'swarm_notice_mark', 'swarm_notice_raise', 'swarm_notice_drop', 'swarm_events',
'swarm_tabs_changed', 'swarm_regain', 'ui_supertabs_ids', 'ui_supertab', 'ui_supertab_recap', 'ui_supertab_focus',
'ui_supertab_wait', 'ui_supertab_wait_close', 'ui_supertabs_clear', 'swarm_said_of', 'ui_supertab_notice', 'ui_supertab_notice_read']:
code += function(name)
code += '#define ui_notify_task_done(a,b,c,d) ui_notify_summary(a,b,c,d,"alert",false,false)\n'
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)
visit_actions=source.split(' case A_LATEST:',1)[1].split(' case A_TABS:',1)[0]
code+='static void visit_action(action_t a) { switch(a.kind) { case A_LATEST:'+visit_actions+'default: break; } }\n'
notice_actions=source.split(' case A_NOTICE:',1)[1].split(' case A_LATEST:',1)[0]
code+='static void notice_action(action_t a) { switch(a.kind) { case A_NOTICE:'+notice_actions+'default: break; } }\n'
desktop_actions=source.split(' case A_DESKTOP:',1)[1].split(' case A_UP:',1)[0]
code+='static void desktop_action(action_t a) { switch(a.kind) { case A_DESKTOP:'+desktop_actions+'default: break; } }\n'
visit_worker=source.split('static void worker(',1)[1].split(' case A_VISIT_SEND:',1)[1].split(' case A_SELECT_SEND:',1)[0]
code+='static void visit_work(action_t a) { switch(a.kind) { case A_VISIT_SEND:'+visit_worker+'default: break; } }\n'
carry_actions = source.split('case A_CARRY:\n',1)[1].split('case A_NAP:',1)[0]
code += 'static void carry_action(action_t a) { switch(a.kind) { case A_CARRY:\n' + carry_actions + 'default: break; } }\n'
code += 'static void dispatch(action_t a);\n'
lead_actions = source.split(' case A_LEAD: {',1)[1].split(' case A_READER:',1)[0]
panes_actions = source.split(' case A_AGENTS: {',1)[1].split(' case A_AGENT: {',1)[0]
code += '#define TAB_ROWS 4\nstatic void panes_action(action_t a) { switch(a.kind) { case A_AGENTS: {'+panes_actions+'default: break; } }\n'
stop_actions = source.split(' case A_STOP_YES:\n',1)[1].split(' case A_MODELS:',1)[0]
code += 'static void stop_action(action_t a) { switch(a.kind) { case A_STOP_YES:\n'+stop_actions+'default: break; } }\n'
code += 'static void lead_action(action_t a) { switch(a.kind) { case A_LEAD: {'+lead_actions+'default: break; } }\n'
question_actions = source.split(' case A_QUESTION_CHOICES:\n',1)[1].split(' case A_INBOX:',1)[0]
code += 'static void question_action(action_t a) { switch(a.kind) { case A_QUESTION_CHOICES:\n'+question_actions+'default: break; } }\n'
draft_actions = source.split(' case A_DRAFT_EDIT:\n',1)[1].split(' case A_HOME:',1)[0]
code += 'static void draft_action(action_t a) { switch(a.kind) { case A_DRAFT_EDIT:\n'+draft_actions+'default: break; } }\n'
form_actions = source.split(' case A_FIND:\n case A_FORM:',1)[1].split(' case A_SETTINGS:',1)[0]
code += 'static void form_action(action_t a) { switch(a.kind) { case A_FIND:\n case A_FORM:'+form_actions+'default: break; } }\n'
workspace_actions = source.split(' case A_TABS:',1)[1].split(' case A_MACHINE:',1)[0]
code += 'static void workspace_action(action_t a) { switch(a.kind) { case A_TABS:'+workspace_actions+'default: break; } }\n'
page_actions = source.split(' case A_UP:',1)[1].split(' case A_SETTINGS_SAVE:',1)[0]
code += 'static void page_action(action_t a) { switch(a.kind) { case A_UP:'+page_actions+'default: break; } }\n'
code += r'''
static void dispatch(action_t a) {
if ((s.view==DRAFT || s.view==DRAFT_OPTIONS) && a.kind!=A_VOICE) { draft_action(a); return; }
if (question_view(s.view) && a.kind!=A_VOICE) { question_action(a); return; }
if (a.kind==A_CARRY || a.kind==A_CARRY_DROP) { carry_action(a); return; }
if (a.kind == A_FIND || a.kind == A_FORM || a.kind == A_FORM_MAIN || a.kind == A_FORM_BACK || a.kind == A_FORM_SAY) {
form_action(a);
} else if (a.kind == A_SELECT_FIND) { a.kind=A_VOICE; a.value=7; dispatch(a);
} else if (a.kind == A_VOICE) {
starts++; COPY(target, a.id); COPY(s.voice_target, a.value==7 ? "Find in output" : active()->name);
s.voice_engine[0]=0; // as the real dispatch: the recipient's engine, none for Find / form / draft voice
for (int i=0;i<s.count;i++) if (a.value!=2 && a.value!=5 && a.value!=6 && a.value!=7 && !strcmp(s.agents[i].id,a.id)) COPY(s.voice_engine,s.agents[i].engine);
const ht_lead_t *lead = voice_lead(a.id, a.value); // and a Swarm's Lead's, by its harness
if (lead) { COPY(s.voice_engine, swarm_voice_engine(lead)); COPY(s.voice_target, lead->project); }
sw.voice_buddy = lead && swarm_on_buddy(lead) && lead->buddy.has; // as the real dispatch: pinned at the start
s.voice_carry=a.value==3; s.voice_search=a.value==7; COPY(voice_context,a.text);
s.voice_return=s.view; s.voice_open = recording = true; view(VOICE);
} else if (a.kind == A_VOICE_STOP) { stops++; if(a.value==1)reviews++; recording = false; }
else if (a.kind == A_VOICE_ABORT) { recording = s.voice_open = false; view(HOME); }
else if (a.kind == A_RETURN || a.kind == A_LATEST) { if(a.kind==A_RETURN)returns++; visit_action(a); }
else if (a.kind == A_PET) boops++;
else if (a.kind == A_TAB_LIST) tabs_open(); // mirrors ui_habitat.c's dispatch
else if (a.kind == A_LEAD) lead_action(a);
else if (a.kind == A_STOP_YES) stop_action(a);
else if (a.kind == A_AGENT) {
swarm_leave(); switches++; s.active = 0; // the pane with that id, as ui_habitat.c's find
for (int i = 0; i < s.count; i++) if (!strcmp(s.agents[i].id, a.id)) s.active = i;
view(AGENT);
} else if (a.kind == A_SETTINGS) view(SETTINGS);
else if (a.kind == A_FIND) view(FORM);
else if (a.kind == A_AGENTS) panes_action(a); // ui_habitat.c's own: the pages open on the pane on the face
else if (a.kind == A_INBOX) notice_open();
else if (a.kind == A_SIDE_PM || a.kind == A_SIDE_BUDDY) swarm_side_set(a.kind == A_SIDE_BUDDY); // ui_habitat.c's own
else if (a.kind == A_PICK_PERSONAL || a.kind == A_PICK_TEAM) { if (s.view == SWARM_PICK) swarm_pick(a.kind == A_PICK_TEAM); } // ui_habitat.c's own
else if (a.kind == A_HOME) view(HOME);
else if (a.kind == A_NOTICE) notice_action(a);
else if (a.kind == A_RECAP_DISMISS) dismiss_result(a.id);
else if (a.kind == A_DESKTOP) desktop_action(a);
else if (a.kind == A_UP || a.kind == A_DOWN) page_action(a);
else if (a.kind == A_TABS || a.kind == A_TAB || a.kind == A_TAB_DONE) workspace_action(a);
else if (a.kind == A_SELECT_BEGIN) {
view(SELECTION); ht_selection_open(&selection,"pick-test",active()->id,1800,select_emit,NULL);
} else if (a.kind == A_SELECT_EXTEND) ht_selection_extend(&selection,3000);
}
'''
code += function('swarm_scroll_reportable') + function('habitat_touch') + function('habitat_touch_cancel') + function('habitat_next_wake_ms')
code += 'static bool audio_client_active(void);\n' + function('ui_boot_pressed')
code += r'''
static ht_scene_t scene;
static void scene_take(void) {
ht_scene_clear(&scene, BG); s.hit_count = 0; s.notice_frame = 0; s.recap_card = (ht_rect_t){0};
if (s.view == OTA) render_brand(&scene);
else if (s.view == DRAFT) render_draft(&scene);
else if (s.view == DRAFT_OPTIONS) render_draft_options(&scene);
else if (s.view == QUESTION) render_question(&scene);
else if (s.view == CHOICE) render_choices(&scene);
else if (s.view == ANSWER_REVIEW) render_answer_review(&scene);
else if (s.view == FORM) render_form(&scene);
else if (s.view == VOICE) render_voice(&scene);
else if (s.view == TABS || s.view == INBOX || s.view == MACHINES) render_list(&scene);
else if (s.view == AGENTS) render_agents(&scene);
else if (s.view == SELECTION) render_selection(&scene);
else if (s.view == SWARM_PICK) render_swarm_pick(&scene); else render_home(&scene);
if (s.view == SETTINGS) { ht_scene_clear(&scene,BG); s.hit_count=0; render_settings(&scene); }
if (present_scene) habitat_scene_presented(habitat_scene_receipt());
}
static void reset(void) {
host_features=31; fake_ms=0; fake_asleep=false; present_scene=true; fake_random=122;
memset(&visit,0,sizeof visit); visit_sends=visit_wire=returns=0; question_pending=false;
memset(&tab_carousel,0,sizeof tab_carousel); memset(&pane_carousel,0,sizeof pane_carousel); memset(&inbox_carousel,0,sizeof inbox_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;
ht_draft_reset(&draft); draft_actions=reviews=0; ht_form_reset(&form); form_actions=0;
memset(&home_caption,0,sizeof home_caption); memset(&character,0,sizeof character); ht_character_select(&character,test_character); memset(&s, 0, sizeof(s)); memset(&gesture, 0, sizeof(gesture)); memset(&scroll, 0, sizeof(scroll));
s.ready = s.connected = true; s.count = 2; s.active = 0; s.view = HOME; s.pressed = -1;
s.brightness = preview_brightness;
strcpy(s.agents[0].id, "a"); strcpy(s.agents[1].id, "b");
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; notice_reads_sent=0;
ht_supertabs_reset(&swarm); memset(&sw,0,sizeof sw); swarm_sent=0; stopped_agent[0]=0;
desk_row_count=0; desk_selected[0]=0;
scene_take();
}
static void workspace_setup(void) {
reset(); s.tab_count=4; strcpy(s.selected_tab,"tab-1");
static const char *names[]={"M2","Product","Device","Research"};
for(int i=0;i<s.tab_count;i++) {
snprintf(s.tabs[i].id,sizeof s.tabs[i].id,"tab-%d",i);
snprintf(s.tabs[i].name,sizeof s.tabs[i].name,"%s",names[i]);
s.tabs[i].panes=i; s.tabs[i].agents=1;
}
scene_take();
}
static void tap(uint32_t t, int x, int y) {
habitat_touch(true, x, y, t);
habitat_touch(false, x, y, t + 75);
scene_take();
}
static bool action_enabled(action_kind_t action) {
for (int i=0;i<s.hit_count;i++) if (s.hits[i].action==action) return s.hits[i].enabled;
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," ");
assert(strlen(footer)+strlen(scene.runs[i].text)<sizeof footer);
strcat(footer,scene.runs[i].text);
}
if(footer[0] && !strcmp(footer,text)) return true;
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) &&
!strcmp(scene.runs[i].text,text)) return true;
return false;
}
static bool inbox_mark_is(const char *mark, uint16_t ink) {
for (int i=0;i<scene.count;i++) if(!strcmp(scene.runs[i].text,mark))
return scene.runs[i].fg==ink && scene.runs[i].font==&ht_mono_28;
return false;
}
static bool title_is(const char *text) {
for(int i=0;i<scene.count;i++)
if((scene.runs[i].arc==1 || (s.straight_title && scene.runs[i].y==41)) && !strcmp(scene.runs[i].text,text)) return true;
return false;
}
// A Focus page draws in ONE font (owner, 2026-10-02): every visible text run is one of the five Inter faces, except an
// icon run (the bell and the close cross, FontAwesome in Montserrat, alone in their run) and the voice bars / sparkles
// (drawn art in ht_wave / ht_spark). No GeistMono, no Geist, no Roboto; a curved run (the name on the upper arc, the
// status and the Listening word on the lower) is Inter Medium 26. An empty run is an invisible placeholder: its font
// pointer does not count. Then the portrait.
static void portrait(const char *dir, const char *name);
static bool focus_inter(const ht_font_t *f) {
return f==&ht_lv_inter_20.base || f==&ht_lv_inter_25.base || f==&ht_lv_inter_med_26.base ||
f==&ht_lv_inter_30.base || f==&ht_lv_inter_36.base || f==&ht_lv_inter_28.base || f==&ht_lv_inter_44.base ||
f==&ht_lv_inter_bold_48.base;
}
static void focus_only_inter(void) {
for (int i = 0; i < scene.count; i++) {
const ht_run_t *r = &scene.runs[i];
if (!r->text[0]) continue;
bool icon = (r->font == &ht_done_28 && !strcmp(r->text, HT_DONE)) ||
(r->font == &ht_lv_montserrat_14.base && !strcmp(r->text, HT_LV_BELL)) ||
(r->font == &ht_lv_montserrat_22.base && !strcmp(r->text, HT_LV_CROSS));
bool art = r->font == &ht_wave || r->font == &ht_spark;
assert(focus_inter(r->font) || icon || art);
// The name and status arcs are Inter Medium 26; a Swarm face's chat, on the inner arc, is Inter 20.
if (r->arc) assert(r->font == (r->arc == 3 ? &ht_lv_inter_20.base : &ht_lv_inter_med_26.base));
}
}
// Every straight text run of a Focus page sits inside the glass (r 230 on its four corners) and a bracket
// control's label sits inside a rect that is tapped (the hit rects did not move with the font).
static void focus_inside(void);
static void portrait_focus(const char *dir, const char *name) {
focus_only_inter();
portrait(dir, name);
}
// The design export (mockup/focus_design.py): every run of the portrait as JSON beside it — kind, place, face,
// colours in panel order, text — and the touch targets, so a designer reads the exact numbers, not a guess.
static const char *spec_font(const ht_font_t *f) {
static const struct { const ht_font_t *f; const char *name; } names[] = {
{&ht_lv_inter_20.base,"inter_20"},{&ht_lv_inter_25.base,"inter_25"},{&ht_lv_inter_med_26.base,"inter_med_26"},
{&ht_lv_inter_30.base,"inter_30"},{&ht_lv_inter_36.base,"inter_36"},
{&ht_lv_inter_28.base,"inter_28"},{&ht_lv_inter_44.base,"inter_44"},{&ht_lv_inter_bold_48.base,"inter_bold_48"},
{&ht_lv_montserrat_14.base,"montserrat_14"},
{&ht_lv_montserrat_22.base,"montserrat_22"},{&ht_done_28,"done_28"},{&ht_wave,"wave"},{&ht_spark,"spark"},
{&ht_mono_16,"mono_16"},{&ht_mono_20,"mono_20"},{&ht_mono_24,"mono_24"},{&ht_mono_28,"mono_28"}};
for (unsigned i = 0; i < sizeof names / sizeof names[0]; i++) if (names[i].f == f) return names[i].name;
return "other";
}
static void spec_string(FILE *fp, const char *t) {
fputc('"', fp);
for (; *t; t++) {
unsigned char c = (unsigned char)*t;
if (c == '"' || c == '\\') fprintf(fp, "\\%c", c);
else if (c < 0x20) fprintf(fp, "\\u%04x", c);
else fputc(c, fp);
}
fputc('"', fp);
}
static void portrait_spec(const char *dir, const char *name) {
char path[1024]; snprintf(path, sizeof(path), "%s/%s.json", dir, name);
FILE *fp = fopen(path, "wb"); assert(fp);
fprintf(fp, "{\"background\":%u,\"runs\":[", scene.background);
for (int i = 0; i < scene.count; i++) {
const ht_run_t *r = &scene.runs[i];
ht_rect_t b = ht_run_bounds(r);
const char *kind = r->ring.set ? "ring" : r->sprite.width ? "sprite" : r->box.h ? "box" : r->arc ? "arc" : "text";
fprintf(fp, "%s{\"kind\":\"%s\",\"x\":%d,\"y\":%d,\"w\":%d,\"bounds\":[%d,%d,%d,%d],\"fg\":%u,\"bg\":%u,\"font\":\"%s\",\"text\":",
i ? "," : "", kind, r->x, r->y, r->w, b.x, b.y, b.w, b.h, r->fg, r->bg, spec_font(r->font));
spec_string(fp, r->text);
fprintf(fp, ",\"line\":%d,\"measure\":%d,\"arc\":%d,\"arc_mid\":%d,\"gained\":%d",
r->font->height, r->text[0] && !r->box.h && !r->ring.set && !r->sprite.width ? ht_measure(r->font, r->text) : 0,
r->arc, r->arc_mid, r->gained);
if (r->box.h) fprintf(fp, ",\"box\":{\"h\":%u,\"radius\":%u,\"fill\":%u,\"border\":%u}", r->box.h, r->box.radius, r->box.fill, r->box.border);
if (r->sprite.width) fprintf(fp, ",\"sprite\":{\"w\":%u,\"h\":%u,\"cell\":%u,\"cells\":%d,\"icon\":%d}",
r->sprite.width, r->sprite.height, r->sprite.cell, r->sprite.cells != NULL, r->sprite.lvgl);
if (r->ring.set) fprintf(fp, ",\"ring\":{\"cx16\":%d,\"cy16\":%d,\"r16\":%u,\"w16\":%u,\"colour\":%u,\"ux\":%d,\"uy\":%d,\"cosh\":%d}",
r->ring.cx16, r->ring.cy16, r->ring.r16, r->ring.w16, r->ring.colour, r->ring.ux, r->ring.uy, r->ring.cosh);
fputc('}', fp);
}
fprintf(fp, "],\"hits\":[");
for (int i = 0; i < s.hit_count; i++)
fprintf(fp, "%s{\"rect\":[%d,%d,%d,%d],\"action\":%d,\"enabled\":%d}", i ? "," : "",
s.hits[i].rect.x, s.hits[i].rect.y, s.hits[i].rect.w, s.hits[i].rect.h, (int)s.hits[i].action, s.hits[i].enabled);
fprintf(fp, "]}\n");
fclose(fp);
}
static void portrait(const char *dir, const char *name) {
if (!dir) return;
char path[1024]; snprintf(path, sizeof(path), "%s/%s.ppm", dir, name);
FILE *fp = fopen(path, "wb"); assert(fp);
fprintf(fp, "P6\n466 466\n255\n");
uint16_t row[466];
for (int y=0; y<466; y++) {
ht_raster(&scene, (ht_rect_t){0,y,466,1}, row);
for (int x=0; x<466; x++) {
uint16_t c = (uint16_t)((row[x] >> 8) | (row[x] << 8));
unsigned char rgb[3] = {(unsigned char)(((c>>11)&31)*255/31),
(unsigned char)(((c>>5)&63)*255/63),(unsigned char)((c&31)*255/31)};
if ((x-233)*(x-233)+(y-233)*(y-233)>233*233) memset(rgb, 0, 3);
fwrite(rgb, 1, 3, fp);
}
}
fclose(fp);
portrait_spec(dir, name);
}
static void focus_inside(void) {
for (int i = 0; i < scene.count; i++) {
const ht_run_t *r = &scene.runs[i];
if (!r->text[0] || r->arc || r->box.h || r->sprite.width || r->font == &ht_wave || r->font == &ht_spark) continue;
int w = ht_measure(r->font, r->text), h = r->font->height;
assert(w <= r->w);
for (int k = 0; k < 4; k++) {
int x = r->x + (k & 1 ? w : 0) - 233, y = r->y + (k & 2 ? h : 0) - 233;
assert(x * x + y * y <= 230 * 230);
}
if (r->text[0] == '[') {
bool tapped = false;
for (int k = 0; k < s.hit_count; k++) {
ht_rect_t q = s.hits[k].rect;
tapped |= r->x >= q.x && r->x + w <= q.x + q.w && r->y >= q.y && r->y + h <= q.y + q.h;
}
assert(tapped);
}
}
}
// One Focus page: Inter only, inside the glass, then its picture.
#define FOCUS_PAGE(name) do { scene_take(); focus_only_inter(); focus_inside(); portrait(dir, name); } while (0)
static void carry_return_setup(bool with_text) {
reset();
assert(ht_visit_latest(&visit,"reading-return","a",100,visit_emit,NULL));
assert(ht_visit_reply(&visit,visit.id,visit.request,true,"Your reading"));
if(with_text) {
ht_carry_open(&carry,"carried-passage","a","pick-test",1,200,carry_emit,NULL);
assert(ht_carry_reply(&carry,carry.id,carry.request,true,"Research helper","Keep this paragraph",3,300000,NULL,250));
}
scene_take();
}
static bool result_visible(void) {
for (int i=0;i<scene.count;i++) if ((scene.runs[i].font->height<=6 && strlen(scene.runs[i].text)>=32)) return true;
return false;
}static void recap_checks(const char *dir) {
// The live row has always received the 1,024-byte memory record's prefix.
// Exercise actual production capacities before/after removing unused tail
// storage, and preserve all fields through full-roster permutations.
static char complete[8193];
static const size_t lengths[] = {0, 1, 239, 1023, 1024, 4095, 8192};
for (unsigned sample=0; sample<sizeof lengths/sizeof lengths[0]; sample++) {
reset();
size_t len=lengths[sample];
for (size_t i=0;i<len;i++) complete[i]=(char)('a'+i%26);
complete[len]=0;
ui_project_emit("a","session-a","summary",complete,"Visible recap.");
const char *want=len?complete:"Visible recap.";
size_t kept=strlen(want);
if (kept>=sizeof s.memory[0].full) kept=sizeof s.memory[0].full-1;
assert(strlen(s.agents[0].full)==kept && !memcmp(s.agents[0].full,want,kept));
assert(!strcmp(s.agents[0].preview,"Visible recap."));
}
reset(); ui_project_clear_all();
char ids[MAX_PROJECTS][ID_MAX]; const char *order[MAX_PROJECTS];
for (int i=0;i<MAX_PROJECTS;i++) {
snprintf(ids[i],sizeof ids[i],"pane-%d",i);
ui_project_set_name(ids[i],ids[i]);
ui_project_emit(ids[i],ids[i],"summary",ids[i],ids[i]);
}
s.active=MAX_PROJECTS/2;
for (int pass=0;pass<64;pass++) {
for (int i=0;i<MAX_PROJECTS;i++) order[i]=ids[(MAX_PROJECTS-1-i+pass)%MAX_PROJECTS];
ui_project_apply_order(order,MAX_PROJECTS);
assert(!strcmp(s.agents[s.active].id,ids[MAX_PROJECTS/2]));
for (int i=0;i<MAX_PROJECTS;i++) {
assert(!strcmp(s.agents[i].id,order[i]));
assert(!strcmp(s.agents[i].name,order[i]));
assert(!strcmp(s.agents[i].full,order[i]));
assert(!strcmp(s.agents[i].preview,order[i]));
}
}
printf("roster storage: sizeof(agent_t)=%zu; full=%zu; exact result prefixes and 64 full-roster permutations PASS\n", sizeof(agent_t),sizeof s.agents[0].full);
reset();
char preview[32];
activity_text(preview,sizeof preview,"Wandering..."); assert(!strcmp(preview,"Wandering"));
activity_text(preview,sizeof preview,"Coalescing\xe2\x80\xa6"); assert(!strcmp(preview,"Coalescing"));
activity_text(preview,sizeof preview,"Working"); assert(!strcmp(preview,"Working"));
activity_text(preview,sizeof preview,"A...B"); assert(!strcmp(preview,"A...B"));
activity_text(preview,sizeof preview," Working ... \n"); assert(!strcmp(preview,"Working"));
activity_text(preview,sizeof preview,"\tMessages to be submitted after "); assert(!strcmp(preview,"Messages to be submitted after"));
recap_preview(preview,sizeof preview," \nFixed\t the\r\nparser. ");
assert(!strcmp(preview,"Fixed the parser."));
recap_preview(preview,5,"caf\xc3\xa9"); assert(!strcmp(preview,"caf"));
recap_preview(preview,6,"caf\xc3\xa9"); assert(!strcmp(preview,"caf\xc3\xa9"));
recap_preview(preview,sizeof preview," \t\r\n"); assert(!preview[0]);
recap_preview(preview,sizeof preview,"bad\xe2"); assert(!strcmp(preview,"bad?"));
recap_preview(preview,1,"x"); assert(!preview[0]);
recap_preview(preview,sizeof preview,"Details continue\xe2\x80\xa6"); assert(!strcmp(preview,"Details continue +"));
recap_preview(preview,sizeof preview,"Details continue+"); assert(!strcmp(preview,"Details continue +"));
recap_preview(preview,sizeof preview,"Details continue +"); assert(!strcmp(preview,"Details continue +"));
recap_preview(preview,sizeof preview,"Written in C++"); assert(!strcmp(preview,"Written in C++"));
recap_preview(preview,sizeof preview,"Wait... then proceed."); assert(!strcmp(preview,"Wait... then proceed."));
reset();
ui_project_emit("a","session-a","summary","It isn't external. That is the branch name.","It isn't external.");
scene_take(); portrait(dir,"complete-sentence");
ui_project_emit("a","session-a","summary","Yes. The fix is installed.","Yes. The fix is installed.");
scene_take(); portrait(dir,"acknowledgment-explanation");
ui_project_emit("a","session-a","summary","Yes. The fix is installed and the device has reconnected successfully to the desktop application.","Yes. The fix is installed and the device has reconnected successfully to the+");
scene_take(); portrait(dir,"continued-sentence");
ui_project_emit("a","session-a","summary","Fixed the parser. All tests pass. Voice input now sends to the selected agent. More details follow.","Fixed the parser. All tests pass. Voice input now sends to the selected agent.");
scene_take(); portrait(dir,"three-sentences");
const char *long_result="The update is installed. Voice input sends to the selected agent. The summary has more room, the octopus is larger, and unread messages open from the bottom edge of the screen.";
assert(strlen(long_result)>160);
ui_project_emit("a","session-a","summary",long_result,long_result);
scene_take(); portrait(dir,"long-reading");
char visible[400]="";
for(int i=0;i<scene.count;i++) if(scene.runs[i].font==&ht_mono_28 && !scene.runs[i].arc && scene.runs[i].y>=HT_CHARACTER_READING_TEXT_Y && scene.runs[i].y<400) {
if(visible[0] && scene.runs[i].text[0])strcat(visible," ");
strcat(visible,scene.runs[i].text);
}
assert(strlen(visible)>60 && strlen(visible)<=HT_CHARACTER_RECAP_CHARS);
for(int i=0;i<scene.count;i++) assert(scene.runs[i].font!=&ht_nav_32 && scene.runs[i].font!=&ht_open_20);
assert(strstr(visible,"...") && !strcmp(s.agents[0].full,long_result));
ui_notify_task_done("b","Other pane","M2","The checks passed.");
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);
ui_project_emit("a","session-a","summary","Full explanation in the reader.","Fixed the parser. All tests pass.");
scene_take(); assert(result_visible()); portrait(dir,"completed");
assert(!strcmp(s.agents[0].preview,"Fixed the parser. All tests pass."));
assert(!strcmp(s.agents[0].full,"Full explanation in the reader."));
surface_tick(60000); scene_take(); assert(result_visible()); // no timed dismissal
ui_project_emit("b","session-b","summary","Another agent's result.","Updated the website.");
scene_take(); assert(result_visible() && s.active==0);
bool recipient_above=false;
for(int i=0;i<scene.count;i++) {
const ht_run_t *r=&scene.runs[i];
if(!strcmp(r->text,"Deploy latest firmware")) {
assert(r->arc==1);
recipient_above=true;
}
}
assert(recipient_above);
tap(61000,233,310); // The same central tap starts voice over a summary.
assert(!desktop_opens && starts==1 && s.view==VOICE && !result_visible());
scene_take(); portrait(dir,"summary-listening");
bool large=false;
for(int i=0;i<scene.count;i++) if(scene.runs[i].font->height>=10 && scene.runs[i].font->height<=12 && strlen(scene.runs[i].text)>=50)large=true;
assert(large);
dispatch((action_t){.kind=A_VOICE_ABORT}); scene_take(); assert(result_visible());
ui_project_restore_event("a","summary","Full explanation in the reader.","Fixed the parser. All tests pass.");
scene_take(); assert(result_visible()); // Recording never dismisses the result.
ui_project_emit("a","session-a","summary","Full explanation in the reader.","Fixed the parser. All tests pass.");
scene_take(); assert(result_visible());
tap(61600,233,150); // The small portrait has its own target above the summary.
assert(starts==2 && !strcmp(target,"a") && s.view==VOICE && !result_visible());
portrait(dir,"completed-listening");
tap(62600,233,220); assert(stops==1);
dispatch((action_t){.kind=A_VOICE_ABORT}); scene_take(); assert(result_visible());
ui_project_emit("a","session-a","processing",NULL,NULL);
scene_take(); assert(!result_visible()); portrait(dir,"next-turn");
ui_project_restore_event("a","summary","Old restored answer.","Old restored recap.");
scene_take(); assert(!result_visible() && s.agents[0].busy);
assert(!strcmp(s.agents[0].preview,"Fixed the parser. All tests pass."));
ui_project_emit("a","session-a","done",NULL,NULL);
scene_take(); assert(!result_visible()); // Done alone cannot resurrect the previous turn.
ui_project_restore_event("a","summary","Fixed the parser. All tests pass.","Fixed the parser. All tests pass.");
scene_take(); assert(!result_visible());
ui_project_emit("a","session-a","summary","Patched the voice handler.","Patched the voice handler.");
scene_take(); assert(result_visible());
waiting_count=1; scene_take(); assert(result_visible()); portrait(dir,"completed-attention");
waiting_count=0; s.connected=false; scene_take(); assert(!result_visible());
s.connected=true; s.loading=true; scene_take(); assert(!result_visible());
s.loading=false; s.nap=true; scene_take(); assert(!result_visible());
s.nap=false; carry.active=true; scene_take(); assert(!result_visible());
carry.active=false; scene_take(); assert(result_visible());
// Scrolling and switching work across the smaller portrait and outcome.
habitat_touch(true,233,310,63000); habitat_touch(true,233,250,63050);
habitat_touch(false,233,250,63100); assert(moves && starts==2);
s.coasting=false; s.coast_until=0;
habitat_touch(true,320,220,64000); habitat_touch(false,150,220,64120);
scene_take(); assert(switches==1 && s.active==1 && result_visible());
assert(!strcmp(s.agents[1].preview,"Updated the website."));
ui_project_clear_event("b"); scene_take(); assert(!result_visible());
ui_project_restore_event("b","summary","Cached completion.","Cached completion.");
scene_take(); assert(result_visible());
ui_project_emit("b",NULL,"summary"," \n",NULL); scene_take(); assert(result_visible());
// A recap gesture remains pinned and cannot open a different pane on release.
reset(); ui_project_emit("a","session-a","summary","Fixed.","Fixed."); scene_take();
habitat_touch(true,233,285,65000); s.active=1; input_cancel();
habitat_touch(false,233,285,65100); assert(!desktop_opens && !starts);
// Reading motion still scrolls; returning to its origin never opens or talks.
reset(); ui_project_emit("a","session-a","summary","Fixed.","Fixed."); scene_take();
habitat_touch(true,233,285,66000); habitat_touch(true,233,225,66040);
habitat_touch(true,233,285,66080); habitat_touch(false,233,285,66120);
assert(moves && !desktop_opens && !starts);
reset();
}
static void notice_checks(const char *dir) {
// Opening a read notification must not present its recap a second time.
// Exercise either receipt order, panes outside the current roster, and a
// notification restored before that pane's result history has arrived.
for(int off_tab=0;off_tab<2;off_tab++) for(int cached=0;cached<2;cached++)
for(int seen_first=0;seen_first<2;seen_first++) {
reset();
const char *id=off_tab ? "outside" : "a";
const char *result="The build is installed. All checks passed.";
if(cached) ui_project_emit(id,"session","summary",result,result);
ui_notify_task_done(id,"Build","M2",result);
ui_notify_task_done("b","Another pane","M2","The website is ready.");
ui_notif_open(); s.offset=1; scene_take();
tap(1000,233,340);
assert(desktop_opens==1 && !strcmp(opened_agent,id));
assert(s.notice_count==2 && s.view==INBOX); // wait for host acknowledgement
ui_apply_pending_focus();
assert(s.view==INBOX); // a periodic roster refresh is not an open receipt
if(seen_first) ui_notif_seen(id);
else ui_focus_project(id);
if(off_tab) {
assert(find(id)<0); // opening never fabricates a local roster row
ui_project_set_name(id,"Build");
ui_apply_pending_focus();
}
if(seen_first) ui_focus_project(id);
else ui_notif_seen(id);
scene_take();
assert(active() && !strcmp(active()->id,id) && s.view==HOME);
assert(s.notice_count==1 && !result_visible() && !starts && !question_sends);
// History fills the reader, while the already-read recap stays hidden.
ui_project_restore_event(id,"summary",result,result);
scene_take(); assert(!result_visible() && !strcmp(active()->full,result));
ui_project_remove(id); ui_project_set_name(id,"Build"); ui_focus_project(id);
ui_project_restore_event(id,"summary",result,result);
scene_take(); assert(!result_visible());
if(!off_tab && cached && !seen_first) portrait(dir,"notification-opened");
ui_project_emit(id,"session","processing","Working",NULL);
ui_project_emit(id,"session","done",NULL,NULL);
ui_project_emit(id,"session","summary","The next change is ready.","The next change is ready.");
scene_take(); assert(result_visible());
}
// A refused local queue keeps the result/card available; viewing still clears its bell count.
reset();
ui_project_emit("a","session","summary","The build is ready.","The build is ready.");
ui_notify_task_done("a","Build","M2","The build is ready.");
ui_notif_open(); congestion=true;
dispatch((action_t){.kind=A_NOTICE,.id="a"});
assert(!desktop_opens && !s.pending_focus[0] && !s.opening_notice[0] && s.notice_count==1);
assert(s.agents[0].recap_ready && !pane_memory("a",false)->dismissed);
// Reading a question is never an approval or a completed-result dismissal.
reset();
ui_project_emit("a","session","summary","The previous build is ready.","The previous build is ready.");
cable_notif_t pending_question={.agent_id="a",.name="Build",.question=true,
.summary="May I deploy this build?"};
ui_notif_replace(&pending_question,1); ui_notif_open();
dispatch((action_t){.kind=A_NOTICE,.id="a"}); ui_notif_seen("a");
assert(desktop_opens==1 && !question_sends && s.notice_count==1);
assert(!pane_memory("a",false)->dismissed);
// Desktop navigation without an Open gesture changes the recipient, but
// keeps the inbox on the card being read, including an off-tab focus.
reset();
ui_notify_task_done("a","Build","M2","The build is installed.");
ui_notify_task_done("b","Website","M2","The site is deployed.");
ui_notif_open();
ui_focus_project("outside"); ui_project_set_name("outside","Other tab");
ui_apply_pending_focus(); assert(s.view==INBOX && s.notice_count==2);
// Back cancels the pending inbox landing, even if a delayed receipt arrives
// after the user has reopened the inbox to read another message.
reset();
ui_notify_task_done("a","Build","M2","The build is installed.");
ui_notify_task_done("b","Website","M2","The site is deployed.");
ui_notif_open(); dispatch((action_t){.kind=A_NOTICE,.id="a"});
view(HOME); assert(!s.opening_notice[0]);
ui_notif_open(); ui_focus_project("a"); assert(s.view==INBOX);
const char *recaps[]={
"It isn't external.",
"Yes. The fix is installed.",
"Fixed the parser. All tests pass. Voice input now sends to the selected agent.",
"Yes. The fix is installed and the device has reconnected successfully to the +",
"A much longer recap from an older host needs to fit three rows, with the same continuation as the home result.",
"“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.",
"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();
ui_project_emit("a","session-a","summary",recaps[i],recaps[i]);
scene_take();
for(int j=0;j<scene.count;j++) {
const ht_run_t *r=&scene.runs[j];
assert(r->font!=&ht_nav_32 && r->font!=&ht_open_20);
if(r->font->height<=6 && strlen(r->text)>=32)
assert(r->font->height==4 && r->y+r->font->height<=HT_CHARACTER_READING_TEXT_Y);
}
if(i==6) portrait(dir,"photo-summary-dials");
if(i==7) portrait(dir,"photo-summary-board");
if(i==8) {
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();
int icons=0;
for(int j=0;j<scene.count;j++) {
const ht_run_t *r=&scene.runs[j];
assert(!r->arc && !r->shimmer && r->font->height>=28); // no creature or home arc
if(r->font==&ht_nav_32) {
assert(r->x==223 && r->y==400 && !strcmp(r->text,"\xe2\x86\x90"));
assert(ht_can_display(r->text,r->font,r->w,1)); icons++;
}
if(r->font==&ht_mono_28 && r->text[0])
assert(r->y>=72 && r->y+r->font->height<=382);
}
assert(icons==1); // Only Back; the full message opens the pane.
// The inbox keeps its own reading layout and the same source message.
assert(!strcmp(s.notice[0].summary,s.agents[0].preview));
assert(s.view==INBOX && s.notice_count==1 && !desktop_opens && !starts);
if(i==2) portrait(dir,"notification-preview");
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.
}
reset();
ui_notify_task_done("a","Deploy latest firmware","M2","Yes. The fix is installed.");
ui_notify_task_done("b","Website","M2","The new page is live.");
ui_notif_open(); scene_take(); portrait(dir,"notification-multiple");
habitat_touch(true,300,260,2000); habitat_touch(true,170,260,2060);
habitat_touch(false,170,260,2120); scene_take();
assert(s.offset==1 && s.notice_count==2 && !desktop_opens && !starts);
habitat_touch(true,233,275,2500); habitat_touch(true,233,190,2560);
habitat_touch(false,233,190,2620); scene_take();
assert(s.offset==0 && s.notice_count==2 && !desktop_opens && !moves && !starts);
tap(3000,233,250); assert(desktop_opens==1 && !strcmp(opened_agent,"b"));
reset();
cable_notif_t question={.agent_id="off-tab",.name="Release",.question=true,
.summary="Should I deploy this build to staging?"};
ui_notif_replace(&question,1); ui_notif_open(); scene_take();
bool question_shown=false;
for(int i=0;i<scene.count;i++) if(strstr(scene.runs[i].text,"Should I deploy"))question_shown=true;
assert(question_shown && s.notice_count==1 && !question_sends);
assert(inbox_mark_is("?", color(HT_THEME_QUESTION)));
portrait(dir,"notification-question");
s.connected=false; scene_take(); assert(!action_enabled(A_NOTICE));
portrait(dir,"inbox-offline");
tap(3500,233,260); assert(s.view==INBOX && !desktop_opens && !question_sends && !starts);
tap(3700,233,415); assert(s.view==HOME && !desktop_opens && !question_sends && !starts);
s.connected=true; ui_notif_open(); scene_take();
habitat_touch(true,233,260,3900); scene_take(); portrait(dir,"inbox-open-pressed");
habitat_touch(false,233,260,3975); scene_take();
assert(desktop_opens==1 && !strcmp(opened_agent,"off-tab") && !starts);
reset(); ui_notify_task_done("a","No saved recap","M2",NULL); ui_notif_open(); scene_take();
bool fallback=false;
for(int i=0;i<scene.count;i++) if(!strcmp(scene.runs[i].text,"No preview available."))fallback=true;
assert(fallback); portrait(dir,"notification-missing");
reset();
}
static uint32_t soak_random(uint32_t *state) {
*state ^= *state << 13; *state ^= *state >> 17; *state ^= *state << 5;
return *state;
}
static void pane_notification_soak(void) {
// Long mixed histories exercise cache eviction and list reconciliation,
// including contacts held across host updates and both 32-bit wraps.
// Everything uses local production handlers; no desktop or audio I/O.
reset(); s.memory_serial=UINT32_MAX-100;
uint32_t seed=0x48a6197u; fake_ms=UINT32_MAX-300000;
unsigned operations[12]={0},contacts=0,rasters=0;
static uint16_t pixels[HT_WIDTH*HT_HEIGHT];
for(unsigned step=0;step<200000;step++) {
uint32_t r=soak_random(&seed);
char id[ID_MAX],name[80],result[260];
snprintf(id,sizeof id,"soak-%03u",(r>>8)%256);
snprintf(name,sizeof name,"Pane %u / turn %u",(r>>8)%256,step);
snprintf(result,sizeof result,"Turn %u is complete. The parser handles the next result after a notification has been opened.",step);
fake_ms+=17;
bool held=s.view==INBOX && s.notice_count && (r&31)==0;
if(held) { scene_take(); habitat_touch(true,233,250,fake_ms); contacts++; }
unsigned op=r%12; operations[op]++;
switch(op) {
case 0: ui_project_set_name(id,name); break;
case 1: ui_project_remove(id); break;
case 2: ui_project_emit(id,"soak-session","processing","Working",NULL); break;
case 3: ui_project_emit(id,"soak-session","summary",result,result); break;
case 4: ui_project_restore_event(id,"summary",result,result); break;
case 5: ui_notify_task_done(id,name,"M2",result); break;
case 6: ui_notif_seen(id); break;
case 7: ui_notif_open(); break;
case 8: ui_focus_project(id); ui_apply_pending_focus(); break;
case 9: {
cable_notif_t rows[NOTICES]={0};
int count=(r>>16)%(NOTICES+1);
for(int i=0;i<count;i++) {
snprintf(rows[i].agent_id,sizeof rows[i].agent_id,"soak-%03u",((r>>8)+i)%256);
COPY(rows[i].name,name); COPY(rows[i].summary,result);
rows[i].question=(i%5)==0;
}
ui_notif_replace(rows,count); break;
}
case 10:
if(s.view==INBOX && s.notice_count) {
action_t a={.kind=A_NOTICE}; COPY(a.id,s.notice[s.offset].agent_id);
congestion=(r&256)!=0; dispatch(a); congestion=false;
}
break;
case 11:
if(r&256) view(HOME);
else ui_project_clear_all();
break;
}
if(held) habitat_touch(false,233,250,fake_ms+75);
assert(s.count>=0 && s.count<=MAX_PROJECTS);
assert(s.active>=-1 && s.active<s.count);
assert(s.notice_count>=0 && s.notice_count<=NOTICES);
if(s.view==INBOX) assert(s.notice_count && s.offset>=0 && s.offset<s.notice_count);
for(int i=0;i<s.notice_count;i++) {
assert(s.notice[i].agent_id[0] && memchr(s.notice[i].agent_id,0,ID_MAX));
assert(memchr(s.notice[i].summary,0,sizeof s.notice[i].summary));
for(int j=0;j<i;j++) assert(strcmp(s.notice[i].agent_id,s.notice[j].agent_id));
}
if((step&255)==0) {
for(int i=0;i<PANE_MEMORY_MAX;i++) {
const pane_memory_t *m=&s.memory[i];
assert(memchr(m->id,0,sizeof m->id));
assert(memchr(m->preview,0,sizeof m->preview));
assert(memchr(m->full,0,sizeof m->full));
if(m->id[0]) for(int j=0;j<i;j++) assert(strcmp(m->id,s.memory[j].id));
}
scene_take(); assert(scene.count<=HT_RUNS && s.hit_count<=24);
}
if((step&4095)==0) {
ht_raster(&scene,(ht_rect_t){0,0,HT_WIDTH,HT_HEIGHT},pixels); rasters++;
}
assert(!starts && !question_sends); // inbox activity cannot start a mic/answer
}
for(unsigned i=0;i<12;i++) assert(operations[i]>10000);
assert(contacts>100);
printf("Pane/inbox soak: 200000 mixed updates, 256 identities, %u held contacts, %u full rasters, cache/time wraps; bounds/identity/modal invariants PASS\n",contacts,rasters);
reset();
}
static void pane_memory_checks(const char *dir) {
// The reported failure: leave mobile's tab, receive its completion while
// absent, then return without any history replay from the bridge.
reset();
ui_project_emit("a","mobile-session","processing","Coalescing...",NULL);
ui_project_remove("a"); assert(find("a")==-1);
ui_project_emit("a","mobile-session","done",NULL,NULL);
ui_project_emit("a","mobile-session","summary","The mobile build is installed. All checks passed.","The mobile build is installed. All checks passed.");
assert(find("a")==-1 && !starts && !desktop_opens); // background data never adds a visible pane
ui_project_set_name("a","Mobile app build and deploy"); s.active=find("a"); scene_take();
assert(result_visible() && !active()->busy && !strcmp(active()->preview,"The mobile build is installed. All checks passed."));
portrait(dir,"mobile-restored");
ui_project_remove("a"); ui_project_set_name("a","Mobile app build and deploy");
s.active=find("a"); scene_take(); assert(result_visible());
// Starting the next turn returns to the large companion and hides old prose.
ui_project_emit("a","mobile-session","processing","Coalescing...",NULL); scene_take();
assert(!result_visible() && active()->busy && !strcmp(active()->tool,"Coalescing"));
bool caption=false;
for(int i=0;i<scene.count;i++) if(!strcmp(scene.runs[i].text,"Last result"))caption=true;
assert(!caption); portrait(dir,"mobile-working");
s.notice_count=2; scene_take(); portrait(dir,"working-notifications-activity");
fake_ms+=3400; surface_tick(fake_ms); scene_take();
bool footer=false;
for(int i=0;i<scene.count;i++) if(strstr(scene.runs[i].text,"Coalescing")) {
assert(scene.runs[i].arc==1 && scene.runs[i].fg==FG); footer=true;
}
assert(footer); s.notice_count=0;
scene_take(); footer=false;
for(int i=0;i<scene.count;i++) if(strstr(scene.runs[i].text,"Coalescing")) {
assert(scene.runs[i].arc==1 && scene.runs[i].fg==FG); footer=true;
}
assert(footer);
ui_project_emit("a",NULL,"processing","Processing",NULL);
assert(!strcmp(active()->tool,"Coalescing")); // heartbeat never flashes a replacement label
ui_project_remove("a"); ui_project_emit("a","mobile-session","activity","Summarizing...",NULL);
ui_project_set_name("a","Mobile app build and deploy"); s.active=find("a"); scene_take();
assert(!result_visible() && active()->busy && !strcmp(active()->tool,"Summarizing"));
ui_project_restore_event("a","summary","An older result.","An older result.");
assert(!strcmp(active()->preview,"The mobile build is installed. All checks passed."));
ui_project_emit("a","mobile-session","done",NULL,NULL); scene_take(); assert(!result_visible());
ui_project_emit("a","mobile-session","summary","The next build is installed.","The next build is installed.");
assert(!strcmp(active()->preview,"The next build is installed."));
scene_take(); assert(result_visible() && !active()->busy); portrait(dir,"next-result");
// History arriving before the roster is safe too, without a notification.
ui_project_clear_all(); ui_project_restore_event("history","summary","Saved result.","Saved result.");
assert(!s.count && !s.notice_count);
ui_project_set_name("history","History"); s.active=find("history"); scene_take(); assert(result_visible());
ui_project_clear_event("history"); ui_project_remove("history"); ui_project_set_name("history","History");
s.active=find("history"); scene_take(); assert(!result_visible());
// Bounded cache: current panes stay pinned; old off-tab slots are evicted.
reset(); ui_project_emit("a",NULL,"summary","Pinned.","Pinned.");
ui_project_emit("b",NULL,"summary","Also pinned.","Also pinned.");
for(int i=0;i<PANE_MEMORY_MAX+40;i++) {
char id[64]; snprintf(id,sizeof id,"background-%d",i);
ui_project_emit(id,NULL,"summary","Background result.","Background result.");
}
assert(pane_memory("a",false) && pane_memory("b",false) && !pane_memory("background-0",false));
ui_project_remove("a"); ui_project_set_name("a","Pinned"); s.active=find("a"); scene_take();
assert(result_visible() && !strcmp(active()->preview,"Pinned."));
s.memory_serial=UINT32_MAX;
ui_project_emit("wrap",NULL,"summary","Wrap-safe.","Wrap-safe.");
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(""));
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"));
s.straight_title=false;
ui_project_emit("a",NULL,"activity","Coalescing...",NULL); scene_take();
assert(title_is("Coalescing") && !title_is("Working"));
// A native footer disappearing must not erase the known busy state.
ui_project_emit("a",NULL,"activity","",NULL); scene_take();
assert(!active()->tool[0] && title_is("Working"));
s.notice_count=2; scene_take(); assert(title_is("Working") && !title_is("[2] Working"));
s.notice_count=0; ui_project_emit("a",NULL,"done",NULL,NULL); scene_take();
assert(!active()->busy && !title_is("Working"));
// A late activity read cannot bring the completed status back.
ui_project_emit("a",NULL,"activity","Coalescing",NULL); scene_take();
assert(!title_is("Working") && !title_is("Coalescing"));
ui_project_emit("a",NULL,"processing","Processing",NULL); scene_take();
fake_ms+=3400; surface_tick(fake_ms); scene_take();
assert(!active()->tool[0] && title_is("Working"));
s.nap=true; scene_take(); assert(!title_is("Working")); s.nap=false;
s.connected=false; scene_take(); assert(scene.count==1 && !strcmp(scene.runs[0].text,"Harness")); s.connected=true;
ui_project_emit("a",NULL,"activity","Working",NULL);
strcpy(active()->name,"hn"); scene_take(); portrait(dir,"short-name-working");
strcpy(active()->name,"firmware v2");
strcpy(active()->tool,"Messages to be submitted after");
scene_take(); portrait(dir,"photo-long-status");
strcpy(active()->tool,"Working");
home_caption.initialized=false; fake_ms=0; scene_take();
for (int frame=0;frame<32;frame++) {
fake_ms=3240+frame*64; surface_tick(fake_ms); scene_take();
int shimmer=0;
for(int i=0;i<scene.count;i++) if(scene.runs[i].shimmer) {
assert(scene.runs[i].arc==1 && !strcmp(scene.runs[i].text,"Working")); shimmer++;
}
assert(shimmer==1);
char label[40]; snprintf(label,sizeof label,"working-shimmer-%02d",frame); portrait(dir,label);
}
s.quiet=true; surface_tick(fake_ms); scene_take();
for(int i=0;i<scene.count;i++) assert(!scene.runs[i].shimmer);
s.quiet=false;
ui_project_remove("a"); pane_memory_t *m=pane_memory("a",false); assert(m);
m->last_busy=ms()-26000; ui_project_set_name("a","Expired busy");
assert(!s.agents[find("a")].busy); scene_take(); assert(!title_is("Working"));
reset(); strcpy(active()->name,"Mobile app build and deploy");
ui_project_emit("a",NULL,"processing","Coalescing",NULL); scene_take();
tap(2000,233,41); assert(s.view==AGENTS && !starts); // top caption always picks panes
reset(); ui_project_emit("a",NULL,"summary","The result is ready.","The result is ready.");
scene_take(); tap(3000,233,280); scene_take(); assert(!result_visible() && !desktop_opens && starts==1);
dispatch((action_t){.kind=A_VOICE_ABORT}); scene_take(); assert(result_visible());
ui_project_remove("a"); ui_project_set_name("a","Return to pane"); s.active=find("a");
ui_project_restore_event("a","summary","The result is ready.","The result is ready.");
ui_project_emit("a",NULL,"processing","Processing",NULL);
scene_take(); assert(!result_visible());
ui_project_emit("a",NULL,"summary","A new result is ready.","A new result is ready.");
scene_take(); assert(result_visible());
printf("pane memory: PASS (off-tab completion, returning panes, late restores, live activity, alternating work/results, 128-slot bound); %zu bytes\n",sizeof s.memory);
reset();
}
static void bell_checks(const char *dir) {
static const int points[][2]={{233,399},{100,408},{150,430},{315,415},{370,405},{233,450}};
assert(ht_can_display(HT_BELL " 32", &ht_mono_28, 68, 1));
reset(); scene_take();
bool found=false;
for(int i=0;i<scene.count;i++) if(!strcmp(scene.runs[i].text,HT_BELL)) {
assert(false); // An empty inbox has no bell run.
found=true;
}
assert(!found && !action_enabled(A_INBOX));
// Identity stays available over USB, while its permanent name never takes
// the notification footer. Even a brief milestone yields to a new bell.
desktop_companion=HT_CHARACTER_ILLUSTRATED_TIM;
strcpy(desktop_identity.name,"tim #0001"); scene_take();
for(int i=0;i<scene.count;i++) assert(!strstr(scene.runs[i].text,"tim #0001"));
companion_celebrating=true; strcpy(celebration_label,"Tim grew!");
cable_notif_t during_growth={.agent_id="b",.name="Other pane",.summary="Ready."};
ui_notif_replace(&during_growth,1); scene_take();
assert(status_is(HT_BELL " 1") && action_enabled(A_INBOX));
for(int i=0;i<scene.count;i++) assert(!strstr(scene.runs[i].text,"grew!"));
companion_celebrating=false; desktop_companion=HT_CHARACTER_COUNT;
memset(&desktop_identity,0,sizeof desktop_identity);
reset();
// 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,
.summary="The deployment failed. Check the terminal for details."};
ui_notif_replace(&failed,1); ui_notif_open(); scene_take();
assert(inbox_mark_is(HT_FAILED, color(HT_THEME_FAILED)));
portrait(dir,"notification-failed");
failed.question=true; ui_notif_replace(&failed,1); scene_take();
assert(inbox_mark_is("?", color(HT_THEME_QUESTION)));
ui_notify_task_done("b","Website","M2","The site is deployed."); scene_take();
assert(inbox_mark_is(HT_DONE, color(HT_THEME_DONE)));
for(int i=0;i<scene.count;i++) assert(!strstr(scene.runs[i].text,"----"));
reset(); scene_take();
portrait(dir,"bell-empty");
for(unsigned i=0;i<sizeof points/sizeof points[0];i++) {
reset(); tap(1000,points[i][0],points[i][1]);
assert(s.view==HOME && !starts && !desktop_opens && !switches);
cable_notif_t n={.agent_id="b",.name="Other pane",.summary="The update is ready. All checks pass."};
ui_notif_replace(&n,1); scene_take();
assert(status_is(HT_BELL " 1") && action_enabled(A_INBOX));
for(int j=0;j<scene.count;j++) if(scene.runs[j].font->height<=6)
assert(scene.runs[j].bg==BG); // no reverse-video envelope on either character
tap(2000,points[i][0],points[i][1]);
assert(s.view==INBOX && !starts && !desktop_opens);
for(int j=0;j<scene.count;j++) assert(!scene.runs[j].arc && scene.runs[j].font->height>=28);
tap(3000,233,100); // The pane title, like its message, opens that pane.
assert(desktop_opens==1 && !strcmp(opened_agent,"b") && !starts);
}
reset(); ui_notify_task_done("b","Other pane","M2","Finished."); scene_take();
habitat_touch(true,233,420,1000); ui_notif_seen("b"); scene_take();
habitat_touch(false,233,420,1080); assert(s.view==HOME && !starts && !desktop_opens);
reset(); habitat_touch(true,233,420,1000);
ui_notify_task_done("b","Other pane","M2","Finished."); scene_take();
habitat_touch(false,233,420,1080); assert(s.view==HOME && !starts && !desktop_opens);
scene_take(); portrait(dir,"bell-unread");
tap(2000,233,220); assert(s.view==VOICE && starts==1); scene_take();
assert(!status_is(HT_BELL " 1"));
dispatch((action_t){.kind=A_VOICE_ABORT}); scene_take(); assert(status_is(HT_BELL " 1"));
reset(); active()->busy=true; scene_take();
fake_ms=3400;surface_tick(fake_ms);scene_take();assert(title_is("Working"));
ui_notify_task_done("b","Other pane","M2","Finished.");scene_take();
assert(title_is("Working") && status_is(HT_BELL " 1"));
fake_ms=6400;surface_tick(fake_ms);scene_take();assert(title_is(active()->name));
portrait(dir,"bell-working-name");
fake_ms=9400;surface_tick(fake_ms);scene_take();assert(title_is("Working"));
portrait(dir,"bell-working-activity");
tap(10000,233,41);assert(s.view==AGENTS && !starts && !desktop_opens);
reset(); active()->busy=true;
memset(active()->name,'x',HT_ARC_COLS);active()->name[HT_ARC_COLS]=0;scene_take();
fake_ms=2800;surface_tick(fake_ms);scene_take();
int end_x=233+(205*arc_trig[HT_ARC_COLS-1][0]>>14),end_y=233-(205*arc_trig[HT_ARC_COLS-1][1]>>14);
habitat_touch(true,end_x,end_y,2800);fake_ms=3100;surface_tick(fake_ms);scene_take();
assert(title_is(active()->name)); // Rotation cannot shrink a held caption target.
habitat_touch(false,end_x,end_y,3150);assert(s.view==AGENTS && !starts && !desktop_opens);
puts("bell/inbox: empty/active glyphs, wide separate targets, arrivals/removal during contact, title/message open, no creature, voice restoration, caption rotation PASS");
reset();
}
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(NULL) && !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(NULL));
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(NULL)==1);
ui_notif_read("a","turn-1"); assert(notice_unread(NULL)==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(NULL) && 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(NULL)==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}};
reset(); ui_notif_replace(rows,2); scene_take();
// Two unread, but the bell counts one: "a" is the agent on the face, and its news is already
// on the glass. Counting it too read as something happening elsewhere.
assert(notice_unread(NULL)==2 && notice_unread("a")==1 && status_is(HT_BELL " 1"));
ui_notif_open(); assert(s.notice[s.offset].question);
present_scene=false; scene_take(); uint32_t frame=habitat_scene_receipt();
assert(frame && notice_unread(NULL)==2); // Constructing a frame is not reading it.
fake_asleep=true; habitat_scene_presented(frame); assert(notice_unread(NULL)==2);
fake_asleep=false; habitat_scene_presented(frame); habitat_scene_presented(frame);
assert(notice_unread(NULL)==1 && s.view==INBOX && s.notice_count==2 && s.notice[s.offset].question);
assert(!question_sends && !desktop_opens && !starts);
// The one left unread is "a"'s own, and "a" is on the face: no bell at all.
present_scene=true; view(HOME); scene_take(); assert(!status_is(HT_BELL " 1") && !notice_unread("a"));
ui_notif_open(); assert(!strcmp(s.notice[s.offset].agent_id,"a")); scene_take();
assert(!notice_unread(NULL) && s.notice_count==2 && s.view==INBOX);
portrait(dir,"inbox-read-stays");
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(NULL) && status_is("")); // Late/reconnect snapshot stays read.
strcpy(rows[0].summary,"The next build is ready.");
ui_notif_replace(rows,2); assert(notice_unread(NULL)==1);
ui_notif_open(); scene_take(); assert(!notice_unread(NULL));
// A new live result, even with identical words, is a new unread message.
ui_notify_task_done("a","Build","M2",rows[0].summary);
assert(notice_unread(NULL)==1);
present_scene=false; scene_take(); frame=habitat_scene_receipt();
ui_notify_task_done("a","Build","M2",rows[0].summary);
habitat_scene_presented(frame); assert(notice_unread(NULL)==1); // Old DMA, new same-text result.
scene_take(); frame=habitat_scene_receipt();
view(HOME); habitat_scene_presented(frame); assert(notice_unread(NULL)==1);
ui_notif_open(); scene_take(); frame=habitat_scene_receipt();
cable_notif_t newer={.agent_id="a",.name="Build",.summary="This message replaced the old frame."};
ui_notif_replace(&newer,1); habitat_scene_presented(frame); assert(notice_unread(NULL)==1);
scene_take(); frame=habitat_scene_receipt();
ui_notif_seen("a"); habitat_scene_presented(frame); assert(!notice_unread(NULL) && s.view==HOME);
ui_notif_replace(&newer,1); assert(!notice_unread(NULL));
newer.failed=true; ui_notif_replace(&newer,1); assert(notice_unread(NULL)==1);
s.notice_revision=UINT32_MAX; ui_notif_replace(&newer,1);
ui_notif_open(); scene_take(); assert(habitat_scene_receipt()!=0);
// Open clears the bell even before a display receipt and even if the local
// focus queue refuses it. A queue failure must never pretend to open a pane.
congestion=true; dispatch((action_t){.kind=A_NOTICE,.id="a"});
assert(!notice_unread(NULL) && !desktop_opens && !question_sends && !starts);
congestion=false; present_scene=true; view(HOME); ui_notif_open(); scene_take();
tap(2000,233,250); assert(!notice_unread(NULL) && desktop_opens==1 && !strcmp(opened_agent,"a"));
// Bounded read history reuses a slot for the same pane and remains safe as
// more than a full inbox's distinct identities are read.
reset();
for(int i=0;i<NOTICES*3;i++) {
char id[ID_MAX]; snprintf(id,sizeof id,"read-%d",i);
ui_notify_task_done(id,"Build","M2","Finished.");
ui_notif_open(); scene_take(); assert(!notice_unread(NULL));
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, hidden empty bell, reconnect snapshots and bounded receipt history PASS");
// NOTIFICATION TIERS: only an alert beeps, wakes and celebrates; a list entry is a drawer row and
// nothing else; silent leaves no row. The pane on the face never beeps or wakes and its row is read.
reset(); fake_ms=5000; wakes=0;
assert(ui_notify_summary("b","B","M2","Built.","alert",false,false) && s.notice_count==1 && wakes==1 && s.pet_pose==3);
reset(); fake_ms=5000; wakes=0;
assert(!ui_notify_summary("b","B","M2","Built.","list",true,false) && s.notice_count==1 && !wakes && !s.pet_pose);
reset(); fake_ms=5000; wakes=0; fake_asleep=true;
assert(!ui_notify_summary("b","B","M2","Built.","list",true,false) && s.notice_count==1 && !wakes && fake_asleep);
reset(); fake_ms=5000; wakes=0;
assert(!ui_notify_summary("b","B","M2","Built.","silent",false,true) && !s.notice_count && !wakes && !s.pet_pose);
// An old daemon sends no tier: quiet is a list entry (it used to beep), silent is silent, neither is an alert.
reset(); fake_ms=5000; wakes=0;
assert(!ui_notify_summary("b","B","M2","x",NULL,true,false) && s.notice_count==1 && !wakes);
assert(!ui_notify_summary("c","C","M2","x",NULL,false,true) && s.notice_count==1);
assert(!ui_notify_summary("c","C","M2","x",NULL,true,true) && s.notice_count==1);
assert(!ui_notify_summary("c","C","M2","x","bogus",true,false) && s.notice_count==2);
assert(ui_notify_summary("d","D","M2","x",NULL,false,false) && s.notice_count==3 && wakes==1);
// One row per agent: the newest wins.
assert(ui_notify_summary("d","D","M2","newer","alert",false,false) && s.notice_count==3 && !strcmp(s.notice[0].summary,"newer"));
// On the face: no beep, no wake, no celebration, and the row is read at once.
reset(); fake_ms=5000; wakes=0;
assert(!ui_notify_summary("a","A","M2","Done.","alert",false,false) && !wakes && !s.pet_pose);
assert(s.notice_count==1 && s.notice[0].read_on_dial && !notice_unread(NULL));
// Rows expire 6 h after receipt, across the millisecond wrap too, but a question never does.
for (int w = 0; w < 2; w++) {
reset(); fake_ms = w ? UINT32_MAX - 1000 : 1000;
ui_notify_summary("b","B","M2","Old.","list",false,false);
cable_notif_t pinned={.agent_id="q",.name="Q",.summary="Which?",.question=true};
ui_notif_replace(&pinned,1); ui_notify_summary("b","B","M2","Old.","list",false,false);
assert(s.notice_count==2);
uint32_t t0 = fake_ms;
fake_ms = t0 + 21599999u; surface_tick(fake_ms); assert(s.notice_count==2);
fake_ms = t0 + 21600000u; surface_tick(fake_ms); assert(s.notice_count==1 && s.notice[0].question);
}
// A failed turn: the full-screen error clears itself after 8 s; the drawer row stays.
reset(); fake_ms=9000; wakes=0;
assert(ui_turn_error("b","The build crashed.") && s.view==MESSAGE && wakes==1);
assert(s.notice_count==1 && s.notice[0].failed && !s.notice[0].read_on_dial);
fake_ms=16999; surface_tick(fake_ms); assert(s.view==MESSAGE);
fake_ms=17000; surface_tick(fake_ms); assert(s.view==HOME && s.notice_count==1);
reset(); fake_ms=9000; wakes=0;
assert(!ui_turn_error("a","The build crashed.") && s.view==MESSAGE && !wakes && s.notice[0].read_on_dial);
// The person's own question is never covered: the row is filed, the screen stays.
reset(); fake_ms=9000; s.view=QUESTION; wakes=0;
assert(ui_turn_error("b","The build crashed.") && s.view==QUESTION && !s.error_until && s.notice_count==1 && s.notice[0].failed);
s.view=CHOICE; ui_turn_error("c","Also broke."); assert(s.view==CHOICE);
s.view=ANSWER_REVIEW; ui_turn_error("d","Also broke."); assert(s.view==ANSWER_REVIEW);
// A different message replacing the error view must not inherit its 8 s timer.
reset(); fake_ms=9000; ui_turn_error("b","The build crashed.");
fake_ms=14000; view(MESSAGE); fake_ms=17000; surface_tick(fake_ms); assert(s.view==MESSAGE);
// An empty failure still says something.
reset(); fake_ms=9000; ui_turn_error("b","");
assert(!strcmp(s.notice[0].summary,"The turn failed") && !strcmp(s.message,"The turn failed"));
ui_turn_error("c",NULL); assert(!strcmp(s.message,"The turn failed"));
puts("Notification tiers: alert/list/silent, old-daemon flags, face, one row per agent, 6 h expiry and 8 s error 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();
snprintf(s.tabs[1].name,sizeof s.tabs[1].name,"%s","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, bounds, clipped movement and exact partial redraw PASS");
reset();
}
/*
* THE SWARMS (docs/superpowers/specs/2026-10-23-round-swarm-tab-design.md). Three Swarms: "openharness", open on the
* desktop as desk tab t1 (which counts no agents), and "studio" and "playground", which the desktop has not opened.
* openharness's Leads arrive in the daemon's urgency order and carry their project order.
*/
static ht_supertab_t card;
static void card_begin(const char *id, const char *tab, const char *name) { assert(ht_supertab_init(&card, id, tab, name, 0)); }
static void card_lead(const char *id, const char *project, const char *engine, const char *local, const char *state, int order, long since) {
ht_lead_in_t in = {.id = id, .project = project, .engine = engine, .local = local, .state = state, .order = order, .since = since};
assert(ht_supertab_lead_add(&card, &in));
}
static bool card_send(void) { card.count = card.lead_n; return ui_supertab(&card); }
static void openharness_card(void) {
card_begin("s1", "t1", "openharness");
card_lead("L2", "docs", "claude", "h2", "ask", 2, -1);
card_lead("L3", "firmware", "codex", "h3", "stuck", 3, -1);
card_lead("L0", "mobile", "claude", "h0", "work", 0, 134);
card_lead("L4", "backend", "cursor", "", "work", 4, -1);
card_lead("L1", "Round dial firmware release candidate", "claude", "h1", "done", 1, -1);
}
// The desktop's three tabs, the window open on "Harness repo".
static void desk_open(void) {
static cable_swarm_t rows[3];
memset(rows, 0, sizeof rows);
COPY(rows[0].id, "t0"); COPY(rows[0].name, "Harness repo"); rows[0].agents = 1;
COPY(rows[1].id, "t1"); COPY(rows[1].name, "openharness"); rows[1].agents = 0;
COPY(rows[2].id, "t2"); COPY(rows[2].name, "Research"); rows[2].agents = 1;
ui_swarms_replace(rows, 3, "t0");
}
static void swarm_setup(void) {
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); fake_ms = 100000;
desk_open();
const char ids[3][ID_MAX] = {"s1", "s3", "s2"};
ui_supertabs_ids(ids, 3);
openharness_card(); card_send();
card_begin("s2", "", "playground"); card_lead("P0", "sandbox", "claude", "h9", "work", 0, 12); card_send();
card_begin("s3", "", "studio"); card_lead("K0", "sketches", "claude", "", "done", 0, -1);
card_lead("K1", "renders", "codex", "h7", "work", 1, 40); card_send();
swarm_sent = 0; scene_take();
}
static const ht_run_t *big_run(void) {
for (int i = 0; i < scene.count; i++) if (scene.runs[i].font == &ht_lv_inter_44.base && scene.runs[i].text[0]) return &scene.runs[i];
return NULL;
}
static void tabs_at(int index) { dispatch((action_t){.kind = A_TABS}); ht_tab_carousel_reset(&tab_carousel, tabs_total(), index); scene_take(); }
static void swarm_tabs_checks(const char *dir) {
// TABS is the desktop's tabs and nothing else, with or without a window (Diego, 2026-10-27). The desktop opens every
// Super Tab its owner has not closed, so a Swarm without a desk tab is one closed there ("PR merge" closed and still
// on the dial).
swarm_setup();
assert(tabs_total() == 3 && tab_index_of("s2") < 0 && tab_index_of("s3") < 0);
{
// Desk tabs [A, S linked], Swarms [S, X, Y]: exactly A and S.
reset(); static cable_swarm_t rows[2]; memset(rows, 0, sizeof rows);
COPY(rows[0].id, "t0"); COPY(rows[0].name, "Harness repo"); rows[0].agents = 1;
COPY(rows[1].id, "t1"); COPY(rows[1].name, "openharness"); rows[1].agents = 0;
ui_swarms_replace(rows, 2, "t0");
const char ids[3][ID_MAX] = {"s1", "s3", "s2"}; ui_supertabs_ids(ids, 3);
openharness_card(); card_send(); card_begin("s2", "", "playground"); card_send(); card_begin("s3", "", "studio"); card_send();
assert(tabs_total() == 2 && !strcmp(tab_id_at(0), "t0") && !strcmp(tab_id_at(1), "t1"));
assert(!strcmp(tab_label(0), "Harness repo") && !strcmp(tab_label(1), "openharness") && tab_index_of("s1") == 1);
// The S desk tab closed: the next `swarms` frame drops S.
ui_swarms_replace(rows, 1, "t0");
assert(tabs_total() == 1 && tab_index_of("s1") < 0);
// No window: no desk tab, so nothing is listed, not X, not Y.
ui_swarms_replace(NULL, 0, NULL);
assert(tabs_total() == 0 && tab_index_of("s1") < 0 && tab_index_of("s2") < 0 && tab_index_of("s3") < 0);
}
{
// The dial in openharness when its desk tab closes on the desktop: it leaves the Swarm (saying so) for TABS,
// on the app's current tab. A `swarms` frame that keeps the desk tab keeps the dial in.
static cable_swarm_t rows[2]; memset(rows, 0, sizeof rows);
COPY(rows[0].id, "t0"); COPY(rows[0].name, "Harness repo"); rows[0].agents = 1;
COPY(rows[1].id, "t2"); COPY(rows[1].name, "Research"); rows[1].agents = 1;
swarm_setup(); tabs_at(1); dispatch((action_t){.kind = A_TAB_DONE}); assert(swarm_mode() && !strcmp(sw.tab, "s1"));
desk_open(); assert(swarm_mode() && s.view == HOME);
swarm_sent = 0; ui_swarms_replace(rows, 2, "t2");
assert(!swarm_mode() && s.view == TABS && ht_tab_carousel_index(&tab_carousel) == 1 && !strcmp(tab_id_at(1), "t2"));
assert(swarm_sent == 1 && !strcmp(swarm_wire[0], "open s1 "));
// No window at all: the same, onto the empty list.
swarm_setup(); tabs_at(1); dispatch((action_t){.kind = A_TAB_DONE}); assert(swarm_mode());
ui_swarms_replace(NULL, 0, NULL); assert(!swarm_mode() && s.view == TABS && tabs_total() == 0);
// A Swarm entered from the inbox with no desk tab is not one the desktop closed: `swarms` frames leave it be.
swarm_setup(); swarm_enter(ht_supertabs_find(&swarm, "s2"), "P0", true); scene_take();
desk_open(); ui_swarms_replace(rows, 2, "t2"); ui_swarms_replace(NULL, 0, NULL);
assert(swarm_mode() && !strcmp(sw.tab, "s2") && s.view == HOME);
}
// A desk tab linked to a Swarm keeps its place and name, listed with no agents; it was hidden before the link came.
swarm_setup();
assert(s.tab_count == 3 && !strcmp(s.tabs[1].id, "t1") && !strcmp(s.tabs[1].name, "openharness"));
{
reset(); static cable_swarm_t rows[2]; memset(rows, 0, sizeof rows);
COPY(rows[0].id, "t0"); rows[0].agents = 1; COPY(rows[1].id, "t1"); rows[1].agents = 0;
ui_swarms_replace(rows, 2, "t0"); assert(s.tab_count == 1);
const char ids[1][ID_MAX] = {"s1"}; ui_supertabs_ids(ids, 1); openharness_card(); card_send();
assert(s.tab_count == 2 && !strcmp(s.tabs[1].id, "t1"));
}
// Decision 1: a Swarm's page is drawn as any tab's. The centred name of the linked "openharness" and of the desk tab
// "Research" share font and ink.
swarm_setup();
tabs_at(2); const ht_run_t desk = *big_run();
tabs_at(1); const ht_run_t linked = *big_run();
assert(!strcmp(linked.text, "openharness") && linked.font == desk.font && linked.fg == desk.fg && linked.bg == desk.bg);
// 1a in "Harness repo", openharness at the right edge; 1b dragging; 1c on openharness.
swarm_setup(); tabs_at(0); FOCUS_PAGE("swarm-tabs-1a");
tab_carousel.position = HT_TAB_PITCH / 2; FOCUS_PAGE("swarm-tabs-1b");
tabs_at(1); assert(!strcmp(big_run()->text, "openharness")); FOCUS_PAGE("swarm-tabs-1c");
// A tap on the Swarm's name enters it: no workspace handshake, no switching view, then select and open for its
// first Lead by order ("mobile").
int switched = tab_switches;
tap(5000, 233, 233);
assert(s.view == HOME && swarm_mode() && !strcmp(sw.tab, "s1") && !strcmp(sw.lead, "L0"));
assert(tab_switches == switched && workspace.phase == HT_WORKSPACE_IDLE && !s.loading);
assert(swarm_sent == 3 && !strcmp(swarm_wire[0], "select s1 L0") && !strcmp(swarm_wire[1], "open s1 L0") &&
!strcmp(swarm_wire[2], "recap.get s1 L0"));
// Done on a Swarm the desktop last showed at a Lead opens on that Lead.
swarm_leave(); ui_supertab_focus("s1", "L3"); assert(!swarm_mode());
tabs_at(1); swarm_sent = 0; dispatch((action_t){.kind = A_TAB_DONE});
assert(!strcmp(sw.tab, "s1") && !strcmp(sw.lead, "L3") && s.view == HOME && tab_switches == switched);
assert(!strcmp(swarm_wire[0], "select s1 L3") && !strcmp(swarm_wire[1], "open s1 L3"));
// Hold on a Swarm's face opens TABS on that Swarm.
s.view = HOME; scene_take();
habitat_touch(true, 233, 230, 9000); habitat_touch(true, 233, 230, 9700);
assert(s.view == TABS && ht_tab_carousel_index(&tab_carousel) == 1 && !starts);
habitat_touch(false, 233, 230, 9800);
// An ordinary desk tab still takes the workspace handshake, and leaving the Swarm says so.
swarm_sent = 0; ht_tab_carousel_reset(&tab_carousel, tabs_total(), 2); scene_take();
dispatch((action_t){.kind = A_TAB_DONE});
assert(!swarm_mode() && !strcmp(tab_target, "t2") && tab_switches > switched && !strcmp(swarm_wire[0], "open s1 "));
puts("Swarm tabs: exactly the desk tabs (closed Swarms never listed, with or without a window), closing the face's desk tab leaves the Swarm, linked desk tab kept with no agents, same font and ink, entered with no handshake, remembered Lead, hold to TABS, desk tabs unchanged PASS");
}
// Every run's text joined, and the first sprite (the pet's frame): what a face says and which pose it holds.
static bool scene_says(const char *needle) {
for (int i = 0; i < scene.count; i++) if (strstr(scene.runs[i].text, needle)) return true;
return false;
}
static const void *pet_frame(void) {
for (int i = 0; i < scene.count; i++) if (scene.runs[i].sprite.width) return scene.runs[i].sprite.cells;
return NULL;
}
// The frames the pet cycles through over six seconds: a pose is its loop, not one instant of it.
static int pet_frames(const void *out[64]) {
int n = 0; uint32_t base = fake_ms;
for (uint32_t t = 0; t < 6000; t += 20) {
fake_ms = base + t; scene_take(); const void *f = pet_frame(); bool seen = false;
for (int i = 0; i < n; i++) seen |= out[i] == f;
if (!seen && n < 64) out[n++] = f;
}
fake_ms = base; scene_take();
return n;
}
static int card_lines(const char **last) {
int n = 0;
for (int i = 0; i < scene.count; i++) if (scene.runs[i].font == &ht_lv_inter_30.base && scene.runs[i].text[0]) { n++; *last = scene.runs[i].text; }
return n;
}
static bool wire_has(int from, const char *line) {
for (int i = from; i < swarm_sent; i++) if (!strcmp(swarm_wire[i], line)) return true;
return false;
}
static void enter_at(const char *tab, const char *lead) {
swarm_enter(ht_supertabs_find(&swarm, tab), lead, true); scene_take();
}
static void no_red(void) {
for (int i = 0; i < scene.count; i++) assert(scene.runs[i].fg != ERROR && scene.runs[i].box.fill != ERROR);
}
static void swarm_pane_checks(const char *dir) {
// openharness's Leads come in urgency order and are kept in project order.
swarm_setup(); const ht_supertab_t *t = ht_supertabs_find(&swarm, "s1");
assert(t->lead_n == 5 && !strcmp(t->leads[0].id, "L0") && !strcmp(t->leads[1].id, "L1") && !strcmp(t->leads[2].id, "L2") &&
!strcmp(t->leads[3].id, "L3") && !strcmp(t->leads[4].id, "L4"));
// 2a "mobile" working on this computer: the time since `since` on the lower arc, the project on the upper.
enter_at("s1", "L0"); assert(title_is("mobile") && scene_says("2:14"));
FOCUS_PAGE("swarm-2a");
fake_ms += 6000; scene_take(); assert(scene_says("2:20")); // the dial's own clock carries it on
// 2b a long name, done: the recap card. A recap for another Lead is dropped.
enter_at("s1", "L1");
ui_supertab_recap("s1", "L2", "", "", "Not this one.", 1792560000u, false); scene_take(); assert(!scene_says("Not this one."));
ui_supertab_recap("s1", "L1", "", "", "Release candidate built and checked on both dials.", 1792560000u, false); scene_take();
assert(scene_says("Release candidate built"));
FOCUS_PAGE("swarm-2b");
// 2g a 1,500-byte recap: four lines, the last ending in "…".
{
char longer[HT_SUPERTAB_TEXT]; size_t n = 0;
while (n + 6 < sizeof longer - 1) { memcpy(longer + n, "words ", 6); n += 6; }
longer[n] = 0;
ui_supertab_recap("s1", "L1", "", "", longer, 1792560000u, false); scene_take();
const char *last = ""; int lines = card_lines(&last);
assert(lines >= 1 && lines <= 4 && strstr(last, "\xe2\x80\xa6"));
FOCUS_PAGE("swarm-2g");
}
// 2f no message yet: the resting face, no card.
ui_supertab_recap("s1", "L1", "", "", "", 0, true); scene_take();
{ const char *last; assert(!card_lines(&last)); }
// With nothing unread the bell leaves the lower arc to the resting face's one line, as in the mockup.
for (int i = 0; i < s.notice_count; i++) notice_mark_read(&s.notice[i]);
scene_take(); { bool line = false; for (int i = 0; i < scene.count; i++) line |= scene.runs[i].arc == 2 && scene.runs[i].text[0]; assert(line); }
FOCUS_PAGE("swarm-2f");
// 2c "docs" needs you, here: its wait's question takes the recap's place, in the asking pose.
enter_at("s1", "L2");
ui_supertab_recap("s1", "L2", "", "", "Docs drafted.", 1792560000u, false);
assert(!ui_supertab_wait("h2", "supertab:w1", "openharness", false, "Publish the docs today?")); // on the face: no beep
scene_take(); assert(scene_says("Publish the docs") && !scene_says("Docs drafted."));
FOCUS_PAGE("swarm-2c");
// 2d "firmware" stuck: the daemon's "Stuck: …" in the same card, and no red anywhere.
enter_at("s1", "L3");
ui_supertab_wait("h3", "supertab:w2", "openharness", true, "Stuck: the release key is missing."); scene_take();
assert(scene_says("Stuck: the release key")); no_red();
FOCUS_PAGE("swarm-2d");
// The asking pose: Codex's asking loop, not the finished one it shows once the same Lead is done with a message.
{
static const void *asking[64], *done[64]; int asking_n = pet_frames(asking);
card_begin("s1", "t1", "openharness"); openharness_card(); card.leads[1].state = HT_LEAD_DONE; // L3, firmware
assert(!strcmp(card.leads[1].id, "L3")); card_send(); ui_supertab_wait_close("h3", "supertab:w2");
ui_supertab_recap("s1", "L3", "", "", "Release key found; build signed.", 1792560000u, false);
int done_n = pet_frames(done); bool other = false;
for (int i = 0; i < asking_n; i++) { bool shared = false; for (int k = 0; k < done_n; k++) shared |= asking[i] == done[k]; other |= !shared; }
assert(asking_n && done_n && other);
openharness_card(); card_send();
}
// 2e "backend" on someone else's machine, working: "Working…" and no time. A tap on the face talks to it by its Swarm
// id, to a daemon that posts such words in its chat (Diego's dial, 2026-10-29); to an older one, to nobody.
enter_at("s1", "L4"); assert(title_is("backend") && scene_says("Working") && !scene_says(":"));
FOCUS_PAGE("swarm-2e");
// (the real dispatch drops a face voice turn with no recipient: test_voice_ui.py)
assert(!make_action((hit_t){.action = A_VOICE}).id[0]);
{ uint32_t was = host_features; host_features |= CABLE_FEATURE_SWARM_REMOTE;
assert(!strcmp(make_action((hit_t){.action = A_VOICE}).id, "L4")); host_features = was; }
enter_at("s1", "L0"); assert(!strcmp(make_action((hit_t){.action = A_VOICE}).id, "h0"));
tap(fake_ms, 233, 260); assert(!strcmp(target, "h0")); dispatch((action_t){.kind = A_VOICE_ABORT});
enter_at("s1", "L4");
// 2e' the same Lead asking: the asking pose and its last message, read-only.
card_begin("s1", "t1", "openharness");
card_lead("L0", "mobile", "claude", "h0", "work", 0, 134); card_lead("L1", "Round dial firmware release candidate", "claude", "h1", "done", 1, -1);
card_lead("L2", "docs", "claude", "h2", "ask", 2, -1); card_lead("L3", "firmware", "codex", "h3", "stuck", 3, -1);
card_lead("L4", "backend", "cursor", "", "ask", 4, -1); card_send();
ui_supertab_recap("s1", "L4", "", "", "Need a decision on the cache size.", 1792560000u, false); scene_take();
assert(scene_says("Need a decision") && !scene_says("Working"));
FOCUS_PAGE("swarm-2e-ask");
// 2h a Swarm with no projects: PANES' own empty page, and "Choose a tab" goes to TABS.
{
const char ids[4][ID_MAX] = {"s1", "s3", "s2", "s4"}; ui_supertabs_ids(ids, 4);
card_begin("s4", "", "empty"); card_send();
enter_at("s4", NULL); assert(scene_says("No panes in") && scene_says("this tab.") && scene_says("Choose a tab"));
FOCUS_PAGE("swarm-2h");
tap(fake_ms, 233, 365); assert(s.view == TABS);
}
// A swipe moves by order, wrapping, and says select, open and recap.get — never `focus` (no pane switch).
swarm_setup(); enter_at("s1", "L4"); swarm_sent = 0; int panes = switches;
habitat_touch(true, 320, 220, fake_ms); habitat_touch(false, 150, 220, fake_ms + 120); scene_take();
assert(!strcmp(sw.lead, "L0") && switches == panes);
assert(swarm_sent == 3 && !strcmp(swarm_wire[0], "select s1 L0") && !strcmp(swarm_wire[1], "open s1 L0") &&
!strcmp(swarm_wire[2], "recap.get s1 L0"));
habitat_touch(true, 150, 220, fake_ms + 1000); habitat_touch(false, 320, 220, fake_ms + 1120); scene_take();
assert(!strcmp(sw.lead, "L4") && switches == panes);
// No recap within 5 s: one more recap.get, and only one.
swarm_sent = 0; surface_tick(fake_ms + 4999); assert(!swarm_sent);
surface_tick(fake_ms + 5000); assert(swarm_sent == 1 && !strcmp(swarm_wire[0], "recap.get s1 L4"));
surface_tick(fake_ms + 11000); assert(swarm_sent == 1);
// A swipe on a Swarm of one project lands on the project already on the face: nothing happens. It used to empty
// the recap for 5 s and pick the project again, which reopened its Lead chat on the desktop (Diego, 2026-10-29).
swarm_setup(); enter_at("s2", "P0");
ui_supertab_recap("s2", "P0", "", "", "Sandbox rebuilt.", 1792560000u, false); scene_take();
assert(swarm.recap.state == HT_RECAP_LOADED); swarm_sent = 0;
habitat_touch(true, 320, 220, fake_ms); habitat_touch(false, 150, 220, fake_ms + 120); scene_take();
habitat_touch(true, 150, 220, fake_ms + 1000); habitat_touch(false, 320, 220, fake_ms + 1120); scene_take();
assert(!strcmp(sw.lead, "P0") && swarm.recap.state == HT_RECAP_LOADED && !strcmp(swarm.recap.text, "Sandbox rebuilt."));
assert(!swarm_sent);
// Two projects still move, both ways.
enter_at("s3", "K0"); swarm_sent = 0;
habitat_touch(true, 320, 220, fake_ms + 2000); habitat_touch(false, 150, 220, fake_ms + 2120);
assert(!strcmp(sw.lead, "K1") && swarm_sent == 3 && !strcmp(swarm_wire[0], "select s3 K1"));
habitat_touch(true, 320, 220, fake_ms + 3000); habitat_touch(false, 150, 220, fake_ms + 3120);
assert(!strcmp(sw.lead, "K0") && swarm_sent == 6 && !strcmp(swarm_wire[3], "select s3 K0"));
// PANES (tap the name): one page per Lead in order, opened on the one on the face; a long name on two lines with
// "…"; Done picks with the swipe's messages.
swarm_setup(); enter_at("s1", "L2"); tap(fake_ms, 233, 30);
assert(s.view == AGENTS && pane_carousel.count == 5 && ht_tab_carousel_index(&pane_carousel) == 2 && !strcmp(big_run()->text, "docs"));
FOCUS_PAGE("swarm-3a");
for (int i = 0; i < 5; i++) assert(!strcmp(pane_label(i), ht_supertabs_find(&swarm, "s1")->leads[i].project));
ht_tab_carousel_reset(&pane_carousel, 5, 1); scene_take();
{
int big = 0; bool cut = false;
for (int i = 0; i < scene.count; i++) if (scene.runs[i].font == &ht_lv_inter_44.base && scene.runs[i].text[0]) {
big++; size_t n = strlen(scene.runs[i].text); cut |= n > 3 && !strcmp(scene.runs[i].text + n - 3, "\xe2\x80\xa6");
}
assert(big == 2 && cut);
}
FOCUS_PAGE("swarm-3b");
swarm_sent = 0; tap(fake_ms + 2000, 233, 420);
assert(s.view == HOME && !strcmp(sw.lead, "L1") && wire_has(0, "select s1 L1") && wire_has(0, "open s1 L1") && wire_has(0, "recap.get s1 L1"));
// Twelve projects, twelve pages, the last one picked.
{
card_begin("s1", "t1", "openharness");
static const char *names[12] = {"mobile", "web", "docs", "firmware", "backend", "api", "infra", "design", "ops", "data", "growth", "support"};
char id[8];
for (int i = 0; i < 12; i++) { snprintf(id, sizeof id, "M%d", i); card_lead(id, names[i], i % 2 ? "codex" : "claude", "", "work", i, -1); }
card_send(); enter_at("s1", "M0"); tap(fake_ms, 233, 30);
assert(s.view == AGENTS && pane_carousel.count == 12);
ht_tab_carousel_reset(&pane_carousel, 12, 5); FOCUS_PAGE("swarm-3c");
ht_tab_carousel_reset(&pane_carousel, 12, 11); scene_take();
dispatch((action_t){.kind = A_LEAD, .id = "M11"}); assert(s.view == HOME && !strcmp(sw.lead, "M11") && sw.at == 11);
}
// Following the desktop: supertab.focus moves the face (no select back), but not while talking.
swarm_setup(); enter_at("s1", "L0"); swarm_sent = 0;
ui_supertab_focus("s1", "L3"); assert(!strcmp(sw.lead, "L3") && !wire_has(0, "select s1 L3") && wire_has(0, "open s1 L3"));
s.voice_open = true; ui_supertab_focus("s1", "L1"); assert(!strcmp(sw.lead, "L3")); s.voice_open = false;
// The desktop opening the Swarm's desk tab takes the dial in with it.
swarm_leave(); COPY(s.selected_tab, "t1"); s.view = HOME; ui_supertab_focus("s1", "L2");
assert(swarm_mode() && !strcmp(sw.tab, "s1") && !strcmp(sw.lead, "L2"));
// A new card without the Lead on the face: the face takes the Lead now at its place.
ui_supertab_focus("s1", "L3"); assert(sw.at == 3);
card_begin("s1", "t1", "openharness");
card_lead("L0", "mobile", "claude", "h0", "work", 0, 134); card_lead("L1", "Round dial firmware release candidate", "claude", "h1", "done", 1, -1);
card_lead("L2", "docs", "claude", "h2", "ask", 2, -1); card_lead("L4", "backend", "cursor", "", "work", 4, -1); card_send();
assert(!strcmp(sw.lead, "L4") && sw.at == 3);
// The Swarm gone from the list: back to TABS.
{ const char ids[2][ID_MAX] = {"s3", "s2"}; ui_supertabs_ids(ids, 2); }
assert(!swarm_mode() && s.view == TABS);
// Diego's dial, 2026-10-29: after a reconnect the list came empty, then whole 2 s later. The Swarm on the face comes
// back on the Lead it showed, with no pick sent, and the TABS the dial opened by itself switched no desk tab meanwhile.
{
const char none[1][ID_MAX] = {""}, ids[3][ID_MAX] = {"s1", "s3", "s2"};
swarm_setup(); enter_at("s1", "L2"); s.view = HOME; swarm_sent = 0; int switched = tab_switches;
ui_supertabs_ids(none, 0); assert(!swarm_mode() && s.view == TABS);
int plain = tab_index_of("t2"); assert(plain >= 0 && !tab_swarm(plain));
ht_tab_carousel_reset(&tab_carousel, tabs_total(), plain); tabs_sync(); assert(tab_switches == switched);
fake_ms += 2000; ui_supertabs_ids(ids, 3); openharness_card(); card_send();
assert(swarm_mode() && !strcmp(sw.tab, "s1") && !strcmp(sw.lead, "L2") && s.view == HOME);
ui_supertab_focus("s1", "L2"); assert(!strcmp(sw.lead, "L2") && s.view == HOME);
assert(!wire_has(0, "select s1 L2") && tab_switches == switched);
// The focus alone brings it back too, when it comes before the card.
ui_supertabs_ids(none, 0); assert(s.view == TABS);
ui_supertabs_ids(ids, 3); openharness_card(); ht_supertabs_put(&swarm, &card, ms(), NULL, 0);
ui_supertab_focus("s1", "L2"); assert(swarm_mode() && !strcmp(sw.lead, "L2") && s.view == HOME);
// A Swarm that really went (the list came back without it), back later: TABS stays, and the person's touch browses as before.
{ const char others[2][ID_MAX] = {"s3", "s2"}; ui_supertabs_ids(others, 2); }
assert(!swarm_mode() && s.view == TABS);
ui_supertabs_ids(ids, 3); openharness_card(); card_send();
assert(!swarm_mode() && s.view == TABS);
habitat_touch(true, 233, 233, fake_ms);
ht_tab_carousel_reset(&tab_carousel, tabs_total(), tab_index_of("t2")); tabs_sync(); assert(tab_switches == switched + 1);
habitat_touch_cancel();
// The person on TABS already, browsing: a Swarm coming back does not pull the dial off it.
swarm_setup(); enter_at("s1", "L2"); s.view = HOME;
ui_supertabs_ids(none, 0); habitat_touch(true, 233, 233, fake_ms); habitat_touch_cancel();
ui_supertabs_ids(ids, 3); openharness_card(); card_send(); assert(!swarm_mode() && s.view == TABS);
// The person touched TABS, chose a plain tab with Done and went HOME: the Swarm back within 10 s stays off the face.
swarm_setup(); enter_at("s1", "L2"); s.view = HOME;
ui_supertabs_ids(none, 0); habitat_touch(true, 233, 233, fake_ms); habitat_touch_cancel();
ht_tab_carousel_reset(&tab_carousel, tabs_total(), tab_index_of("t2")); dispatch((action_t){.kind = A_TAB_DONE});
dispatch((action_t){.kind = A_HOME}); assert(s.view == HOME);
fake_ms += 2000; ui_supertabs_ids(ids, 3); openharness_card(); card_send();
ui_supertab_focus("s1", "L2"); assert(!swarm_mode() && s.view == HOME);
}
// Diego's dial, 2026-10-28: the window on a Swarm tab with no project open (its Chat with PM, a DM) names no Lead.
// The dial still goes into that Swarm, on the Lead the desktop last showed there, else the first by order; a dial
// already in it keeps its face.
swarm_setup(); COPY(s.selected_tab, "t1"); s.view = HOME; ui_supertab_focus("s1", "");
assert(swarm_mode() && !strcmp(sw.tab, "s1") && !strcmp(sw.lead, "L0") && !wire_has(0, "select s1 L0"));
ui_supertab_focus("s1", "L2"); ui_supertab_focus("s1", ""); assert(!strcmp(sw.lead, "L2"));
swarm_leave(); ui_supertab_focus("s1", ""); assert(swarm_mode() && !strcmp(sw.lead, "L2"));
swarm_leave(); s.voice_open = true; ui_supertab_focus("s1", ""); assert(!swarm_mode()); s.voice_open = false;
// A focus that arrives just before the `swarms` frame that selects its desk tab enters when that frame lands…
{
swarm_setup(); s.view = HOME; ui_supertab_focus("s1", "L2"); assert(!swarm_mode());
cable_swarm_t rows[3]; memcpy(rows, desk_rows, sizeof rows);
ui_swarms_replace(rows, 3, "t1"); assert(swarm_mode() && !strcmp(sw.tab, "s1") && !strcmp(sw.lead, "L2"));
// …once: leaving and coming back to the tab by itself does not replay it.
swarm_leave(); ui_swarms_replace(rows, 3, "t0"); ui_swarms_replace(rows, 3, "t1"); assert(!swarm_mode());
// One with no Lead waits the same way.
ui_swarms_replace(rows, 3, "t0"); ui_supertab_focus("s1", ""); assert(!swarm_mode());
ui_swarms_replace(rows, 3, "t1"); assert(swarm_mode() && !strcmp(sw.lead, "L2"));
// The window going to another tab first spends it.
swarm_leave(); ui_swarms_replace(rows, 3, "t0"); ui_supertab_focus("s1", "L3");
ui_swarms_replace(rows, 3, "t2"); ui_swarms_replace(rows, 3, "t1"); assert(!swarm_mode());
// Diego's dial, 2026-10-29: the window leaving the Swarm's desk tab for another takes the dial out with it,
// onto that tab's panes. It used to stay on the Swarm face until its desk tab was closed.
ui_swarms_replace(rows, 3, "t0"); ui_supertab_focus("s1", "L2"); ui_swarms_replace(rows, 3, "t1");
assert(swarm_mode() && !strcmp(sw.desk, "t1"));
s.view = AGENTS; ui_swarms_replace(rows, 3, "t0"); assert(!swarm_mode() && s.view == HOME);
// Not while talking or answering: the face keeps its recipient, as a focus does.
ui_supertab_focus("s1", "L2"); ui_swarms_replace(rows, 3, "t1"); assert(swarm_mode());
s.voice_open = true; ui_swarms_replace(rows, 3, "t0"); assert(swarm_mode()); s.voice_open = false;
swarm_leave(); ui_supertab_focus("s1", "L2"); ui_swarms_replace(rows, 3, "t1"); assert(swarm_mode());
s.view = QUESTION; ui_swarms_replace(rows, 3, "t0"); assert(swarm_mode());
// A frame that keeps the same tab, or names none, leaves the face alone.
s.view = HOME; swarm_leave(); ui_supertab_focus("s1", "L2"); ui_swarms_replace(rows, 3, "t1");
ui_swarms_replace(rows, 3, "t1"); assert(swarm_mode()); ui_swarms_replace(rows, 3, ""); assert(swarm_mode());
// Only from the Swarm's own desk tab: a frame still naming another tab, just after the dial's own pick and before
// the desktop moved, keeps the face (review of #2204).
swarm_leave(); ui_swarms_replace(rows, 3, "t0"); enter_at("s1", "L2");
assert(swarm_mode() && !strcmp(sw.desk, "t1") && !strcmp(s.selected_tab, "t0"));
ui_swarms_replace(rows, 3, "t2"); assert(swarm_mode() && !strcmp(sw.tab, "s1"));
ui_swarms_replace(rows, 3, "t1"); assert(swarm_mode() && !strcmp(sw.tab, "s1"));
// The desktop from one Swarm's desk tab to another's: its focus comes first, then the frame, and the dial ends on
// that Swarm's face, not on a plain HOME.
card_begin("s2", "t2", "playground"); card_lead("P0", "sandbox", "claude", "h9", "work", 0, 12); card_send();
ui_supertab_focus("s2", "P0"); assert(!strcmp(sw.tab, "s1"));
ui_swarms_replace(rows, 3, "t2"); assert(swarm_mode() && !strcmp(sw.tab, "s2") && !strcmp(sw.lead, "P0"));
}
// The side button: STOP for a busy Lead on this computer (its harness id), HOME for a remote one.
swarm_setup(); enter_at("s1", "L0"); ui_boot_pressed(); assert(s.view == STOP && !strcmp(s.stop_agent, "h0"));
dispatch((action_t){.kind = A_STOP_YES}); assert(!strcmp(stopped_agent, "h0") && s.view == HOME);
s.stop_agent[0] = 0; enter_at("s1", "L4"); ui_boot_pressed(); assert(s.view == HOME && !s.stop_agent[0]);
puts("Swarm panes: project order, faces 2a-2h (time, recap card and cut, resting, wait text, stuck without red, remote read-only), swipe with wrap and no focus, one recap retry, PANES 3a-3c, follow the desktop, Lead gone, Swarm gone, side button PASS");
}
// The dial's own entry for a Lead, its index in the inbox, or -1.
static int swarm_entry(const char *lead) {
for (int i = 0; i < s.notice_count; i++) if (s.notice[i].swarm && !strcmp(s.notice[i].agent_id, lead)) return i;
return -1;
}
static void inbox_at(const char *lead) {
ui_notif_open(); s.offset = swarm_entry(lead); assert(s.offset >= 0); scene_take();
}
// One run's ink and face, by its text.
static const ht_run_t *run_of(const char *text) {
for (int i = 0; i < scene.count; i++) if (!strcmp(scene.runs[i].text, text)) return &scene.runs[i];
return NULL;
}
// openharness with every Lead working, so a test raises exactly the Leads it means to.
static void calm_card(const char *backend, const char *docs) {
card_begin("s1", "t1", "openharness");
card_lead("L0", "mobile", "claude", "h0", "work", 0, 134); card_lead("L1", "Round dial firmware release candidate", "claude", "h1", "done", 1, -1);
card_lead("L2", "docs", "claude", "h2", docs, 2, -1); card_lead("L3", "firmware", "codex", "h3", "work", 3, -1);
card_lead("L4", "backend", "cursor", "", backend, 4, -1);
}
static void swarm_inbox_checks(const char *dir) {
// The fixture's card raised docs (ask) and firmware (stuck), each once, with the approved fixed lines.
swarm_setup();
assert(swarm_entry("L2") >= 0 && swarm_entry("L3") >= 0 && swarm_entry("L0") < 0 && swarm_entry("L4") < 0);
assert(!strcmp(s.notice[swarm_entry("L2")].summary, "Needs you. Answer on the desktop."));
assert(!strcmp(s.notice[swarm_entry("L3")].summary, "Stuck. See the desktop."));
assert(s.notice[swarm_entry("L2")].question && s.notice[swarm_entry("L2")].swarm == 1 && s.notice[swarm_entry("L3")].swarm == 2);
// 4e a Lead on someone else's machine, done/work -> ask: one entry and one beep; the Swarm's name grey, the
// project green. Asking again raises nothing; stuck changes the line and beeps; back to work removes it.
calm_card("work", "ask"); assert(!card_send());
calm_card("ask", "ask"); assert(card_send());
int e = swarm_entry("L4"); assert(e >= 0 && !strcmp(s.notice[e].summary, "Needs you. Answer on the desktop."));
calm_card("ask", "ask"); assert(!card_send());
inbox_at("L4");
{
const ht_run_t *grey = run_of("openharness"), *green = run_of("backend");
assert(grey && grey->font == &ht_lv_inter_25.base && grey->fg == color(0x8a8a99));
assert(green && green->font == &ht_lv_inter_25.base && green->fg == color(0x04fe08));
assert(scene_says("Needs you."));
}
FOCUS_PAGE("swarm-4e");
calm_card("stuck", "ask"); assert(card_send());
assert(!strcmp(s.notice[swarm_entry("L4")].summary, "Stuck. See the desktop."));
calm_card("work", "ask"); assert(!card_send()); assert(swarm_entry("L4") < 0);
// 4c, 4d the local Leads' waits: their questions take the fixed lines' place, with no second beep.
swarm_setup();
assert(!ui_supertab_wait("h2", "supertab:w1", "openharness", false, "Publish the docs today?"));
assert(!ui_supertab_wait("h3", "supertab:w2", "openharness", true, "Stuck: the release key is missing."));
assert(!strcmp(s.notice[swarm_entry("L2")].summary, "Publish the docs today?"));
assert(!strcmp(s.notice[swarm_entry("L3")].summary, "Stuck: the release key is missing."));
// A Super Tab wait never opens the question screen, whatever the dial shows.
assert(s.view == HOME);
{ cable_notif_t desk = {.agent_id = "a", .name = "Payments refactor", .machine = "MacBook", .summary = "Hero and pricing are in."};
ui_notif_replace(&desk, 1); }
inbox_at("L2"); assert(scene_says("Publish the docs") && run_of("openharness") && run_of("docs"));
FOCUS_PAGE("swarm-4c");
inbox_at("L3"); assert(scene_says("Stuck: the release key"));
FOCUS_PAGE("swarm-4d");
// question.close: the fixed line again while the Lead still asks, and no beep.
ui_supertab_wait_close("h2", "supertab:other"); assert(!strcmp(s.notice[swarm_entry("L2")].summary, "Publish the docs today?"));
ui_supertab_wait_close("h2", "supertab:w1"); assert(!strcmp(s.notice[swarm_entry("L2")].summary, "Needs you. Answer on the desktop."));
// The wait first, then the Lead's state: one entry, one beep. The state first, then the wait: the same.
{
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); fake_ms = 100000;
const char ids[1][ID_MAX] = {"s1"}; ui_supertabs_ids(ids, 1);
calm_card("work", "work"); assert(!card_send());
int before = s.notice_count;
assert(ui_supertab_wait("h2", "supertab:w1", "openharness", false, "Publish the docs today?")); // the wait beeps
calm_card("work", "ask"); assert(!card_send()); // the state does not
assert(s.notice_count == before + 1 && !strcmp(s.notice[swarm_entry("L2")].summary, "Publish the docs today?"));
calm_card("work", "ask"); assert(!card_send());
ui_supertab_wait_close("h2", "supertab:w1"); calm_card("work", "work"); assert(!card_send()); assert(swarm_entry("L2") < 0);
calm_card("work", "ask"); assert(card_send());
assert(!ui_supertab_wait("h2", "supertab:w3", "openharness", false, "Ship it?"));
int count = 0; for (int i = 0; i < s.notice_count; i++) count += !strcmp(s.notice[i].agent_id, "L2");
assert(count == 1 && !strcmp(s.notice[swarm_entry("L2")].summary, "Ship it?"));
}
// A wait from a harness that is no Lead's: nothing.
{ int before = s.notice_count; assert(!ui_supertab_wait("h99", "supertab:w9", "openharness", false, "Worker question"));
assert(s.notice_count == before && !scene_says("Worker question")); }
// The desktop's snapshot replaces its own rows only: every Swarm entry stays, after it and before it.
swarm_setup();
{ cable_notif_t desk[2] = {{.agent_id = "a", .name = "Payments refactor", .summary = "Shipped."}, {.agent_id = "b", .name = "Agent B", .summary = "Done."}};
ui_notif_replace(desk, 2); assert(swarm_entry("L2") >= 0 && swarm_entry("L3") >= 0 && s.notice_count == 4);
ui_notif_replace(desk, 0); assert(swarm_entry("L2") >= 0 && swarm_entry("L3") >= 0 && s.notice_count == 2); }
// An entry for the Lead on the face is read at once, with no beep.
swarm_setup(); enter_at("s1", "L4");
calm_card("ask", "ask"); assert(!card_send()); assert(swarm_entry("L4") >= 0 && s.notice[swarm_entry("L4")].read_on_dial);
// 4a in a desk tab, the bell pill at y 400 counts the Swarm entries; 4b on a working Clawd, its bubble instead.
swarm_setup(); scene_take();
{ bool pill = false; for (int i = 0; i < scene.count; i++) pill |= scene.runs[i].box.h == 32 && scene.runs[i].y == 400;
assert(pill && action_enabled(A_INBOX) && run_of("2")); }
FOCUS_PAGE("swarm-4a");
enter_at("s1", "L0"); fake_ms += 2000; scene_take(); // the bubble has popped in
{ bool pill = false; for (int i = 0; i < scene.count; i++) pill |= scene.runs[i].box.h == 32 && scene.runs[i].y == 400;
assert(!pill && action_enabled(A_INBOX)); }
FOCUS_PAGE("swarm-4b");
// Pull down from the face opens the inbox; a tap on a Swarm entry enters that Swarm at that Lead.
swarm_setup(); inbox_at("L3"); tap(fake_ms, 233, 233);
assert(swarm_mode() && !strcmp(sw.tab, "s1") && !strcmp(sw.lead, "L3") && s.view == HOME && !desktop_opens);
// Link lost: the Swarms and their entries go; the desktop's rows stay.
swarm_setup();
{ cable_notif_t desk = {.agent_id = "a", .name = "Payments refactor", .summary = "Shipped."}; ui_notif_replace(&desk, 1); }
enter_at("s1", "L0"); ui_supertabs_clear();
assert(!swarm_mode() && swarm_entry("L2") < 0 && swarm_entry("L3") < 0 && s.notice_count == 1 && tabs_total() == 2);
// 4f nothing left: the existing empty inbox.
ui_notif_replace(NULL, 0); assert(!s.notice_count); view(INBOX); scene_take(); assert(scene_says("No notification"));
FOCUS_PAGE("swarm-4f");
puts("Swarm inbox: one entry per Lead, fixed lines, one beep (raise, stuck, either order with a wait), wait text and its close, never a question screen, no worker entries, kept across notif.replace, read on the face, bell pill and bubble, tap enters the Swarm, cleared on link loss PASS");
}
static int voice_bars(void) {
int n = 0;
for (int i = 0; i < scene.count; i++) n += scene.runs[i].font == &ht_wave && scene.runs[i].text[0];
return n;
}
static void swarm_voice_checks(const char *dir) {
// 5a-5d "mobile" on this computer: a tap on its face talks to its harness, with Clawd listening, then sending, then
// the Swarm's face again.
swarm_setup(); enter_at("s1", "L0"); FOCUS_PAGE("swarm-5a");
tap(fake_ms, 233, 260);
assert(s.view == VOICE && !strcmp(target, "h0") && !strcmp(s.voice_engine, "claude") && !strcmp(s.voice_target, "mobile"));
assert(!voice_bars()); FOCUS_PAGE("swarm-5b");
s.voice_waiting = true; FOCUS_PAGE("swarm-5c");
dispatch((action_t){.kind = A_VOICE_ABORT}); s.voice_waiting = false; scene_take();
assert(s.view == HOME && swarm_mode() && !strcmp(sw.lead, "L0") && title_is("mobile"));
FOCUS_PAGE("swarm-5d");
// 5e an engine with no listening scene: the seven bars.
card_begin("s2", "", "playground"); card_lead("P0", "agents", "opencode", "h9", "work", 0, 12); card_send();
fake_ms += 3000; enter_at("s2", "P0"); tap(fake_ms, 233, 260);
assert(s.view == VOICE && !strcmp(target, "h9") && !strcmp(s.voice_engine, "opencode") && voice_bars() == 7);
FOCUS_PAGE("swarm-5e");
dispatch((action_t){.kind = A_VOICE_ABORT});
puts("Swarm voice: a local Lead's face talks to its harness with its engine's scene or the seven bars, and returns to the Swarm's face PASS");
}
/*
* A DAEMON THAT SPEAKS swarmChat (docs/superpowers/specs/2026-10-28-round-dial-swarm-chat-design.md §3): each Lead's face
* is the chat the desktop has open, `work` only for a working group, never ask or stuck, and the alerts are the Lead's
* new messages (`supertab.notice`).
*/
static void chat_lead(const char *id, const char *project, const char *local, const char *state, int order, long since,
const char *chat, const char *chat_id, const char *chat_name) {
ht_lead_in_t in = {.id = id, .project = project, .engine = "claude", .local = local, .state = state, .order = order, .since = since,
.chat = chat, .chat_id = chat_id, .chat_name = chat_name};
assert(ht_supertab_lead_add(&card, &in));
}
// C0 on a working group, C1 on its Chat with PM, C2 on its Lead chat.
static bool chat_card(const char *group_state, const char *c1_chat, const char *c1_id) {
card_begin("s1", "t1", "openharness");
chat_lead("C0", "mobile", "h0", group_state, 0, !strcmp(group_state, "work") ? 9 : -1, "group", "g1", "Fix login");
chat_lead("C1", "docs", "h1", "done", 1, -1, c1_chat, c1_id, !strcmp(c1_chat, "pm") ? "PM" : "Lead");
chat_lead("C2", "web", "", "done", 2, -1, "lead", "lead-web", "Lead");
return card_send();
}
static const ht_run_t *inner_arc(void) {
for (int i = 0; i < scene.count; i++) if (scene.runs[i].arc == 3 && scene.runs[i].text[0]) return &scene.runs[i];
return NULL;
}
static void chat_setup(void) {
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); fake_ms = 100000;
desk_open();
const char ids[1][ID_MAX] = {"s1"};
ui_supertabs_ids(ids, 1);
assert(!chat_card("work", "pm", "pm1"));
scene_take();
}
static void swarm_chat_checks(const char *dir) {
// No entry from a Lead's state when chats are on: the daemon sends no ask or stuck, and a group's work is no alert.
chat_setup();
assert(s.notice_count == 0);
assert(!chat_card("done", "pm", "pm1") && !chat_card("work", "pm", "pm1") && s.notice_count == 0);
// The chat name under the project, on the inner arc: none for the Lead chat or the PM chat (spec 2026-11-05), a group's name cut at a word.
enter_at("s1", "C2"); assert(title_is("web") && !inner_arc());
enter_at("s1", "C1"); assert(title_is("docs") && !inner_arc());
FOCUS_PAGE("swarm-6a");
card_begin("s1", "t1", "openharness");
chat_lead("C0", "mobile", "h0", "done", 0, -1, "group", "g1", "Fix the login redirect loop on Safari and Chrome");
card_send(); enter_at("s1", "C0");
assert(inner_arc() && !strcmp(inner_arc()->text, "Fix the login\xe2\x80\xa6"));
FOCUS_PAGE("swarm-6b");
assert(!chat_card("work", "pm", "pm1")); scene_take();
// A working group shows the working pet and its clock, its name under the project, and no recap.
enter_at("s1", "C0");
assert(title_is("mobile") && scene_says("0:09") && inner_arc() && !strcmp(inner_arc()->text, "Fix login"));
FOCUS_PAGE("swarm-6c");
ui_supertab_recap("s1", "C0", "g1", "", "Tests green on both dials.", 1792560000u, false); scene_take();
assert(!scene_says("Tests green"));
// A done group shows its recap.
assert(!chat_card("done", "pm", "pm1")); scene_take();
assert(scene_says("Tests green") && !scene_says("0:09"));
// The PM chat: its recap, never working.
enter_at("s1", "C1");
ui_supertab_recap("s1", "C1", "pm1", "", "The release notes are ready.", 1792560000u, false); scene_take();
assert(scene_says("release notes") && !scene_says("Working"));
// The desktop moved that project to its Lead chat: the PM chat's recap is no longer this face's.
assert(!chat_card("done", "lead", "lead-docs")); scene_take();
assert(!scene_says("release notes"));
assert(!chat_card("done", "pm", "pm1")); scene_take();
// A notice for the face's chat is read at once and does not beep.
enter_at("s1", "C1");
assert(!ui_supertab_notice("s1", "C1", HT_CHAT_PM, "pm1", "", "Shall I cut the release?", 1792560000u));
int e = swarm_entry("C1");
assert(e >= 0 && s.notice[e].read_on_dial && !s.notice[e].question && s.notice[e].swarm == 3);
assert(!strcmp(s.notice[e].summary, "Shall I cut the release?") && !strcmp(s.notice[e].name, "docs"));
assert(!strcmp(s.notice[e].machine, "openharness \xc2\xb7 PM"));
// A notice for another chat stays unread and beeps once: the Lead chat, while the face shows the PM chat.
assert(ui_supertab_notice("s1", "C1", HT_CHAT_LEAD, "lead-docs", "", "Docs are merged.", 1792560001u));
e = swarm_entry("C1");
assert(e >= 0 && !s.notice[e].read_on_dial && !strcmp(s.notice[e].summary, "Docs are merged."));
assert(!strcmp(s.notice[e].machine, "openharness"));
// Off the face: unread, and it beeps.
assert(ui_supertab_notice("s1", "C2", HT_CHAT_LEAD, "lead-web", "", "Web is deployed.", 1792560002u));
assert(swarm_entry("C2") >= 0 && !s.notice[swarm_entry("C2")].read_on_dial);
// One entry per Lead: a second notice replaces the text and is unread again.
notice_mark_read(&s.notice[swarm_entry("C2")]);
assert(ui_supertab_notice("s1", "C2", HT_CHAT_LEAD, "lead-web", "", "Web is rolled back.", 1792560003u));
{ int count = 0; for (int i = 0; i < s.notice_count; i++) count += !strcmp(s.notice[i].agent_id, "C2"); assert(count == 1); }
e = swarm_entry("C2");
assert(!strcmp(s.notice[e].summary, "Web is rolled back.") && !s.notice[e].read_on_dial);
// A notice for a Lead the dial does not know is nothing.
{ int before = s.notice_count; assert(!ui_supertab_notice("s1", "nobody", HT_CHAT_LEAD, "x", "", "?", 1)); assert(s.notice_count == before); }
// It stays news across the desktop's inbox snapshot: kept, and not turned into a question.
{ cable_notif_t desk = {.agent_id = "a", .name = "Payments refactor", .summary = "Shipped."}; ui_notif_replace(&desk, 1); }
e = swarm_entry("C2"); assert(e >= 0 && !s.notice[e].question && s.notice[e].swarm == 3 && !s.notice[e].read_on_dial);
// notice.read removes the entry, only for its own chat.
ui_supertab_notice_read("s1", "C2", "other-chat"); assert(swarm_entry("C2") >= 0);
ui_supertab_notice_read("s1", "C2", "lead-web"); assert(swarm_entry("C2") < 0);
ui_supertab_notice_read("s1", "C1", "lead-docs"); assert(swarm_entry("C1") < 0);
// A Lead wait still raises its entry, and beeps off the face; its close removes it (the Lead never reads ask here).
enter_at("s1", "C0");
assert(ui_supertab_wait("h2-none", "supertab:x", "openharness", false, "Not a Lead's") == false);
assert(ui_supertab_wait("h1", "supertab:w1", "openharness", false, "Publish the docs today?"));
e = swarm_entry("C1"); assert(e >= 0 && !strcmp(s.notice[e].summary, "Publish the docs today?") && s.notice[e].question);
ui_supertab_wait_close("h1", "supertab:w1"); assert(swarm_entry("C1") < 0);
puts("Swarm chats: work only for a working group, the face chat's recap, Lead/PM notices read on their face or unread with a beep, one entry per Lead, news across a snapshot, notice.read, Lead waits still alert PASS");
}
/*
* A DAEMON THAT SPEAKS swarmBuddy (docs/superpowers/specs/2026-10-29-round-dial-pm-buddy-spec.md): each project has a PM
* side (today's face, plus two dots) and a Buddy side (the reader's Buddy's avatar, a lilac ring, its last message).
* Swipe up for the Buddy, down for the PM; the side is kept per Swarm; the Buddy's word is a quiet badge.
*/
static void buddy_lead(const char *id, const char *project, const char *local, const char *chat, const char *chat_id,
const char *buddy_chat, const char *buddy_engine) {
ht_lead_in_t in = {.id = id, .project = project, .engine = "claude", .local = local, .state = "done", .order = card.lead_n, .since = -1,
.chat = chat, .chat_id = chat_id, .chat_name = !strcmp(chat, "buddy") ? "diego's Buddy" : "Lead", .buddies = true,
.buddy = {.present = buddy_chat != NULL, .chat_id = buddy_chat, .name = "diego's Buddy", .engine = buddy_engine,
.color = "#d6a79a", .cells = 25513, .live = true}};
assert(ht_supertab_lead_add(&card, &in));
}
// web-api (B0, a Codex Buddy) and firmware (B1, a Claude Buddy) have Buddies, docs (B2) none. `face` is B0's chat kind.
static void buddy_card(const char *face) {
card_begin("s1", "t1", "openharness");
buddy_lead("B0", "web-api", "h0", face, !strcmp(face, "buddy") ? "b0" : "lead-web", "b0", "codex");
buddy_lead("B1", "firmware", "h1", "lead", "lead-fw", "b1", "claude");
buddy_lead("B2", "docs", "h2", "lead", "lead-docs", NULL, NULL);
assert(!card_send());
}
static void buddy_setup(void) {
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); fake_ms = 100000;
desk_open();
const char ids[1][ID_MAX] = {"s1"};
ui_supertabs_ids(ids, 1);
buddy_card("lead");
enter_at("s1", "B0"); swarm_sent = 0;
}
static void swipe_v(int from_y, int to_y) {
fake_ms += 1000; habitat_touch(true, 233, from_y, fake_ms); habitat_touch(false, 233, to_y, fake_ms + 120); scene_take();
}
// A drag: held 660 ms, moving all the while, as a reading thumb does.
static void drag_v(int from_y, int to_y) {
fake_ms += 1000; habitat_touch(true, 233, from_y, fake_ms);
for (int i = 1; i <= 10; i++) habitat_touch(true, 233, from_y + (to_y - from_y) * i / 10, fake_ms + 60 * (uint32_t)i);
habitat_touch(false, 233, to_y, fake_ms + 660); scene_take();
}
static void swipe_up(void) { swipe_v(330, 150); }
static void swipe_down(void) { swipe_v(150, 330); }
// The PM | Buddy pair (spec 2026-11-05): a tap on a half, as the person switches sides now.
// The notice badge on the companion's shoulder (option B, 2026-11-05): a 30 px blue disc.
static bool badge_rect(ht_rect_t *out) {
for (int i = 0; i < scene.count; i++) {
const ht_run_t *r = &scene.runs[i];
if (r->box.h == 30 && r->w == 30 && r->box.fill == ht_rgb(0x006fff)) { if (out) *out = (ht_rect_t){r->x, r->y, 30, 30}; return true; }
}
return false;
}
static void pair_buddy(void) { fake_ms += 1000; tap(fake_ms, 278, 410); }
// A thumb's press, not an ideal tap: it lands, drifts `dx`,`dy` px and lifts after `hold` ms (Diego's dial, 2026-11-05: such a
// press on the pair started voice).
static void thumb(int x, int y, int dx, int dy, uint32_t hold) {
fake_ms += 1000;
habitat_touch(true, x, y, fake_ms);
habitat_touch(true, x + dx / 2, y + dy / 2, fake_ms + hold / 2);
habitat_touch(false, x + dx, y + dy, fake_ms + hold);
scene_take();
}
static void pair_pm(void) { fake_ms += 1000; tap(fake_ms, 188, 410); }
static void swipe_next(void) {
fake_ms += 1000; habitat_touch(true, 320, 220, fake_ms); habitat_touch(false, 150, 220, fake_ms + 120); scene_take();
}
// A box run by its centre, diameter and fill.
static bool disc_at(int cx, int cy, int d, unsigned rgb) {
for (int i = 0; i < scene.count; i++) {
const ht_run_t *r = &scene.runs[i];
if (r->box.h == d && r->x == cx - d / 2 && r->y == cy - d / 2 && r->box.fill == ht_rgb(rgb)) return true;
}
return false;
}
// The lilac ring at the glass edge: r 230, 3 px, #c49bff at 32 % over black.
static bool lilac_ring(void) {
for (int i = 0; i < scene.count; i++) {
const ht_run_t *r = &scene.runs[i];
if (r->ring.set && r->ring.w16 == 3 * 16 && r->ring.r16 == 230 * 16 && r->ring.colour == ht_rgb(0x3f3252)) return true;
}
return false;
}
// The avatar: a 50 px sprite of the pattern, centred on its disc (the colour at 16 % over black, r 46) at x 233, at y 158
// or higher, so it stands at least 8 px clear of the recap's card.
static const ht_run_t *avatar_sprite(void) {
for (int i = 0; i < scene.count; i++) {
const ht_run_t *r = &scene.runs[i];
if (r->sprite.width == 50 && r->x == 208 && r->y <= 133) return r;
}
return NULL;
}
static int card_top(void) {
for (int i = 0; i < scene.count; i++) if (scene.runs[i].box.h && scene.runs[i].w >= 300) return scene.runs[i].y;
return 0;
}
static bool avatar(void) {
const ht_run_t *a = avatar_sprite();
if (!a || !disc_at(233, a->y + 25, 92, 0x221b19)) return false;
return !card_top() || a->y + 25 + 46 + 8 <= card_top();
}
// Nothing written in the middle of the glass under the avatar's disc and its 8 px: "Tap the name to switch panes" stood
// under it with no recap (Diego's dial, 2026-10-29).
static bool clear_of_text(void) {
const ht_run_t *a = avatar_sprite();
if (!a) return false;
int bottom = a->y + 25 + 46 + 8;
for (int i = 0; i < scene.count; i++) {
const ht_run_t *r = &scene.runs[i];
if (!r->text[0] || r->arc || r->y < 90 || r->y > 380) continue;
ht_rect_t b = ht_run_bounds(r);
if (b.x < 279 && b.x + b.w > 187 && b.y < bottom) return false;
}
return true;
}
// The pair: the pill 180 wide at y 388, and the current half filled #2b2d33 (the side dots are gone with it).
static bool pair_pill(void) {
for (int i = 0; i < scene.count; i++) {
const ht_run_t *r = &scene.runs[i];
if (r->box.h == 44 && r->w == 180 && r->x == 143 && r->y == 388 && r->box.fill == ht_rgb(0x141518)) return true;
}
return false;
}
static int pair_half(void) { // 0 PM, 1 Buddy, -1 none
for (int i = 0; i < scene.count; i++) {
const ht_run_t *r = &scene.runs[i];
if (r->box.h && r->box.fill == ht_rgb(0x2b2d33) && r->y == 391) return r->x < 233 ? 0 : 1;
}
return -1;
}
static bool pm_dots(void) { return pair_pill() && pair_half() == 0; }
static bool buddy_dots(void) { return pair_pill() && pair_half() == 1; }
static bool any_dot(void) { return pair_pill(); }
// The Buddy's unheard word on the PM side: "Your Buddy replied", one line at y 318.
static bool badge(void) { return scene_says("Your Buddy replied"); }
// Nothing drawn off the dots' line: the old badge, 7 px off the lower dot, smeared the two together.
static bool offset_disc(void) {
for (int i = 0; i < scene.count; i++) {
const ht_run_t *r = &scene.runs[i];
if (r->box.h > 1 && r->x + r->w / 2 == 449 && r->y + r->box.h / 2 == 241) return true;
}
return false;
}
/*
* Diego's dial, 2026-11-02: every daemon restart (each CLI update) dropped the dial on the tabs list, because the Swarm cards
* took 5-40 s to come back. The face comes back on its Swarm, Lead and side whenever the cards do, unless the person moved on.
*/
static void swarm_restart_checks(void) {
const char none[1][ID_MAX] = {""}, ids[3][ID_MAX] = {"s1", "s3", "s2"}, others[2][ID_MAX] = {"s3", "s2"};
// The session goes down for 40 s and the cards come back: the same Lead, on the same screen, with no pick sent.
swarm_setup(); enter_at("s1", "L2"); s.view = HOME; swarm_sent = 0;
ui_supertabs_clear(); sw.opened = false; s.connected = false; assert(!swarm_mode() && s.view == HOME);
fake_ms += 40000; s.connected = true;
ui_supertabs_ids(ids, 3); assert(s.view == HOME);
openharness_card(); card_send();
assert(swarm_mode() && !strcmp(sw.tab, "s1") && !strcmp(sw.lead, "L2") && s.view == HOME && !wire_has(0, "select s1 L2"));
// The app is on another Lead of that Swarm by now: the face follows it.
ui_supertab_focus("s1", "L3"); assert(!strcmp(sw.lead, "L3") && s.view == HOME);
// The same when the focus comes before the card has brought the face back.
swarm_setup(); enter_at("s1", "L2"); s.view = HOME;
ui_supertabs_clear(); fake_ms += 40000; ui_supertabs_ids(ids, 3); openharness_card(); ht_supertabs_put(&swarm, &card, ms(), NULL, 0);
ui_supertab_focus("s1", "L3"); assert(swarm_mode() && !strcmp(sw.lead, "L3") && s.view == HOME);
// The daemon came back with an empty list (it had not read them yet, or signed in late): TABS for now, the face after 40 s.
swarm_setup(); enter_at("s1", "L2"); s.view = HOME;
ui_supertabs_ids(none, 0); assert(!swarm_mode() && s.view == TABS && sw.auto_tabs);
fake_ms += 40000; ui_supertabs_ids(ids, 3); openharness_card(); card_send();
assert(swarm_mode() && !strcmp(sw.lead, "L2") && s.view == HOME && !sw.auto_tabs);
// That TABS, then a session down too: it still comes back.
swarm_setup(); enter_at("s1", "L2"); s.view = HOME;
ui_supertabs_ids(none, 0); ui_supertabs_clear(); assert(s.view == TABS && sw.auto_tabs);
fake_ms += 40000; ui_supertabs_ids(ids, 3); openharness_card(); card_send();
assert(swarm_mode() && !strcmp(sw.lead, "L2") && s.view == HOME);
// The Swarm on the face really went, and the app is on another: the auto-opened TABS follows the app.
swarm_setup(); enter_at("s1", "L2"); s.view = HOME;
ui_supertabs_ids(none, 0); ui_supertabs_ids(others, 2); assert(s.view == TABS && sw.auto_tabs);
card_begin("s2", "t2", "playground"); card_lead("P0", "sandbox", "claude", "h9", "work", 0, 12); card_send();
COPY(s.selected_tab, "t2"); ui_supertab_focus("s2", "P0");
assert(swarm_mode() && !strcmp(sw.tab, "s2") && !strcmp(sw.lead, "P0") && s.view == HOME);
// The Swarm really gone once the cards are back: it does not come back over the dial later.
swarm_setup(); enter_at("s1", "L2"); s.view = HOME;
ui_supertabs_clear(); fake_ms += 40000; ui_supertabs_ids(others, 2);
ui_supertabs_ids(ids, 3); openharness_card(); card_send(); assert(!swarm_mode());
// The person touched the dial meanwhile: that is their screen now, and the Swarm stays off the face.
swarm_setup(); enter_at("s1", "L2"); s.view = HOME;
ui_supertabs_clear(); habitat_touch(true, 233, 233, fake_ms); habitat_touch_cancel(); fake_ms += 40000;
ui_supertabs_ids(ids, 3); openharness_card(); card_send(); assert(!swarm_mode());
// A person's own TABS is never followed off, by the focus either.
swarm_setup(); s.view = HOME; dispatch((action_t){.kind = A_TABS}); assert(s.view == TABS && !sw.auto_tabs);
COPY(s.selected_tab, "t1"); ui_supertab_focus("s1", "L2"); assert(!swarm_mode() && s.view == TABS);
// The side comes back too, and the new daemon, which remembers none, is told it.
buddy_setup(); enter_at("s1", "B1"); s.view = HOME; pair_buddy(); assert(swarm_side_buddy("s1"));
ui_supertabs_clear(); assert(!swarm_side_buddy("s1")); fake_ms += 40000; swarm_sent = 0;
{ const char one[1][ID_MAX] = {"s1"}; ui_supertabs_ids(one, 1); }
buddy_card("lead");
assert(swarm_mode() && !strcmp(sw.lead, "B1") && swarm_side_buddy("s1") && wire_has(0, "side-kept s1 buddy") && !wire_has(0, "side s1 buddy"));
puts("Swarm restart: the face keeps its Swarm, Lead and side across a session down or an empty list with no time limit, follows the app, and only the person or a Swarm really gone ends it");
}
// A face in a thread (spec 2026-11-03-dial-thread-face): the teal face, the card, and the swipe out that selects nothing.
static void thread_lead(const char *id, const char *project, const char *thread, const char *title, long replies) {
ht_lead_in_t in = {.id = id, .project = project, .engine = "claude", .local = "", .state = "done", .order = card.lead_n, .since = -1,
.chat = "pm", .chat_id = "pm1", .chat_name = "PM", .thread = thread, .thread_title = title, .thread_replies = replies};
assert(ht_supertab_lead_add(&card, &in));
}
static bool teal_ring(void) {
for (int i = 0; i < scene.count; i++) {
const ht_run_t *r = &scene.runs[i];
if (r->ring.set && r->ring.w16 == 5 * 16 && r->ring.r16 == 229 * 16 && r->ring.colour == ht_rgb(0x197569)) return true; // #2dd4bf at 55 % over black
}
return false;
}
// The label is "Thread" with a teal hook arrow of boxes left of it (Inter has no U+21B3, and no "›" stands in); the card starts at
// x 63. No "‹ chat" at the left edge and no teal spine on the card (Diego, 2026-11-04): the swipe out needs no label.
static void thread_chrome_checks(void) {
const ht_run_t *label = NULL; int card_x = -1, spines = 0;
for (int i = 0; i < scene.count; i++) {
const ht_run_t *r = &scene.runs[i];
if (!strcmp(r->text, "Thread")) label = r;
if (!r->text[0] && r->w == 340 && r->box.h >= 60) card_x = r->x;
if (!r->text[0] && r->w == 7 && r->box.fill == ht_rgb(0x2dd4bf)) spines++;
}
assert(label && card_x == 63 && !scene_says("\xe2\x80\xba"));
assert(!scene_says("chat") && !scene_says("\xe2\x80\xb9") && spines == 0);
int strokes = 0;
for (int i = 0; i < scene.count; i++) {
const ht_run_t *r = &scene.runs[i];
if (!r->text[0] && r->box.fill == ht_rgb(0x2dd4bf) && r->y >= 100 && r->y <= 116 && r->x + r->w <= label->x) strokes++;
}
assert(strokes >= 6); // the down stroke, the right stroke and the head's four columns, all left of the label
}
static void swarm_thread_checks(const char *dir) {
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); fake_ms = 100000;
desk_open();
const char ids[1][ID_MAX] = {"s1"};
ui_supertabs_ids(ids, 1);
card_begin("s1", "t1", "openharness");
thread_lead("T0", "web-api", "m9", "Fix the login bug on Safari when the session expires", 1);
thread_lead("T1", "firmware", "", "", -1);
assert(!card_send());
enter_at("s1", "T0"); swarm_sent = 0;
// Before a reply: the thread, its title on two lines, and what it waits for; no pet, no working time.
scene_take();
assert(title_is("web-api") && scene_says("Thread") && scene_says("Fix the login bug on Safari") && scene_says("session expires"));
thread_chrome_checks();
portrait(dir, "thread-a-waiting-1line");
assert(scene_says("Waiting for the PM") && !scene_says("Working") && teal_ring() && !pet_frame());
// The main chat's recap is not the thread's; the thread's is, with who spoke and how many.
ui_supertab_recap("s1", "T0", "pm1", "", "Merged #2704.", 1792560000u, false); scene_take();
assert(!scene_says("Merged") && scene_says("Waiting for the PM"));
ui_supertab_recap("s1", "T0", "pm1", "m9", "Taken: Milo fixes it now.", 1792560000u, false); scene_take();
portrait(dir, "thread-1line-recap");
// 2-line title, 3-line recap, "PM · 2 replies": the largest card.
card_begin("s1", "t1", "openharness");
thread_lead("T0", "web-api", "m9", "Fix the login bug on Safari when the session expires", 2); thread_lead("T1", "firmware", "", "", -1); assert(!card_send());
ui_supertab_recap("s1", "T0", "pm1", "m9", "Taken: Milo fixes the login bug now and Quinn reviews it before the end of the day, then we ship the release to everyone on the beta channel.", 1792560000u, false); scene_take();
assert(scene_says("PM \xc2\xb7 2 replies")); thread_chrome_checks();
portrait(dir, "thread-b-2line-3line-recap");
// A Buddy thread: "Thread · Buddy" and the same chrome.
{ ht_lead_in_t in = {.id = "T0", .project = "web-api", .engine = "claude", .local = "", .state = "done", .order = 0, .since = -1,
.chat = "buddy", .chat_id = "b0", .chat_name = "Buddy", .thread = "m5", .thread_title = "Plan the Pro voice", .thread_replies = 2,
.buddies = true, .buddy = {.present = true, .chat_id = "b0", .name = "Buddy", .engine = "claude", .color = "#d6a79a", .cells = 25513, .live = true}};
card_begin("s1", "t1", "openharness"); assert(ht_supertab_lead_add(&card, &in)); thread_lead("T1", "firmware", "", "", -1); card.leads[0].buddies = true;
card.side = HT_SIDE_BUDDY; assert(!card_send()); }
ui_supertab_recap("s1", "T0", "b0", "m5", "Two options: push-to-talk or wake word.", 1792560000u, false); scene_take();
assert(scene_says("Thread \xc2\xb7 Buddy") && scene_says("Buddy \xc2\xb7 2 replies")); portrait(dir, "thread-c-buddy");
// Back to the PM thread for the rest of the checks.
card_begin("s1", "t1", "openharness");
thread_lead("T0", "web-api", "m9", "Fix the login bug on Safari when the session expires", 1); thread_lead("T1", "firmware", "", "", -1); assert(!card_send());
ui_supertab_recap("s1", "T0", "pm1", "m9", "Taken: Milo fixes it now.", 1792560000u, false); scene_take();
assert(scene_says("Taken: Milo") && scene_says("PM \xc2\xb7 1 reply") && !scene_says("Waiting"));
// A Lead that starts waiting on the person stays visible on the thread face: the wait takes the card, the chrome stays.
card_begin("s1", "t1", "openharness");
thread_lead("T0", "web-api", "m9", "Fix the login bug on Safari when the session expires", 1); thread_lead("T1", "firmware", "", "", -1);
strcpy(card.leads[0].local, "h5"); assert(!card_send());
assert(!ui_supertab_wait("h5", "supertab:w1", "openharness", false, "Publish the docs today?")); scene_take();
assert(scene_says("Publish the docs today?") && !scene_says("Taken: Milo") && !scene_says("1 reply") && scene_says("Thread") && teal_ring());
thread_chrome_checks();
portrait(dir, "thread-e-waiting-lead");
ui_supertab_wait_close("h5", "supertab:w1"); scene_take();
assert(scene_says("Taken: Milo") && !scene_says("Publish the docs"));
// The swipe sideways leaves the thread: the daemon is told, the main chat's recap is asked for, nothing is selected, and the
// face stays on the same project.
swarm_sent = 0; swipe_next();
assert(swarm_sent == 2 && !strcmp(swarm_wire[0], "thread-leave s1 T0") && !strcmp(swarm_wire[1], "recap.get s1 T0"));
assert(!strcmp(sw.lead, "T0") && !scene_says("Thread") && !teal_ring() && !scene_says("Taken: Milo") && swarm.recap.state == HT_RECAP_LOADING);
ui_supertab_recap("s1", "T0", "pm1", "", "Merged #2704. Next: the Kilo picker fix.", 1792560000u, false); scene_take(); portrait(dir, "thread-d-main-pm-after-leave");
// The thread's recap arriving late is refused; the main chat's lands.
ui_supertab_recap("s1", "T0", "pm1", "m9", "Late.", 1792560000u, false); scene_take(); assert(!scene_says("Late."));
ui_supertab_recap("s1", "T0", "pm1", "", "Merged #2704.", 1792560000u, false); scene_take(); assert(scene_says("Merged #2704."));
// A card made before the swipe still names the thread left: it does not bring the face back. One without it, or 3 s, ends that.
swarm_sent = 0; card_begin("s1", "t1", "openharness");
thread_lead("T0", "web-api", "m9", "Fix the login bug on Safari when the session expires", 1); thread_lead("T1", "firmware", "", "", -1); assert(!card_send());
scene_take(); assert(!scene_says("Thread") && !teal_ring() && swarm_sent == 0 && swarm.recap.state == HT_RECAP_LOADED);
card_begin("s1", "t1", "openharness"); thread_lead("T0", "web-api", "", "", -1); thread_lead("T1", "firmware", "", "", -1); assert(!card_send());
card_begin("s1", "t1", "openharness");
thread_lead("T0", "web-api", "m9", "Fix the login bug on Safari when the session expires", 1); thread_lead("T1", "firmware", "", "", -1); assert(!card_send());
scene_take(); assert(scene_says("Thread") && teal_ring()); // a thread entered again after the mask ended
ui_supertab_recap("s1", "T0", "pm1", "m9", "Back.", 1792560000u, false);
// A frame that puts the face in a thread (the app opened one, or the dial's words started it) asks for that thread's recap.
swarm_sent = 0; card_begin("s1", "t1", "openharness");
thread_lead("T0", "web-api", "m10", "Plan the release", 0); thread_lead("T1", "firmware", "", "", -1); assert(!card_send());
assert(swarm_sent == 1 && !strcmp(swarm_wire[0], "recap.get s1 T0") && swarm.recap.state == HT_RECAP_LOADING);
scene_take(); assert(scene_says("Plan the release") && scene_says("Waiting for the PM"));
ui_supertab_recap("s1", "T0", "pm1", "m10", "Two options.", 1792560000u, false); scene_take(); assert(scene_says("PM \xc2\xb7 0 replies"));
swarm_sent = 0; card_begin("s1", "t1", "openharness"); thread_lead("T0", "web-api", "", "", -1); thread_lead("T1", "firmware", "", "", -1); assert(!card_send());
assert(swarm_sent == 1 && !strcmp(swarm_wire[0], "recap.get s1 T0")); // and one that ends it (the app closed it) asks the main chat's
// Now on the main chat, the same swipe moves to the next project as before.
swarm_sent = 0; swipe_next();
assert(!strcmp(sw.lead, "T1") && swarm_sent >= 1 && !strcmp(swarm_wire[0], "select s1 T1"));
puts("Swarm thread face: title, waiting, a recap only for the thread, swipe out sends the leave and the main recap ask and selects nothing, then swipes move on PASS");
}
// A PM reply inside a thread (#2463, Diego 2026-10-29): read at once only while the face shows that very thread, else it beeps
// and stays unread. A message in the main stream keeps today's rule: read at once while the face shows its chat.
static void swarm_thread_notice_checks(void) {
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); fake_ms = 100000;
desk_open();
const char ids[1][ID_MAX] = {"s1"};
ui_supertabs_ids(ids, 1);
card_begin("s1", "t1", "openharness");
thread_lead("T0", "web-api", "m9", "Fix the login bug on Safari when the session expires", 1); thread_lead("T1", "firmware", "", "", -1); assert(!card_send());
enter_at("s1", "T0"); scene_take();
assert(!strcmp(sw.lead, "T0") && scene_says("Thread"));
// The face is in thread m9: a reply there is read at once and does not beep.
assert(!ui_supertab_notice("s1", "T0", HT_CHAT_PM, "pm1", "m9", "Fixed on Safari.", 1792560001u));
int e = swarm_entry("T0"); assert(e >= 0 && s.notice[e].read_on_dial && !strcmp(s.notice[e].summary, "Fixed on Safari."));
// A reply in another thread of that chat beeps and stays unread.
assert(ui_supertab_notice("s1", "T0", HT_CHAT_PM, "pm1", "m7", "The other task is merged.", 1792560002u));
e = swarm_entry("T0"); assert(e >= 0 && !s.notice[e].read_on_dial && !strcmp(s.notice[e].summary, "The other task is merged."));
ui_supertab_notice_read("s1", "T0", "pm1"); assert(swarm_entry("T0") < 0);
// The face back on the main chat: a thread reply beeps and stays unread, a main-stream one is read at once.
card_begin("s1", "t1", "openharness"); thread_lead("T0", "web-api", "", "", -1); thread_lead("T1", "firmware", "", "", -1); assert(!card_send());
scene_take(); assert(!strcmp(sw.lead, "T0") && !scene_says("Thread"));
assert(ui_supertab_notice("s1", "T0", HT_CHAT_PM, "pm1", "m9", "Fixed on Chrome too.", 1792560003u));
e = swarm_entry("T0"); assert(e >= 0 && !s.notice[e].read_on_dial);
assert(!ui_supertab_notice("s1", "T0", HT_CHAT_PM, "pm1", "", "Next: the release.", 1792560004u));
e = swarm_entry("T0"); assert(e >= 0 && s.notice[e].read_on_dial);
// Off the face, a thread reply beeps as any notice does.
assert(ui_supertab_notice("s1", "T1", HT_CHAT_PM, "pm1", "m9", "Flashed.", 1792560005u));
puts("Swarm thread notices: read at once only on that thread's face, a beep on the main chat or another thread, main-stream notices as before PASS");
}
// A tag in a task chat (#2965, Diego 2026-11-04): it alerts as a Lead's notice does, read at once only while the face shows
// that very chat and thread, else it beeps and wakes. The daemon sends each tag once.
static void group_lead(const char *id, const char *thread) {
ht_lead_in_t in = {.id = id, .project = "web", .engine = "claude", .local = "", .state = "work", .order = card.lead_n, .since = -1,
.chat = "group", .chat_id = "g1", .chat_name = "Fix login", .thread = thread,
.thread_title = thread[0] ? "Fix login on Safari" : "", .thread_replies = -1};
assert(ht_supertab_lead_add(&card, &in));
}
static void swarm_tag_notice_checks(void) {
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); fake_ms = 100000;
desk_open();
const char ids[1][ID_MAX] = {"s1"};
ui_supertabs_ids(ids, 1);
card_begin("s1", "t1", "openharness"); group_lead("G0", "r1"); thread_lead("G1", "firmware", "", "", -1); assert(!card_send());
enter_at("s1", "G0"); scene_take();
assert(!strcmp(sw.lead, "G0"));
// The face is in that task chat's thread r1: the tag there is read at once, with no beep.
assert(!ui_supertab_notice("s1", "G0", HT_CHAT_GROUP, "g1", "r1", "Sam: @diego look", 1792560001u));
int e = swarm_entry("G0"); assert(e >= 0 && s.notice[e].read_on_dial);
// Another thread of the chat on the face beeps and stays unread; its main stream is that chat's, read at once.
assert(ui_supertab_notice("s1", "G0", HT_CHAT_GROUP, "g1", "r2", "Sam: @diego and here", 1792560002u));
e = swarm_entry("G0"); assert(e >= 0 && !s.notice[e].read_on_dial && !strcmp(s.notice[e].summary, "Sam: @diego and here"));
assert(!ui_supertab_notice("s1", "G0", HT_CHAT_GROUP, "g1", "", "Sam: @diego main", 1792560003u));
// Another project's task chat, off the face: it beeps and is that Lead's one entry, named for the Swarm.
assert(ui_supertab_notice("s1", "G1", HT_CHAT_GROUP, "g9", "", "River: @diego merged?", 1792560004u));
e = swarm_entry("G1"); assert(e >= 0 && !s.notice[e].read_on_dial && !strcmp(s.notice[e].summary, "River: @diego merged?"));
puts("Swarm tag notices: a task chat's tag is read at once only on that chat and thread's face, else it beeps PASS");
}
static void swarm_buddy_checks(const char *dir) {
// 7a the PM side: today's face and two dots, the upper one lit.
buddy_setup();
assert(title_is("web-api") && pm_dots() && !lilac_ring() && !avatar());
FOCUS_PAGE("buddy-7a");
int pm_runs = scene.count;
// A drag held past a flick scrolls the Swarm chat the desktop has open, and the side stays (Diego's dial, 2026-10-29:
// scrolling the recap did not scroll the chat). The daemon sends it to the Swarm the dial has open.
drag_v(330, 150);
assert(down_reports == 1 && moves > 0 && ups == 1 && travel != 0);
assert(!swarm_sent && pm_dots() && !lilac_ring());
// A tap while that fling coasts on the desktop stops it there (review of #2232: the tap was swallowed and the chat
// kept scrolling).
{ int before = down_reports; habitat_touch(true, 233, 260, fake_ms + 700); habitat_touch(false, 233, 260, fake_ms + 760);
assert(down_reports == before + 1); }
// A thumb that rests before it flicks no longer switches the side (spec 2026-11-05): the pair's taps do.
buddy_setup(); down_reports = moves = ups = 0;
fake_ms += 1000; habitat_touch(true, 233, 330, fake_ms); habitat_touch(true, 233, 330, fake_ms + 400);
habitat_touch(true, 233, 240, fake_ms + 450); habitat_touch(false, 233, 150, fake_ms + 500); scene_take();
assert(!moves && swarm_sent == 0 && !lilac_ring() && pm_dots());
// A daemon that came back has forgotten the Lead open here (the dial's link dropped, as ui_set_connected(false)
// leaves it): the next frame tells it again, so a drag scrolls its Swarm and recaps reach the face (review of #2232).
buddy_setup(); sw.opened = false;
// Until then the daemon has no Lead open, and would hand a drag to the focused pane: none is sent.
drag_v(330, 150); assert(!moves && !ups);
buddy_card("lead");
assert(wire_has(0, "open s1 B0") && wire_has(0, "recap.get s1 B0"));
{ int n = swarm_sent; buddy_card("lead"); assert(swarm_sent == n); }
buddy_setup();
// The PM chat's recap is on the face.
ui_supertab_recap("s1", "B0", "lead-web", "", "Merged.", 1792560000u, false); scene_take(); assert(scene_says("Merged."));
// 7b tap Buddy: the dial says so, and draws the Buddy side at once: the ring, the avatar, the lower dot lit.
pair_buddy();
// The tap scrolls nothing (it used to scroll the pane still active behind it).
assert(!down_reports && !moves && !ups);
assert(swarm_sent == 1 && !strcmp(swarm_wire[0], "side s1 buddy"));
assert(s.view == HOME && title_is("web-api") && lilac_ring() && avatar() && buddy_dots());
// The Buddy chat's recap can come before the frame that puts that chat on the face (a card is held 300 ms, a recap is
// not), and is refused as another chat's. The frame then asks for it again: the Buddy side showed no last message
// (Diego's dial, 2026-10-29).
ui_supertab_recap("s1", "B0", "b0", "", "Too early.", 1792560000u, false);
// The daemon puts the Buddy chat on the face; its recap is the Buddy's last message.
buddy_card("buddy");
assert(swarm_sent == 2 && !strcmp(swarm_wire[1], "recap.get s1 B0"));
ui_supertab_recap("s1", "B0", "b0", "", "Two ways: cache the read, or move it to the host. I'd cache it.", 1792560000u, false); scene_take();
assert(scene_says("Two ways") && lilac_ring() && avatar());
// Without a recap it stands at 233, 158 exactly.
{ const ht_run_t *a = avatar_sprite(); assert(a); }
{
// A four-line recap: the card rises, the avatar with it.
ui_supertab_recap("s1", "B0", "b0", "", "Two ways: cache the read, or move it to the host. I'd cache it. Want me to write it up and send it to the PM?", 1792560000u, false);
scene_take(); assert(avatar() && card_top());
// With the bell too (an unread notice off the face) every run still fits the scene.
assert(ui_supertab_notice("s1", "B1", HT_CHAT_LEAD, "lead-fw", "", "Flashed.", 1792560001u));
scene_take(); assert(avatar() && scene.count < HT_RUNS);
ui_supertab_recap("s1", "B0", "b0", "", "", 1792560000u, true);
// Nothing said yet: whatever the face writes instead stands clear of the avatar, at any of its captions.
for (int k = 0; k < 40; k++) { fake_ms += 9000; scene_take(); assert(avatar() && clear_of_text()); }
ui_supertab_recap("s1", "B0", "b0", "", "Two ways: cache the read, or move it to the host. I'd cache it.", 1792560000u, false); scene_take();
}
FOCUS_PAGE("buddy-7b");
{
// The pattern: 25513's half bits mirrored on 5 x 5 cells of 10 px, each with its corner pixel cut.
const ht_run_t *a = avatar_sprite();
assert(a->sprite.height == 50 && a->sprite.cell == 1 && !a->sprite.row_at && a->sprite.palette[1]);
#define AV(x, y) a->sprite.cells[(y) * 50 + (x)]
static const int cols[5] = {0, 1, 2, 1, 0};
for (int r = 0; r < 5; r++) for (int c = 0; c < 5; c++) {
bool on = (25513 >> (r * 3 + cols[c])) & 1;
assert((AV(c * 10 + 5, r * 10 + 5) != 0) == on);
if (on) assert(!AV(c * 10, r * 10) && AV(c * 10 + 1, r * 10) && !AV(c * 10 + 9, r * 10 + 9));
}
#undef AV
}
// A swipe up on the Buddy side does nothing.
swipe_up(); assert(swarm_sent == 2 && lilac_ring());
// The next project keeps the side, and the dial says it again with the move.
swipe_next();
assert(!strcmp(sw.lead, "B1") && title_is("firmware") && lilac_ring() && avatar() && wire_has(1, "side s1 buddy") && wire_has(1, "select s1 B1"));
// 7c a project with no Buddy: the empty state, and a tap there starts no voice.
swipe_next();
assert(!strcmp(sw.lead, "B2") && title_is("docs") && lilac_ring() && buddy_dots() && !avatar());
assert(scene_says("No Buddy here yet") && scene_says("Add one in the Harness app."));
FOCUS_PAGE("buddy-7c");
{ int before = starts; tap(fake_ms + 2000, 233, 260); assert(starts == before && s.view == HOME); }
// Tap PM: back to the PM side.
int sent = swarm_sent; pair_pm();
assert(swarm_sent == sent + 1 && !strcmp(swarm_wire[sent], "side s1 pm") && pm_dots() && !lilac_ring() && !scene_says("No Buddy"));
// On the PM side an unread Lead notice opens the inbox from the badged pet, not from a pull down.
assert(ui_supertab_notice("s1", "B0", HT_CHAT_LEAD, "lead-web", "", "Web is merged.", 1792560001u));
scene_take(); sent = swarm_sent; swipe_down();
assert(s.view == HOME && swarm_sent == sent);
{ ht_rect_t b; assert(badge_rect(&b)); tap(fake_ms += 1000, b.x - 20, b.y + 30); }
assert(s.view == INBOX && swarm_sent == sent);
dispatch((action_t){.kind = A_HOME}); scene_take();
// The side follows the daemon, newest wins: a face that turns to its Buddy chat (the desktop opened it) is the Buddy
// side; one that turns away (the desktop moved on) is the PM side again. The dial does not answer either.
buddy_setup(); buddy_card("buddy");
scene_take(); assert(lilac_ring() && avatar() && swarm_sent == 0);
buddy_card("lead"); scene_take(); assert(!lilac_ring() && pm_dots() && swarm_sent == 0);
// A desktop focus moves the face without saying a side; only the person's own move does.
pair_buddy(); assert(swarm_sent == 1);
ui_supertab_focus("s1", "B1"); scene_take(); assert(!strcmp(sw.lead, "B1") && !wire_has(1, "side s1 buddy") && !wire_has(1, "side s1 pm"));
// The dial follows the daemon even right after its own move: the daemon keeps the side through the desktop move its
// select causes, so a turn away is always a newer desktop focus.
buddy_setup(); pair_buddy(); buddy_card("buddy"); swipe_next();
assert(!strcmp(sw.lead, "B1") && lilac_ring() && wire_has(0, "side s1 buddy"));
sent = swarm_sent; buddy_card("lead"); scene_take();
assert(!lilac_ring() && pm_dots() && swarm_sent == sent);
// The daemon's side is the truth where it says one (review of #2218): Buddies on and no Buddy anywhere, the person
// swipes up to the empty Buddy side, then opens a group on the desktop. No face turns to or from a Buddy chat, and the
// frame says the PM side: the dial follows the desktop's group.
{
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); fake_ms = 100000; desk_open();
const char ids[1][ID_MAX] = {"s1"}; ui_supertabs_ids(ids, 1);
card_begin("s1", "t1", "openharness"); buddy_lead("B2", "docs", "h2", "lead", "lead-docs", NULL, NULL); card.side = HT_SIDE_PM; card_send();
enter_at("s1", "B2"); swarm_sent = 0;
pair_buddy(); assert(scene_says("No Buddy here yet") && swarm_sent == 1);
// The daemon took the swipe: its frame says the Buddy side, and the empty screen stays.
card_begin("s1", "t1", "openharness"); buddy_lead("B2", "docs", "h2", "lead", "lead-docs", NULL, NULL); card.side = HT_SIDE_BUDDY; card_send();
scene_take(); assert(scene_says("No Buddy here yet"));
// The desktop opens a group: the daemon drops the side.
card_begin("s1", "t1", "openharness"); buddy_lead("B2", "docs", "h2", "group", "g-docs", NULL, NULL); card.side = HT_SIDE_PM; card_send();
scene_take(); assert(!scene_says("No Buddy here yet") && !lilac_ring() && pm_dots() && swarm_sent == 1);
// And the daemon's Buddy side shows it, with no swipe here (another dial, or the side said again).
card_begin("s1", "t1", "openharness"); buddy_lead("B2", "docs", "h2", "lead", "lead-docs", NULL, NULL); card.side = HT_SIDE_BUDDY; card_send();
scene_take(); assert(scene_says("No Buddy here yet") && lilac_ring());
}
// Buddies off: no dots, swipe up is inert, and the face is exactly a face from a daemon without Buddies.
buddy_setup();
card_begin("s1", "t1", "openharness");
chat_lead("B0", "web-api", "h0", "done", 0, -1, "lead", "lead-web", "Lead");
card_send(); scene_take();
assert(!any_dot() && !lilac_ring());
swipe_up(); assert(swarm_sent == 0 && !lilac_ring() && !any_dot() && s.view == HOME);
static ht_scene_t off; off = scene;
{
ht_lead_in_t in = {.id = "B0", .project = "web-api", .engine = "claude", .local = "h0", .state = "done", .order = 0, .since = -1,
.chat = "lead", .chat_id = "lead-web", .chat_name = "Lead"};
card_begin("s1", "t1", "openharness"); assert(ht_supertab_lead_add(&card, &in)); card_send(); scene_take();
assert(scene.count == off.count && !memcmp(&scene, &off, sizeof scene));
}
// Buddies turned off while on the Buddy side: the PM face, no dots.
buddy_setup(); pair_buddy(); assert(lilac_ring());
card_begin("s1", "t1", "openharness"); chat_lead("B0", "web-api", "h0", "done", 0, -1, "lead", "lead-web", "Lead"); card_send();
scene_take(); assert(!lilac_ring() && !any_dot() && !avatar());
// A Buddy removed while its side is open (Buddies still on, no block): the empty state, no voice.
buddy_setup(); pair_buddy();
card_begin("s1", "t1", "openharness"); buddy_lead("B0", "web-api", "h0", "lead", "lead-web", NULL, NULL); card_send(); scene_take();
assert(scene_says("No Buddy here yet") && lilac_ring());
{ int before = starts; tap(fake_ms + 2000, 233, 260); assert(starts == before); }
// 7d the quiet notice: on the PM side the Buddy's word turns the lower dot lilac and writes a line on the lower arc, with
// no beep, no inbox entry and no wake. The run count holds.
buddy_setup();
ui_supertab_recap("s1", "B0", "lead-web", "", "Assigned #2083 to web-api. I'll post here when the PR is up.", 1792560000u, false);
scene_take(); pm_runs = scene.count;
assert(!badge() && pm_dots() && !offset_disc() && !scene_says("Your Buddy replied"));
int entries = s.notice_count; int woke = wakes;
assert(!ui_supertab_notice("s1", "B0", HT_CHAT_BUDDY, "b0", "", "Cache it.", 1792560002u));
scene_take();
assert(s.notice_count == entries && wakes == woke && badge() && pm_dots() && !offset_disc() && scene_says("Your Buddy replied") && scene.count == pm_runs);
FOCUS_PAGE("buddy-7d");
// Another project shows none; back on web-api it is still there.
swipe_next(); assert(!badge() && !scene_says("Your Buddy replied"));
swarm_show(ht_supertabs_find(&swarm, "s1"), 0, true); scene_take(); assert(badge());
// Opening the Buddy side reads it.
pair_buddy(); assert(!badge()); pair_pm(); assert(!badge() && !scene_says("Your Buddy replied"));
// The resting face has no lower-arc hint with the pair, so the line stands at y 318 here too.
ui_supertab_recap("s1", "B0", "lead-web", "", "", 1792560000u, true);
assert(!ui_supertab_notice("s1", "B0", HT_CHAT_BUDDY, "b0", "", "Later.", 1792560002u));
scene_take(); assert(badge() && !offset_disc());
pair_buddy(); pair_pm(); assert(!badge() && pm_dots());
// A Buddy word while its side is open is read there; the desktop opening the Buddy chat reads one too.
pair_buddy(); buddy_card("buddy");
assert(!ui_supertab_notice("s1", "B0", HT_CHAT_BUDDY, "b0", "", "Done.", 1792560003u));
pair_pm(); assert(!badge());
assert(!ui_supertab_notice("s1", "B0", HT_CHAT_BUDDY, "b0", "", "Again.", 1792560004u)); scene_take(); assert(badge());
ui_supertab_notice_read("s1", "B0", "other"); scene_take(); assert(badge());
ui_supertab_notice_read("s1", "B0", "b0"); scene_take(); assert(!badge());
// A Lead notice is unchanged: an entry, and a beep off the face.
assert(ui_supertab_notice("s1", "B1", HT_CHAT_LEAD, "lead-fw", "", "Flashed.", 1792560005u) && s.notice_count == entries + 1);
// 7e-7g voice on the Buddy side: the Buddy's engine's pet, the ring kept, and "Sending to your Buddy".
buddy_setup(); pair_buddy(); buddy_card("buddy"); scene_take();
tap(fake_ms + 2000, 233, 260);
assert(s.view == VOICE && !strcmp(target, "h0") && !strcmp(s.voice_engine, "codex") && lilac_ring());
FOCUS_PAGE("buddy-7e");
s.voice_waiting = true; recording = false; scene_take();
assert(lilac_ring() && scene_says("Sending to your Buddy"));
FOCUS_PAGE("buddy-7f");
dispatch((action_t){.kind = A_VOICE_ABORT}); s.voice_waiting = false; scene_take();
assert(s.view == HOME && lilac_ring());
// A Claude Buddy listens with Claude's pet.
swipe_next(); tap(fake_ms + 2000, 233, 260);
assert(s.view == VOICE && !strcmp(target, "h1") && !strcmp(s.voice_engine, "claude"));
FOCUS_PAGE("buddy-7g");
dispatch((action_t){.kind = A_VOICE_ABORT}); scene_take();
// On the PM side voice is today's: the Lead's engine, no ring, no Buddy line.
pair_pm(); tap(fake_ms + 2000, 233, 260);
assert(s.view == VOICE && !strcmp(target, "h1") && !strcmp(s.voice_engine, "claude") && !lilac_ring());
s.voice_waiting = true; recording = false; scene_take(); assert(!scene_says("Sending to your Buddy"));
dispatch((action_t){.kind = A_VOICE_ABORT}); s.voice_waiting = false;
// The ring and "Sending to your Buddy" belong to the turn: pinned when it starts, as its chat is (the batch's check of
// #2218 with #2207). The side changing under a recording, or while it is sent, moves neither, either way.
for (int waiting = 0; waiting < 2; waiting++) {
// Started on the PM side; the desktop then opens the Buddy chat.
buddy_setup(); tap(fake_ms + 2000, 233, 260);
assert(s.view == VOICE && !lilac_ring());
if (waiting) { s.voice_waiting = true; recording = false; }
buddy_card("buddy"); scene_take();
assert(swarm_side_buddy("s1") && s.view == VOICE && !lilac_ring() && !scene_says("Sending to your Buddy"));
s.voice_waiting = true; recording = false; scene_take();
assert(!lilac_ring() && !scene_says("Sending to your Buddy"));
dispatch((action_t){.kind = A_VOICE_ABORT}); s.voice_waiting = false;
// Started on the Buddy side; the desktop then opens another conversation.
buddy_setup(); pair_buddy(); buddy_card("buddy"); scene_take(); tap(fake_ms + 2000, 233, 260);
assert(s.view == VOICE && lilac_ring());
if (waiting) { s.voice_waiting = true; recording = false; }
buddy_card("lead"); scene_take();
assert(!swarm_side_buddy("s1") && s.view == VOICE && lilac_ring());
s.voice_waiting = true; recording = false; scene_take();
assert(lilac_ring() && scene_says("Sending to your Buddy"));
dispatch((action_t){.kind = A_VOICE_ABORT}); s.voice_waiting = false;
}
puts("Swarm Buddies: tap Buddy on the pair (ring, avatar, its recap), PM for the PM, side kept across projects and following the daemon, the empty state, Buddies off unchanged, the quiet badge, voice with the Buddy's engine PASS");
}
// The PM | Buddy pair (spec 2026-11-05): the bottom pill, the bell above it, vertical swipes inert, no "PM" line.
static bool run_at(const char *text, int y) {
for (int i = 0; i < scene.count; i++) if (!strcmp(scene.runs[i].text, text) && scene.runs[i].y == y) return true;
return false;
}
static bool arc2_text(void) {
for (int i = 0; i < scene.count; i++) if (scene.runs[i].arc == 2 && scene.runs[i].text[0]) return true;
return false;
}
static bool bell_at(int y) {
for (int i = 0; i < scene.count; i++) if (scene.runs[i].box.h == 32 && scene.runs[i].y == y && scene.runs[i].box.fill == ht_rgb(0x006fff)) return true;
return false;
}
static void pair_lead(const char *id, const char *project, const char *state, long since, bool buddies, const char *chat, const char *chat_name) {
ht_lead_in_t in = {.id = id, .project = project, .engine = "claude", .local = "h0", .state = state, .order = card.lead_n, .since = since,
.chat = chat, .chat_id = "c0", .chat_name = chat_name, .buddies = buddies,
.buddy = {.present = buddies, .chat_id = "b0", .name = "diego's Buddy", .engine = "codex", .color = "#d6a79a", .cells = 25513, .live = true}};
assert(ht_supertab_lead_add(&card, &in));
}
static void pair_face(const char *state, long since, bool buddies, const char *chat, const char *chat_name) {
buddy_setup();
card_begin("s1", "t1", "openharness"); pair_lead("B0", "web-api", state, since, buddies, chat, chat_name);
pair_lead("B1", "firmware", "done", -1, buddies, "lead", "Lead"); assert(!card_send());
enter_at("s1", "B0"); swarm_sent = 0; scene_take();
}
// No side or select frame went out after wire slot `from`: a vertical swipe sends nothing (a recap retry may still go out with time).
static bool no_side_since(int from) {
for (int k = from; k < swarm_sent; k++) if (strstr(swarm_wire[k], "side") || strstr(swarm_wire[k], "select")) return false;
return true;
}
// PERSONAL | TEAM (spec 2026-11-05): cards by id in list order; "sp" is the reader's Personal Swarm, "s1" and "s3" are Team.
static void pick_card(const char *id, const char *tab, const char *name, const char *lead, bool personal) {
card_begin(id, tab, name); card.personal = personal;
pair_lead(lead, "web-api", "done", -1, false, "lead", "Lead"); assert(!card_send());
}
static void pick_setup(bool personal, int teams, const char *face) {
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); fake_ms = 100000; desk_open();
const char ids[3][ID_MAX] = {"sp", "s1", "s3"}; char list[3][ID_MAX]; int n = 0;
if (personal) COPY(list[n++], ids[0]);
for (int i = 0; i < teams; i++) COPY(list[n++], ids[1 + i]);
ui_supertabs_ids(list, n);
if (personal) pick_card("sp", "t2", "Personal", "P0", true);
if (teams > 0) pick_card("s1", "t1", "Team A", "A0", false);
if (teams > 1) pick_card("s3", "t0", "Team B", "B0", false);
enter_at(face, NULL); swarm_sent = 0; scene_take();
}
// The picker's two rows (option B, Diego 2026-11-06): 340 x 104 at x 63, Personal at y 120 and Team at y 242.
static int pick_half(void) { // the filled row: 0 Personal, 1 Team, -1 none
for (int i = 0; i < scene.count; i++) {
const ht_run_t *r = &scene.runs[i];
if (r->box.h == 104 && r->w == 340 && r->x == 63 && r->box.fill == ht_rgb(0x2b2d33)) return r->y == 120 ? 0 : r->y == 242 ? 1 : -1;
}
return -1;
}
static bool pick_pill(void) { // both rows drawn, the other one on the dark fill
int rows = 0;
for (int i = 0; i < scene.count; i++) {
const ht_run_t *r = &scene.runs[i];
if (r->box.h == 104 && r->w == 340 && r->x == 63 && (r->y == 120 || r->y == 242)
&& (r->box.fill == ht_rgb(0x2b2d33) || r->box.fill == ht_rgb(0x141518))) rows++;
}
return rows == 2;
}
static bool pick_check_at(int y0) { // the green check on the filled row
for (int i = 0; i < scene.count; i++) if (!strcmp(scene.runs[i].text, HT_DONE) && scene.runs[i].y > y0 && scene.runs[i].y < y0 + 104) return true;
return false;
}
static bool pick_icon_at(int y0) { // a cell sprite icon at the row's left
for (int i = 0; i < scene.count; i++) {
const ht_run_t *r = &scene.runs[i];
if (r->sprite.width && r->x >= 80 && r->x <= 100 && r->y > y0 && r->y < y0 + 104) return true;
}
return false;
}
#define PICK_PERSONAL_X 233
#define PICK_PERSONAL_Y 172
#define PICK_TEAM_Y 294
// Diego (2026-11-06): in a Swarm, a hold on the recap opens Personal | Team; the name keeps opening the project list.
static void hold_at(int x, int y) {
fake_ms += 1000; habitat_touch(true, x, y, fake_ms); surface_tick(fake_ms + 700);
habitat_touch(false, x, y, fake_ms + 760); scene_take();
}
static void hold_recap(void) {
ui_supertab_recap(sw.tab, sw.lead, "c0", "", "Tests green on all three boards.", 1792560000u, false); scene_take();
ht_rect_t c = s.recap_card; assert(c.w && c.h);
hold_at(c.x + c.w / 2, c.y + c.h / 2);
}
static void swarm_pick_checks(const char *dir) {
// The name opens the project list (PANES), even with a Personal and a Team card.
pick_setup(true, 1, "s1");
fake_ms += 1000; tap(fake_ms, 233, 30); assert(s.view == AGENTS);
dispatch((action_t){.kind = A_HOME}); scene_take();
// A hold on the recap opens the picker: "Swarm" on the top arc, one pill, the Swarm on the face (Team) filled.
hold_recap();
assert(s.view == SWARM_PICK && scene_says("Swarm") && scene_says("Personal") && scene_says("Team") && pick_pill() && pick_half() == 1);
// Each row says where it lands: Personal its project count, Team the Swarm it opens; icons left, the check on the filled one.
assert(scene_says("1 project") && scene_says("Team A") && pick_check_at(242) && !pick_check_at(120));
assert(pick_icon_at(120) && pick_icon_at(242));
portrait(dir, "pick-team");
// Personal by a thumb's press (drifting, held): the Personal card's first Lead on the face, the desktop told as for a tab pick.
thumb(PICK_PERSONAL_X, PICK_PERSONAL_Y, 14, 10, 500);
assert(s.view == HOME && !strcmp(sw.tab, "sp") && !strcmp(sw.lead, "P0") && wire_has(0, "select sp P0"));
hold_recap();
assert(s.view == SWARM_PICK && pick_half() == 0 && pick_check_at(120) && !pick_check_at(242));
portrait(dir, "pick-personal");
// The filled half only returns, unchanged and silent.
swarm_sent = 0; fake_ms += 1000; tap(fake_ms, PICK_PERSONAL_X, PICK_PERSONAL_Y);
assert(s.view == HOME && !strcmp(sw.tab, "sp") && swarm_sent == 0);
// Team goes to the last non-Personal card shown, else the first in list order.
pick_setup(true, 2, "s3");
swarm_enter(ht_supertabs_find(&swarm, "sp"), NULL, true); scene_take();
hold_recap(); assert(s.view == SWARM_PICK);
fake_ms += 1000; tap(fake_ms, PICK_PERSONAL_X, PICK_TEAM_Y);
assert(s.view == HOME && !strcmp(sw.tab, "s3") && !strcmp(sw.lead, "B0") && wire_has(0, "select s3 B0"));
pick_setup(true, 2, "sp");
hold_recap(); assert(s.view == SWARM_PICK);
fake_ms += 1000; tap(fake_ms, PICK_PERSONAL_X, PICK_TEAM_Y);
assert(s.view == HOME && !strcmp(sw.tab, "s1") && !strcmp(sw.lead, "A0"));
// The desktop's focus (supertab.focus) while the picker is open never closes it: a tap meant for a row talked to the
// face instead (Diego's dial, 2026-11-06 14:38).
pick_setup(true, 1, "s1");
hold_recap(); assert(s.view == SWARM_PICK);
ui_supertab_focus("s1", "A0"); scene_take(); assert(s.view == SWARM_PICK);
ui_supertab_focus("sp", "P0"); scene_take(); assert(s.view == SWARM_PICK && !strcmp(sw.tab, "s1"));
fake_ms += 1000; tap(fake_ms, PICK_PERSONAL_X, PICK_PERSONAL_Y);
assert(s.view == HOME && !strcmp(sw.tab, "sp"));
// Idle: 5 s with no touch returns to the same Lead and side, and sends no select or side frame.
pick_setup(true, 1, "s1");
hold_recap(); assert(s.view == SWARM_PICK);
swarm_sent = 0; fake_ms += 4000; surface_tick(fake_ms); assert(s.view == SWARM_PICK);
fake_ms += 1000; surface_tick(fake_ms); scene_take();
assert(s.view == HOME && !strcmp(sw.tab, "s1") && !strcmp(sw.lead, "A0") && no_side_since(0)); // (a recap retry may still go out with time)
// A finger held down past the idle deadline does not make the wake 1 ms on every pass (the picker waits for the lift).
pick_setup(true, 1, "s1");
hold_recap(); assert(s.view == SWARM_PICK && s.pick_until);
sw.retried = true; // the recap's own 5 s retry is not under test
s.touch_down = true; fake_ms = s.pick_until + 500; assert(habitat_next_wake_ms() > 1); s.touch_down = false;
assert(habitat_next_wake_ms() == 1); // and once lifted the deadline is due
// No picker without both a Personal card and another: the hold opens the tabs, as on any face.
pick_setup(true, 0, "sp");
hold_recap(); assert(s.view == TABS);
pick_setup(false, 2, "s1");
hold_recap(); assert(s.view == TABS);
// A hold off the recap (on the pet) opens the tabs too.
pick_setup(true, 1, "s1");
ui_supertab_recap(sw.tab, sw.lead, "c0", "", "Tests green.", 1792560000u, false); scene_take();
hold_at(233, 110); assert(s.view == TABS);
}
static void swarm_pair_checks(const char *dir) {
// Drawn: 180 x 44 at y 388, "PM" lit, no side dots, no lower-arc hint, no unread bell.
buddy_setup();
assert(pair_pill() && pm_dots() && scene_says("PM") && scene_says("Buddy") && !arc2_text() && !bell_at(346) && !bell_at(400));
assert(!disc_at(442, 218, 12, 0xeaeaf0) && !disc_at(442, 218, 9, 0x55565f));
FOCUS_PAGE("pair-pm");
// A notice off the face: its count is a badge on the pet's shoulder, no pill.
assert(ui_supertab_notice("s1", "B1", HT_CHAT_LEAD, "lead-fw", "", "Flashed.", 1792560001u));
scene_take(); assert(badge_rect(NULL) && !bell_at(346) && !bell_at(400) && pair_pill());
FOCUS_PAGE("pair-bell");
// Tap Buddy: the side switches and the daemon is told; tapping it again does nothing; PM goes back.
pair_buddy();
assert(swarm_side_buddy("s1") && wire_has(0, "side s1 buddy") && swarm_sent == 1 && buddy_dots() && lilac_ring());
FOCUS_PAGE("pair-buddy");
pair_buddy(); assert(swarm_sent == 1 && buddy_dots());
pair_pm();
assert(!swarm_side_buddy("s1") && wire_has(1, "side s1 pm") && swarm_sent == 2 && pm_dots() && !lilac_ring());
pair_pm(); assert(swarm_sent == 2);
// Vertical swipes are inert on the face, with or without a notice: no side, no inbox, no frame.
int sent = swarm_sent;
swipe_up(); assert(!swarm_side_buddy("s1") && s.view == HOME && no_side_since(sent));
swipe_down(); assert(!swarm_side_buddy("s1") && s.view == HOME && no_side_since(sent));
pair_buddy(); sent = swarm_sent;
swipe_up(); swipe_down(); assert(swarm_side_buddy("s1") && s.view == HOME && no_side_since(sent));
pair_pm();
// The pet, with its badge, opens the inbox.
{ ht_rect_t b; assert(badge_rect(&b)); tap(fake_ms += 1000, b.x - 20, b.y + 30); assert(s.view == INBOX); }
dispatch((action_t){.kind = A_HOME}); scene_take();
// Hits: the halves as a thumb's targets, 130 px wide each from y 382 (under the bell) to the edge, meeting at x 233.
{ bool pm = false, bu = false;
for (int i = 0; i < s.hit_count; i++) {
if (s.hits[i].action == A_SIDE_PM) pm = s.hits[i].rect.x == 103 && s.hits[i].rect.y == 382 && s.hits[i].rect.w == 130 && s.hits[i].rect.h == HT_HEIGHT - 382;
if (s.hits[i].action == A_SIDE_BUDDY) bu = s.hits[i].rect.x == 233 && s.hits[i].rect.y == 382 && s.hits[i].rect.w == 130 && s.hits[i].rect.h == HT_HEIGHT - 382;
}
assert(pm && bu); }
// The empty Buddy side keeps the pair, so the person can come back.
pair_face("done", -1, true, "lead", "Lead"); card_begin("s1", "t1", "openharness");
{ ht_lead_in_t in = {.id = "B0", .project = "web-api", .engine = "claude", .local = "h0", .state = "done", .order = 0, .since = -1,
.chat = "lead", .chat_id = "c0", .chat_name = "Lead", .buddies = true}; assert(ht_supertab_lead_add(&card, &in)); }
card_send(); pair_buddy(); assert(scene_says("No Buddy here yet") && buddy_dots());
pair_pm(); assert(pm_dots() && !scene_says("No Buddy"));
// No pair without Buddies: the bell keeps y 400, vertical swipes are still inert.
pair_face("done", -1, false, "lead", "Lead");
assert(!pair_pill() && !scene_says("Buddy") && !run_at("PM", 399));
assert(ui_supertab_notice("s1", "B1", HT_CHAT_LEAD, "lead-fw", "", "Flashed.", 1792560001u));
scene_take(); assert(badge_rect(NULL) && !bell_at(400) && !bell_at(346));
sent = swarm_sent; swipe_up(); swipe_down(); assert(s.view == HOME && no_side_since(sent));
// No "PM" line under the name for the PM chat; a group keeps its name.
pair_face("done", -1, false, "pm", "PM");
assert(!scene_says("PM"));
pair_face("done", -1, true, "pm", "PM");
for (int i = 0; i < scene.count; i++) assert(strcmp(scene.runs[i].text, "PM") || scene.runs[i].y >= 388);
pair_face("done", -1, false, "group", "Launch crew");
assert(scene_says("Launch crew"));
// Working: the line is centred at y 318, none on the lower arc.
pair_face("work", 12, true, "lead", "Lead");
assert(pair_pill() && !arc2_text());
{ bool found = false;
for (int i = 0; i < scene.count; i++) {
const ht_run_t *r = &scene.runs[i];
if (r->y == 318 && r->text[0] && !r->arc && strstr(r->text, "0:12")) { found = true; assert(r->x + r->w / 2 >= 231 && r->x + r->w / 2 <= 235); }
}
assert(found); }
FOCUS_PAGE("pair-working");
// "Your Buddy replied" is the same line, at y 318, beside a bell.
buddy_setup();
ui_supertab_recap("s1", "B0", "lead-web", "", "Assigned #2083.", 1792560000u, false);
assert(!ui_supertab_notice("s1", "B0", HT_CHAT_BUDDY, "b0", "", "Cache it.", 1792560002u));
assert(ui_supertab_notice("s1", "B1", HT_CHAT_LEAD, "lead-fw", "", "Flashed.", 1792560003u));
scene_take(); assert(run_at("Your Buddy replied", 318) && badge_rect(NULL) && !bell_at(346) && !arc2_text());
FOCUS_PAGE("pair-replied");
// A thread face: the pair replaces its side dots, and a sideways swipe still leaves the thread.
buddy_setup();
card_begin("s1", "t1", "openharness");
{ ht_lead_in_t in = {.id = "B0", .project = "web-api", .engine = "claude", .local = "h0", .state = "done", .order = 0, .since = -1,
.chat = "pm", .chat_id = "pm1", .chat_name = "PM", .thread = "m9", .thread_title = "Fix the login bug", .thread_replies = 1,
.buddies = true, .buddy = {.present = true, .chat_id = "b0", .name = "diego's Buddy", .engine = "codex", .color = "#d6a79a", .cells = 25513, .live = true}};
assert(ht_supertab_lead_add(&card, &in)); }
assert(!card_send()); enter_at("s1", "B0"); swarm_sent = 0; scene_take();
assert(scene_says("Thread") && pair_pill() && pm_dots());
FOCUS_PAGE("pair-thread");
pair_buddy(); assert(swarm_side_buddy("s1") && buddy_dots());
pair_pm();
swipe_next(); assert(wire_has(0, "thread-leave s1 B0"));
// Audit: a creature skin draws its bell above the pair too, and its tap opens the inbox from there.
pair_face("done", -1, true, "lead", "Lead"); ht_character_select(&character, HT_CHARACTER_TIM);
assert(ui_supertab_notice("s1", "B1", HT_CHAT_LEAD, "lead-fw", "", "Flashed.", 1792560001u));
scene_take();
{ bool above = false, under = false;
for (int i = 0; i < scene.count; i++) if (scene.runs[i].font == &ht_bell_footer) { if (scene.runs[i].y < 388 && scene.runs[i].y + scene.runs[i].font->height <= 388) above = true; else under = true; }
assert(above && !under && pair_pill());
bool hit = false;
for (int i = 0; i < s.hit_count; i++) if (s.hits[i].action == A_INBOX && s.hits[i].rect.y == 346 - 18) hit = true;
assert(hit); }
pair_buddy(); assert(swarm_side_buddy("s1")); pair_pm(); assert(!swarm_side_buddy("s1"));
tap(fake_ms += 1000, 233, 350); assert(s.view == INBOX);
dispatch((action_t){.kind = A_HOME});
// Without Buddies a creature skin keeps its bell where it was, under the companion at HT_NOTIFICATION_Y.
pair_face("done", -1, false, "lead", "Lead"); ht_character_select(&character, HT_CHARACTER_TIM);
assert(ui_supertab_notice("s1", "B1", HT_CHAT_LEAD, "lead-fw", "", "Flashed.", 1792560001u));
scene_take();
{ bool home = false; for (int i = 0; i < scene.count; i++) if (scene.runs[i].font == &ht_bell_footer) { assert(scene.runs[i].y == HT_NOTIFICATION_Y); home = true; }
assert(home && !pair_pill()); }
dispatch((action_t){.kind = A_HOME});
// Audit: a thread face with the pair and the bell holds its card to two lines, clear of the bell at y 346.
buddy_setup();
card_begin("s1", "t1", "openharness");
{ ht_lead_in_t in = {.id = "B0", .project = "web-api", .engine = "claude", .local = "h0", .state = "done", .order = 0, .since = -1,
.chat = "pm", .chat_id = "pm1", .chat_name = "PM", .thread = "m9", .thread_title = "Fix the login bug on Safari when the session expires", .thread_replies = 2,
.buddies = true, .buddy = {.present = true, .chat_id = "b0", .name = "diego's Buddy", .engine = "codex", .color = "#d6a79a", .cells = 25513, .live = true}};
assert(ht_supertab_lead_add(&card, &in)); }
pair_lead("B1", "firmware", "done", -1, true, "lead", "Lead");
assert(!card_send()); enter_at("s1", "B0"); swarm_sent = 0;
ui_supertab_recap("s1", "B0", "pm1", "m9", "Taken: Milo fixes the login bug now and Quinn reviews it before the end of the day, then we ship the release to everyone on the beta channel.", 1792560000u, false);
assert(ui_supertab_notice("s1", "B1", HT_CHAT_LEAD, "lead-fw", "", "Flashed.", 1792560001u));
scene_take();
assert(scene_says("PM \xc2\xb7 2 replies") && bell_at(346) && !badge_rect(NULL)); // a thread has no pet: the pill
for (int i = 0; i < scene.count; i++) { const ht_run_t *r = &scene.runs[i]; if (r->text[0] && r->y < 388 && ht_run_bounds(r).y + ht_run_bounds(r).h > 340 && r->y > 100 && r->font != &ht_bell_footer && r->box.h != 32 && r->x < 150) { fprintf(stderr, "card run y=%d \"%s\"\n", r->y, r->text); assert(false); } }
{ bool dots = false; for (int i = 0; i < scene.count; i++) if (strstr(scene.runs[i].text, "\xe2\x80\xa6")) dots = true; assert(dots); }
// A thumb's press on a half switches the side and never starts voice: drifting 16 px, held half a second, or landing
// just off the drawn pill (below it, or beside it).
pair_face("done", -1, true, "lead", "Lead");
thumb(270, 404, 14, 8, 500); assert(swarm_side_buddy("s1") && s.view == HOME && !s.voice_open);
thumb(190, 404, -12, 10, 450); assert(!swarm_side_buddy("s1") && s.view == HOME && !s.voice_open);
thumb(300, 446, 0, 0, 120); assert(swarm_side_buddy("s1") && !s.voice_open); // under the pill
thumb(130, 410, 0, 0, 120); assert(!swarm_side_buddy("s1") && !s.voice_open); // beside it
// Dragged far off the pill it is no press: nothing switches.
thumb(278, 410, 0, -150, 300); assert(!swarm_side_buddy("s1") && !s.voice_open);
// Option B (Diego's dial, 2026-11-05): over a four-line reply the badge sits on the pet, well above the card, and nothing
// overlaps the card; a tap on the pet opens the notices, and with nothing unread it talks as before.
{
const char *say = "Noted. That doesn't look like work for this project, so I'm not opening anything for it. If you want a task, tell me which project and what done looks like.";
pair_face("done", -1, true, "lead", "Lead");
ui_supertab_recap("s1", "B0", "c0", "", say, 1792560000u, false); scene_take();
ht_rect_t b;
assert(!badge_rect(NULL));
int card_top = HT_HEIGHT;
for (int i = 0; i < scene.count; i++) if (scene.runs[i].box.h > 100 && scene.runs[i].w >= 300) card_top = scene.runs[i].y;
assert(card_top < 300);
tap(fake_ms += 1000, 233, 112); assert(s.view != INBOX);
if (s.view != HOME) dispatch((action_t){.kind = A_HOME});
pair_face("done", -1, true, "lead", "Lead");
ui_supertab_recap("s1", "B0", "c0", "", say, 1792560000u, false);
assert(ui_supertab_notice("s1", "B1", HT_CHAT_LEAD, "lead-fw", "", "Flashed.", 1792560001u));
scene_take();
assert(badge_rect(&b) && b.y + b.h + 3 < card_top && !bell_at(346));
for (int i = 0; i < scene.count; i++) { // nothing blue on the card or the pair
const ht_run_t *r = &scene.runs[i];
if (r->box.h && r->box.fill == ht_rgb(0x006fff)) assert(r->y + r->box.h < card_top);
}
FOCUS_PAGE("badge-long");
tap(fake_ms += 1000, 233, 112); assert(s.view == INBOX);
dispatch((action_t){.kind = A_HOME}); scene_take();
// A swipe that starts on the badged pet still moves to the next project; a hold still opens the tabs.
assert(ui_supertab_notice("s1", "B1", HT_CHAT_LEAD, "lead-fw2", "", "Flashed again.", 1792560009u)); scene_take();
assert(badge_rect(NULL) && !strcmp(sw.lead, "B0"));
fake_ms += 1000; habitat_touch(true, 300, 120, fake_ms); habitat_touch(false, 130, 120, fake_ms + 120); scene_take();
assert(!strcmp(sw.lead, "B1") && s.view == HOME);
// The Buddy side: the badge on the Buddy's disc.
buddy_setup();
assert(ui_supertab_notice("s1", "B1", HT_CHAT_LEAD, "lead-fw", "", "Flashed.", 1792560001u));
pair_buddy(); assert(swarm_side_buddy("s1") && badge_rect(&b) && !bell_at(346));
FOCUS_PAGE("badge-buddy");
pair_pm();
}
puts("Swarm PM | Buddy pair: drawn at y 388, taps switch sides, vertical swipes inert, the bell opens the inbox at y 346 (400 without Buddies), no PM line, the working line at y 318 PASS");
}
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);
bell_checks(argc>1 ? argv[1] : NULL);
swarm_tabs_checks(argc>1 ? argv[1] : NULL);
swarm_pane_checks(argc>1 ? argv[1] : NULL);
swarm_inbox_checks(argc>1 ? argv[1] : NULL);
swarm_voice_checks(argc>1 ? argv[1] : NULL);
// The companion screen is gone: character, edge text and still-character are the app's now
// (Settings > Autonomous robots). What the glass kept is actions, and Nap is the one that moved
// off that screen into the controls list.
// Artwork can switch during an existing voice session without touching its owner or audio. The
// switch arrives from the app now, so it is ht_character_select that has to be safe here.
reset(); tap(1000,233,220); assert(recording && starts==1);
assert(ht_character_select(&character,(ht_character_id_t)((character.id+1)%HT_CHARACTER_COUNT)));
assert(recording && s.voice_open && s.view==VOICE && starts==1 && !stops && !strcmp(target,"a"));
const char *brightness = getenv("HABITAT_PREVIEW_BRIGHTNESS");
if (brightness) {
char *end; long value = strtol(brightness, &end, 10);
assert(*brightness && !*end && value >= 0 && value <= 100);
preview_brightness = (unsigned)value;
}
// Identity boundaries are exact, including IDs that share a full-length prefix.
{
reset();
char exact[ID_MAX], oversized[ID_MAX+1];
memset(exact,'a',sizeof exact-1);exact[sizeof exact-1]=0;
snprintf(oversized,sizeof oversized,"%sx",exact);
int count=s.count, target=ensure(exact);assert(target==count);
assert(ensure(oversized)==-1 && s.count==count+1);
assert(ensure(NULL)==-1 && ensure("")==-1);
strcpy(s.pending_focus,"b");ui_focus_project(oversized);
assert(!strcmp(s.pending_focus,"b"));
s.active=0;ui_apply_pending_focus();assert(s.active==1 && !s.pending_focus[0]);
ui_focus_project(exact);assert(s.active==target);
notice_add(exact,"Exact target","M2","This target fits.",false,false);
unsigned exact_notices=s.notice_count;
notice_add(oversized,"Wrong target","M2","Must not alias another pane.",false,false);
assert((unsigned)s.notice_count==exact_notices && !strcmp(s.notice[0].agent_id,exact));
reset();
}
const char *dir = argc > 1 ? argv[1] : NULL;
recap_checks(dir);
notice_checks(dir);
pane_memory_checks(dir);
pane_notification_soak();
carry_return_setup(true);
assert(action_enabled(A_RETURN) && action_enabled(A_CARRY_DROP));
portrait(dir,"carry-return");
tap(1000,173,410);
assert(visit.pending && visit.op==HT_VISIT_BACK && carry.active && !carry_drops && !starts);
assert(!strcmp(carry.id,"carried-passage") && !strcmp(carry.excerpt,"Keep this paragraph"));
assert(!down_reports && !moves && !ups); // A footer is not a terminal contact.
{
char request[32]; snprintf(request,sizeof request,"visit-%lu",(unsigned long)visit.request);
cJSON fields[]={
{.string="requestId",.type=JSTRING,.valuestring=request},
{.string="visitId",.type=JSTRING,.valuestring=visit.id},
{.string="agentId",.type=JSTRING,.valuestring="a"},
{.string="ok",.type=JTRUE}};
for(int i=0;i<3;i++)fields[i].next=&fields[i+1];
cJSON reply={.child=fields}; ui_visit_state(&reply); scene_take();
assert(s.view==HOME && !visit.available && carry.active && !carry_drops);
assert(action_enabled(A_CARRY_DROP) && !action_enabled(A_RETURN));
portrait(dir,"carry-after-return");
}
carry_return_setup(true); scene_take();
tap(1000,317,413); // Near the bezel, where the rim gesture used to take it.
assert(!carry.active && carry_drops==1 && visit.available && !visit.pending);
assert(!starts && !switches && !down_reports && !moves && !ups);
tap(1700,233,420); assert(visit.pending && visit.op==HT_VISIT_BACK);
carry_return_setup(true); scene_take();
tap(1000,173,413); assert(visit.pending && carry.active && !carry_drops && !moves);
carry_return_setup(false); scene_take();
tap(1000,233,425); assert(visit.pending && !starts && !moves && !down_reports);
// Sliding off either button, crossing to the other one, or a sensor loss
// cannot discard, navigate, scroll, or start speech.
{
static const int drags[][4]={{173,410,317,410},{317,410,173,410},{173,410,233,250},{317,410,233,250}};
for(size_t i=0;i<sizeof drags/sizeof drags[0];i++) {
carry_return_setup(true); scene_take();
habitat_touch(true,drags[i][0],drags[i][1],1000);
habitat_touch(true,drags[i][2],drags[i][3],1070);
habitat_touch(false,drags[i][2],drags[i][3],1150);
assert(carry.active && visit.available && !visit.pending && !carry_drops && visit_sends==1);
assert(!starts && !switches && !down_reports && !moves && !ups);
}
}
carry_return_setup(true); habitat_touch(true,173,410,1000); habitat_touch_cancel();
habitat_touch(false,173,410,1100); assert(!visit.pending && carry.active && !carry_drops);
carry_return_setup(true); s.coasting=true; s.coast_until=2000;
tap(1000,317,410); assert(carry.active && !carry_drops && down_reports==1 && ups==1);
tap(1700,317,410); assert(!carry.active && carry_drops==1 && visit.available);
carry_return_setup(true); congestion=true; tap(1000,173,410);
assert(!visit.pending && visit.available && carry.active && !carry_drops && s.view==MESSAGE);
congestion=false; view(HOME); scene_take(); tap(1700,173,410); assert(visit.pending && carry.active);
carry_return_setup(true); s.connected=false; scene_take();
assert(!action_enabled(A_RETURN) && !action_enabled(A_CARRY_DROP));
tap(1000,173,410); assert(!visit.pending && carry.active);
tap(1700,317,410); assert(carry.active && !carry_drops);
s.connected=true; scene_take();
tap(2400,317,410); assert(!carry.active && carry_drops==1);
// Expiry changes the carry identity. An old finger cannot drop a new quote.
carry_return_setup(true); habitat_touch(true,317,410,1000);
assert(ht_carry_tick(&carry,300250)); scene_take(); portrait(dir,"carry-expired-return");
assert(action_enabled(A_RETURN) && action_enabled(A_CARRY_DROP));
ht_carry_open(&carry,"replacement-passage","a","pick-test",1,1100,carry_emit,NULL);
assert(ht_carry_reply(&carry,carry.id,carry.request,true,"New source","New quote",1,300000,NULL,1101));
int drops=carry_drops; habitat_touch(false,317,410,1150);
assert(carry.active && !strcmp(carry.id,"replacement-passage") && carry_drops==drops);
carry_return_setup(true); habitat_touch(true,173,410,1000);
ht_visit_close(&visit);
assert(ht_visit_latest(&visit,"new-reading","b",1100,visit_emit,NULL));
assert(ht_visit_reply(&visit,visit.id,visit.request,true,"Different reading"));
int sends=visit_sends; habitat_touch(false,173,410,1150);
assert(!visit.pending && visit.available && visit_sends==sends && carry.active);
reset(); s.view=SETTINGS; s.offset=6; scene_take(); assert(action_enabled(A_LATEST)); portrait(dir,"reading-controls");
tap(1000,233,272); assert(visit.pending && visit.op==HT_VISIT_LATEST && visit_sends==1 && !starts);
action_t old_visit=visit_queued; visit_work(old_visit); assert(visit_wire==1 && !strcmp(visit_wire_op,"latest"));
char visit_request[32]; snprintf(visit_request,sizeof visit_request,"visit-%lu",(unsigned long)visit.request);
cJSON visit_fields[]={
{.string="requestId",.type=JSTRING,.valuestring=visit_request},
{.string="visitId",.type=JSTRING,.valuestring=visit.id},
{.string="agentId",.type=JSTRING,.valuestring="a"},
{.string="label",.type=JSTRING,.valuestring="Your reading"},
{.string="ok",.type=JTRUE},{.string="active",.type=JTRUE}};
for(int i=0;i<5;i++)visit_fields[i].next=&visit_fields[i+1];
cJSON visit_reply={.child=visit_fields};
question_pending=true; ui_visit_state(&visit_reply); scene_take();
assert(s.view==HOME && visit.available && !visit.pending && !starts); // Latest never opens a question.
portrait(dir,"reading-return");
tap(2000,233,410); assert(visit.pending && visit.op==HT_VISIT_BACK);
visit_work(visit_queued); assert(visit_wire==2 && !strcmp(visit_wire_op,"back"));
snprintf(visit_request,sizeof visit_request,"visit-%lu",(unsigned long)visit.request);
visit_fields[5].type=0; ui_visit_state(&visit_reply); assert(!visit.available && s.view==HOME);
reset(); dispatch((action_t){.kind=A_LATEST,.id="a"}); old_visit=visit_queued;
ht_visit_close(&visit); visit_work(old_visit); assert(!visit_wire); // A cancelled queued action cannot jump later.
dispatch((action_t){.kind=A_LATEST,.id="a"}); visit_work(old_visit); assert(!visit_wire && visit.pending);
reset(); s.view=SETTINGS; s.offset=6; scene_take(); habitat_touch(true,233,272,1000); s.active=1;
habitat_touch(false,233,272,1080); assert(!visit_sends && !starts); // Destination changed under the finger.
reset(); s.view=SETTINGS; s.offset=6; scene_take(); congestion=true;
tap(1000,233,272); 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(""));
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==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.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);
// The visible top name keeps a stable pane-picker target. Notifications
// use a separate bottom bell; top name/activity share one stable target.
const int update_contacts[][2]={{233,28},{233,41},{100,49},{366,49},{233,61}};
for (int question=0;question<2;question++) for (unsigned i=0;i<sizeof update_contacts/sizeof update_contacts[0];i++) {
workspace_setup(); s.notice_count=1; waiting_count=question; active()->busy=true; scene_take();
assert(action_enabled(A_INBOX) && action_enabled(A_AGENTS) && !action_enabled(A_TABS));
bool label=false;
for (int j=0;j<scene.count;j++) {
assert(strcmp(scene.runs[j].text,"[1]"));
if(!strcmp(scene.runs[j].text,active()->name)) {
assert(scene.runs[j].arc==1); label=true;
}
}
assert(label);
tap(1000,update_contacts[i][0],update_contacts[i][1]);
assert(s.view==AGENTS && !tab_switches && !starts);
}
workspace_setup(); s.notice_count=1; scene_take(); portrait(dir,"clear-notification");
// Long top labels curve below y=66. Their visible end letters must
// remain caption targets, even where the old rectangle reached the portrait.
for(int length=11;length<=HT_ARC_COLS;length++) for(int side=-1;side<=1;side+=2) for(int dy=-6;dy<=6;dy+=6) {
workspace_setup();s.notice_count=1;active()->busy=true;
memset(active()->name,'x',(size_t)length);active()->name[length]=0;scene_take();
int x=233+side*(205*arc_trig[length-1][0]>>14);
int y=233-(205*arc_trig[length-1][1]>>14)+dy;
tap(1000,x,y);assert(s.view==AGENTS&&!starts&&!tab_switches&&!moves);
}
workspace_setup();s.notice_count=1;active()->busy=true;
strcpy(active()->tool,"Recontextualizing");scene_take();portrait(dir,"long-curved-notification");
tap(1000,233,220);assert(starts==1&&s.view==VOICE); // the central companion still speaks
workspace_setup(); s.notice_count=1; active()->busy=true; scene_take();
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
// 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);
// 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);
workspace_setup(); s.notice_count=1; scene_take(); s.notice_count=0; scene_take();
assert(!action_enabled(A_TABS) && !action_enabled(A_INBOX));
workspace_setup(); fake_ms=30000; surface_tick(fake_ms);
ui_notify_task_done("b","Other pane","M2","Finished.");
assert(s.pet_pose==3 && s.pet_until==32000);
fake_ms=30010; surface_tick(fake_ms); scene_take(); portrait(dir,"notification-glance-right");
assert(character.motion.reaction.pose.look==2);
fake_ms=30170; surface_tick(fake_ms); scene_take(); portrait(dir,"mail-lift");
assert(!character.delivery.moving && !character.delivery.lift && status_is(HT_BELL " 1"));
fake_ms=30400; surface_tick(fake_ms); scene_take(); portrait(dir,"notification-glance-left");
assert(character.motion.reaction.pose.look==-2);
surface_tick(30860); assert(character.motion.reaction.pose.blink);
surface_tick(31400); assert(!character.motion.reaction.pose.look && !character.motion.reaction.pose.blink);
s.pet_pose=0; fake_ms=33000; surface_tick(fake_ms); scene_take();
assert(character_mood()!=HT_TIM_DONE && action_enabled(A_INBOX)); portrait(dir,"unread-persistent");
active()->recap_ready=true;
strcpy(active()->preview,"The update is ready. All checks pass.");
scene_take(); portrait(dir,"mail-with-summary");
active()->recap_ready=false; active()->preview[0]=0;
cable_notif_t restored={.agent_id="b",.name="Other pane",.summary="Finished."};
ui_notif_replace(&restored,1); assert(!s.pet_pose); // history never replays a celebration
waiting_count=1; surface_tick(33500); scene_take(); portrait(dir,"needs-attention");
assert(character_mood()==HT_TIM_ATTENTION);
surface_tick(60000); assert(character_mood()==HT_TIM_ATTENTION); // persists until resolved
waiting_count=0; surface_tick(61000); assert(character_mood()!=HT_TIM_ATTENTION);
ui_notif_seen("b"); assert(!s.notice_count); scene_take(); portrait(dir,"inbox-handled");
// The last seen result exits the inbox even while a finger is on the card.
workspace_setup(); ui_notify_task_done("a","Deploy latest firmware","M2","Installed.");
ui_notif_open(); scene_take(); portrait(dir,"inbox-unread");
assert(s.view==INBOX && action_enabled(A_NOTICE));
habitat_touch(true,233,215,1000); ui_notif_seen("a"); scene_take();
assert(s.view==HOME && !s.notice_count && s.touch_cancelled);
habitat_touch(false,233,215,1100); assert(!starts && !desktop_opens);
ui_notif_open(); assert(s.view==HOME); // no empty-inbox dead end
// Snapshot reconciliation is atomic: replacing the only row stays in inbox.
cable_notif_t notices[2]={
{.agent_id="a",.name="Deploy latest firmware",.machine="M2",.summary="Installed."},
{.agent_id="b",.name="Research",.machine="M2",.summary="Which branch?",.question=true}};
ui_notif_replace(notices,1); ui_notif_open();
ui_notif_replace(notices,1); assert(s.view==INBOX && s.notice_count==1);
ui_notif_replace(notices,2); s.offset=1;
ui_notif_seen("a"); assert(s.view==INBOX && s.notice_count==1 && s.offset==0);
ui_notif_seen("b"); assert(s.view==INBOX && s.notice_count==1); // a glance is not an answer
scene_take(); portrait(dir,"inbox-question");
ui_question_close("b","question-1"); assert(s.view==HOME && !s.notice_count);
ui_notif_replace(notices,1); ui_notif_open(); scene_take();
habitat_touch(true,233,215,2000); ui_notif_replace(NULL,0); scene_take();
assert(s.view==HOME && s.touch_cancelled);
habitat_touch(false,233,215,2100); assert(!starts && !desktop_opens);
// Clearing notifications never interrupts another screen or a live microphone.
s.view=TABS; ui_notif_replace(NULL,0); assert(s.view==TABS);
s.view=VOICE; s.voice_open=true; ui_notif_replace(NULL,0); assert(s.view==VOICE);
// New arrivals, repeated updates and reordered host snapshots must preserve
// the message being read. A changed card consumes an in-flight release.
workspace_setup();
ui_notify_task_done("a","First pane","M2","The update is installed. Voice input sends to the selected agent. The summary has more room, the octopus is larger, and unread messages open from the bottom edge of the screen.");
ui_notify_task_done("b","Second pane","M2","All tests pass.");
ui_notif_open(); s.offset=1; scene_take(); portrait(dir,"notification-long-reading");
assert(!strcmp(s.notice[s.offset].agent_id,"a"));
habitat_touch(true,233,250,3000);
ui_notify_task_done("c","Third pane","M2","The build is ready.");
assert(!strcmp(s.notice[s.offset].agent_id,"a")&&s.touch_cancelled);
habitat_touch(false,233,250,3100);assert(!desktop_opens&&!starts);
ui_notify_task_done("a","First pane","M2","A newer result from the same pane.");
assert(!strcmp(s.notice[s.offset].agent_id,"a")&&s.offset==0);
cable_notif_t reordered[3]={
{.agent_id="d",.name="Fourth",.summary="The deploy is complete."},
{.agent_id="a",.name="First pane",.summary="A newer result from the same pane."},
{.agent_id="b",.name="Second pane",.summary="All tests pass."}};
ui_notif_replace(reordered,3);assert(!strcmp(s.notice[s.offset].agent_id,"a")&&s.offset==1);
ui_notif_seen("d");assert(!strcmp(s.notice[s.offset].agent_id,"a")&&s.offset==0);
scene_take();tap(3700,150,430);assert(s.view==HOME&&!desktop_opens&&!starts);
ui_notif_open();scene_take();tap(4400,233,260);
assert(desktop_opens==1&&!strcmp(opened_agent,"b")&&!starts); // Reopening chooses the remaining unread card.
// A full inbox evicts another row instead of the oldest card being read.
workspace_setup();
for(int i=0;i<NOTICES;i++) {
char id[24];snprintf(id,sizeof id,"notice-%d",i);
ui_notify_task_done(id,"A pane","M2","A complete result to read.");
}
ui_notif_open();s.offset=NOTICES-1;
for(int i=0;i<2*NOTICES;i++) {
char id[24];snprintf(id,sizeof id,"incoming-%d",i);
ui_notify_task_done(id,"New pane","M2","Another result arrived.");
assert(s.notice_count==NOTICES&&!strcmp(s.notice[s.offset].agent_id,"notice-0"));
}
ui_notif_seen(NULL);assert(s.notice_count==NOTICES);
ui_notif_replace(NULL,1000);assert(s.view==HOME&&!s.notice_count);
// 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==4 && !action_enabled(A_UP) && !action_enabled(A_DOWN));
assert(action_enabled(A_TAB_DONE) && !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(scene.runs[i].bg==BG); // no list boxes or alternating row fills
}
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"));
}
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==1 && !strcmp(tab_target,"tab-2") && !starts && !moves);
portrait(dir,"tabs-dragging");
habitat_touch(false,220,233,3150); scene_take();
assert(tab_carousel.animating && tab_switches==1 && !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==1 && !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(s.view==TABS && tab_switches==1 && !strcmp(tab_target,chosen_id));
// Host echoes and replacement panes must not break a live drag. Newer
// pages supersede earlier requests; only the latest roster can finish it.
workspace_setup(); dispatch((action_t){.kind=A_TABS}); scene_take();
habitat_touch(true,300,233,3000); habitat_touch(true,240,233,3120);
uint32_t first_tab_serial=workspace.serial;
assert(tab_switches==1 && !strcmp(tab_target,"tab-2") && tab_carousel.touching);
ui_swarms_replace(s.tabs,s.tab_count,"tab-2");
assert(!s.touch_cancelled && tab_carousel.touching);
assert(ht_workspace_refresh(&workspace,first_tab_serial,10));
ui_focus_project("b"); ui_project_remove("b");
assert(!s.touch_cancelled && tab_carousel.touching);
habitat_touch(true,120,233,3420);
assert(tab_switches==2 && !strcmp(tab_target,"tab-3") && workspace.serial!=first_tab_serial);
ui_workspace_applied("tab-2",11); ui_land_after_reload();
assert(s.loading && s.view==TABS && !s.touch_cancelled);
ui_swarms_replace(s.tabs,s.tab_count,"tab-2");
assert(ht_tab_carousel_index(&tab_carousel)==3 && workspace.phase==HT_WORKSPACE_WAIT_TAB);
ui_project_clear_all(); assert(!s.touch_cancelled && tab_carousel.touching);
habitat_touch(false,120,233,3500); surface_tick(3800); scene_take();
ui_swarms_replace(s.tabs,s.tab_count,"tab-3");
assert(ht_workspace_refresh(&workspace,workspace.serial,11));
ui_workspace_applied("tab-3",12); ui_land_after_reload();
assert(s.view==TABS && !s.loading && workspace.phase==HT_WORKSPACE_IDLE);
// A desktop/TUI selection also moves an idle picker, without echoing it.
ui_swarms_replace(s.tabs,s.tab_count,"tab-0"); surface_tick(3900); scene_take();
assert(ht_tab_carousel_index(&tab_carousel)==0 && tab_switches==2);
tap(4100,233,420); assert(s.view==HOME && tab_switches==2 && !starts);
// Tapping a visible neighbor previews that exact tab without closing the picker.
workspace_setup(); dispatch((action_t){.kind=A_TABS}); scene_take();
tap(4000,80,233); assert(s.view==TABS && tab_switches==1 && !strcmp(tab_target,"tab-0") && !starts);
workspace_setup(); dispatch((action_t){.kind=A_TABS}); scene_take();
tap(4000,386,233); assert(s.view==TABS && tab_switches==1 && !strcmp(tab_target,"tab-2") && !starts);
// Vertical motion is inert; reversing a horizontal drag switches back live.
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(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==2 && !strcmp(tab_target,"tab-1") && s.view==TABS);
// 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);
s.tabs[i].agents=1;
}
strcpy(s.selected_tab,"tab-23"); dispatch((action_t){.kind=A_TABS}); scene_take();
assert(ht_tab_carousel_index(&tab_carousel)==23 && s.hits[0].value==23);
portrait(dir,"tabs-last");
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==23-wanted && !starts && s.view==TABS);
}
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==23 && !starts && s.hit_count==3 && ht_tab_carousel_index(&tab_carousel)==0);
// A tab holding no agent (only shells, or nothing) is not listed.
{
cable_swarm_t mixed[3]={{"shell","Shell",0,1},{"tab-0","M2",1,1},{"none","Nothing",0,0}};
ui_swarms_replace(mixed,3,"shell");
assert(s.tab_count==1 && !strcmp(s.tabs[0].id,"tab-0") && workspace_index("shell")<0);
}
ui_swarms_replace(NULL,0,NULL); scene_take(); portrait(dir,"tabs-empty");
assert(s.view==MESSAGE && !s.loading && workspace.phase==HT_WORKSPACE_IDLE); // removed pending tab fails explicitly
dispatch((action_t){.kind=A_TABS}); scene_take();
assert(s.hit_count==1 && action_enabled(A_TAB_DONE) && !action_enabled(A_TAB));
workspace_setup(); s.connected=false; dispatch((action_t){.kind=A_TABS}); scene_take();
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 Done.
workspace_setup(); snprintf(s.tabs[1].name,sizeof s.tabs[1].name,"%s","A workspace with a longer name for device development");
dispatch((action_t){.kind=A_TABS}); scene_take(); portrait(dir,"tabs-long-name");
bool checkmark=false,back_arrow=false;
for(int i=0;i<scene.count;i++) {
checkmark |= !strcmp(scene.runs[i].text,HT_DONE) && scene.runs[i].font==&ht_done_28;
back_arrow |= !strcmp(scene.runs[i].text,"\xe2\x86\x90");
}
assert(checkmark && !back_arrow && action_enabled(A_TAB_DONE) && !action_enabled(A_HOME));
tap(33000,233,420); assert(s.view==HOME && !tab_switches && !starts);
workspace_setup(); dispatch((action_t){.kind=A_TABS}); scene_take();
ht_tab_carousel_reset(&tab_carousel,s.tab_count,2); congestion=true;
dispatch((action_t){.kind=A_TAB_DONE});
assert(s.view==MESSAGE && !s.loading && workspace.phase==HT_WORKSPACE_IDLE && !tab_switches);
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.
reset(); s.view=INBOX; s.connected=false; dispatch((action_t){.kind=A_NOTICE,.id="a"});
assert(!desktop_opens && !visit_sends);
reset(); s.view=INBOX; congestion=true; dispatch((action_t){.kind=A_NOTICE,.id="a"});
assert(!desktop_opens && s.view==MESSAGE && !visit.pending);
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");
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();
assert(tab_switches==2 && !strcmp(tab_target,"tab-3") && s.loading && s.view==TABS);
tap(4000,233,420); // Done waits for the newest tab and its complete roster.
assert(tab_switches==2 && 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.
ui_workspace_applied("tab-3",3); ui_land_after_reload(); assert(s.loading);
ui_swarms_replace(s.tabs,s.tab_count,"tab-3"); assert(tab_queued.kind==A_TAB_REFRESH);
assert(ht_workspace_refresh(&workspace,serial,10));
ui_workspace_applied("tab-1",11); ui_land_after_reload(); assert(s.loading);
ui_workspace_applied("tab-3",10); ui_land_after_reload(); assert(s.loading);
ui_workspace_applied("tab-3",11); ui_land_after_reload(); assert(!s.loading && s.view==HOME);
assert(workspace.phase==HT_WORKSPACE_IDLE && !starts);
// Empty tabs have a valid receipt too, without inventing a voice recipient.
dispatch((action_t){.kind=A_TAB,.id="tab-0"});
ui_swarms_replace(s.tabs,s.tab_count,"tab-0"); assert(ht_workspace_refresh(&workspace,workspace.serial,11));
s.count=0; s.active=-1; ui_workspace_applied("tab-0",12); ui_land_after_reload();
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==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");
habitat_touch(true,233,130,2000); habitat_touch(true,233,130,2700);
habitat_touch(true,100,130,2800); habitat_touch(false,100,130,2900); scene_take();
assert(s.view==TABS && !starts && !desktop_opens && !tab_switches);
workspace_setup(); active()->busy=true; scene_take(); tap(1000,233,41);
assert(s.view==AGENTS && !starts && !moves);
workspace_setup(); s.coasting=true; s.coast_until=2000; active()->busy=true; scene_take(); tap(1000,233,41);
assert(s.view==HOME && down_reports==1 && ups==1 && !tab_switches && !starts);
tap(1300,233,41); assert(s.view==AGENTS && !starts && !tab_switches);
workspace_setup(); visit.available=true; strcpy(visit.label,"Return"); scene_take();
assert(action_enabled(A_RETURN) && !action_enabled(A_TABS));
workspace_setup(); carry.active=true; scene_take();
assert(action_enabled(A_CARRY_DROP) && !action_enabled(A_TABS));
workspace_setup(); congestion=true; dispatch((action_t){.kind=A_TAB,.id="tab-2"});
assert(!s.loading && s.view==MESSAGE && workspace.phase==HT_WORKSPACE_IDLE && !tab_switches);
reset(); dispatch((action_t){.kind=A_FIND}); scene_take();
assert(s.view==FORM && form.pending && form.id[0] && form_actions==1 && form_command.op==HT_FORM_OPEN);
char opening_id[48]; COPY(opening_id,form.id); uint32_t opening_request=form.request;
assert(action_enabled(A_FORM_BACK) && !action_enabled(A_FORM_SAY));
tap(2000,113,389); assert(s.view==HOME && !form.id[0] && form_command.op==HT_FORM_CLOSE);
ht_form_page_t late={.active=true,.can_query=true,.revision=1};
assert(!ht_form_reply(&form,opening_id,opening_request,true,&late,2100));
dispatch((action_t){.kind=A_FIND}); assert(form.pending && form.request>opening_request);
assert(ht_form_tick(&form,6000)); scene_take();
assert(form.failed && action_enabled(A_FORM_BACK));
tap(6500,113,389); assert(s.view==HOME && !form.id[0]);
// A background refresh can coincide with any repaint. Its unchanged reply
// must restore both the visible Say control and its real touch target.
reset(); view(FORM);
ht_form_page_t finder_page={.active=true,.can_query=true,.revision=1,
.title="Find Harness",.label="Say a name",.action="open"};
ht_form_open(&form,"find-test",1000,form_emit,NULL);
if (ht_form_reply(&form,"find-test",form.request,true,&finder_page,1010)) scene_take();
assert(action_enabled(A_FORM_SAY));
ht_form_tick(&form,2010); assert(form.pending);
scene_take(); // Touch or an agent status causes a frame while the read is in flight.
assert(!action_enabled(A_FORM_SAY));
if (ht_form_reply(&form,"find-test",form.request,true,&finder_page,2020)) scene_take();
assert(action_enabled(A_FORM_SAY));
tap(2200,223,389); assert(starts==1);
reset(); portrait(dir, "ready");
s.agents[0].busy = true; strcpy(s.agents[0].tool,"Running firmware checks"); scene_take(); portrait(dir, "working");
habitat_touch(true,233,220,1000); assert(!starts); // act only on release
habitat_touch(false,233,220,1075); scene_take();
assert(starts==1 && !strcmp(target,"a") && s.view==VOICE);
portrait(dir,"listening");
bool listening_arc=false;
for(int i=0;i<scene.count;i++) {
assert(!strstr(scene.runs[i].text,"discard"));
if(strstr(scene.runs[i].text,"Listening")) {
assert(!strcmp(scene.runs[i].text,"Listening") && scene.runs[i].arc==2 && scene.runs[i].shimmer);
listening_arc=true;
}
}
assert(listening_arc && !action_enabled(A_VOICE_ABORT));
tap(1200,233,220); tap(1400,233,220); assert(!stops); // double/triple are one intent
s.active=1; input_cancel();
assert(!strcmp(target,"a") && !strcmp(s.voice_target,"Deploy latest firmware"));
// Anywhere on the glass finishes the recording, not just the pet: (233,422) is below its old box.
tap(2400,233,422); assert(stops==1);
assert(s.view==VOICE && s.voice_open);
dispatch((action_t){.kind=A_VOICE_ABORT}); // Finish the fixture's pending host reply.
tap(4000,233,220); assert(starts==2 && !strcmp(target,"b"));
reset(); tap(1000,233,220); tap(1200,233,422);
assert(s.voice_open && s.view==VOICE && !stops); // Bottom caption never discards a capture.
// Recording has a steady word (no clock to rerotate) over a moving body.
// Listening alone gets the faster sweep; transmission keeps the moving body.
reset(); tap(1000,233,220);
unsigned first_frame=character.motion.frame;
bool moved_while_listening=false;
for(int i=0;i<32;i++) {
fake_ms=2000+i*256; surface_tick(fake_ms); scene_take();
moved_while_listening |= character.motion.frame != first_frame;
assert(character.motion.running && character.motion.rate==2);
bool animated=false;
for(int j=0;j<scene.count;j++) if(scene.runs[j].arc==2) {
assert(!strcmp(scene.runs[j].text,"Listening") && scene.runs[j].shimmer);
animated=true;
}
assert(animated && !stops && !strcmp(target,"a"));
char label[40];snprintf(label,sizeof label,"listening-live-%02d",i);portrait(dir,label);
}
assert(moved_while_listening);
fake_ms=12288;surface_tick(fake_ms);scene_take();assert(s.status_phase==1);
fake_ms=12320;surface_tick(fake_ms);scene_take();assert(s.status_phase==2);
assert(status_wake_ms(12321)==31 && status_wake_ms(UINT32_MAX)==1);
fake_ms=13312;surface_tick(fake_ms);scene_take();assert(s.status_phase==1);
s.quiet=true;surface_tick(fake_ms);scene_take();
assert(!character.motion.running);
for(int j=0;j<scene.count;j++)assert(!scene.runs[j].shimmer);
s.quiet=false;tap(fake_ms+1000,233,220);assert(stops==1);
s.voice_waiting=true;recording=false;surface_tick(fake_ms);scene_take();portrait(dir,"voice-transmitting");
assert(character.motion.running && !status_animated());
for(int j=0;j<scene.count;j++) {
assert(scene.runs[j].arc!=2 && !scene.runs[j].shimmer);
assert(!strstr(scene.runs[j].text,"Listening") && !strstr(scene.runs[j].text,"Sending"));
}
s.voice_return=FORM; fake_ms=16384; surface_tick(fake_ms); scene_take();
assert(status_is("Finding") && status_speed()==1 && status_wake_ms(16385)==63);
s.view=HOME; active()->busy=true; fake_ms=15000; surface_tick(fake_ms); fake_ms=18432; surface_tick(fake_ms); scene_take(); assert(s.status_phase==1);
fake_ms+=32; surface_tick(fake_ms); assert(s.status_phase==1);
fake_ms+=32; surface_tick(fake_ms); assert(s.status_phase==2);
reset(); habitat_touch(true,233,220,1000); s.active=1; input_cancel();
habitat_touch(false,233,220,1075); assert(!starts);
tap(1200,233,220); assert(starts==1 && !strcmp(target,"b"));
reset(); habitat_touch(true,233,220,1000); habitat_touch_cancel();
habitat_touch(false,233,220,1080); assert(!starts);
tap(1200,233,220); assert(starts==1);
reset(); habitat_touch(true,233,220,1000);
habitat_touch(true,233,170,1020); assert(moves>0 && !starts && travel==-50);
habitat_touch(true,233,220,1040); habitat_touch(false,233,220,1080);
assert(!starts && s.coasting);
tap(1200,233,220); assert(!starts); // tap brakes, even over Tim
tap(1500,233,220); assert(starts==1);
reset(); habitat_touch(true,233,220,1000);
habitat_touch(true,310,220,1020); habitat_touch(true,233,220,1040);
habitat_touch(false,233,220,1080); assert(!starts && !switches);
tap(1200,233,220); assert(starts==1);
reset(); habitat_touch(true,320,220,1000); habitat_touch(false,150,220,1120);
assert(switches==1 && s.active==1 && !moves);
reset(); congestion=true;
habitat_touch(true,233,220,1200); habitat_touch(true,233,300,1220);
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==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);
assert(!scene.runs[0].arc && !scene.runs[0].shimmer);
ht_rect_t brand=ht_run_bounds(&scene.runs[0]);
assert(abs(brand.x*2+brand.w-466)<=1 && abs(brand.y*2+brand.h-466)<=1);
tap(1000,233,220); assert(!starts);
surface_tick(1500); assert(!character.motion.running);
// Handshake alone is not ready: retain the wordmark until the roster lands.
s.connected=true; s.loading=true; scene_take(); portrait(dir,"connecting");
assert(scene.count==1 && !strcmp(scene.runs[0].text,"Harness") && !s.hit_count);
surface_tick(2000); assert(!character.motion.running);
ui_land_after_reload(); scene_take(); assert(scene.count>1);
s.view=OTA; scene_take(); portrait(dir,"updating");
assert(scene.count==1 && !strcmp(scene.runs[0].text,"Harness") && !s.hit_count);
reset(); s.count=0; s.active=-1; scene_take();
tap(1000,233,220); assert(!starts);
// A missed utterance keeps the entire creature as the retry target.
reset(); ui_project_emit("a",NULL,"summary","Previous result stays saved.","Previous result stays saved.");
s.voice_retry_until=4000; scene_take(); portrait(dir,"voice-retry");
assert(status_is("Try again") && !result_visible() && action_enabled(A_PET));
for(int i=0;i<scene.count;i++)assert(!scene.runs[i].shimmer);
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 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));
scene_take(); portrait(dir,"selection");
habitat_touch(true,233,290,2100); habitat_touch(true,233,240,2160);
habitat_touch(false,233,240,2210); assert(!starts && !moves && selection.pending);
assert(selected_command.op==HT_SELECT_STEP && selected_command.delta==2);
scene_take(); tap(2400,233,220); assert(!starts); // await the current highlight
assert(ht_selection_reply(&selection,selection.request,"pick-test",true,2,"A highlighted paragraph",3,true,NULL,2500));
scene_take(); portrait(dir,"selection-range");
action_t to_carry=make_action((hit_t){.action=A_CARRY});
to_carry.dy--; dispatch(to_carry); assert(!carry.pending && !carry_prepares);
tap(2650,330,350); assert(carry.pending && carry_prepares==1 && !starts);
tap(2800,233,220); assert(!starts); // no voice while the selected text is being frozen
assert(ht_carry_reply(&carry,carry.id,carry.request,true,"Research helper","A highlighted paragraph",3,300000,NULL,3000));
ht_selection_close(&selection); view(HOME); s.active=1; scene_take(); portrait(dir,"carry-home");
tap(3400,233,220); assert(starts==1 && s.voice_carry && !strcmp(target,"b") && !strcmp(voice_context,carry.id));
scene_take(); portrait(dir,"carry-listening");
dispatch((action_t){.kind=A_VOICE_ABORT}); scene_take();
tap(4100,233,410); assert(!carry.active && carry_drops==1 && starts==1);
reset(); view(SELECTION); ht_selection_open(&selection,"pick-test","a",1000,select_emit,NULL);
assert(ht_selection_reply(&selection,selection.request,"pick-test",true,1,"A highlighted paragraph",3,true,NULL,1010));
action_t selected_action=make_action((hit_t){.action=A_PET});
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==TABS && !starts);
reset(); habitat_touch(true,233,220,1000); surface_tick(1650); surface_tick(6000);
habitat_touch(false,233,220,6100); assert(s.view==TABS && !starts); // resting hand never selects a tab
reset(); habitat_touch(true,233,220,1000); habitat_touch(true,233,170,1100);
surface_tick(1650); habitat_touch(false,233,170,1800);
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);
// A stroke around the bezel is an ORDINARY VERTICAL DRAG now. Rim scrolling is gone — it read a
// turn around the annulus as a scroll wheel, and its `rim_candidate` flag survived
// ht_scroll_cancel(), so after one bezel touch every footer tap was swallowed as motion.
reset(); habitat_touch(true,433,233,2000); habitat_touch(true,418,310,2100);
habitat_touch(true,374,374,2200); habitat_touch(true,310,418,2300);
habitat_touch(false,233,433,2400); assert(travel && !switches && !starts);
reset(); s.focus_face=true; s.agents[0].busy=true;
strcpy(s.agents[0].tool,"Running firmware checks"); scene_take(); portrait(dir,"focus");
tap(1000,233,220); assert(starts==1); // same voice muscle memory in both faces
/*
* THE FOCUS FACE'S MICROPHONE, across its whole target.
*
* The creature skins start speech by tapping the companion; Focus has none, so it draws a mic in
* the footer and registers the rect itself. Every row of that rect has to answer — a button whose
* top half works reads as a broken button, not as a small one.
*/
// The Focus SKIN's home face, footer and all — the "focus" portrait above is the legacy
// focus-face option on the default character, which draws no microphone.
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); scene_take(); portrait_focus(dir,"focus-skin");
/*
* THE DOORS on Focus (owner, 2026-10-01), laid out like the octopus: a tap on the curved name opens
* the pane list, a hold on the face the tab list, and a tap anywhere else talks. There is no tab
* pill and no microphone any more.
*/
workspace_setup(); ht_character_select(&character, HT_CHARACTER_FOCUS); strcpy(s.agents[0].engine, "claude");
ui_project_emit(s.agents[0].id, "sess", "summary", "Flashed 0.0.91 to both dials and verified the image on each. All 44 host checks pass.",
"Flashed 0.0.91 to both dials and verified the image on each. All 44 host checks pass.");
scene_take(); portrait_focus(dir,"focus-recap");
assert(!action_enabled(A_TAB_LIST));
for (int i = 0; i < scene.count; i++) assert(scene.runs[i].sprite.pixels != ht_icon_mic.px);
tap(1000, 233, 30); assert(s.view == AGENTS && !starts);
// The hold: on the recap, past 650 ms, and the tab list is open before the finger lifts.
workspace_setup(); ht_character_select(&character, HT_CHARACTER_FOCUS); strcpy(s.agents[0].engine, "claude");
ui_project_emit(s.agents[0].id, "sess", "summary", "Retry queue shipped.", "Retry queue shipped.");
scene_take();
habitat_touch(true, 233, 300, 2000); habitat_touch(true, 233, 300, 2700);
assert(s.view == TABS && !starts);
habitat_touch(false, 233, 300, 2800); assert(s.view == TABS && !starts);
// A tap ANYWHERE on the face below the name talks (owner, 2026-10-01): the recap, the mark, the
// empty glass around them, and the bottom edge where the microphone used to be.
{
const int at[][2] = {{233, 110}, {233, 260}, {120, 300}, {346, 200}, {233, 360}, {233, 410}, {233, 440}};
for (unsigned k = 0; k < sizeof at / sizeof at[0]; k++) {
workspace_setup(); ht_character_select(&character, HT_CHARACTER_FOCUS); strcpy(s.agents[0].engine, "claude");
ui_project_emit(s.agents[0].id, "sess", "summary", "Retry queue shipped.", "Retry queue shipped.");
scene_take(); tap(1000, at[k][0], at[k][1]); assert(starts == 1 && s.view == VOICE);
assert(!strcmp(target, s.agents[0].id)); // to the agent on the face: none is dropped on glass
}
}
// And on a face with nothing yet to say.
workspace_setup(); ht_character_select(&character, HT_CHARACTER_FOCUS); scene_take();
tap(1000, 233, 233); assert(starts == 1);
/*
* A THUMB, not an idealised tap: it drifts 10 px and stays down up to 600 ms, which
* ht_gesture_end() calls no tap at all. On the Focus face it still talks. A contact that travels
* 20 px up or down has scrolled the terminal, and belongs to the scroll.
*/
for (int drift = 0; drift <= 10; drift += 5) for (int held = 120; held <= 600; held += 240) {
workspace_setup(); ht_character_select(&character, HT_CHARACTER_FOCUS); strcpy(s.agents[0].engine, "claude");
ui_project_emit(s.agents[0].id, "sess", "summary", "Retry queue shipped.", "Retry queue shipped.");
scene_take();
habitat_touch(true, 233, 260, 1000);
habitat_touch(true, 233 + drift / 2, 260 + drift, 1000 + held / 2);
habitat_touch(false, 233 + drift / 2, 260 + drift, 1000 + held);
assert(starts == 1 && s.view == VOICE && !strcmp(target, s.agents[0].id));
}
workspace_setup(); ht_character_select(&character, HT_CHARACTER_FOCUS); scene_take();
habitat_touch(true, 233, 260, 1000); habitat_touch(true, 233, 300, 1100); habitat_touch(false, 233, 300, 1200);
assert(!starts); // 40 px is a drag, not a touch
/*
* THE BELL DOES NOT COUNT THE AGENT ON THE FACE. Standing on "a", its question arrives: it shows in
* the recap's place and the bell stays dark — a +1 there read as another agent asking. Move to
* "b" without answering and the bell says 1, until the question is answered.
*/
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS);
{
cable_notif_t asked={.agent_id="a",.name="Research",.question=true,.summary="Which colour do you like?"};
ui_notif_replace(&asked,1); scene_take();
assert(s.view==HOME && s.active==0 && !action_enabled(A_INBOX));
s.active=1; scene_take(); assert(action_enabled(A_INBOX)); // the bell, drawn at the top on Focus
bool bell = false, one = false; // the blue pill: the bell, and its count beside it
for (int i = 0; i < scene.count; i++) {
if (scene.runs[i].font == &ht_lv_montserrat_14.base && !strcmp(scene.runs[i].text, HT_LV_BELL)) bell = true;
if (scene.runs[i].font == &ht_lv_inter_20.base && !strcmp(scene.runs[i].text, "1")) one = true;
}
assert(bell && one);
s.active=0; scene_take(); assert(!action_enabled(A_INBOX));
}
// THE PETS (claude, codex): the face publishes when the pet next changes (s.pet_next_ms);
// surface_tick asks for a redraw then and not before. Other things may ask on their own clocks,
// so the same ticks are replayed for a Cursor agent (no pet) and the pet's requests are the difference.
for (unsigned pe = 0; pe < ht_pet_count; pe++) {
const char *pet_engine = ht_pets[pe].engine;
unsigned seen[2][2]; uint32_t due = 0;
for (int pass = 0; pass < 2; pass++) {
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS);
strcpy(s.agents[0].engine, pass ? pet_engine : "cursor");
fake_ms = 1200; scene_take();
if (!pass) assert(!s.pet_next_ms);
else { due = s.pet_next_ms; assert(due > 1200); }
if (pass) { for (int k = 0; k < 2; k++) {
s.pet_next_ms = due; changes = 0; surface_tick(k ? due : due - 1); seen[1][k] = changes; } }
}
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); strcpy(s.agents[0].engine, "cursor");
fake_ms = 1200; scene_take();
for (int k = 0; k < 2; k++) { changes = 0; surface_tick(k ? due : due - 1); seen[0][k] = changes; }
assert(seen[1][0] == seen[0][0] && seen[1][1] == seen[0][1] + 1);
// A finger down pauses it, and so does the VOICE view.
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); strcpy(s.agents[0].engine, pet_engine);
fake_ms = 1200; scene_take(); assert(s.pet_next_ms == due);
s.touch_down = true; changes = 0; surface_tick(due); assert(s.pet_next_ms == due);
s.touch_down = false;
s.view = HOME;
}
// THE WORKING TIMER: the elapsed text redraws when its displayed unit changes (elapsed.h) — each second
// under an hour, each minute under a day — and not before. 0 = unknown (no start stamp): no deadline.
{
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS);
s.agents[0].busy = true; strcpy(s.agents[0].tool, "Running firmware checks");
fake_ms = 1200; scene_take(); assert(!s.timer_at); // busy_ms = 0: unknown, nothing drawn
s.agents[0].busy_ms = 1000; fake_ms = 1000 + 7500; scene_take(); // 7.5 s in: "0:07" until 8.0 s
assert(s.timer_at == 1000 + 8000);
surface_tick(1000 + 7999); assert(s.timer_at == 1000 + 8000); // not due: still waiting
changes = 0; surface_tick(1000 + 8000); assert(changes >= 1 && !s.timer_at);
s.agents[0].busy_ms = 1000; fake_ms = 1000 + 3600000 + 90000 + 400; // 1 h 1 m 30.4 s: "1h 1m" until 1 h 2 m
scene_take(); assert(s.timer_at == 1000 + 3600000 + 120000);
s.agents[0].busy = false; scene_take(); assert(!s.timer_at);
}
// THE WORKING SCENE (claude): a busy agent's face is the large cooking Clawd, which changes on its step
// clock, so s.pet_next_ms is its next change and surface_tick redraws then and not before.
{
const ht_pet_scene_t *ws = ht_pets[0].working_scene;
assert(!strcmp(ht_pets[0].engine, "claude") && ws);
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); strcpy(s.agents[0].engine, "claude");
s.agents[0].busy = true; strcpy(s.agents[0].tool, "Running firmware checks");
fake_ms = 1200; scene_take();
// the next step that draws differently (the pan's still steps draw the same)
unsigned now = 1201 / ws->step_ms, nx = now + 1;
const ht_pet_overlay_t *o = ws->overlay;
for (; nx < now + ws->steps; nx++) {
unsigned a = nx % ws->steps, b = now % ws->steps;
if (ws->loop[a] != ws->loop[b] || (ws->step_dy && ws->step_dy[a] != ws->step_dy[b]) ||
(o && (o->loop[a] != o->loop[b] || o->at[a][0] != o->at[b][0] || o->at[a][1] != o->at[b][1]))) break;
}
uint32_t due = nx * ws->step_ms;
assert(s.pet_next_ms == due);
bool scene_run = false, lower_arc = false;
for (int i = 0; i < scene.count; i++) {
scene_run |= scene.runs[i].sprite.width == ws->w;
lower_arc |= scene.runs[i].arc == 2 && !strncmp(scene.runs[i].text, "Running firmware", 16);
}
assert(scene_run && lower_arc);
// Other clocks (the status shimmer) may ask too: replay the ticks for a Cursor agent, whose
// face has no scene, and the scene's request is the difference.
unsigned seen[2][2];
for (int k = 0; k < 2; k++) { s.pet_next_ms = due; changes = 0; surface_tick(k ? due : due - 1); seen[1][k] = changes; }
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); strcpy(s.agents[0].engine, "cursor");
s.agents[0].busy = true; strcpy(s.agents[0].tool, "Running firmware checks");
fake_ms = 1200; scene_take(); assert(!s.pet_next_ms);
for (int k = 0; k < 2; k++) { changes = 0; surface_tick(k ? due : due - 1); seen[0][k] = changes; }
assert(seen[1][0] == seen[0][0] && seen[1][1] == seen[0][1] + 1);
// THE BUILDER (owner, 2026-10-16): an odd draw as the scene starts showing plays it instead, for as long as the
// scene shows — later draws do not move it — and the next showing (after the turn) draws again.
const ht_pet_scene_t *bs = ht_pets[0].working_alt;
assert(bs && bs->w != ws->w);
#define SCENE_W(w_) ({ bool v_ = false; for (int i_ = 0; i_ < scene.count; i_++) v_ |= scene.runs[i_].sprite.cells && scene.runs[i_].sprite.width == (w_); v_; })
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); strcpy(s.agents[0].engine, "claude");
s.agents[0].busy = true; strcpy(s.agents[0].tool, "Running firmware checks");
fake_random = 123; fake_ms = 1200; scene_take(); assert(SCENE_W(bs->w) && !SCENE_W(ws->w));
fake_random = 122;
for (int k = 1; k <= 40; k++) { fake_ms = 1200 + 55u * k; scene_take(); assert(SCENE_W(bs->w) && !SCENE_W(ws->w)); }
s.agents[0].busy = false; fake_ms += 55; scene_take(); assert(!SCENE_W(bs->w) && !SCENE_W(ws->w));
s.agents[0].busy = true; fake_ms += 55; scene_take(); assert(SCENE_W(ws->w) && !SCENE_W(bs->w));
#undef SCENE_W
}
// CODEX'S SCENES: the same three, on the same clocks. Working on the face (status on the lower arc),
// listening and sending on VOICE by the recipient's engine (pane on the face is Claude), quiet holds them.
{
const ht_pet_t *xp = &ht_pets[1];
assert(!strcmp(xp->engine, "codex") && xp->working_scene && xp->listening_scene && xp->sending_scene);
const ht_pet_scene_t *ws = xp->working_scene, *ls = xp->listening_scene, *ss = xp->sending_scene;
#define XRUN(sc) ({ bool v_ = false; for (int i_ = 0; i_ < scene.count; i_++) v_ |= scene.runs[i_].sprite.width == (sc)->w && scene.runs[i_].sprite.cells; v_; })
#define XBARS() ({ int b_ = 0; for (int i_ = 0; i_ < scene.count; i_++) b_ += scene.runs[i_].font == &ht_wave && scene.runs[i_].text[0]; b_; })
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); strcpy(s.agents[0].engine, "codex");
s.agents[0].busy = true; strcpy(s.agents[0].tool, "Running firmware checks");
fake_ms = 1200; scene_take();
uint32_t due = (1201 / ws->step_ms + 1) * ws->step_ms;
assert(s.pet_next_ms == due && XRUN(ws));
bool lower_arc = false;
for (int i = 0; i < scene.count; i++) lower_arc |= scene.runs[i].arc == 2 && !strncmp(scene.runs[i].text, "Running firmware", 16);
assert(lower_arc);
changes = 0; s.pet_next_ms = due; surface_tick(due - 1); assert(s.pet_next_ms == due);
surface_tick(due); assert(!s.pet_next_ms && changes >= 1);
// Listening: pane is Claude, the voice goes to Codex: its scene, no bars, its 80 ms step.
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS);
strcpy(s.agents[0].engine, "claude"); strcpy(s.agents[1].engine, "codex");
fake_ms = 1200; dispatch((action_t){.kind = A_VOICE, .id = "b"}); scene_take();
assert(s.view == VOICE && !strcmp(s.voice_engine, "codex") && XRUN(ls) && !XBARS());
focus_only_inter();
// Level 0 (no mic yet), at the rest of the "Listening" sweep: the word's first step of the next period (1365),
// or the scene's own next frame, whichever is first. The word is on the lower arc, the bars are not drawn.
due = s.pet_next_ms; assert(due > 1200 && due <= 1365);
bool word = false;
for (int i = 0; i < scene.count; i++) word |= scene.runs[i].arc == 2 && !strcmp(scene.runs[i].text, "Listening") && scene.runs[i].gained;
assert(word);
s.touch_down = true; changes = 0;
surface_tick(due - 1); assert(s.pet_next_ms == due);
surface_tick(due); assert(!s.pet_next_ms && changes >= 1);
s.touch_down = false;
fake_ms = 1200; s.quiet = true; scene_take(); assert(XRUN(ls) && !s.pet_next_ms); s.quiet = false;
// Sending to Codex: the paper plane on its own 140 ms step; quiet holds it.
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); strcpy(s.agents[0].engine, "claude"); strcpy(s.agents[1].engine, "codex");
fake_ms = 1200; dispatch((action_t){.kind = A_VOICE, .id = "b"}); s.voice_waiting = true; scene_take();
assert(s.view == VOICE && !strcmp(s.voice_engine, "codex") && XRUN(ss) && !XBARS() && s.pet_next_ms);
due = s.pet_next_ms; assert(due > 1200 && due <= 1201 + ss->step_ms * ss->steps);
changes = 0; surface_tick(due - 1); assert(s.pet_next_ms == due);
surface_tick(due); assert(!s.pet_next_ms && changes >= 1);
fake_ms = 1200; s.quiet = true; scene_take(); assert(!s.pet_next_ms); s.quiet = false;
#undef XRUN
#undef XBARS
}
// THE WORKING SCENE and a notice (owner, 2026-10-05; 2026-10-07 "keep the bell, the number beside it"): no bell
// pill. For each engine with a scene the pet's bell bubble pops in over the working scene and rings, the count
// written in it once it is whole, then its last step holds until the notice is read; a tap on it opens the inbox,
// and a second notice rings it again without popping in, the count 2. The run count never changes meanwhile.
{
const ht_pet_scene_t *ws = ht_pets[0].working_scene;
static const char *engines[3] = {"claude", "codex", "muse"};
for (int e = 0; e < 3; e++) {
const ht_pet_t *pet = NULL;
for (unsigned i = 0; i < ht_pet_count; i++) if (!strcmp(ht_pets[i].engine, engines[e])) pet = &ht_pets[i];
assert(pet && pet->alert_scene && pet->alert_scene->overlay && pet->alert_scene->count_at &&
pet->alert_scene->steps >= 10 && !pet->alert_scene->frames);
const ht_pet_scene_t *al = pet->alert_scene, *wk = pet->working_scene;
assert(e != 1 || !wk->overlay); // Codex works without its sandbox bubble
const uint32_t A = (uint32_t)al->steps * al->step_ms, S = al->step_ms;
#define HAS_SPRITE(sc_) ({ bool f_ = false; for (int i_ = 0; i_ < scene.count; i_++) \
f_ |= scene.runs[i_].sprite.cells && scene.runs[i_].sprite.width == (sc_)->w && \
scene.runs[i_].sprite.height == (sc_)->h; f_; })
// The bubble on the glass at a step, over the working scene.
#define ALERT_AT(k_) ({ bool g_ = false; const ht_cell_frame_t *b_ = &al->overlay->frames[al->overlay->loop[k_]]; \
for (int i_ = 0; i_ < scene.count; i_++) g_ |= scene.runs[i_].sprite.cells == b_->cells; \
HAS_SPRITE(wk) && g_; })
// The count's run, in the notice blue: its index, -1 = none.
#define COUNT(t_) ({ int c_ = -1; for (int i_ = 0; i_ < scene.count; i_++) if (!strcmp(scene.runs[i_].text, t_) && \
scene.runs[i_].fg == ht_rgb(0x006fff)) c_ = i_; c_; })
#define BLUE_BOX() ({ int f_ = -1; for (int i_ = 0; i_ < scene.count; i_++) if (scene.runs[i_].box.h && \
scene.runs[i_].box.fill == color(0x006fff)) f_ = i_; f_; })
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); strcpy(s.agents[0].engine, engines[e]);
s.agents[0].busy = true; strcpy(s.agents[0].tool, "Running firmware checks");
fake_ms = 1200; scene_take();
assert(HAS_SPRITE(wk) && BLUE_BOX() < 0 && !action_enabled(A_INBOX));
int runs = scene.count;
cable_notif_t note={.agent_id="b",.name="Other",.summary="Done"};
ui_notif_replace(¬e,1);
fake_ms = 2000; scene_take();
uint32_t from = s.notice_ms;
assert(from && ALERT_AT(0) && BLUE_BOX() < 0 && COUNT("1") < 0 && scene.count == runs);
for (int i = 0; i < scene.count; i++) {
assert(scene.runs[i].font != &ht_lv_montserrat_14.base || !scene.runs[i].text[0]); // no bell pill
if (scene.runs[i].arc == 2 && scene.runs[i].text[0]) assert(scene.runs[i].fg == ht_rgb(0x00ff2f));
}
// its next step, or the working scene's next frame if that comes first
assert(s.pet_next_ms > from && s.pet_next_ms <= from + S);
fake_ms = from + 5 * S + 3; scene_take(); // still popping in: no count yet
assert(ALERT_AT(5) && COUNT("1") < 0 && s.pet_next_ms > fake_ms && s.pet_next_ms <= from + 6 * S);
fake_ms = from + 8 * S; scene_take(); // whole and ringing: the count in it
assert(ALERT_AT(8) && COUNT("1") >= 0 && scene.count == runs);
fake_ms = from + A + 3000; scene_take(); // held after the ring, the work playing on
int c = COUNT("1");
assert(ALERT_AT(al->steps - 1) && c >= 0 && BLUE_BOX() < 0 && scene.count == runs);
assert(s.pet_next_ms > fake_ms && s.pet_next_ms <= fake_ms + 1000); // the work's frames, not a spin
// The count sits inside the bubble, on the glass.
assert(scene.runs[c].x > 40 && scene.runs[c].x < 420 && scene.runs[c].y > 60 && scene.runs[c].y < 300);
// A second notice: rung again from where it is whole, the count 2.
cable_notif_t two[2] = {note, {.agent_id="c",.name="Third",.summary="Done"}};
fake_ms += 1000; ui_notif_replace(two,2); scene_take();
uint32_t pop = (fake_ms | 1) - s.notice_ms;
assert(pop >= 3 * S && pop <= 8 * S && COUNT("2") >= 0 && COUNT("1") < 0 && scene.count == runs);
// A tap on the bubble opens the inbox, the name still the panes.
fake_ms += A + 1000; scene_take(); c = COUNT("2"); assert(c >= 0);
tap(fake_ms + 10, scene.runs[c].x + 4, scene.runs[c].y + 8); assert(s.view == INBOX);
#undef HAS_SPRITE
#undef ALERT_AT
#undef COUNT
#undef BLUE_BOX
}
cable_notif_t note={.agent_id="b",.name="Other",.summary="Done"};
bool box = false, scene_run = false;
// A recap or no scene (idle): the bell keeps 400.
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); strcpy(s.agents[0].engine, "claude");
ui_notif_replace(¬e,1); fake_ms = 1200; scene_take();
box = false;
for (int i = 0; i < scene.count; i++) if (scene.runs[i].box.h == 32) { box = true; assert(scene.runs[i].y == 400); }
assert(box && action_enabled(A_INBOX));
s.agents[0].busy = true; strcpy(s.agents[0].tool, "Running firmware checks");
// A footer control (carried text): the straight line at 334, no arc.
carry.active = true; strcpy(carry.source, "x"); carry.rows = 2; fake_ms = 1300; scene_take();
scene_run = false; bool line = false;
for (int i = 0; i < scene.count; i++) {
scene_run |= scene.runs[i].sprite.width == ws->w; assert(scene.runs[i].arc != 2);
if (scene.runs[i].font == &ht_lv_inter_30.base && !strncmp(scene.runs[i].text, "Running firm", 12)) { line = true; assert(scene.runs[i].y == 334); }
}
assert(scene_run && line);
carry.active = false;
// Free bottom edge: the lower arc again, and no straight line.
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); strcpy(s.agents[0].engine, "claude");
s.agents[0].busy = true; strcpy(s.agents[0].tool, "Running firmware checks"); fake_ms = 34000 + 1200; scene_take();
bool arc = false;
for (int i = 0; i < scene.count; i++) {
if (scene.runs[i].arc == 2) { arc = true; assert(strlen(scene.runs[i].text) <= 26); }
assert(scene.runs[i].font != &ht_lv_inter_30.base || !scene.runs[i].text[0]);
}
assert(arc);
portrait_focus(dir,"focus-working"); // the Claude scene, its status on the lower arc
}
// THE LISTENING SCENE follows the recipient's engine, not the pane on the face, and has its own
// schedule: the next 140 ms step, honoured on VOICE with the finger down (hold-to-talk); quiet holds it.
{
const ht_pet_scene_t *ls = ht_pets[0].listening_scene;
assert(!strcmp(ht_pets[0].engine, "claude") && ls);
#define VOICE_SCENE() ({ bool v_ = false; for (int i_ = 0; i_ < scene.count; i_++) v_ |= scene.runs[i_].sprite.width == ls->w && scene.runs[i_].sprite.cells; v_; })
#define VOICE_BARS() ({ int b_ = 0; for (int i_ = 0; i_ < scene.count; i_++) b_ += scene.runs[i_].font == &ht_wave && scene.runs[i_].text[0]; b_; })
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS);
strcpy(s.agents[0].engine, "codex"); strcpy(s.agents[1].engine, "claude");
// Pane on the face is Codex, the voice goes to Claude: the scene.
fake_ms = 1200; dispatch((action_t){.kind = A_VOICE, .id = "b"}); scene_take();
assert(s.view == VOICE && !strcmp(s.voice_engine, "claude") && VOICE_SCENE() && !VOICE_BARS());
portrait_focus(dir,"focus-voice-listening"); // the Listening word on the lower arc, the scene in the middle
// The next step, or sooner: Claude's sound arcs glide on a 50 ms tick.
uint32_t due = s.pet_next_ms;
assert(due > 1200 && due <= (1201 / ls->step_ms + 1) * ls->step_ms);
s.touch_down = true; changes = 0;
surface_tick(due - 1); assert(s.pet_next_ms == due);
surface_tick(due); assert(!s.pet_next_ms && changes >= 1);
assert(habitat_next_wake_ms() >= 1);
s.touch_down = false;
// The wake honours it too: 1 ms from the step on VOICE, finger down or not.
fake_ms = 1200; scene_take(); s.touch_down = true;
fake_ms = due - 3; assert(habitat_next_wake_ms() <= 3); s.touch_down = false;
// Quiet: still, no schedule.
fake_ms = 1200; s.quiet = true; scene_take();
assert(VOICE_SCENE() && !s.pet_next_ms);
s.quiet = false;
// Pane on the face is Claude, the voice goes to an engine without scenes (Cursor): the bars.
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS);
strcpy(s.agents[0].engine, "claude"); strcpy(s.agents[1].engine, "cursor");
fake_ms = 1200; dispatch((action_t){.kind = A_VOICE, .id = "b"}); scene_take();
assert(s.view == VOICE && !strcmp(s.voice_engine, "cursor") && !VOICE_SCENE() && VOICE_BARS() == 7 && !s.pet_next_ms);
portrait_focus(dir,"focus-voice-bars");
// Find in output (no agent): the bars even though the pane is Claude.
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); strcpy(s.agents[0].engine, "claude");
fake_ms = 1200; dispatch((action_t){.kind = A_VOICE, .id = "a", .value = 7}); scene_take();
assert(s.view == VOICE && !s.voice_engine[0] && !VOICE_SCENE() && VOICE_BARS() == 7 && !s.pet_next_ms);
// Sending to Claude: the post box scene animates on its own step; quiet holds it.
const ht_pet_scene_t *ss = ht_pets[0].sending_scene;
assert(ss);
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); strcpy(s.agents[0].engine, "claude");
fake_ms = 1200; dispatch((action_t){.kind = A_VOICE, .id = "a"}); s.voice_waiting = true; scene_take();
assert(s.view == VOICE && !strcmp(s.voice_engine, "claude") && !VOICE_BARS());
bool post = false; for (int i = 0; i < scene.count; i++) post |= scene.runs[i].sprite.width == ss->w && scene.runs[i].sprite.cells;
assert(post && s.pet_next_ms);
portrait_focus(dir,"focus-voice-sending");
due = s.pet_next_ms; assert(due > 1200 && due <= 1201 + ss->step_ms * ss->steps);
changes = 0; surface_tick(due - 1); assert(s.pet_next_ms == due);
surface_tick(due); assert(!s.pet_next_ms && changes >= 1);
fake_ms = 1200; s.quiet = true; scene_take(); assert(!s.pet_next_ms); s.quiet = false;
#undef VOICE_SCENE
#undef VOICE_BARS
}
// THE FOCUS INBOX (design 2026-10-06; owner, 2026-10-06: four lines and arrows): the close pill, then the notices
// paged like the tabs. A notice is a block centred on the glass — machine (Inter 25, muted), mark + name (Inter 25,
// green), the message in the recap's Inter 30 on up to four lines — with a faint › on the side that has more, and
// "1/2" at y 400. The page shown is the one read. A swipe pages (s.offset follows), a tap on an arrow's side pages back,
// a tap on the page opens that agent, the cross goes back; the run count holds while the finger drags.
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); strcpy(s.agents[0].engine, "claude");
{
cable_notif_t rows[2]={{.agent_id="a",.name="Payments refactor",.machine="MacBook",
.summary="Shipped the retry queue, moved the parser tests to new fixtures and fixed the flaky upload check on CI so the nightly build is green again."},
{.agent_id="b",.name="Landing page",.machine="Studio Mac",.summary="Hero and pricing are in."}};
ui_notif_replace(rows,2); ui_notif_open(); scene_take(); portrait_focus(dir,"focus-inbox");
assert(s.view == INBOX && scene.background == BG); // black, like the face
assert(habitat_scene_receipt() == s.notice[0].display_revision); // the page on the glass is the one read
bool machine=false, name=false, right=false, left=false; int lines = 0, last = 0, name_y = -1, first_y = 999;
for (int i = 0; i < scene.count; i++) {
const ht_run_t *r = &scene.runs[i];
if (!strcmp(r->text,"MacBook")) machine = r->font == &ht_lv_inter_25.base && r->fg == color(0x8a8a99) && abs(r->x + r->w/2 - 233) <= 1;
if (!strcmp(r->text,"Payments refactor")) { name = r->font == &ht_lv_inter_25.base && r->fg == color(0x04fe08); name_y = r->y; }
if (r->font == &ht_lv_inter_30.base && r->text[0]) {
assert(r->fg == color(0xd6d6d2) && abs(r->x + r->w/2 - 233) <= 1 && r->x >= 60 && r->x + r->w <= 406);
lines++; last = i; if (r->y < first_y) first_y = r->y;
}
right |= !strcmp(r->text,"\xe2\x80\xba") && r->x > 400;
left |= !strcmp(r->text,"\xe2\x80\xb9");
assert(!strstr(r->text,"Studio") && !strstr(r->text,"Landing")); // no neighbour peeks in
}
assert(machine && name && right && !left && lines == 4 && name_y < first_y);
assert(strstr(scene.runs[last].text, "...")); // the fourth line is cut
int runs = scene.count;
for (int d = -200; d <= 200; d += 40) {
int keep = inbox_carousel.position; inbox_carousel.position = keep + d;
ht_scene_t dragged; ht_scene_clear(&dragged, BG); s.hit_count = 0; render_list(&dragged);
assert(dragged.count == runs);
for (int i = 0; i < dragged.count; i++) { ht_rect_t b = ht_run_bounds(&dragged.runs[i]); assert(b.x >= 0 && b.x + b.w <= HT_WIDTH); }
inbox_carousel.position = keep;
}
scene_take();
habitat_touch(true,300,233,1000);
for (int k=1;k<=5;k++) habitat_touch(true,300-k*12,233,1000+k*40);
habitat_touch(false,240,233,1260);
for (uint32_t t=1260;t<=1900;t+=16) surface_tick(t);
scene_take();
assert(s.view == INBOX && s.offset == 1 && !desktop_opens);
bool two=false, back=false, more=false;
for (int i = 0; i < scene.count; i++) {
two |= !strcmp(scene.runs[i].text,"2/2");
back |= !strcmp(scene.runs[i].text,"\xe2\x80\xb9") && scene.runs[i].x < 60;
more |= !strcmp(scene.runs[i].text,"\xe2\x80\xba");
}
assert(two && back && !more);
assert(habitat_scene_receipt() == s.notice[1].display_revision); // and now the second one is read
tap(2000, 20, 233); // the left arrow's side pages back
for (uint32_t t=2100;t<=2600;t+=16) surface_tick(t);
scene_take(); assert(s.view == INBOX && s.offset == 0 && !desktop_opens);
tap(3000, 233, 233); assert(desktop_opens == 1 && !strcmp(opened_agent, "a")); // a tap on the page opens it
ui_notif_open(); scene_take(); tap(3500, 233, 32); assert(s.view == HOME); // the cross goes back
}
// An open question on Focus: shown on the home face, in the recap's place, and nowhere else.
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); strcpy(s.agents[0].engine, "claude");
{
// The question on the face, and another agent's news so the bell is up — at the bottom, under
// the question, where the microphone was.
cable_notif_t asked[2]={{.question=true,.summary="Which database should the retry queue use?"},
{.agent_id="b",.name="Website",.summary="The site is deployed."}};
COPY(asked[0].agent_id, s.agents[0].id); COPY(asked[0].name, s.agents[0].name);
s.tab_count=1; COPY(s.tabs[0].id,"tab-0"); COPY(s.tabs[0].name,"Daily life"); COPY(s.selected_tab,"tab-0");
ui_notif_replace(asked,2); scene_take(); portrait_focus(dir,"focus-question");
assert(s.view == HOME && action_enabled(A_INBOX));
int last_text = 0, bell_top = HT_HEIGHT;
for (int i = 0; i < scene.count; i++) {
const ht_run_t *r = &scene.runs[i];
if (r->font == &ht_lv_inter_30.base && r->text[0]) last_text = r->y + r->font->height;
if (r->box.h && r->box.fill == color(0x006fff) && r->y < bell_top) bell_top = r->y;
}
assert(last_text && bell_top < HT_HEIGHT && last_text <= bell_top);
tap(3000, 233, 416); assert(s.view == INBOX);
ui_notif_replace(asked,2); s.view = HOME; scene_take();
bool shown = false;
for (int i = 0; i < scene.count; i++) if (strstr(scene.runs[i].text, "retry queue")) shown = true;
assert(shown);
}
reset(); s.straight_title=true; scene_take(); portrait(dir,"straight-title");
reset(); s.nap=true; scene_take(); portrait(dir,"asleep");
reset(); s.pet_pose=3; scene_take(); portrait(dir,"done");
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; 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");
scene_take(); portrait(dir,"long-name");
reset(); ht_form_open(&form,"form-test",100,form_emit,NULL);
ht_form_page_t page={.active=true,.enabled=true,.revision=1,.position=4,.total=4,
.title="New Harness",.label="New Harness",.action="start",.previous="Options",
.detail="Claude Code\nM2:~/code/harness"};
ht_form_reply(&form,"form-test",form.request,true,&page,101); s.view=FORM; scene_take();
portrait(dir,"new-harness");
tap(1000,290,375); assert(form_actions==2 && form_command.op==HT_FORM_ACTIVATE && !starts);
page.revision++; ht_form_reply(&form,"form-test",form.request,true,&page,1090); scene_take();
tap(1200,290,375); assert(form_actions==2); // a double tap cannot launch twice
tap(1700,290,375); assert(form_actions==3 && !starts);
ht_form_reply(&form,"form-test",form.request,true,&page,1800); scene_take();
int before=form_actions;
habitat_touch(true,233,260,2500); habitat_touch(true,234,180,2590); habitat_touch(false,234,180,2660);
assert(form_actions==before+1 && form_command.op==HT_FORM_MOVE && !starts && !switches);
page.revision++; ht_form_reply(&form,"form-test",form.request,true,&page,2700); scene_take();
habitat_touch(true,120,233,3100); habitat_touch(true,280,234,3190); habitat_touch(false,280,234,3260);
assert(form_command.op==HT_FORM_BACK && !starts && !switches);
page.revision++; strcpy(page.error,"Choices changed. Try again.");
ht_form_reply(&form,"form-test",form.request,false,&page,3300); scene_take(); portrait(dir,"new-harness-stale");
page.can_query=true; strcpy(page.title,"Project"); strcpy(page.label,"harness");
strcpy(page.query,"harness"); strcpy(page.action,"choose"); page.error[0]=0;
form.page=page; form.pending=false; scene_take(); portrait(dir,"spoken-project");
int speech_before=starts;
habitat_touch(true,220,390,4000); habitat_touch(true,220,300,4090); habitat_touch(false,220,300,4160);
assert(starts==speech_before); // a drag starting on Say is still only movement
page.revision++; ht_form_reply(&form,"form-test",form.request,true,&page,4200); scene_take();
tap(5000,220,391); assert(starts==speech_before+1);
tap(5200,220,391); assert(starts==speech_before+1); // rapid duplicate cannot open twice
reset(); strcpy(form.id,"find-test"); s.view=FORM;
form.page=(ht_form_page_t){.active=true,.enabled=true,.can_query=true,.revision=1,
.position=1,.total=2,.title="Find Harness",.label="Fix login screen",
.detail="Codex / M2\nopenharness",.query="login",.next="Login flow tests",.action="open"};
scene_take(); portrait(dir,"find-named");
reset(); s.view=QUESTION; s.q.valid=s.q.supported=true; s.q.count=1; s.q.revision=1;
strcpy(s.q.agent,"a"); strcpy(s.q.token,"token-a"); strcpy(s.q.name,"Research helper");
strcpy(s.q.item[0].prompt,"One\nTwo\nThree\nFour\nFive\nSix\nSeven\nEight");
s.q.item[0].count=3;
strcpy(s.q.item[0].options[0],"This file"); strcpy(s.q.item[0].options[1],"Whole project"); strcpy(s.q.item[0].options[2],"Leave it");
scene_take(); habitat_touch(true,233,270,1000); habitat_touch(true,233,150,1100); habitat_touch(false,233,150,1180);
assert(s.offset==3 && !starts && !question_sends && !s.q.item[0].selected);
scene_take(); tap(2000,300,370); assert(s.view==CHOICE);
scene_take(); habitat_touch(true,233,240,2500); habitat_touch(true,233,195,2580); habitat_touch(false,233,195,2650);
assert(s.q.choice==1 && !s.q.item[0].selected && !question_sends);
scene_take(); tap(3000,233,320); assert(s.q.item[0].selected==2);
scene_take(); tap(4000,305,393); assert(s.view==ANSWER_REVIEW && !question_sends);
scene_take(); tap(4150,305,393); assert(!question_sends); // Rapid second tap cannot skip review.
scene_take(); tap(4800,305,393); assert(question_sends==1 && s.q.pending && !starts);
strcpy(s.agents[0].name,"Research helper");
s.q.pending=false;s.q.item[0].selected=0;s.q.item[0].can_text=true;question_sends=0;view(QUESTION);scene_take();
habitat_touch(true,223,350,6000);habitat_touch(true,223,280,6100);habitat_touch(false,223,280,6180);
assert(!starts && !question_sends); // Drag beginning on Say still reads.
scene_take();tap(7000,223,350);assert(starts==1 && s.view==VOICE && s.voice_return==QUESTION);
assert(!strcmp(target,"a") && !strcmp(voice_context,"token-a"));scene_take();portrait(dir,"question-listening");
tap(7140,233,220);assert(!stops); // Say's second tap cannot instantly end the new capture.
tap(7800,233,220);assert(stops==1 && !question_sends);
s.voice_open=false;strcpy(s.q.item[0].draft,"reviewed-draft");
strcpy(s.q.item[0].answer,"Keep the public API. Only change the parser.");view(ANSWER_REVIEW);
ht_gesture_guard(&gesture,9000);scene_take();tap(9050,330,350);assert(!question_sends);
scene_take();tap(9600,330,350);assert(question_sends==1);
reset(); tap(1000,233,220); scene_take();
habitat_touch(true,233,220,2000); surface_tick(2675); assert(s.voice_review_preview); scene_take(); portrait(dir,"voice-review-hold");
habitat_touch(false,233,220,2750); assert(stops==1 && reviews==1);
reset(); tap(1000,233,220); scene_take();
habitat_touch(true,233,220,2000); habitat_touch(true,233,195,2050); surface_tick(2700);
assert(!s.voice_review_preview); habitat_touch(false,233,220,2800); assert(!stops && !reviews);
reset(); tap(1000,233,220); scene_take();
habitat_touch(true,233,220,2000); surface_tick(4000); habitat_touch(false,233,220,4100);
assert(!stops && !reviews); // Resting a hand is not review.
// On a Swarm face an older daemon takes no review: the hold does not promise one.
reset(); tap(1000,233,220); scene_take(); s.voice_swarm=true;
habitat_touch(true,233,220,2000); surface_tick(2675); assert(!s.voice_review_preview);
reset(); s.view=DRAFT;
ht_draft_page_t draft_page={.active=true,.revision=1,.can_send=true,.id="draft-one",.agent="a",.name="Parser helper",
.text="Keep the public API.\n\nOnly change the parser.\nPreserve existing tests.\nAdd Unicode coverage.\nDo not rename exports.\nKeep async behavior.\nKeep all exported types.",.position=1,.total=2};
ht_draft_open(&draft,&draft_page,draft_emit,NULL);scene_take();portrait(dir,"voice-draft");
ht_gesture_guard(&gesture,1000);tap(1100,300,389);assert(!draft_actions); // Fast second tap cannot Send.
scene_take();habitat_touch(true,233,250,2000);habitat_touch(true,233,170,2080);habitat_touch(false,233,170,2160);
assert(!starts && s.offset==2 && !draft_actions);scene_take();
habitat_touch(true,233,250,3000);habitat_touch(true,233,90,3080);habitat_touch(false,233,90,3160);
assert(!draft_actions && !starts);
scene_take();
habitat_touch(true,233,280,3200); habitat_touch(true,233,60,3260); habitat_touch(false,233,60,3340);
assert(draft_actions==1 && draft_command.op==HT_DRAFT_MOVE && !starts);
draft_page.revision=2;draft_page.position=2;strcpy(draft_page.text,"And keep the documentation up to date.");
ht_draft_reply(&draft,draft_page.id,draft.request,true,&draft_page);scene_take();tap(4000,233,220);
assert(starts==1 && s.voice_return==DRAFT && !strcmp(voice_context,"draft-one"));
s.voice_open=recording=false;view(DRAFT);scene_take();
habitat_touch(true,233,220,5000);habitat_touch(false,233,220,5750);scene_take();
assert(s.view==DRAFT_OPTIONS && starts==1);portrait(dir,"voice-draft-options");
tap(6400,200,330);assert(s.view==DRAFT);scene_take();tap(7200,305,389);
assert(draft.pending && draft_command.op==HT_DRAFT_SEND && draft_actions==2);
reset(); view(SELECTION); ht_selection_open(&selection,"pick-test","a",1000,select_emit,NULL);
assert(ht_selection_reply(&selection,selection.request,"pick-test",true,1,"A remembered phrase",1,false,NULL,1010));
scene_take(); tap(1600,110,362); assert(starts==1 && s.voice_search && !strcmp(voice_context,"pick-test"));
scene_take(); portrait(dir,"search-listening");
tap(2300,233,220); assert(stops==1 && !reviews);
s.voice_open=recording=false; view(SELECTION);
assert(ht_selection_found(&selection,"pick-test","a",2,"ERROR: connection refused. Retrying in five seconds.",2,"connection refused",2,7));
scene_take(); portrait(dir,"output-search");
habitat_touch(true,233,290,3000); habitat_touch(true,233,230,3060); habitat_touch(false,233,230,3120);
assert(selected_command.op==HT_SELECT_MATCH && selected_command.delta==1 && starts==1 && !moves);
assert(ht_selection_reply_search(&selection,selection.request,"pick-test",true,3,"connection refused again",1,false,NULL,"connection refused",3,7,3200));
scene_take(); tap(3700,233,220); assert(starts==2 && !s.voice_search); // matched passage becomes ordinary quoted speech
s.voice_open=recording=false; view(SELECTION);
assert(ht_selection_found(&selection,"pick-test","a",4,"",0,"missing phrase",0,0));
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.
// 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); }
view(AGENTS); scene_take(); assert(s.hit_count==5);
habitat_touch(true,233,380,1000); habitat_touch(true,233,100,1300);
assert(s.offset==4 && !starts && !switches && !moves);
habitat_touch(false,233,100,1375); scene_take();
assert(s.offset==4 && !strcmp(make_action(s.hits[4]).id,"pane-7"));
portrait(dir,"panes-last");
// FOCUS'S PANES (design 2026-10-06): paged like the tabs. The pane on the face is the chosen page, Inter 44 green,
// "claude - Harness" on two balanced lines ("claude -" / "Harness"), the next one peeking in Inter 28; "PANES" on
// top, a green Done at the foot. A swipe browses and changes nothing; Done opens the chosen pane; no close pill.
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); s.count=3; s.active=0;
{
const char *names[3]={"claude - Harness","Energy","Opencode"};
for(int i=0;i<3;i++) { snprintf(s.agents[i].id,sizeof s.agents[i].id,"pane-%d",i); COPY(s.agents[i].name,names[i]); }
dispatch((action_t){.kind=A_AGENTS}); scene_take(); portrait_focus(dir,"focus-panes");
int big=0, small=0; bool done=false;
for(int i=0;i<scene.count;i++) {
const ht_run_t *r=&scene.runs[i];
if (r->font==&ht_lv_inter_44.base && r->text[0]) {
big++; assert(r->fg==color(HT_THEME_VOICE) && !strcmp(r->text, big==1 ? "claude -" : "Harness"));
assert(abs(r->x + r->w / 2 - 233) <= 1 && r->y == (big==1 ? 181 : 233) + (52 - ht_lv_inter_44.base.height) / 2);
}
if (r->font==&ht_lv_inter_28.base && r->text[0]) { small++; assert(r->x >= 393 && r->fg != color(0x6a6962)); }
done |= !strcmp(r->text,HT_DONE) && r->y==400 && r->fg==color(HT_THEME_VOICE);
}
assert(big==2 && small>=1 && done);
// The header: "PANES" a letter to a run in Inter 20, grey, spaced 2 at y 62.
{
const char *letters = "PANES"; int at = -1, found = 0;
for(int i=0;i<scene.count;i++) if (scene.runs[i].y == 62 && scene.runs[i].text[0] && !scene.runs[i].text[1]) {
assert(scene.runs[i].font == &ht_lv_inter_20.base && scene.runs[i].fg == color(0x4c4c4c));
assert(scene.runs[i].text[0] == letters[found]);
if (found) assert(scene.runs[i].x == at);
at = scene.runs[i].x + scene.runs[i].w + 2; found++;
}
assert(found == 5);
}
int runs = scene.count;
// A swipe to the left: the next page, and nothing switched.
habitat_touch(true,300,233,1000);
for (int k=1;k<=5;k++) habitat_touch(true,300-k*12,233,1000+k*40);
habitat_touch(false,240,233,1260);
for (uint32_t t=1200;t<=1800;t+=16) surface_tick(t);
scene_take();
assert(ht_tab_carousel_index(&pane_carousel)==1 && !switches && s.view==AGENTS && scene.count==runs);
bool energy=false;
for(int i=0;i<scene.count;i++) energy |= scene.runs[i].font==&ht_lv_inter_44.base && !strcmp(scene.runs[i].text,"Energy");
assert(energy);
tap(2500,233,420); assert(switches==1 && s.view==AGENT && s.active==1); // Done opens it
dispatch((action_t){.kind=A_AGENTS}); scene_take();
assert(ht_tab_carousel_index(&pane_carousel)==1); // and the pages open on it next time
for (int i = 0; i < scene.count; i++) assert(strcmp(scene.runs[i].text, HT_LV_CROSS)); // no close pill
switches=0;
tap(4500,233,233); assert(switches==1 && s.view==AGENT && s.active==1); // a tap on the name opens it, as Done does
// The run count holds while the finger drags, and nothing leaves the glass.
dispatch((action_t){.kind=A_AGENTS}); scene_take(); runs = scene.count;
for (int d = -200; d <= 200; d += 40) {
int keep = pane_carousel.position; pane_carousel.position = keep + d;
ht_scene_t dragged; ht_scene_clear(&dragged, BG); s.hit_count = 0; render_agents(&dragged);
assert(dragged.count == runs);
for (int i = 0; i < dragged.count; i++) { ht_rect_t r = ht_run_bounds(&dragged.runs[i]); assert(r.x >= 0 && r.x + r.w <= HT_WIDTH); }
pane_carousel.position = keep;
}
}
// A long Vietnamese name: two balanced lines, each cut to 300 px with "…".
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); s.count=2; s.active=0;
{
COPY(s.agents[0].id,"p0"); COPY(s.agents[0].name,"Tri\xe1\xbb\x83n khai firmware m\xe1\xbb\x9bi nh\xe1\xba\xa5t cho m\xe1\xbb\x8di thi\xe1\xba\xbft b\xe1\xbb\x8b");
COPY(s.agents[1].id,"p1"); COPY(s.agents[1].name,"Nguy\xe1\xbb\x85n V\xc4\x83n \xe1\xba\xbe");
dispatch((action_t){.kind=A_AGENTS}); scene_take(); portrait_focus(dir,"focus-panes-vietnamese");
int seen=0; bool cut=false;
for(int i=0;i<scene.count;i++) if (scene.runs[i].font == &ht_lv_inter_44.base && scene.runs[i].text[0]) {
seen++; assert(scene.runs[i].w <= 300 && ht_measure(scene.runs[i].font, scene.runs[i].text) == scene.runs[i].w);
size_t n=strlen(scene.runs[i].text); cut |= n>3 && !strcmp(scene.runs[i].text+n-3,"\xe2\x80\xa6");
}
assert(seen==2 && cut);
bool whole=false;
for(int i=0;i<scene.count;i++) whole |= scene.runs[i].font == &ht_lv_inter_44.base && !strcmp(scene.runs[i].text,"Tri\xe1\xbb\x83n khai");
assert(whole);
}
// The empty page (design 2026-10-06): "No panes in / this tab." on two Inter 44 lines centred on the glass, the header
// as ever, "Choose a tab" in Inter 28 on a 260 x 64 pill at (103, 333) that opens the tabs; loading on one line,
// the run count unchanged.
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); s.count=0; s.connected=true;
{
view(AGENTS); scene_take(); portrait_focus(dir,"focus-panes-empty");
int lines=0; bool pill=false, box=false, header=false;
for(int i=0;i<scene.count;i++) {
const ht_run_t *r=&scene.runs[i];
if(!strcmp(r->text,"No panes in")) { lines++; assert(r->font==&ht_lv_inter_44.base && r->y==181+(52-ht_lv_inter_44.base.height)/2); }
if(!strcmp(r->text,"this tab.")) { lines++; assert(r->font==&ht_lv_inter_44.base && r->y==233+(52-ht_lv_inter_44.base.height)/2); }
if(!strcmp(r->text,"Choose a tab")) pill = r->font == &ht_lv_inter_28.base && abs(r->x + r->w / 2 - 233) <= 1;
if(r->box.h==64) box = r->x==103 && r->y==333 && r->w==260 && r->box.radius==32 && r->box.fill==color(0x171718) && r->box.border==color(0x3a3f4b);
if(!strcmp(r->text,"P") && r->y == 62) header = r->font == &ht_lv_inter_20.base;
}
assert(lines==2 && pill && box && header);
int runs=scene.count;
tap(1000, 233, 365); assert(s.view==TABS);
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); s.count=0; s.loading=true; view(AGENTS); scene_take();
bool loading=false;
for(int i=0;i<scene.count;i++) loading |= !strcmp(scene.runs[i].text,"Loading...") && scene.runs[i].y==207+(52-ht_lv_inter_44.base.height)/2;
assert(loading && scene.count==runs);
}
// Nine panes: the pages open on the pane on the face ("Pane 5" on two lines), neighbours on both sides.
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); s.count=9; s.active=5;
{
for(int i=0;i<9;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); }
dispatch((action_t){.kind=A_AGENTS}); scene_take();
int big=0, left=0, right=0;
for(int i=0;i<scene.count;i++) { const ht_run_t *r=&scene.runs[i];
if (r->font==&ht_lv_inter_44.base && r->text[0]) { big++; assert(!strcmp(r->text, big==1 ? "Pane" : "5")); }
if (r->font==&ht_lv_inter_28.base && r->text[0]) { if (r->x < 233) left++; else right++; } }
assert(big==2 && left>=1 && right>=1);
portrait_focus(dir,"focus-panes-scrolled");
}
// And its tabs: the same carousel, the tab you are in green.
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS);
s.tab_count=3; COPY(s.tabs[0].id,"t0"); COPY(s.tabs[0].name,"Harness repo"); COPY(s.tabs[1].id,"t1"); COPY(s.tabs[1].name,"Doi");
COPY(s.tabs[2].id,"t2"); COPY(s.tabs[2].name,"Research"); COPY(s.selected_tab,"t0");
dispatch((action_t){.kind=A_TABS}); scene_take(); portrait_focus(dir,"focus-tabs");
{
bool green=false;
// (design 2026-10-06: the chosen tab in Inter 44, green; a two-word name on two balanced lines)
for(int i=0;i<scene.count;i++) if(strstr(scene.runs[i].text,"Harness") && scene.runs[i].fg==color(HT_THEME_VOICE) &&
scene.runs[i].font==&ht_lv_inter_44.base) green=true;
assert(green);
bool title=false, arrow=false, done=false;
for(int i=0;i<scene.count;i++) { title |= !strcmp(scene.runs[i].text,"T") && scene.runs[i].y==62;
arrow |= !strcmp(scene.runs[i].text,"\xe2\x86\x90");
done |= !strcmp(scene.runs[i].text,HT_DONE) && scene.runs[i].y==400; }
assert(title && !arrow && done && action_enabled(A_TAB_DONE) && !action_enabled(A_HOME));
// The chosen "Harness repo" on two balanced lines of Inter 44 (52 px apart, centred on 233); the next tab, "Doi",
// in Inter 28 a letter to a run, each darker than #6a6962 and darker still toward the edge; the close pill
// is gone; the run count holds while the finger drags the pages.
int big_lines = 0, last_x = -1; uint16_t last_ink = 0xffff; bool darker = true;
for(int i=0;i<scene.count;i++) {
const ht_run_t *r=&scene.runs[i];
if (r->font==&ht_lv_inter_44.base && r->text[0]) {
big_lines++;
assert(!strcmp(r->text, big_lines == 1 ? "Harness" : "repo") && r->y == (big_lines == 1 ? 181 : 233) + (52 - ht_lv_inter_44.base.height) / 2);
}
if (r->font==&ht_lv_inter_28.base && r->text[0]) {
uint16_t c = r->fg;
assert(((c >> 5) & 63) < ((color(0x6a6962) >> 5) & 63));
if (last_x >= 0 && r->x > last_x) darker &= ((c >> 5) & 63) <= ((last_ink >> 5) & 63);
last_x = r->x; last_ink = c;
}
}
assert(big_lines == 2 && last_x >= 0 && darker);
int closes = 0;
for (int i = 0; i < s.hit_count; i++) closes += s.hits[i].action == A_TAB_DONE && s.hits[i].rect.y == 0;
for (int i = 0; i < scene.count; i++) assert(strcmp(scene.runs[i].text, HT_LV_CROSS));
assert(closes == 0); // no close pill (owner, 2026-10-06)
int runs = scene.count;
for (int d = -200; d <= 200; d += 40) {
int keep = tab_carousel.position; tab_carousel.position = keep + d;
ht_scene_t dragged; ht_scene_clear(&dragged, BG); s.hit_count = 0; render_tabs(&dragged);
assert(dragged.count == runs);
for (int i = 0; i < dragged.count; i++) { ht_rect_t b = ht_run_bounds(&dragged.runs[i]);
assert(b.x >= 0 && b.x + b.w <= HT_WIDTH); }
tab_carousel.position = keep;
}
scene_take();
tap(3000,233,420); assert(s.view==HOME);
dispatch((action_t){.kind=A_TABS}); scene_take();
tap(4000,233,233); assert(s.view==HOME); // a tap on the chosen name is the check too
}
// The Focus states that say something plain: connecting (the wordmark) and a tab list with no tabs.
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); s.connected = false; scene_take();
{
bool brand = false;
for (int i = 0; i < scene.count; i++) brand |= !strcmp(scene.runs[i].text, "Harness") && scene.runs[i].font == &ht_lv_inter_bold_48.base;
assert(brand);
}
portrait_focus(dir,"focus-connecting");
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); s.tab_count = 0; s.selected_tab[0] = 0;
dispatch((action_t){.kind=A_TABS}); scene_take();
{
bool none = false;
for (int i = 0; i < scene.count; i++) none |= !strcmp(scene.runs[i].text, "No tabs yet.") && scene.runs[i].font == &ht_lv_inter_30.base;
assert(none);
}
portrait_focus(dir,"focus-empty-tabs");
// EVERY PAGE THE FOCUS SKIN CAN SHOW IS INTER (owner, 2026-10-02: "all pages, one font"): the question, its
// choices and the answer review, the controls list, the empty inbox, the machines list, the workspace preview,
// the form, the selection pages and the draft. Each is scanned for a face that is not Inter, for ink outside
// r 230, and for a bracket control drawn outside its own hit rect; the mono skins' pages are byte-for-byte the
// goldens above.
{
// Wrapping: whole words at the width, a word wider than the line cut at a letter, every line within it.
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS);
{
const ht_font_t *body = &ht_lv_inter_25.base;
const char *words = "The quick brown fox jumps over the lazy dog and keeps running through the whole afternoon without stopping";
const char *p = words; int lines = 0;
while (*p) { const char *e = focus_take(&p, body, 200); assert(ht_measure(body, "x") > 0 && e > p - strlen(p) - 200); lines++; }
assert(lines == focus_rows(words, body, 200) && lines >= 5);
const char *wide = "Supercalifragilisticexpialidocious_and_longer_still_than_any_line_could_hold";
assert(focus_rows(wide, body, 120) >= 4);
ht_scene_clear(&scene, BG);
assert(ui_wrap(&scene, 59, 146, 348, 3, 0, UI_FONT, FG, words) == focus_rows(words, body, 348));
assert(scene.count == 3);
for (int i = 0; i < scene.count; i++) assert(scene.runs[i].font == body && ht_measure(body, scene.runs[i].text) <= 348);
ht_scene_clear(&scene, BG); ui_wrap(&scene, 59, 146, 348, 3, 0, UI_FONT, FG, "short"); assert(scene.count == 3); // run count is constant
assert(ui_can_display("Thêm phần kiểm tra \xe2\x80\xa6 \xe2\x9c\x93", UI_FONT, 348, 8));
assert(!ui_can_display("emoji \xf0\x9f\x90\x88", UI_FONT, 348, 8) && !ui_can_display("arrow \xe2\x86\x92", UI_FONT, 348, 8));
assert(!ui_can_display(words, UI_FONT, 200, 2) && ui_can_display(words, UI_FONT, 200, 9));
}
// The question: the long prompt that scrolls, a short one, loading, the error, and a second option page.
#define FOCUS_QUESTION() do { reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); \
s.view=QUESTION; s.q.valid=s.q.supported=true; s.q.count=1; s.q.revision=1; strcpy(s.q.agent,"a"); \
strcpy(s.q.token,"token-a"); strcpy(s.q.name,"Research helper"); \
strcpy(s.q.item[0].prompt,"Which database should the retry queue use? It must survive a restart, stay quick under load, and be easy to back up on a laptop."); \
s.q.item[0].count=3; strcpy(s.q.item[0].options[0],"This file only"); \
strcpy(s.q.item[0].options[1],"Thêm phần kiểm tra cho toàn bộ dự án"); strcpy(s.q.item[0].options[2],"Leave it as it is"); } while (0)
FOCUS_QUESTION(); s.q.item[0].can_text = true; FOCUS_PAGE("lit-question");
assert(action_enabled(A_QUESTION_SAY) && action_enabled(A_QUESTION_CHOICES));
FOCUS_QUESTION(); strcpy(s.q.item[0].prompt, "Ship it?"); FOCUS_PAGE("lit-question-short");
FOCUS_QUESTION(); s.q.item[0].can_text = true; snprintf(s.q.speech_error,sizeof s.q.speech_error,"%s","Cannot show that answer. Say it again."); FOCUS_PAGE("lit-question-error");
FOCUS_QUESTION(); s.q.loading = true; FOCUS_PAGE("lit-question-loading");
FOCUS_QUESTION(); s.q.error[0]='N'; s.q.error[1]=0; snprintf(s.q.error,sizeof s.q.error,"%s","The desktop could not read this question."); FOCUS_PAGE("lit-question-failed");
FOCUS_QUESTION(); s.q.supported = false; FOCUS_PAGE("lit-question-unsupported");
FOCUS_QUESTION(); s.view = CHOICE; s.q.choice = 1; FOCUS_PAGE("lit-choices");
FOCUS_QUESTION(); s.view = CHOICE; s.q.choice = 1; s.q.item[0].selected = 2; FOCUS_PAGE("lit-choices-selected");
FOCUS_QUESTION(); s.view = ANSWER_REVIEW; strcpy(s.q.item[0].answer, "Keep the public API. Only change the parser, and preserve the existing tests."); s.q.item[0].selected = 1;
FOCUS_PAGE("lit-answer-review");
FOCUS_QUESTION(); s.view = ANSWER_REVIEW; s.q.item[0].can_text = true; strcpy(s.q.item[0].draft, "d"); strcpy(s.q.item[0].answer, "Yes, ship it today."); FOCUS_PAGE("lit-answer-draft");
FOCUS_QUESTION(); s.view = ANSWER_REVIEW; strcpy(s.q.item[0].answer, "Yes."); s.q.pending = true; FOCUS_PAGE("lit-answer-waiting");
FOCUS_QUESTION(); s.view = ANSWER_REVIEW; s.q.error[0] = 0; snprintf(s.q.error,sizeof s.q.error,"%s","That answer could not be sent."); FOCUS_PAGE("lit-answer-error");
#undef FOCUS_QUESTION
// The controls list, at the top and scrolled, and the pressed row.
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); view(SETTINGS); FOCUS_PAGE("lit-controls");
assert(action_enabled(A_INBOX));
s.offset = 3; FOCUS_PAGE("lit-controls-scrolled");
s.offset = 0; s.pressed = 1; FOCUS_PAGE("lit-controls-pressed");
// The empty inbox ("No notification", design 2026-10-06) and the machines list.
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); view(INBOX); s.notice_count = 0; FOCUS_PAGE("lit-inbox-empty");
{
bool caught = false;
for (int i = 0; i < scene.count; i++) caught |= !strcmp(scene.runs[i].text, "No notification") && scene.runs[i].font == &ht_lv_inter_25.base &&
scene.runs[i].fg == color(0xada6ad);
assert(caught);
}
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); view(MACHINES); s.machine_count = 2;
strcpy(s.machines[0].id, "m1"); strcpy(s.machines[0].name, "MacBook Pro of the studio"); strcpy(s.machines[0].state, "ready"); s.machines[0].local = true;
strcpy(s.machines[1].id, "m2"); strcpy(s.machines[1].name, "Mini"); strcpy(s.machines[1].state, "offline");
FOCUS_PAGE("lit-machines");
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); view(MACHINES); s.machine_count = 0; FOCUS_PAGE("lit-machines-empty");
// The workspace preview held while dragging across the tabs.
workspace_setup(); ht_character_select(&character, HT_CHARACTER_FOCUS);
workspace.touching = workspace.moved = true; workspace.choice = 3; workspace.origin = 1; FOCUS_PAGE("lit-workspace-preview");
assert(s.hit_count == 4);
workspace.choice = 1; strcpy(s.tabs[1].name, "Quarterly planning and roadmap review"); FOCUS_PAGE("lit-workspace-preview-long");
// The form (find and new), the selection pages, the draft and its options.
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); ht_form_open(&form,"form-test",100,form_emit,NULL);
{
ht_form_page_t fp={.active=true,.enabled=true,.revision=1,.position=2,.total=4,.title="New Harness",
.label="Claude Code in the monorepo",.action="start",.previous="Options",.detail="Claude Code\nM2:~/code/harness",.can_query=true};
ht_form_reply(&form,"form-test",form.request,true,&fp,101); s.view=FORM; FOCUS_PAGE("lit-form");
fp.error[0]=0; strcpy(fp.error,"That folder is not there."); fp.revision++; ht_form_reply(&form,"form-test",form.request,true,&fp,102); FOCUS_PAGE("lit-form-error");
}
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); view(SELECTION); ht_selection_open(&selection,"pick-test","a",1000,select_emit,NULL);
FOCUS_PAGE("lit-selection-pending");
assert(ht_selection_reply(&selection,selection.request,"pick-test",true,1,"A highlighted paragraph from the desktop, long enough to wrap onto a second and a third line of the page.",3,true,NULL,1010));
FOCUS_PAGE("lit-selection");
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); s.view=DRAFT;
{
ht_draft_page_t dp={.active=true,.revision=1,.can_send=true,.id="draft-one",.agent="a",.name="Parser helper",
.text="Keep the public API.\n\nOnly change the parser.\nPreserve existing tests.\nAdd Unicode coverage.",.position=1,.total=2};
ht_draft_open(&draft,&dp,draft_emit,NULL); FOCUS_PAGE("lit-draft");
s.view=DRAFT_OPTIONS; FOCUS_PAGE("lit-draft-options");
}
}
// THE DESIGN EXPORT (mockup/focus_design.py): the Focus home and voice states once per engine with a scene, so
// Claude and Codex are both on the sheet. Pictures only; the checks above cover these states.
if (dir) {
static const char *engines[2] = {"claude", "codex"};
for (int e = 0; e < 2; e++) {
char name[64];
#define DESIGN(state) do { snprintf(name, sizeof name, "design-%s-%s", engines[e], state); portrait(dir, name); } while (0)
#define DESIGN_HOME() do { reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); \
strcpy(s.agents[0].engine, engines[e]); strcpy(s.agents[1].engine, engines[e]); \
strcpy(s.agents[0].name, "Payments refactor"); strcpy(s.agents[1].name, "Landing page"); } while (0)
DESIGN_HOME(); fake_ms = 1200; scene_take(); DESIGN("rest");
DESIGN_HOME();
ui_project_emit("a", "sess", "summary", "Shipped the retry queue and moved the parser tests to the new fixtures. All 44 checks pass.",
"Shipped the retry queue and moved the parser tests to the new fixtures. All 44 checks pass.");
fake_ms = 1200; scene_take(); DESIGN("recap");
DESIGN_HOME(); s.agents[0].busy = true; strcpy(s.agents[0].tool, "Coalescing");
fake_ms = 1200; scene_take(); s.agents[0].busy_ms = 1; fake_ms = 34000 + 1200; scene_take(); DESIGN("working");
{
cable_notif_t note = {.agent_id = "b", .name = "Landing page", .machine = "MacBook", .summary = "Hero and pricing are in."};
ui_notif_replace(¬e, 1);
fake_ms = 35000; scene_take(); DESIGN("working-notice");
}
DESIGN_HOME();
{
cable_notif_t asked = {.agent_id = "a", .name = "Payments refactor", .question = true,
.summary = "Which database should the retry queue use?"};
ui_notif_replace(&asked, 1); fake_ms = 1200; scene_take(); DESIGN("question");
}
DESIGN_HOME(); fake_ms = 1200; dispatch((action_t){.kind = A_VOICE, .id = "a"}); scene_take(); DESIGN("voice-listening");
DESIGN_HOME(); fake_ms = 1200; dispatch((action_t){.kind = A_VOICE, .id = "a"}); s.voice_waiting = true; scene_take(); DESIGN("voice-sending");
#undef DESIGN_HOME
#undef DESIGN
}
}
// Every advertised optional control is present, none appear for a legacy host.
reset(); host_features=0; view(SETTINGS); scene_take();
assert(settings_count()==5 && !action_enabled(A_FORM) && !action_enabled(A_LATEST));
portrait(dir,"controls-core");
habitat_touch(true,233,370,1000); habitat_touch(true,233,160,1250); habitat_touch(false,233,160,1300);
// Five rows without the optional controls, so the list scrolls to its one remaining offset and
// Nap — the only preference-shaped thing the glass kept — is reachable there.
scene_take(); assert(s.offset==1 && action_enabled(A_NAP));
portrait(dir,"controls-core-scroll");
dispatch((action_t){.kind=A_FIND}); assert(s.view==AGENTS && !form_actions && !starts);
dispatch((action_t){.kind=A_LATEST,.id="a"}); assert(!visit_sends);
reset(); host_features=0; tap(1000,233,220); assert(starts==1 && recording);
habitat_touch(true,233,220,2000); surface_tick(2700); assert(!s.voice_review_preview);
habitat_touch(false,233,220,2800); assert(!stops && !reviews && recording);
tap(3400,233,220); assert(stops==1 && !reviews);
puts("touch UI: PASS (production contacts/renderers; voice start/finish/discard, target pinning, sensor cancellation, immediate scroll, swipes, round trips, congestion and holds)");
// Last, so every face above renders exactly as it did before chats: the faces are compared byte for byte.
swarm_chat_checks(argc>1 ? argv[1] : NULL);
swarm_restart_checks();
swarm_buddy_checks(argc>1 ? argv[1] : NULL);
swarm_pair_checks(argc>1 ? argv[1] : NULL);
swarm_pick_checks(argc>1 ? argv[1] : NULL);
swarm_thread_checks(argc>1 ? argv[1] : NULL);
swarm_thread_notice_checks();
swarm_tag_notice_checks();
}
'''
extra_sources = []
extra_includes = ['-DDEVICE_HABITAT_ORANGE=1'] if os.environ.get('HABITAT_TEST_ORANGE') else []
if os.environ.get('HABITAT_BRIDGE_TRACE'):
from bridge_flow_replay import instrument
code = instrument(code, os.environ['HABITAT_BRIDGE_TRACE'], native.parent.parent)
json_dir = Path(os.environ['IDF_PATH']) / 'components/json/cJSON'
extra_sources = [str(json_dir / 'cJSON.c'), str(native.parent.parent / 'cable_frame.c'),
str(native.parent.parent / 'cable_json_guard.c')]
extra_includes += ['-I', str(json_dir), '-I', str(native.parent.parent), '-Wno-deprecated-declarations']
with tempfile.TemporaryDirectory(prefix='harness-touch-ui-') as d:
out = Path(d)
(out / 'touch_ui.c').write_text(code)
subprocess.run(['cc','-std=c11', '-D_POSIX_C_SOURCE=200809L','-Wall','-Wextra','-Werror','-O1','-g',
'-fsanitize='+os.environ.get('SANITIZERS','undefined,bounds'),
*extra_includes, '-I',str(native),str(out/'touch_ui.c'), *extra_sources, str(native/'gestures.c'),
str(native/'form.c'),str(native/'visit.c'),str(native/'draft.c'), str(native/'scroll.c'),str(native/'selection.c'),str(native/'carry.c'),str(native/'tim.c'),str(native/'character_motion.c'),str(native/'character_layout.c'),str(native/'character.c'),str(native/'illustrated.c'),str(native/'tux.c'),str(native/'focus.c'),str(native/'lvgl_fonts.c'),str(native/'lvgl_icons.c'),str(native/'focus_marks.c'),str(native/'focus_faces.c'),str(native/'pets.c'),str(native/'../../pet_store.c'),str(native/'../../elapsed.c'),str(native/'terminal.c'),
str(native/'fonts.c'),str(native/'octopus.c'),str(native/'ascii_clip.c'),str(native/'octopus_font.c'),str(native/'workspace.c'),str(native/'supertab.c'),str(native/'command_face.c'),'-o',str(out/'touch_ui'),'-lm'],check=True)
args=[str(out/'touch_ui')]
if os.environ.get('HABITAT_PREVIEW_DIR'):
dest=Path(os.environ['HABITAT_PREVIEW_DIR']);dest.mkdir(parents=True,exist_ok=True)
args.append(str(dest))
subprocess.run(args,check=True)
tux_env = dict(os.environ, HABITAT_TEST_TUX='1')
if len(args) == 2:
tux_preview = Path(args[1]) / 'tux'; tux_preview.mkdir(exist_ok=True)
args[1] = str(tux_preview)
subprocess.run(args,check=True,env=tux_env)