Keep notification history on single lines with responsive navigation

This commit is contained in:
ak47 committed 2026-11-16 22:54:28 -05:00
1 parent 5dfa038706
commit 5fd5a26120
8 files changed
+394 -64

No files matched your search

+68
View File
@@ -0,0 +1,68 @@
# Notification list
Cthulhu+Ctrl+N opens notification history with the newest entry selected.
Each notification is one accessible cell: message followed by received time.
Line breaks and repeated whitespace are collapsed for display; Copy preserves
the original message and received time. Up/Down move one notification, and
Home/End move to the newest/oldest entry. Escape closes the list.
Previously every selection requested a daemon refresh and rebuilt the GTK
model, invalidating accessible cells and disturbing the keyboard cursor.
Navigation now retains the rows and updates only the selected entry's action
controls using the window's snapshot. Received times and action availability
refresh on reopening or a host response to an operation. The host still checks
live availability before invoking an action or dismissing a notification.
This does not add action support for other notification providers.
The local Orca notification presenter also populates its GTK model when opening
the dialog rather than rebuilding it on every selection. Cthulhu deliberately
uses one column instead of Orca's separate message and time columns.
## Automated checks
```sh
go test ./internal/notification ./internal/notificationui ./internal/app -run 'TestNotification|TestPresenter|TestMako' -count=1
go build -o /tmp/cthulhu-notification-test ./cmd/cthulhu
CTHULHU_BINARY=/tmp/cthulhu-notification-test python3 tests/native_notifications.py
```
The native harness uses private Xvfb and D-Bus. It checks all 55 history rows
in both directions, accessible cell identity, absence of navigation IPC,
multiline message rendering, Copy, Dismiss, Clear and action buttons. It also
records Cthulhu's speech requests and Braille frames during Up/Down/Home/End
navigation and checks Escape. It does not replace the desktop reader or prove
physical keyboard, audible speech or physical Braille behavior.
For GTK selection-update measurements, run in a private session:
```sh
python3 tests/native_test_session.py env CTHULHU_NATIVE_NOTIFICATIONS=1 go test ./internal/notificationui -run '^$' -bench '^BenchmarkNotificationSelection$' -benchmem -count=5
```
The benchmark uses a full 55-entry history and excludes daemon, pipe, event
delivery and speech latency. Before the fix, five 200ms runs measured
250–281 microseconds and 1,344 Go bytes per update. Afterward they measured
0.50–0.86 microseconds with zero Go allocations on the same Ryzen 7 3700X
using Go 1.27.4-X:nodwarf5 on Linux/amd64.
These measurements cover removal of repeated model construction, not audible
responsiveness. Baseline: testing commit 5dfa038 with the benchmark and
initialization extraction; comparison: the working-tree notification fix.
## Live acceptance
1. Quit Cthulhu with Cthulhu+Q.
2. Press Ctrl+Escape, then separately press Shift+G. This rebuilds and launches
Cthulhu through `~/devel/cthulhu-go.sh` and opens a test terminal.
3. Receive several notifications, including one containing multiple lines.
Open the list with Cthulhu+Ctrl+N. The newest notification should have focus.
4. Press Down several times, then Up. Each press should announce one complete
notification with its age; there should be no blank steps or separate
time-only stops. Braille should contain the same combined entry.
5. Try Home, End and repeated arrows. Focus should remain in the list and
navigation should remain responsive. Tab to Copy on an older entry and
activate it; paste into an editor to check the original message was copied.
6. Close with Escape. Confirm focus returns to the previous application and
its keyboard input still works. Reopen the list and check navigation again.
Report the precise spoken text, Braille content, focused control and key for
any unexpected step. Inspect `~/devel/cthulhu-go.log` if live results differ.
@@ -0,0 +1,106 @@
// Copyright (c) 2026 Storm Dragon
// Authors: Storm Dragon, Angus Kola
// SPDX-License-Identifier: GPL-3.0-or-later
package app
import (
"context"
"encoding/json"
"io"
"log/slog"
"os"
"os/exec"
"strings"
"testing"
"time"
"git.stormux.org/storm/cthulhu/internal/atspi"
"git.stormux.org/storm/cthulhu/internal/braille"
"git.stormux.org/storm/cthulhu/internal/notificationui"
)
func TestNativeNotificationListOutput(t *testing.T) {
if os.Getenv("CTHULHU_NATIVE_NOTIFICATIONS") != "1" {
t.Skip("requires private notification UI session")
}
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
defer cancel()
adapter := atspi.New()
if err := adapter.Start(ctx); err != nil {
t.Fatal(err)
}
defer adapter.Stop(context.Background())
queue := &autocompleteRequestQueue{requests: make(chan speechRequest, 256)}
frames := make(chan braille.Frame, 256)
done := make(chan struct{})
go func() {
defer close(done)
processEventsWithInput(ctx, slog.New(slog.DiscardHandler),
outputQueue{speech: queue, braille: frameRecorder{frames: frames}},
adapter, nil, nil, 0, nil, nil, nil, nil)
}()
defer func() { cancel(); <-done }()
command := exec.CommandContext(ctx, os.Getenv("CTHULHU_BINARY"), "--notification-list-ui")
in, err := command.StdinPipe()
if err != nil {
t.Fatal(err)
}
defer in.Close()
command.Stdout = io.Discard
command.Stderr = os.Stderr
if err := command.Start(); err != nil {
t.Fatal(err)
}
defer func() { _ = command.Process.Kill(); _ = command.Wait() }()
if err := json.NewEncoder(in).Encode(notificationui.Response{
Title: "Notification output test", Selected: "newest",
Entries: []notificationui.Entry{
{ID: "newest", Message: "Newest message", Received: "0 seconds ago"},
{ID: "middle", Message: "Middle\n\nmessage\tbody", Received: "1 minute ago"},
{ID: "oldest", Message: "Oldest message", Received: "2 minutes ago"},
},
}); err != nil {
t.Fatal(err)
}
wait := func(want string) {
t.Helper()
spoken, displayed := false, false
timer := time.NewTimer(4 * time.Second)
defer timer.Stop()
for !spoken || !displayed {
select {
case request := <-queue.requests:
t.Logf("speech: %q", request.Text)
spoken = spoken || strings.Contains(request.Text, want)
case frame := <-frames:
t.Logf("braille: %q", frame.Text)
displayed = displayed || strings.Contains(frame.Text, want)
case <-timer.C:
t.Fatalf("missing %q: speech=%v braille=%v", want, spoken, displayed)
case <-ctx.Done():
t.Fatal(ctx.Err())
}
}
}
wait("Newest message, 0 seconds ago")
for _, step := range []struct{ key, want string }{
{"Down", "Middle message body, 1 minute ago"},
{"Down", "Oldest message, 2 minutes ago"},
{"Up", "Middle message body, 1 minute ago"},
{"Home", "Newest message, 0 seconds ago"},
{"End", "Oldest message, 2 minutes ago"},
} {
if output, err := exec.CommandContext(ctx, "xdotool", "key", "--clearmodifiers", step.key).CombinedOutput(); err != nil {
t.Fatalf("%s: %v: %s", step.key, err, output)
}
wait(step.want)
}
if output, err := exec.CommandContext(ctx, "xdotool", "key", "--clearmodifiers", "Escape").CombinedOutput(); err != nil {
t.Fatalf("Escape: %v: %s", err, output)
}
if err := command.Wait(); err != nil {
t.Fatalf("closing notification list: %v", err)
}
}
+42 -21
View File
@@ -11,6 +11,7 @@ enum { ACTION_NONE, ACTION_COPY, ACTION_DISMISS, ACTION_CLEAR, ACTION_CLOSE,
static GtkWidget *dialog; static GtkWidget *dialog;
static GtkListStore *model; static GtkListStore *model;
static GtkWidget *tree;
static GtkTreeSelection *selection; static GtkTreeSelection *selection;
static GtkWidget *dismiss_button; static GtkWidget *dismiss_button;
static GtkWidget *actions_box; static GtkWidget *actions_box;
@@ -24,13 +25,25 @@ static void set_action(int code) {
if (!action_code) action_code = code; if (!action_code) action_code = code;
} }
static void dialog_destroyed(GtkWidget *widget, gpointer data) {
(void)widget;
(void)data;
dialog = NULL;
tree = NULL;
selection = NULL;
dismiss_button = NULL;
actions_box = NULL;
actions_status = NULL;
action_code = ACTION_CLOSE;
}
static void response(GtkDialog *widget, int response_id, gpointer data) { static void response(GtkDialog *widget, int response_id, gpointer data) {
(void)widget; (void)widget;
(void)data; (void)data;
if (response_id == ACTION_COPY) set_action(ACTION_COPY); if (response_id == ACTION_COPY) set_action(ACTION_COPY);
else if (response_id == ACTION_DISMISS) set_action(ACTION_DISMISS); else if (response_id == ACTION_DISMISS) set_action(ACTION_DISMISS);
else if (response_id == ACTION_CLEAR) set_action(ACTION_CLEAR); else if (response_id == ACTION_CLEAR) set_action(ACTION_CLEAR);
else if (response_id == ACTION_CLOSE) set_action(ACTION_CLOSE); else if (response_id == ACTION_CLOSE || response_id == GTK_RESPONSE_DELETE_EVENT) set_action(ACTION_CLOSE);
} }
static void selection_changed(GtkTreeSelection *widget, gpointer data) { static void selection_changed(GtkTreeSelection *widget, gpointer data) {
@@ -67,9 +80,10 @@ static void set_actions(char **keys, char **labels, int count) {
gtk_widget_show_all(actions_box); gtk_widget_show_all(actions_box);
} }
int notification_list_init(const char *title, const char *message_header, int notification_list_init(const char *title, const char *message_header) {
const char *received_header) {
if (!gtk_init_check(NULL, NULL)) return 0; if (!gtk_init_check(NULL, NULL)) return 0;
action_code = ACTION_NONE;
if (g_strcmp0(g_get_application_name(), "Cthulhu Notifications"))
g_set_application_name("Cthulhu Notifications"); g_set_application_name("Cthulhu Notifications");
dialog = gtk_dialog_new(); dialog = gtk_dialog_new();
gtk_window_set_title(GTK_WINDOW(dialog), title ? title : "Notifications"); gtk_window_set_title(GTK_WINDOW(dialog), title ? title : "Notifications");
@@ -81,6 +95,7 @@ int notification_list_init(const char *title, const char *message_header,
gtk_dialog_add_button(GTK_DIALOG(dialog), "Close", ACTION_CLOSE); gtk_dialog_add_button(GTK_DIALOG(dialog), "Close", ACTION_CLOSE);
gtk_dialog_set_default_response(GTK_DIALOG(dialog), ACTION_CLOSE); gtk_dialog_set_default_response(GTK_DIALOG(dialog), ACTION_CLOSE);
g_signal_connect(dialog, "response", G_CALLBACK(response), NULL); g_signal_connect(dialog, "response", G_CALLBACK(response), NULL);
g_signal_connect(dialog, "destroy", G_CALLBACK(dialog_destroyed), NULL);
GtkWidget *content = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); GtkWidget *content = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
GtkWidget *grid = gtk_grid_new(); GtkWidget *grid = gtk_grid_new();
@@ -91,20 +106,20 @@ int notification_list_init(const char *title, const char *message_header,
gtk_widget_set_vexpand(scrolled, TRUE); gtk_widget_set_vexpand(scrolled, TRUE);
gtk_container_add(GTK_CONTAINER(grid), scrolled); gtk_container_add(GTK_CONTAINER(grid), scrolled);
model = gtk_list_store_new(3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); model = gtk_list_store_new(4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
GtkWidget *tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model)); tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
gtk_widget_set_hexpand(tree, TRUE); gtk_widget_set_hexpand(tree, TRUE);
gtk_widget_set_vexpand(tree, TRUE); gtk_widget_set_vexpand(tree, TRUE);
AtkObject *tree_accessible = gtk_widget_get_accessible(tree); AtkObject *tree_accessible = gtk_widget_get_accessible(tree);
if (tree_accessible) atk_object_set_name(tree_accessible, title ? title : "Notifications"); if (tree_accessible) atk_object_set_name(tree_accessible, title ? title : "Notifications");
for (int column = 0; column < 2; column++) { // A single accessible cell contains both the message and received time.
const char *header = column == 0 ? message_header : received_header; // Keep history order fixed, with the newest notification first.
GtkCellRenderer *renderer = gtk_cell_renderer_text_new(); GtkCellRenderer *renderer = gtk_cell_renderer_text_new();
GtkTreeViewColumn *view = gtk_tree_view_column_new_with_attributes(header, renderer, g_object_set(renderer, "single-paragraph-mode", TRUE, NULL);
"text", column, NULL); GtkTreeViewColumn *view = gtk_tree_view_column_new_with_attributes(message_header,
if (header && header[0]) gtk_tree_view_column_set_sort_column_id(view, column); renderer, "text", 3, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(tree), view); gtk_tree_view_append_column(GTK_TREE_VIEW(tree), view);
} gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), FALSE);
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE); gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
g_signal_connect(selection, "changed", G_CALLBACK(selection_changed), NULL); g_signal_connect(selection, "changed", G_CALLBACK(selection_changed), NULL);
@@ -129,11 +144,9 @@ int notification_list_init(const char *title, const char *message_header,
return 1; return 1;
} }
void notification_list_set_entries(char **messages, char **received, int count, void notification_list_set_entries(char **lines, char **messages, char **received, int count,
char **ids, const char *selected, int can_control, char **ids, const char *selected) {
char **action_keys, char **action_labels, if (!dialog || !model) return;
int action_count) {
if (!model) return;
suppress_selection = 1; suppress_selection = 1;
gtk_list_store_clear(model); gtk_list_store_clear(model);
for (int index = 0; index < count; index++) { for (int index = 0; index < count; index++) {
@@ -141,7 +154,7 @@ void notification_list_set_entries(char **messages, char **received, int count,
gtk_list_store_append(model, &iterator); gtk_list_store_append(model, &iterator);
gtk_list_store_set(model, &iterator, 0, messages && messages[index] ? messages[index] : "", gtk_list_store_set(model, &iterator, 0, messages && messages[index] ? messages[index] : "",
1, received && received[index] ? received[index] : "", 1, received && received[index] ? received[index] : "",
2, ids && ids[index] ? ids[index] : "", -1); 2, ids && ids[index] ? ids[index] : "", 3, lines && lines[index] ? lines[index] : "", -1);
} }
GtkTreeIter iterator; GtkTreeIter iterator;
gboolean found = FALSE; gboolean found = FALSE;
@@ -153,13 +166,20 @@ void notification_list_set_entries(char **messages, char **received, int count,
g_free(value); g_free(value);
if (found) { if (found) {
GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(model), &iterator); GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(model), &iterator);
gtk_tree_selection_select_path(selection, path); gtk_tree_view_set_cursor(GTK_TREE_VIEW(tree), path, NULL, FALSE);
gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(tree), path, NULL, FALSE, 0, 0);
gtk_tree_path_free(path); gtk_tree_path_free(path);
break; break;
} }
} while (gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iterator)); } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iterator));
} }
if (!found) gtk_tree_selection_unselect_all(selection); if (!found) gtk_tree_selection_unselect_all(selection);
suppress_selection = 0;
}
void notification_list_set_actions(int can_control, char **action_keys,
char **action_labels, int action_count) {
if (!dialog) return;
gtk_widget_set_sensitive(dismiss_button, can_control != 0); gtk_widget_set_sensitive(dismiss_button, can_control != 0);
if (!can_control) { if (!can_control) {
clear_action_buttons(); clear_action_buttons();
@@ -174,13 +194,13 @@ void notification_list_set_entries(char **messages, char **received, int count,
gtk_label_set_text(GTK_LABEL(actions_status), ""); gtk_label_set_text(GTK_LABEL(actions_status), "");
gtk_widget_hide(actions_status); gtk_widget_hide(actions_status);
} }
suppress_selection = 0;
} }
void notification_list_show(void) { void notification_list_show(void) {
if (!dialog) return; if (!dialog) return;
gtk_widget_show_all(dialog); gtk_widget_show_all(dialog);
gtk_window_present(GTK_WINDOW(dialog)); gtk_window_present(GTK_WINDOW(dialog));
gtk_widget_grab_focus(tree);
} }
void notification_list_present(void) { void notification_list_present(void) {
@@ -248,10 +268,11 @@ int notification_list_copy(void) {
} }
void notification_list_close(void) { void notification_list_close(void) {
if (!dialog) return; if (dialog) gtk_widget_destroy(dialog);
gtk_widget_destroy(dialog);
dialog = NULL; dialog = NULL;
if (model) g_object_unref(model);
model = NULL; model = NULL;
tree = NULL;
selection = NULL; selection = NULL;
dismiss_button = NULL; dismiss_button = NULL;
actions_box = NULL; actions_box = NULL;
+5 -6
View File
@@ -1,12 +1,11 @@
#ifndef CTHULHU_NOTIFICATION_UI_NATIVE_H #ifndef CTHULHU_NOTIFICATION_UI_NATIVE_H
#define CTHULHU_NOTIFICATION_UI_NATIVE_H #define CTHULHU_NOTIFICATION_UI_NATIVE_H
int notification_list_init(const char *title, const char *message_header, int notification_list_init(const char *title, const char *message_header);
const char *received_header); void notification_list_set_entries(char **lines, char **messages, char **received, int count,
void notification_list_set_entries(char **messages, char **received, int count, char **ids, const char *selected);
char **ids, const char *selected, int can_control, void notification_list_set_actions(int can_control, char **action_keys,
char **action_keys, char **action_labels, char **action_labels, int action_count);
int action_count);
void notification_list_show(void); void notification_list_show(void);
void notification_list_present(void); void notification_list_present(void);
void notification_list_iterate(void); void notification_list_iterate(void);
+62 -26
View File
@@ -18,6 +18,7 @@ import (
"errors" "errors"
"io" "io"
"runtime" "runtime"
"strings"
"time" "time"
"unsafe" "unsafe"
) )
@@ -60,19 +61,12 @@ func Run(ctx context.Context, input io.Reader, output io.Writer) error {
case <-ctx.Done(): case <-ctx.Done():
return ctx.Err() return ctx.Err()
} }
title := C.CString(initial.Title) if err := initialize(initial); err != nil {
defer C.free(unsafe.Pointer(title)) return err
messageHeader := C.CString("Notifications")
defer C.free(unsafe.Pointer(messageHeader))
receivedHeader := C.CString("Received")
defer C.free(unsafe.Pointer(receivedHeader))
if C.notification_list_init(title, messageHeader, receivedHeader) == 0 {
return errors.New("cannot open the notification list on this display")
} }
defer C.notification_list_close() defer closeWindow()
apply(initial)
C.notification_list_show()
current := initial
encoder := json.NewEncoder(output) encoder := json.NewEncoder(output)
ticker := time.NewTicker(10 * time.Millisecond) ticker := time.NewTicker(10 * time.Millisecond)
defer ticker.Stop() defer ticker.Stop()
@@ -93,13 +87,14 @@ func Run(ctx context.Context, input io.Reader, output io.Writer) error {
C.notification_list_present() C.notification_list_present()
continue continue
} }
current = response
apply(response) apply(response)
case <-ticker.C: case <-ticker.C:
C.notification_list_iterate() C.notification_list_iterate()
switch C.notification_list_action() { switch C.notification_list_action() {
case 1: case 1:
if C.notification_list_copy() != 0 { if C.notification_list_copy() != 0 {
if err := encoder.Encode(Request{Copy: true}); err != nil { if err := encoder.Encode(Request{Copy: true, Selection: C.GoString(C.notification_list_selected_id())}); err != nil {
return err return err
} }
} }
@@ -117,10 +112,9 @@ func Run(ctx context.Context, input io.Reader, output io.Writer) error {
return nil return nil
case 5: case 5:
selection := C.GoString(C.notification_list_selected_id()) selection := C.GoString(C.notification_list_selected_id())
row := int(C.notification_list_selected_row()) // Navigation is local: keep the GTK rows and cursor intact and
if err := encoder.Encode(Request{Selection: selection, Row: &row}); err != nil { // avoid a daemon refresh and pipe round trip for every arrow.
return err updateSelection(current, selection)
}
case 6: case 6:
action := C.GoString(C.notification_list_selected_action()) action := C.GoString(C.notification_list_selected_action())
selection := C.GoString(C.notification_list_selected_id()) selection := C.GoString(C.notification_list_selected_id())
@@ -133,16 +127,48 @@ func Run(ctx context.Context, input io.Reader, output io.Writer) error {
} }
} }
func initialize(initial Response) error {
title := C.CString(initial.Title)
defer C.free(unsafe.Pointer(title))
messageHeader := C.CString("Notifications")
defer C.free(unsafe.Pointer(messageHeader))
if C.notification_list_init(title, messageHeader) == 0 {
return errors.New("cannot open the notification list on this display")
}
apply(initial)
C.notification_list_show()
return nil
}
func closeWindow() { C.notification_list_close() }
func updateSelection(response Response, selected string) {
var selectedEntry Entry
for _, entry := range response.Entries {
if entry.ID == selected {
selectedEntry = entry
break
}
}
applyActions(selectedEntry)
}
func apply(response Response) { func apply(response Response) {
lines := make([]*C.char, len(response.Entries))
messages := make([]*C.char, len(response.Entries)) messages := make([]*C.char, len(response.Entries))
received := make([]*C.char, len(response.Entries)) received := make([]*C.char, len(response.Entries))
identifiers := make([]*C.char, len(response.Entries)) identifiers := make([]*C.char, len(response.Entries))
for index, entry := range response.Entries { for index, entry := range response.Entries {
identifiers[index] = C.CString(entry.ID) identifiers[index] = C.CString(entry.ID)
lines[index] = C.CString(entryLine(entry))
messages[index] = C.CString(entry.Message) messages[index] = C.CString(entry.Message)
received[index] = C.CString(entry.Received) received[index] = C.CString(entry.Received)
} }
defer func() { defer func() {
for _, value := range lines {
C.free(unsafe.Pointer(value))
}
for _, value := range messages { for _, value := range messages {
C.free(unsafe.Pointer(value)) C.free(unsafe.Pointer(value))
} }
@@ -156,13 +182,26 @@ func apply(response Response) {
selectedID := C.CString(response.Selected) selectedID := C.CString(response.Selected)
defer C.free(unsafe.Pointer(selectedID)) defer C.free(unsafe.Pointer(selectedID))
var selectedEntry Entry C.notification_list_set_entries(
for _, entry := range response.Entries { cStringArray(lines), cStringArray(messages), cStringArray(received), C.int(len(response.Entries)),
if entry.ID == response.Selected { cStringArray(identifiers), selectedID,
selectedEntry = entry )
break updateSelection(response, response.Selected)
} }
func entryLine(entry Entry) string {
message := strings.Join(strings.Fields(entry.Message), " ")
received := strings.Join(strings.Fields(entry.Received), " ")
if message == "" {
return received
} }
if received == "" {
return message
}
return message + ", " + received
}
func applyActions(selectedEntry Entry) {
actionKeys := make([]*C.char, len(selectedEntry.Actions)) actionKeys := make([]*C.char, len(selectedEntry.Actions))
actionLabels := make([]*C.char, len(selectedEntry.Actions)) actionLabels := make([]*C.char, len(selectedEntry.Actions))
for index, action := range selectedEntry.Actions { for index, action := range selectedEntry.Actions {
@@ -178,11 +217,8 @@ func apply(response Response) {
} }
}() }()
C.notification_list_set_entries( C.notification_list_set_actions(cBoolean(selectedEntry.CanControl),
cStringArray(messages), cStringArray(received), C.int(len(response.Entries)), cStringArray(actionKeys), cStringArray(actionLabels), C.int(len(selectedEntry.Actions)))
cStringArray(identifiers), selectedID, cBoolean(selectedEntry.CanControl),
cStringArray(actionKeys), cStringArray(actionLabels), C.int(len(selectedEntry.Actions)),
)
} }
func cStringArray(values []*C.char) **C.char { func cStringArray(values []*C.char) **C.char {
+61
View File
@@ -0,0 +1,61 @@
// Copyright (c) 2026 Storm Dragon
// Authors: Storm Dragon, Angus Kola
// SPDX-License-Identifier: GPL-3.0-or-later
package notificationui
import (
"fmt"
"os"
"runtime"
"testing"
)
func TestNotificationSingleLine(t *testing.T) {
for _, test := range []struct{ text, want string }{
{"Mail\n\nNew message\r\nFrom a friend\t ", "Mail New message From a friend"},
{"Alpha\u2028Beta\u2029Gamma", "Alpha Beta Gamma"},
{"One notification", "One notification"},
{"", ""},
} {
if got := entryLine(Entry{Message: test.text}); got != test.want {
t.Errorf("entryLine(%q) = %q, want %q", test.text, got, test.want)
}
}
for _, entry := range []Entry{
{Message: "Mail", Received: "1 minute ago"},
{Message: "Mail\n", Received: "1\tminute ago"},
} {
if got := entryLine(entry); got != "Mail, 1 minute ago" {
t.Errorf("entryLine(%+v) = %q", entry, got)
}
}
if got := entryLine(Entry{Received: "1 minute ago"}); got != "1 minute ago" {
t.Errorf("time-only entry = %q", got)
}
}
// This measures GTK work for a full history, excluding daemon and pipe latency.
// Run only on a private display and accessibility bus.
func BenchmarkNotificationSelection(b *testing.B) {
if os.Getenv("CTHULHU_NATIVE_NOTIFICATIONS") != "1" {
b.Skip("requires private notification UI session")
}
runtime.LockOSThread()
defer runtime.UnlockOSThread()
response := Response{Title: "Notifications", Selected: "0"}
for index := range 55 {
response.Entries = append(response.Entries, Entry{
ID: fmt.Sprint(index), Message: fmt.Sprintf("Notification %d", index), Received: "1 minute ago",
})
}
if err := initialize(response); err != nil {
b.Fatal(err)
}
defer closeWindow()
b.ReportAllocs()
b.ResetTimer()
for index := 0; index < b.N; index++ {
updateSelection(response, response.Entries[index%len(response.Entries)].ID)
}
}
+1 -1
View File
@@ -47,7 +47,7 @@ preferences-basic-speech,src/cthulhu/cthulhu_gui_prefs.py,settings,Open accessib
review-component-geometry,src/cthulhu/flat_review.py,review,Capture component screen bounds and visibility for flat-review clipping,Storm Dragon,internal/atspi,implemented,DISPLAY=:0 go test ./internal/atspi -count=1; DISPLAY=:0 python3 tests/native_atspi.py,Private Xvfb D-Bus GtkBox tests verify screen bounds resize invalidation changed dimensions hide invalidation and recapture. Physical acceptance deferred by maintainer on 2026-09-14.,,,,Geometry queries run only during owned-tree capture. Bounds and visibility events invalidate geometry without removing identities. Negative coordinates overflow-safe clipping malformed geometry and concurrent invalidation have unit tests. Component bounds do not establish occlusion text ranges zones reading order or flat-review key support. review-component-geometry,src/cthulhu/flat_review.py,review,Capture component screen bounds and visibility for flat-review clipping,Storm Dragon,internal/atspi,implemented,DISPLAY=:0 go test ./internal/atspi -count=1; DISPLAY=:0 python3 tests/native_atspi.py,Private Xvfb D-Bus GtkBox tests verify screen bounds resize invalidation changed dimensions hide invalidation and recapture. Physical acceptance deferred by maintainer on 2026-09-14.,,,,Geometry queries run only during owned-tree capture. Bounds and visibility events invalidate geometry without removing identities. Negative coordinates overflow-safe clipping malformed geometry and concurrent invalidation have unit tests. Component bounds do not establish occlusion text ranges zones reading order or flat-review key support.
review-visible-text,src/cthulhu/flat_review.py,review,Capture bounded visible text with character offsets and screen clipping,Storm Dragon,internal/atspi,in-progress,DISPLAY=:0 go test -race ./internal/atspi ./internal/review ./internal/app ./internal/parity -count=1; DISPLAY=:0 python3 tests/native_atspi.py,Private ListBox and GtkBox capture edit clipping hidden-text and password-exclusion checks pass. Physical acceptance deferred.,,Maintainer reports current flat review working well after the previous day's fixes on 2026-10-22. This is general live-use acceptance rather than confirmation of every parity feature or historical fixture. See docs/testing/release-acceptance.md.,,Exact Unicode offsets and owned ranges include captured caret offsets. Text caret and geometry events invalidate cached text without retiring identities. Capture budgets are 65536 characters and 256 visible spans per object and 1 MiB per tree. Bounded line-rectangle discovery supports large objects without character rectangles; oversized lines use viewport glyph locations and bounded text spans. Zero-area glyphs no longer discard other visible text. Known unavailable objects and child subtrees leave healthy content reviewable with diagnostic omission counts and standard screen-boundary messages. Verified synthetic Text on controls uses accessible names or child content; tabs retain their label beside Close controls. Chromium address-value geometry remains unavailable. Root failures and aggregate layout budgets remain fatal. Private GTK fixtures and worker tests pass; physical speech and Braille acceptance remain pending. See docs/testing/flat-review-robustness.md. review-visible-text,src/cthulhu/flat_review.py,review,Capture bounded visible text with character offsets and screen clipping,Storm Dragon,internal/atspi,in-progress,DISPLAY=:0 go test -race ./internal/atspi ./internal/review ./internal/app ./internal/parity -count=1; DISPLAY=:0 python3 tests/native_atspi.py,Private ListBox and GtkBox capture edit clipping hidden-text and password-exclusion checks pass. Physical acceptance deferred.,,Maintainer reports current flat review working well after the previous day's fixes on 2026-10-22. This is general live-use acceptance rather than confirmation of every parity feature or historical fixture. See docs/testing/release-acceptance.md.,,Exact Unicode offsets and owned ranges include captured caret offsets. Text caret and geometry events invalidate cached text without retiring identities. Capture budgets are 65536 characters and 256 visible spans per object and 1 MiB per tree. Bounded line-rectangle discovery supports large objects without character rectangles; oversized lines use viewport glyph locations and bounded text spans. Zero-area glyphs no longer discard other visible text. Known unavailable objects and child subtrees leave healthy content reviewable with diagnostic omission counts and standard screen-boundary messages. Verified synthetic Text on controls uses accessible names or child content; tabs retain their label beside Close controls. Chromium address-value geometry remains unavailable. Root failures and aggregate layout budgets remain fatal. Private GTK fixtures and worker tests pass; physical speech and Braille acceptance remain pending. See docs/testing/flat-review-robustness.md.
date-time-commands,src/cthulhu/date_and_time_presenter.py,command,Speak local time with Cthulhu+T and date with a double tap using saved formats,Storm Dragon,internal/input internal/app internal/preferences internal/config,implemented,go test ./... -count=1; focused race checks; native keyboard double-tap checks,Private Xvfb press-time and both-release-order checks passed; physical Xorg pending,,Maintainer confirms date/time; spoken version; window-title; and clipboard-reading commands pass live testing on 2026-10-22. See docs/testing/release-acceptance.md.,Pending braille,All 7 Python time and 16 Python date format choices are wired including locale seconds word numeric full and abbreviated variants; see docs/testing/time-date.md. date-time-commands,src/cthulhu/date_and_time_presenter.py,command,Speak local time with Cthulhu+T and date with a double tap using saved formats,Storm Dragon,internal/input internal/app internal/preferences internal/config,implemented,go test ./... -count=1; focused race checks; native keyboard double-tap checks,Private Xvfb press-time and both-release-order checks passed; physical Xorg pending,,Maintainer confirms date/time; spoken version; window-title; and clipboard-reading commands pass live testing on 2026-10-22. See docs/testing/release-acceptance.md.,Pending braille,All 7 Python time and 16 Python date format choices are wired including locale seconds word numeric full and abbreviated variants; see docs/testing/time-date.md.
notifications,src/cthulhu/notification_presenter.py;src/cthulhu/scripts/apps/notification-daemon/script.py;src/cthulhu/scripts/apps/notify-osd/script.py;src/cthulhu/mako_notification_monitor.py,notification,Present provider notifications save history expose mako live actions speak the last notification and open the notification-list GUI,Storm Dragon,internal/notification internal/app internal/notificationui internal/atspi internal/input,implemented,NO_COLOR=1 GOCACHE=/tmp/cthulhu-build-cache go test ./... -count=1; NO_COLOR=1 python3 tests/native_notifications.py,,,Automated speech-queue history list-state and list-action assertions and private GUI checks pass. Maintainer confirms notification announcements and the notification list work in live testing on 2026-10-22. See docs/testing/release-acceptance.md.,Mako notification announcements implement Braille flashes through notificationAnnouncer.Announce. Provider-specific physical display acceptance was not separately stated.,Go registers window-create and accessible-name events maps notification-daemon mate and xfce4 providers handles notify-osd gauge and name events keeps a 55-entry history and adds Cthulhu+N plus Cthulhu+Ctrl+N. The modal accessible list opens in a GTK helper process with sortable rows copy dismiss clear close dynamic actions and mako live refresh. Parity review corrections and remaining physical gates: docs/testing/parity-review-follow-up.md. notifications,src/cthulhu/notification_presenter.py;src/cthulhu/scripts/apps/notification-daemon/script.py;src/cthulhu/scripts/apps/notify-osd/script.py;src/cthulhu/mako_notification_monitor.py,notification,Present provider notifications save history expose mako live actions speak the last notification and open the notification-list GUI,Storm Dragon,internal/notification internal/app internal/notificationui internal/atspi internal/input,implemented,NO_COLOR=1 GOCACHE=/tmp/cthulhu-build-cache go test ./... -count=1; NO_COLOR=1 python3 tests/native_notifications.py,,,Automated speech-queue history list-state and list-action assertions and private GUI checks pass. Maintainer confirms notification announcements and the notification list work in live testing on 2026-10-22. See docs/testing/release-acceptance.md.,Mako notification announcements implement Braille flashes through notificationAnnouncer.Announce. Provider-specific physical display acceptance was not separately stated.,Go registers window-create and accessible-name events maps notification-daemon mate and xfce4 providers handles notify-osd gauge and name events keeps a 55-entry history and adds Cthulhu+N plus Cthulhu+Ctrl+N. The modal accessible list opens in a GTK helper process with one combined message-and-time cell per notification in newest-first order. Arrow navigation updates local action controls without rebuilding rows or refreshing mako. Copy retains original text; dismiss clear close and dynamic actions remain available. Single-line navigation has private AT-SPI speech and Braille-output checks; live acceptance of this change remains pending. See docs/testing/notifications.md. Parity review corrections and remaining physical gates: docs/testing/parity-review-follow-up.md.
ordinary-key-speech-interrupt,src/cthulhu/input_event.py,input,Interrupt speech on an ordinary key press even if focus does not move,,internal/input internal/app,implemented,go test ./internal/input ./internal/app -run TestProcessInputEventsInterruptsSpeechOnKeyPress -count=1,,,,,Python KeyboardEvent._present interrupts on press outside game mode. Go interrupts on every observed press by default; Speech preferences can restrict interruption to common or recorded keys. Physical FastSMRW table-boundary listening remains pending. ordinary-key-speech-interrupt,src/cthulhu/input_event.py,input,Interrupt speech on an ordinary key press even if focus does not move,,internal/input internal/app,implemented,go test ./internal/input ./internal/app -run TestProcessInputEventsInterruptsSpeechOnKeyPress -count=1,,,,,Python KeyboardEvent._present interrupts on press outside game mode. Go interrupts on every observed press by default; Speech preferences can restrict interruption to common or recorded keys. Physical FastSMRW table-boundary listening remains pending.
table-cell-selection-speech,src/cthulhu/speech_generator.py; src/cthulhu/scripts/default.py,speech,Omit selected from table-cell focus speech and avoid deselection chatter during movement,,internal/presentation internal/app,implemented,go test ./internal/presentation ./internal/app -count=1,,,,,Selected table-cell focus omits the state; a focused selected-state event can still announce selected. Physical FastSMRW listening remains pending. table-cell-selection-speech,src/cthulhu/speech_generator.py; src/cthulhu/scripts/default.py,speech,Omit selected from table-cell focus speech and avoid deselection chatter during movement,,internal/presentation internal/app,implemented,go test ./internal/presentation ./internal/app -count=1,,,,,Selected table-cell focus omits the state; a focused selected-state event can still announce selected. Physical FastSMRW listening remains pending.
braille-focused-text-routing,src/cthulhu/braille.py,braille,Route display cells to the native focused text caret,,internal/braille internal/app internal/atspi,in-progress,go test -race -tags brlapi ./internal/braille ./internal/app ./internal/atspi -count=1; python3 tests/native_atspi.py,Private GTK/Xvfb routes Unicode and EOL carets and rejects stale content and old focus. Physical Xorg pending.,,,Physical cursor routing untested: the maintainer's Orbit has no routing keys. General reading and panning pass on Orbit as confirmed on 2026-10-22; BRLTTY ownership recovery remains unverified. See docs/testing/release-acceptance.md.,Frame IDs and panned Unicode offsets return through the helper; the GLib owner revalidates focus and source text. Component actions and mouse fallback; virtual browser carets; contracted and review routing remain pending. See docs/testing/braille.md. braille-focused-text-routing,src/cthulhu/braille.py,braille,Route display cells to the native focused text caret,,internal/braille internal/app internal/atspi,in-progress,go test -race -tags brlapi ./internal/braille ./internal/app ./internal/atspi -count=1; python3 tests/native_atspi.py,Private GTK/Xvfb routes Unicode and EOL carets and rejects stale content and old focus. Physical Xorg pending.,,,Physical cursor routing untested: the maintainer's Orbit has no routing keys. General reading and panning pass on Orbit as confirmed on 2026-10-22; BRLTTY ownership recovery remains unverified. See docs/testing/release-acceptance.md.,Frame IDs and panned Unicode offsets return through the helper; the GLib owner revalidates focus and source text. Component actions and mouse fallback; virtual browser carets; contracted and review routing remain pending. See docs/testing/braille.md.
1 id python_source subsystem behavior owner go_destination status automated_evidence x11_evidence wayland_evidence speech_evidence braille_evidence notes
47 review-component-geometry src/cthulhu/flat_review.py review Capture component screen bounds and visibility for flat-review clipping Storm Dragon internal/atspi implemented DISPLAY=:0 go test ./internal/atspi -count=1; DISPLAY=:0 python3 tests/native_atspi.py Private Xvfb D-Bus GtkBox tests verify screen bounds resize invalidation changed dimensions hide invalidation and recapture. Physical acceptance deferred by maintainer on 2026-09-14. Geometry queries run only during owned-tree capture. Bounds and visibility events invalidate geometry without removing identities. Negative coordinates overflow-safe clipping malformed geometry and concurrent invalidation have unit tests. Component bounds do not establish occlusion text ranges zones reading order or flat-review key support.
48 review-visible-text src/cthulhu/flat_review.py review Capture bounded visible text with character offsets and screen clipping Storm Dragon internal/atspi in-progress DISPLAY=:0 go test -race ./internal/atspi ./internal/review ./internal/app ./internal/parity -count=1; DISPLAY=:0 python3 tests/native_atspi.py Private ListBox and GtkBox capture edit clipping hidden-text and password-exclusion checks pass. Physical acceptance deferred. Maintainer reports current flat review working well after the previous day's fixes on 2026-10-22. This is general live-use acceptance rather than confirmation of every parity feature or historical fixture. See docs/testing/release-acceptance.md. Exact Unicode offsets and owned ranges include captured caret offsets. Text caret and geometry events invalidate cached text without retiring identities. Capture budgets are 65536 characters and 256 visible spans per object and 1 MiB per tree. Bounded line-rectangle discovery supports large objects without character rectangles; oversized lines use viewport glyph locations and bounded text spans. Zero-area glyphs no longer discard other visible text. Known unavailable objects and child subtrees leave healthy content reviewable with diagnostic omission counts and standard screen-boundary messages. Verified synthetic Text on controls uses accessible names or child content; tabs retain their label beside Close controls. Chromium address-value geometry remains unavailable. Root failures and aggregate layout budgets remain fatal. Private GTK fixtures and worker tests pass; physical speech and Braille acceptance remain pending. See docs/testing/flat-review-robustness.md.
49 date-time-commands src/cthulhu/date_and_time_presenter.py command Speak local time with Cthulhu+T and date with a double tap using saved formats Storm Dragon internal/input internal/app internal/preferences internal/config implemented go test ./... -count=1; focused race checks; native keyboard double-tap checks Private Xvfb press-time and both-release-order checks passed; physical Xorg pending Maintainer confirms date/time; spoken version; window-title; and clipboard-reading commands pass live testing on 2026-10-22. See docs/testing/release-acceptance.md. Pending braille All 7 Python time and 16 Python date format choices are wired including locale seconds word numeric full and abbreviated variants; see docs/testing/time-date.md.
50 notifications src/cthulhu/notification_presenter.py;src/cthulhu/scripts/apps/notification-daemon/script.py;src/cthulhu/scripts/apps/notify-osd/script.py;src/cthulhu/mako_notification_monitor.py notification Present provider notifications save history expose mako live actions speak the last notification and open the notification-list GUI Storm Dragon internal/notification internal/app internal/notificationui internal/atspi internal/input implemented NO_COLOR=1 GOCACHE=/tmp/cthulhu-build-cache go test ./... -count=1; NO_COLOR=1 python3 tests/native_notifications.py Automated speech-queue history list-state and list-action assertions and private GUI checks pass. Maintainer confirms notification announcements and the notification list work in live testing on 2026-10-22. See docs/testing/release-acceptance.md. Mako notification announcements implement Braille flashes through notificationAnnouncer.Announce. Provider-specific physical display acceptance was not separately stated. Go registers window-create and accessible-name events maps notification-daemon mate and xfce4 providers handles notify-osd gauge and name events keeps a 55-entry history and adds Cthulhu+N plus Cthulhu+Ctrl+N. The modal accessible list opens in a GTK helper process with sortable rows copy dismiss clear close dynamic actions and mako live refresh. Parity review corrections and remaining physical gates: docs/testing/parity-review-follow-up.md. Go registers window-create and accessible-name events maps notification-daemon mate and xfce4 providers handles notify-osd gauge and name events keeps a 55-entry history and adds Cthulhu+N plus Cthulhu+Ctrl+N. The modal accessible list opens in a GTK helper process with one combined message-and-time cell per notification in newest-first order. Arrow navigation updates local action controls without rebuilding rows or refreshing mako. Copy retains original text; dismiss clear close and dynamic actions remain available. Single-line navigation has private AT-SPI speech and Braille-output checks; live acceptance of this change remains pending. See docs/testing/notifications.md. Parity review corrections and remaining physical gates: docs/testing/parity-review-follow-up.md.
51 ordinary-key-speech-interrupt src/cthulhu/input_event.py input Interrupt speech on an ordinary key press even if focus does not move internal/input internal/app implemented go test ./internal/input ./internal/app -run TestProcessInputEventsInterruptsSpeechOnKeyPress -count=1 Python KeyboardEvent._present interrupts on press outside game mode. Go interrupts on every observed press by default; Speech preferences can restrict interruption to common or recorded keys. Physical FastSMRW table-boundary listening remains pending.
52 table-cell-selection-speech src/cthulhu/speech_generator.py; src/cthulhu/scripts/default.py speech Omit selected from table-cell focus speech and avoid deselection chatter during movement internal/presentation internal/app implemented go test ./internal/presentation ./internal/app -count=1 Selected table-cell focus omits the state; a focused selected-state event can still announce selected. Physical FastSMRW listening remains pending.
53 braille-focused-text-routing src/cthulhu/braille.py braille Route display cells to the native focused text caret internal/braille internal/app internal/atspi in-progress go test -race -tags brlapi ./internal/braille ./internal/app ./internal/atspi -count=1; python3 tests/native_atspi.py Private GTK/Xvfb routes Unicode and EOL carets and rejects stale content and old focus. Physical Xorg pending. Physical cursor routing untested: the maintainer's Orbit has no routing keys. General reading and panning pass on Orbit as confirmed on 2026-10-22; BRLTTY ownership recovery remains unverified. See docs/testing/release-acceptance.md. Frame IDs and panned Unicode offsets return through the helper; the GLib owner revalidates focus and source text. Component actions and mouse fallback; virtual browser carets; contracted and review routing remain pending. See docs/testing/braille.md.
+49 -10
View File
@@ -14,6 +14,10 @@ from native_test_session import run_private_session
def inside(): def inside():
import pyatspi import pyatspi
import gi
gi.require_version("Gtk", "3.0")
gi.require_version("Gdk", "3.0")
from gi.repository import Gdk, Gtk
binary = os.environ.get("CTHULHU_BINARY", str(Path(__file__).resolve().parents[1] / "cthulhu")) binary = os.environ.get("CTHULHU_BINARY", str(Path(__file__).resolve().parents[1] / "cthulhu"))
process = subprocess.Popen( process = subprocess.Popen(
@@ -64,7 +68,7 @@ def inside():
{"key": "default", "label": "View"}, {"key": "default", "label": "View"},
{"key": "reply", "label": "Reply"}, {"key": "reply", "label": "Reply"},
]), ]),
entry("0", "Older message", "1 minute ago"), entry("0", "Older\n\nmessage\t", "1 minute ago"),
], ],
} }
try: try:
@@ -79,7 +83,10 @@ def inside():
table = next(node for node in nodes if node.getRole() == pyatspi.ROLE_TABLE) table = next(node for node in nodes if node.getRole() == pyatspi.ROLE_TABLE)
assert table.name == "2 notifications", table.name assert table.name == "2 notifications", table.name
names = {node.name for node in nodes} names = {node.name for node in nodes}
for name in ("Live message", "Older message", "0 seconds ago", "1 minute ago", assert table.queryTable().nColumns == 1, "notification split into multiple cells"
assert table.queryTable().nRows == 2
original_cells = [table.queryTable().getAccessibleAt(row, 0) for row in range(2)]
for name in ("Live message, 0 seconds ago", "Older message, 1 minute ago",
"Copy", "Dismiss Notification", "Clear", "Close", "View", "Reply"): "Copy", "Dismiss Notification", "Clear", "Close", "View", "Reply"):
assert name in names, ("missing accessible name", name) assert name in names, ("missing accessible name", name)
interactive_roles = { interactive_roles = {
@@ -97,9 +104,9 @@ def inside():
subprocess.run(["xdotool", "windowfocus", xid], check=True) subprocess.run(["xdotool", "windowfocus", xid], check=True)
assert table.queryComponent().grabFocus(), "cannot focus notification table" assert table.queryComponent().grabFocus(), "cannot focus notification table"
subprocess.run(["xdotool", "key", "--clearmodifiers", "Down"], check=True) subprocess.run(["xdotool", "key", "--clearmodifiers", "Down"], check=True)
selected = request() wait_for(lambda: table.querySelection().getSelectedChild(0).name ==
assert selected == {"selection": "0", "row": 1}, selected "Older message, 1 minute ago", "Down did not move exactly one notification")
send(dict(initial, selected="0")) assert not select.select([process.stdout], [], [], 0.1)[0], "navigation requested a host refresh"
wait_for(lambda: "Notification is no longer available" in { wait_for(lambda: "Notification is no longer available" in {
node.name for node in walk(window) node.name for node in walk(window)
@@ -108,9 +115,11 @@ def inside():
assert "View" not in {node.name for node in walk(window)} assert "View" not in {node.name for node in walk(window)}
assert "Reply" not in {node.name for node in walk(window)} assert "Reply" not in {node.name for node in walk(window)}
send(dict(initial, selected="1")) subprocess.run(["xdotool", "key", "--clearmodifiers", "Up"], check=True)
wait_for(lambda: controls["Dismiss Notification"].getState().contains(pyatspi.STATE_SENSITIVE), wait_for(lambda: controls["Dismiss Notification"].getState().contains(pyatspi.STATE_SENSITIVE),
"live selection did not restore controls") "live selection did not restore controls")
assert original_cells == [table.queryTable().getAccessibleAt(row, 0) for row in range(2)], \
"arrow navigation replaced accessible rows"
refresh_controls() refresh_controls()
press(controls["Reply"]) press(controls["Reply"])
invoked = request() invoked = request()
@@ -120,22 +129,47 @@ def inside():
press(controls["Copy"]) press(controls["Copy"])
copied = request() copied = request()
assert copied == {"copy": True}, copied assert copied == {"copy": True, "selection": "1"}, copied
press(controls["Dismiss Notification"]) press(controls["Dismiss Notification"])
dismissed = request() dismissed = request()
assert dismissed == {"dismiss": True, "selection": "1", "row": 0}, dismissed assert dismissed == {"dismiss": True, "selection": "1", "row": 0}, dismissed
send({"title": "1 notification", "selected": "0", send({"title": "1 notification", "selected": "0",
"entries": [entry("0", "Older message", "1 minute ago")]}) "entries": [entry("0", "Older\n\nmessage\t", "1 minute ago")]})
refresh_controls() refresh_controls()
# Fill the history and navigate every row in both directions. No blank
# stops, detached cells, or IPC requests should result from navigation.
history = [entry(str(index), f"Message {index}\nbody", "1 minute ago")
for index in range(55)]
send({"title": "55 notifications", "selected": "0", "entries": history})
wait_for(lambda: table.queryTable().nRows == 55, "full history missing")
assert table.queryComponent().grabFocus()
cells = [table.queryTable().getAccessibleAt(row, 0) for row in range(55)]
for key, rows in (("Down", range(1, 55)), ("Up", range(53, -1, -1))):
for row in rows:
subprocess.run(["xdotool", "key", "--clearmodifiers", key], check=True)
expected = f"Message {row} body, 1 minute ago"
wait_for(lambda: table.querySelection().getSelectedChild(0).name == expected,
f"{key} failed to select {expected}")
assert cells == [table.queryTable().getAccessibleAt(row, 0) for row in range(55)], \
"history navigation replaced accessible rows"
assert not select.select([process.stdout], [], [], 0.1)[0], "history navigation used IPC"
subprocess.run(["xdotool", "key", "--clearmodifiers", "End"], check=True)
wait_for(lambda: table.querySelection().getSelectedChild(0).name ==
"Message 54 body, 1 minute ago", "End did not select the oldest notification")
refresh_controls()
press(controls["Copy"])
assert request() == {"copy": True, "selection": "54"}, "copy lost the selected row"
clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD).wait_for_text()
assert clipboard == "Message 54\nbody\t1 minute ago", ("copy changed original text", clipboard)
press(controls["Clear"]) press(controls["Clear"])
cleared = request() cleared = request()
assert cleared == {"clear": True}, cleared assert cleared == {"clear": True}, cleared
send({"close": True}) send({"close": True})
assert process.wait(timeout=5) == 0 assert process.wait(timeout=5) == 0
assert process.stdout.read() == "", "clear submitted extra requests" assert process.stdout.read() == "", "clear submitted extra requests"
print("PASS: notification list accessibility, selection refresh, actions, copy, dismiss, clear") print("PASS: single-line notifications, stable full-history navigation, actions, original clipboard text, dismiss, clear")
finally: finally:
if process.poll() is None: if process.poll() is None:
process.kill() process.kill()
@@ -145,6 +179,11 @@ def inside():
def main(): def main():
if "--inside" in sys.argv: if "--inside" in sys.argv:
inside() inside()
environment = dict(os.environ, CTHULHU_NATIVE_NOTIFICATIONS="1")
environment.setdefault("CTHULHU_BINARY", str(Path(__file__).resolve().parents[1] / "cthulhu"))
subprocess.run(["go", "test", "./internal/app", "-run", "^TestNativeNotificationListOutput$",
"-count=1", "-v"], cwd=Path(__file__).resolve().parents[1],
env=environment, check=True)
return return
read_fd, write_fd = os.pipe() read_fd, write_fd = os.pipe()
server = subprocess.Popen( server = subprocess.Popen(
@@ -158,7 +197,7 @@ def main():
assert display, "Xvfb failed" assert display, "Xvfb failed"
environment = dict( environment = dict(
os.environ, DISPLAY=":" + display, GDK_BACKEND="x11", os.environ, DISPLAY=":" + display, GDK_BACKEND="x11",
GTK_MODULES="gail:atk-bridge", GIO_USE_VFS="local", GTK_MODULES="gail:atk-bridge", GIO_USE_VFS="local", G_DEBUG="fatal-criticals",
) )
for key in ("DBUS_SESSION_BUS_ADDRESS", "AT_SPI_BUS_ADDRESS", "WAYLAND_DISPLAY"): for key in ("DBUS_SESSION_BUS_ADDRESS", "AT_SPI_BUS_ADDRESS", "WAYLAND_DISPLAY"):
environment.pop(key, None) environment.pop(key, None)