Share verified reading context announcements with Remote

This commit is contained in:
ak47 committed 2026-11-05 20:39:19 -05:00
1 parent 8631c5a601
commit 9ac33560dc
7 files changed
+287 -20

No files matched your search

@@ -23,6 +23,7 @@ import (
"time"
"git.stormux.org/storm/cthulhu/internal/atspi"
"git.stormux.org/storm/cthulhu/internal/config"
"git.stormux.org/storm/cthulhu/internal/input"
"git.stormux.org/storm/cthulhu/internal/interaction"
"git.stormux.org/storm/cthulhu/internal/review"
@@ -353,6 +354,7 @@ func TestRemoteConnectionCommandPrivateRelay(t *testing.T) {
worker := runtime.output.speech
worker.speaker = &observationSpeaker{fakeSpeaker{spoken: make(chan string, 64)}}
worker.textTransform = func(text string) string { return strings.ReplaceAll(text, "colour", "color") }
worker.reading = func() config.ReadingSettings { return runtime.output.live.Load().Reading }
if err := worker.Start(t.Context()); err != nil {
t.Fatal(err)
}
@@ -600,6 +602,19 @@ func TestRemoteConnectionCommandPrivateRelay(t *testing.T) {
t.Fatal(err)
}
}
list := atspi.Snapshot{BusName: ":1.42", Path: "/relay-list", Role: "list", Name: "Relay items"}
privateList := list
privateList.Path, privateList.Name = "/private-list", "Private relay label"
for _, request := range []speechRequest{
{origin: speechOriginLocal, Text: "Relay inside", Context: []atspi.Snapshot{list}},
{origin: speechOriginLocal, Text: "Relay outside", Context: []atspi.Snapshot{}},
{origin: speechOriginSecret, Text: "Private relay content", Context: []atspi.Snapshot{privateList}},
{origin: speechOriginLocal, Text: "Relay resumed", Context: []atspi.Snapshot{}},
} {
if err := worker.EnqueueAndWait(t.Context(), request); err != nil {
t.Fatal(err)
}
}
worker.InterruptForUser()
var received strings.Builder
ends, frames := 0, 0
@@ -635,7 +650,7 @@ func TestRemoteConnectionCommandPrivateRelay(t *testing.T) {
t.Fatal("reader output did not reach the relay in order")
}
}
if received.String() != "color "+remoteText+"First color.Second color.Current color.Native color.Review color.staticFlat color. Review color.Review color.staticNative color.text" || frames < 13 || ends != 12 {
if received.String() != "color "+remoteText+"First color.Second color.Current color.Native color.Review color.staticFlat color. Review color.Review color.staticNative color.textRelay items listRelay insideLeaving Relay items list.Relay outsideRelay resumed" || frames < 18 || ends != 17 {
t.Fatalf("observation leaked private text or lost resolved output/boundaries: frames=%d ends=%d suffix=%q", frames, ends, received.String()[max(0, received.Len()-160):])
}
}