Open merge dialog instantly from pushed merge facts

This commit is contained in:
Ian Gulliver
2026-10-21 11:48:21 -07:00
parent 4bb6f1fa11
commit 890fb6b691
15 changed files with 736 additions and 678 deletions
+13 -10
View File
@@ -57,19 +57,21 @@ fi
`
type Terminals struct {
zdotdir string
changed func(taskID string)
zdotdir string
changed func(taskID string)
prompted func(taskID string)
mu sync.Mutex
byTask map[string][]*Terminal
}
type Terminal struct {
ID string
Name string
ptmx *os.File
cmd *exec.Cmd
Prompts bool
ID string
Name string
ptmx *os.File
cmd *exec.Cmd
Prompts bool
prompted func()
mu sync.Mutex
backlog []byte
@@ -89,7 +91,7 @@ type wake struct {
out []byte
}
func New(zdotdir string, changed func(taskID string)) (*Terminals, error) {
func New(zdotdir string, changed, prompted func(taskID string)) (*Terminals, error) {
err := os.MkdirAll(zdotdir, 0o755)
if err != nil {
return nil, err
@@ -98,7 +100,7 @@ func New(zdotdir string, changed func(taskID string)) (*Terminals, error) {
if err != nil {
return nil, err
}
return &Terminals{zdotdir: zdotdir, changed: changed, byTask: map[string][]*Terminal{}}, nil
return &Terminals{zdotdir: zdotdir, changed: changed, prompted: prompted, byTask: map[string][]*Terminal{}}, nil
}
func (ts *Terminals) List(taskID string) []*Terminal {
@@ -159,7 +161,7 @@ func (ts *Terminals) start(t api.Task, name string, size api.TerminalSize) (*Ter
return nil, fmt.Errorf("start %s: %w", shell, err)
}
term := &Terminal{ID: ids.New(ids.Terminal), Name: name, ptmx: ptmx, cmd: cmd, Prompts: prompts, clients: map[chan []byte]bool{}, started: time.Now()}
term := &Terminal{ID: ids.New(ids.Terminal), Name: name, ptmx: ptmx, cmd: cmd, Prompts: prompts, prompted: func() { ts.prompted(t.Id) }, clients: map[chan []byte]bool{}, started: time.Now()}
ts.byTask[t.Id] = append(ts.byTask[t.Id], term)
slog.Info("terminal started", "task", t.Id, "terminal", term.ID, "name", name, "shell", shell, "pid", cmd.Process.Pid)
go func() {
@@ -338,6 +340,7 @@ func (term *Terminal) trackLine(b []byte) {
switch {
case string(prefix) == promptMark:
term.atPrompt, term.line = true, ""
go term.prompted()
case body == "E":
term.atPrompt, term.line = false, ""
case strings.HasPrefix(body, "L"):