π OpenHands: AI-Driven Development
fix(canvas): hide unavailable cloud VS Code action (#18149)
Graham Neubig6eebcbecc3ed
diff --git a/__tests__/hooks/use-unified-vscode-url.test.tsx b/__tests__/hooks/use-unified-vscode-url.test.tsxindex 2c68f1962b..7dcc834274 100644--- a/__tests__/hooks/use-unified-vscode-url.test.tsx+++ b/__tests__/hooks/use-unified-vscode-url.test.tsx@@ -272,9 +272,10 @@ describe("useUnifiedVSCodeUrl", () => {expect(result.current.data?.error).toBe(i18n.t(I18nKey.VSCODE$URL_NOT_AVAILABLE),);+ expect(result.current.isUnavailable).toBe(false);});- it("ignores unrelated cloud exposed URLs", async () => {+ it("hides the control when a running cloud sandbox exposes no VSCode service", async () => {vi.mocked(useActiveBackend).mockReturnValue(cloudBackend);vi.mocked(batchGetCloudSandboxes).mockResolvedValue([makeSandbox({@@ -291,6 +292,7 @@ describe("useUnifiedVSCodeUrl", () => {url: null,error: i18n.t(I18nKey.VSCODE$URL_NOT_AVAILABLE),});+ expect(result.current.isUnavailable).toBe(true);});it("falls through to AgentServerConversationService.getVSCodeUrl in local mode", async () => {diff --git a/src/hooks/query/use-unified-vscode-url.ts b/src/hooks/query/use-unified-vscode-url.tsindex fc9a570d42..521b436a8e 100644--- a/src/hooks/query/use-unified-vscode-url.ts+++ b/src/hooks/query/use-unified-vscode-url.ts@@ -150,10 +150,10 @@ export const useUnifiedVSCodeUrl = () => {: undefined,};};- // Cloud behavior is deliberately unchanged: a sandbox with no VSCODE- // entry in `exposed_urls` still surfaces the control. Narrowing this- // change to self-hosted keeps its blast radius off the cloud path.- isUnavailable = false;+ isUnavailable =+ cloudSandboxQuery.isSuccess &&+ sandbox?.status === "RUNNING" &&+ exposedUrl === null;} else {data = localQuery.data;// The URL request only starts once the capability probe has cleared it,