Skip to content

Commit 7868b85

Browse files
authored
Merge pull request #217 from 11cafe/dev
Fix UI problems in chat textarea buttons
2 parents aaf57ce + beb8e01 commit 7868b85

8 files changed

Lines changed: 49 additions & 170 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jaaz",
3-
"version": "1.0.24",
3+
"version": "1.0.26",
44
"description": "AI design agent local desktop app",
55
"author": "weixuanfu",
66
"main": "electron/main.js",

react/src/components/chat/ChatTextarea.tsx

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,16 @@ import { ModelInfo, ToolInfo } from '@/api/model'
1414
import { useMutation } from '@tanstack/react-query'
1515
import { useDrop } from 'ahooks'
1616
import { produce } from 'immer'
17-
import { ArrowUp, Loader2, PlusIcon, Square, XIcon, RectangleVertical, ChevronDown, Hash } from 'lucide-react'
17+
import {
18+
ArrowUp,
19+
Loader2,
20+
PlusIcon,
21+
Square,
22+
XIcon,
23+
RectangleVertical,
24+
ChevronDown,
25+
Hash,
26+
} from 'lucide-react'
1827
import { AnimatePresence, motion } from 'motion/react'
1928
import Textarea, { TextAreaRef } from 'rc-textarea'
2029
import { useCallback, useEffect, useRef, useState } from 'react'
@@ -407,7 +416,7 @@ const ChatTextarea: React.FC<ChatTextareaProps> = ({
407416
/>
408417

409418
<div className="flex items-center justify-between gap-2 w-full">
410-
<div className="flex items-center gap-2 max-w-[calc(100%-50px)]">
419+
<div className="flex items-center gap-2 max-w-[calc(100%-50px)] flex-wrap">
411420
<input
412421
ref={imageInputRef}
413422
type="file"
@@ -418,7 +427,7 @@ const ChatTextarea: React.FC<ChatTextareaProps> = ({
418427
/>
419428
<Button
420429
variant="outline"
421-
size="icon"
430+
size="sm"
422431
onClick={() => imageInputRef.current?.click()}
423432
>
424433
<PlusIcon className="size-4" />
@@ -431,7 +440,8 @@ const ChatTextarea: React.FC<ChatTextareaProps> = ({
431440
<DropdownMenuTrigger asChild>
432441
<Button
433442
variant="outline"
434-
className="h-9 px-3 flex items-center gap-2"
443+
className="flex items-center gap-1"
444+
size={'sm'}
435445
>
436446
<RectangleVertical className="size-4" />
437447
<span className="text-sm">{selectedAspectRatio}</span>
@@ -458,8 +468,9 @@ const ChatTextarea: React.FC<ChatTextareaProps> = ({
458468
<div className="relative" ref={quantitySliderRef}>
459469
<Button
460470
variant="outline"
461-
className="h-9 px-3 flex items-center gap-2"
471+
className="flex items-center gap-1"
462472
onClick={() => setShowQuantitySlider(!showQuantitySlider)}
473+
size={'sm'}
463474
>
464475
<Hash className="size-4" />
465476
<span className="text-sm">{quantity}</span>
@@ -470,16 +481,20 @@ const ChatTextarea: React.FC<ChatTextareaProps> = ({
470481
<AnimatePresence>
471482
{showQuantitySlider && (
472483
<motion.div
473-
className="absolute bottom-full mb-2 left-1/2 -translate-x-1/2 bg-background border border-border rounded-lg p-4 shadow-lg min-w-48"
484+
className="absolute bottom-full mb-2 left-0 bg-background border border-border rounded-lg p-4 shadow-lg min-w-48"
474485
initial={{ opacity: 0, y: 10, scale: 0.95 }}
475486
animate={{ opacity: 1, y: 0, scale: 1 }}
476487
exit={{ opacity: 0, y: 10, scale: 0.95 }}
477488
transition={{ duration: 0.15, ease: 'easeOut' }}
478489
>
479490
<div className="flex flex-col gap-3">
480491
<div className="flex items-center justify-between">
481-
<span className="text-sm font-medium">{t('chat:textarea.quantity')}</span>
482-
<span className="text-sm text-muted-foreground">{quantity}</span>
492+
<span className="text-sm font-medium">
493+
{t('chat:textarea.quantity', 'Image Quantity')}
494+
</span>
495+
<span className="text-sm text-muted-foreground">
496+
{quantity}
497+
</span>
483498
</div>
484499
<div className="flex items-center gap-3">
485500
<span className="text-xs text-muted-foreground">1</span>
@@ -496,7 +511,9 @@ const ChatTextarea: React.FC<ChatTextareaProps> = ({
496511
[&::-moz-range-thumb]:w-4 [&::-moz-range-thumb]:h-4 [&::-moz-range-thumb]:rounded-full
497512
[&::-moz-range-thumb]:bg-primary [&::-moz-range-thumb]:cursor-pointer [&::-moz-range-thumb]:border-0"
498513
/>
499-
<span className="text-xs text-muted-foreground">{MAX_QUANTITY}</span>
514+
<span className="text-xs text-muted-foreground">
515+
{MAX_QUANTITY}
516+
</span>
500517
</div>
501518
</div>
502519
{/* Arrow pointing down */}

react/src/components/chat/ModelSelector.tsx

Lines changed: 0 additions & 151 deletions
This file was deleted.

react/src/components/chat/ModelSelectorV2.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ const ModelSelector: React.FC = () => {
116116
)
117117
}}
118118
>
119-
<SelectTrigger className="w-fit max-w-[100px] bg-background">
119+
<SelectTrigger className="w-fit max-w-[100px] bg-background" size="sm">
120120
<SelectValue placeholder="Theme" />
121121
</SelectTrigger>
122122
<SelectContent>
@@ -142,6 +142,7 @@ const ModelSelector: React.FC = () => {
142142
<DropdownMenu open={dropdownOpen} onOpenChange={setDropdownOpen}>
143143
<DropdownMenuTrigger asChild>
144144
<Button
145+
size={'sm'}
145146
variant="outline"
146147
className="w-fit max-w-[40%] bg-background justify-between overflow-hidden"
147148
>

react/src/components/chat/SessionSelector.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,13 @@ const SessionSelector: React.FC<SessionSelectorProps> = ({
3737
<SelectValue placeholder="Theme" />
3838
</SelectTrigger>
3939
<SelectContent>
40-
{sessionList?.map((session) => (
41-
<SelectItem key={session.id} value={session.id}>
42-
{session.title}
43-
</SelectItem>
44-
))}
40+
{sessionList
41+
?.filter((session) => session.id && session.id.trim() !== '') // Fix error of A ‹Select.Item /> must have a value prop that is not an empty string.
42+
?.map((session) => (
43+
<SelectItem key={session.id} value={session.id}>
44+
{session.title}
45+
</SelectItem>
46+
))}
4547
</SelectContent>
4648
</Select>
4749

react/src/i18n/locales/en/chat.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"selectModel": "Please select a text model! Go to Settings to set your API keys if you haven't done so.",
77
"selectTool": "Please go to settings to add image or video generation tools, or you won't be able to generate any images or videos!!",
88
"enterPrompt": "Please enter a prompt",
9-
"quantity": "Quantity"
9+
"quantity": "Image Quantity"
1010
},
1111
"messages": {
1212
"imagePositioning": "Go to image",

react/src/i18n/locales/zh-CN/chat.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"selectModel": "请选择一个文本模型!如果您还没有设置 API 密钥,请前往设置页面进行配置。",
77
"selectTool": "请选择一个图片模型!如果您还没有设置 API 密钥,请前往设置页面进行配置。",
88
"enterPrompt": "请输入提示内容",
9-
"quantity": "数量"
9+
"quantity": "生成数量"
1010
},
1111
"messages": {
1212
"imagePositioning": "定位到图片",

server/main.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
# Ensure stdout and stderr use utf-8 encoding to prevent emoji logs from crashing python server
55
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
66
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding="utf-8")
7+
print('Importing websocket_router')
78
from routers.websocket_router import * # DO NOT DELETE THIS LINE, OTHERWISE, WEBSOCKET WILL NOT WORK
9+
print('Importing routers')
810
from routers import config_router, image_router, root_router, workspace, canvas, ssl_test, chat_router, settings
911
from fastapi.responses import FileResponse
1012
from fastapi.staticfiles import StaticFiles
@@ -14,13 +16,19 @@
1416
from starlette.types import Scope
1517
from starlette.responses import Response
1618
import socketio # type: ignore
19+
print('Importing websocket_state')
1720
from services.websocket_state import sio
21+
print('Importing websocket_service')
1822
from services.websocket_service import broadcast_init_done
23+
print('Importing config_service')
1924
from services.config_service import config_service
25+
print('Importing tool_service')
2026
from services.tool_service import tool_service
2127

2228
async def initialize():
29+
print('Initializing config_service')
2330
await config_service.initialize()
31+
print('Initializing broadcast_init_done')
2432
await broadcast_init_done()
2533

2634
root_dir = os.path.dirname(__file__)
@@ -34,9 +42,11 @@ async def lifespan(app: FastAPI):
3442
yield
3543
# onshutdown
3644

45+
print('Creating FastAPI app')
3746
app = FastAPI(lifespan=lifespan)
3847

3948
# Include routers
49+
print('Including routers')
4050
app.include_router(config_router.router)
4151
app.include_router(settings.router)
4252
app.include_router(root_router.router)
@@ -75,7 +85,7 @@ async def serve_react_app():
7585
response.headers["Expires"] = "0"
7686
return response
7787

78-
88+
print('Creating socketio app')
7989
socket_app = socketio.ASGIApp(sio, other_asgi_app=app, socketio_path='/socket.io')
8090

8191
if __name__ == "__main__":

0 commit comments

Comments
 (0)