Agent review pass.

This commit is contained in:
hjozwiak committed 2026-11-24 11:12:17 -05:00
1 parent e9b2e9508b
commit 64ee749a8e
105 files changed
+2098 -320

No files matched your search

+16
View File
@@ -42,6 +42,19 @@ type VirtualResponse struct {
// panning and routing maps, so remote cells match local behaviour apart from
// the explicit uncontracted table and static cursor. It exits on EOF.
func RunVirtual(ctx context.Context, input io.Reader, output io.Writer) error {
// A blocked Scan cannot observe ctx; closing a closable input (the
// helper's stdin) on cancellation unblocks it, as RunClient does.
if closer, ok := input.(io.Closer); ok {
done := make(chan struct{})
defer close(done)
go func() {
select {
case <-ctx.Done():
_ = closer.Close()
case <-done:
}
}()
}
scanner := bufio.NewScanner(input)
scanner.Buffer(make([]byte, 4096), 65536)
encoder := json.NewEncoder(output)
@@ -115,5 +128,8 @@ func RunVirtual(ctx context.Context, input io.Reader, output io.Writer) error {
return err
}
}
if ctx.Err() != nil {
return nil
}
return scanner.Err()
}
+29
View File
@@ -0,0 +1,29 @@
// Copyright (c) 2026 Storm Dragon
// Authors: Storm Dragon, Angus Kola
// SPDX-License-Identifier: GPL-3.0-or-later
package braille
import (
"context"
"io"
"testing"
"time"
)
func TestRunVirtualCancelUnblocksIdleInput(t *testing.T) {
reader, writer := io.Pipe()
defer writer.Close()
ctx, cancel := context.WithCancel(context.Background())
done := make(chan error, 1)
go func() { done <- RunVirtual(ctx, reader, io.Discard) }()
cancel()
select {
case err := <-done:
if err != nil {
t.Fatalf("cancelled RunVirtual: %v", err)
}
case <-time.After(5 * time.Second):
t.Fatal("RunVirtual did not return after cancellation on blocked input")
}
}