Skip to content

Setting terminal title and bell notification#122

Merged
alexec merged 4 commits into
mainfrom
copilot/set-terminal-title-and-bell
Jun 21, 2026
Merged

Setting terminal title and bell notification#122
alexec merged 4 commits into
mainfrom
copilot/set-terminal-title-and-bell

Conversation

Copilot AI commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Pull request created by AI Agent

@alexec alexec marked this pull request as ready for review June 21, 2026 16:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds terminal UX enhancements to RunSubgraph by updating the terminal window title to reflect workflow state and ringing the terminal bell on key transitions (ready/done/failure).

Changes:

  • Introduces terminal helper functions to set the terminal title, ring the bell, and compute a workflow status title.
  • Wires terminal title updates and bell notifications into RunSubgraph lifecycle events.
  • Adds unit tests covering title sanitization, workflow title formatting, and RunSubgraph terminal updates; promotes golang.org/x/term to a direct dependency.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
internal/terminal.go Adds terminal title/bell helpers and workflow title computation.
internal/terminal_test.go Adds tests for terminal title sanitization and workflow title formatting.
internal/run.go Updates RunSubgraph to set terminal title during execution and ring bell on completion/ready/failure.
internal/run_test.go Adds integration-style tests asserting terminal title/bell behavior during runs.
go.mod Adds golang.org/x/term as a direct dependency.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/terminal.go
Comment on lines +3 to +10
import (
"fmt"
"io"
"os"
"strings"

"golang.org/x/term"
)
Comment thread internal/terminal.go
Comment on lines +12 to +17
var terminalWriter io.Writer = os.Stdout

var isTerminalWriter = func(w io.Writer) bool {
file, ok := w.(*os.File)
return ok && term.IsTerminal(int(file.Fd()))
}
Comment thread internal/terminal.go
Comment on lines +19 to +25
func setTerminalTitle(title string) {
if terminalWriter == nil || !isTerminalWriter(terminalWriter) {
return
}
title = strings.NewReplacer("\a", "", "\x1b", "", "\r", " ", "\n", " ").Replace(title)
_, _ = fmt.Fprintf(terminalWriter, "\033]0;%s\033\\", title)
}
Comment thread internal/terminal.go
Comment on lines +27 to +33
func ringTerminalBell() {
if terminalWriter == nil || !isTerminalWriter(terminalWriter) {
return
}
_, _ = io.WriteString(terminalWriter, "\a")
}

Comment thread internal/terminal.go
Comment on lines +43 to +51
switch node.Phase {
case "failed":
failures = append(failures, node.Name)
case "running", "stalled":
running++
complete++
case "succeeded", "skipped":
complete++
}
Comment thread internal/terminal_test.go
Comment thread internal/terminal_test.go
Comment on lines +29 to +31
title := workflowTitle("kit", map[string]*TaskNode{
"api": {Name: "api", Phase: "running"},
})
@alexec

alexec commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator

@copilot please add a mutex to guard the title.

Copilot AI commented Jun 21, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please add a mutex to guard the title.

Added a package-level sync.Mutex (terminalMu) that guards both setTerminalTitle and ringTerminalBell, so concurrent goroutines can't interleave escape sequences. Also promoted the strings.Replacer to a package-level variable to avoid allocating it on every call. Commit: Add mutex to guard terminal title and bell writes.

Copilot AI requested a review from alexec June 21, 2026 16:46
@alexec

alexec commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator

@copilot did you address all the review comments ? Please do so.

Copilot AI commented Jun 21, 2026

Copy link
Copy Markdown
Contributor Author

@copilot did you address all the review comments ? Please do so.

The remaining review comments are now addressed:

  • workflowTitle service/job semantics: Only services (tasks with ports or probes) are counted as complete when running/stalled; jobs must reach succeeded/skipped to count as complete. This matches blocked() in task_node.go.
  • Tests: Added the types import; the "ready" test now uses a service task (Ports: types.Ports{{ContainerPort: 8080}}), and a new "starting when job running" subtest confirms a running job is not counted as complete.

Commit: Fix workflowTitle service/job semantics and update tests

@alexec alexec enabled auto-merge (squash) June 21, 2026 20:30
@alexec alexec merged commit 20b7c41 into main Jun 21, 2026
2 checks passed
@alexec alexec deleted the copilot/set-terminal-title-and-bell branch June 21, 2026 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants