@townco/ui 0.1.0 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/hooks/use-chat-input.d.ts +17 -17
- package/dist/core/hooks/use-chat-input.js +64 -55
- package/dist/core/hooks/use-chat-messages.d.ts +11 -11
- package/dist/core/hooks/use-chat-messages.js +121 -114
- package/dist/core/hooks/use-chat-session.d.ts +5 -5
- package/dist/core/hooks/use-chat-session.js +78 -80
- package/dist/core/hooks/use-media-query.d.ts +5 -5
- package/dist/core/hooks/use-media-query.js +38 -38
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/schemas/chat.d.ts +83 -56
- package/dist/core/schemas/chat.js +27 -25
- package/dist/core/store/chat-store.d.ts +28 -22
- package/dist/core/store/chat-store.js +59 -50
- package/dist/gui/components/Button.d.ts +23 -7
- package/dist/gui/components/Button.js +40 -27
- package/dist/gui/components/Card.d.ts +26 -7
- package/dist/gui/components/Card.js +54 -8
- package/dist/gui/components/ChatHeader.d.ts +58 -31
- package/dist/gui/components/ChatHeader.js +171 -66
- package/dist/gui/components/ChatInput.d.ts +58 -36
- package/dist/gui/components/ChatInput.js +191 -121
- package/dist/gui/components/ChatInterface.d.ts +9 -6
- package/dist/gui/components/ChatInterface.js +162 -90
- package/dist/gui/components/ChatLayout.d.ts +71 -41
- package/dist/gui/components/ChatLayout.js +214 -87
- package/dist/gui/components/ChatPanelTabContent.d.ts +18 -9
- package/dist/gui/components/ChatPanelTabContent.js +88 -10
- package/dist/gui/components/ChatPreview.d.ts +9 -6
- package/dist/gui/components/ChatPreview.js +212 -162
- package/dist/gui/components/ChatSecondaryPanel.d.ts +14 -11
- package/dist/gui/components/ChatSecondaryPanel.js +115 -38
- package/dist/gui/components/ChatSidebar.d.ts +26 -13
- package/dist/gui/components/ChatSidebar.js +48 -14
- package/dist/gui/components/ChatStatus.d.ts +4 -2
- package/dist/gui/components/ChatStatus.js +45 -34
- package/dist/gui/components/ChatView.d.ts +5 -3
- package/dist/gui/components/ChatView.js +38 -9
- package/dist/gui/components/ConfigPanel.d.ts +16 -12
- package/dist/gui/components/ConfigPanel.js +218 -41
- package/dist/gui/components/Conversation.d.ts +17 -14
- package/dist/gui/components/Conversation.js +143 -83
- package/dist/gui/components/Dialog.d.ts +57 -11
- package/dist/gui/components/Dialog.js +84 -8
- package/dist/gui/components/DropdownMenu.d.ts +101 -20
- package/dist/gui/components/DropdownMenu.js +161 -14
- package/dist/gui/components/HeightTransition.d.ts +12 -7
- package/dist/gui/components/HeightTransition.js +88 -77
- package/dist/gui/components/Input.d.ts +13 -6
- package/dist/gui/components/Input.js +27 -16
- package/dist/gui/components/InputBox.d.ts +19 -12
- package/dist/gui/components/InputBox.js +86 -14
- package/dist/gui/components/Label.d.ts +7 -1
- package/dist/gui/components/Label.js +12 -2
- package/dist/gui/components/MarkdownRenderer.d.ts +6 -4
- package/dist/gui/components/MarkdownRenderer.js +178 -81
- package/dist/gui/components/Message.d.ts +25 -18
- package/dist/gui/components/Message.js +44 -23
- package/dist/gui/components/MessageContent.d.ts +29 -22
- package/dist/gui/components/MessageContent.js +157 -85
- package/dist/gui/components/PlaygroundLayout.d.ts +9 -5
- package/dist/gui/components/PlaygroundLayout.js +43 -12
- package/dist/gui/components/Reasoning.d.ts +30 -24
- package/dist/gui/components/Reasoning.js +187 -60
- package/dist/gui/components/Response.d.ts +11 -9
- package/dist/gui/components/Response.js +229 -90
- package/dist/gui/components/Select.d.ts +69 -10
- package/dist/gui/components/Select.js +118 -12
- package/dist/gui/components/Sonner.d.ts +3 -1
- package/dist/gui/components/Sonner.js +29 -18
- package/dist/gui/components/StatusBar.d.ts +9 -5
- package/dist/gui/components/StatusBar.js +56 -9
- package/dist/gui/components/Tabs.d.ts +24 -4
- package/dist/gui/components/Tabs.js +32 -4
- package/dist/gui/components/Task.d.ts +28 -24
- package/dist/gui/components/Task.js +164 -31
- package/dist/gui/components/Textarea.d.ts +15 -7
- package/dist/gui/components/Textarea.js +63 -46
- package/dist/gui/components/ThinkingBlock.d.ts +20 -10
- package/dist/gui/components/ThinkingBlock.js +134 -35
- package/dist/gui/components/TodoList.d.ts +12 -10
- package/dist/gui/components/TodoList.js +22 -7
- package/dist/gui/components/TodoListItem.d.ts +9 -6
- package/dist/gui/components/TodoListItem.js +18 -4
- package/dist/gui/components/index.d.ts +59 -8
- package/dist/gui/components/index.js +42 -8
- package/dist/gui/lib/utils.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.test.js +0 -1
- package/dist/sdk/client/acp-client.d.ts +88 -76
- package/dist/sdk/client/acp-client.js +215 -217
- package/dist/sdk/index.d.ts +1 -1
- package/dist/sdk/index.js +1 -1
- package/dist/sdk/schemas/agent.d.ts +111 -64
- package/dist/sdk/schemas/agent.js +24 -24
- package/dist/sdk/schemas/message.d.ts +245 -147
- package/dist/sdk/schemas/message.js +40 -40
- package/dist/sdk/schemas/session.d.ts +219 -135
- package/dist/sdk/schemas/session.js +27 -27
- package/dist/sdk/transports/http.d.ts +55 -55
- package/dist/sdk/transports/http.js +472 -469
- package/dist/sdk/transports/stdio.d.ts +20 -20
- package/dist/sdk/transports/stdio.js +289 -286
- package/dist/sdk/transports/types.d.ts +42 -42
- package/dist/sdk/transports/websocket.d.ts +12 -12
- package/dist/sdk/transports/websocket.js +52 -46
- package/dist/tui/components/ChatView.d.ts +4 -2
- package/dist/tui/components/ChatView.js +51 -18
- package/dist/tui/components/GameOfLife.js +64 -35
- package/dist/tui/components/InputBox.d.ts +18 -11
- package/dist/tui/components/InputBox.js +70 -10
- package/dist/tui/components/MessageList.d.ts +4 -2
- package/dist/tui/components/MessageList.js +37 -10
- package/dist/tui/components/MultiSelect.d.ts +15 -9
- package/dist/tui/components/MultiSelect.js +116 -69
- package/dist/tui/components/ReadlineInput.d.ts +12 -6
- package/dist/tui/components/ReadlineInput.js +252 -237
- package/dist/tui/components/SingleSelect.d.ts +15 -9
- package/dist/tui/components/SingleSelect.js +84 -43
- package/dist/tui/components/StatusBar.d.ts +11 -6
- package/dist/tui/components/StatusBar.js +102 -67
- package/dist/tui/index.d.ts +1 -1
- package/dist/tui/index.js +1 -1
- package/package.json +2 -3
|
@@ -19,62 +19,62 @@ import { useEffect, useState } from "react";
|
|
|
19
19
|
* ```
|
|
20
20
|
*/
|
|
21
21
|
export function useMediaQuery(query) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
22
|
+
const [matches, setMatches] = useState(() => {
|
|
23
|
+
// SSR-safe: return false on server, check on client
|
|
24
|
+
if (typeof window === "undefined") {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
return window.matchMedia(query).matches;
|
|
28
|
+
});
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
// SSR guard
|
|
31
|
+
if (typeof window === "undefined") {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const mediaQueryList = window.matchMedia(query);
|
|
35
|
+
// Update state if query evaluation changes
|
|
36
|
+
const handleChange = (event) => {
|
|
37
|
+
setMatches(event.matches);
|
|
38
|
+
};
|
|
39
|
+
// Set initial value
|
|
40
|
+
setMatches(mediaQueryList.matches);
|
|
41
|
+
// Listen for changes
|
|
42
|
+
mediaQueryList.addEventListener("change", handleChange);
|
|
43
|
+
// Cleanup
|
|
44
|
+
return () => {
|
|
45
|
+
mediaQueryList.removeEventListener("change", handleChange);
|
|
46
|
+
};
|
|
47
|
+
}, [query]);
|
|
48
|
+
return matches;
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
51
|
* Common breakpoint presets for convenience
|
|
52
52
|
*/
|
|
53
53
|
export const breakpoints = {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
sm: "(min-width: 640px)",
|
|
55
|
+
md: "(min-width: 768px)",
|
|
56
|
+
lg: "(min-width: 1024px)",
|
|
57
|
+
xl: "(min-width: 1280px)",
|
|
58
|
+
"2xl": "(min-width: 1536px)",
|
|
59
59
|
};
|
|
60
60
|
/**
|
|
61
61
|
* Convenience hooks for common breakpoints
|
|
62
62
|
*/
|
|
63
63
|
export function useIsSmallScreen() {
|
|
64
|
-
|
|
64
|
+
return useMediaQuery("(max-width: 639px)");
|
|
65
65
|
}
|
|
66
66
|
export function useIsMediumScreen() {
|
|
67
|
-
|
|
67
|
+
return useMediaQuery(breakpoints.md);
|
|
68
68
|
}
|
|
69
69
|
export function useIsLargeScreen() {
|
|
70
|
-
|
|
70
|
+
return useMediaQuery(breakpoints.lg);
|
|
71
71
|
}
|
|
72
72
|
export function useIsDesktop() {
|
|
73
|
-
|
|
73
|
+
return useMediaQuery(breakpoints.lg);
|
|
74
74
|
}
|
|
75
75
|
export function useIsMobile() {
|
|
76
|
-
|
|
76
|
+
return useMediaQuery("(max-width: 767px)");
|
|
77
77
|
}
|
|
78
78
|
export function useIsTablet() {
|
|
79
|
-
|
|
79
|
+
return useMediaQuery("(min-width: 768px) and (max-width: 1023px)");
|
|
80
80
|
}
|
package/dist/core/index.d.ts
CHANGED
package/dist/core/index.js
CHANGED
|
@@ -5,74 +5,101 @@ import { z } from "zod";
|
|
|
5
5
|
/**
|
|
6
6
|
* Display message schema (UI representation of messages)
|
|
7
7
|
*/
|
|
8
|
-
export declare const DisplayMessage: z.ZodObject<
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
8
|
+
export declare const DisplayMessage: z.ZodObject<
|
|
9
|
+
{
|
|
10
|
+
id: z.ZodString;
|
|
11
|
+
role: z.ZodEnum<{
|
|
12
|
+
user: "user";
|
|
13
|
+
assistant: "assistant";
|
|
14
|
+
system: "system";
|
|
15
|
+
}>;
|
|
16
|
+
content: z.ZodString;
|
|
17
|
+
timestamp: z.ZodISODateTime;
|
|
18
|
+
isStreaming: z.ZodDefault<z.ZodBoolean>;
|
|
19
|
+
streamingStartTime: z.ZodOptional<z.ZodNumber>;
|
|
20
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
21
|
+
},
|
|
22
|
+
z.core.$strip
|
|
23
|
+
>;
|
|
21
24
|
export type DisplayMessage = z.infer<typeof DisplayMessage>;
|
|
22
25
|
/**
|
|
23
26
|
* Input state schema
|
|
24
27
|
*/
|
|
25
|
-
export declare const InputState: z.ZodObject<
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
export declare const InputState: z.ZodObject<
|
|
29
|
+
{
|
|
30
|
+
value: z.ZodString;
|
|
31
|
+
isSubmitting: z.ZodBoolean;
|
|
32
|
+
attachedFiles: z.ZodArray<
|
|
33
|
+
z.ZodObject<
|
|
34
|
+
{
|
|
35
|
+
name: z.ZodString;
|
|
36
|
+
path: z.ZodString;
|
|
37
|
+
size: z.ZodNumber;
|
|
38
|
+
mimeType: z.ZodString;
|
|
39
|
+
},
|
|
40
|
+
z.core.$strip
|
|
41
|
+
>
|
|
42
|
+
>;
|
|
43
|
+
},
|
|
44
|
+
z.core.$strip
|
|
45
|
+
>;
|
|
35
46
|
export type InputState = z.infer<typeof InputState>;
|
|
36
47
|
/**
|
|
37
48
|
* Chat session UI state
|
|
38
49
|
*/
|
|
39
|
-
export declare const ChatSessionState: z.ZodObject<
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
50
|
+
export declare const ChatSessionState: z.ZodObject<
|
|
51
|
+
{
|
|
52
|
+
sessionId: z.ZodNullable<z.ZodString>;
|
|
53
|
+
isConnected: z.ZodBoolean;
|
|
54
|
+
isStreaming: z.ZodBoolean;
|
|
55
|
+
messages: z.ZodArray<
|
|
56
|
+
z.ZodObject<
|
|
57
|
+
{
|
|
58
|
+
id: z.ZodString;
|
|
59
|
+
role: z.ZodEnum<{
|
|
60
|
+
user: "user";
|
|
61
|
+
assistant: "assistant";
|
|
62
|
+
system: "system";
|
|
63
|
+
}>;
|
|
64
|
+
content: z.ZodString;
|
|
65
|
+
timestamp: z.ZodISODateTime;
|
|
66
|
+
isStreaming: z.ZodDefault<z.ZodBoolean>;
|
|
67
|
+
streamingStartTime: z.ZodOptional<z.ZodNumber>;
|
|
68
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
69
|
+
},
|
|
70
|
+
z.core.$strip
|
|
71
|
+
>
|
|
72
|
+
>;
|
|
73
|
+
input: z.ZodObject<
|
|
74
|
+
{
|
|
75
|
+
value: z.ZodString;
|
|
76
|
+
isSubmitting: z.ZodBoolean;
|
|
77
|
+
attachedFiles: z.ZodArray<
|
|
78
|
+
z.ZodObject<
|
|
79
|
+
{
|
|
80
|
+
name: z.ZodString;
|
|
81
|
+
path: z.ZodString;
|
|
82
|
+
size: z.ZodNumber;
|
|
83
|
+
mimeType: z.ZodString;
|
|
84
|
+
},
|
|
85
|
+
z.core.$strip
|
|
86
|
+
>
|
|
87
|
+
>;
|
|
88
|
+
},
|
|
89
|
+
z.core.$strip
|
|
90
|
+
>;
|
|
91
|
+
error: z.ZodNullable<z.ZodString>;
|
|
92
|
+
},
|
|
93
|
+
z.core.$strip
|
|
94
|
+
>;
|
|
68
95
|
export type ChatSessionState = z.infer<typeof ChatSessionState>;
|
|
69
96
|
/**
|
|
70
97
|
* Connection status
|
|
71
98
|
*/
|
|
72
99
|
export declare const ConnectionStatus: z.ZodEnum<{
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
100
|
+
error: "error";
|
|
101
|
+
disconnected: "disconnected";
|
|
102
|
+
connecting: "connecting";
|
|
103
|
+
connected: "connected";
|
|
77
104
|
}>;
|
|
78
105
|
export type ConnectionStatus = z.infer<typeof ConnectionStatus>;
|
|
@@ -6,44 +6,46 @@ import { z } from "zod";
|
|
|
6
6
|
* Display message schema (UI representation of messages)
|
|
7
7
|
*/
|
|
8
8
|
export const DisplayMessage = z.object({
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
id: z.string(),
|
|
10
|
+
role: z.enum(["user", "assistant", "system"]),
|
|
11
|
+
content: z.string(),
|
|
12
|
+
timestamp: z.iso.datetime(),
|
|
13
|
+
isStreaming: z.boolean().default(false),
|
|
14
|
+
streamingStartTime: z.number().optional(), // Unix timestamp when streaming started
|
|
15
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
16
16
|
});
|
|
17
17
|
/**
|
|
18
18
|
* Input state schema
|
|
19
19
|
*/
|
|
20
20
|
export const InputState = z.object({
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
value: z.string(),
|
|
22
|
+
isSubmitting: z.boolean(),
|
|
23
|
+
attachedFiles: z.array(
|
|
24
|
+
z.object({
|
|
25
|
+
name: z.string(),
|
|
26
|
+
path: z.string(),
|
|
27
|
+
size: z.number(),
|
|
28
|
+
mimeType: z.string(),
|
|
29
|
+
}),
|
|
30
|
+
),
|
|
29
31
|
});
|
|
30
32
|
/**
|
|
31
33
|
* Chat session UI state
|
|
32
34
|
*/
|
|
33
35
|
export const ChatSessionState = z.object({
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
sessionId: z.string().nullable(),
|
|
37
|
+
isConnected: z.boolean(),
|
|
38
|
+
isStreaming: z.boolean(),
|
|
39
|
+
messages: z.array(DisplayMessage),
|
|
40
|
+
input: InputState,
|
|
41
|
+
error: z.string().nullable(),
|
|
40
42
|
});
|
|
41
43
|
/**
|
|
42
44
|
* Connection status
|
|
43
45
|
*/
|
|
44
46
|
export const ConnectionStatus = z.enum([
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
"disconnected",
|
|
48
|
+
"connecting",
|
|
49
|
+
"connected",
|
|
50
|
+
"error",
|
|
49
51
|
]);
|
|
@@ -1,30 +1,36 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
ConnectionStatus,
|
|
3
|
+
DisplayMessage,
|
|
4
|
+
InputState,
|
|
5
|
+
} from "../schemas/index.js";
|
|
2
6
|
/**
|
|
3
7
|
* Chat store state
|
|
4
8
|
*/
|
|
5
9
|
export interface ChatStore {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
10
|
+
connectionStatus: ConnectionStatus;
|
|
11
|
+
sessionId: string | null;
|
|
12
|
+
error: string | null;
|
|
13
|
+
messages: DisplayMessage[];
|
|
14
|
+
isStreaming: boolean;
|
|
15
|
+
streamingStartTime: number | null;
|
|
16
|
+
input: InputState;
|
|
17
|
+
setConnectionStatus: (status: ConnectionStatus) => void;
|
|
18
|
+
setSessionId: (id: string | null) => void;
|
|
19
|
+
setError: (error: string | null) => void;
|
|
20
|
+
addMessage: (message: DisplayMessage) => void;
|
|
21
|
+
updateMessage: (id: string, updates: Partial<DisplayMessage>) => void;
|
|
22
|
+
clearMessages: () => void;
|
|
23
|
+
setIsStreaming: (streaming: boolean) => void;
|
|
24
|
+
setStreamingStartTime: (time: number | null) => void;
|
|
25
|
+
setInputValue: (value: string) => void;
|
|
26
|
+
setInputSubmitting: (submitting: boolean) => void;
|
|
27
|
+
addFileAttachment: (file: InputState["attachedFiles"][number]) => void;
|
|
28
|
+
removeFileAttachment: (index: number) => void;
|
|
29
|
+
clearInput: () => void;
|
|
26
30
|
}
|
|
27
31
|
/**
|
|
28
32
|
* Create chat store
|
|
29
33
|
*/
|
|
30
|
-
export declare const useChatStore: import("zustand").UseBoundStore<
|
|
34
|
+
export declare const useChatStore: import("zustand").UseBoundStore<
|
|
35
|
+
import("zustand").StoreApi<ChatStore>
|
|
36
|
+
>;
|
|
@@ -3,54 +3,63 @@ import { create } from "zustand";
|
|
|
3
3
|
* Create chat store
|
|
4
4
|
*/
|
|
5
5
|
export const useChatStore = create((set) => ({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
6
|
+
// Initial state
|
|
7
|
+
connectionStatus: "disconnected",
|
|
8
|
+
sessionId: null,
|
|
9
|
+
error: null,
|
|
10
|
+
messages: [],
|
|
11
|
+
isStreaming: false,
|
|
12
|
+
streamingStartTime: null,
|
|
13
|
+
input: {
|
|
14
|
+
value: "",
|
|
15
|
+
isSubmitting: false,
|
|
16
|
+
attachedFiles: [],
|
|
17
|
+
},
|
|
18
|
+
// Actions
|
|
19
|
+
setConnectionStatus: (status) => set({ connectionStatus: status }),
|
|
20
|
+
setSessionId: (id) => set({ sessionId: id }),
|
|
21
|
+
setError: (error) => set({ error }),
|
|
22
|
+
addMessage: (message) =>
|
|
23
|
+
set((state) => ({
|
|
24
|
+
messages: [...state.messages, message],
|
|
25
|
+
})),
|
|
26
|
+
updateMessage: (id, updates) =>
|
|
27
|
+
set((state) => ({
|
|
28
|
+
messages: state.messages.map((msg) =>
|
|
29
|
+
msg.id === id ? { ...msg, ...updates } : msg,
|
|
30
|
+
),
|
|
31
|
+
})),
|
|
32
|
+
clearMessages: () => set({ messages: [] }),
|
|
33
|
+
setIsStreaming: (streaming) => set({ isStreaming: streaming }),
|
|
34
|
+
setStreamingStartTime: (time) => set({ streamingStartTime: time }),
|
|
35
|
+
setInputValue: (value) =>
|
|
36
|
+
set((state) => ({
|
|
37
|
+
input: { ...state.input, value },
|
|
38
|
+
})),
|
|
39
|
+
setInputSubmitting: (submitting) =>
|
|
40
|
+
set((state) => ({
|
|
41
|
+
input: { ...state.input, isSubmitting: submitting },
|
|
42
|
+
})),
|
|
43
|
+
addFileAttachment: (file) =>
|
|
44
|
+
set((state) => ({
|
|
45
|
+
input: {
|
|
46
|
+
...state.input,
|
|
47
|
+
attachedFiles: [...state.input.attachedFiles, file],
|
|
48
|
+
},
|
|
49
|
+
})),
|
|
50
|
+
removeFileAttachment: (index) =>
|
|
51
|
+
set((state) => ({
|
|
52
|
+
input: {
|
|
53
|
+
...state.input,
|
|
54
|
+
attachedFiles: state.input.attachedFiles.filter((_, i) => i !== index),
|
|
55
|
+
},
|
|
56
|
+
})),
|
|
57
|
+
clearInput: () =>
|
|
58
|
+
set((_state) => ({
|
|
59
|
+
input: {
|
|
60
|
+
value: "",
|
|
61
|
+
isSubmitting: false,
|
|
62
|
+
attachedFiles: [],
|
|
63
|
+
},
|
|
64
|
+
})),
|
|
56
65
|
}));
|
|
@@ -1,11 +1,27 @@
|
|
|
1
1
|
import { type VariantProps } from "class-variance-authority";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
declare const buttonVariants: (
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
declare const buttonVariants: (
|
|
4
|
+
props?:
|
|
5
|
+
| ({
|
|
6
|
+
variant?:
|
|
7
|
+
| "default"
|
|
8
|
+
| "destructive"
|
|
9
|
+
| "outline"
|
|
10
|
+
| "secondary"
|
|
11
|
+
| "ghost"
|
|
12
|
+
| "link"
|
|
13
|
+
| null
|
|
14
|
+
| undefined;
|
|
15
|
+
size?: "default" | "sm" | "lg" | "icon" | null | undefined;
|
|
16
|
+
} & import("class-variance-authority/types").ClassProp)
|
|
17
|
+
| undefined,
|
|
18
|
+
) => string;
|
|
19
|
+
export interface ButtonProps
|
|
20
|
+
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
|
21
|
+
VariantProps<typeof buttonVariants> {
|
|
22
|
+
asChild?: boolean;
|
|
9
23
|
}
|
|
10
|
-
declare const Button: React.ForwardRefExoticComponent<
|
|
24
|
+
declare const Button: React.ForwardRefExoticComponent<
|
|
25
|
+
ButtonProps & React.RefAttributes<HTMLButtonElement>
|
|
26
|
+
>;
|
|
11
27
|
export { Button, buttonVariants };
|
|
@@ -1,33 +1,46 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
1
|
import { Slot } from "@radix-ui/react-slot";
|
|
3
2
|
import { cva } from "class-variance-authority";
|
|
4
3
|
import * as React from "react";
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
5
|
import { cn } from "../lib/utils.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
6
|
+
|
|
7
|
+
const buttonVariants = cva(
|
|
8
|
+
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
|
9
|
+
{
|
|
10
|
+
variants: {
|
|
11
|
+
variant: {
|
|
12
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
13
|
+
destructive:
|
|
14
|
+
"bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
15
|
+
outline:
|
|
16
|
+
"border border-input bg-background hover:bg-accent hover:text-accent-foreground",
|
|
17
|
+
secondary:
|
|
18
|
+
"bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
19
|
+
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
20
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
21
|
+
},
|
|
22
|
+
size: {
|
|
23
|
+
default: "h-10 px-4 py-2",
|
|
24
|
+
sm: "h-9 rounded-md px-3",
|
|
25
|
+
lg: "h-11 rounded-md px-8",
|
|
26
|
+
icon: "h-10 w-10",
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
defaultVariants: {
|
|
30
|
+
variant: "default",
|
|
31
|
+
size: "default",
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
);
|
|
35
|
+
const Button = React.forwardRef(
|
|
36
|
+
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
37
|
+
const Comp = asChild ? Slot : "button";
|
|
38
|
+
return _jsx(Comp, {
|
|
39
|
+
className: cn(buttonVariants({ variant, size, className })),
|
|
40
|
+
ref: ref,
|
|
41
|
+
...props,
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
);
|
|
32
45
|
Button.displayName = "Button";
|
|
33
46
|
export { Button, buttonVariants };
|