@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
|
@@ -1,137 +1,207 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
1
|
import { Slot } from "@radix-ui/react-slot";
|
|
3
2
|
import * as React from "react";
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
import { useChatInput as useCoreChatInput } from "../../core/hooks/use-chat-input.js";
|
|
5
5
|
import { useChatStore } from "../../core/store/chat-store.js";
|
|
6
6
|
import { cn } from "../lib/utils.js";
|
|
7
7
|
import { Button } from "./Button.js";
|
|
8
|
+
|
|
8
9
|
const ChatInputContext = React.createContext(undefined);
|
|
9
10
|
const useChatInputContext = () => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
const context = React.useContext(ChatInputContext);
|
|
12
|
+
if (!context) {
|
|
13
|
+
throw new Error("ChatInput components must be used within ChatInput.Root");
|
|
14
|
+
}
|
|
15
|
+
return context;
|
|
15
16
|
};
|
|
16
|
-
const ChatInputRoot = React.forwardRef(
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
17
|
+
const ChatInputRoot = React.forwardRef(
|
|
18
|
+
(
|
|
19
|
+
{
|
|
20
|
+
client,
|
|
21
|
+
value: valueProp,
|
|
22
|
+
onChange: onChangeProp,
|
|
23
|
+
onSubmit: onSubmitProp,
|
|
24
|
+
disabled = false,
|
|
25
|
+
isSubmitting: isSubmittingProp,
|
|
26
|
+
submitOnEnter = true,
|
|
27
|
+
className,
|
|
28
|
+
children,
|
|
29
|
+
...props
|
|
30
|
+
},
|
|
31
|
+
ref,
|
|
32
|
+
) => {
|
|
33
|
+
const textareaRef = React.useRef(null);
|
|
34
|
+
// Always call hooks unconditionally (React rules)
|
|
35
|
+
const hookData = useCoreChatInput(client ?? null);
|
|
36
|
+
const storeIsStreaming = useChatStore((state) => state.isStreaming);
|
|
37
|
+
// Choose data source based on whether client is provided
|
|
38
|
+
const value = hookData ? hookData.value : valueProp || "";
|
|
39
|
+
const onChange = hookData ? hookData.onChange : onChangeProp || (() => {});
|
|
40
|
+
const onSubmit = hookData
|
|
41
|
+
? hookData.onSubmit
|
|
42
|
+
: onSubmitProp || (async () => {});
|
|
43
|
+
const isSubmitting = hookData
|
|
44
|
+
? hookData.isSubmitting || storeIsStreaming
|
|
45
|
+
: isSubmittingProp || false;
|
|
46
|
+
const handleSubmit = async (e) => {
|
|
47
|
+
e.preventDefault();
|
|
48
|
+
if (value.trim() && !isSubmitting && !disabled) {
|
|
49
|
+
await onSubmit();
|
|
50
|
+
// Restore focus to textarea after submit
|
|
51
|
+
setTimeout(() => {
|
|
52
|
+
textareaRef.current?.focus();
|
|
53
|
+
}, 0);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
// Expose textarea ref to children via context
|
|
57
|
+
React.useEffect(() => {
|
|
58
|
+
const textarea = document.querySelector('textarea[name="chat-input"]');
|
|
59
|
+
if (textarea && textareaRef.current !== textarea) {
|
|
60
|
+
textareaRef.current = textarea;
|
|
61
|
+
}
|
|
62
|
+
}, []);
|
|
63
|
+
// Reset textarea height when value becomes empty (after submit)
|
|
64
|
+
React.useEffect(() => {
|
|
65
|
+
if (!value && textareaRef.current) {
|
|
66
|
+
textareaRef.current.style.height = "auto";
|
|
67
|
+
textareaRef.current.style.overflowY = "hidden";
|
|
68
|
+
}
|
|
69
|
+
}, [value]);
|
|
70
|
+
return _jsx(ChatInputContext.Provider, {
|
|
71
|
+
value: {
|
|
72
|
+
value,
|
|
73
|
+
onChange,
|
|
74
|
+
onSubmit,
|
|
75
|
+
disabled,
|
|
76
|
+
isSubmitting,
|
|
77
|
+
submitOnEnter,
|
|
78
|
+
},
|
|
79
|
+
children: _jsx("form", {
|
|
80
|
+
ref: ref,
|
|
81
|
+
onSubmit: handleSubmit,
|
|
82
|
+
className: cn(
|
|
83
|
+
"w-full divide-y overflow-hidden rounded-xl border bg-background shadow-sm",
|
|
84
|
+
className,
|
|
85
|
+
),
|
|
86
|
+
...props,
|
|
87
|
+
children: children,
|
|
88
|
+
}),
|
|
89
|
+
});
|
|
90
|
+
},
|
|
91
|
+
);
|
|
63
92
|
ChatInputRoot.displayName = "ChatInput.Root";
|
|
64
|
-
const ChatInputField = React.forwardRef(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
93
|
+
const ChatInputField = React.forwardRef(
|
|
94
|
+
({ asChild = false, className, onKeyDown, children, ...props }, ref) => {
|
|
95
|
+
const { value, onChange, onSubmit, disabled, isSubmitting, submitOnEnter } =
|
|
96
|
+
useChatInputContext();
|
|
97
|
+
const textareaRef = React.useRef(null);
|
|
98
|
+
const handleRef = React.useCallback(
|
|
99
|
+
(node) => {
|
|
100
|
+
textareaRef.current = node;
|
|
101
|
+
if (typeof ref === "function") {
|
|
102
|
+
ref(node);
|
|
103
|
+
} else if (ref) {
|
|
104
|
+
ref.current = node;
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
[ref],
|
|
108
|
+
);
|
|
109
|
+
const handleKeyDown = (e) => {
|
|
110
|
+
// Handle Enter without Shift - only submit if not already submitting
|
|
111
|
+
if (submitOnEnter && e.key === "Enter" && !e.shiftKey) {
|
|
112
|
+
// Only prevent default and submit if conditions are met
|
|
113
|
+
if (value.trim() && !isSubmitting && !disabled) {
|
|
114
|
+
e.preventDefault();
|
|
115
|
+
onSubmit();
|
|
116
|
+
} else if (isSubmitting || disabled) {
|
|
117
|
+
// Block Enter when submitting or disabled - don't add newline
|
|
118
|
+
e.preventDefault();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
onKeyDown?.(e);
|
|
122
|
+
};
|
|
123
|
+
const handleChange = (e) => {
|
|
124
|
+
onChange(e.target.value);
|
|
125
|
+
// Auto-resize
|
|
126
|
+
const textarea = textareaRef.current;
|
|
127
|
+
if (!textarea) return;
|
|
128
|
+
textarea.style.height = "auto";
|
|
129
|
+
const newHeight = Math.min(textarea.scrollHeight, 164);
|
|
130
|
+
textarea.style.height = `${newHeight}px`;
|
|
131
|
+
if (textarea.scrollHeight > 164) {
|
|
132
|
+
textarea.style.overflowY = "auto";
|
|
133
|
+
} else {
|
|
134
|
+
textarea.style.overflowY = "hidden";
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
const fieldProps = {
|
|
138
|
+
ref: handleRef,
|
|
139
|
+
name: "chat-input",
|
|
140
|
+
value,
|
|
141
|
+
onChange: handleChange,
|
|
142
|
+
onKeyDown: handleKeyDown,
|
|
143
|
+
disabled: disabled,
|
|
144
|
+
...props,
|
|
145
|
+
};
|
|
146
|
+
if (asChild && React.isValidElement(children)) {
|
|
147
|
+
return React.cloneElement(children, fieldProps);
|
|
148
|
+
}
|
|
149
|
+
return _jsx("textarea", {
|
|
150
|
+
...fieldProps,
|
|
151
|
+
className: cn(
|
|
152
|
+
"w-full resize-none rounded-none border-none p-3 shadow-none",
|
|
153
|
+
"outline-none ring-0 field-sizing-content max-h-[6lh]",
|
|
154
|
+
"bg-transparent dark:bg-transparent focus-visible:ring-0",
|
|
155
|
+
"text-sm placeholder:text-muted-foreground",
|
|
156
|
+
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
157
|
+
className,
|
|
158
|
+
),
|
|
159
|
+
});
|
|
160
|
+
},
|
|
161
|
+
);
|
|
121
162
|
ChatInputField.displayName = "ChatInput.Field";
|
|
122
|
-
const ChatInputSubmit = React.forwardRef(
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
163
|
+
const ChatInputSubmit = React.forwardRef(
|
|
164
|
+
(
|
|
165
|
+
{ asChild = false, className, disabled: disabledProp, children, ...props },
|
|
166
|
+
ref,
|
|
167
|
+
) => {
|
|
168
|
+
const { value, disabled, isSubmitting } = useChatInputContext();
|
|
169
|
+
const isDisabled =
|
|
170
|
+
disabledProp || disabled || isSubmitting || !value.trim();
|
|
171
|
+
const Comp = asChild ? Slot : Button;
|
|
172
|
+
return _jsx(Comp, {
|
|
173
|
+
ref: ref,
|
|
174
|
+
type: "submit",
|
|
175
|
+
disabled: isDisabled,
|
|
176
|
+
size: "icon",
|
|
177
|
+
className: cn(
|
|
178
|
+
!asChild &&
|
|
179
|
+
"gap-1.5 rounded-lg bg-transparent text-foreground hover:bg-transparent",
|
|
180
|
+
className,
|
|
181
|
+
),
|
|
182
|
+
...props,
|
|
183
|
+
children: children,
|
|
184
|
+
});
|
|
185
|
+
},
|
|
186
|
+
);
|
|
129
187
|
ChatInputSubmit.displayName = "ChatInput.Submit";
|
|
130
|
-
const ChatInputToolbar = React.forwardRef(
|
|
131
|
-
|
|
132
|
-
|
|
188
|
+
const ChatInputToolbar = React.forwardRef(
|
|
189
|
+
({ className, children, ...props }, ref) => {
|
|
190
|
+
return _jsx("div", {
|
|
191
|
+
ref: ref,
|
|
192
|
+
className: cn("flex items-center justify-between p-1", className),
|
|
193
|
+
...props,
|
|
194
|
+
children: children,
|
|
195
|
+
});
|
|
196
|
+
},
|
|
197
|
+
);
|
|
133
198
|
ChatInputToolbar.displayName = "ChatInput.Toolbar";
|
|
134
199
|
/* -------------------------------------------------------------------------------------------------
|
|
135
200
|
* Exports
|
|
136
201
|
* -----------------------------------------------------------------------------------------------*/
|
|
137
|
-
export {
|
|
202
|
+
export {
|
|
203
|
+
ChatInputRoot as Root,
|
|
204
|
+
ChatInputField as Field,
|
|
205
|
+
ChatInputSubmit as Submit,
|
|
206
|
+
ChatInputToolbar as Toolbar,
|
|
207
|
+
};
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { type DisplayMessage } from "./MessageList.js";
|
|
2
2
|
interface ChatInterfaceProps {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
initialMessages?: DisplayMessage[];
|
|
4
|
+
thinkingDisplayStyle?: "collapsible" | "inline";
|
|
5
|
+
status?: string;
|
|
6
6
|
}
|
|
7
|
-
export declare function ChatInterface({
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
export declare function ChatInterface({
|
|
8
|
+
initialMessages,
|
|
9
|
+
thinkingDisplayStyle,
|
|
10
|
+
status,
|
|
11
|
+
}: ChatInterfaceProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
//# sourceMappingURL=ChatInterface.d.ts.map
|
|
@@ -1,50 +1,51 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useState, useEffect } from "react";
|
|
3
1
|
import { ChevronDown } from "lucide-react";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { ChatInput } from "./ChatInput.js";
|
|
6
5
|
import { ChatSecondaryPanel } from "./ChatSecondaryPanel.js";
|
|
6
|
+
import { ChatStatus } from "./ChatStatus.js";
|
|
7
7
|
import { HeightTransition } from "./HeightTransition.js";
|
|
8
|
-
import {
|
|
8
|
+
import { MessageList } from "./MessageList.js";
|
|
9
|
+
|
|
9
10
|
const SAMPLE_TODOS = [
|
|
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
|
-
|
|
11
|
+
{
|
|
12
|
+
id: "1",
|
|
13
|
+
text: "Identify the last 25 Winter Olympics host countries",
|
|
14
|
+
status: "completed",
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
id: "2",
|
|
18
|
+
text: "For each host country, find the tallest mountain",
|
|
19
|
+
status: "in_progress",
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
id: "3",
|
|
23
|
+
text: "Gather key details for each mountain (name, elevation, location)",
|
|
24
|
+
status: "pending",
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: "4",
|
|
28
|
+
text: "Verify information using reliable sources (geographical databases, official records)",
|
|
29
|
+
status: "pending",
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
id: "5",
|
|
33
|
+
text: "Compile findings into a summary table or document",
|
|
34
|
+
status: "pending",
|
|
35
|
+
},
|
|
35
36
|
];
|
|
36
37
|
const SAMPLE_MESSAGES = [
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
38
|
+
{
|
|
39
|
+
id: "msg-1",
|
|
40
|
+
role: "user",
|
|
41
|
+
content: "Hello! Can you help me understand how to use markdown?",
|
|
42
|
+
timestamp: new Date().toISOString(),
|
|
43
|
+
isStreaming: false,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
id: "msg-2",
|
|
47
|
+
role: "assistant",
|
|
48
|
+
content: `Sure! Markdown is a lightweight markup language. Here are some basics:
|
|
48
49
|
|
|
49
50
|
## Headings
|
|
50
51
|
Use \`#\` for headings. More \`#\` symbols make smaller headings.
|
|
@@ -79,54 +80,125 @@ You can make text **bold** or *italic*.
|
|
|
79
80
|
|----------|----------|
|
|
80
81
|
| Cell 1 | Cell 2 |
|
|
81
82
|
| Cell 3 | Cell 4 |`,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
83
|
+
timestamp: new Date().toISOString(),
|
|
84
|
+
isStreaming: false,
|
|
85
|
+
metadata: {
|
|
86
|
+
thinking: "Let me provide a comprehensive overview of markdown syntax...",
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
id: "msg-3",
|
|
91
|
+
role: "user",
|
|
92
|
+
content: "That's really helpful, thank you!",
|
|
93
|
+
timestamp: new Date().toISOString(),
|
|
94
|
+
isStreaming: false,
|
|
95
|
+
},
|
|
95
96
|
];
|
|
96
|
-
export function ChatInterface({
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
97
|
+
export function ChatInterface({
|
|
98
|
+
initialMessages = SAMPLE_MESSAGES,
|
|
99
|
+
thinkingDisplayStyle = "collapsible",
|
|
100
|
+
status = "Connected",
|
|
101
|
+
}) {
|
|
102
|
+
const [messages, setMessages] = useState(initialMessages);
|
|
103
|
+
const [currentStatus, setCurrentStatus] = useState(status);
|
|
104
|
+
const [config, setConfig] = useState(null);
|
|
105
|
+
const [isHeaderExpanded, setIsHeaderExpanded] = useState(false);
|
|
106
|
+
const [todos] = useState(SAMPLE_TODOS);
|
|
107
|
+
// Listen for config and status updates from parent window
|
|
108
|
+
useEffect(() => {
|
|
109
|
+
const handleMessage = (event) => {
|
|
110
|
+
if (event.data.type === "CONFIG_UPDATE") {
|
|
111
|
+
const newConfig = event.data.config;
|
|
112
|
+
setConfig(newConfig);
|
|
113
|
+
applyConfigToDocument(newConfig);
|
|
114
|
+
} else if (event.data.type === "STATUS_UPDATE") {
|
|
115
|
+
setCurrentStatus(event.data.status);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
window.addEventListener("message", handleMessage);
|
|
119
|
+
// Request config from parent on mount
|
|
120
|
+
if (window.parent !== window) {
|
|
121
|
+
window.parent.postMessage({ type: "REQUEST_CONFIG" }, "*");
|
|
122
|
+
}
|
|
123
|
+
return () => {
|
|
124
|
+
window.removeEventListener("message", handleMessage);
|
|
125
|
+
};
|
|
126
|
+
}, []);
|
|
127
|
+
const applyConfigToDocument = (cfg) => {
|
|
128
|
+
const root = document.documentElement;
|
|
129
|
+
root.setAttribute("data-theme", cfg.colorScheme);
|
|
130
|
+
root.style.setProperty("--color-accent", cfg.accentColor);
|
|
131
|
+
root.style.setProperty("--font-family", cfg.typography);
|
|
132
|
+
root.style.setProperty("--font-size", `${cfg.fontSize}px`);
|
|
133
|
+
};
|
|
134
|
+
return _jsxs("div", {
|
|
135
|
+
className:
|
|
136
|
+
"flex flex-col h-screen bg-[var(--color-bg)] text-[var(--color-text)]",
|
|
137
|
+
children: [
|
|
138
|
+
_jsxs("div", {
|
|
139
|
+
className:
|
|
140
|
+
"relative border-b border-[var(--color-border)] bg-[var(--color-surface)] z-10",
|
|
141
|
+
children: [
|
|
142
|
+
_jsxs("div", {
|
|
143
|
+
className: "flex items-center justify-between px-6 py-4",
|
|
144
|
+
children: [
|
|
145
|
+
_jsx("h1", {
|
|
146
|
+
className: "text-xl font-semibold m-0",
|
|
147
|
+
children: "Chat Interface",
|
|
148
|
+
}),
|
|
149
|
+
_jsxs("div", {
|
|
150
|
+
className: "flex items-center gap-3",
|
|
151
|
+
children: [
|
|
152
|
+
_jsx(ChatStatus, { children: currentStatus }),
|
|
153
|
+
_jsx("button", {
|
|
154
|
+
onClick: () => setIsHeaderExpanded(!isHeaderExpanded),
|
|
155
|
+
className:
|
|
156
|
+
"p-1 rounded hover:bg-[var(--color-bg)] transition-colors",
|
|
157
|
+
"aria-label": isHeaderExpanded
|
|
158
|
+
? "Collapse header"
|
|
159
|
+
: "Expand header",
|
|
160
|
+
children: _jsx(ChevronDown, {
|
|
161
|
+
className: `w-5 h-5 text-[var(--color-text)] transition-transform duration-200 ${isHeaderExpanded ? "rotate-180" : ""}`,
|
|
162
|
+
}),
|
|
163
|
+
}),
|
|
164
|
+
],
|
|
165
|
+
}),
|
|
166
|
+
],
|
|
167
|
+
}),
|
|
168
|
+
_jsx("div", {
|
|
169
|
+
className: "absolute top-full left-0 right-0 z-20",
|
|
170
|
+
children: _jsx(HeightTransition, {
|
|
171
|
+
children:
|
|
172
|
+
isHeaderExpanded &&
|
|
173
|
+
_jsx("div", {
|
|
174
|
+
className:
|
|
175
|
+
"bg-[var(--color-surface)] border-b border-[var(--color-border)] px-6 py-4 shadow-lg",
|
|
176
|
+
children: _jsx(ChatSecondaryPanel, { todos: todos }),
|
|
177
|
+
}),
|
|
178
|
+
}),
|
|
179
|
+
}),
|
|
180
|
+
],
|
|
181
|
+
}),
|
|
182
|
+
_jsx("div", {
|
|
183
|
+
className: "flex-1 overflow-y-auto py-4",
|
|
184
|
+
children: _jsx(MessageList, {
|
|
185
|
+
messages: messages,
|
|
186
|
+
thinkingDisplayStyle:
|
|
187
|
+
config?.thinkingDisplayStyle || thinkingDisplayStyle,
|
|
188
|
+
}),
|
|
189
|
+
}),
|
|
190
|
+
_jsx("div", {
|
|
191
|
+
className:
|
|
192
|
+
"border-t border-[var(--color-border)] px-6 py-4 bg-[var(--color-surface)]",
|
|
193
|
+
children: _jsx(ChatInput, {
|
|
194
|
+
value: "",
|
|
195
|
+
onChange: () => {},
|
|
196
|
+
onSubmit: () => {},
|
|
197
|
+
disabled: true,
|
|
198
|
+
placeholder: "Type a message...",
|
|
199
|
+
}),
|
|
200
|
+
}),
|
|
201
|
+
],
|
|
202
|
+
});
|
|
131
203
|
}
|
|
132
|
-
//# sourceMappingURL=ChatInterface.js.map
|
|
204
|
+
//# sourceMappingURL=ChatInterface.js.map
|