Skip to content

Commit dda69f0

Browse files
committed
fix: prevent double devbox creation when pressing Enter in interactive form
The DevboxCreatePage had two overlapping Enter key handlers that both called handleCreate(): the FormTextInput's onSubmit prop and a global catch-all in the parent useInput handler. Since ink doesn't stop event propagation between useInput hooks, pressing Enter on any text field fired both handlers, creating two devboxes. Replaced the global catch-all with a specific handler for the create button field, and removed onSubmit from text inputs. Now only the create button and Ctrl+S trigger devbox creation, while each special field (metadata, gateways, etc.) retains its own Enter handler. Bonus: Fixed some unrelated build errors.
1 parent 2c73cba commit dda69f0

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

src/components/DevboxCreatePage.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,8 @@ export const DevboxCreatePage = ({
459459
return;
460460
}
461461

462-
// Handle Enter on any field to submit
463-
if (key.return) {
462+
// Enter on the create button to submit
463+
if (currentField === "create" && key.return) {
464464
handleCreate();
465465
return;
466466
}
@@ -1918,7 +1918,6 @@ export const DevboxCreatePage = ({
19181918
onChange={(value) =>
19191919
setFormData({ ...formData, [field.key]: value })
19201920
}
1921-
onSubmit={handleCreate}
19221921
isActive={isActive}
19231922
placeholder={field.placeholder}
19241923
/>

src/services/agentService.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ export interface ListAgentsOptions {
1111
limit?: number;
1212
startingAfter?: string;
1313
publicOnly?: boolean;
14+
privateOnly?: boolean;
15+
name?: string;
16+
search?: string;
1417
}
1518

1619
export interface ListAgentsResult {
@@ -32,6 +35,8 @@ export async function listAgents(
3235
limit?: number;
3336
starting_after?: string;
3437
is_public?: boolean;
38+
name?: string;
39+
search?: string;
3540
} = {
3641
limit: options.limit || 50,
3742
};
@@ -40,9 +45,18 @@ export async function listAgents(
4045
queryParams.starting_after = options.startingAfter;
4146
}
4247

43-
// Use API filter for public agents
4448
if (options.publicOnly) {
4549
queryParams.is_public = true;
50+
} else if (options.privateOnly) {
51+
queryParams.is_public = false;
52+
}
53+
54+
if (options.name) {
55+
queryParams.name = options.name;
56+
}
57+
58+
if (options.search) {
59+
queryParams.search = options.search;
4660
}
4761

4862
const page = await client.agents.list(queryParams);

0 commit comments

Comments
 (0)