MCPcopy Index your code
hub / github.com/codeaashu/claude-code / handleKeyDown

Function handleKeyDown

src/components/tasks/BackgroundTasksDialog.tsx:253–305  ·  view source on GitHub ↗
(e: KeyboardEvent)

Source from the content-addressed store, hash-verified

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 }

Callers

nothing calls this directly

Calls 10

killShellTaskFunction · 0.85
killAgentTaskFunction · 0.85
killTeammateTaskFunction · 0.85
killDreamTaskFunction · 0.85
stopUltraplanFunction · 0.85
killRemoteAgentTaskFunction · 0.85
enterTeammateViewFunction · 0.85
exitTeammateViewFunction · 0.85
preventDefaultMethod · 0.80
onDoneFunction · 0.50

Tested by

no test coverage detected