Skip to content

🙌 OpenHands: AI-Driven Development

Add VS Code tab alongside workspace, terminal, and jupyter tabs (#8033)

Robert Brennane4b7b31f4813
diff --git a/frontend/__tests__/components/file-explorer/explorer-tree.test.tsx b/frontend/__tests__/components/file-explorer/explorer-tree.test.tsx
deleted file mode 100644
index 3d04a3753f..0000000000
--- a/frontend/__tests__/components/file-explorer/explorer-tree.test.tsx
+++ /dev/null
@@ -1,28 +0,0 @@
-import { screen } from "@testing-library/react";
-import { renderWithProviders } from "test-utils";
-import { describe, afterEach, vi, it, expect } from "vitest";
-import { ExplorerTree } from "#/components/features/file-explorer/explorer-tree";
-
-const FILES = ["file-1-1.ts", "folder-1-2"];
-
-describe.skip("ExplorerTree", () => {
- afterEach(() => {
- vi.resetAllMocks();
- });
-
- it("should render the explorer", () => {
- renderWithProviders(<ExplorerTree files={FILES} defaultOpen />);
-
- expect(screen.getByText("file-1-1.ts")).toBeInTheDocument();
- expect(screen.getByText("folder-1-2")).toBeInTheDocument();
- // TODO: make sure children render
- });
-
- it("should render the explorer given the defaultExpanded prop", () => {
- renderWithProviders(<ExplorerTree files={FILES} />);
-
- expect(screen.queryByText("file-1-1.ts")).toBeInTheDocument();
- expect(screen.queryByText("folder-1-2")).toBeInTheDocument();
- // TODO: make sure children don't render
- });
-});
diff --git a/frontend/__tests__/components/file-explorer/file-explorer.test.tsx b/frontend/__tests__/components/file-explorer/file-explorer.test.tsx
deleted file mode 100644
index a951151185..0000000000
--- a/frontend/__tests__/components/file-explorer/file-explorer.test.tsx
+++ /dev/null
@@ -1,64 +0,0 @@
-import { screen } from "@testing-library/react";
-import userEvent from "@testing-library/user-event";
-import { renderWithProviders } from "test-utils";
-import { describe, it, expect, vi, afterEach } from "vitest";
-import { AgentState } from "#/types/agent-state";
-import { FileExplorer } from "#/components/features/file-explorer/file-explorer";
-import { FileService } from "#/api/file-service/file-service.api";
-
-const getFilesSpy = vi.spyOn(FileService, "getFiles");
-
-vi.mock("../../services/fileService", async () => ({
- uploadFiles: vi.fn(),
-}));
-
-const renderFileExplorerWithRunningAgentState = () =>
- renderWithProviders(<FileExplorer isOpen onToggle={() => {}} />, {
- preloadedState: {
- agent: {
- curAgentState: AgentState.RUNNING,
- },
- },
- });
-
-describe.skip("FileExplorer", () => {
- afterEach(() => {
- vi.clearAllMocks();
- });
-
- it("should get the workspace directory", async () => {
- renderFileExplorerWithRunningAgentState();
-
- expect(await screen.findByText("folder1")).toBeInTheDocument();
- expect(await screen.findByText("file1.ts")).toBeInTheDocument();
- expect(getFilesSpy).toHaveBeenCalledTimes(1); // once for root
- });
-
- it("should refetch the workspace when clicking the refresh button", async () => {
- const user = userEvent.setup();
- renderFileExplorerWithRunningAgentState();
-
- expect(await screen.findByText("folder1")).toBeInTheDocument();
- expect(await screen.findByText("file1.ts")).toBeInTheDocument();
- expect(getFilesSpy).toHaveBeenCalledTimes(1); // once for root
-
- const refreshButton = screen.getByTestId("refresh");
- await user.click(refreshButton);
-
- expect(getFilesSpy).toHaveBeenCalledTimes(2); // once for root, once for refresh button
- });
-
- it("should toggle the explorer visibility when clicking the toggle button", async () => {
- const user = userEvent.setup();
- renderFileExplorerWithRunningAgentState();
-
- const folder1 = await screen.findByText("folder1");
- expect(folder1).toBeInTheDocument();
-
- const toggleButton = screen.getByTestId("toggle");
- await user.click(toggleButton);
-
- expect(folder1).toBeInTheDocument();
- expect(folder1).not.toBeVisible();
- });
-});
diff --git a/frontend/__tests__/components/file-explorer/tree-node.test.tsx b/frontend/__tests__/components/file-explorer/tree-node.test.tsx
deleted file mode 100644
index b46aecba4a..0000000000
--- a/frontend/__tests__/components/file-explorer/tree-node.test.tsx
+++ /dev/null
@@ -1,110 +0,0 @@
-import { screen } from "@testing-library/react";
-import userEvent from "@testing-library/user-event";
-import { renderWithProviders } from "test-utils";
-import { vi, describe, afterEach, it, expect } from "vitest";
-import TreeNode from "#/components/features/file-explorer/tree-node";
-import { FileService } from "#/api/file-service/file-service.api";
-
-const getFileSpy = vi.spyOn(FileService, "getFile");
-const getFilesSpy = vi.spyOn(FileService, "getFiles");
-
-vi.mock("../../services/fileService", async () => ({
- uploadFile: vi.fn(),
-}));
-
-describe.skip("TreeNode", () => {
- afterEach(() => {
- vi.clearAllMocks();
- });
-
- it("should render a file if property has no children", () => {
- renderWithProviders(<TreeNode path="/file.ts" defaultOpen />);
- expect(screen.getByText("file.ts")).toBeInTheDocument();
- });
-
- it("should render a folder if it's in a subdir", async () => {
- renderWithProviders(<TreeNode path="/folder1/" defaultOpen />);
- expect(getFilesSpy).toHaveBeenCalledWith("/folder1/");
-
- expect(await screen.findByText("folder1")).toBeInTheDocument();
- expect(await screen.findByText("file2.ts")).toBeInTheDocument();
- });
-
- it("should close a folder when clicking on it", async () => {
- const user = userEvent.setup();
- renderWithProviders(<TreeNode path="/folder1/" defaultOpen />);
-
- const folder1 = await screen.findByText("folder1");
- const file2 = await screen.findByText("file2.ts");
-
- expect(folder1).toBeInTheDocument();
- expect(file2).toBeInTheDocument();
-
- await user.click(folder1);
-
- expect(folder1).toBeInTheDocument();
- expect(screen.queryByText("file2.ts")).not.toBeInTheDocument();
- });
-
- it("should open a folder when clicking on it", async () => {
- const user = userEvent.setup();
- renderWithProviders(<TreeNode path="/folder1/" />);
-
- const folder1 = await screen.findByText("folder1");
-
- expect(folder1).toBeInTheDocument();
- expect(screen.queryByText("file2.ts")).not.toBeInTheDocument();
-
- await user.click(folder1);
- expect(getFilesSpy).toHaveBeenCalledWith("/folder1/");
-
- expect(folder1).toBeInTheDocument();
- expect(await screen.findByText("file2.ts")).toBeInTheDocument();
- });
-
- it("should call `OpenHands.getFile` and return the full path of a file when clicking on a file", async () => {
- const user = userEvent.setup();
- renderWithProviders(<TreeNode path="/folder1/file2.ts" defaultOpen />);
-
- const file2 = screen.getByText("file2.ts");
- await user.click(file2);
-
- expect(getFileSpy).toHaveBeenCalledWith("/folder1/file2.ts");
- });
-
- it("should render the full explorer given the defaultOpen prop", async () => {
- const user = userEvent.setup();
- renderWithProviders(<TreeNode path="/" defaultOpen />);
-
- expect(getFilesSpy).toHaveBeenCalledWith("/");
-
- const file1 = await screen.findByText("file1.ts");
- const folder1 = await screen.findByText("folder1");
-
- expect(file1).toBeInTheDocument();
- expect(folder1).toBeInTheDocument();
- expect(screen.queryByText("file2.ts")).not.toBeInTheDocument();
-
- await user.click(folder1);
- expect(getFilesSpy).toHaveBeenCalledWith("folder1/");
-
- expect(file1).toBeInTheDocument();
- expect(folder1).toBeInTheDocument();
- expect(await screen.findByText("file2.ts")).toBeInTheDocument();
- });
-
- it("should render all children as collapsed when defaultOpen is false", async () => {
- renderWithProviders(<TreeNode path="/folder1/" defaultOpen={false} />);
-
- const folder1 = await screen.findByText("folder1");
-
- expect(folder1).toBeInTheDocument();
- expect(screen.queryByText("file2.ts")).not.toBeInTheDocument();
-
- await userEvent.click(folder1);
- expect(getFilesSpy).toHaveBeenCalledWith("/folder1/");
-
- expect(folder1).toBeInTheDocument();
- expect(await screen.findByText("file2.ts")).toBeInTheDocument();
- });
-});
diff --git a/frontend/src/components/features/file-explorer/explorer-tree.tsx b/frontend/src/components/features/file-explorer/explorer-tree.tsx
deleted file mode 100644
index 01ddea816d..0000000000
--- a/frontend/src/components/features/file-explorer/explorer-tree.tsx
+++ /dev/null
@@ -1,28 +0,0 @@
-import { useTranslation } from "react-i18next";
-import TreeNode from "./tree-node";
-import { I18nKey } from "#/i18n/declaration";
-
-interface ExplorerTreeProps {
- files: string[] | null;
- defaultOpen?: boolean;
-}
-
-export function ExplorerTree({
- files,
- defaultOpen = false,
-}: ExplorerTreeProps) {
- const { t } = useTranslation();
- if (!files?.length) {
- const message = !files
- ? I18nKey.EXPLORER$LOADING_WORKSPACE_MESSAGE
- : I18nKey.EXPLORER$EMPTY_WORKSPACE_MESSAGE;
- return <div className="text-sm text-gray-400 pt-4">{t(message)}</div>;
- }
- return (
- <div className="w-full h-full pt-[4px]">
- {files.map((file) => (
- <TreeNode key={file} path={file} defaultOpen={defaultOpen} />
- ))}
- </div>
- );
-}
diff --git a/frontend/src/components/features/file-explorer/file-explorer-actions.tsx b/frontend/src/components/features/file-explorer/file-explorer-actions.tsx
deleted file mode 100644
index 244ae7e19e..0000000000
--- a/frontend/src/components/features/file-explorer/file-explorer-actions.tsx
+++ /dev/null
@@ -1,28 +0,0 @@
-import { RefreshIconButton } from "#/components/shared/buttons/refresh-icon-button";
-import { ToggleWorkspaceIconButton } from "#/components/shared/buttons/toggle-workspace-icon-button";
-import { cn } from "#/utils/utils";
-
-interface ExplorerActionsProps {
- onRefresh: () => void;
- toggleHidden: () => void;
- isHidden: boolean;
-}
-
-export function ExplorerActions({
- toggleHidden,
- onRefresh,
- isHidden,
-}: ExplorerActionsProps) {
- return (
- <div
- className={cn(
- "flex h-[24px] items-center gap-1",
- isHidden ? "right-3" : "right-2",
- )}
- >
- {!isHidden && <RefreshIconButton onClick={onRefresh} />}
-
- <ToggleWorkspaceIconButton isHidden={isHidden} onClick={toggleHidden} />
- </div>
- );
-}
diff --git a/frontend/src/components/features/file-explorer/file-explorer-header.tsx b/frontend/src/components/features/file-explorer/file-explorer-header.tsx
deleted file mode 100644
index d280595146..0000000000
--- a/frontend/src/components/features/file-explorer/file-explorer-header.tsx
+++ /dev/null
@@ -1,39 +0,0 @@
-import { useTranslation } from "react-i18next";
-import { I18nKey } from "#/i18n/declaration";
-import { cn } from "#/utils/utils";
-import { ExplorerActions } from "./file-explorer-actions";
-
-interface FileExplorerHeaderProps {
- isOpen: boolean;
- onToggle: () => void;
- onRefreshWorkspace: () => void;
-}
-
-export function FileExplorerHeader({
- isOpen,
- onToggle,
- onRefreshWorkspace,
-}: FileExplorerHeaderProps) {
- const { t } = useTranslation();
-
- return (
- <div
- className={cn(
- "sticky top-0 bg-base-secondary",
- "flex items-center",
- !isOpen ? "justify-center" : "justify-between",
- )}
- >
- {isOpen && (
- <div className="text-neutral-300 font-bold text-sm">
- {t(I18nKey.EXPLORER$LABEL_WORKSPACE)}
- </div>
- )}
- <ExplorerActions
- isHidden={!isOpen}
- toggleHidden={onToggle}
- onRefresh={onRefreshWorkspace}
- />
- </div>
- );
-}
diff --git a/frontend/src/components/features/file-explorer/file-explorer.tsx b/frontend/src/components/features/file-explorer/file-explorer.tsx
deleted file mode 100644
index 845da816bb..0000000000
--- a/frontend/src/components/features/file-explorer/file-explorer.tsx
+++ /dev/null
@@ -1,97 +0,0 @@
-import React from "react";
-import { useSelector } from "react-redux";
-import { useTranslation } from "react-i18next";
-import { RUNTIME_INACTIVE_STATES } from "#/types/agent-state";
-import { ExplorerTree } from "#/components/features/file-explorer/explorer-tree";
-import toast from "#/utils/toast";
-import { RootState } from "#/store";
-import { I18nKey } from "#/i18n/declaration";
-import { useListFiles } from "#/hooks/query/use-list-files";
-import { cn } from "#/utils/utils";
-import { FileExplorerHeader } from "./file-explorer-header";
-import { useVSCodeUrl } from "#/hooks/query/use-vscode-url";
-import { BrandButton } from "../settings/brand-button";
-import VSCodeIcon from "#/assets/vscode-alt.svg?react";
-
-interface FileExplorerProps {
- isOpen: boolean;
- onToggle: () => void;
-}
-
-export function FileExplorer({ isOpen, onToggle }: FileExplorerProps) {
- const { t } = useTranslation();
-
- const { curAgentState } = useSelector((state: RootState) => state.agent);
-
- const { data: paths, refetch, error } = useListFiles();
- const { data: vscodeUrl } = useVSCodeUrl({
- enabled: !RUNTIME_INACTIVE_STATES.includes(curAgentState),
- });
-
- const handleOpenVSCode = () => {
- if (vscodeUrl?.vscode_url) {
- window.open(vscodeUrl.vscode_url, "_blank");
- } else if (vscodeUrl?.error) {
- toast.error(
- `open-vscode-error-${new Date().getTime()}`,
- t(I18nKey.EXPLORER$VSCODE_SWITCHING_ERROR_MESSAGE, {
- error: vscodeUrl.error,
- }),
- );
- }
- };
-
- const refreshWorkspace = () => {
- if (!RUNTIME_INACTIVE_STATES.includes(curAgentState)) {
- refetch();
- }
- };
-
- React.useEffect(() => {
- refreshWorkspace();
- }, [curAgentState]);
-
- return (
- <div data-testid="file-explorer" className="relative h-full">
- <div
- className={cn(
- "bg-base-secondary h-full border-r-1 border-r-neutral-600 flex flex-col",
- !isOpen ? "w-12" : "w-60",
- )}
- >
- <div className="flex flex-col relative h-full px-3 py-2 overflow-hidden">
- <FileExplorerHeader
- isOpen={isOpen}
- onToggle={onToggle}
- onRefreshWorkspace={refreshWorkspace}
- />
- {!error && (
- <div className="overflow-auto flex-grow min-h-0">
- <div style={{ display: !isOpen ? "none" : "block" }}>
- <ExplorerTree files={paths || []} />
- </div>
- </div>
- )}
- {error && (
- <div className="flex flex-col items-center justify-center h-full">
- <p className="text-neutral-300 text-sm">{error.message}</p>
- </div>
- )}
- {isOpen && (
- <BrandButton
- testId="open-vscode-button"
- type="button"
- variant="secondary"
- className="w-full text-content border-content"
- isDisabled={RUNTIME_INACTIVE_STATES.includes(curAgentState)}
- onClick={handleOpenVSCode}
- startContent={<VSCodeIcon width={20} height={20} />}
- >
- {t(I18nKey.VSCODE$OPEN)}
- </BrandButton>
- )}
- </div>
- </div>
- </div>
- );
-}
diff --git a/frontend/src/components/features/file-explorer/file-icon.tsx b/frontend/src/components/features/file-explorer/file-icon.tsx
deleted file mode 100644
index bd6486a035..0000000000
--- a/frontend/src/components/features/file-explorer/file-icon.tsx
+++ /dev/null
@@ -1,12 +0,0 @@
-import { FaFile } from "react-icons/fa";
-import { getExtension } from "#/utils/utils";
-import { EXTENSION_ICON_MAP } from "../../extension-icon-map.constant";
-
-interface FileIconProps {
- filename: string;
-}
-
-export function FileIcon({ filename }: FileIconProps) {
- const extension = getExtension(filename);
- return EXTENSION_ICON_MAP[extension] || <FaFile />;
-}
diff --git a/frontend/src/components/features/file-explorer/filename.tsx b/frontend/src/components/features/file-explorer/filename.tsx
deleted file mode 100644
index 179fe84d86..0000000000
--- a/frontend/src/components/features/file-explorer/filename.tsx
+++ /dev/null
@@ -1,20 +0,0 @@
-import { FolderIcon } from "./folder-icon";
-import { FileIcon } from "./file-icon";
-
-interface FilenameProps {
- name: string;
- type: "folder" | "file";
- isOpen: boolean;
-}
-
-export function Filename({ name, type, isOpen }: FilenameProps) {
- return (
- <div className="cursor-pointer text-nowrap rounded-[5px] p-1 nowrap flex items-center gap-2 aria-selected:bg-neutral-600 aria-selected:text-white hover:text-white">
- <div className="flex-shrink-0">
- {type === "folder" && <FolderIcon isOpen={isOpen} />}
- {type === "file" && <FileIcon filename={name} />}
- </div>
- <div className="flex-grow">{name}</div>
- </div>
- );
-}
diff --git a/frontend/src/components/features/file-explorer/folder-icon.tsx b/frontend/src/components/features/file-explorer/folder-icon.tsx
deleted file mode 100644
index e358f0fc39..0000000000
--- a/frontend/src/components/features/file-explorer/folder-icon.tsx
+++ /dev/null
@@ -1,13 +0,0 @@
-import { FaFolder, FaFolderOpen } from "react-icons/fa";
-
-interface FolderIconProps {
- isOpen: boolean;
-}
-
-export function FolderIcon({ isOpen }: FolderIconProps) {
- return isOpen ? (
- <FaFolderOpen color="D9D3D0" className="icon" />
- ) : (
- <FaFolder color="D9D3D0" className="icon" />
- );
-}
diff --git a/frontend/src/components/features/file-explorer/tree-node.tsx b/frontend/src/components/features/file-explorer/tree-node.tsx
deleted file mode 100644
index 53a8fb85d1..0000000000
--- a/frontend/src/components/features/file-explorer/tree-node.tsx
+++ /dev/null
@@ -1,88 +0,0 @@
-import React from "react";
-import { useSelector } from "react-redux";
-
-import { useFiles } from "#/context/files";
-import { cn } from "#/utils/utils";
-import { useListFiles } from "#/hooks/query/use-list-files";
-import { useListFile } from "#/hooks/query/use-list-file";
-import { Filename } from "./filename";
-import { RootState } from "#/store";
-
-interface TreeNodeProps {
- path: string;
- defaultOpen?: boolean;
-}
-
-function TreeNode({ path, defaultOpen = false }: TreeNodeProps) {
- const { setFileContent, setSelectedPath, files, selectedPath } = useFiles();
- const [isOpen, setIsOpen] = React.useState(defaultOpen);
- const { curAgentState } = useSelector((state: RootState) => state.agent);
-
- const isDirectory = path.endsWith("/");
-
- const { data: paths } = useListFiles({
- path,
- enabled: isDirectory && isOpen,
- });
-
- const { data: fileContent, refetch } = useListFile({ path });
-
- React.useEffect(() => {
- if (fileContent) {
- if (fileContent !== files[path]) {
- setFileContent(path, fileContent);
- }
- }
- }, [fileContent, path]);
-
- React.useEffect(() => {
- if (selectedPath === path && !isDirectory) {
- refetch();
- }
- }, [curAgentState, selectedPath, path, isDirectory]);
-
- const fileParts = path.split("/");
- const filename =
- fileParts[fileParts.length - 1] || fileParts[fileParts.length - 2];
-
- const handleClick = async () => {
- if (isDirectory) setIsOpen((prev) => !prev);
- else {
- setSelectedPath(path);
- await refetch();
- }
- };
-
- return (
- <div
- className={cn(
- "text-sm text-neutral-400",
- path === selectedPath && "bg-gray-700",
- )}
- >
- <button
- type={isDirectory ? "button" : "submit"}
- name="file"
- value={path}
- onClick={handleClick}
- className="flex items-center justify-between w-full px-1"
- >
- <Filename
- name={filename}
- type={isDirectory ? "folder" : "file"}
- isOpen={isOpen}
- />
- </button>
-
- {isOpen && paths && (
- <div className="ml-5">
- {paths.map((child, index) => (
- <TreeNode key={index} path={child} />
- ))}
- </div>
- )}
- </div>
- );
-}
-
-export default React.memo(TreeNode);
diff --git a/frontend/src/components/features/terminal/terminal.tsx b/frontend/src/components/features/terminal/terminal.tsx
index bb9e8d8900..692d82ccb2 100644
--- a/frontend/src/components/features/terminal/terminal.tsx
+++ b/frontend/src/components/features/terminal/terminal.tsx
@@ -18,7 +18,7 @@ function Terminal() {
return (
<div className="h-full p-2 min-h-0 flex-grow">
{isRuntimeInactive && (
- <div className="text-sm text-gray-400 mb-2">
+ <div className="w-full h-full flex items-center text-center justify-center text-2xl text-tertiary-light">
{t("DIFF_VIEWER$WAITING_FOR_RUNTIME")}
</div>
)}
diff --git a/frontend/src/components/layout/container.tsx b/frontend/src/components/layout/container.tsx
index 14c55b3e98..4f39595c73 100644
--- a/frontend/src/components/layout/container.tsx
+++ b/frontend/src/components/layout/container.tsx
@@ -10,6 +10,7 @@ interface ContainerProps {
icon?: React.ReactNode;
isBeta?: boolean;
isLoading?: boolean;
+ rightContent?: React.ReactNode;
}[];
children: React.ReactNode;
className?: React.HTMLAttributes<HTMLDivElement>["className"];
@@ -30,16 +31,19 @@ export function Container({
>
{labels && (
<div className="flex text-xs h-[36px]">
- {labels.map(({ label: l, to, icon, isBeta, isLoading }) => (
- <NavTab
- key={to}
- to={to}
- label={l}
- icon={icon}
- isBeta={isBeta}
- isLoading={isLoading}
- />
- ))}
+ {labels.map(
+ ({ label: l, to, icon, isBeta, isLoading, rightContent }) => (
+ <NavTab
+ key={to}
+ to={to}
+ label={l}
+ icon={icon}
+ isBeta={isBeta}
+ isLoading={isLoading}
+ rightContent={rightContent}
+ />
+ ),
+ )}
</div>
)}
{!labels && label && (
diff --git a/frontend/src/components/layout/nav-tab.tsx b/frontend/src/components/layout/nav-tab.tsx
index 4ba2b8d3b8..91d3d6c590 100644
--- a/frontend/src/components/layout/nav-tab.tsx
+++ b/frontend/src/components/layout/nav-tab.tsx
@@ -9,9 +9,17 @@ interface NavTabProps {
icon: React.ReactNode;
isBeta?: boolean;
isLoading?: boolean;
+ rightContent?: React.ReactNode;
}
-export function NavTab({ to, label, icon, isBeta, isLoading }: NavTabProps) {
+export function NavTab({
+ to,
+ label,
+ icon,
+ isBeta,
+ isLoading,
+ rightContent,
+}: NavTabProps) {
return (
<NavLink
end
@@ -24,15 +32,17 @@ export function NavTab({ to, label, icon, isBeta, isLoading }: NavTabProps) {
)}
>
{({ isActive }) => (
- <>
+ <div className="flex items-center justify-between w-full">
<div className="flex items-center gap-2">
<div className={cn(isActive && "text-logo")}>{icon}</div>
{label}
{isBeta && <BetaBadge />}
</div>
-
- {isLoading && <LoadingSpinner size="small" />}
- </>
+ <div className="flex items-center gap-2">
+ {rightContent}
+ {isLoading && <LoadingSpinner size="small" />}
+ </div>
+ </div>
)}
</NavLink>
);
diff --git a/frontend/src/components/shared/buttons/refresh-icon-button.tsx b/frontend/src/components/shared/buttons/refresh-icon-button.tsx
index 91793d7e81..585186d204 100644
--- a/frontend/src/components/shared/buttons/refresh-icon-button.tsx
+++ b/frontend/src/components/shared/buttons/refresh-icon-button.tsx
@@ -19,7 +19,7 @@ export function RefreshIconButton({ onClick }: RefreshIconButtonProps) {
/>
}
testId="refresh"
- ariaLabel={t(I18nKey.WORKSPACE$REFRESH)}
+ ariaLabel={t("BUTTON$REFRESH" as I18nKey)}
onClick={onClick}
/>
);
diff --git a/frontend/src/components/shared/buttons/toggle-workspace-icon-button.tsx b/frontend/src/components/shared/buttons/toggle-workspace-icon-button.tsx
deleted file mode 100644
index 5efde44ce8..0000000000
--- a/frontend/src/components/shared/buttons/toggle-workspace-icon-button.tsx
+++ /dev/null
@@ -1,39 +0,0 @@
-import { IoIosArrowForward, IoIosArrowBack } from "react-icons/io";
-import { useTranslation } from "react-i18next";
-import { IconButton } from "./icon-button";
-import { I18nKey } from "#/i18n/declaration";
-
-interface ToggleWorkspaceIconButtonProps {
- onClick: () => void;
- isHidden: boolean;
-}
-
-export function ToggleWorkspaceIconButton({
- onClick,
- isHidden,
-}: ToggleWorkspaceIconButtonProps) {
- const { t } = useTranslation();
-
- return (
- <IconButton
- icon={
- isHidden ? (
- <IoIosArrowForward
- size={20}
- className="text-neutral-400 hover:text-neutral-100 transition"
- />
- ) : (
- <IoIosArrowBack
- size={20}
- className="text-neutral-400 hover:text-neutral-100 transition"
- />
- )
- }
- testId="toggle"
- ariaLabel={
- isHidden ? t(I18nKey.WORKSPACE$OPEN) : t(I18nKey.WORKSPACE$CLOSE)
- }
- onClick={onClick}
- />
- );
-}
diff --git a/frontend/src/context/files.tsx b/frontend/src/context/files.tsx
deleted file mode 100644
index f0315172ee..0000000000
--- a/frontend/src/context/files.tsx
+++ /dev/null
@@ -1,69 +0,0 @@
-import React from "react";
-
-interface FilesContextType {
- /**
- * List of file paths in the workspace
- */
- paths: string[];
- /**
- * Set the list of file paths in the workspace
- * @param paths The list of file paths in the workspace
- * @returns void
- */
- setPaths: (paths: string[]) => void;
- /**
- * A map of file paths to their contents
- */
- files: Record<string, string>;
- /**
- * Set the content of a file
- * @param path The path of the file
- * @param content The content of the file
- * @returns void
- */
- setFileContent: (path: string, content: string) => void;
- selectedPath: string | null;
- setSelectedPath: (path: string | null) => void;
-}
-
-const FilesContext = React.createContext<FilesContextType | undefined>(
- undefined,
-);
-
-interface FilesProviderProps {
- children: React.ReactNode;
-}
-
-function FilesProvider({ children }: FilesProviderProps) {
- const [paths, setPaths] = React.useState<string[]>([]);
- const [files, setFiles] = React.useState<Record<string, string>>({});
- const [selectedPath, setSelectedPath] = React.useState<string | null>(null);
-
- const setFileContent = React.useCallback((path: string, content: string) => {
- setFiles((prev) => ({ ...prev, [path]: content }));
- }, []);
-
- const value = React.useMemo(
- () => ({
- paths,
- setPaths,
- files,
- setFileContent,
- selectedPath,
- setSelectedPath,
- }),
- [paths, setPaths, files, setFileContent, selectedPath, setSelectedPath],
- );
-
- return <FilesContext value={value}>{children}</FilesContext>;
-}
-
-function useFiles() {
- const context = React.useContext(FilesContext);
- if (context === undefined) {
- throw new Error("useFiles must be used within a FilesProvider");
- }
- return context;
-}
-
-export { FilesProvider, useFiles };
diff --git a/frontend/src/hooks/query/use-list-file.ts b/frontend/src/hooks/query/use-list-file.ts
deleted file mode 100644
index b349b6e564..0000000000
--- a/frontend/src/hooks/query/use-list-file.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import { useQuery } from "@tanstack/react-query";
-import { useConversation } from "#/context/conversation-context";
-import { FileService } from "#/api/file-service/file-service.api";
-
-interface UseListFileConfig {
- path: string;
-}
-
-export const useListFile = (config: UseListFileConfig) => {
- const { conversationId } = useConversation();
- return useQuery({
- queryKey: ["files", conversationId, config.path],
- queryFn: () => FileService.getFile(conversationId, config.path),
- enabled: false, // don't fetch by default, trigger manually via `refetch`
- });
-};
diff --git a/frontend/src/hooks/query/use-list-files.ts b/frontend/src/hooks/query/use-list-files.ts
deleted file mode 100644
index 1e0fa166b2..0000000000
--- a/frontend/src/hooks/query/use-list-files.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-import { useQuery } from "@tanstack/react-query";
-import { useSelector } from "react-redux";
-import { useConversation } from "#/context/conversation-context";
-import { RootState } from "#/store";
-import { RUNTIME_INACTIVE_STATES } from "#/types/agent-state";
-import { FileService } from "#/api/file-service/file-service.api";
-
-interface UseListFilesConfig {
- path?: string;
- enabled?: boolean;
-}
-
-const DEFAULT_CONFIG: UseListFilesConfig = {
- enabled: true,
-};
-
-export const useListFiles = (config: UseListFilesConfig = DEFAULT_CONFIG) => {
- const { conversationId } = useConversation();
- const { curAgentState } = useSelector((state: RootState) => state.agent);
- const runtimeIsActive = !RUNTIME_INACTIVE_STATES.includes(curAgentState);
-
- return useQuery({
- queryKey: ["files", conversationId, config?.path],
- queryFn: () => FileService.getFiles(conversationId, config?.path),
- enabled: runtimeIsActive && !!config?.enabled,
- staleTime: 1000 * 60 * 5, // 5 minutes
- gcTime: 1000 * 60 * 15, // 15 minutes
- });
-};
diff --git a/frontend/src/i18n/declaration.ts b/frontend/src/i18n/declaration.ts
index fe104d700f..6392e065c8 100644
--- a/frontend/src/i18n/declaration.ts
+++ b/frontend/src/i18n/declaration.ts
@@ -34,7 +34,6 @@ export enum I18nKey {
SETTINGS$TITLE = "SETTINGS$TITLE",
CONVERSATION$START_NEW = "CONVERSATION$START_NEW",
ACCOUNT_SETTINGS$TITLE = "ACCOUNT_SETTINGS$TITLE",
- WORKSPACE$TITLE = "WORKSPACE$TITLE",
WORKSPACE$TERMINAL_TAB_LABEL = "WORKSPACE$TERMINAL_TAB_LABEL",
TERMINAL$WAITING_FOR_CLIENT = "TERMINAL$WAITING_FOR_CLIENT",
CODE_EDITOR$FILE_SAVED_SUCCESSFULLY = "CODE_EDITOR$FILE_SAVED_SUCCESSFULLY",
@@ -63,14 +62,12 @@ export enum I18nKey {
ERROR$GENERIC = "ERROR$GENERIC",
GITHUB$AUTH_SCOPE = "GITHUB$AUTH_SCOPE",
FILE_SERVICE$INVALID_FILE_PATH = "FILE_SERVICE$INVALID_FILE_PATH",
- WORKSPACE$PLANNER_TAB_LABEL = "WORKSPACE$PLANNER_TAB_LABEL",
- WORKSPACE$JUPYTER_TAB_LABEL = "WORKSPACE$JUPYTER_TAB_LABEL",
- WORKSPACE$CODE_EDITOR_TAB_LABEL = "WORKSPACE$CODE_EDITOR_TAB_LABEL",
- WORKSPACE$BROWSER_TAB_LABEL = "WORKSPACE$BROWSER_TAB_LABEL",
- WORKSPACE$REFRESH = "WORKSPACE$REFRESH",
- WORKSPACE$OPEN = "WORKSPACE$OPEN",
- WORKSPACE$CLOSE = "WORKSPACE$CLOSE",
VSCODE$OPEN = "VSCODE$OPEN",
+ VSCODE$TITLE = "VSCODE$TITLE",
+ VSCODE$LOADING = "VSCODE$LOADING",
+ VSCODE$URL_NOT_AVAILABLE = "VSCODE$URL_NOT_AVAILABLE",
+ VSCODE$FETCH_ERROR = "VSCODE$FETCH_ERROR",
+ VSCODE$IFRAME_PERMISSIONS = "VSCODE$IFRAME_PERMISSIONS",
INCREASE_TEST_COVERAGE = "INCREASE_TEST_COVERAGE",
AUTO_MERGE_PRS = "AUTO_MERGE_PRS",
FIX_README = "FIX_README",
@@ -134,10 +131,6 @@ export enum I18nKey {
SESSION$SOCKET_NOT_INITIALIZED_ERROR_MESSAGE = "SESSION$SOCKET_NOT_INITIALIZED_ERROR_MESSAGE",
EXPLORER$UPLOAD_ERROR_MESSAGE = "EXPLORER$UPLOAD_ERROR_MESSAGE",
EXPLORER$LABEL_DROP_FILES = "EXPLORER$LABEL_DROP_FILES",
- EXPLORER$LABEL_WORKSPACE = "EXPLORER$LABEL_WORKSPACE",
- EXPLORER$EMPTY_WORKSPACE_MESSAGE = "EXPLORER$EMPTY_WORKSPACE_MESSAGE",
- EXPLORER$LOADING_WORKSPACE_MESSAGE = "EXPLORER$LOADING_WORKSPACE_MESSAGE",
- EXPLORER$REFRESH_ERROR_MESSAGE = "EXPLORER$REFRESH_ERROR_MESSAGE",
EXPLORER$UPLOAD_SUCCESS_MESSAGE = "EXPLORER$UPLOAD_SUCCESS_MESSAGE",
EXPLORER$NO_FILES_UPLOADED_MESSAGE = "EXPLORER$NO_FILES_UPLOADED_MESSAGE",
EXPLORER$UPLOAD_PARTIAL_SUCCESS_MESSAGE = "EXPLORER$UPLOAD_PARTIAL_SUCCESS_MESSAGE",
@@ -348,9 +341,6 @@ export enum I18nKey {
BROWSER$SCREENSHOT_ALT = "BROWSER$SCREENSHOT_ALT",
ERROR_TOAST$CLOSE_BUTTON_LABEL = "ERROR_TOAST$CLOSE_BUTTON_LABEL",
FILE_EXPLORER$UPLOAD = "FILE_EXPLORER$UPLOAD",
- FILE_EXPLORER$REFRESH_WORKSPACE = "FILE_EXPLORER$REFRESH_WORKSPACE",
- FILE_EXPLORER$OPEN_WORKSPACE = "FILE_EXPLORER$OPEN_WORKSPACE",
- FILE_EXPLORER$CLOSE_WORKSPACE = "FILE_EXPLORER$CLOSE_WORKSPACE",
ACTION_MESSAGE$RUN = "ACTION_MESSAGE$RUN",
ACTION_MESSAGE$RUN_IPYTHON = "ACTION_MESSAGE$RUN_IPYTHON",
ACTION_MESSAGE$READ = "ACTION_MESSAGE$READ",
diff --git a/frontend/src/i18n/translation.json b/frontend/src/i18n/translation.json
index 314a93e336..027e26700c 100644
--- a/frontend/src/i18n/translation.json
+++ b/frontend/src/i18n/translation.json
@@ -511,21 +511,7 @@
"tr": "Hesap ayarları",
"de": "Kontoeinstellungen"
},
- "WORKSPACE$TITLE": {
- "en": "Workspace",
- "zh-CN": "工作区",
- "de": "Arbeitsbereich",
- "ko-KR": "워크스페이스",
- "no": "Arbeidsområde",
- "zh-TW": "工作區",
- "ar": "مساحة العمل",
- "fr": "Espace de travail",
- "it": "Area di lavoro",
- "pt": "Espaço de trabalho",
- "es": "Espacio de trabajo",
- "ja": "ワークスペース",
- "tr": "Çalışma Alanı"
- },
+
"WORKSPACE$TERMINAL_TAB_LABEL": {
"en": "Terminal",
"zh-CN": "终端",
@@ -541,6 +527,66 @@
"tr": "Terminal",
"ja": "ターミナル"
},
+ "WORKSPACE$BROWSER_TAB_LABEL": {
+ "en": "Browser",
+ "zh-CN": "浏览器",
+ "de": "Browser",
+ "ko-KR": "브라우저",
+ "no": "Nettleser",
+ "zh-TW": "瀏覽器",
+ "it": "Browser",
+ "pt": "Navegador",
+ "es": "Navegador",
+ "ar": "المتصفح",
+ "fr": "Navigateur",
+ "tr": "Tarayıcı",
+ "ja": "ブラウザ"
+ },
+ "WORKSPACE$JUPYTER_TAB_LABEL": {
+ "en": "Jupyter",
+ "zh-CN": "Jupyter",
+ "de": "Jupyter",
+ "ko-KR": "Jupyter",
+ "no": "Jupyter",
+ "zh-TW": "Jupyter",
+ "it": "Jupyter",
+ "pt": "Jupyter",
+ "es": "Jupyter",
+ "ar": "Jupyter",
+ "fr": "Jupyter",
+ "tr": "Jupyter",
+ "ja": "Jupyter"
+ },
+ "WORKSPACE$CODE_EDITOR_TAB_LABEL": {
+ "en": "Code Editor",
+ "zh-CN": "代码编辑器",
+ "de": "Code-Editor",
+ "ko-KR": "코드 에디터",
+ "no": "Kodeeditor",
+ "zh-TW": "程式碼編輯器",
+ "it": "Editor di codice",
+ "pt": "Editor de código",
+ "es": "Editor de código",
+ "ar": "محرر الكود",
+ "fr": "Éditeur de code",
+ "tr": "Kod Düzenleyici",
+ "ja": "コードエディタ"
+ },
+ "WORKSPACE$TITLE": {
+ "en": "Workspace",
+ "zh-CN": "工作区",
+ "de": "Arbeitsbereich",
+ "ko-KR": "작업 공간",
+ "no": "Arbeidsområde",
+ "zh-TW": "工作區",
+ "it": "Area di lavoro",
+ "pt": "Espaço de trabalho",
+ "es": "Espacio de trabajo",
+ "ar": "مساحة العمل",
+ "fr": "Espace de travail",
+ "tr": "Çalışma Alanı",
+ "ja": "ワークスペース"
+ },
"TERMINAL$WAITING_FOR_CLIENT": {
"en": "Waiting for client to become ready...",
"ja": "クライアントの準備を待機中...",
@@ -946,111 +992,13 @@
"tr": "Geçersiz dosya yolu. Lütfen dosya adını kontrol edin ve tekrar deneyin.",
"ja": "ファイルパスが無効です。ファイル名を確認して、もう一度お試しください。"
},
- "WORKSPACE$PLANNER_TAB_LABEL": {
- "en": "Planner",
- "zh-CN": "规划器",
- "de": "Planer",
- "ko-KR": "플래너",
- "no": "Planlegger",
- "zh-TW": "規劃工具",
- "ar": "المخطط",
- "fr": "Planificateur",
- "it": "Pianificatore",
- "pt": "Planejador",
- "es": "Planificador",
- "ja": "プランナー",
- "tr": "Planlayıcı"
- },
- "WORKSPACE$JUPYTER_TAB_LABEL": {
- "en": "Jupyter",
- "zh-CN": "Jupyter",
- "de": "Jupyter",
- "ko-KR": "Jupyter",
- "no": "Jupyter",
- "zh-TW": "Jupyter",
- "ar": "Jupyter",
- "fr": "Jupyter",
- "it": "Jupyter",
- "pt": "Jupyter",
- "es": "Jupyter",
- "ja": "Jupyter",
- "tr": "Jupyter"
- },
- "WORKSPACE$CODE_EDITOR_TAB_LABEL": {
- "en": "Code Editor",
- "zh-CN": "代码编辑器",
- "de": "Code-Editor",
- "ko-KR": "코드 편집기",
- "no": "Kode editor",
- "zh-TW": "程式碼編輯器",
- "ar": "محرر الكود",
- "fr": "Éditeur de code",
- "it": "Editor di codice",
- "pt": "Editor de código",
- "es": "Editor de código",
- "ja": "コードエディタ",
- "tr": "Kod Editörü"
- },
- "WORKSPACE$BROWSER_TAB_LABEL": {
- "en": "Browser",
- "zh-CN": "浏览器",
- "de": "Browser",
- "ko-KR": "브라우저",
- "no": "Nettleser",
- "zh-TW": "瀏覽器",
- "it": "Browser",
- "pt": "Navegador",
- "es": "Navegador",
- "ar": "المتصفح",
- "fr": "Navigateur",
- "tr": "Tarayıcı",
- "ja": "ブラウザ"
- },
- "WORKSPACE$REFRESH": {
- "en": "Refresh",
- "de": "Aktualisieren",
- "zh-CN": "刷新",
- "zh-TW": "重新整理",
- "ko-KR": "새로고침",
- "no": "Oppdater",
- "it": "Aggiorna",
- "pt": "Atualizar",
- "es": "Actualizar",
- "ar": "تحديث",
- "fr": "Rafraîchir",
- "tr": "Yenile",
- "ja": "更新"
- },
- "WORKSPACE$OPEN": {
- "en": "Open workspace",
- "de": "Arbeitsbereich öffnen",
- "zh-CN": "打开工作区",
- "zh-TW": "開啟工作區",
- "ko-KR": "작업 공간 열기",
- "no": "Åpne arbeidsområde",
- "it": "Apri area di lavoro",
- "pt": "Abrir espaço de trabalho",
- "es": "Abrir espacio de trabajo",
- "ar": "فتح مساحة العمل",
- "fr": "Ouvrir l'espace de travail",
- "tr": "Çalışma alanını aç",
- "ja": "ワークスペースを開く"
- },
- "WORKSPACE$CLOSE": {
- "en": "Close workspace",
- "de": "Arbeitsbereich schließen",
- "zh-CN": "关闭工作区",
- "zh-TW": "關閉工作區",
- "ko-KR": "작업 공간 닫기",
- "no": "Lukk arbeidsområde",
- "it": "Chiudi area di lavoro",
- "pt": "Fechar espaço de trabalho",
- "es": "Cerrar espacio de trabajo",
- "ar": "إغلاق مساحة العمل",
- "fr": "Fermer l'espace de travail",
- "tr": "Çalışma alanını kapat",
- "ja": "ワークスペースを閉じる"
- },
+
+
+
+
+
+
+
"VSCODE$OPEN": {
"en": "Open in VS Code",
"ja": "VS Codeで開く",
@@ -1066,6 +1014,81 @@
"fr": "Ouvrir dans VS Code",
"tr": "VS Code'da aç"
},
+ "VSCODE$TITLE": {
+ "en": "VS Code",
+ "ja": "VS Code",
+ "zh-CN": "VS Code",
+ "zh-TW": "VS Code",
+ "ko-KR": "VS Code",
+ "de": "VS Code",
+ "no": "VS Code",
+ "it": "VS Code",
+ "pt": "VS Code",
+ "es": "VS Code",
+ "ar": "VS Code",
+ "fr": "VS Code",
+ "tr": "VS Code"
+ },
+ "VSCODE$LOADING": {
+ "en": "Loading VS Code...",
+ "ja": "VS Codeを読み込み中...",
+ "zh-CN": "正在加载VS Code...",
+ "zh-TW": "正在加載VS Code...",
+ "ko-KR": "VS Code 로딩 중...",
+ "de": "VS Code wird geladen...",
+ "no": "Laster VS Code...",
+ "it": "Caricamento di VS Code...",
+ "pt": "Carregando VS Code...",
+ "es": "Cargando VS Code...",
+ "ar": "جاري تحميل VS Code...",
+ "fr": "Chargement de VS Code...",
+ "tr": "VS Code yükleniyor..."
+ },
+ "VSCODE$URL_NOT_AVAILABLE": {
+ "en": "VS Code URL not available",
+ "ja": "VS Code URLが利用できません",
+ "zh-CN": "VS Code URL不可用",
+ "zh-TW": "VS Code URL不可用",
+ "ko-KR": "VS Code URL을 사용할 수 없습니다",
+ "de": "VS Code URL nicht verfügbar",
+ "no": "VS Code URL ikke tilgjengelig",
+ "it": "URL di VS Code non disponibile",
+ "pt": "URL do VS Code não disponível",
+ "es": "URL de VS Code no disponible",
+ "ar": "رابط VS Code غير متوفر",
+ "fr": "URL VS Code non disponible",
+ "tr": "VS Code URL'si mevcut değil"
+ },
+ "VSCODE$FETCH_ERROR": {
+ "en": "Failed to fetch VS Code URL",
+ "ja": "VS Code URLの取得に失敗しました",
+ "zh-CN": "获取VS Code URL失败",
+ "zh-TW": "獲取VS Code URL失敗",
+ "ko-KR": "VS Code URL을 가져오지 못했습니다",
+ "de": "Fehler beim Abrufen der VS Code URL",
+ "no": "Kunne ikke hente VS Code URL",
+ "it": "Impossibile recuperare l'URL di VS Code",
+ "pt": "Falha ao buscar URL do VS Code",
+ "es": "Error al obtener la URL de VS Code",
+ "ar": "فشل في جلب رابط VS Code",
+ "fr": "Échec de la récupération de l'URL VS Code",
+ "tr": "VS Code URL'si alınamadı"
+ },
+ "VSCODE$IFRAME_PERMISSIONS": {
+ "en": "clipboard-read; clipboard-write",
+ "ja": "clipboard-read; clipboard-write",
+ "zh-CN": "clipboard-read; clipboard-write",
+ "zh-TW": "clipboard-read; clipboard-write",
+ "ko-KR": "clipboard-read; clipboard-write",
+ "de": "clipboard-read; clipboard-write",
+ "no": "clipboard-read; clipboard-write",
+ "it": "clipboard-read; clipboard-write",
+ "pt": "clipboard-read; clipboard-write",
+ "es": "clipboard-read; clipboard-write",
+ "ar": "clipboard-read; clipboard-write",
+ "fr": "clipboard-read; clipboard-write",
+ "tr": "clipboard-read; clipboard-write"
+ },
"INCREASE_TEST_COVERAGE": {
"en": "Increase test coverage",
"ja": "テストカバレッジを向上",
@@ -1990,66 +2013,10 @@
"tr": "Dosyaları buraya bırakın",
"ja": "ここにファイルをドロップ"
},
- "EXPLORER$LABEL_WORKSPACE": {
- "en": "Workspace",
- "zh-CN": "工作区",
- "de": "Arbeitsbereich",
- "zh-TW": "工作區",
- "es": "Espacio de trabajo",
- "fr": "Espace de travail",
- "it": "Area di lavoro",
- "pt": "Espaço de trabalho",
- "ko-KR": "워크스페이스",
- "ar": "مساحة العمل",
- "tr": "Çalışma alanı",
- "no": "Arbeidsområde",
- "ja": "ワークスペース"
- },
- "EXPLORER$EMPTY_WORKSPACE_MESSAGE": {
- "en": "No files in workspace",
- "zh-CN": "工作区为空",
- "de": "Keine Dateien im Arbeitsbereich",
- "zh-TW": "工作區為空",
- "es": "No hay archivos en el espacio de trabajo",
- "fr": "Aucun fichier dans l'espace de travail",
- "it": "Nessun file nell'area di lavoro",
- "pt": "Nenhum arquivo no espaço de trabalho",
- "ko-KR": "워크스페이스가 비어 있습니다",
- "ar": "لا توجد ملفات في مساحة العمل",
- "tr": "Çalışma alanında dosya yok",
- "no": "Ingen filer i arbeidsområdet",
- "ja": "ワークスペースにファイルがありません"
- },
- "EXPLORER$LOADING_WORKSPACE_MESSAGE": {
- "en": "Loading workspace...",
- "zh-CN": "加载工作区中...",
- "de": "Arbeitsbereich wird geladen...",
- "zh-TW": "載入工作區中...",
- "es": "Cargando espacio de trabajo...",
- "fr": "Chargement de l'espace de travail...",
- "it": "Caricamento dell'area di lavoro...",
- "pt": "Carregando espaço de trabalho...",
- "ko-KR": "워크스페이스 로딩 중...",
- "ar": "جارٍ تحميل مساحة العمل...",
- "tr": "Çalışma alanı yükleniyor...",
- "no": "Laster arbeidsområde...",
- "ja": "ワークスペースを読み込み中..."
- },
- "EXPLORER$REFRESH_ERROR_MESSAGE": {
- "en": "Error refreshing workspace",
- "zh-CN": "刷新时出错",
- "de": "Fehler beim Aktualisieren des Arbeitsbereichs",
- "zh-TW": "重新整理時發生錯誤",
- "es": "Error al actualizar el espacio de trabajo",
- "fr": "Erreur lors de l'actualisation de l'espace de travail",
- "it": "Errore durante l'aggiornamento dell'area di lavoro",
- "pt": "Erro ao atualizar o espaço de trabalho",
- "ko-KR": "새로고침 중 오류 발생",
- "ar": "خطأ في تحديث مساحة العمل",
- "tr": "Çalışma alanı yenilenirken hata oluştu",
- "no": "Feil ved oppdatering av arbeidsområde",
- "ja": "ワークスペースの更新中にエラーが発生しました"
- },
+
+
+
+
"EXPLORER$UPLOAD_SUCCESS_MESSAGE": {
"en": "Successfully uploaded {{count}} file(s)",
"zh-CN": "上传成功",
@@ -4058,6 +4025,21 @@
"BUTTON$COPY_TO_CLIPBOARD": {
"en": "Copy to Clipboard"
},
+ "BUTTON$REFRESH": {
+ "en": "Refresh",
+ "ja": "更新",
+ "zh-CN": "刷新",
+ "zh-TW": "重新整理",
+ "ko-KR": "새로고침",
+ "no": "Oppdater",
+ "it": "Aggiorna",
+ "pt": "Atualizar",
+ "es": "Actualizar",
+ "ar": "تحديث",
+ "fr": "Rafraîchir",
+ "tr": "Yenile",
+ "de": "Aktualisieren"
+ },
"ERROR$REQUIRED_FIELD": {
"en": "This field is required"
},
@@ -4935,51 +4917,9 @@
"es": "Subir archivo",
"tr": "Dosya yükle"
},
- "FILE_EXPLORER$REFRESH_WORKSPACE": {
- "en": "Refresh workspace",
- "zh-CN": "刷新工作区",
- "zh-TW": "重新整理工作區",
- "ko-KR": "워크스페이스 새로고침",
- "ja": "ワークスペースを更新",
- "no": "Oppdater arbeidsområde",
- "ar": "تحديث مساحة العمل",
- "de": "Arbeitsbereich aktualisieren",
- "fr": "Actualiser l'espace de travail",
- "it": "Aggiorna area di lavoro",
- "pt": "Atualizar área de trabalho",
- "es": "Actualizar espacio de trabajo",
- "tr": "Çalışma alanını yenile"
- },
- "FILE_EXPLORER$OPEN_WORKSPACE": {
- "en": "Open workspace",
- "zh-CN": "打开工作区",
- "zh-TW": "開啟工作區",
- "ko-KR": "워크스페이스 열기",
- "ja": "ワークスペースを開く",
- "no": "Åpne arbeidsområde",
- "ar": "فتح مساحة العمل",
- "de": "Arbeitsbereich öffnen",
- "fr": "Ouvrir l'espace de travail",
- "it": "Apri area di lavoro",
- "pt": "Abrir área de trabalho",
- "es": "Abrir espacio de trabajo",
- "tr": "Çalışma alanını aç"
- },
- "FILE_EXPLORER$CLOSE_WORKSPACE": {
- "en": "Close workspace",
- "zh-CN": "关闭工作区",
- "zh-TW": "關閉工作區",
- "ko-KR": "워크스페이스 닫기",
- "ja": "ワークスペースを閉じる",
- "no": "Lukk arbeidsområde",
- "ar": "إغلاق مساحة العمل",
- "de": "Arbeitsbereich schließen",
- "fr": "Fermer l'espace de travail",
- "it": "Chiudi area di lavoro",
- "pt": "Fechar área de trabalho",
- "es": "Cerrar espacio de trabajo",
- "tr": "Çalışma alanını kapat"
- },
+
+
+
"ACTION_MESSAGE$RUN": {
"en": "Running <cmd>{{action.payload.args.command}}</cmd>",
"zh-CN": "运行 <cmd>{{action.payload.args.command}}</cmd>",
diff --git a/frontend/src/routes.ts b/frontend/src/routes.ts
index 3543a2f65e..5e8c01a8be 100644
--- a/frontend/src/routes.ts
+++ b/frontend/src/routes.ts
@@ -15,11 +15,11 @@ export default [
]),
route("conversations/:conversationId", "routes/conversation.tsx", [
index("routes/editor.tsx"),
- route("workspace", "routes/editor-tab.tsx"),
route("browser", "routes/browser-tab.tsx"),
route("jupyter", "routes/jupyter-tab.tsx"),
route("served", "routes/served-tab.tsx"),
route("terminal", "routes/terminal-tab.tsx"),
+ route("vscode", "routes/vscode-tab.tsx"),
]),
]),
] satisfies RouteConfig;
diff --git a/frontend/src/routes/conversation.tsx b/frontend/src/routes/conversation.tsx
index 21b1c1cdb8..cf449a5f1d 100644
--- a/frontend/src/routes/conversation.tsx
+++ b/frontend/src/routes/conversation.tsx
@@ -2,10 +2,12 @@ import { useDisclosure } from "@heroui/react";
import React from "react";
import { Outlet } from "react-router";
import { useDispatch, useSelector } from "react-redux";
-import { FaServer } from "react-icons/fa";
+import { FaServer, FaExternalLinkAlt } from "react-icons/fa";
import { useTranslation } from "react-i18next";
import { DiGit } from "react-icons/di";
+import { VscCode } from "react-icons/vsc";
import { I18nKey } from "#/i18n/declaration";
+import { RUNTIME_INACTIVE_STATES } from "#/types/agent-state";
import {
ConversationProvider,
useConversation,
@@ -14,12 +16,12 @@ import { Controls } from "#/components/features/controls/controls";
import { clearMessages, addUserMessage } from "#/state/chat-slice";
import { clearTerminal } from "#/state/command-slice";
import { useEffectOnce } from "#/hooks/use-effect-once";
-import CodeIcon from "#/icons/code.svg?react";
+
import GlobeIcon from "#/icons/globe.svg?react";
import JupyterIcon from "#/icons/jupyter.svg?react";
import TerminalIcon from "#/icons/terminal.svg?react";
import { clearJupyter } from "#/state/jupyter-slice";
-import { FilesProvider } from "#/context/files";
+
import { ChatInterface } from "../components/features/chat/chat-interface";
import { WsClientProvider } from "#/context/ws-client-provider";
import { EventHandler } from "../wrapper/event-handler";
@@ -50,6 +52,7 @@ function AppContent() {
const { initialPrompt, files } = useSelector(
(state: RootState) => state.initialQuery,
);
+ const { curAgentState } = useSelector((state: RootState) => state.agent);
const dispatch = useDispatch();
const endSession = useEndSession();
@@ -134,9 +137,37 @@ function AppContent() {
icon: <DiGit className="w-6 h-6" />,
},
{
- label: t(I18nKey.WORKSPACE$TITLE),
- to: "workspace",
- icon: <CodeIcon />,
+ label: (
+ <div className="flex items-center gap-1">
+ {t(I18nKey.VSCODE$TITLE)}
+ </div>
+ ),
+ to: "vscode",
+ icon: <VscCode className="w-5 h-5" />,
+ rightContent: !RUNTIME_INACTIVE_STATES.includes(
+ curAgentState,
+ ) ? (
+ <FaExternalLinkAlt
+ className="w-3 h-3 text-neutral-400 cursor-pointer"
+ onClick={async (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ if (conversationId) {
+ try {
+ const response = await fetch(
+ `/api/conversations/${conversationId}/vscode-url`,
+ );
+ const data = await response.json();
+ if (data.vscode_url) {
+ window.open(data.vscode_url, "_blank");
+ }
+ } catch (err) {
+ // Silently handle the error
+ }
+ }
+ }}
+ />
+ ) : null,
},
{
label: t(I18nKey.WORKSPACE$TERMINAL_TAB_LABEL),
@@ -160,9 +191,7 @@ function AppContent() {
},
]}
>
- <FilesProvider>
- <Outlet />
- </FilesProvider>
+ <Outlet />
</Container>
}
/>
diff --git a/frontend/src/routes/editor-tab.tsx b/frontend/src/routes/editor-tab.tsx
deleted file mode 100644
index 1788cf206e..0000000000
--- a/frontend/src/routes/editor-tab.tsx
+++ /dev/null
@@ -1,57 +0,0 @@
-import React from "react";
-import { useRouteError } from "react-router";
-import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
-import { vscDarkPlus } from "react-syntax-highlighter/dist/esm/styles/prism";
-import { useTranslation } from "react-i18next";
-import { FileExplorer } from "#/components/features/file-explorer/file-explorer";
-import { useFiles } from "#/context/files";
-import { getLanguageFromPath } from "#/utils/get-language-from-path";
-
-export function ErrorBoundary() {
- const error = useRouteError();
- const { t } = useTranslation();
-
- return (
- <div className="w-full h-full border border-danger rounded-b-xl flex flex-col items-center justify-center gap-2 bg-red-500/5">
- <h1 className="text-3xl font-bold">{t("ERROR$GENERIC")}</h1>
- {error instanceof Error && <pre>{error.message}</pre>}
- </div>
- );
-}
-
-function FileViewer() {
- const [fileExplorerIsOpen, setFileExplorerIsOpen] = React.useState(true);
- const { selectedPath, files } = useFiles();
-
- const toggleFileExplorer = () => {
- setFileExplorerIsOpen((prev) => !prev);
- };
-
- return (
- <div className="flex h-full bg-base-secondary relative">
- <FileExplorer isOpen={fileExplorerIsOpen} onToggle={toggleFileExplorer} />
- <div className="w-full h-full flex flex-col">
- {selectedPath && files[selectedPath] && (
- <div className="h-full w-full overflow-auto">
- <SyntaxHighlighter
- language={getLanguageFromPath(selectedPath)}
- style={vscDarkPlus}
- customStyle={{
- margin: 0,
- padding: "10px",
- height: "100%",
- background: "#171717",
- fontSize: "0.875rem",
- borderRadius: 0,
- }}
- >
- {files[selectedPath]}
- </SyntaxHighlighter>
- </div>
- )}
- </div>
- </div>
- );
-}
-
-export default FileViewer;
diff --git a/frontend/src/routes/vscode-tab.tsx b/frontend/src/routes/vscode-tab.tsx
new file mode 100644
index 0000000000..d1b75a3bd2
--- /dev/null
+++ b/frontend/src/routes/vscode-tab.tsx
@@ -0,0 +1,81 @@
+import React from "react";
+import { useTranslation } from "react-i18next";
+import { useSelector } from "react-redux";
+import { useConversation } from "#/context/conversation-context";
+import { I18nKey } from "#/i18n/declaration";
+import { RootState } from "#/store";
+import { RUNTIME_INACTIVE_STATES } from "#/types/agent-state";
+
+function VSCodeTab() {
+ const { t } = useTranslation();
+ const { conversationId } = useConversation();
+ const [vsCodeUrl, setVsCodeUrl] = React.useState<string | null>(null);
+ const [isLoading, setIsLoading] = React.useState(true);
+ const [error, setError] = React.useState<string | null>(null);
+ const { curAgentState } = useSelector((state: RootState) => state.agent);
+ const isRuntimeInactive = RUNTIME_INACTIVE_STATES.includes(curAgentState);
+
+ React.useEffect(() => {
+ async function fetchVSCodeUrl() {
+ if (!conversationId || isRuntimeInactive) return;
+
+ try {
+ setIsLoading(true);
+ const response = await fetch(
+ `/api/conversations/${conversationId}/vscode-url`,
+ );
+ const data = await response.json();
+
+ if (data.vscode_url) {
+ setVsCodeUrl(data.vscode_url);
+ } else {
+ setError(t(I18nKey.VSCODE$URL_NOT_AVAILABLE));
+ }
+ } catch (err) {
+ setError(t(I18nKey.VSCODE$FETCH_ERROR));
+ // Error is handled by setting the error state
+ } finally {
+ setIsLoading(false);
+ }
+ }
+
+ fetchVSCodeUrl();
+ }, [conversationId, isRuntimeInactive, t]);
+
+ if (isRuntimeInactive) {
+ return (
+ <div className="w-full h-full flex items-center text-center justify-center text-2xl text-tertiary-light">
+ {t("DIFF_VIEWER$WAITING_FOR_RUNTIME")}
+ </div>
+ );
+ }
+
+ if (isLoading) {
+ return (
+ <div className="w-full h-full flex items-center text-center justify-center text-2xl text-tertiary-light">
+ {t("DIFF_VIEWER$WAITING_FOR_RUNTIME")}
+ </div>
+ );
+ }
+
+ if (error || !vsCodeUrl) {
+ return (
+ <div className="w-full h-full flex items-center text-center justify-center text-2xl text-tertiary-light">
+ {error || t(I18nKey.VSCODE$URL_NOT_AVAILABLE)}
+ </div>
+ );
+ }
+
+ return (
+ <div className="h-full w-full">
+ <iframe
+ title={t(I18nKey.VSCODE$TITLE)}
+ src={vsCodeUrl}
+ className="w-full h-full border-0"
+ allow={t(I18nKey.VSCODE$IFRAME_PERMISSIONS)}
+ />
+ </div>
+ );
+}
+
+export default VSCodeTab;
diff --git a/frontend/src/types/tab-option.tsx b/frontend/src/types/tab-option.tsx
index a732acb2c7..bd6d3cc9ef 100644
--- a/frontend/src/types/tab-option.tsx
+++ b/frontend/src/types/tab-option.tsx
@@ -1,18 +1,18 @@
enum TabOption {
PLANNER = "planner",
- CODE = "code",
BROWSER = "browser",
JUPYTER = "jupyter",
+ VSCODE = "vscode",
}
type TabType =
| TabOption.PLANNER
- | TabOption.CODE
| TabOption.BROWSER
- | TabOption.JUPYTER;
+ | TabOption.JUPYTER
+ | TabOption.VSCODE;
const AllTabs = [
- TabOption.CODE,
+ TabOption.VSCODE,
TabOption.BROWSER,
TabOption.PLANNER,
TabOption.JUPYTER,