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 4ae2eb41dccca01ca9f7a3ff4e1e2ae7aec5a00c
Author: Boris Faure <[email protected]>
AuthorDate: Sat Oct 31 21:15:45 2026 +0000
termptyesc: show OSC 9 notifications
Parse iTerm2's desktop notification, OSC 9 ; <message> ST
(https://iterm2.com/documentation-escape-codes.html): the whole payload
is the summary, there is no title/body split and nothing is answered.
It goes through the same path as OSC 777 and OSC 99, behind
notification_escapes.
ConEmu numbers its other OSC 9 extensions (sleep, message box, tab
title, wait for input, cwd, ...): a payload starting with decimal
digits followed by ';' or by the end is one of them, never a
notification. All of them are dropped, so a malformed or future
progress report such as "4;tests failed" cannot pop up as a desktop
notification.
tests/xterm-osc-9.sh covers notifications, the guard and the lookalike
text; tytest_osc9_notify does the same from the unit tests.
---
src/bin/termpty.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++
src/bin/termptyesc.c | 29 +++++++++++++++++++++++++++
src/bin/tytest.c | 1 +
src/bin/unit_tests.h | 1 +
tests/tests.results | 1 +
tests/xterm-osc-9.sh | 26 ++++++++++++++++++++++++
6 files changed, 114 insertions(+)
diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index 4c62af27..e0404f47 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -2901,6 +2901,62 @@ tytest_notify_query_gated(void)
_ty_test_shutdown(&ty);
return 0;
}
+
+/* iTerm2 notifications through OSC 9; ConEmu sequences, malformed
+ * progress reports and a gated option never reach the recorder. */
+int
+tytest_osc9_notify(void)
+{
+ Termpty ty;
+
+ _ty_test_init(&ty, 80, 24);
+
+ tytest_notifications_clear();
+ /* the whole payload is the summary, semicolons included */
+ _ty_feed(&ty, "\x1b]9;Build finished\x07");
+ _ty_feed(&ty, "\x1b]9;done; 3 warnings\x1b\\");
+ assert(strstr(tytest_notifications_get(), "title=Build finished"));
+ assert(strstr(tytest_notifications_get(), "title=done; 3 warnings"));
+
+ /* ConEmu sequences are never notifications */
+ tytest_notifications_clear();
+ _ty_feed(&ty, "\x1b]9;5\x07");
+ _ty_feed(&ty, "\x1b]9;1;100\x07");
+ _ty_feed(&ty, "\x1b]9;9;/tmp\x1b\\");
+ _ty_feed(&ty, "\x1b]9;42\x1b\\");
+ assert(tytest_notifications_get() == NULL ||
+ tytest_notifications_get()[0] == '\0');
+
+ /* malformed progress is not a notification either */
+ _ty_feed(&ty, "\x1b]9;4\x07");
+ _ty_feed(&ty, "\x1b]9;4;\x07");
+ _ty_feed(&ty, "\x1b]9;4;5\x07");
+ _ty_feed(&ty, "\x1b]9;4;tests failed\x07");
+ assert(tytest_notifications_get() == NULL ||
+ tytest_notifications_get()[0] == '\0');
+
+ /* text that only looks numeric is text */
+ tytest_notifications_clear();
+ _ty_feed(&ty, "\x1b]9;4x\x07");
+ _ty_feed(&ty, "\x1b]9;12 done\x07");
+ assert(strstr(tytest_notifications_get(), "title=4x"));
+ assert(strstr(tytest_notifications_get(), "title=12 done"));
+
+ /* empty payload: nothing */
+ tytest_notifications_clear();
+ _ty_feed(&ty, "\x1b]9;\x07");
+ assert(tytest_notifications_get() == NULL ||
+ tytest_notifications_get()[0] == '\0');
+
+ /* gated off: nothing */
+ ty.config->notification_escapes = EINA_FALSE;
+ _ty_feed(&ty, "\x1b]9;hidden\x07");
+ assert(tytest_notifications_get() == NULL ||
+ tytest_notifications_get()[0] == '\0');
+
+ _ty_test_shutdown(&ty);
+ return 0;
+}
#endif
/* DECRQSS: an unsupported request is answered "invalid", DECSCL keeps its
diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index 1c5f5e89..124d3b81 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -5417,6 +5417,24 @@ _handle_osc_palette_reset(Termpty *ty, Eina_Unicode *p)
termio_palette_apply(ty->obj);
}
+/* ConEmu numbers its OSC 9 extensions; a payload starting with decimal
+ * digits followed by ';' or by the end is one of them, never notification
+ * text. */
+static void
+_handle_osc_9(Termpty *ty, const char *s, int len)
+{
+ int digits = 0;
+
+ while ((digits < len) && (s[digits] >= '0') && (s[digits] <= '9'))
+ digits++;
+ if ((digits > 0) && ((digits == len) || (s[digits] == ';')))
+ {
+ DBG("ignoring ConEmu OSC 9;%.*s", digits, s);
+ return;
+ }
+ termpty_notify_show(ty, s, NULL, -1, -1, -1);
+}
+
static int
_handle_esc_osc(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
{
@@ -5573,6 +5591,17 @@ _handle_esc_osc(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
free(s);
}
break;
+ case 9:
+ DBG("iTerm2 notification or ConEmu sequence");
+ if (!p)
+ goto err;
+ s = eina_unicode_unicode_to_utf8(p, &len);
+ if (s)
+ {
+ _handle_osc_9(ty, s, len);
+ free(s);
+ }
+ break;
case 10:
DBG("Set foreground color");
_handle_xterm_10_command(ty, p, payload_len - (p - buf), bel);
diff --git a/src/bin/tytest.c b/src/bin/tytest.c
index d1509ec3..d00a6ef6 100644
--- a/src/bin/tytest.c
+++ b/src/bin/tytest.c
@@ -78,6 +78,7 @@ static struct {
{ "xtgettcap", tytest_xtgettcap},
{ "tcap_table_sorted", tytest_tcap_table_sorted},
{ "notify_gated", tytest_notify_gated},
+ { "osc9_notify", tytest_osc9_notify},
{ "notify_meta_parse", tytest_notify_meta_parse},
{ "notify_pending_cap", tytest_notify_pending_cap},
{ "notify_query_gated", tytest_notify_query_gated},
diff --git a/src/bin/unit_tests.h b/src/bin/unit_tests.h
index 045b03ee..9a2b6f2e 100644
--- a/src/bin/unit_tests.h
+++ b/src/bin/unit_tests.h
@@ -52,6 +52,7 @@ int tytest_xmodkeys_reset(void);
int tytest_xtgettcap(void);
int tytest_tcap_table_sorted(void);
int tytest_notify_gated(void);
+int tytest_osc9_notify(void);
int tytest_notify_meta_parse(void);
int tytest_notify_pending_cap(void);
int tytest_notify_query_gated(void);
diff --git a/tests/tests.results b/tests/tests.results
index 25a6f345..af8aad72 100644
--- a/tests/tests.results
+++ b/tests/tests.results
@@ -229,3 +229,4 @@ rect-last-column.sh b9ebef7c23ee278b65d7ea16371cdd27
decslrm-two-columns.sh 2bc3f2840cc2e18a5e68b3d9e053a5f2
decstbm-one-row.sh 1657d126de08379e16ac0e7ec5693309
irm-runs.sh d3a480e2a58939db077a06b95712371a
+xterm-osc-9.sh 09d136a6b7f579c0d23e95f406f65bf4
diff --git a/tests/xterm-osc-9.sh b/tests/xterm-osc-9.sh
new file mode 100755
index 00000000..c461daec
--- /dev/null
+++ b/tests/xterm-osc-9.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+# fill space with E
+printf '\033#8'
+
+# iTerm2 notification: the whole payload is the summary
+printf '\033]9;Build finished\007'
+# semicolons inside the text are kept, no title/body split
+printf '\033]9;done; 3 warnings\033\\'
+# what opentui sends to iTerm2
+printf '\033]9;OpenCode: Session done\033\\'
+# ConEmu sequences are never notifications
+printf '\033]9;5\007'
+printf '\033]9;1;100\007'
+printf '\033]9;9;/tmp\033\\'
+printf '\033]9;42\033\\'
+# malformed progress: not a notification either
+printf '\033]9;4\007'
+printf '\033]9;4;\007'
+printf '\033]9;4;5\007'
+printf '\033]9;4;tests failed\007'
+# text that only looks numeric is text
+printf '\033]9;4x\007'
+printf '\033]9;12 done\007'
+# empty: nothing
+printf '\033]9;\007'
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.