(e: KeyboardEvent)
| 251 | // Component-specific shortcuts (x=stop, f=foreground, right=zoom) shown in UI. |
| 252 | // These are task-type and status dependent, not standard dialog keybindings. |
| 253 | const handleKeyDown = (e: KeyboardEvent) => { |
| 254 | // Only handle input when in list mode |
| 255 | if (viewState.mode !== 'list') return; |
| 256 | if (e.key === 'left') { |
| 257 | e.preventDefault(); |
| 258 | onDone('Background tasks dialog dismissed', { |
| 259 | display: 'system' |
| 260 | }); |
| 261 | return; |
| 262 | } |
| 263 | |
| 264 | // Compute current selection at the time of the key press |
| 265 | const currentSelection_0 = allSelectableItems[selectedIndex]; |
| 266 | if (!currentSelection_0) return; // everything below requires a selection |
| 267 | |
| 268 | if (e.key === 'x') { |
| 269 | e.preventDefault(); |
| 270 | if (currentSelection_0.type === 'local_bash' && currentSelection_0.status === 'running') { |
| 271 | void killShellTask(currentSelection_0.id); |
| 272 | } else if (currentSelection_0.type === 'local_agent' && currentSelection_0.status === 'running') { |
| 273 | void killAgentTask(currentSelection_0.id); |
| 274 | } else if (currentSelection_0.type === 'in_process_teammate' && currentSelection_0.status === 'running') { |
| 275 | void killTeammateTask(currentSelection_0.id); |
| 276 | } else if (currentSelection_0.type === 'local_workflow' && currentSelection_0.status === 'running' && killWorkflowTask) { |
| 277 | killWorkflowTask(currentSelection_0.id, setAppState); |
| 278 | } else if (currentSelection_0.type === 'monitor_mcp' && currentSelection_0.status === 'running' && killMonitorMcp) { |
| 279 | killMonitorMcp(currentSelection_0.id, setAppState); |
| 280 | } else if (currentSelection_0.type === 'dream' && currentSelection_0.status === 'running') { |
| 281 | void killDreamTask(currentSelection_0.id); |
| 282 | } else if (currentSelection_0.type === 'remote_agent' && currentSelection_0.status === 'running') { |
| 283 | if (currentSelection_0.task.isUltraplan) { |
| 284 | void stopUltraplan(currentSelection_0.id, currentSelection_0.task.sessionId, setAppState); |
| 285 | } else { |
| 286 | void killRemoteAgentTask(currentSelection_0.id); |
| 287 | } |
| 288 | } |
| 289 | } |
| 290 | if (e.key === 'f') { |
| 291 | if (currentSelection_0.type === 'in_process_teammate' && currentSelection_0.status === 'running') { |
| 292 | e.preventDefault(); |
| 293 | enterTeammateView(currentSelection_0.id, setAppState); |
| 294 | onDone('Viewing teammate', { |
| 295 | display: 'system' |
| 296 | }); |
| 297 | } else if (currentSelection_0.type === 'leader') { |
| 298 | e.preventDefault(); |
| 299 | exitTeammateView(setAppState); |
| 300 | onDone('Viewing leader', { |
| 301 | display: 'system' |
| 302 | }); |
| 303 | } |
| 304 | } |
| 305 | }; |
| 306 | async function killShellTask(taskId: string): Promise<void> { |
| 307 | await LocalShellTask.kill(taskId, setAppState); |
| 308 | } |
nothing calls this directly
no test coverage detected