- {!loaded && (
-
-
-
- )}
+
);
@@ -99,18 +75,16 @@ function VscodePanelBody({
isRunning,
isProgress,
iframeUrl,
- refreshKey,
onRetry,
}: {
status: VscodeStatus;
isRunning: boolean;
isProgress: boolean;
iframeUrl: string;
- refreshKey: number;
onRetry: () => void;
}) {
if (isRunning) {
- return
;
+ return
;
}
if (isProgress) {
return (
@@ -136,7 +110,6 @@ function useVscodeLifecycle() {
const activeSessionId = useAppStore((state) => state.tasks.activeSessionId);
const { resolvedTheme } = useTheme();
const [status, setStatus] = useState
({ status: "stopped" });
- const [refreshKey, setRefreshKey] = useState(0);
const startedRef = useRef(false);
// Auto-start on mount or session change
@@ -183,23 +156,6 @@ function useVscodeLifecycle() {
return () => clearInterval(interval);
}, [activeSessionId, status.status]);
- const handleStop = useCallback(async () => {
- if (!activeSessionId) return;
- await stopVscode(activeSessionId);
- setStatus({ status: "stopped" });
- startedRef.current = false;
- // Remove the vscode panel from the current layout instead of switching layouts
- const dockApi = useDockviewStore.getState().api;
- const vscodePanel = dockApi?.getPanel("vscode");
- if (vscodePanel) {
- try {
- dockApi!.removePanel(vscodePanel);
- } catch {
- /* already removed */
- }
- }
- }, [activeSessionId]);
-
const handleRetry = useCallback(() => {
if (!activeSessionId) return;
startedRef.current = true;
@@ -212,26 +168,12 @@ function useVscodeLifecycle() {
});
}, [activeSessionId, resolvedTheme]);
- const handleRefresh = useCallback(() => {
- setRefreshKey((k) => k + 1);
- }, []);
-
- const handleOpenInTab = useCallback(() => {
- if (status.url) {
- window.open(buildBaseUrl(status.url), "_blank", "noopener,noreferrer");
- }
- }, [status.url]);
-
const iframeUrl = status.status === "running" && status.url ? buildBaseUrl(status.url) : null;
return {
status,
iframeUrl,
- refreshKey,
- handleStop,
handleRetry,
- handleRefresh,
- handleOpenInTab,
};
}
@@ -241,8 +183,7 @@ type VscodePanelProps = {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export const VscodePanel = memo(function VscodePanel({ panelId }: VscodePanelProps) {
- const { status, iframeUrl, refreshKey, handleStop, handleRetry, handleRefresh, handleOpenInTab } =
- useVscodeLifecycle();
+ const { status, iframeUrl, handleRetry } = useVscodeLifecycle();
const isRunning = status.status === "running" && iframeUrl;
const isProgress =
@@ -256,76 +197,9 @@ export const VscodePanel = memo(function VscodePanel({ panelId }: VscodePanelPro
isRunning={!!isRunning}
isProgress={isProgress}
iframeUrl={iframeUrl ?? ""}
- refreshKey={refreshKey}
onRetry={handleRetry}
/>
-
);
});
-
-function VscodePanelFooter({
- status,
- isRunning,
- onOpenInTab,
- onRefresh,
- onStop,
-}: {
- status: VscodeStatus["status"];
- isRunning: boolean;
- onOpenInTab: () => void;
- onRefresh: () => void;
- onStop: () => void;
-}) {
- return (
-
-
-
- VS Code
- {isRunning && }
- {(status === "installing" || status === "starting") && (
-
- )}
-
-
- {isRunning && (
- <>
-
-
-
- >
- )}
-
- );
-}