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.

Merge origin/main: the square face on top of the character refactor

0xdiego25d3e1b6be7f54
diff --cc devices/harness-device/firmware/main/ui/habitat/character_layout.c
index 000000000,1bc698aea..f36bd7f27
mode 000000,100644..100644
--- a/devices/harness-device/firmware/main/ui/habitat/character_layout.c
+++ b/devices/harness-device/firmware/main/ui/habitat/character_layout.c
@@@ -1,0 -1,222 +1,250 @@@
+ #include "character_layout.h"
+ #include <stdio.h>
+ #include <string.h>
+
+ bool ht_character_caption_tick(ht_character_caption_t *c, uint32_t now,
+ const char *pane, bool working)
+ {
+ if (!pane) pane = "";
+ bool activity = c->activity;
+ uint8_t opacity = c->opacity;
+ if (!c->initialized || c->working != working || strcmp(c->pane, pane)) {
+ size_t n = strlen(pane);
+ if (n >= sizeof c->pane) n = sizeof c->pane - 1;
+ memcpy(c->pane, pane, n); c->pane[n] = 0;
+ c->began = now; c->initialized = true; c->working = working;
+ }
+ c->activity = false; c->opacity = 255; c->next_ms = 1000;
+ if (working) {
+ uint32_t age = now - c->began, phase = age % 3000;
+ c->activity = (age / 3000) % 2;
+ if (phase >= 2760) {
+ c->opacity = (3000 - phase) * 255 / 240;
+ c->next_ms = 40;
+ } else if (phase < 240 && age >= 3000) {
+ c->opacity = phase * 255 / 240;
+ c->next_ms = 40;
+ } else c->next_ms = 2760 - phase;
+ }
+ return activity != c->activity || opacity != c->opacity;
+ }
+ uint16_t ht_character_caption_ink(uint16_t fg, uint16_t bg, uint8_t opacity)
+ {
+ unsigned inverse = 255 - opacity;
+ unsigned r = (((fg >> 11) * opacity + (bg >> 11) * inverse) + 127) / 255;
+ unsigned g = ((((fg >> 5) & 63) * opacity + ((bg >> 5) & 63) * inverse) + 127) / 255;
+ unsigned b = (((fg & 31) * opacity + (bg & 31) * inverse) + 127) / 255;
+ return (uint16_t)((r << 11) | (g << 5) | b);
+ }
+
+ void ht_character_letter(ht_scene_t *s, const ht_character_face_t *f,
+ const ht_font_t *font, int x, int y)
+ {
+ static const char letter[4][12] = {
+ "\\ /", " \\ / ", " \\_/ ", " "
+ };
+ uint16_t paper = f->mood == HT_CHARACTER_OFFLINE || f->mood == HT_CHARACTER_ASLEEP
+ ? f->dim : f->foreground;
+ // Reverse-video ASCII cells make unread mail a solid light envelope.
+ // Reuse the text ink so saved brightness still applies; no image asset.
+ for (int row = 0; row < 4; row++)
+ ht_ascii_text(s, x, y + row * font->height, 11 * font->width,
+ font, s->background, paper, letter[row], 11);
+ }
+
+ static void lines(ht_scene_t *s, int y, int width, int count, const ht_font_t *font,
+ uint16_t ink, const char *text, bool mark, const int *widths)
+ {
+ if (!text) text = "";
+ int start = s->count;
+ const char *rest = text;
+ for (int row = 0; row < count; row++) {
+ int w = widths ? widths[row] : width;
+ const char *begin = rest, *end = ht_take_line(&rest, w / font->width);
+ char line[HT_TEXT_BYTES];
+ size_t n = (size_t)(end - begin);
+ if (n >= sizeof line) n = sizeof line - 1;
+ memcpy(line, begin, n); line[n] = 0;
+ ht_text(s, (HT_WIDTH - w) / 2, y + row * font->height, w, font, ink, s->background, line);
+ }
+ if (mark && *rest && s->count > start) {
+ char *line = s->runs[s->count - 1].text, *p = line, *space = NULL;
+ int keep = (widths ? widths[count - 1] : width) / font->width - 3;
+ for (int i = 0; *p && i < keep; i++) {
+ if (*p == ' ') space = p;
+ const char *next = p; ht_utf8_next(&next); p = (char *)next;
+ }
+ if (*p && *p != ' ' && space) p = space;
+ while (p > line && p[-1] == ' ') p--;
+ strcpy(p, "...");
+ }
+ for (int i = start; i < s->count; i++) {
+ ht_run_t *r = &s->runs[i]; const char *p = r->text; int n = 0;
+ while (*p) { ht_utf8_next(&p); n++; }
+ r->w = n * font->width; r->x = (HT_WIDTH - r->w) / 2;
+ }
+ }
+
+ static void recap_lines(ht_scene_t *s, int y, int width, int rows, bool centered, const int *widths,
+ uint16_t ink, const char *recap, const ht_font_t *font, int max_chars)
+ {
+ // Summary text has no action glyph. Only incomplete prose gets an ellipsis;
+ // the desktop action lives in the inbox footer. Bound cached UTF-8 input.
+ char marked[7 * HT_TEXT_BYTES + 4];
+ size_t used = 0;
+ const char *p = recap ? recap : "";
+ while (*p) {
+ const char *start = p;
+ ht_utf8_next(&p);
+ size_t bytes = (size_t)(p - start);
+ if (used + bytes + 4 > sizeof marked) break;
+ memcpy(marked + used, start, bytes);
+ used += bytes;
+ }
+ while (used && marked[used - 1] == ' ') used--;
+ marked[used] = 0;
+ if (used >= 2 && !strcmp(marked + used - 2, " +"))
+ strcpy(marked + used - 2, "...");
+ if (max_chars > 3) {
+ const char *end = marked;
+ for (int count = 0; *end && count < max_chars; count++) ht_utf8_next(&end);
+ if (*end) {
+ // Count glyphs, not UTF-8 bytes. The ellipsis is inside the budget;
+ // finish at the last whole word whenever the text supplies one.
+ char *cut = marked, *space = NULL;
+ for (int count = 0; *cut && count < max_chars - 3; count++) {
+ if (*cut == ' ') space = cut;
+ const char *next = cut; ht_utf8_next(&next); cut = (char *)next;
+ }
+ if (*cut && *cut != ' ' && space) cut = space;
+ while (cut > marked && (cut[-1] == ' ' || cut[-1] == '.')) cut--;
+ strcpy(cut, "...");
+ }
+ }
+ int start = s->count;
+ lines(s, y, width, rows, font, ink, marked, true, widths);
+ if (centered) {
+ int bottom = y;
+ for (int i = start; i < s->count; i++)
+ if (s->runs[i].text[0]) bottom = s->runs[i].y + font->height;
+ // y describes the full reading area. Center the actual prose inside it.
+ int shift = (rows * font->height - (bottom - y)) / 2;
+ for (int i = start; i < s->count; i++) s->runs[i].y += shift;
+ }
+ }
+
+ void ht_recap_lines(ht_scene_t *s, int y, uint16_t ink, const char *recap)
+ {
+ recap_lines(s, y, 336, 3, false, NULL, ink, recap, &ht_mono_20, 0);
+ }
+ void ht_inbox_card(ht_scene_t *s, const char *mark, const char *name,
+ const char *message, uint16_t foreground, uint16_t status_ink)
+ {
+ // One balanced text block. A fixed 28 px gap separates label and message,
+ // whether they take two lines or six. No divider or empty reserved rows.
+ char title[HT_TEXT_BYTES];
+ snprintf(title, sizeof title, "%s %s", mark, name);
+ int start = s->count;
+ lines(s, 0, 374, 2, &ht_mono_28, foreground, title, true, NULL);
+ while (s->count > start && !s->runs[s->count - 1].text[0]) s->count--;
+ int body = s->count;
+ recap_lines(s, 0, 391, HT_CHARACTER_RECAP_ROWS, false, NULL,
+ foreground, message, &ht_mono_28, HT_CHARACTER_RECAP_CHARS);
+ while (s->count > body && !s->runs[s->count - 1].text[0]) s->count--;
+ int title_height = (body - start) * ht_mono_28.height;
+ int body_height = (s->count - body) * ht_mono_28.height;
+ int top = 72 + (310 - title_height - 28 - body_height) / 2;
+ for (int i = start; i < s->count; i++)
+ s->runs[i].y += i < body ? top : top + title_height + 28;
+ if (body > start) {
+ // Put the colored symbol in its own immutable run. Avoid a shared
+ // mutable per-cell palette between the compositor's two scene buffers.
+ ht_run_t *r = &s->runs[start];
+ const char *next = r->text; ht_utf8_next(&next);
+ memmove(r->text + 1, next, strlen(next) + 1); r->text[0] = ' ';
+ ht_text(s, r->x, r->y, ht_mono_28.width, &ht_mono_28, status_ink, s->background, mark);
+ }
+ }
+ void ht_notification_bell(ht_scene_t *s, unsigned count, uint16_t ink)
+ {
+ char number[12];
+ snprintf(number, sizeof number, "%u", count);
+ int digits = count ? (int)strlen(number) * ht_mono_28.width : 0;
+ int width = ht_bell_footer.width + (count ? 8 + digits : 0);
+ int x = (HT_WIDTH - width) / 2;
+ ht_text(s, x, HT_NOTIFICATION_Y, ht_bell_footer.width, &ht_bell_footer,
+ ink, s->background, HT_BELL);
+ if (count) ht_text(s, x + ht_bell_footer.width + 8, HT_NOTIFICATION_Y, digits,
+ &ht_mono_28, ink, s->background, number);
+ }
+ static void recipient(ht_scene_t *s, const ht_character_face_t *f, int y)
+ {
+ // In reading mode the name labels the message directly underneath it.
+ // Long names wrap without changing the text size.
+ lines(s, y, 320, 2, &ht_mono_20, f->primary_title ? f->foreground : f->dim, f->recipient, false, NULL);
+ }
+
+ void ht_character_layout(ht_scene_t *s, const ht_character_face_t *f, uint8_t frame, uint16_t ink,
+ const char *recap, ht_character_painter_t paint)
+ {
+ // The outcome owns the reading space after a turn. Artwork and its label
+ // move together above the recap; the home caption stays on the top curve.
+ bool result = recap && *recap;
+ // The live reading surface has one fixed small portrait for every summary.
+ // Legacy benchmark scenes retain their original geometry for comparison.
+ bool brief = result && !f->roomy_reading && ht_text_rows(recap, &ht_mono_20, 324) <= 3;
+ bool compact = f->focus || f->carrying;
+ ht_character_size_t size = result ? (brief ? HT_CHARACTER_BRIEF : HT_CHARACTER_READING) :
+ compact ? HT_CHARACTER_COMPACT : HT_CHARACTER_FULL;
++#if HT_FACE_PX >= 720
++ // Live work keeps the FULL companion here: 432 px of it fits above the status band with room to
++ // spare, so there is no reason to drop a rung the way the round face has to.
++ int y = result ? HT_CHARACTER_READING_Y : 140;
++ if (result && brief) y = HT_CHARACTER_BRIEF_Y;
++#else
+ int y = result ? (brief ? 78 : 72) : compact ? 113 : 98;
+ if (result && f->roomy_reading) y = HT_CHARACTER_READING_Y;
+ else if (!compact && f->roomy_reading) { size = HT_CHARACTER_COMPACT; y = 114; }
++#endif
+ paint(s, f, frame, ink, size, y);
+ if (!f->single_label) {
++#if HT_FACE_PX >= 720
++ // Under the tab strip at y=40, which is chrome about which book you are in; the name is the
++ // content. There is no arc branch here at all: ht_arc_title bends text around a 205 px radius
++ // baked into arc_trig[32][2], and on a square there is no rim to bend it around.
++ recipient(s, f, 80);
++#else
+ if (f->straight_title) recipient(s, f, 41);
+ else ht_arc_title(s, f->primary_title ? f->foreground : f->dim, f->recipient);
++#endif
+ }
++#if HT_FACE_PX >= 720
++ // SIX ROWS OF 656, AND NO WIDTH TABLE. Every row on the dial is a different width because each
++ // one is a different chord; here they are all the same, so the tables below do not exist on this
++ // face rather than existing unused.
++ if (result) recap_lines(s, brief ? HT_CHARACTER_BRIEF_TEXT_Y : HT_CHARACTER_READING_TEXT_Y,
++ 656, brief ? 3 : HT_CHARACTER_RECAP_ROWS, false, NULL, f->foreground, recap,
++ &ht_mono_28, HT_CHARACTER_RECAP_CHARS);
++ else lines(s, 542, 656, 1, &ht_mono_20, f->dim, compact ? f->detail : "", false, NULL);
++ // Straight, both of them. ht_arc_status bakes a 205 px radius into arc_trig[32][2] and there is
++ // no rim here to bend text around.
++ lines(s, 600, 656, 1, &ht_mono_28, f->ink, f->status, false, NULL);
++ lines(s, 660, 656, 1, &ht_mono_20, f->dim, f->hint, false, NULL);
++#else
+ // Keep slots stable through long titles and animation; damage stays local.
+ static const int reading_widths[] = {396, 396, 384, 372, 348, 324, 276};
+ static const int brief_widths[] = {372, 348, 324};
- // Larger summaries occupy the center of the circle, with the last row
- // above the footer. Narrow lower rows keep every glyph inside the bezel.
++ // Larger summaries occupy the center of the circle, with the last row above the footer. Narrow
++ // lower rows keep every glyph inside the bezel.
+ static const int roomy_widths[] = {408, 408, 391, 340};
+ if (result && f->roomy_reading) recap_lines(s, HT_CHARACTER_READING_TEXT_Y,
+ 408, HT_CHARACTER_RECAP_ROWS, false, roomy_widths, f->foreground, recap,
+ &ht_mono_28, HT_CHARACTER_RECAP_CHARS);
+ else if (result) recap_lines(s, brief ? 252 : 194, brief ? 372 : 396,
+ brief ? 3 : 7, false, brief ? brief_widths : reading_widths, f->foreground, recap, &ht_mono_20, 0);
+ else lines(s, 337, 320, 1, &ht_mono_20, f->dim, compact ? f->detail : "", false, NULL);
+ if (!f->footer_action && !f->straight_title) ht_arc_status(s, f->ink, f->status);
+ else lines(s, f->footer_action ? 369 : 385, 276, 1, &ht_mono_20, f->ink, f->status, false, NULL);
+ lines(s, 417, 210, 1, &ht_mono_20, f->dim, f->hint, false, NULL);
++#endif
+ }
diff --cc devices/harness-device/firmware/main/ui/habitat/character_layout.h
index 000000000,bfdab503a..857c439e8
mode 000000,100644..100644
--- a/devices/harness-device/firmware/main/ui/habitat/character_layout.h
+++ b/devices/harness-device/firmware/main/ui/habitat/character_layout.h
@@@ -1,0 -1,30 +1,48 @@@
+ #pragma once
+ #include "character_types.h"
+ typedef enum {
+ HT_CHARACTER_FULL, HT_CHARACTER_COMPACT, HT_CHARACTER_BRIEF,
+ HT_CHARACTER_READING, HT_CHARACTER_QUICK
+ } ht_character_size_t;
++#if HT_FACE_PX >= 720
++/*
++ * The square face. A font_8 portrait is 27 x 8 = 216 tall, so 126 -> 342 and the recap starts at 366;
++ * six rows of ht_mono_28 is 228 px, ending at 594, just clear of the status band at 600. A brief
++ * result uses font_10 (270 tall), so 126 -> 396 and three rows from 420 end at 534.
++ *
++ * 656 / 17 = 38 cells a row. The dial's cap exists because four tapering rows inside a circle
++ * genuinely cannot hold more; neither reason applies here, and a recap that fits is the single
++ * biggest thing this face changes about living with the device.
++ */
++enum { HT_CHARACTER_BRIEF_Y = 126, HT_CHARACTER_READING_Y = 126,
++ HT_CHARACTER_BRIEF_TEXT_Y = 420, HT_CHARACTER_READING_TEXT_Y = 366,
++ HT_CHARACTER_RECAP_CHARS = 228, HT_CHARACTER_RECAP_ROWS = 6,
++ // Below the status band (600..638) and in the row the hint would use, which this face leaves
++ // empty: the bell IS the chrome here.
++ HT_NOTIFICATION_Y = 660 };
++#else
+ enum { HT_CHARACTER_BRIEF_Y = 84, HT_CHARACTER_READING_Y = 82,
+ HT_CHARACTER_BRIEF_TEXT_Y = 264, HT_CHARACTER_READING_TEXT_Y = 208,
+ HT_CHARACTER_RECAP_CHARS = 90, HT_CHARACTER_RECAP_ROWS = 4,
+ HT_NOTIFICATION_Y = 414 };
++#endif
+ typedef struct {
+ char pane[128];
+ uint32_t began, next_ms;
+ uint8_t opacity;
+ bool initialized, working, activity;
+ } ht_character_caption_t;
+ bool ht_character_caption_tick(ht_character_caption_t *caption, uint32_t now,
+ const char *pane, bool working);
+ uint16_t ht_character_caption_ink(uint16_t foreground, uint16_t background, uint8_t opacity);
+ typedef void (*ht_character_painter_t)(ht_scene_t *, const ht_character_face_t *, uint8_t frame,
+ uint16_t ink, ht_character_size_t size, int y);
+ void ht_character_layout(ht_scene_t *s, const ht_character_face_t *f, uint8_t frame,
+ uint16_t ink, const char *recap, ht_character_painter_t paint);
+ // Text-only inbox, deliberately distinct from the companion's home recap.
+ void ht_inbox_card(ht_scene_t *scene, const char *mark, const char *name,
+ const char *message, uint16_t foreground, uint16_t status_ink);
+ void ht_notification_bell(ht_scene_t *scene, unsigned count, uint16_t ink);
+ // The envelope is painted in the character's own cells, attached to its limb.
+ void ht_character_letter(ht_scene_t *s, const ht_character_face_t *f,
+ const ht_font_t *font, int x, int y);
diff --cc devices/harness-device/firmware/main/ui/habitat/character_motion.c
index 000000000,6eca08a3d..57cf1350f
mode 000000,100644..100644
--- a/devices/harness-device/firmware/main/ui/habitat/character_motion.c
+++ b/devices/harness-device/firmware/main/ui/habitat/character_motion.c
@@@ -1,0 -1,111 +1,114 @@@
+ #include "character_types.h"
+ #include "perf_bench.h"
+
+ static bool due(uint32_t now, uint32_t deadline) { return (int32_t)(now - deadline) >= 0; }
+ static void deadline(ht_character_reaction_t *m, uint32_t now, uint32_t at)
+ {
+ uint32_t left = due(now, at) ? 1 : at - now;
+ if (left < m->next_ms) m->next_ms = left;
+ }
+ bool ht_character_reaction_tick(ht_character_reaction_t *m, uint32_t now, ht_character_mood_t mood,
+ bool quiet, bool visible, bool down, int x, unsigned level, uint32_t activity)
+ {
+ ht_character_pose_t old = m->pose, p = {0};
+ m->next_ms = 1000;
+ if (!m->initialized) {
+ m->initialized = true;
+ m->next_blink = now + 5700;
+ m->blink_until = m->reaction_until = m->release_until = now;
+ m->mood = mood; m->activity = activity;
+ }
+ if (!visible || quiet || mood == HT_CHARACTER_ASLEEP || mood == HT_CHARACTER_OFFLINE) {
+ m->next_blink = now + 5700;
+ m->blink_until = m->reaction_until = m->release_until = now;
+ } else {
+ if ((activity != m->activity || mood != m->mood) &&
+ (mood == HT_CHARACTER_WORKING || mood == HT_CHARACTER_DONE || mood == HT_CHARACTER_ATTENTION)) {
+ // Repeated tool packets cannot restart an endless busy animation.
+ bool completed = mood == HT_CHARACTER_DONE && m->mood != HT_CHARACTER_DONE;
+ if (completed || (due(now, m->reaction_until) && (!m->reaction_at || now - m->reaction_at >= 2000))) {
+ m->reaction_at = now;
+ m->reaction_until = now + (completed ? 1320 : 720);
+ }
+ }
+ if (down) {
- int gaze = (x - 233) / 40;
++ // The eyes follow the finger relative to the middle of the FACE, not to 233 — which is
++ // the dial's centre and a third of the way across the Pro's, so every touch there read
++ // as a look to the right.
++ int gaze = (x - HT_WIDTH / 2) / 40;
+ p.look = gaze < -2 ? -2 : gaze > 2 ? 2 : gaze;
+ p.pressed = true;
+ m->release_until = now + 400;
+ } else if (m->was_down || !due(now, m->release_until)) {
+ p.look = old.look;
+ deadline(m, now, m->release_until);
+ }
+ if (!down && due(now, m->next_blink)) {
+ m->blink_until = now + 110;
+ m->sequence++;
+ m->next_blink = now + 5700 + (m->sequence % 5) * 413;
+ }
+ p.blink = !down && !due(now, m->blink_until);
+ if (!down) deadline(m, now, p.blink ? m->blink_until : m->next_blink);
+ if (!due(now, m->reaction_until)) {
+ p.hands = (uint8_t)(1 + (now - m->reaction_at) / 120 % 2);
+ if (mood == HT_CHARACTER_DONE && !down) {
+ // A brief glance right, glance left, then a blink and smile.
+ // The completion event owns this finite cue; repeated status
+ // packets cannot sustain it, and touch always keeps its gaze.
+ uint32_t age = now - m->reaction_at;
+ p.look = age < 360 ? 2 : age < 720 ? -2 : 0;
+ p.blink = age >= 840 && age < 960;
+ }
+ deadline(m, now, now + 120 - (now - m->reaction_at) % 120);
+ }
+ if (mood == HT_CHARACTER_LISTENING) {
+ p.level = old.level;
+ if (m->mood != mood || now - m->level_at >= 125) {
+ p.level = level > 4 ? 4 : (uint8_t)level;
+ m->level_at = now;
+ }
+ deadline(m, now, m->level_at + 125);
+ }
+ }
+ m->pose = p; m->mood = mood; m->activity = activity; m->was_down = down;
+ return p.look != old.look || p.hands != old.hands || p.level != old.level ||
+ p.blink != old.blink || p.pressed != old.pressed;
+ }
+ bool ht_character_motion_step(ht_character_motion_t *m, const ht_character_animation_t *a,
+ uint32_t now, ht_character_mood_t mood, bool quiet, bool visible,
+ bool down, int x, unsigned level, uint32_t activity, bool animate)
+ {
+ if (!a || !a->frames || !a->duration || !a->ends) return false;
+ #ifdef DEVICE_OCTOPUS_BENCH
+ animate = animate && octopus_perf_animate();
+ #endif
+ bool changed = ht_character_reaction_tick(&m->reaction, now, mood, quiet, visible, down, x, level, activity);
+ bool running = animate && visible && !quiet && !down &&
+ mood != HT_CHARACTER_ASLEEP && mood != HT_CHARACTER_OFFLINE;
+ // The body keeps its gentle idle pace while listening. Microphone-driven
+ // mouth/eye reactions remain independent and continue at their own cadence.
+ uint8_t rate = mood == HT_CHARACTER_IDLE || mood == HT_CHARACTER_LISTENING ? 2 : 1;
+ uint8_t old_frame = m->frame;
+ if (m->animation != a) {
+ changed = true;
+ m->phase = m->remainder = 0;
+ m->initialized = false;
+ m->animation = a;
+ }
+ if (m->initialized && m->running && running) {
+ uint32_t scaled = (now - m->last_ms) % (a->duration * m->rate) + m->remainder;
+ m->phase = (m->phase + scaled / m->rate) % a->duration;
+ m->remainder = scaled % m->rate;
+ } else m->remainder = 0;
+ if (m->rate != rate) m->remainder = 0;
+ m->initialized = true; m->running = running; m->rate = rate; m->last_ms = now;
+ m->frame = 0;
+ while (m->frame + 1 < a->frames && m->phase >= a->ends[m->frame]) m->frame++;
+ m->next_ms = m->reaction.next_ms;
+ if (running) {
+ uint32_t next = (a->ends[m->frame] - m->phase) * rate - m->remainder;
+ if (next < m->next_ms) m->next_ms = next ? next : 1;
+ }
+ return changed || m->frame != old_frame;
+ }
diff --cc devices/harness-device/firmware/main/ui/habitat/octopus.c
index 061fb4b9c,957472154..07c278be5
--- a/devices/harness-device/firmware/main/ui/habitat/octopus.c
+++ b/devices/harness-device/firmware/main/ui/habitat/octopus.c
@@@ -249,71 -78,26 +78,42 @@@ void ht_octopus_portrait(ht_scene_t *s
ht_ascii_text(s, x, y + i * font->height, HT_OCTOPUS_COLS * font->width,
font, ink, s->background, row, HT_OCTOPUS_COLS);
}
+ if (f->pose.mail) {
+ int top = octopus_eyes[frame] - 7 - (f->pose.mail == 2);
+ if (top < 0) top = 0;
+ ht_character_letter(s, f, font, x + 43 * font->width, y + top * font->height);
+ }
}
- void ht_octopus_face(ht_scene_t *s, const ht_tim_face_t *f, uint8_t frame, uint16_t ink,
- const char *recap)
+ void ht_octopus_draw(ht_scene_t *s, const ht_character_face_t *f, uint8_t frame, uint16_t ink,
+ ht_character_size_t size, int y)
{
- if (frame >= HT_OCTOPUS_FRAMES) frame = 0;
- // The outcome owns the reading space after a turn. Artwork and its label
- // move together above the recap; the status footer stays fixed.
- bool result = recap && *recap;
- bool brief = result && ht_octopus_short_recap(recap);
- bool compact = f->focus || f->carrying;
+#if HT_FACE_PX >= 720
- // Two rungs up the atlas ladder, because the face is 720 and not 466. Live work gets font_16 —
- // 27*16 = 432 px of companion against the dial's 270 — and every other state drops the way the
- // dial's does, just from higher up: a result to font_8, a brief result to font_10, and the
- // carrying state to font_14, which is the rung that leaves room for a detail line.
- const ht_font_t *font = result ? (brief ? &ht_octopus_font_10 : &ht_octopus_font_8)
- : compact ? &ht_octopus_font_14 : &ht_octopus_font_16;
- int y = result ? HT_OCTOPUS_READING_Y : compact ? 140 : 140;
- #else
- const ht_font_t *font = result ? (brief ? &ht_octopus_font_6 : &ht_octopus_font_4) : compact ? &ht_octopus_font_8 : &ht_octopus_font_10;
- int y = result ? (brief ? 78 : 72) : compact ? 113 : 98;
- #endif
- if (result && f->roomy_reading)
- y = brief ? HT_OCTOPUS_BRIEF_Y : HT_OCTOPUS_READING_Y;
- ht_octopus_portrait(s, f, frame, ink, font, y);
- if (f->straight_title) recipient(s, f, ht_octopus_title_y(result, compact));
- else ht_arc_title(s, f->primary_title ? f->foreground : f->dim, f->recipient);
- // Keep slots stable through long titles and animation; damage stays local.
- static const int reading_widths[] = {396, 396, 384, 372, 348, 324, 276};
- static const int brief_widths[] = {372, 348, 324};
+ /*
- * FOUR ROWS FROM 212 — and the fourth is what makes 60 characters true.
++ * TWO RUNGS UP THE LADDER, because the face is 720 and not 466.
+ *
- * Three rows at 17 x 38 are 24 + 23 + 21 = 68 cells on paper. Measured, they carry about FIFTY
- * characters of real prose: word wrap gives up part of every line break, and the desktop arrow
- * takes the last two cells. A 60-character recap arrived cut at 50 — the cap was not the limit,
- * the rows were.
++ * The atlas number is the cell HEIGHT and the advance is half of it, so a 54 x 27 clip in font_N
++ * is 27N square: the dial's largest is font_10 at 270 px, and this face has room for font_16 at
++ * 432. Every other state drops the way the dial's does, just from higher up — a result to font_8,
++ * a brief one to font_10, and the carrying state to font_14, the rung that still leaves a line
++ * for the detail underneath it.
+ *
- * The portrait ends at 200 and the status band starts near 385, so 212 + 4 * 38 = 364 fits. The
- * widths taper to the chord: 372 is the widest the fourth row can be at y=364.
++ * Order is HT_CHARACTER_FULL, COMPACT, BRIEF, READING, QUICK.
+ */
- static const int roomy_widths[] = {408, 408, 396, 372};
- #if HT_FACE_PX >= 720
- (void)reading_widths; (void)brief_widths; (void)roomy_widths;
- // SIX ROWS OF 656, and no width table at all. On the dial every row is a different width because
- // each one is a different chord; here they are all the same, so passing NULL is not laziness — it
- // is the shape of the face.
- if (result) recap_lines(s, brief ? HT_OCTOPUS_BRIEF_TEXT_Y : HT_OCTOPUS_READING_TEXT_Y,
- 656, brief ? 3 : 6, false, NULL, f->foreground, recap);
- else lines(s, 542, 656, 1, &ht_mono_20, f->dim, compact ? f->detail : "", false, NULL);
- // Straight, both of them. ht_arc_status bakes a 205 px radius into arc_trig[32][2] and there is no
- // rim here to bend text around, so the status is an ordinary run and the hint is the control row.
- lines(s, 600, 656, 1, RECAP_FONT, f->ink, f->status, false, NULL);
- lines(s, 660, 656, 1, &ht_mono_20, f->dim, f->hint, false, NULL);
++ const ht_font_t *fonts[] = {&ht_octopus_font_16, &ht_octopus_font_14, &ht_octopus_font_10,
++ &ht_octopus_font_8, &ht_octopus_font_8};
+#else
- if (result && f->roomy_reading) recap_lines(s,
- brief ? HT_OCTOPUS_BRIEF_TEXT_Y : 212,
- brief ? 372 : 408, brief ? 3 : 4, false,
- brief ? brief_widths : roomy_widths, f->foreground, recap);
- else if (result) recap_lines(s, brief ? 252 : 194, brief ? 372 : 396,
- brief ? 3 : 7, false, brief ? brief_widths : reading_widths, f->foreground, recap);
- else lines(s, 337, 320, 1, &ht_mono_20, f->dim, compact ? f->detail : "", false, NULL);
- if (!f->footer_action && !f->straight_title) ht_arc_status(s, f->ink, f->status);
- else lines(s, f->footer_action ? 369 : 385, 276, 1, &ht_mono_20, f->ink, f->status, false, NULL);
- lines(s, 417, 210, 1, &ht_mono_20, f->dim, f->hint, false, NULL);
+ const ht_font_t *fonts[] = {&ht_octopus_font_10, &ht_octopus_font_8, &ht_octopus_font_6,
+ &ht_octopus_font_4, &ht_octopus_font_4};
+#endif
+ if ((unsigned)size > HT_CHARACTER_QUICK) size = HT_CHARACTER_FULL;
+ ht_octopus_portrait(s, f, frame, ink, fonts[size], y);
+ }
+ bool ht_octopus_short_recap(const char *recap)
+ {
+ return recap && *recap && ht_text_rows(recap, &ht_mono_20, 324) <= 3;
+ }
+ void ht_octopus_face(ht_scene_t *s, const ht_tim_face_t *f, uint8_t frame, uint16_t ink, const char *recap)
+ {
+ ht_character_layout(s, f, frame, ink, recap, ht_octopus_draw);
}
diff --cc devices/harness-device/firmware/main/ui/habitat/terminal.c
index 4cb3211bd,38aa13b94..3677d3049
--- a/devices/harness-device/firmware/main/ui/habitat/terminal.c
+++ b/devices/harness-device/firmware/main/ui/habitat/terminal.c
@@@ -4,23 -4,7 +4,23 @@@
static int imin(int a, int b) { return a < b ? a : b; }
static int imax(int a, int b) { return a > b ? a : b; }
-static uint16_t be16(uint16_t v) { return (uint16_t)((v << 8) | (v >> 8)); }
+/*
+ * THE PANEL'S OWN BYTE ORDER, and the two panels disagree about it.
+ *
+ * The dial's CO5300 is fed over QSPI and wants RGB565 byte-swapped, so the raster emits it that way and
+ * saves a per-pixel swap on every flush. The Pro's ST7703 is a DPI panel scanned continuously out of a
+ * framebuffer in the SoC's own little-endian order, and it swaps nothing.
+ *
+ * Getting this wrong is not subtle and it is not a crash: #181818 read the other way round is
+ * rgb(192,96,192), so the whole face comes up bright purple with a yellow-green octopus on it. That is
- * exactly what the first Pro build did. The function was called be16() then, which is why this one is
++ * exactly what the first Pro build did. The function was called panel16() then, which is why this one is
+ * not — a name that promises a swap it no longer always performs is worse than no name at all.
+ */
+#if HT_FACE_PX >= 720
+static uint16_t panel16(uint16_t v) { return v; }
+#else
+static uint16_t panel16(uint16_t v) { return (uint16_t)((v << 8) | (v >> 8)); }
+#endif
static uint32_t punctuation_alias(uint32_t cp)
{
// One cell in, one cell out. Keep the original UTF-8 in the scene/wire;
@@@ -694,7 -680,25 +737,25 @@@ static void arc_raster(const ht_run_t *
arc_cache_t *cache = &arc_caches[r->arc == 2];
arc_prepare(r, cache);
if (!cache->mask_bytes) return;
- uint16_t palette[4] = {0, blend(r->fg,r->bg,1), blend(r->fg,r->bg,2), be16(r->fg)};
+ uint16_t palette[4] = {0, blend(r->fg,r->bg,1), blend(r->fg,r->bg,2), panel16(r->fg)};
+ // Colour a cached mask: no glyph rotation, allocations or extra text runs.
+ // Sixteen brightness levels use 128 bytes of bounded stack scratch.
+ uint16_t sweep[16][4];
+ int center = 0;
+ if (r->shimmer) {
+ center = shimmer_center(r, ht_run_bounds(r));
+ for (unsigned level = 0; level < 16; level++) {
+ unsigned opacity = 100 + level * 155 / 15, inverse = 255 - opacity;
+ unsigned red = ((r->fg >> 11) * opacity + (r->bg >> 11) * inverse + 127) / 255;
+ unsigned green = (((r->fg >> 5) & 63) * opacity + ((r->bg >> 5) & 63) * inverse + 127) / 255;
+ unsigned blue = ((r->fg & 31) * opacity + (r->bg & 31) * inverse + 127) / 255;
+ uint16_t ink = (uint16_t)((red << 11) | (green << 5) | blue);
+ sweep[level][0] = 0;
+ sweep[level][1] = blend(ink, r->bg, 1);
+ sweep[level][2] = blend(ink, r->bg, 2);
- sweep[level][3] = be16(ink);
++ sweep[level][3] = panel16(ink);
+ }
+ }
int x0 = imax(clip.x,r->x), x1 = imin(clip.x+clip.w,r->x+r->w);
int y0 = imax(clip.y,r->y), y1 = imin(clip.y+clip.h,r->y+HT_ARC_HEIGHT);
for (int y = y0; y < y1; y++) for (int h = 0; h < 2; h++) {
@@@ -726,10 -737,10 +794,10 @@@ void ht_raster(const ht_scene_t *s, ht_
x1 = imax(clip.x, r->x), x2 = imin(clip.x + clip.w, r->x + r->w);
if (r->bg != s->background)
for (int y = y1; y < y2; y++)
- fill(out + (y - clip.y) * clip.w + x1 - clip.x, (size_t)(x2 - x1), be16(r->bg));
- uint16_t palette[4] = {be16(r->bg), blend(r->fg, r->bg, 1), blend(r->fg, r->bg, 2),
- be16(r->fg)};
+ fill(out + (y - clip.y) * clip.w + x1 - clip.x, (size_t)(x2 - x1), panel16(r->bg));
+ uint16_t palette[4] = {panel16(r->bg), blend(r->fg, r->bg, 1), blend(r->fg, r->bg, 2),
+ panel16(r->fg)};
- bool cached = glyph_cache_prepare(f, r->fg, r->bg);
+ bool cached = !r->colors && glyph_cache_prepare(f, r->fg, r->bg);
bool ascii = f->first == 32 && f->last >= 126;
#ifdef DEVICE_LAYOUT_BENCH
ascii = ascii && raster_fast_ascii;
@@@ -746,6 -757,12 +814,12 @@@
c = font_codepoint(f, c);
}
if (gx + f->width > x1 && c != ' ') {
+ if (r->colors) {
+ uint16_t fg = r->colors[cell];
+ palette[1] = blend(fg, r->bg, 1);
+ palette[2] = blend(fg, r->bg, 2);
- palette[3] = be16(fg);
++ palette[3] = panel16(fg);
+ }
const ht_font_t *face = glyph_font(f, c);
size_t stride = ((size_t)face->width * face->height + 3) / 4;
const uint8_t *glyph = face->pixels + (c - face->first) * stride;
diff --cc devices/harness-device/firmware/main/ui/habitat/ui_habitat.c
index c33c77ea3,35d53104e..5253da351
--- a/devices/harness-device/firmware/main/ui/habitat/ui_habitat.c
+++ b/devices/harness-device/firmware/main/ui/habitat/ui_habitat.c
@@@ -84,13 -84,6 +84,12 @@@ typedef enum
A_NOTICE,
A_TABS,
A_TAB, A_TAB_REFRESH,
+#if HT_FACE_PX >= 720
+ // The Pro's tab strip, walked two at a time. Declared only on the square face: the dispatch
+ // switch is built with -Werror=switch, so an action that exists but is never handled is a
- // compile error rather than a silent no-op — which is the right trade, and the reason these
- // are inside the guard rather than merely unused on the dial.
++ // compile error rather than a silent no-op.
+ A_TAB_STRIP_LEFT, A_TAB_STRIP_RIGHT,
+#endif
A_MACHINES,
A_MACHINE,
A_VOICE,
@@@ -184,25 -182,8 +188,23 @@@ static EXT_RAM_BSS_ATTR struct
int pet_pose;
uint32_t pet_until, nap_until, last_celebration;
cable_swarm_t tabs[SWARMS_MAX];
- int tab_count, tab_drag;
- char selected_tab[ID_MAX];
+#if HT_FACE_PX >= 720
+ // Set when a tab was chosen from the strip, consumed by ui_land_after_reload(). A one-shot flag
- // rather than changing where every reload lands: the same function catches a boot and a reconnect,
- // and those still belong on the companion face.
++ // rather than changing where every reload lands: the same function catches a boot and a
++ // reconnect, and those still belong on the companion face.
+ bool land_on_desk;
- // The tab strip's left-most tab. Honoured while you walk the strip, and snapped whenever the tab
- // you are IN would otherwise be off the end of it.
- int tab_first;
++ int tab_first; // the strip's left-most tab; yours while you walk it
+ int tab_strip_drag; // accumulated horizontal travel while walking the strip
+ bool tab_strip_held; // this contact began on the strip, so it is the strip's to consume
- // The selected tab's SHAPE, as the window laid it out: normalised 0..1000 rectangles plus the agent
- // at each seat. Tagged with the tab they belong to, because a shape drawn against another tab's
- // rectangles puts agents where they are not. The dial has no use for these — see cable_client.c.
++ // The selected tab's SHAPE, as the window laid it out: normalised 0..1000 rectangles plus the
++ // agent at each seat, tagged with the tab they belong to. The dial has no spatial desk and no
++ // use for these — see cable_client.c.
+ cable_tile_t tiles[SWARM_TILES_MAX];
+ int tile_count;
+ char tile_tab[ID_MAX];
+#endif
+ int tab_count, tab_drag;
+ char selected_tab[ID_MAX];
cable_machine_t machines[CABLE_MAX_MACHINES];
int machine_count;
char selected_machine[ID_MAX], pending_machine[ID_MAX];
@@@ -254,13 -242,12 +263,17 @@@ static ht_form_t form
static ht_draft_t draft;
static bool selection_emit(const ht_select_command_t *command, void *ctx);
static ht_gesture_t gesture;
- static ht_octopus_motion_t octopus_motion;
+ static ht_character_t character;
+ static ht_character_caption_t home_caption;
static action_t pressed_action;
+#if HT_FACE_PX >= 720
+// The rectangle the contact went down on. A written control activates when the finger comes up inside
+// it, so the rect has to outlive s.pressed, which the release path clears before it decides anything.
+static ht_rect_t pressed_rect;
+#endif
+ static bool queue(action_t a);
+ static void view(view_t v);
+ static const char *voice_status(void);
static uint32_t ms(void) { return (uint32_t)(esp_timer_get_time() / 1000); }
static void copy(char *dst, size_t cap, const char *src)
{
@@@ -546,48 -590,9 +616,48 @@@ static void control(ht_scene_t *f, int
ht_text(f, x, y, w, UI_FONT, enabled ? (a == A_STOP_YES ? ERROR : n == s.pressed ? ACCENT : FG) : DIM,
n == s.pressed ? SEL : BG, label);
}
+#if HT_FACE_PX >= 720
+/*
+ * A ONE-PANE TAB HAS NO LAYOUT WORTH SHOWING.
+ *
+ * The desk exists to say WHERE an agent is among others. With one pane there is no "among": the page
+ * is a single rectangle filling the glass and a name in the corner of it, and every visit costs a tap
+ * to get past. So a tab with one pane opens on the companion instead.
+ *
+ * Read off cable_swarm_t.panes rather than counted from the tiles, because this decides where to GO
+ * and the rectangles arrive a frame later than the decision does. `panes` counts tiles of any kind —
+ * a tab holding one terminal and no agent is still one pane — which is the count this question is
+ * actually asking about. A daemon too old to send it reports panes == agents, which lands the same way.
+ */
+static int pro_panes_of(const char *id)
+{
+ if (!id || !*id) return 0;
+ for (int i = 0; i < s.tab_count; i++)
+ if (!strcmp(id, s.tabs[i].id)) return s.tabs[i].panes;
+ return 0;
+}
+/*
+ * A LABEL IS NOT A GESTURE.
+ *
+ * ht_gesture_end() classifies a contact as TAP only between 25 and 350 ms, and as HOLD only between
+ * 650 and 1800 — so a press of 400 ms is neither, and returns HT_TOUCH_NONE. On the dial almost every
+ * target is the companion itself, where that dead band is invisible. This face is made of written
+ * controls, and a deliberate press on a small written label lands in it constantly: the symptom is a
+ * button that works perhaps half the time, which reads as a broken screen rather than as a timing rule.
+ *
+ * These are the controls that say what they do. A press that did not move activates them, full stop.
+ * A_PET is deliberately NOT here: its tap and its hold mean two different things, and that is the one
+ * place on this face where duration is content.
+ */
+static bool pro_written_control(action_kind_t a)
+{
+ return a == A_VOICE_ABORT || a == A_TAB || a == A_TAB_STRIP_LEFT || a == A_TAB_STRIP_RIGHT ||
+ a == A_INBOX || a == A_AGENT || a == A_AGENTS || a == A_NOTICE;
+}
+#endif
static bool home_footer(action_kind_t action)
{
- return action == A_TABS || action == A_INBOX || action == A_RETURN || action == A_CARRY_DROP;
+ return action == A_TABS || action == A_INBOX || action == A_AGENTS || action == A_RETURN || action == A_CARRY_DROP;
}
static bool hit_contains(const hit_t *hit, int x, int y, bool surface)
{
@@@ -699,133 -765,6 +830,118 @@@ static void command_face(ht_scene_t *f
s.hits[s.hit_count++] = links[i];
}
}
+#if HT_FACE_PX >= 720
+/*
+ * THE FIRST LINE IS THE TAB STRIP — every tab, not just the one you are in.
+ *
+ * The dial names the current tab on the arc above the agent and stops there, because a curved line
+ * that wide is all the room it has. A square has a whole 54-cell row, which is enough to carry the
+ * switcher itself: the names in sequence, the one you are in filled with SEL, and a tap that goes
+ * straight to that tab's panes.
+ *
+ * TWO RUNS, NOT ONE PER TAB. The strip is drawn once in DIM across the full width, then the selected
+ * label is drawn again over it with the selection fill. Six tabs as six runs would cost six of the
+ * forty a scene has, and the agent's result page already spends 27 on the companion and 6 on the
+ * recap. Two is what the budget can afford, and overdraw is free here — later runs paint over earlier
+ * ones by construction.
+ *
+ * The hit rects are per tab and cost nothing from that budget.
+ */
+static void pro_tab_strip(ht_scene_t *f)
+{
+ const int CELLS = 648 / ht_mono_20.width; /* 54 */
+ if (s.tab_count <= 0) {
+ ht_text(f, 36, 40, 648, &ht_mono_20, DIM, BG, s.loading ? "loading tabs" : "no tabs");
+ return;
+ }
+ int sel = -1;
+ for (int i = 0; i < s.tab_count; i++)
+ if (!strcmp(s.selected_tab, s.tabs[i].id)) { sel = i; break; }
+
+ /* A tab costs its name plus a space either side — the same space that becomes the selection's
+ * padding, so a filled tab never has its first letter against the fill's edge. */
+ int span[SWARMS_MAX], cells[SWARMS_MAX];
+ for (int i = 0; i < s.tab_count; i++) {
+ int n = 0;
+ for (const char *q = s.tabs[i].name; *q; ) { ht_utf8_next(&q); n++; }
+ cells[i] = n > 14 ? 14 : n; /* one long name must not eat the whole line */
+ span[i] = cells[i] + 2;
+ }
+ if (s.tab_first < 0) s.tab_first = 0;
+ if (s.tab_first >= s.tab_count) s.tab_first = s.tab_count - 1;
+
+ /*
+ * WALKING THE STRIP. `tab_first` is yours while you use < and >, and the device only overrides it
+ * when the tab you are actually in has scrolled off — otherwise the strip would snap back under
+ * your finger every time you moved it.
+ *
+ * The arrows cost two cells each and are only reserved when there is something past that edge, so
+ * a strip that fits uses the whole line.
+ */
+ for (int pass = 0; pass < 2; pass++) {
+ int left_arrow = s.tab_first > 0 ? 2 : 0, room = CELLS - left_arrow, used = 0, last = s.tab_first;
+ while (last < s.tab_count && used + span[last] <= room) { used += span[last]; last++; }
+ if (last < s.tab_count) { /* something past the right edge: reserve > */
+ room -= 2;
+ while (last > s.tab_first + 1 && used > room) used -= span[--last];
+ }
+ if (pass || sel < 0 || (sel >= s.tab_first && sel < last)) {
+ /* draw */
+ char strip[HT_TEXT_BYTES];
+ size_t bytes = 0;
+ int at = left_arrow, sel_x = -1, sel_cells = 0;
+ char sel_text[40] = "";
+ if (left_arrow) { strip[bytes++] = '<'; strip[bytes++] = ' '; }
+ for (int i = s.tab_first; i < last; i++) {
+ char label[40];
+ int n = 0; size_t lb = 0;
+ label[lb++] = ' ';
+ for (const char *q = s.tabs[i].name; *q && n < cells[i]; n++) {
+ const char *begin = q;
+ ht_utf8_next(&q);
+ size_t w = (size_t)(q - begin);
+ if (lb + w + 2 >= sizeof label) break;
+ memcpy(label + lb, begin, w); lb += w;
+ }
+ label[lb++] = ' '; label[lb] = 0;
+ if (bytes + lb + 3 >= sizeof strip) break;
+ memcpy(strip + bytes, label, lb); bytes += lb;
+ if (i == sel) { sel_x = at; sel_cells = span[i]; snprintf(sel_text, sizeof sel_text, "%s", label); }
+ if (s.hit_count < 24)
+ s.hits[s.hit_count++] = (hit_t){{(int16_t)(36 + at * ht_mono_20.width), 26,
+ (int16_t)(span[i] * ht_mono_20.width), 56},
+ A_TAB, i, s.connected};
+ at += span[i];
+ }
+ bool right_arrow = last < s.tab_count;
+ if (right_arrow) {
+ while (at < CELLS - 1 && bytes + 2 < sizeof strip) { strip[bytes++] = ' '; at++; }
+ if (bytes + 1 < sizeof strip) strip[bytes++] = '>';
+ }
+ strip[bytes] = 0;
+ ht_text(f, 36, 40, 648, &ht_mono_20, DIM, BG, strip);
+ if (sel_x >= 0)
+ ht_text(f, 36 + sel_x * ht_mono_20.width, 40, sel_cells * ht_mono_20.width,
+ &ht_mono_20, ACCENT, SEL, sel_text);
+ if (left_arrow && s.hit_count < 24)
+ s.hits[s.hit_count++] = (hit_t){{36, 26, 48, 56}, A_TAB_STRIP_LEFT, 0, true};
+ if (right_arrow && s.hit_count < 24)
+ s.hits[s.hit_count++] = (hit_t){{36 + (CELLS - 2) * ht_mono_20.width, 26, 48, 56},
+ A_TAB_STRIP_RIGHT, 0, true};
+ return;
+ }
+ /* The tab we are in is off the strip. Anchor on it and lay the line out again. */
+ s.tab_first = sel;
+ while (s.tab_first > 0) {
+ int back = s.tab_first - 1, total = span[back], k = back + 1;
+ while (k <= sel) total += span[k++];
+ if (total + 4 > CELLS) break; /* 4 = room for both arrows */
+ s.tab_first = back;
+ }
+ }
+}
+
- /*
- * THE UNREAD COUNT IS THE STATUS LINE, and it is the only control this face has.
- *
- * There was a [panes] [say] [inbox] row under it for one build. It was three labels that are three
- * gestures, permanently on screen whether or not any of them had anything to do — and the inbox one
- * lied twice over, since A_INBOX with an empty inbox returns you to the screen you are already on.
- *
- * render_home already writes the count into the status as "[%d] %s", so there is nothing to draw:
- * the affordance is the number that is already there, and this gives it a target.
- */
- static void pro_status_is_inbox(void)
- {
- if (s.notice_count <= 0 || s.hit_count >= 24) return;
- s.hits[s.hit_count++] = (hit_t){{36, 590, 648, 58}, A_INBOX, 0, true};
- }
+#endif
static void render_workspace_preview(ht_scene_t *f)
{
int i=workspace.choice;
@@@ -836,27 -775,33 +952,43 @@@
}
static void render_home(ht_scene_t *f)
{
- s.inbox_arc = (ht_rect_t){0};
+ s.caption_arc = (ht_rect_t){0};
+ if (!s.connected || s.loading) { render_brand(f); return; }
+ if (s.quick_open) { render_quick(f); return; }
if (workspace.touching && workspace.moved && !workspace.cancelled) { render_workspace_preview(f); return; }
++#if HT_FACE_PX >= 720
++ pro_tab_strip(f); // the first line is the whole switcher on this face
++#endif
agent_t *a = active();
- // Two alternating states: current work owns the large companion; only its
- // completed result gets the reading layout. Never pair old prose with live work.
+ // The top caption belongs to the current pane; only completed work gets
+ // a recap. The bell has its own lower target, outside the voice surface.
const char *recap = a && !a->busy && a->recap_ready && s.connected && !s.loading &&
- !s.nap && !carry.active && !carry.error[0] ? a->preview : NULL;
- const char *activity = a && a->busy && s.connected && !s.loading && !s.nap ? a->tool : "";
+ !s.nap && !s.voice_retry_until && !carry.active && !carry.error[0] ? a->preview : NULL;
+ // A live turn can outlast its terminal footer (or have no readable footer).
+ // Keep its busy state visible while more specific activity is unavailable.
+ const char *activity = a && a->busy && s.connected && !s.loading && !s.nap ?
+ (a->tool[0] ? a->tool : "Working") : "";
+ home_caption_tick(ms());
+ bool rotating = home_caption_rotates();
+ 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();
char status[100];
- if (!s.connected) COPY(status, "Reconnect Harness");
- else if (s.loading) COPY(status, "Connecting...");
- else if (!a) COPY(status, "Choose a pane");
- else if (s.notice_count && !carry.active && !carry.error[0] && !visit.available)
- snprintf(status, sizeof status, "[%d]%s%.60s", s.notice_count, activity[0] ? " " : "", activity);
- else COPY(status, activity);
- ht_tim_face_t f_ = {.recipient = a ? a->name : "harness", .status = status,
- .hint = (s.connected && !s.loading) ? "" : "hold for controls",
- .detail = "", .unread = s.notice_count > 0,
- .mood = tim_mood(), .pose = octopus_motion.reaction.pose, .straight_title = STRAIGHT_TITLE,
+ if (s.voice_retry_until) COPY(status, "Try again");
+ else status[0] = 0;
+ ht_character_face_t f_ = {.recipient = caption, .status = bell ? "" : status,
+ .hint = "",
+ .detail = "",
- .mood = character_mood(), .pose = character.motion.reaction.pose, .straight_title = s.straight_title,
++ .mood = character_mood(), .pose = character.motion.reaction.pose,
++#if HT_FACE_PX >= 720
++ // Always straight here. ht_arc_title bends text around a 205 px radius baked into
++ // arc_trig[32][2]; at 720 the same table draws the name through the companion.
++ .straight_title = true,
++#else
++ .straight_title = s.straight_title,
++#endif
.footer_action = carry.active || carry.error[0] || visit.available,
- .ink = s.notice_count ? ACCENT : FG, .foreground = FG, .dim = DIM,
+ .ink = bell && !unread ? DIM : FG, .foreground = FG, .dim = DIM,
.primary_title = true, .roomy_reading = true};
char carried[128];
if (carry.active) {
@@@ -866,31 -811,17 +998,21 @@@
f_.status="Text expired"; f_.detail="Select it again or drop text"; f_.hint=""; f_.focus=true;
}
if (visit.available) f_.hint = "";
- if (s.touch_down && scroll.axis == 3) {
- f_.hint = "turn rim to scroll";
- f_.status = "scrolling";
- }
- #if HT_FACE_PX >= 720
- pro_tab_strip(f);
- /*
- * THE CONTROL ROW rides the hint field, which on this face only ever said "hold for controls" —
- * the dial's apology for having nowhere to write the gestures down. See pro_control_row().
- *
- * The tab row says which book you are in. It is mono_20 — 54 cells across 648 px — with the tab's
- * name left and its position right, in one run: the name is what you recognise and the counter is
- * what tells you a swipe has somewhere to go.
- *
- * The control row is the hint field, which on this face was only ever "hold for controls" — the
- * dial's apology for having nowhere to write the gestures down. Here the three that matter get
- * their names, in the habitat's own bracket vocabulary, and hit rects under them. Every gesture
- * still works exactly as it did: this is additive, and it is why the labels are DIM rather than FG.
- */
- f_.hint = "";
- #endif
- ht_octopus_face(f, &f_, octopus_motion.frame, ACCENT, recap);
+ ht_character_face(f, &character, &f_, ACCENT, recap);
+ if (bell) ht_notification_bell(f, unread, f_.ink);
+ s.status_phase = status_animated() ? ht_shimmer_phase(ms()) : 0;
+ for (int i = 0; i < f->count; i++) {
+ ht_run_t *run = &f->runs[i];
- if (run->arc == 1 || (s.straight_title && run->font == &ht_mono_20 &&
- (run->y == 41 || run->y == 69))) {
++ if (run->arc == 1 || (run->font == &ht_mono_20 &&
+#if HT_FACE_PX >= 720
- pro_status_is_inbox();
++ (run->y == 80 || run->y == 108))) {
++#else
++ s.straight_title && (run->y == 41 || run->y == 69))) {
+#endif
+ run->fg = rotating ? ht_character_caption_ink(FG, BG, home_caption.opacity) : FG;
+ if (run->arc) run->shimmer = s.status_phase;
+ }
+ }
if ((carry.active || carry.error[0]) && visit.available) {
footer_control(f, 95, 156, "[return]", A_RETURN, s.connected && !visit.pending);
footer_control(f, 263, 108, "[drop]", A_CARRY_DROP, true);
@@@ -899,254 -830,23 +1021,228 @@@
} else if (visit.available) {
footer_control(f, 113, 240, "[ return ]", A_RETURN, s.connected && !visit.pending);
}
- if (s.notice_count && s.connected && !s.loading && !carry.active && !carry.error[0] && !visit.available) {
- // The compact curved count owns a generous bottom-edge target.
- // It never shares the title/pane picker or the voice portrait.
- s.hits[s.hit_count++] = (hit_t){{83, 400, 300, 66}, A_INBOX, 0, true};
- for (int i = 0; i < f->count; i++) if (f->runs[i].arc == 2) {
+ if (!carry.active && !carry.error[0] && !visit.available) {
+ // Both phases of the caption open the same pane picker.
++#if HT_FACE_PX >= 720
++ s.hits[s.hit_count++] = (hit_t){{36, 76, 648, 46}, A_AGENTS, 0, true};
++#else
+ s.hits[s.hit_count++] = (hit_t){{83, 0, 300, 66}, A_AGENTS, 0, true};
++#endif
+ for (int i = 0; i < f->count; i++) if (f->runs[i].arc == 1) {
ht_rect_t r = ht_run_bounds(&f->runs[i]);
- s.inbox_arc = (ht_rect_t){r.x - 14, r.y - 14, r.w + 28, r.h + 28};
+ s.caption_arc = (ht_rect_t){r.x - 14, r.y - 14, r.w + 28, r.h + 28};
break;
}
}
- // The portrait is the large gesture area. Labels retain a few discoverable single-tap paths.
- bool result = recap && *recap;
- // The name stays on the upper arc in both states. Its rising ends stay
- // outside the companion's central voice target.
+ if (bell)
+#if HT_FACE_PX >= 720
- /*
- * THE TARGETS, RE-SEATED. Every rectangle below used to be a dial coordinate, and on a 720 face
- * that is not a near miss — it is a different part of the screen. The name sits at y 80..118 here
- * while the dial's rect covers 8..100; the companion is {144,140,432,432} while the dial's PET
- * target is {53,100,360,259}. Drawing was re-seated first and these were not, which is exactly
- * what "nothing responds to a tap" looks like from the outside.
- */
- s.hits[s.hit_count++] = (hit_t){{36, 76, 648, 46}, A_AGENTS, 0, true};
- if (result) {
- /* The recap's block, plus a little margin, dismisses it; the portrait above still pets. Both
- * sizes of result portrait are centred, so one rect covers font_8 (216) and font_10 (270). */
- int text_y = (ht_octopus_short_recap(recap) ? HT_OCTOPUS_BRIEF_TEXT_Y
- : HT_OCTOPUS_READING_TEXT_Y) - 6;
- s.hits[s.hit_count++] = (hit_t){{32, (int16_t)text_y, 656, (int16_t)(594 - text_y)},
- A_RECAP_DISMISS, 0, true};
- s.hits[s.hit_count++] = (hit_t){{225, HT_OCTOPUS_READING_Y, 270, 276}, A_PET, 0, true};
- } else {
- /* The font_16 companion exactly: 54*8 x 27*16 at x=(720-432)/2. */
- s.hits[s.hit_count++] = (hit_t){{144, 140, 432, 432}, A_PET, 0, true};
- }
- if (!a) /* "Choose a pane" is on the status line down at 600, not at 359. */
- s.hits[s.hit_count++] = (hit_t){{36, 594, 648, 50}, A_AGENTS, 0, true};
++ // Under the bell at HT_NOTIFICATION_Y, in the row the hint leaves empty on this face.
++ s.hits[s.hit_count++] = (hit_t){{144, 646, 432, 66}, A_INBOX, 0, unread > 0};
+#else
- s.hits[s.hit_count++] = (hit_t){{53, 8, 360, 92}, A_AGENTS, 0, true};
- if (!STRAIGHT_TITLE) {
- s.hits[s.hit_count++] = (hit_t){{33, 100, 90, 40}, A_AGENTS, 0, true};
- s.hits[s.hit_count++] = (hit_t){{343, 100, 90, 40}, A_AGENTS, 0, true};
- }
- if (result) {
- int reading_y = (ht_octopus_short_recap(recap) ? HT_OCTOPUS_BRIEF_TEXT_Y : HT_OCTOPUS_READING_TEXT_Y) - 4;
- s.hits[s.hit_count++] = (hit_t){{29, reading_y, 408, 396 - reading_y}, A_RECAP_DISMISS, 0, true};
- s.hits[s.hit_count++] = (hit_t){{143, 100, 180, reading_y - 106}, A_PET, 0, true};
- } else s.hits[s.hit_count++] = (hit_t){{53, 100, 360, 259}, A_PET, 0, true};
- if (!a)
- s.hits[s.hit_count++] = (hit_t){{65, 359, 336, 30}, A_AGENTS, 0, true};
+ s.hits[s.hit_count++] = (hit_t){{83, 382, 300, 84}, A_INBOX, 0, unread > 0};
++#endif
+ // The bell and the creature never share a target, even when the bell is
+ // dimmed or its count changes under a finger. Centre always starts voice.
++#if HT_FACE_PX >= 720
++ // The font_16 companion exactly: 54*8 x 27*16 at x=(720-432)/2, y=140.
++ s.hits[s.hit_count++] = (hit_t){{144, 140, 432, 432}, A_PET, 0, true};
++#else
+ s.hits[s.hit_count++] = (hit_t){{33, 66, 400, 316}, A_PET, 0, true};
+#endif
-
}
+#if HT_FACE_PX >= 720
+/*
+ * PAGE ONE: the tab's agents, in the window's own layout.
+ *
+ * The desktop does not send a list, it sends a SHAPE — normalised rectangles from
+ * app_state.dart's activeTileShape, one per pane, including the ones this device cannot drive, because
+ * "a shell or a viewer holds its place in the grid, and dropping it would leave the shape with a hole
+ * in it". So the device is not choosing a layout here. It is being told one, and its only job is to
+ * land it on a cell grid without lying about the proportions.
+ *
+ * 54 x 18 CELLS, and both numbers are chosen for their divisors. Every preset in pane_preset.dart is
+ * built from halves, thirds, sixths and ninths; 54 and 18 divide by all four, so a half is exactly a
+ * half and a third is exactly a third with no rounding drift anywhere. 54 * 12 x 18 * 28 = 648 x 504,
+ * which is 1.286:1 against the window's 1.344:1 — within 4.3%.
+ *
+ * (The LVGL desk on this same board is 656 x 600 = 1.093:1. Its comment still claims 1.34:1, which was
+ * true at the original DESK_GRID_H 488; raising it to 600 for the extra room left every rectangle the
+ * window sends 23% too tall. Worth fixing there separately.)
+ *
+ * A TILE IS THREE RUNS, not a box: a rule of ':' along its top edge, the name a row below it, and the
+ * state as a WORD a row below that. Nine tiles is 27 runs, plus the tab row, the status and the control
+ * row — 30 of HT_RUNS 40. A fourth line per tile would not fit, and neither would a tenth tile.
+ * The ':' is from the octopus's own density ramp; ht_mono_* covers 32..255 and has no box-drawing set
+ * at all, so a border made of U+2500 would be an empty cell on the glass.
+ */
+enum { DESK_COLS = 54, DESK_ROWS = 18, DESK_X = 36, DESK_Y = 100 };
+static int desk_col(int v) { return (v * DESK_COLS + 500) / 1000; }
+static int desk_row(int v) { return (v * DESK_ROWS + 500) / 1000; }
+static int desk_agent(const char *id)
+{
+ if (!id || !*id) return -1;
+ for (int i = 0; i < s.count; i++) if (!strcmp(s.agents[i].id, id)) return i;
+ return -1;
+}
+static void render_desk(ht_scene_t *f)
+{
+ pro_tab_strip(f);
+ // The shape must be the SELECTED tab's. A roster that has moved on while the shape has not is the
+ // one case that would draw agents at another tab's seats, so it falls back to saying so.
+ bool tagged = !strcmp(s.tile_tab, s.selected_tab);
+ /*
+ * EVERY NAMED SEAT MUST RESOLVE, or this shape belongs to a roster we do not have yet.
+ *
+ * The window's shape and the device's roster ride DIFFERENT frames, so after a tab switch the
+ * rectangles routinely land a beat before the agents that go in them. Drawing anyway fills the
+ * desk with the word "pane" — every seat unnamed — and it stays that way in the eye long after
+ * the roster arrives, because that is what the person saw. The LVGL desk on this board hit
+ * exactly this and answered it the same way (desk_tiles_usable in ui_screens.c).
+ *
+ * A seat with an empty agentId is a shell or a viewer and is legitimately unnamed; only the named
+ * ones have to be found.
+ */
+ int named = 0, resolved = 0;
+ for (int i = 0; i < s.tile_count; i++) {
+ if (!s.tiles[i].agent_id[0]) continue;
+ named++;
+ if (desk_agent(s.tiles[i].agent_id) >= 0) resolved++;
+ }
+ /*
+ * ONE SEAT THAT NEVER RESOLVES MUST NOT HOLD THE WHOLE DESK.
+ *
+ * Requiring every named seat was right for the transient case and wrong for the steady one: a
+ * window can hold a pane this device's roster does not carry — an agent on another machine, or one
+ * the roster filters — and then "3 of 4 named" is the permanent truth, not a beat of lag. Waiting
+ * on it showed a sentence instead of a desk, forever.
+ *
+ * So the bar is that SOMETHING resolves. Nothing resolving is the roster being a frame behind, and
+ * that is the case worth waiting out; the odd unresolvable seat is drawn as what it is.
+ */
+ bool ready = named == 0 || resolved > 0;
+ bool shaped = s.tile_count > 0 && tagged && ready;
+ if (!shaped) {
+ // Three different failures used to read as one sentence, which is no use to anyone standing in
+ // front of the device: nothing to lay out, a shape that belongs to another tab, or a window
+ // that has not described this one yet.
+ ht_center(f, 330, UI_FONT, FG,
+ s.loading ? "Loading..."
+ : !s.count ? "No panes in this tab."
+ : !s.tile_count ? "No layout from the app yet."
+ : !tagged ? "Layout is for another tab."
+ : "Matching panes to agents...");
+ if (!ready && tagged && s.tile_count) {
+ // The counts, so a shape that never resolves can be told from one that is merely early.
+ char why[64];
+ snprintf(why, sizeof why, "%d of %d named %s roster %d", resolved, named, "\xc2\xb7", s.count);
+ ht_center(f, 386, &ht_mono_20, DIM, why);
+ }
- pro_status_is_inbox();
+ return;
+ }
+ /*
+ * THE SEPARATORS ARE ONE RUN PER GRID ROW, not one per tile edge.
+ *
+ * A run is a single line of text, so a VERTICAL line costs one run per row it crosses — eighteen
+ * of them for a full-height boundary, and a 3 x 3 desk has two such boundaries. That is the whole
+ * scene budget spent on lines. Drawing the grid into a character buffer first and emitting one run
+ * per row inverts the cost: every vertical boundary at that row shares the run, so the lines cost
+ * 18 runs no matter how many columns the window is using.
+ *
+ * Budget, against HT_RUNS 40: 18 line rows + 2 per tile + the tab strip's 2 + the status. Nine
+ * tiles is 39. That is the ceiling, and it is why a tile gets two text rows and not three.
+ */
+ char grid[DESK_ROWS][DESK_COLS + 1];
+ memset(grid, ' ', sizeof grid);
+ int working = 0, idle = 0;
+ struct { int16_t x, y, w; int ai; bool pane; const char *state; } seat[SWARM_TILES_MAX];
+ int seats = 0;
+
+ for (int i = 0; i < s.tile_count; i++) {
+ const cable_tile_t *t = &s.tiles[i];
+ int c0 = desk_col(t->x1), c1 = desk_col(t->x2);
+ int r0 = desk_row(t->y1), r1 = desk_row(t->y2);
+ if (c1 <= c0 || r1 <= r0) continue; // a rectangle thinner than one cell
+ if (c1 > DESK_COLS) c1 = DESK_COLS;
+ if (r1 > DESK_ROWS) r1 = DESK_ROWS;
+ // The tile's top edge, across its own width.
+ for (int c = c0; c < c1; c++) grid[r0][c] = ':';
+ /*
+ * The left edge, full height, TWO COLUMNS of the same ':' — one column reads as a hairline
+ * between two panes that are themselves full of text, which is not enough separation at a
+ * glance. Doubling the column rather than changing the character keeps the dotted texture the
+ * rest of the face is drawn in; '|' or '=' made it a different object entirely.
+ *
+ * Only where it is an INTERIOR boundary. The canvas has no outer border: the face's own margin
+ * is the border, and a box drawn around the whole grid would read as a window inside a window.
+ *
+ * The second column costs one cell of the tile's width, which is why the labels below start
+ * two cells in.
+ */
+ if (c0 > 0)
+ for (int r = r0; r < r1; r++) {
+ grid[r][c0] = ':';
+ if (c0 + 1 < DESK_COLS) grid[r][c0 + 1] = ':';
+ }
+
+ int ai = desk_agent(t->agent_id);
+ agent_t *a = ai >= 0 ? &s.agents[ai] : NULL;
+ if (a && a->busy) working++; else if (a) idle++;
+ if (seats < SWARM_TILES_MAX)
+ seat[seats++] = (typeof(seat[0])){
+ (int16_t)(DESK_X + c0 * ht_mono_20.width), (int16_t)(DESK_Y + r0 * ht_mono_20.height),
+ (int16_t)((c1 - c0) * ht_mono_20.width), ai, !t->agent_id[0],
+ !t->agent_id[0] ? "pane" : !a ? "unknown"
+ : a->busy ? "working" : a->recap_ready ? "done" : "idle"};
+ if (s.hit_count < 24)
+ s.hits[s.hit_count++] = (hit_t){{(int16_t)(DESK_X + c0 * ht_mono_20.width),
+ (int16_t)(DESK_Y + r0 * ht_mono_20.height),
+ (int16_t)((c1 - c0) * ht_mono_20.width),
+ (int16_t)((r1 - r0) * ht_mono_20.height)},
+ A_AGENT, ai, ai >= 0 && s.connected};
+ }
+
+ for (int r = 0; r < DESK_ROWS; r++) {
+ grid[r][DESK_COLS] = 0;
+ if (!memchr(grid[r], ':', DESK_COLS)) continue; // a row with no line on it costs no run
+ ht_ascii_text(f, DESK_X, DESK_Y + r * ht_mono_20.height, DESK_COLS * ht_mono_20.width,
+ &ht_mono_20, DIM, BG, grid[r], DESK_COLS);
+ }
+
+ // The labels go on top of the lines, inset by one cell on each side so a name can never paint out
+ // the boundary of the tile beside it.
+ for (int i = 0; i < seats; i++) {
+ int ai = seat[i].ai;
+ bool focused = ai >= 0 && ai == s.active;
+ // Two cells in from the doubled rule, and one clear of the next tile's, so a name can never
+ // paint out either column of a boundary.
+ int w = seat[i].w - 3 * ht_mono_20.width;
+ if (w < ht_mono_20.width) continue;
+ char label[HT_TEXT_BYTES];
+ // Three states, three words: a seat with no agent at all is a shell or a viewer ("pane"); a
+ // seat naming an agent this device does not carry is "agent"; the rest have their own name.
+ snprintf(label, sizeof label, "%s", seat[i].pane ? "pane" : ai < 0 ? "agent" : s.agents[ai].name);
+ ht_text(f, seat[i].x + 2 * ht_mono_20.width, seat[i].y + ht_mono_20.height, w, &ht_mono_20,
+ !s.connected ? DIM : focused ? ACCENT : seat[i].pane ? DIM : FG, BG, label);
+ ht_text(f, seat[i].x + 2 * ht_mono_20.width, seat[i].y + 2 * ht_mono_20.height, w, &ht_mono_20,
+ DIM, BG, seat[i].state);
+ }
+ /* The unread count leads here too, in the same brackets and the same place as on the agent face,
+ * so one habit reaches the inbox from either page. */
+ char tally[64];
+ if (s.notice_count > 0)
+ snprintf(tally, sizeof tally, "[%d] %d working %s %d idle", s.notice_count, working, "\xc2\xb7", idle);
+ else
+ snprintf(tally, sizeof tally, "%d working %s %d idle", working, "\xc2\xb7", idle);
+ ht_center(f, 600, UI_FONT, s.notice_count > 0 ? ACCENT : DIM, tally);
- pro_status_is_inbox();
+}
+#endif
static void render_agents(ht_scene_t *f)
{
+#if HT_FACE_PX >= 720
+ // On a square the pane list IS the desk: the window's shape, not a column of rows.
+ render_desk(f);
+ return;
+#endif
heading(f, "panes");
int last = s.count > TAB_ROWS ? s.count - TAB_ROWS : 0;
if (s.offset > last) s.offset = last;
@@@ -2023,49 -1699,18 +2095,42 @@@ static void dispatch(action_t a
s.offset=first<0 ? 0 : first>last ? last : first;
break;
}
+#if HT_FACE_PX >= 720
+ case A_TAB_STRIP_LEFT:
+ case A_TAB_STRIP_RIGHT:
- // Two at a time: one felt like nothing had happened on a strip this wide. The strip, and the
- // tab_first it walks, exist only on the square face — the dial has no room for the row.
++ // Two at a time: one felt like nothing had happened on a strip this wide.
+ s.tab_first += a.kind == A_TAB_STRIP_LEFT ? -2 : 2;
+ if (s.tab_first < 0) s.tab_first = 0;
+ if (s.tab_first >= s.tab_count) s.tab_first = s.tab_count ? s.tab_count - 1 : 0;
+ change();
+ break;
+#endif
case A_MACHINES:
view(MACHINES);
break;
case A_TAB:
if (!s.connected || s.voice_open || s.loading || workspace_index(a.id)<0) break;
+#if HT_FACE_PX >= 720
+ // Choosing a tab asks to see ITS PANES — unless there is only one, in which case the pane IS
- // the tab and the companion is the answer. On the dial a tab always lands on the companion,
- // because that is the only face there is.
++ // the tab and the companion is the answer.
+ if (!strcmp(a.id,s.selected_tab)) { view(pro_panes_of(a.id) > 1 ? AGENTS : HOME); break; }
+ s.land_on_desk = pro_panes_of(a.id) > 1;
+#else
if (!strcmp(a.id,s.selected_tab)) { view(HOME); break; }
+#endif
if (ht_workspace_request(&workspace,a.id,ms())) {
a.revision=workspace.serial;
if (!queue(a)) { workspace_failed("Device busy. Choose the tab again."); break; }
ht_visit_close(&visit); s.pending_focus[0]=0;
+#if HT_FACE_PX >= 720
- /*
- * NO INTERSTITIAL. Going to MESSAGE for the wait meant leaving the companion face for a
- * near-empty screen and coming back — two whole-face repaints for something that takes
- * well under a second, which reads as the screen flashing rather than as progress.
- *
- * The panes page is where the switch is going anyway, and it already has a quiet
- * "Loading..." for exactly this. So it goes there now and stays there.
- */
++ // NO INTERSTITIAL. Going to MESSAGE meant leaving the companion for a near-empty screen
++ // and coming back — two whole-face repaints for well under a second, which reads as the
++ // screen flashing rather than as progress. The panes page is where this is going anyway.
+ view(AGENTS); s.loading=true;
+#else
COPY(s.title,"Switching tab"); COPY(s.message,"Opening your workspace...");
view(MESSAGE); s.loading=true;
+#endif
}
break;
case A_MACHINE:
@@@ -2637,35 -2266,17 +2715,41 @@@ void habitat_touch(bool down, int x, in
}
int dx = x - s.start_x, dy = y - s.start_y;
s.pressed = -1;
+ if (s.quick_open && !s.touch_cancelled) {
+ // Use the release coordinates too: lifting after sliding back to
+ // the center cancels, even if no final MOVE sample was delivered.
+ int choice = 0;
+ if (dx * dx + dy * dy > 54 * 54)
+ choice = abs(dx) > abs(dy) ? (dx < 0 ? 3 : 2) : (dy < 0 ? 1 : 4);
+ static const action_kind_t destinations[] = {A_NONE, A_AGENTS, A_INBOX, A_TABS, A_SETTINGS};
+ s.quick_open = false;
+ if (choice) dispatch((action_t){.kind = destinations[choice]});
+ change();
+#if HT_FACE_PX >= 720
- if (s.tab_strip_held && gesture.moved && gesture.axis == 2) {
++ } else if (s.tab_strip_held && gesture.moved && gesture.axis == 2) {
+ // The strip consumed this contact while it was moving; its end is not a choice.
+ } else if (pro_written_control(pressed_action.kind) &&
+ x >= pressed_rect.x && x < pressed_rect.x + pressed_rect.w &&
+ y >= pressed_rect.y && y < pressed_rect.y + pressed_rect.h) {
+ /*
+ * A BUTTON, JUDGED BY WHERE THE FINGER CAME UP — not by how far it wandered, and not by
+ * how long it stayed.
+ *
- * Both earlier attempts at this failed on the same measurement. ht_gesture_move() calls a
- * contact "moved" at 12 px, which on this panel is 1.20 mm; a deliberate press with a
- * fingertip drifts two to four. So `!gesture.moved` was false most of the time, and the
- * scroll layer — same 12 px claim — had already taken the contact anyway, which is why the
- * branch also had to come up here, above `scrolled || s.touch_cancelled`.
++ * ht_gesture_move() calls a contact "moved" at 12 px, which on this panel is 1.20 mm; a
++ * deliberate press with a fingertip drifts two to four. So a rule keyed on !gesture.moved
++ * fires for a still finger and not for a real one, and the scroll layer — same 12 px
++ * claim — has already taken the contact by the time the branch below is reached, which is
++ * why this sits above it.
+ *
- * The rule every touch button uses is the right one: down on the control, up on the
- * control, activate. Drift inside it is a press. Drift out of it is a cancel, which is
- * what the bounds test below gives for free.
- *
- * The strip's drag is checked first, so dragging the tab row still scrolls it rather than
- * choosing whichever tab the finger happened to leave.
++ * Down on the control, up on the control, activate. Drift inside it is a press; drift out
++ * of it is a cancel, which the bounds test gives for free. The strip's drag is checked
++ * first, so dragging the tab row scrolls it rather than choosing whichever tab the finger
++ * happened to leave.
+ */
+ ht_gesture_cancel(&gesture);
+ dispatch(pressed_action);
- } else if (scrolled || s.touch_cancelled) {
- #else
- if (scrolled || s.touch_cancelled) {
+#endif
+ } else if (scrolled || s.touch_cancelled) {
// Motion owns this entire contact, even if the finger returns to its starting point.
} else if (result == HT_TOUCH_TAP && s.touch_brake) {
// DOWN already stopped desktop inertia. This entire tap is only a brake.
@@@ -3370,14 -2991,7 +3467,14 @@@ void ui_land_after_reload(void
if (s.loading && (workspace.phase==HT_WORKSPACE_IDLE || workspace.phase==HT_WORKSPACE_READY)) {
ht_workspace_cancel_request(&workspace);
s.loading = false;
+#if HT_FACE_PX >= 720
+ // Re-checked here as well as at the tap: the swarm row can arrive with a truer pane count
- // between asking for a tab and landing in it, and this is the last moment the answer matters.
++ // between asking for a tab and landing in it, and this is the last moment it matters.
+ view(s.land_on_desk && pro_panes_of(s.selected_tab) > 1 ? AGENTS : HOME);
+ s.land_on_desk = false;
+#else
view(HOME);
+#endif
}
change();
display_unlock();
diff --cc devices/harness-device/firmware/test/test_touch_driver.py
index db0916ee3,db0916ee3..f147cd964
--- a/devices/harness-device/firmware/test/test_touch_driver.py
+++ b/devices/harness-device/firmware/test/test_touch_driver.py
@@@ -16,8 -16,8 +16,10 @@@ code=r''
#include <setjmp.h>
#include <stdio.h>
#include "creature_gallery.h"
--#define HT_WIDTH 466
--#define HT_HEIGHT 466
++/* HT_WIDTH / HT_HEIGHT come from terminal.h through the header above. They used to be repeated here
++ as 466, which was a harmless identical redefinition while the header spelled them the same way;
++ the header now derives them from HT_FACE_PX, so repeating them is a -Wmacro-redefined error and,
++ worse, would pin this test to one face. */
#define ESP_OK 0
#define ESP_ERR_INVALID_RESPONSE 1
#define ESP_FAIL 2