Skip to content

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.

fix(device): the bell does not count the agent on the face

0xdiego254ef894e30f00
diff --git a/devices/harness-device/firmware/main/ui/habitat/ui_habitat.c b/devices/harness-device/firmware/main/ui/habitat/ui_habitat.c
index ebd83380d..2e7f2cc4f 100644
--- a/devices/harness-device/firmware/main/ui/habitat/ui_habitat.c
+++ b/devices/harness-device/firmware/main/ui/habitat/ui_habitat.c
@@ -338,10 +338,19 @@ static void change(void)
s.dirty = true;
habitat_render_notify();
}
-static unsigned notice_unread(void)
+/*
+ * What the bell counts: unread notices about any agent EXCEPT the one on the face.
+ *
+ * That agent's news is already on the glass — its recap, or its question in the recap's place — so
+ * counting it too told a person something else had happened, somewhere else (owner, 2026-09-30:
+ * people took the +1 for another agent's news). Nothing is marked read by this: look away from that agent
+ * and its unanswered question counts again, until it is answered.
+ */
+static unsigned notice_unread(const char *except)
{
unsigned count = 0;
- for (int i = 0; i < s.notice_count; i++) count += !s.notice[i].read_on_dial;
+ for (int i = 0; i < s.notice_count; i++)
+ count += !s.notice[i].read_on_dial && !(except && !strcmp(s.notice[i].agent_id, except));
return count;
}
static bool notice_was_read(const cable_notif_t *n)
@@ -858,7 +867,7 @@ static void render_home(ht_scene_t *f)
bool rotating = home_caption_rotates() && character.id != HT_CHARACTER_FOCUS;
const char *caption = rotating && home_caption.activity ? activity : a ? a->name : "Choose a pane";
bool bell = !s.voice_retry_until && !carry.active && !carry.error[0] && !visit.available;
- unsigned unread = notice_unread();
+ unsigned unread = notice_unread(a ? a->id : NULL);
bell = bell && unread > 0;
char status[100];
if (s.voice_retry_until) COPY(status, "Try again");
@@ -2514,7 +2523,7 @@ void habitat_touch(bool down, int x, int y, uint32_t now)
// Reading/choosing consumed this contact; motion cannot submit an answer.
} else if (s.view == SELECTION) {
// Its bounded reading cursor already consumed this vertical drag.
- } else if (surface && character.id == HT_CHARACTER_FOCUS && dy > 0 && notice_unread()) {
+ } else if (surface && character.id == HT_CHARACTER_FOCUS && dy > 0 && notice_unread(active() ? active()->id : NULL)) {
// Pull down from the badge. The creature skins keep this drag inert — their footer
// badge is a target you tap — but on Focus the badge sits at the top edge and a pull
// is the gesture the rest of the world already means by it.
diff --git a/devices/harness-device/firmware/test/bridge_flow_replay.py b/devices/harness-device/firmware/test/bridge_flow_replay.py
index 2226f236e..87dfe279c 100644
--- a/devices/harness-device/firmware/test/bridge_flow_replay.py
+++ b/devices/harness-device/firmware/test/bridge_flow_replay.py
@@ -53,7 +53,7 @@ static void audio_notify_done(void) {} // no real speaker or audio hardware in t
extra += 'assert(!decoder.corrupt_frames && !decoder.discarded_bytes && !s_bad && !s_unknown && s_last_rx_us);scene_take();\n'
extra += f'assert(active()->busy=={str(wanted["busy"]).lower()});assert(result_visible()=={str(wanted["recap"]).lower()});\n'
extra += 'assert(!strcmp(active()->tool,' + json.dumps(wanted['status']) + '));\n'
- extra += 'assert(title_is(active()->name));char bell[24];unsigned unread=notice_unread();if(unread)snprintf(bell,sizeof bell,HT_BELL \" %u\",unread);else bell[0]=0;assert(status_is(bell));\n'
+ extra += 'assert(title_is(active()->name));char bell[24];unsigned unread=notice_unread(active()?active()->id:NULL);if(unread)snprintf(bell,sizeof bell,HT_BELL \" %u\",unread);else bell[0]=0;assert(status_is(bell));\n'
display_status = wanted.get('display_status', wanted['status'])
if display_status:
extra += 'fake_ms+=3400;surface_tick(fake_ms);scene_take();\n'
diff --git a/devices/harness-device/firmware/test/test_touch_ui.py b/devices/harness-device/firmware/test/test_touch_ui.py
index dd2665473..936e26ebe 100644
--- a/devices/harness-device/firmware/test/test_touch_ui.py
+++ b/devices/harness-device/firmware/test/test_touch_ui.py
@@ -1017,19 +1017,19 @@ static void notification_read_checks(const char *dir) {
// Exact occurrence receipts: no focus, no answering, idempotent retries.
cable_notif_t synced={.agent_id="a",.name="Build",.summary="The build passed. All checks are green.",.read_token="turn-1"};
reset(); ui_notif_replace(&synced,1); ui_notif_open(); scene_take();
- assert(notice_reads_sent==1 && !notice_unread() && !strcmp(notice_read_queued.text,"turn-1"));
+ assert(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());
+ 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()==1);
- ui_notif_read("a","turn-1"); assert(notice_unread()==1); // stale, identical text
+ 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() && s.view==INBOX && !question_sends);
+ 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);
@@ -1037,62 +1037,65 @@ static void notification_read_checks(const char *dir) {
reset(); ui_notif_replace(&synced,1); ui_notif_open(); present_scene=false; scene_take();
uint32_t old_frame=habitat_scene_receipt(); strcpy(synced.read_token,"question-2");
ui_notif_replace(&synced,1); habitat_scene_presented(old_frame);
- assert(notice_unread()==1 && !notice_reads_sent); // late DMA cannot read a new occurrence
+ 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();
- assert(notice_unread()==2 && status_is(HT_BELL " 2"));
+ // 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()==2); // Constructing a frame is not reading it.
- fake_asleep=true; habitat_scene_presented(frame); assert(notice_unread()==2);
+ 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()==1 && s.view==INBOX && s.notice_count==2 && s.notice[s.offset].question);
+ assert(notice_unread(NULL)==1 && s.view==INBOX && s.notice_count==2 && s.notice[s.offset].question);
assert(!question_sends && !desktop_opens && !starts);
- present_scene=true; view(HOME); scene_take(); assert(status_is(HT_BELL " 1"));
+ // 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() && s.notice_count==2 && s.view==INBOX);
+ 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() && status_is("")); // Late/reconnect snapshot stays read.
+ 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()==1);
- ui_notif_open(); scene_take(); assert(!notice_unread());
+ 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()==1);
+ 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()==1); // Old DMA, new same-text result.
+ 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()==1);
+ 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()==1);
+ 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() && s.view==HOME);
- ui_notif_replace(&newer,1); assert(!notice_unread());
- newer.failed=true; ui_notif_replace(&newer,1); assert(notice_unread()==1);
+ 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() && !desktop_opens && !question_sends && !starts);
+ 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() && desktop_opens==1 && !strcmp(opened_agent,"a"));
+ 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());
+ 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);
@@ -1778,13 +1781,29 @@ int main(int argc, char **argv) {
assert(switches == 1 && !starts);
reset(); ht_character_select(&character, HT_CHARACTER_FOCUS); s.count = 1; scene_take();
tap(1000, 98, 388); tap(1200, 368, 388); assert(!switches && !starts); // one agent: no arrows at all
+ /*
+ * 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 one = false; // bell and count are separate runs there, so the count is read on its own
+ for (int i = 0; i < scene.count; i++) if (scene.runs[i].y == 8 && !strcmp(scene.runs[i].text, "1")) one = true;
+ assert(one);
+ s.active=0; scene_take(); assert(!action_enabled(A_INBOX));
+ }
// 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");
{
cable_notif_t asked={.question=true,.summary="Which database should the retry queue use?"};
COPY(asked.agent_id, s.agents[0].id); COPY(asked.name, s.agents[0].name);
// A pill under the bell, as on glass: the two must not touch.
- s.tab_count=1; COPY(s.tabs[0].id,"tab-0"); COPY(s.tabs[0].name,"Doi song"); COPY(s.selected_tab,"tab-0");
+ 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,1); scene_take(); portrait(dir, "focus-question");
assert(s.view == HOME);
uint16_t gap[HT_WIDTH];