Revert "feat: Introduce an AI-driven interactive shell mode with new"

This reverts commit 651ad63ed6.
This commit is contained in:
Gaurav Ghosh
2026-04-08 07:31:17 -07:00
parent 651ad63ed6
commit e7f8d9cf1a
22 changed files with 84 additions and 907 deletions
+1 -17
View File
@@ -92,23 +92,7 @@ export function shellReducer(
nextTasks.delete(action.pid);
}
nextTasks.set(action.pid, updatedTask);
// Auto-hide panel when all tasks have exited
let nextVisible = state.isBackgroundTaskVisible;
if (action.update.status === 'exited') {
const hasRunning = Array.from(nextTasks.values()).some(
(s) => s.status === 'running',
);
if (!hasRunning) {
nextVisible = false;
}
}
return {
...state,
backgroundTasks: nextTasks,
isBackgroundTaskVisible: nextVisible,
};
return { ...state, backgroundTasks: nextTasks };
}
case 'APPEND_TASK_OUTPUT': {
const task = state.backgroundTasks.get(action.pid);
@@ -1,101 +0,0 @@
/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import { useState, useEffect, useMemo, useRef } from 'react';
import { type BackgroundTask } from './shellReducer.js';
export interface BackgroundShellManagerProps {
backgroundTasks: Map<number, BackgroundTask>;
backgroundTaskCount: number;
isBackgroundTaskVisible: boolean;
activePtyId: number | null | undefined;
embeddedShellFocused: boolean;
setEmbeddedShellFocused: (focused: boolean) => void;
terminalHeight: number;
}
export function useBackgroundShellManager({
backgroundTasks,
backgroundTaskCount,
isBackgroundTaskVisible,
activePtyId,
embeddedShellFocused,
setEmbeddedShellFocused,
terminalHeight,
}: BackgroundShellManagerProps) {
const [isBackgroundShellListOpen, setIsBackgroundShellListOpen] =
useState(false);
const [activeBackgroundShellPid, setActiveBackgroundShellPid] = useState<
number | null
>(null);
const prevShellCountRef = useRef(backgroundTaskCount);
useEffect(() => {
if (backgroundTasks.size === 0) {
if (activeBackgroundShellPid !== null) {
setActiveBackgroundShellPid(null);
}
if (isBackgroundShellListOpen) {
setIsBackgroundShellListOpen(false);
}
} else if (
activeBackgroundShellPid === null ||
!backgroundTasks.has(activeBackgroundShellPid)
) {
// If active shell is closed or none selected, select the first one
setActiveBackgroundShellPid(backgroundTasks.keys().next().value ?? null);
} else if (backgroundTaskCount > prevShellCountRef.current) {
// A new shell was added — auto-switch to the newest one (last in the map)
const pids = Array.from(backgroundTasks.keys());
const newestPid = pids[pids.length - 1];
if (newestPid !== undefined && newestPid !== activeBackgroundShellPid) {
setActiveBackgroundShellPid(newestPid);
}
}
prevShellCountRef.current = backgroundTaskCount;
}, [
backgroundTasks,
activeBackgroundShellPid,
backgroundTaskCount,
isBackgroundShellListOpen,
]);
useEffect(() => {
if (embeddedShellFocused) {
const hasActiveForegroundShell = !!activePtyId;
const hasVisibleBackgroundShell =
isBackgroundTaskVisible && backgroundTasks.size > 0;
if (!hasActiveForegroundShell && !hasVisibleBackgroundShell) {
setEmbeddedShellFocused(false);
}
}
}, [
isBackgroundTaskVisible,
backgroundTasks,
embeddedShellFocused,
backgroundTaskCount,
activePtyId,
setEmbeddedShellFocused,
]);
const backgroundShellHeight = useMemo(
() =>
isBackgroundTaskVisible && backgroundTasks.size > 0
? Math.max(Math.floor(terminalHeight * 0.3), 5)
: 0,
[isBackgroundTaskVisible, backgroundTasks.size, terminalHeight],
);
return {
isBackgroundShellListOpen,
setIsBackgroundShellListOpen,
activeBackgroundShellPid,
setActiveBackgroundShellPid,
backgroundShellHeight,
};
}
@@ -661,10 +661,6 @@ export const useExecutionLifecycle = (
(s: BackgroundTask) => s.status === 'running',
).length;
const showBackgroundShell = useCallback(() => {
dispatch({ type: 'SET_VISIBILITY', visible: true });
}, [dispatch]);
return {
handleShellCommand,
activeShellPtyId: state.activeShellPtyId,
@@ -672,7 +668,6 @@ export const useExecutionLifecycle = (
backgroundTaskCount,
isBackgroundTaskVisible: state.isBackgroundTaskVisible,
toggleBackgroundTasks,
showBackgroundShell,
backgroundCurrentExecution,
registerBackgroundTask,
dismissBackgroundTask,
@@ -390,7 +390,6 @@ export const useGeminiStream = (
backgroundTaskCount,
isBackgroundTaskVisible,
toggleBackgroundTasks,
showBackgroundShell,
backgroundCurrentExecution,
registerBackgroundTask,
dismissBackgroundTask,
@@ -1918,7 +1917,6 @@ export const useGeminiStream = (
backgroundedTool.command,
backgroundedTool.initialOutput,
);
showBackgroundShell();
}
}
@@ -2058,7 +2056,6 @@ export const useGeminiStream = (
modelSwitchedFromQuotaError,
addItem,
registerBackgroundTask,
showBackgroundShell,
consumeUserHint,
isLowErrorVerbosity,
maybeAddSuppressedToolErrorNote,