Skip to content

Commit 2350046

Browse files
committed
Add json editor support to client side tool
Fix the minor bugs of client side tool Remove atom agent from boot-strap and support remember me prerequisite dialog
1 parent 75e71a4 commit 2350046

File tree

5 files changed

+775
-16
lines changed

5 files changed

+775
-16
lines changed

ui/src/components/AiPlayground.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,20 @@ const AiPlayground: React.FC = () => {
10061006
console.log('Has client-side tools:', hasClientSideTools(agent));
10071007

10081008
// Check if agent has client-side tools and show prerequisite dialog
1009+
// Skip showing dialog if user has dismissed it within the last 14 days
10091010
if (hasClientSideTools(agent)) {
1011+
const dismissedUntil = localStorage.getItem('clientSideToolsPrerequisiteDismissed');
1012+
if (dismissedUntil) {
1013+
const expiryDate = new Date(dismissedUntil);
1014+
const now = new Date();
1015+
if (now < expiryDate) {
1016+
console.log('Prerequisite dialog dismissed until:', expiryDate);
1017+
return;
1018+
} else {
1019+
// Expired, remove from localStorage
1020+
localStorage.removeItem('clientSideToolsPrerequisiteDismissed');
1021+
}
1022+
}
10101023
console.log('Showing prerequisite dialog for agent:', agent.name);
10111024
setPrerequisiteDialogOpen(true);
10121025
}

ui/src/components/ArrayItemsModal.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ const ArrayItemsModal: React.FC<ArrayItemsModalProps> = ({
5151
if (open) {
5252
if (initialItems) {
5353
setItems(initialItems);
54-
setPropertyType(initialItems.type);
54+
// If property has enum values, treat it as enum type in UI (even if saved type is 'string')
55+
setPropertyType(initialItems.enum && initialItems.enum.length > 0 ? 'enum' : initialItems.type);
5556
setPropertyDescription(initialItems.description || '');
5657
setPropertyDefaultValue(initialItems.default !== undefined ? JSON.stringify(initialItems.default) : '');
5758
setPropertyEnumValues(initialItems.enum || []);
@@ -120,7 +121,7 @@ const ArrayItemsModal: React.FC<ArrayItemsModalProps> = ({
120121
const parsedDefaultValue = parseDefaultValue(propertyDefaultValue, propertyType);
121122

122123
const newItems: PropertyDefinition = {
123-
type: propertyType,
124+
type: propertyType === 'enum' ? 'string' : propertyType,
124125
description: propertyDescription.trim() || undefined,
125126
...(parsedDefaultValue !== undefined && { default: parsedDefaultValue }),
126127
...(propertyType === 'enum' && propertyEnumValues.length > 0 && { enum: propertyEnumValues }),
@@ -134,7 +135,8 @@ const ArrayItemsModal: React.FC<ArrayItemsModalProps> = ({
134135
const handleCancel = () => {
135136
if (initialItems) {
136137
setItems(initialItems);
137-
setPropertyType(initialItems.type);
138+
// If property has enum values, treat it as enum type in UI (even if saved type is 'string')
139+
setPropertyType(initialItems.enum && initialItems.enum.length > 0 ? 'enum' : initialItems.type);
138140
setPropertyDescription(initialItems.description || '');
139141
setPropertyDefaultValue(initialItems.default !== undefined ? JSON.stringify(initialItems.default) : '');
140142
setPropertyEnumValues(initialItems.enum || []);

ui/src/components/ClientSideToolsPrerequisiteDialog.tsx

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import {
99
import { AlertTriangle, Eye, EyeOff, Copy, Check } from 'lucide-react';
1010
import { Input } from '@/components/ui/input';
1111
import { Button } from '@/components/ui/button';
12+
import { Checkbox } from '@/components/ui/checkbox';
13+
import { Label } from '@/components/ui/label';
14+
import { Separator } from '@/components/ui/separator';
1215
import { apiClient } from '@/lib/api';
1316

1417
interface ClientSideToolsPrerequisiteDialogProps {
@@ -27,6 +30,7 @@ const ClientSideToolsPrerequisiteDialog: React.FC<ClientSideToolsPrerequisiteDia
2730
const [isLoading, setIsLoading] = React.useState(false);
2831
const [error, setError] = React.useState<string | null>(null);
2932
const [isCopied, setIsCopied] = React.useState(false);
33+
const [rememberMe, setRememberMe] = React.useState(false);
3034

3135
const fetchCredentials = async () => {
3236
setIsLoading(true);
@@ -45,6 +49,8 @@ const ClientSideToolsPrerequisiteDialog: React.FC<ClientSideToolsPrerequisiteDia
4549
React.useEffect(() => {
4650
if (open && agentName) {
4751
fetchCredentials();
52+
// Reset checkbox state when dialog opens
53+
setRememberMe(false);
4854
}
4955
}, [open, agentName]);
5056

@@ -59,8 +65,18 @@ const ClientSideToolsPrerequisiteDialog: React.FC<ClientSideToolsPrerequisiteDia
5965
}
6066
};
6167

68+
const handleClose = (open: boolean) => {
69+
if (!open && rememberMe) {
70+
// Store the preference in localStorage with timestamp (14 days from now)
71+
const expiryDate = new Date();
72+
expiryDate.setDate(expiryDate.getDate() + 14);
73+
localStorage.setItem('clientSideToolsPrerequisiteDismissed', expiryDate.toISOString());
74+
}
75+
onOpenChange(open);
76+
};
77+
6278
return (
63-
<Dialog open={open} onOpenChange={onOpenChange}>
79+
<Dialog open={open} onOpenChange={handleClose}>
6480
<DialogContent className="sm:max-w-2xl">
6581
<DialogHeader>
6682
<div className="flex items-center gap-2">
@@ -198,6 +214,22 @@ const ClientSideToolsPrerequisiteDialog: React.FC<ClientSideToolsPrerequisiteDia
198214
</div>
199215
</div>
200216
</div>
217+
218+
<Separator className="my-4" />
219+
220+
<div className="flex items-center space-x-2">
221+
<Checkbox
222+
id="remember-me"
223+
checked={rememberMe}
224+
onCheckedChange={(checked) => setRememberMe(checked === true)}
225+
/>
226+
<Label
227+
htmlFor="remember-me"
228+
className="text-sm font-normal cursor-pointer text-muted-foreground"
229+
>
230+
Don't show this again for 14 days
231+
</Label>
232+
</div>
201233
</DialogContent>
202234
</Dialog>
203235
);

0 commit comments

Comments
 (0)