The best way to control Claude Code, Codex and more from any computer or phone
fix(web): pressing Enter in the Add CLIProxyAPI hub dialog adds the hub (#36755)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
preet committed
Nov 14, 2026 at 19:17 UTC
616067de84b8826f201a3704928369fbfb1958fa
2 files changed
+52
-2
apps/web/src/components/settings/AddUsageLimitSourceDialog.browser.test.tsx
new
+48
@@ -0,0 +1,48 @@
1
+import { EnvironmentId } from "@t3tools/contracts";
2
+import { page, userEvent } from "vite-plus/test/browser";
3
+import { describe, expect, it, vi } from "vite-plus/test";
4
+
5
+import { render } from "../../../test/render";
6
+
7
+const updateSettings = vi.hoisted(() => vi.fn());
8
+
9
+vi.mock(import("../../hooks/useSettings"), async (original) => ({
10
+ ...(await original()),
11
+ useUpdateEnvironmentSettings: (() => updateSettings) as never,
12
+}));
13
+vi.mock(import("./SecretSourceInput"), async (original) => ({
14
+ ...(await original()),
15
+ useSecretSources: () => [],
16
+}));
17
+
18
+import { AddUsageLimitSourceDialog } from "./AddUsageLimitSourceDialog";
19
+
20
+describe("AddUsageLimitSourceDialog", () => {
21
+ it("adds the hub when Enter is pressed in a field", async () => {
22
+ updateSettings.mockClear();
23
+ const onOpenChange = vi.fn();
24
+ await using _screen = await render(
25
+ <AddUsageLimitSourceDialog
26
+ open
27
+ onOpenChange={onOpenChange}
28
+ environmentId={EnvironmentId.make("local")}
29
+ environmentLabel="This Mac"
30
+ sources={{}}
31
+ />,
32
+ );
33
+
34
+ await userEvent.type(page.getByLabelText("Hub URL"), "https://hub.example.ts.net:8318");
35
+ await userEvent.type(page.getByLabelText("Management key"), "secret-key{Enter}");
36
+
37
+ expect(updateSettings).toHaveBeenCalledOnce();
38
+ expect(updateSettings).toHaveBeenCalledWith({
39
+ usageLimitSources: {
40
+ "cliproxy-hub.example.ts.net-8318": expect.objectContaining({
41
+ url: "https://hub.example.ts.net:8318",
42
+ managementKey: "secret-key",
43
+ }),
44
+ },
45
+ });
46
+ expect(onOpenChange).toHaveBeenCalledWith(false);
47
+ });
48
+});
apps/web/src/components/settings/AddUsageLimitSourceDialog.tsx
+4
-2
@@ -1,5 +1,5 @@
1
import type { EnvironmentId, SecretReference, UnifiedSettings } from "@t3tools/contracts";
2
-import { useState } from "react";
2
+import { useId, useState } from "react";
3
4
import { useUpdateEnvironmentSettings } from "../../hooks/useSettings";
5
import { Button } from "../ui/button";
@@ -31,6 +31,7 @@ export function AddUsageLimitSourceDialog({
31
readonly environmentLabel: string;
32
readonly sources: UnifiedSettings["usageLimitSources"];
33
}) {
34
+ const formId = useId();
35
const updateSettings = useUpdateEnvironmentSettings(environmentId);
36
const [label, setLabel] = useState("");
37
const [url, setUrl] = useState("");
@@ -84,6 +85,7 @@ export function AddUsageLimitSourceDialog({
85
</DialogHeader>
86
<DialogPanel>
87
<form
88
+ id={formId}
89
className="grid gap-4"
90
onSubmit={(event) => {
91
event.preventDefault();
@@ -134,7 +136,7 @@ export function AddUsageLimitSourceDialog({
136
>
137
Cancel
138
</Button>
137
- <Button onClick={save} disabled={!canSave}>
139
+ <Button type="submit" form={formId} disabled={!canSave}>
140
Add hub
141
</Button>
142
</DialogFooter>