@townco/ui 0.1.0 → 0.1.6

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.
Files changed (125) hide show
  1. package/dist/core/hooks/use-chat-input.d.ts +17 -17
  2. package/dist/core/hooks/use-chat-input.js +64 -55
  3. package/dist/core/hooks/use-chat-messages.d.ts +11 -11
  4. package/dist/core/hooks/use-chat-messages.js +121 -114
  5. package/dist/core/hooks/use-chat-session.d.ts +5 -5
  6. package/dist/core/hooks/use-chat-session.js +78 -80
  7. package/dist/core/hooks/use-media-query.d.ts +5 -5
  8. package/dist/core/hooks/use-media-query.js +38 -38
  9. package/dist/core/index.d.ts +1 -1
  10. package/dist/core/index.js +1 -1
  11. package/dist/core/schemas/chat.d.ts +83 -56
  12. package/dist/core/schemas/chat.js +27 -25
  13. package/dist/core/store/chat-store.d.ts +28 -22
  14. package/dist/core/store/chat-store.js +59 -50
  15. package/dist/gui/components/Button.d.ts +23 -7
  16. package/dist/gui/components/Button.js +40 -27
  17. package/dist/gui/components/Card.d.ts +26 -7
  18. package/dist/gui/components/Card.js +54 -8
  19. package/dist/gui/components/ChatHeader.d.ts +58 -31
  20. package/dist/gui/components/ChatHeader.js +171 -66
  21. package/dist/gui/components/ChatInput.d.ts +58 -36
  22. package/dist/gui/components/ChatInput.js +191 -121
  23. package/dist/gui/components/ChatInterface.d.ts +9 -6
  24. package/dist/gui/components/ChatInterface.js +162 -90
  25. package/dist/gui/components/ChatLayout.d.ts +71 -41
  26. package/dist/gui/components/ChatLayout.js +214 -87
  27. package/dist/gui/components/ChatPanelTabContent.d.ts +18 -9
  28. package/dist/gui/components/ChatPanelTabContent.js +88 -10
  29. package/dist/gui/components/ChatPreview.d.ts +9 -6
  30. package/dist/gui/components/ChatPreview.js +212 -162
  31. package/dist/gui/components/ChatSecondaryPanel.d.ts +14 -11
  32. package/dist/gui/components/ChatSecondaryPanel.js +115 -38
  33. package/dist/gui/components/ChatSidebar.d.ts +26 -13
  34. package/dist/gui/components/ChatSidebar.js +48 -14
  35. package/dist/gui/components/ChatStatus.d.ts +4 -2
  36. package/dist/gui/components/ChatStatus.js +45 -34
  37. package/dist/gui/components/ChatView.d.ts +5 -3
  38. package/dist/gui/components/ChatView.js +38 -9
  39. package/dist/gui/components/ConfigPanel.d.ts +16 -12
  40. package/dist/gui/components/ConfigPanel.js +218 -41
  41. package/dist/gui/components/Conversation.d.ts +17 -14
  42. package/dist/gui/components/Conversation.js +143 -83
  43. package/dist/gui/components/Dialog.d.ts +57 -11
  44. package/dist/gui/components/Dialog.js +84 -8
  45. package/dist/gui/components/DropdownMenu.d.ts +101 -20
  46. package/dist/gui/components/DropdownMenu.js +161 -14
  47. package/dist/gui/components/HeightTransition.d.ts +12 -7
  48. package/dist/gui/components/HeightTransition.js +88 -77
  49. package/dist/gui/components/Input.d.ts +13 -6
  50. package/dist/gui/components/Input.js +27 -16
  51. package/dist/gui/components/InputBox.d.ts +19 -12
  52. package/dist/gui/components/InputBox.js +86 -14
  53. package/dist/gui/components/Label.d.ts +7 -1
  54. package/dist/gui/components/Label.js +12 -2
  55. package/dist/gui/components/MarkdownRenderer.d.ts +6 -4
  56. package/dist/gui/components/MarkdownRenderer.js +178 -81
  57. package/dist/gui/components/Message.d.ts +25 -18
  58. package/dist/gui/components/Message.js +44 -23
  59. package/dist/gui/components/MessageContent.d.ts +29 -22
  60. package/dist/gui/components/MessageContent.js +157 -85
  61. package/dist/gui/components/PlaygroundLayout.d.ts +9 -5
  62. package/dist/gui/components/PlaygroundLayout.js +43 -12
  63. package/dist/gui/components/Reasoning.d.ts +30 -24
  64. package/dist/gui/components/Reasoning.js +187 -60
  65. package/dist/gui/components/Response.d.ts +11 -9
  66. package/dist/gui/components/Response.js +229 -90
  67. package/dist/gui/components/Select.d.ts +69 -10
  68. package/dist/gui/components/Select.js +118 -12
  69. package/dist/gui/components/Sonner.d.ts +3 -1
  70. package/dist/gui/components/Sonner.js +29 -18
  71. package/dist/gui/components/StatusBar.d.ts +9 -5
  72. package/dist/gui/components/StatusBar.js +56 -9
  73. package/dist/gui/components/Tabs.d.ts +24 -4
  74. package/dist/gui/components/Tabs.js +32 -4
  75. package/dist/gui/components/Task.d.ts +28 -24
  76. package/dist/gui/components/Task.js +164 -31
  77. package/dist/gui/components/Textarea.d.ts +15 -7
  78. package/dist/gui/components/Textarea.js +63 -46
  79. package/dist/gui/components/ThinkingBlock.d.ts +20 -10
  80. package/dist/gui/components/ThinkingBlock.js +134 -35
  81. package/dist/gui/components/TodoList.d.ts +12 -10
  82. package/dist/gui/components/TodoList.js +22 -7
  83. package/dist/gui/components/TodoListItem.d.ts +9 -6
  84. package/dist/gui/components/TodoListItem.js +18 -4
  85. package/dist/gui/components/index.d.ts +59 -8
  86. package/dist/gui/components/index.js +42 -8
  87. package/dist/gui/lib/utils.js +1 -1
  88. package/dist/index.d.ts +1 -1
  89. package/dist/index.js +1 -1
  90. package/dist/index.test.js +0 -1
  91. package/dist/sdk/client/acp-client.d.ts +88 -76
  92. package/dist/sdk/client/acp-client.js +215 -217
  93. package/dist/sdk/index.d.ts +1 -1
  94. package/dist/sdk/index.js +1 -1
  95. package/dist/sdk/schemas/agent.d.ts +111 -64
  96. package/dist/sdk/schemas/agent.js +24 -24
  97. package/dist/sdk/schemas/message.d.ts +245 -147
  98. package/dist/sdk/schemas/message.js +40 -40
  99. package/dist/sdk/schemas/session.d.ts +219 -135
  100. package/dist/sdk/schemas/session.js +27 -27
  101. package/dist/sdk/transports/http.d.ts +55 -55
  102. package/dist/sdk/transports/http.js +472 -469
  103. package/dist/sdk/transports/stdio.d.ts +20 -20
  104. package/dist/sdk/transports/stdio.js +289 -286
  105. package/dist/sdk/transports/types.d.ts +42 -42
  106. package/dist/sdk/transports/websocket.d.ts +12 -12
  107. package/dist/sdk/transports/websocket.js +52 -46
  108. package/dist/tui/components/ChatView.d.ts +4 -2
  109. package/dist/tui/components/ChatView.js +51 -18
  110. package/dist/tui/components/GameOfLife.js +64 -35
  111. package/dist/tui/components/InputBox.d.ts +18 -11
  112. package/dist/tui/components/InputBox.js +70 -10
  113. package/dist/tui/components/MessageList.d.ts +4 -2
  114. package/dist/tui/components/MessageList.js +37 -10
  115. package/dist/tui/components/MultiSelect.d.ts +15 -9
  116. package/dist/tui/components/MultiSelect.js +116 -69
  117. package/dist/tui/components/ReadlineInput.d.ts +12 -6
  118. package/dist/tui/components/ReadlineInput.js +252 -237
  119. package/dist/tui/components/SingleSelect.d.ts +15 -9
  120. package/dist/tui/components/SingleSelect.js +84 -43
  121. package/dist/tui/components/StatusBar.d.ts +11 -6
  122. package/dist/tui/components/StatusBar.js +102 -67
  123. package/dist/tui/index.d.ts +1 -1
  124. package/dist/tui/index.js +1 -1
  125. 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
