Skip to content

Commit

Permalink
refactor: replace VS Code toast with chat message
Browse files Browse the repository at this point in the history
- Remove short-lived toast when opening VS Code
- Add persistent message in chat instead
- Remove artificial delay when opening VS Code
- Keep error handling with toasts for failed cases
  • Loading branch information
openhands-agent committed Nov 9, 2024
1 parent 9890c05 commit d35ecd4
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions frontend/src/components/file-explorer/FileExplorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { useTranslation } from "react-i18next";
import { twMerge } from "tailwind-merge";
import AgentState from "#/types/AgentState";
import { setRefreshID } from "#/state/codeSlice";
import { addAssistantMessage } from "#/state/chatSlice";
import IconButton from "../IconButton";
import ExplorerTree from "./ExplorerTree";
import toast from "#/utils/toast";
Expand Down Expand Up @@ -174,14 +175,8 @@ function FileExplorer({ error, isOpen, onToggle }: FileExplorerProps) {
try {
const response = await OpenHands.getVSCodeUrl();
if (response.vscode_url) {
toast.success(
`open-vscode-${new Date().getTime()}`,
t(I18nKey.EXPLORER$VSCODE_SWITCHING_MESSAGE),
);
setTimeout(
() => window.open(response.vscode_url ?? "", "_blank"),
3000,
);
dispatch(addAssistantMessage("You opened VS Code. Please inform the agent of any changes you made to the workspace or environment. To avoid conflicts, it's best to pause the agent before making any changes."));

Check failure on line 178 in frontend/src/components/file-explorer/FileExplorer.tsx

View workflow job for this annotation

GitHub Actions / Lint frontend

Replace `addAssistantMessage("You·opened·VS·Code.·Please·inform·the·agent·of·any·changes·you·made·to·the·workspace·or·environment.·To·avoid·conflicts,·it's·best·to·pause·the·agent·before·making·any·changes.")` with `⏎··········addAssistantMessage(⏎············"You·opened·VS·Code.·Please·inform·the·agent·of·any·changes·you·made·to·the·workspace·or·environment.·To·avoid·conflicts,·it's·best·to·pause·the·agent·before·making·any·changes.",⏎··········),⏎········`
window.open(response.vscode_url, "_blank");
} else {
toast.error(
`open-vscode-error-${new Date().getTime()}`,
Expand Down

0 comments on commit d35ecd4

Please sign in to comment.