This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch tymux-10-quiet-head
in repository terminology.

View the commit online.

commit 7cf1a49edfb8643d74f68d94020eda30e5e6cf0d
Author: Boris Faure <[email protected]>
AuthorDate: Sun Nov 15 17:25:07 2026 +0000

    termpty: notify program status summary changes
    
    The summary of the records — the most urgent state, with its progress
    — is pushed, not polled: termpty grows a program_status callback beside
    bell and progress, fired only when the summary moves, and termio
    relays it as a "program,status" smart callback. Dropping the transient
    records moves the summary too, and notifies the same way, so a
    listener never holds a stale one. A drop can only lower the summary,
    so it can not raise an attention path on its own.
    
    The new record is allocated before the oldest one is evicted, so a
    failed allocation leaves the store, and the summary, untouched.
    
    Nothing listens yet; the tab title does in the next commit.
---
 src/bin/termio.c        |  11 ++++
 src/bin/termpty.h       |   2 +-
 src/bin/termptystatus.c | 134 +++++++++++++++++++++++++++++++++++++++++++++---
 src/bin/tytest.c        |   1 +
 src/bin/unit_tests.h    |   1 +
 5 files changed, 141 insertions(+), 8 deletions(-)

diff --git a/src/bin/termio.c b/src/bin/termio.c
index 72beafba..2bf8f3cb 100644
--- a/src/bin/termio.c
+++ b/src/bin/termio.c
@@ -4069,6 +4069,15 @@ _smart_pty_bell(void *data)
      edje_object_signal_emit(sd->cursor.obj, "bell,ring", "terminology");
 }
 
+static void
+_smart_pty_program_status(void *data)
+{
+   Termio *sd = evas_object_smart_data_get(data);
+
+   EINA_SAFETY_ON_NULL_RETURN(sd);
+   evas_object_smart_callback_call(data, "program,status", NULL);
+}
+
 /* The OSC 9;4 progress indicator went stale: the program stopped
  * reporting or died, so forget the state, which hides the bar. */
 static Eina_Bool
@@ -4719,6 +4728,8 @@ termio_add(Evas_Object *win, Config *config,
    sd->pty->cb.command.data = ""
    sd->pty->cb.progress.func = _smart_pty_progress;
    sd->pty->cb.progress.data = ""
+   sd->pty->cb.program_status.func = _smart_pty_program_status;
+   sd->pty->cb.program_status.data = ""
    _smart_size(obj, w, h, EINA_TRUE);
    return obj;
 }
diff --git a/src/bin/termpty.h b/src/bin/termpty.h
index f4629f5c..fc917134 100644
--- a/src/bin/termpty.h
+++ b/src/bin/termpty.h
@@ -190,7 +190,7 @@ struct tag_Termpty
          void (*func) (void *data);
          void *data;
       } change, set_title, set_icon, cancel_sel, exited, bell, command,
-        progress;
+        progress, program_status;
    } cb;
    struct {
       Ecore_Timer *watchdog;
diff --git a/src/bin/termptystatus.c b/src/bin/termptystatus.c
index a5341f9d..5a2c6eb3 100644
--- a/src/bin/termptystatus.c
+++ b/src/bin/termptystatus.c
@@ -39,6 +39,9 @@ struct ps_staging
    const char *msg;
 };
 
+static void _ps_summary_notify(Termpty *ty, Termpty_Program_State prev_state,
+                               int prev_progress);
+
 static void
 _ps_record_free(Termpty_Program_Record *rec)
 {
@@ -469,6 +472,8 @@ termpty_program_status_handle(Termpty *ty, const Eina_Unicode *body)
    signed char progress = -1;
    char *title = NULL, *msg = NULL;
    Termpty_Program_Record *rec;
+   Termpty_Program_State prev_state = TERMPTY_PROGRAM_STATE_NONE;
+   int prev_progress = -1;
 
    if (!body || !*body)
      return;
@@ -550,6 +555,8 @@ termpty_program_status_handle(Termpty *ty, const Eina_Unicode *body)
    if (staging.app && !_ps_app_ok(staging.app))
      staging.app = NULL;
 
+   termpty_program_status_summary_get(ty, &prev_state, &prev_progress);
+
    ty->program_status_seen = EINA_TRUE;
 
    if (is_clear)
@@ -570,6 +577,7 @@ termpty_program_status_handle(Termpty *ty, const Eina_Unicode *body)
                   _ps_record_free(rec);
                }
           }
