Setting terminal title and bell notification#122
Conversation
There was a problem hiding this comment.
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
RunSubgraphlifecycle events. - Adds unit tests covering title sanitization, workflow title formatting, and RunSubgraph terminal updates; promotes
golang.org/x/termto 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.
| import ( | ||
| "fmt" | ||
| "io" | ||
| "os" | ||
| "strings" | ||
|
|
||
| "golang.org/x/term" | ||
| ) |
| 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())) | ||
| } |
| 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) | ||
| } |
| func ringTerminalBell() { | ||
| if terminalWriter == nil || !isTerminalWriter(terminalWriter) { | ||
| return | ||
| } | ||
| _, _ = io.WriteString(terminalWriter, "\a") | ||
| } | ||
|
|
| switch node.Phase { | ||
| case "failed": | ||
| failures = append(failures, node.Name) | ||
| case "running", "stalled": | ||
| running++ | ||
| complete++ | ||
| case "succeeded", "skipped": | ||
| complete++ | ||
| } |
| title := workflowTitle("kit", map[string]*TaskNode{ | ||
| "api": {Name: "api", Phase: "running"}, | ||
| }) |
|
@copilot please add a mutex to guard the title. |
Added a package-level |
|
@copilot did you address all the review comments ? Please do so. |
The remaining review comments are now addressed:
Commit: |
Pull request created by AI Agent