refactor(core): extract ExecutionLifecycleService for tool backgrounding (#21717)

This commit is contained in:
Adam Weidman
2026-03-12 00:03:54 -04:00
committed by GitHub
parent 949e85ca55
commit 10ab958378
13 changed files with 1580 additions and 802 deletions

View File

@@ -80,7 +80,7 @@ export const useShellCommandProcessor = (
setShellInputFocused: (value: boolean) => void,
terminalWidth?: number,
terminalHeight?: number,
activeToolPtyId?: number,
activeBackgroundExecutionId?: number,
isWaitingForConfirmation?: boolean,
) => {
const [state, dispatch] = useReducer(shellReducer, initialState);
@@ -103,7 +103,8 @@ export const useShellCommandProcessor = (
}
const m = manager.current;
const activePtyId = state.activeShellPtyId || activeToolPtyId;
const activePtyId =
state.activeShellPtyId ?? activeBackgroundExecutionId ?? undefined;
useEffect(() => {
const isForegroundActive = !!activePtyId || !!isWaitingForConfirmation;
@@ -191,7 +192,8 @@ export const useShellCommandProcessor = (
]);
const backgroundCurrentShell = useCallback(() => {
const pidToBackground = state.activeShellPtyId || activeToolPtyId;
const pidToBackground =
state.activeShellPtyId ?? activeBackgroundExecutionId;
if (pidToBackground) {
ShellExecutionService.background(pidToBackground);
m.backgroundedPids.add(pidToBackground);
@@ -202,7 +204,7 @@ export const useShellCommandProcessor = (
m.restoreTimeout = null;
}
}
}, [state.activeShellPtyId, activeToolPtyId, m]);
}, [state.activeShellPtyId, activeBackgroundExecutionId, m]);
const dismissBackgroundShell = useCallback(
async (pid: number) => {