+        _ps_summary_notify(ty, prev_state, prev_progress);
         return;
      }
 
@@ -587,6 +595,13 @@ termpty_program_status_handle(Termpty *ty, const Eina_Unicode *body)
      }
    else
      {
+        rec = calloc(1, sizeof(*rec));
+        if (!rec)
+          {
+             free(title);
+             free(msg);
+             return;
+          }
         if (ty->program_records_count >= PS_RECORDS_MAX)
           {
              /* the least recently updated record is the head of the list */
@@ -597,13 +612,6 @@ termpty_program_status_handle(Termpty *ty, const Eina_Unicode *body)
              ty->program_records_count--;
              _ps_record_free(old);
           }
-        rec = calloc(1, sizeof(*rec));
-        if (!rec)
-          {
-             free(title);
-             free(msg);
-             return;
-          }
         ty->program_records_count++;
      }
 
@@ -616,6 +624,22 @@ termpty_program_status_handle(Termpty *ty, const Eina_Unicode *body)
    rec->msg = msg;
    ty->program_records = eina_inlist_append(ty->program_records,
                                             EINA_INLIST_GET(rec));
+
+   _ps_summary_notify(ty, prev_state, prev_progress);
+}
+
+static void
+_ps_summary_notify(Termpty *ty, Termpty_Program_State prev_state,
+                   int prev_progress)
+{
+   Termpty_Program_State state = TERMPTY_PROGRAM_STATE_NONE;
+   int progress = -1;
+
+   termpty_program_status_summary_get(ty, &state, &progress);
+   if ((state == prev_state) && (progress == prev_progress))
+     return;
+   if (ty->cb.program_status.func)
+     ty->cb.program_status.func(ty->cb.program_status.data);
 }
 
 void
@@ -668,6 +692,10 @@ void
 termpty_program_status_drop_transient(Termpty *ty)
 {
    Eina_Inlist *l = ty->program_records;
+   Termpty_Program_State prev_state = TERMPTY_PROGRAM_STATE_NONE;
+   int prev_progress = -1;
+
+   termpty_program_status_summary_get(ty, &prev_state, &prev_progress);
 
    while (l)
      {
@@ -684,6 +712,9 @@ termpty_program_status_drop_transient(Termpty *ty)
           }
         l = next;
      }
+
+   /* the drop is a summary change, and notifies like a report does */
+   _ps_summary_notify(ty, prev_state, prev_progress);
 }
 
 #if defined(BINARY_TYTEST)
@@ -887,4 +918,93 @@ tytest_program_status_parse(void)
 
    return 0;
 }
+
+static int _ty_ps_summary_cb_count;
+
+static void
+_ty_ps_summary_cb(void *data EINA_UNUSED)
+{
+   _ty_ps_summary_cb_count++;
+}
+
+int
+tytest_program_status_summary(void)
+{
+   Termpty ty;
+   Termpty_Program_State state = TERMPTY_PROGRAM_STATE_NONE;
+   int progress = -2;
+
+   memset(&ty, 0, sizeof(ty));
+   _ty_ps_summary_cb_count = 0;
+
+   /* no record at all */
+   termpty_program_status_summary_get(&ty, &state, &progress);
+   assert(state == TERMPTY_PROGRAM_STATE_NONE);
+   assert(progress == -1);
+
+   /* the most urgent state wins, and carries its own progress */
+   _ty_ps_feed(&ty, "id=w:state=working:progress=40");
+   _ty_ps_feed(&ty, "id=i:state=idle");
+   termpty_program_status_summary_get(&ty, &state, &progress);
+   assert(state == TERMPTY_PROGRAM_STATE_WORKING);
+   assert(progress == 40);
+   _ty_ps_feed(&ty, "id=d:state=done");
+   termpty_program_status_summary_get(&ty, &state, &progress);
+   assert(state == TERMPTY_PROGRAM_STATE_DONE);
+   assert(progress == -1);
+   _ty_ps_feed(&ty, "id=e:state=error");
+   termpty_program_status_summary_get(&ty, &state, &progress);
+   assert(state == TERMPTY_PROGRAM_STATE_ERROR);
+   _ty_ps_feed(&ty, "id=b:state=blocked:progress=60");
+   termpty_program_status_summary_get(&ty, &state, &progress);
+   assert(state == TERMPTY_PROGRAM_STATE_BLOCKED);
+   assert(progress == 60);
+
+   /* ties go to the most recently updated record */
+   termpty_program_status_clear_all(&ty);
+   _ty_ps_feed(&ty, "id=w1:state=working:progress=30");
+   _ty_ps_feed(&ty, "id=w2:state=working:progress=70");
+   termpty_program_status_summary_get(&ty, &state, &progress);
+   assert(state == TERMPTY_PROGRAM_STATE_WORKING);
+   assert(progress == 70);
+   _ty_ps_feed(&ty, "id=w1:state=working:progress=30");
+   termpty_program_status_summary_get(&ty, &state, &progress);
+   assert(progress == 30);
+
+   /* the callback fires on every summary change, and only then */
+   ty.cb.program_status.func = _ty_ps_summary_cb;
+   /* a report with no state is discarded before the summary is read */
+   _ty_ps_feed(&ty, "id=x");
+   assert(_ty_ps_summary_cb_count == 0);
+   /* a record below the summary changes nothing */
+   _ty_ps_feed(&ty, "id=i:state=idle");
+   assert(_ty_ps_summary_cb_count == 0);
+   /* the same values again on the winning record */
+   _ty_ps_feed(&ty, "id=w1:state=working:progress=30");
+   assert(_ty_ps_summary_cb_count == 0);
+   /* a progress change on the winning record is a change */
+   _ty_ps_feed(&ty, "id=w1:state=working:progress=31");
+   assert(_ty_ps_summary_cb_count == 1);
+   /* so is a more urgent state */
+   _ty_ps_feed(&ty, "id=e:state=error");
+   assert(_ty_ps_summary_cb_count == 2);
+   /* and a clear report */
+   _ty_ps_feed(&ty, "state=clear");
+   assert(_ty_ps_summary_cb_count == 3);
+   /* clear_all is a full reset, not a report: it does not notify */
+   termpty_program_status_clear_all(&ty);
+   assert(_ty_ps_summary_cb_count == 3);
+
+   /* the transient drop is a summary change too: the pushed summary
+    * must not linger after a prompt start or a child exit */
+   _ty_ps_feed(&ty, "id=w:state=working");
+   assert(_ty_ps_summary_cb_count == 4);
+   termpty_program_status_drop_transient(&ty);
+   assert(_ty_ps_summary_cb_count == 5);
+   /* nothing left to drop: the summary did not move */
+   termpty_program_status_drop_transient(&ty);
+   assert(_ty_ps_summary_cb_count == 5);
+
+   return 0;
+}
 #endif
diff --git a/src/bin/tytest.c b/src/bin/tytest.c
index 56ed485d..d6c10de4 100644
--- a/src/bin/tytest.c
+++ b/src/bin/tytest.c
@@ -84,6 +84,7 @@ static struct {
        { "osc9_progress", tytest_osc9_progress},
        { "osc9_progress_cb", tytest_osc9_progress_cb},
        { "program_status_parse", tytest_program_status_parse},
+       { "program_status_summary", tytest_program_status_summary},
        { "program_status_exit", tytest_program_status_exit},
        { "notify_meta_parse", tytest_notify_meta_parse},
        { "notify_pending_cap", tytest_notify_pending_cap},
diff --git a/src/bin/unit_tests.h b/src/bin/unit_tests.h
index 3a3237ca..e81948a7 100644
--- a/src/bin/unit_tests.h
+++ b/src/bin/unit_tests.h
@@ -57,6 +57,7 @@ int tytest_osc9_notify(void);
 int tytest_osc9_progress(void);
 int tytest_osc9_progress_cb(void);
 int tytest_program_status_parse(void);
+int tytest_program_status_summary(void);
 int tytest_program_status_exit(void);
 int tytest_notify_meta_parse(void);
 int tytest_notify_pending_cap(void);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to