Files
DeepSeek-Reasonix/internal/platform/terminal/pty_windows.go
T
yhh 83bdeb81f0 feat(studio): the workbench gets a terminal of your own, as the Terminal board draws it
A fourth kind of tab opens a real shell (ConPTY on Windows, a pty elsewhere) in
the project folder, outside the model's permissions and sandbox and with the
host's provider keys left out of its environment. The kernel keeps each shell's
output, so a tab left or a window reloaded comes back as it was; a tab is named
for the command submitted while the shell is busy and carries a blue dot, and
closing a busy one asks first.

Also: the composer's note stack no longer clips to a few pixels when it holds
two notes, which left the second one overlapping the input.
2026-11-06 04:44:41 -08:00

56 lines
1.3 KiB
Go

//go:build windows
package terminal
import (
"context"
"strings"
"sync"
"syscall"
"github.com/UserExistsError/conpty"
)
type winPty struct {
c *conpty.ConPty
once sync.Once
}
func startPty(o Options) (pty, error) {
parts := make([]string, 0, len(o.Args)+1)
parts = append(parts, syscall.EscapeArg(o.Shell))
for _, a := range o.Args {
parts = append(parts, syscall.EscapeArg(a))
}
opts := []conpty.ConPtyOption{conpty.ConPtyDimensions(int(o.Cols), int(o.Rows))}
if o.Dir != "" {
opts = append(opts, conpty.ConPtyWorkDir(o.Dir))
}
if len(o.Env) > 0 {
opts = append(opts, conpty.ConPtyEnv(o.Env))
}
c, err := conpty.Start(strings.Join(parts, " "), opts...)
if err != nil {
return nil, fail(CodeStartFailed, "%v", err)
}
return &winPty{c: c}, nil
}
func (p *winPty) Read(b []byte) (int, error) { return p.c.Read(b) }
func (p *winPty) Write(b []byte) (int, error) { return p.c.Write(b) }
func (p *winPty) Close() error {
var err error
p.once.Do(func() { err = p.c.Close() })
return err
}
func (p *winPty) Resize(cols, rows uint16) error {
return p.c.Resize(int(cols), int(rows))
}
func (p *winPty) Wait() (int, error) {
code, err := p.c.Wait(context.Background())
return int(code), err
}
// Kill ends the shell by closing its console, which takes its children with it.
func (p *winPty) Kill() error { return p.Close() }