feat: implement execution control (pause/resume/abort) for agent mode
Adds execution control system per GitHub issue #113: - Ctrl+P: Toggle pause/resume during agent execution - Ctrl+Z: Abort with rollback (undo file changes) - Ctrl+Shift+S: Toggle step-by-step mode - Enter: Advance one step when in step mode New files: - src/types/execution-control.ts: Type definitions - src/services/execution-control.ts: Control implementation with rollback - src/constants/execution-control.ts: Keyboard shortcuts and messages Modified: - agent-stream.ts: Integrated execution control into agent loop - message-handler.ts: Added control functions and callbacks - app.tsx: Added keyboard shortcut handlers - help-content.ts: Added help topics for new shortcuts Closes #113
This commit is contained in:
53
src/constants/execution-control.ts
Normal file
53
src/constants/execution-control.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* Execution Control Constants
|
||||
*
|
||||
* Constants for agent execution control (pause/resume/abort).
|
||||
*/
|
||||
|
||||
/**
|
||||
* Keyboard shortcuts for execution control
|
||||
*/
|
||||
export const EXECUTION_CONTROL_KEYS = {
|
||||
/** Toggle pause/resume (Ctrl+P) */
|
||||
TOGGLE_PAUSE: "ctrl+p",
|
||||
/** Abort execution (Ctrl+C) */
|
||||
ABORT: "ctrl+c",
|
||||
/** Abort with rollback (Ctrl+Z) */
|
||||
ABORT_WITH_ROLLBACK: "ctrl+z",
|
||||
/** Toggle step mode (Ctrl+Shift+S) */
|
||||
TOGGLE_STEP_MODE: "ctrl+shift+s",
|
||||
/** Advance one step in step mode (Enter when waiting) */
|
||||
STEP: "return",
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* Execution control status messages
|
||||
*/
|
||||
export const EXECUTION_CONTROL_MESSAGES = {
|
||||
PAUSED: "⏸ Execution paused. Press Ctrl+P to resume.",
|
||||
RESUMED: "▶ Execution resumed.",
|
||||
STEP_MODE_ENABLED: "🚶 Step mode enabled. Press Enter to advance each tool call.",
|
||||
STEP_MODE_DISABLED: "🏃 Step mode disabled. Execution will continue automatically.",
|
||||
WAITING_FOR_STEP: (toolName: string): string =>
|
||||
`⏳ Step mode: Ready to execute ${toolName}. Press Enter to continue.`,
|
||||
ROLLBACK_ACTION: (description: string): string =>
|
||||
`↩ Rolling back: ${description}`,
|
||||
ROLLBACK_COMPLETE: (count: number): string =>
|
||||
`✓ Rollback complete. ${count} action(s) undone.`,
|
||||
ABORT_INITIATED: (rollbackCount: number): string =>
|
||||
rollbackCount > 0
|
||||
? `Aborting with rollback of ${rollbackCount} action(s)...`
|
||||
: "Aborting execution...",
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* Help text for execution control
|
||||
*/
|
||||
export const EXECUTION_CONTROL_HELP = `
|
||||
Execution Control:
|
||||
Ctrl+P - Toggle pause/resume
|
||||
Ctrl+C - Abort execution
|
||||
Ctrl+Z - Abort with rollback (undo file changes)
|
||||
Ctrl+Shift+S - Toggle step-by-step mode
|
||||
Enter - Advance one step (when in step mode)
|
||||
` as const;
|
||||
@@ -173,6 +173,33 @@ export const HELP_TOPICS: HelpTopic[] = [
|
||||
shortcuts: ["Ctrl+M"],
|
||||
category: "shortcuts",
|
||||
},
|
||||
{
|
||||
id: "shortcut-ctrlp",
|
||||
name: "Ctrl+P",
|
||||
shortDescription: "Pause/Resume",
|
||||
fullDescription:
|
||||
"Toggle pause/resume during agent execution. When paused, tool calls are suspended until resumed.",
|
||||
shortcuts: ["Ctrl+P"],
|
||||
category: "shortcuts",
|
||||
},
|
||||
{
|
||||
id: "shortcut-ctrlz",
|
||||
name: "Ctrl+Z",
|
||||
shortDescription: "Abort with rollback",
|
||||
fullDescription:
|
||||
"Abort current operation and rollback file changes made during this execution. Use to undo unwanted modifications.",
|
||||
shortcuts: ["Ctrl+Z"],
|
||||
category: "shortcuts",
|
||||
},
|
||||
{
|
||||
id: "shortcut-ctrlshifts",
|
||||
name: "Ctrl+Shift+S",
|
||||
shortDescription: "Toggle step mode",
|
||||
fullDescription:
|
||||
"Enable step-by-step mode where you can advance one tool call at a time. Press Enter to execute each tool.",
|
||||
shortcuts: ["Ctrl+Shift+S"],
|
||||
category: "shortcuts",
|
||||
},
|
||||
];
|
||||
|
||||
export const getTopicsByCategory = (category: HelpCategory): HelpTopic[] =>
|
||||
|
||||
Reference in New Issue
Block a user