Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion web-app/src/containers/DropdownAssistant.tsx
Original file line number Diff line number Diff line change
@@ -1,100 +1,100 @@
import { useState } from 'react'
import {

Check warning on line 2 in web-app/src/containers/DropdownAssistant.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

1-2 lines are not covered with tests
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from '@/components/ui/dropdown-menu'
import { useAssistant } from '@/hooks/useAssistant'
import AddEditAssistant from './dialogs/AddEditAssistant'
import { IconCirclePlus, IconSettings } from '@tabler/icons-react'
import { useThreads } from '@/hooks/useThreads'
import { AvatarEmoji } from '@/containers/AvatarEmoji'

Check warning on line 13 in web-app/src/containers/DropdownAssistant.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

9-13 lines are not covered with tests

const DropdownAssistant = () => {
const {
assistants,
currentAssistant,
addAssistant,
updateAssistant,
setCurrentAssistant,
} = useAssistant()
const { updateCurrentThreadAssistant } = useThreads()
const [dropdownOpen, setDropdownOpen] = useState(false)
const [dialogOpen, setDialogOpen] = useState(false)
const [editingAssistantId, setEditingAssistantId] = useState<string | null>(
null
)

Check warning on line 28 in web-app/src/containers/DropdownAssistant.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

15-28 lines are not covered with tests

const selectedAssistant =
assistants.find((a) => a.id === currentAssistant.id) || assistants[0]

Check warning on line 31 in web-app/src/containers/DropdownAssistant.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

30-31 lines are not covered with tests

return (
<>
<DropdownMenu open={dropdownOpen} onOpenChange={setDropdownOpen}>
<div className="flex items-center justify-between gap-2 bg-main-view-fg/5 py-1 hover:bg-main-view-fg/8 px-2 rounded-sm">
<DropdownMenuTrigger asChild>
<button className="font-medium cursor-pointer flex items-center gap-1.5 relative z-20 max-w-40">
<div className="text-main-view-fg/80 flex items-center gap-1">
{selectedAssistant?.avatar && (
<span className="shrink-0 w-4 h-4 relative flex items-center justify-center">
<AvatarEmoji
avatar={selectedAssistant.avatar}
imageClassName="object-cover"
textClassName="text-sm"
/>
</span>

Check warning on line 47 in web-app/src/containers/DropdownAssistant.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

33-47 lines are not covered with tests
)}
<div className="truncate max-w-30">
<span>{selectedAssistant?.name || 'Jan'}</span>
</div>
</div>
</button>
</DropdownMenuTrigger>
<div
className="size-5 cursor-pointer relative z-10 flex items-center justify-center rounded hover:bg-main-view-fg/10 transition-all duration-200 ease-in-out "
onClick={() => {
if (selectedAssistant) {
setEditingAssistantId(selectedAssistant.id)
setDialogOpen(true)
}
}}

Check warning on line 62 in web-app/src/containers/DropdownAssistant.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

49-62 lines are not covered with tests
>
<IconSettings
size={16}
className="text-main-view-fg/50"
title="Edit Assistant"
/>
</div>
</div>
<DropdownMenuContent
className="w-44 max-h-[320px]"
side="bottom"
sideOffset={10}
align="start"

Check warning on line 75 in web-app/src/containers/DropdownAssistant.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

64-75 lines are not covered with tests
>
{assistants.map((assistant) => (
<div
className="relative pr-6 hover:bg-main-view-fg/4 rounded-sm"
key={assistant.id}

Check warning on line 80 in web-app/src/containers/DropdownAssistant.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

77-80 lines are not covered with tests
>
<DropdownMenuItem className="hover:bg-transparent">
<div
className="text-main-view-fg/70 cursor-pointer flex gap-2"
className="text-main-view-fg/70 cursor-pointer flex gap-2 w-full"
onClick={() => {
setCurrentAssistant(assistant)
updateCurrentThreadAssistant(assistant)
}}

Check warning on line 88 in web-app/src/containers/DropdownAssistant.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

82-88 lines are not covered with tests
>
{assistant?.avatar && (
<div className="shrink-0 relative w-4 h-4">
<AvatarEmoji
avatar={assistant?.avatar}
imageClassName="object-cover"
textClassName=""
/>
</div>

Check warning on line 97 in web-app/src/containers/DropdownAssistant.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

90-97 lines are not covered with tests
)}

<div className="text-left">
Expand Down
18 changes: 17 additions & 1 deletion web-app/src/containers/dialogs/AddEditAssistant.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export default function AddEditAssistant({
const [paramsTypes, setParamsTypes] = useState<string[]>(['string'])
const [showEmojiPicker, setShowEmojiPicker] = useState(false)
const emojiPickerRef = useRef<HTMLDivElement>(null)
const [nameError, setNameError] = useState<string | null>(null)

// Handle click outside emoji picker
useEffect(() => {
Expand Down Expand Up @@ -118,6 +119,7 @@ export default function AddEditAssistant({
setParamsKeys([''])
setParamsValues([''])
setParamsTypes(['string'])
setNameError(null)
}

const handleParameterChange = (
Expand Down Expand Up @@ -193,6 +195,11 @@ export default function AddEditAssistant({
}

const handleSave = () => {
if (!name.trim()) {
setNameError(t('assistants:nameRequired'))
return
}
setNameError(null)
// Convert parameters arrays to object
const parameters: Record<string, unknown> = {}
paramsKeys.forEach((key, index) => {
Expand Down Expand Up @@ -275,13 +282,22 @@ export default function AddEditAssistant({
</label>
<Input
value={name}
onChange={(e) => setName(e.target.value)}
onChange={(e) => {
setName(e.target.value)
if (e.target.value.trim()) setNameError(null)
}}
placeholder={t('assistants:enterName')}
autoFocus
/>
</div>
</div>

{nameError && (
<div className="ml-12 text-xs text-destructive mt-1">
{nameError}
</div>
)}

<div className="space-y-2">
<label className="text-sm mb-2 inline-block">
{t('assistants:description')}
Expand Down
1 change: 1 addition & 0 deletions web-app/src/locales/de-DE/assistants.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"emoji": "Emoji",
"name": "Name",
"enterName": "Namen eingeben",
"nameRequired": "Name ist erforderlich",
"description": "Beschreibung (optional)",
"enterDescription": "Beschreibung eingeben",
"instructions": "Anweisungen",
Expand Down
3 changes: 2 additions & 1 deletion web-app/src/locales/en/assistants.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"emoji": "Emoji",
"name": "Name",
"enterName": "Enter name",
"nameRequired": "Name is required",
"description": "Description (optional)",
"enterDescription": "Enter description",
"instructions": "Instructions",
Expand All @@ -29,4 +30,4 @@
"createNew": "Create New Assistant",
"personality": "Personality",
"capabilities": "Capabilities"
}
}
3 changes: 2 additions & 1 deletion web-app/src/locales/id/assistants.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"emoji": "Emoji",
"name": "Nama",
"enterName": "Masukkan nama",
"nameRequired": "Nama wajib diisi",
"description": "Deskripsi (opsional)",
"enterDescription": "Masukkan deskripsi",
"instructions": "Instruksi",
Expand All @@ -29,4 +30,4 @@
"createNew": "Buat Asisten Baru",
"personality": "Kepribadian",
"capabilities": "Kemampuan"
}
}
3 changes: 2 additions & 1 deletion web-app/src/locales/vn/assistants.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"emoji": "Biểu tượng",
"name": "Tên",
"enterName": "Nhập tên",
"nameRequired": "Tên là bắt buộc",
"description": "Mô tả (tùy chọn)",
"enterDescription": "Nhập mô tả",
"instructions": "Hướng dẫn",
Expand All @@ -29,4 +30,4 @@
"createNew": "Tạo Trợ lý Mới",
"personality": "Tính cách",
"capabilities": "Khả năng"
}
}
3 changes: 2 additions & 1 deletion web-app/src/locales/zh-CN/assistants.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"emoji": "表情符号",
"name": "名称",
"enterName": "输入名称",
"nameRequired": "名称为必填项",
"description": "描述(可选)",
"enterDescription": "输入描述",
"instructions": "说明",
Expand All @@ -29,4 +30,4 @@
"createNew": "创建新助手",
"personality": "个性",
"capabilities": "能力"
}
}
3 changes: 2 additions & 1 deletion web-app/src/locales/zh-TW/assistants.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"emoji": "表情符號",
"name": "名稱",
"enterName": "輸入名稱",
"nameRequired": "名稱為必填項",
"description": "描述(可選)",
"enterDescription": "輸入描述",
"instructions": "指示",
Expand All @@ -29,4 +30,4 @@
"createNew": "建立新助理",
"personality": "個性",
"capabilities": "能力"
}
}
Loading