MCPcopy
hub / github.com/codeaashu/claude-code / unregisterForeground

Function unregisterForeground

src/tasks/LocalShellTask/LocalShellTask.tsx:491–514  ·  view source on GitHub ↗
(taskId: string, setAppState: SetAppState)

Source from the content-addressed store, hash-verified

489 * Unregister a foreground task when the command completes without being backgrounded.
490 */
491export function unregisterForeground(taskId: string, setAppState: SetAppState): void {
492 let cleanupFn: (() => void) | undefined;
493 setAppState(prev => {
494 const task = prev.tasks[taskId];
495 // Only remove if it's a foreground task (not backgrounded)
496 if (!isLocalShellTask(task) || task.isBackgrounded) {
497 return prev;
498 }
499
500 // Capture cleanup function to call outside of updater
501 cleanupFn = task.unregisterCleanup;
502 const {
503 [taskId]: removed,
504 ...rest
505 } = prev.tasks;
506 return {
507 ...prev,
508 tasks: rest
509 };
510 });
511
512 // Call cleanup outside of the state updater (avoid side effects in updater)
513 cleanupFn?.();
514}
515async function flushAndCleanup(shellCommand: ShellCommand): Promise<void> {
516 try {
517 await shellCommand.taskOutput.flush();

Callers 2

runPowerShellCommandFunction · 0.85
runShellCommandFunction · 0.85

Calls 1

isLocalShellTaskFunction · 0.85

Tested by

no test coverage detected