Run chat shell commands in a pseudo-terminal with typed input and resize
Commands start in a PTY (creack/pty; macOS and Linux) of the client's size with TERM=xterm-256color in their own session. chat_shell_input writes typed UTF-8 text in order through a bounded queue; chat_shell_resize sets the size. Output stays the raw terminal stream with byte offsets as sequence numbers, chat_shell_run_output resumes from an offset, and a plain-text rendering is persisted for Copy output and Send to agent. Input is never stored or logged.
This commit is contained in:
@@ -44,7 +44,7 @@ func testShellRunner(t *testing.T, ctx context.Context) (*chatShellRunner, *shel
|
||||
|
||||
func TestChatShellStopKillsAfterGrace(t *testing.T) {
|
||||
runner, frames := testShellRunner(t, context.Background())
|
||||
run, err := runner.Start(context.Background(), "ses_1", t.TempDir(), `trap "" INT; echo ready; while :; do sleep 0.05; done`)
|
||||
run, err := runner.Start(context.Background(), "ses_1", t.TempDir(), `trap "" INT; echo ready; while :; do sleep 0.05; done`, 0, 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -65,7 +65,7 @@ func TestChatShellStopKillsAfterGrace(t *testing.T) {
|
||||
func TestChatShellRetainsBoundedTail(t *testing.T) {
|
||||
runner, frames := testShellRunner(t, context.Background())
|
||||
total := protocol.ChatShellRunRetained + 200_000
|
||||
run, err := runner.Start(context.Background(), "ses_1", t.TempDir(), `head -c 1248576 /dev/zero | tr '\0' a; printf END`)
|
||||
run, err := runner.Start(context.Background(), "ses_1", t.TempDir(), `head -c 1248576 /dev/zero | tr '\0' a; printf END`, 0, 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -93,7 +93,7 @@ func TestChatShellRetainsBoundedTail(t *testing.T) {
|
||||
func TestChatShellShutdownAndRestartInterrupt(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
runner, frames := testShellRunner(t, ctx)
|
||||
run, err := runner.Start(context.Background(), "ses_1", t.TempDir(), "sleep 30")
|
||||
run, err := runner.Start(context.Background(), "ses_1", t.TempDir(), "sleep 30", 0, 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -102,7 +102,7 @@ func TestChatShellShutdownAndRestartInterrupt(t *testing.T) {
|
||||
if final := frames.final(run.ID); final == nil || final.Status != protocol.ChatShellRunInterrupted {
|
||||
t.Fatalf("shutdown final = %+v", final)
|
||||
}
|
||||
if _, err := runner.Start(context.Background(), "ses_1", t.TempDir(), "true"); err == nil {
|
||||
if _, err := runner.Start(context.Background(), "ses_1", t.TempDir(), "true", 0, 0); err == nil {
|
||||
t.Fatal("a stopping server started a command")
|
||||
}
|
||||
// A record a crashed process left running is interrupted on start.
|
||||
|
||||
Reference in New Issue
Block a user