- 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;
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
- sm: "(min-width: 640px)",
55
- md: "(min-width: 768px)",
56
- lg: "(min-width: 1024px)",
57
- xl: "(min-width: 1280px)",
58
- "2xl": "(min-width: 1536px)",
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
- return useMediaQuery("(max-width: 639px)");
64
+ return useMediaQuery("(max-width: 639px)");
65
65
  }
66
66
  export function useIsMediumScreen() {
67
- return useMediaQuery(breakpoints.md);
67
+ return useMediaQuery(breakpoints.md);
68
68
  }
69
69
  export function useIsLargeScreen() {
70
- return useMediaQuery(breakpoints.lg);
70
+ return useMediaQuery(breakpoints.lg);
71
71
  }
72
72
  export function useIsDesktop() {
73
- return useMediaQuery(breakpoints.lg);
73
+ return useMediaQuery(breakpoints.lg);
74
74
  }
75
75
  export function useIsMobile() {
76
- return useMediaQuery("(max-width: 767px)");
76
+ return useMediaQuery("(max-width: 767px)");
77
77
  }
78
78
  export function useIsTablet() {
79
- return useMediaQuery("(min-width: 768px) and (max-width: 1023px)");
79
+ return useMediaQuery("(min-width: 768px) and (max-width: 1023px)");
80
80
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @townco/ui/core
2
+ * @town/ui/core
3
3
  *
4
4
  * Headless UI components for chat
5
5
  * Contains business logic, state management, and hooks
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @townco/ui/core
2
+ * @town/ui/core
3
3
  *
4
4
  * Headless UI components for chat
5
5
  * Contains business logic, state management, and hooks
@@ -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
- id: z.ZodString;
10
- role: z.ZodEnum<{
11
- user: "user";
12
- assistant: "assistant";
13
- system: "system";
14
- }>;
15
- content: z.ZodString;
16
- timestamp: z.ZodISODateTime;
17
- isStreaming: z.ZodDefault<z.ZodBoolean>;
18
- streamingStartTime: z.ZodOptional<z.ZodNumber>;
19
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
20
- }, z.core.$strip>;
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
- value: z.ZodString;
27
- isSubmitting: z.ZodBoolean;
28
- attachedFiles: z.ZodArray<z.ZodObject<{
29
- name: z.ZodString;
30
- path: z.ZodString;
31
- size: z.ZodNumber;
32
- mimeType: z.ZodString;
33
- }, z.core.$strip>>;
34
- }, z.core.$strip>;
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
- sessionId: z.ZodNullable<z.ZodString>;
41
- isConnected: z.ZodBoolean;
42
- isStreaming: z.ZodBoolean;
43
- messages: z.ZodArray<z.ZodObject<{
44
- id: z.ZodString;
45
- role: z.ZodEnum<{
46
- user: "user";
47
- assistant: "assistant";
48
- system: "system";
49
- }>;
50
- content: z.ZodString;
51
- timestamp: z.ZodISODateTime;
52
- isStreaming: z.ZodDefault<z.ZodBoolean>;
53
- streamingStartTime: z.ZodOptional<z.ZodNumber>;
54
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
55
- }, z.core.$strip>>;
56
- input: z.ZodObject<{
57
- value: z.ZodString;
58
- isSubmitting: z.ZodBoolean;
59
- attachedFiles: z.ZodArray<z.ZodObject<{
60
- name: z.ZodString;
61
- path: z.ZodString;
62
- size: z.ZodNumber;
63
- mimeType: z.ZodString;
64
- }, z.core.$strip>>;
65
- }, z.core.$strip>;
66
- error: z.ZodNullable<z.ZodString>;
67
- }, z.core.$strip>;
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
- error: "error";
74
- disconnected: "disconnected";
75
- connecting: "connecting";
76
- connected: "connected";
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
- 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(),
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
- value: z.string(),
22
- isSubmitting: z.boolean(),
23
- attachedFiles: z.array(z.object({
24
- name: z.string(),
25
- path: z.string(),
26
- size: z.number(),
27
- mimeType: z.string(),
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
- sessionId: z.string().nullable(),
35
- isConnected: z.boolean(),
36
- isStreaming: z.boolean(),
37
- messages: z.array(DisplayMessage),
38
- input: InputState,
39
- error: z.string().nullable(),
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
- "disconnected",
46
- "connecting",
47
- "connected",
48
- "error",
47
+ "disconnected",
48
+ "connecting",
49
+ "connected",
50
+ "error",
49
51
  ]);
@@ -1,30 +1,36 @@
1
- import type { ConnectionStatus, DisplayMessage, InputState } from "../schemas/index.js";
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
- connectionStatus: ConnectionStatus;
7
- sessionId: string | null;
8
- error: string | null;
9
- messages: DisplayMessage[];
10
- isStreaming: boolean;
11
- streamingStartTime: number | null;
12
- input: InputState;
13
- setConnectionStatus: (status: ConnectionStatus) => void;
14
- setSessionId: (id: string | null) => void;
15
- setError: (error: string | null) => void;
16
- addMessage: (message: DisplayMessage) => void;
17
- updateMessage: (id: string, updates: Partial<DisplayMessage>) => void;
18
- clearMessages: () => void;
19
- setIsStreaming: (streaming: boolean) => void;
20
- setStreamingStartTime: (time: number | null) => void;
21
- setInputValue: (value: string) => void;
22
- setInputSubmitting: (submitting: boolean) => void;
23
- addFileAttachment: (file: InputState["attachedFiles"][number]) => void;
24
- removeFileAttachment: (index: number) => void;
25
- clearInput: () => void;
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<import("zustand").StoreApi<ChatStore>>;
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
- // 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) => set((state) => ({
23
- messages: [...state.messages, message],
24
- })),
25
- updateMessage: (id, updates) => set((state) => ({
26
- messages: state.messages.map((msg) => msg.id === id ? { ...msg, ...updates } : msg),
27
- })),
28
- clearMessages: () => set({ messages: [] }),
29
- setIsStreaming: (streaming) => set({ isStreaming: streaming }),
30
- setStreamingStartTime: (time) => set({ streamingStartTime: time }),
31
- setInputValue: (value) => set((state) => ({
32
- input: { ...state.input, value },
33
- })),
34
- setInputSubmitting: (submitting) => set((state) => ({
35
- input: { ...state.input, isSubmitting: submitting },
36
- })),
37
- addFileAttachment: (file) => set((state) => ({
38
- input: {
39
- ...state.input,
40
- attachedFiles: [...state.input.attachedFiles, file],
41
- },
42
- })),
43
- removeFileAttachment: (index) => set((state) => ({
44
- input: {
45
- ...state.input,
46
- attachedFiles: state.input.attachedFiles.filter((_, i) => i !== index),
47
- },
48
- })),
49
- clearInput: () => set((_state) => ({
50
- input: {
51
- value: "",
52
- isSubmitting: false,
53
- attachedFiles: [],
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: (props?: ({
4
- variant?: "default" | "destructive" | "outline" | "secondary" | "ghost" | "link" | null | undefined;
5
- size?: "default" | "sm" | "lg" | "icon" | null | undefined;
6
- } & import("class-variance-authority/types").ClassProp) | undefined) => string;
7
- export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
8
- asChild?: boolean;
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<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
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
- const buttonVariants = cva("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", {
7
- variants: {
8
- variant: {
9
- default: "bg-primary text-primary-foreground hover:bg-primary/90",
10
- destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
11
- outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
12
- secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
13
- ghost: "hover:bg-accent hover:text-accent-foreground",
14
- link: "text-primary underline-offset-4 hover:underline",
15
- },
16
- size: {
17
- default: "h-10 px-4 py-2",
18
- sm: "h-9 rounded-md px-3",
19
- lg: "h-11 rounded-md px-8",
20
- icon: "h-10 w-10",
21
- },
22
- },
23
- defaultVariants: {
24
- variant: "default",
25
- size: "default",
26
- },
27
- });
28
- const Button = React.forwardRef(({ className, variant, size, asChild = false, ...props }, ref) => {
29
- const Comp = asChild ? Slot : "button";
30
- return (_jsx(Comp, { className: cn(buttonVariants({ variant, size, className })), ref: ref, ...props }));
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 };