Harden touch device recovery and input lifecycle

This commit is contained in:
Storm Dragon committed 2026-11-24 19:17:26 -05:00
1 parent e4ba4d9882
commit 03066b2abe
16 files changed
+323 -66

No files matched your search

+5
View File
@@ -35,6 +35,8 @@ func Run(ctx context.Context, path, command string) error {
return err
}
defer conn.Close()
stop := context.AfterFunc(ctx, func() { conn.Close() })
defer stop()
deadline := time.Now().Add(timeout)
if d, ok := ctx.Deadline(); ok && d.Before(deadline) {
deadline = d
@@ -59,6 +61,9 @@ func Run(ctx context.Context, path, command string) error {
if err := json.Unmarshal(body, &replies); err != nil {
return fmt.Errorf("i3 reply: %w", err)
}
if len(replies) == 0 {
return errors.New("empty i3 command reply")
}
for _, reply := range replies {
if !reply.Success {
return fmt.Errorf("i3 %q: %s", command, reply.Error)
+7
View File
@@ -65,3 +65,10 @@ func TestBehaviorRunReportsI3Failure(t *testing.T) {
t.Fatal("a missing socket must return an error")
}
}
func TestEmptyReplyIsNotSuccess(t *testing.T) {
path, _ := fakeI3(t, `[]`)
if err := Run(t.Context(), path, "workspace next"); err == nil {
t.Fatal("empty reply accepted")
}
}