mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 18:01:22 +00:00
feat(coding-agent): add Ctrl+Z to suspend process (#267)
* feat(tui): add isCtrlZ key detection and resetRenderState method * feat(coding-agent): add Ctrl+Z handler to suspend process * docs(coding-agent): add Ctrl+Z to keyboard shortcuts documentation * feat(tui): add force parameter to requestRender
This commit is contained in:
parent
55ca650a40
commit
8868d623fc
7 changed files with 48 additions and 1 deletions
|
|
@ -6,6 +6,7 @@ import {
|
|||
isCtrlO,
|
||||
isCtrlP,
|
||||
isCtrlT,
|
||||
isCtrlZ,
|
||||
isEscape,
|
||||
isShiftTab,
|
||||
} from "@mariozechner/pi-tui";
|
||||
|
|
@ -22,6 +23,7 @@ export class CustomEditor extends Editor {
|
|||
public onCtrlO?: () => void;
|
||||
public onCtrlT?: () => void;
|
||||
public onCtrlG?: () => void;
|
||||
public onCtrlZ?: () => void;
|
||||
|
||||
handleInput(data: string): void {
|
||||
// Intercept Ctrl+G for external editor
|
||||
|
|
@ -30,6 +32,12 @@ export class CustomEditor extends Editor {
|
|||
return;
|
||||
}
|
||||
|
||||
// Intercept Ctrl+Z for suspend
|
||||
if (isCtrlZ(data) && this.onCtrlZ) {
|
||||
this.onCtrlZ();
|
||||
return;
|
||||
}
|
||||
|
||||
// Intercept Ctrl+T for thinking block visibility toggle
|
||||
if (isCtrlT(data) && this.onCtrlT) {
|
||||
this.onCtrlT();
|
||||
|
|
|
|||
|
|
@ -213,6 +213,9 @@ export class InteractiveMode {
|
|||
theme.fg("dim", "ctrl+d") +
|
||||
theme.fg("muted", " to exit (empty)") +
|
||||
"\n" +
|
||||
theme.fg("dim", "ctrl+z") +
|
||||
theme.fg("muted", " to suspend") +
|
||||
"\n" +
|
||||
theme.fg("dim", "ctrl+k") +
|
||||
theme.fg("muted", " to delete line") +
|
||||
"\n" +
|
||||
|
|
@ -576,6 +579,7 @@ export class InteractiveMode {
|
|||
|
||||
this.editor.onCtrlC = () => this.handleCtrlC();
|
||||
this.editor.onCtrlD = () => this.handleCtrlD();
|
||||
this.editor.onCtrlZ = () => this.handleCtrlZ();
|
||||
this.editor.onShiftTab = () => this.cycleThinkingLevel();
|
||||
this.editor.onCtrlP = () => this.cycleModel();
|
||||
this.editor.onCtrlO = () => this.toggleToolOutputExpansion();
|
||||
|
|
@ -1159,6 +1163,20 @@ export class InteractiveMode {
|
|||
process.exit(0);
|
||||
}
|
||||
|
||||
private handleCtrlZ(): void {
|
||||
// Set up handler to restore TUI when resumed
|
||||
process.once("SIGCONT", () => {
|
||||
this.ui.start();
|
||||
this.ui.requestRender(true);
|
||||
});
|
||||
|
||||
// Stop the TUI (restore terminal to normal mode)
|
||||
this.ui.stop();
|
||||
|
||||
// Send SIGTSTP to process group (pid=0 means all processes in group)
|
||||
process.kill(0, "SIGTSTP");
|
||||
}
|
||||
|
||||
private updateEditorBorderColor(): void {
|
||||
if (this.isBashMode) {
|
||||
this.editor.borderColor = theme.getBashModeBorderColor();
|
||||
|
|
@ -1747,6 +1765,7 @@ export class InteractiveMode {
|
|||
| \`Escape\` | Cancel autocomplete / abort streaming |
|
||||
| \`Ctrl+C\` | Clear editor (first) / exit (second) |
|
||||
| \`Ctrl+D\` | Exit (when editor is empty) |
|
||||
| \`Ctrl+Z\` | Suspend to background |
|
||||
| \`Shift+Tab\` | Cycle thinking level |
|
||||
| \`Ctrl+P\` | Cycle models |
|
||||
| \`Ctrl+O\` | Toggle tool output expansion |
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue