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.

feat(device): synchronize tab browsing and confirm with Done

deecff6544aaf30
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 2b9ef931c..2dc2dcfe7 100644
--- a/devices/harness-device/firmware/main/ui/habitat/ui_habitat.c
+++ b/devices/harness-device/firmware/main/ui/habitat/ui_habitat.c
@@ -106,7 +106,7 @@ typedef enum {
A_INBOX,
A_NOTICE,
A_TABS,
- A_TAB, A_TAB_REFRESH,
+ A_TAB, A_TAB_REFRESH, A_TAB_DONE,
A_MACHINES,
A_MACHINE,
A_VOICE,
@@ -583,6 +583,34 @@ static void workspace_failed(const char *message)
s.loading=false; s.active=-1;
COPY(s.title,"Workspaces"); COPY(s.message,message); view(MESSAGE);
}
+static void tab_request(const char *id, bool browsing)
+{
+ if (!s.connected || s.voice_open || (!browsing && s.loading) || workspace_index(id)<0) return;
+ if (workspace.phase!=HT_WORKSPACE_IDLE) {
+ if (!browsing || !strcmp(id,workspace.pending)) return;
+ // A newer page supersedes both queued selects and their roster receipts.
+ ht_workspace_cancel_request(&workspace);
+ } else if (!strcmp(id,s.selected_tab)) {
+ if (!browsing) view(HOME);
+ return;
+ }
+ if (!ht_workspace_request(&workspace,id,ms())) return;
+ action_t a={.kind=A_TAB,.revision=workspace.serial}; COPY(a.id,id);
+ if (!queue(a)) { workspace_failed("Device busy. Choose the tab again."); return; }
+ ht_visit_close(&visit); s.pending_focus[0]=0;
+ s.loading=true;
+ if (!browsing) {
+ COPY(s.title,"Switching tab"); COPY(s.message,"Opening your workspace...");
+ view(MESSAGE);
+ }
+ change();
+}
+static void tabs_sync(void)
+{
+ if (s.view!=TABS || (s.touch_down && s.touch_cancelled)) return;
+ int index=ht_tab_carousel_index(&tab_carousel);
+ if (index>=0 && index<s.tab_count) tab_request(s.tabs[index].id,true);
+}
static int waiting(void)
{
int n = 0;
@@ -953,7 +981,10 @@ static void surface_tick(uint32_t now)
if (companion_celebrating && (now-celebration_began>=2400 || s.view!=HOME || s.quiet || !follow_companion || display_is_asleep() || character_mood()==HT_CHARACTER_ATTENTION)) {
companion_celebrating=false; select_companion(); change();
}
- if (s.view == TABS && !display_is_asleep() && ht_tab_carousel_tick(&tab_carousel, now)) change();
+ if (s.view == TABS && !display_is_asleep()) {
+ if (ht_tab_carousel_tick(&tab_carousel, now)) change();
+ tabs_sync();
+ }
if (home_caption_tick(now)) change();
uint8_t phase = status_animated() ? ht_shimmer_phase(now * status_speed()) : 0;
if (phase != s.status_phase) { s.status_phase = phase; change(); }
@@ -1243,7 +1274,7 @@ static void focus_clipped(ht_scene_t *f, int x, int y, const ht_font_t *font, ui
if (w > 0) ht_text(f, x, y, w, font, ink, BG, probe);
}
/*
- * The top of Focus's two lists, as the LVGL TABS picker drew it: the 60 x 32 close pill at y 16 —
+ * The top of Focus's lists: the 60 x 32 close pill at y 16 (tabs use Done below) —
* the way back, in place of a ← — and the list's name in grey Literata 20 (literata_20: the Kindle
* style of the curved name and the pane names, owner 2026-10-02), letter-spaced 2, at y 62.
*/
@@ -1253,11 +1284,13 @@ static void focus_header(ht_scene_t *f, const char *title)
const ht_font_t *small = &ht_lv_literata_20.base, *cross = &ht_lv_montserrat_22.base;
uint16_t fg = color(0xeaeaf0), close = color(0x171718);
// make_close_pill: COL_FG at 10 % over black, the cross centred in it.
- int cw = ht_measure(cross, HT_LV_CROSS);
- ht_box(f, CLOSE_X, CLOSE_Y, CLOSE_W, CLOSE_H, CLOSE_H / 2, close, close);
- ht_text(f, CLOSE_X + (CLOSE_W - cw) / 2, CLOSE_Y + (CLOSE_H - cross->height) / 2, cw, cross, fg,
- close, HT_LV_CROSS);
- s.hits[s.hit_count++] = (hit_t){{CLOSE_X - 40, 0, CLOSE_W + 80, CLOSE_Y + CLOSE_H + 12}, A_HOME, 0, true};
+ if (s.view != TABS) {
+ int cw = ht_measure(cross, HT_LV_CROSS);
+ ht_box(f, CLOSE_X, CLOSE_Y, CLOSE_W, CLOSE_H, CLOSE_H / 2, close, close);
+ ht_text(f, CLOSE_X + (CLOSE_W - cw) / 2, CLOSE_Y + (CLOSE_H - cross->height) / 2, cw, cross, fg,
+ close, HT_LV_CROSS);
+ s.hits[s.hit_count++] = (hit_t){{CLOSE_X - 40, 0, CLOSE_W + 80, CLOSE_Y + CLOSE_H + 12}, A_HOME, 0, true};
+ }
// A letter to a run, which is how the spacing is drawn.
int tw = 0;
for (const char *c = title; *c; c++) { char one[2] = {*c, 0}; tw += ht_measure(small, one) + 2; }
@@ -1537,7 +1570,7 @@ static void tab_name(ht_scene_t *f, const char *name, int center_x, uint16_t ink
}
}
/*
- * FOCUS'S TABS: the close pill and "TABS" on top (focus_header), then the same carousel, in Literata 30 — the name on at most two lines of 204 px, as
+ * FOCUS'S TABS: "TABS" on top (focus_header), then the same carousel, in Literata 30 — the name on at most two lines of 204 px, as
* the mono version wrapped at twelve cells, ending in "..." past that; neighbours peek in at the
* edges, cut to whole letters inside x 42..424. The tab you are in is green.
*/
@@ -1574,13 +1607,19 @@ static void render_focus_tabs(ht_scene_t *f)
if (left < 33) left = 33;
if (right > 433) right = 433;
if (right > left) s.hits[s.hit_count++] = (hit_t){{left, 110, right - left, 252},
- A_TAB, i, s.connected && !s.loading};
+ A_TAB, i, s.connected};
}
}
}
static void render_tabs(ht_scene_t *f)
{
- if (character.id == HT_CHARACTER_FOCUS) { render_focus_tabs(f); return; }
+ // Done is shared by every face, with the same generous bottom-edge target.
+ ht_text(f, (HT_WIDTH-ht_done_28.width)/2, 400, ht_done_28.width, &ht_done_28, FG, BG, HT_DONE);
+ if (character.id == HT_CHARACTER_FOCUS) {
+ render_focus_tabs(f);
+ s.hits[s.hit_count++] = (hit_t){{83, 392, 300, 74}, A_TAB_DONE, 0, true};
+ return;
+ }
ht_arc_title(f, DIM, "tabs");
int current = ht_tab_carousel_index(&tab_carousel);
if (current < 0) center(f, 214, "No tabs yet.", DIM);
@@ -1593,7 +1632,7 @@ static void render_tabs(ht_scene_t *f)
ink = ht_character_caption_ink(ink, BG, fade < 210 ? 255 - fade : 45);
tab_name(f, s.tabs[i].name, 233 + dx, ink);
}
- // Each visible name owns its tap; a swipe from any page only browses.
+ // Each visible name owns its tap; dragging selects the centered page live.
// Keep the centered page first for stable accessibility/test ordering.
for (int n = 0; n < 3; n++) {
int i = current + (n == 1 ? -1 : n == 2 ? 1 : 0);
@@ -1604,11 +1643,10 @@ static void render_tabs(ht_scene_t *f)
if (left < 33) left = 33;
if (right > 433) right = 433;
if (right > left) s.hits[s.hit_count++] = (hit_t){{left, 110, right - left, 252},
- A_TAB, i, s.connected && !s.loading};
+ A_TAB, i, s.connected};
}
}
- ht_text(f, 223, 400, 20, &ht_nav_32, DIM, BG, "←");
- s.hits[s.hit_count++] = (hit_t){{83, 392, 300, 74}, A_HOME, 0, true};
+ s.hits[s.hit_count++] = (hit_t){{83, 392, 300, 74}, A_TAB_DONE, 0, true};
}
static void render_notice(ht_scene_t *f)
{
@@ -2371,15 +2409,19 @@ static void dispatch(action_t a)
view(MACHINES);
break;
case A_TAB:
- if (!s.connected || s.voice_open || s.loading || workspace_index(a.id)<0) break;
- if (!strcmp(a.id,s.selected_tab)) { view(HOME); break; }
- 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 (s.view==TABS && workspace_index(a.id)>=0)
+ ht_tab_carousel_reset(&tab_carousel,s.tab_count,workspace_index(a.id));
+ tab_request(a.id,s.view==TABS);
+ break;
+ case A_TAB_DONE:
+ if (s.view!=TABS) break;
+ ht_tab_carousel_cancel(&tab_carousel);
+ tabs_sync();
+ if (s.view!=TABS) break; // preserve a queue failure shown by tabs_sync
+ if (workspace.phase!=HT_WORKSPACE_IDLE) {
COPY(s.title,"Switching tab"); COPY(s.message,"Opening your workspace...");
- view(MESSAGE); s.loading=true;
- }
+ view(MESSAGE);
+ } else view(HOME);
break;
case A_MACHINE:
if (s.connected && queue(a)) {
@@ -2853,7 +2895,9 @@ void habitat_touch(bool down, int x, int y, uint32_t now)
if (surface && home_footer(pressed_action.kind)) {
if (pressed_action.kind==A_TABS && ht_workspace_move(&workspace,x,y,gesture.axis,now)) change();
} else if (s.view == TABS) {
- if (gesture.axis == 2 && ht_tab_carousel_move(&tab_carousel, x, now)) change();
+ if (gesture.axis == 2 && ht_tab_carousel_move(&tab_carousel, x, now)) {
+ tabs_sync(); change();
+ }
} else if (s.view == AGENTS && character.id == HT_CHARACTER_FOCUS && gesture.axis == 1) {
panes_move((s.last_y - y) * (scroll_reversed ? -1 : 1));
} else if ((s.view == AGENTS || s.view == SETTINGS) && gesture.axis == 1) {
@@ -2897,6 +2941,7 @@ void habitat_touch(bool down, int x, int y, uint32_t now)
int index = pressed_action.value;
if (tab_tap && result == HT_TOUCH_TAP && pressed_action.kind == A_TAB && index >= 0 &&
index < s.tab_count && !strcmp(pressed_action.id, s.tabs[index].id)) dispatch(pressed_action);
+ tabs_sync();
change();
} else if (result == HT_TOUCH_TAP && s.touch_brake) {
// DOWN already stopped desktop inertia. This entire tap is only a brake.
@@ -3475,7 +3520,7 @@ void ui_project_remove(const char *id)
display_lock();
int i = find(id);
if (i >= 0) {
- if (s.active == i) {
+ if (s.active == i && s.view != TABS) {
input_cancel();
}
memmove(&s.agents[i], &s.agents[i + 1], (size_t)(s.count - i - 1) * sizeof(agent_t));
@@ -3491,7 +3536,7 @@ void ui_project_remove(const char *id)
void ui_project_clear_all(void)
{
display_lock();
- input_cancel();
+ if (s.view != TABS) input_cancel();
s.count = 0;
s.active = -1;
change();
@@ -3753,7 +3798,7 @@ void ui_focus_project(const char *id)
s.pending_focus[0] = 0;
bool opened = s.opening_notice[0] && !strcmp(s.opening_notice, id);
if (opened) s.opening_notice[0] = 0;
- if (s.active != i) {
+ if (s.active != i && s.view != TABS) {
input_cancel();
}
s.active = i;
@@ -3796,7 +3841,7 @@ 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;
- view(HOME);
+ if (s.view != TABS) view(HOME);
}
change();
display_unlock();
@@ -4189,7 +4234,9 @@ void ui_swarms_replace(const cable_swarm_t *rows, int count, const char *selecte
char focused[ID_MAX] = "";
int focused_index = ht_tab_carousel_index(&tab_carousel);
if (s.view == TABS && focused_index >= 0 && focused_index < s.tab_count) COPY(focused, s.tabs[focused_index].id);
- bool changed=bounded!=s.tab_count || strcmp(s.selected_tab,selected ? selected : "");
+ bool selected_changed=strcmp(s.selected_tab,selected ? selected : "");
+ bool browsing=workspace.phase!=HT_WORKSPACE_IDLE || tab_carousel.touching || tab_carousel.animating;
+ bool changed=bounded!=s.tab_count;
for (int i=0;!changed && i<bounded;i++) {
changed=strcmp(rows[i].id,s.tabs[i].id) || strcmp(rows[i].name,s.tabs[i].name);
}
@@ -4197,8 +4244,8 @@ void ui_swarms_replace(const cable_swarm_t *rows, int count, const char *selecte
s.tab_count=bounded;
if (bounded) memcpy(s.tabs,rows,(size_t)bounded*sizeof *rows);
COPY(s.selected_tab,selected);
- if (changed && s.view == TABS) {
- int index = workspace_index(focused);
+ if (s.view == TABS && (changed || (selected_changed && !browsing))) {
+ int index = browsing ? workspace_index(focused) : workspace_index(s.selected_tab);
ht_tab_carousel_reset(&tab_carousel, bounded, index >= 0 ? index : workspace_index(s.selected_tab));
}
if (workspace.phase!=HT_WORKSPACE_IDLE && workspace_index(workspace.pending)<0) {
diff --git a/devices/harness-device/firmware/main/ui/habitat/workspace.h b/devices/harness-device/firmware/main/ui/habitat/workspace.h
index a81ada64e..2c5cf1e63 100644
--- a/devices/harness-device/firmware/main/ui/habitat/workspace.h
+++ b/devices/harness-device/firmware/main/ui/habitat/workspace.h
@@ -26,7 +26,8 @@ void ht_workspace_cancel_request(ht_workspace_t *);
bool ht_workspace_tick(ht_workspace_t *, uint32_t now);
// Thumb-driven tab pages. Position is in glass pixels; all easing is integer.
-// Browsing never sends a request. Only a subsequent, settled tap may open a tab.
+// The UI sends the centered tab as it changes, including during drag and settling.
+// The return from end only identifies a settled tap; Done closes the picker.
enum { HT_TAB_PITCH = 228, HT_TAB_DRAG_GAIN = 2, HT_TAB_SETTLE_MS = 192 };
typedef struct {
int count, position, from, target, origin, x, last_x, velocity;
diff --git a/devices/harness-device/firmware/test/test_touch_ui.py b/devices/harness-device/firmware/test/test_touch_ui.py
index d5445de9b..80031c0e3 100644
--- a/devices/harness-device/firmware/test/test_touch_ui.py
+++ b/devices/harness-device/firmware/test/test_touch_ui.py
@@ -202,7 +202,7 @@ static bool scroll_emit(ht_scroll_phase_t phase, int dy, int velocity, void *ctx
code += function('color')
code += function('settings_item') + function('settings_count') + function('hit_contains')
code += function('find')
-for name in ['copy', 'recap_preview', 'notice_unread', 'notice_was_read', 'notice_forget_read', 'notice_flush_reads', 'notice_mark_read', 'habitat_scene_receipt', 'habitat_scene_presented', 'pane_memory', 'pane_memory_apply', 'dismiss_result', 'activity_text', 'ensure', 'input_cancel', 'view', 'notice_open', 'workspace_index', 'tabs_open', 'workspace_failed', 'ui_scroll_reportable', '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', 'render_home', 'render_voice', 'render_selection', 'render_form', 'draft_move', 'render_draft', 'render_draft_options', 'ui_swarms_replace', 'ui_workspace_applied', 'ui_land_after_reload']:
+for name in ['copy', 'recap_preview', 'notice_unread', 'notice_was_read', 'notice_forget_read', 'notice_flush_reads', 'notice_mark_read', 'habitat_scene_receipt', 'habitat_scene_presented', 'pane_memory', 'pane_memory_apply', 'dismiss_result', 'activity_text', 'ensure', 'input_cancel', 'view', 'notice_open', 'workspace_index', 'tabs_open', 'workspace_failed', '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', 'render_home', 'render_voice', 'render_selection', 'render_form', 'draft_move', 'render_draft', 'render_draft_options', 'ui_swarms_replace', 'ui_workspace_applied', 'ui_land_after_reload']:
code += function(name)
code += function('render_settings') + function('ui_visit_state')
code += function('ui_project_known') + function('ui_focus_project') + function('ui_apply_pending_focus')
@@ -262,7 +262,7 @@ static void dispatch(action_t 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) workspace_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);
@@ -365,7 +365,8 @@ static void focus_only_literata(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_lv_montserrat_14.base && !strcmp(r->text, HT_LV_BELL)) ||
+ 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_literata(r->font) || icon || art);
@@ -1475,7 +1476,7 @@ int main(int argc, char **argv) {
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_HOME) && !action_enabled(A_SETTINGS) && !action_enabled(A_MACHINES));
+ 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"));
@@ -1490,30 +1491,57 @@ int main(int argc, char **argv) {
}
assert(previous_visible && next_visible);
habitat_touch(true,300,233,3000); habitat_touch(true,240,233,3120); scene_take();
- assert(tab_carousel.position==HT_TAB_PITCH+120 && !tab_switches && !starts && !moves);
+ 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 && !starts);
+ 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 && !starts);
+ 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(tab_switches==1 && !strcmp(tab_target,chosen_id));
- // Tapping a visible neighbor opens that exact tab, never the centered name.
+ 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();
- tap(4000,80,233); assert(tab_switches==1 && !strcmp(tab_target,"tab-0") && !starts);
+ 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,386,233); assert(tab_switches==1 && !strcmp(tab_target,"tab-2") && !starts);
- // Vertical/out-and-back motion stays in the picker and never opens a tab.
+ 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);
+ 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++) {
@@ -1528,7 +1556,7 @@ int main(int argc, char **argv) {
uint32_t t=6000+(22-wanted)*1000;
habitat_touch(true,203,233,t); habitat_touch(true,263,233,t+300);
habitat_touch(false,263,233,t+450); surface_tick(t+700); scene_take();
- assert(ht_tab_carousel_index(&tab_carousel)==wanted && !tab_switches && !starts);
+ 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.
@@ -1537,15 +1565,27 @@ int main(int argc, char **argv) {
assert(!s.touch_cancelled);
ui_swarms_replace(s.tabs,2,"tab-1");
habitat_touch(false,233,233,30075); scene_take();
- assert(!tab_switches && !starts && s.hit_count==3 && ht_tab_carousel_index(&tab_carousel)==0);
+ assert(tab_switches==23 && !starts && s.hit_count==3 && ht_tab_carousel_index(&tab_carousel)==0);
ui_swarms_replace(NULL,0,NULL); scene_take(); portrait(dir,"tabs-empty");
- assert(s.hit_count==1 && action_enabled(A_HOME) && !action_enabled(A_TAB));
+ 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 Back.
+ // 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.
@@ -1559,8 +1599,10 @@ int main(int argc, char **argv) {
habitat_touch(true,263,233,2000); habitat_touch(true,203,233,2300); habitat_touch(false,203,233,2450);
surface_tick(2700); scene_take();
habitat_touch(true,263,233,3000); habitat_touch(true,203,233,3300); habitat_touch(false,203,233,3450);
- surface_tick(3700); scene_take(); tap(4000,233,233); // Research. The normal switch receipt still applies.
- assert(tab_switches==1 && !strcmp(tab_target,"tab-3") && s.loading && s.view==MESSAGE);
+ 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);
@@ -2339,11 +2381,12 @@ int main(int argc, char **argv) {
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_literata_30.base) green=true;
assert(green);
- bool title=false, arrow=false; // the close pill and "TABS" on top; no ← at the bottom
+ 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"); }
- assert(title && !arrow);
- tap(3000,233,30); assert(s.view==HOME); // the cross goes back
+ 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));
+ tap(3000,233,420); assert(s.view==HOME);
}
// 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();