mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 10:05:14 +00:00
Add terminal title support to TUI framework (#407)
Add setTitle() method to Terminal interface for setting window title. Uses standard OSC escape sequence \x1b]0;...\x07 for broad terminal compatibility (macOS Terminal, iTerm2, Kitty, WezTerm, Ghostty, etc.). Changes: - Add setTitle(title: string) to Terminal interface - Implement in ProcessTerminal using OSC sequence - Implement no-op in VirtualTerminal for testing - Use in interactive mode to set title as "pi - <dirname>"
This commit is contained in:
parent
fd35d9188c
commit
5c3c8e6f7e
3 changed files with 17 additions and 0 deletions
|
|
@ -303,6 +303,10 @@ export class InteractiveMode {
|
|||
this.ui.start();
|
||||
this.isInitialized = true;
|
||||
|
||||
// Set terminal title
|
||||
const cwdBasename = path.basename(process.cwd());
|
||||
this.ui.terminal.setTitle(`pi - ${cwdBasename}`);
|
||||
|
||||
// Initialize hooks with TUI-based UI context
|
||||
await this.initHooksAndCustomTools();
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,9 @@ export interface Terminal {
|
|||
clearLine(): void; // Clear current line
|
||||
clearFromCursor(): void; // Clear from cursor to end of screen
|
||||
clearScreen(): void; // Clear entire screen and move cursor to (0,0)
|
||||
|
||||
// Title operations
|
||||
setTitle(title: string): void; // Set terminal window title
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -127,4 +130,9 @@ export class ProcessTerminal implements Terminal {
|
|||
clearScreen(): void {
|
||||
process.stdout.write("\x1b[2J\x1b[H"); // Clear screen and move to home (1,1)
|
||||
}
|
||||
|
||||
setTitle(title: string): void {
|
||||
// OSC 0;title BEL - set terminal window title
|
||||
process.stdout.write(`\x1b]0;${title}\x07`);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,6 +86,11 @@ export class VirtualTerminal implements Terminal {
|
|||
this.xterm.write("\x1b[2J\x1b[H"); // Clear screen and move to home (1,1)
|
||||
}
|
||||
|
||||
setTitle(title: string): void {
|
||||
// OSC 0;title BEL - set terminal window title
|
||||
this.xterm.write(`\x1b]0;${title}\x07`);
|
||||
}
|
||||
|
||||
// Test-specific methods not in Terminal interface
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue