Repository navigation
fix(web): Add Environment dialog reopens on Remote link instead of a stale SSH selection #26160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
maria-rcks
merged 5 commits into
pingdotgg:main
from
Mnigos:fix-add-environment-dialog-mode-reset
Oct 31, 2026
+166
−16
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ed8dea9
fix(web): Add Environment dialog reopens on Remote link instead of a …
Mnigos aed7ccb
fix(web): reset the Add Environment form when closing starts
Mnigos 92b3d78
chore: merge main into environment dialog fix
maria-rcks 3a2ef25
fix(web): reset every add environment close path
maria-rcks 83a65d5
fix(web): ignore ssh results from dismissed environment dialogs
maria-rcks File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
139 changes: 139 additions & 0 deletions
139
apps/web/src/components/settings/AddEnvironmentDialog.browser.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,139 @@ | ||
| import { Atom, AsyncResult } from "effect/reactivity"; | ||
| import * as Cause from "effect/Cause"; | ||
| import type { AtomCommandResult } from "@t3tools/client-runtime/state/runtime"; | ||
| import { useState } from "react"; | ||
| import { page, userEvent } from "vite-plus/test/browser"; | ||
| import { describe, expect, it, vi } from "vite-plus/test"; | ||
|
|
||
| import { render, stubGlobal } from "../../../test/render"; | ||
| import { AppAtomRegistryProvider } from "../../rpc/atomRegistry"; | ||
|
|
||
| const mocks = vi.hoisted(() => ({ | ||
| connectSshEnvironment: vi.fn<() => Promise<AtomCommandResult<void, Error>>>(async () => | ||
| AsyncResult.success(undefined), | ||
| ), | ||
| refresh: () => {}, | ||
| })); | ||
|
|
||
| vi.mock(import("../../state/use-atom-command"), async (original) => ({ | ||
| ...(await original()), | ||
| useAtomCommand: ((command: unknown) => command) as never, | ||
| })); | ||
| vi.mock(import("~/connection/onboarding"), async (original) => ({ | ||
| ...(await original()), | ||
| connectSshEnvironment: mocks.connectSshEnvironment as never, | ||
| })); | ||
| vi.mock(import("~/state/query"), async (original) => ({ | ||
| ...(await original()), | ||
| useEnvironmentQuery: (() => ({ | ||
| data: [], | ||
| isPending: false, | ||
| error: null, | ||
| refresh: mocks.refresh, | ||
| })) as never, | ||
| })); | ||
| vi.mock(import("~/state/environments"), async (original) => ({ | ||
| ...(await original()), | ||
| useRelayEnvironmentDiscovery: (() => ({ environments: new Map() })) as never, | ||
| })); | ||
| vi.mock(import("~/state/server"), async (original) => ({ | ||
| ...(await original()), | ||
| primaryServerKeybindingsAtom: Atom.make([]) as never, | ||
| })); | ||
|
|
||
| import { AddEnvironmentDialog } from "./AddEnvironmentDialog"; | ||
|
|
||
| function Owner() { | ||
| const [open, setOpen] = useState(false); | ||
| const [error, setError] = useState<string | null>(null); | ||
| return ( | ||
| <AppAtomRegistryProvider> | ||
| <AddEnvironmentDialog | ||
| open={open} | ||
| routeTarget={null} | ||
| error={error} | ||
| savedEnvironments={[]} | ||
| onOpenChange={setOpen} | ||
| onErrorChange={setError} | ||
| /> | ||
| </AppAtomRegistryProvider> | ||
| ); | ||
| } | ||
|
|
||
| function setup() { | ||
| mocks.connectSshEnvironment.mockClear(); | ||
| return stubGlobal("desktopBridge", {}); | ||
| } | ||
|
|
||
| const remoteCard = () => page.getByRole("button", { name: /Remote link/ }); | ||
| const sshCard = () => page.getByRole("button", { name: /^SSH/ }); | ||
|
|
||
| async function openDialogOnSsh() { | ||
| await userEvent.click(page.getByRole("button", { name: "Add environment" })); | ||
| await userEvent.click(sshCard()); | ||
| await expect.element(sshCard()).toHaveAttribute("aria-pressed", "true"); | ||
| } | ||
|
|
||
| async function expectDefaultModeAfterReopen() { | ||
| await expect.element(page.getByRole("dialog")).not.toBeInTheDocument(); | ||
| await userEvent.click(page.getByRole("button", { name: "Add environment" })); | ||
| await expect.element(remoteCard()).toHaveAttribute("aria-pressed", "true"); | ||
| await expect.element(sshCard()).toHaveAttribute("aria-pressed", "false"); | ||
| await expect.element(page.getByPlaceholder("backend.example.com")).toBeInTheDocument(); | ||
| } | ||
|
|
||
| describe("AddEnvironmentDialog", () => { | ||
| it("reopens on Remote link after adding an SSH environment", async () => { | ||
| using _bridge = setup(); | ||
| await using _screen = await render(<Owner />); | ||
|
|
||
| await openDialogOnSsh(); | ||
| await userEvent.type(page.getByPlaceholder("Search hosts or type devbox"), "devbox"); | ||
| await userEvent.click( | ||
| page.getByRole("dialog").getByRole("button", { name: "Add environment" }), | ||
| ); | ||
| expect(mocks.connectSshEnvironment).toHaveBeenCalledOnce(); | ||
|
|
||
| await expectDefaultModeAfterReopen(); | ||
| }); | ||
|
|
||
| it("clears the form after dismissing it on SSH", async () => { | ||
| using _bridge = setup(); | ||
| await using _screen = await render(<Owner />); | ||
|
|
||
| await openDialogOnSsh(); | ||
| await userEvent.click(remoteCard()); | ||
| await userEvent.type(page.getByPlaceholder("backend.example.com"), "devbox.example.com"); | ||
| await userEvent.type(page.getByPlaceholder("PAIRCODE"), "PAIRCODE"); | ||
| await userEvent.click(sshCard()); | ||
| await userEvent.type(page.getByPlaceholder("Search hosts or type devbox"), "devbox"); | ||
| await userEvent.type(page.getByPlaceholder("root"), "maria"); | ||
| await userEvent.type(page.getByPlaceholder("22"), "2222"); | ||
| await userEvent.keyboard("{Escape}"); | ||
|
|
||
| await expectDefaultModeAfterReopen(); | ||
| await expect.element(page.getByPlaceholder("backend.example.com")).toHaveValue(""); | ||
| await expect.element(page.getByPlaceholder("PAIRCODE")).toHaveValue(""); | ||
| await userEvent.click(sshCard()); | ||
| await expect.element(page.getByPlaceholder("Search hosts or type devbox")).toHaveValue(""); | ||
| await expect.element(page.getByPlaceholder("root")).toHaveValue(""); | ||
| await expect.element(page.getByPlaceholder("22")).toHaveValue(""); | ||
|
|
||
| let finishConnection!: (result: AtomCommandResult<void, Error>) => void; | ||
| const pending = new Promise<AtomCommandResult<void, Error>>((resolve) => { | ||
| finishConnection = resolve; | ||
| }); | ||
| mocks.connectSshEnvironment.mockImplementationOnce(() => pending); | ||
| await userEvent.type(page.getByPlaceholder("Search hosts or type devbox"), "devbox"); | ||
| await userEvent.click( | ||
| page.getByRole("dialog").getByRole("button", { name: "Add environment" }), | ||
| ); | ||
| await userEvent.keyboard("{Escape}"); | ||
| await expectDefaultModeAfterReopen(); | ||
| finishConnection(AsyncResult.failure(Cause.fail(new Error("dismissed SSH attempt")))); | ||
| await expect | ||
| .element(page.getByRole("dialog").getByRole("button", { name: "Add environment" })) | ||
| .toBeEnabled(); | ||
| await expect.element(page.getByText(/dismissed SSH attempt/)).not.toBeInTheDocument(); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.