@conscience-technology/ovenn 0.7.0 → 0.7.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/assets/components/AIMessage/AIMessage.module.css +21 -0
- package/assets/components/AIMessage/AIMessage.tsx +27 -7
- package/assets/components/AttachmentItem/AttachmentItem.module.css +41 -10
- package/assets/components/AttachmentItem/AttachmentItem.tsx +25 -8
- package/assets/components/AttachmentThumb/AttachmentThumb.module.css +9 -10
- package/assets/components/Button/Button.module.css +19 -0
- package/assets/components/Callout/Callout.module.css +53 -7
- package/assets/components/Callout/Callout.tsx +26 -2
- package/assets/components/Callout/index.ts +1 -1
- package/assets/components/ChatComposer/ChatComposer.module.css +17 -0
- package/assets/components/ChatComposer/ChatComposer.tsx +131 -0
- package/assets/components/ChatComposer/index.ts +2 -0
- package/assets/components/ChatInput/ChatInput.module.css +192 -30
- package/assets/components/ChatInput/ChatInput.tsx +137 -45
- package/assets/components/ChatInput/SendButton.tsx +4 -1
- package/assets/components/ChatInput/index.ts +5 -0
- package/assets/components/ChatMessage/ChatMessage.module.css +19 -0
- package/assets/components/ChatMessage/ChatMessage.tsx +63 -0
- package/assets/components/ChatMessage/index.ts +2 -0
- package/assets/components/ChatReactions/ChatReactions.module.css +15 -0
- package/assets/components/ChatReactions/ChatReactions.tsx +58 -0
- package/assets/components/ChatReactions/index.ts +2 -0
- package/assets/components/CodeBlock/CodeBlock.module.css +106 -10
- package/assets/components/CodeBlock/CodeBlock.tsx +114 -29
- package/assets/components/CodeBlock/SyntaxHighlight.tsx +20 -0
- package/assets/components/CodeBlock/diff-lines.ts +21 -0
- package/assets/components/CodeBlock/index.ts +2 -1
- package/assets/components/CodeBlock/line-preview.ts +7 -0
- package/assets/components/CodeBlock/syntax-highlighter.ts +96 -0
- package/assets/components/CodeBlock/use-syntax-tokens.ts +17 -0
- package/assets/components/ColorField/ColorField.module.css +19 -196
- package/assets/components/ColorField/ColorField.tsx +116 -109
- package/assets/components/Combobox/Combobox.module.css +21 -4
- package/assets/components/Combobox/Combobox.tsx +37 -21
- package/assets/components/CommandPalette/CommandPalette.module.css +1 -1
- package/assets/components/ControlGroup/ControlGroup.module.css +13 -6
- package/assets/components/DatePicker/DateField.tsx +72 -25
- package/assets/components/DatePicker/DatePicker.module.css +28 -59
- package/assets/components/DatePicker/DatePicker.tsx +76 -40
- package/assets/components/Drawer/Drawer.module.css +12 -15
- package/assets/components/Drawer/Drawer.tsx +15 -23
- package/assets/components/EmojiPicker/EmojiGlyph.module.css +2 -0
- package/assets/components/EmojiPicker/EmojiGlyph.tsx +12 -0
- package/assets/components/EmojiPicker/EmojiPicker.module.css +43 -0
- package/assets/components/EmojiPicker/EmojiPicker.tsx +143 -0
- package/assets/components/EmojiPicker/UNICODE-LICENSE.txt +39 -0
- package/assets/components/EmojiPicker/data.ts +41 -0
- package/assets/components/EmojiPicker/emojiData-0.json +1 -0
- package/assets/components/EmojiPicker/emojiData-1.json +1 -0
- package/assets/components/EmojiPicker/emojiData-2.json +1 -0
- package/assets/components/EmojiPicker/emojiData-3.json +1 -0
- package/assets/components/EmojiPicker/emojiData.sources.json +35 -0
- package/assets/components/EmojiPicker/emojiData.ts +8 -0
- package/assets/components/EmojiPicker/emojiFallbacks.json +1 -0
- package/assets/components/EmojiPicker/index.ts +4 -0
- package/assets/components/EmptyState/EmptyState.module.css +2 -2
- package/assets/components/FileIcon/FileIcon.module.css +4 -6
- package/assets/components/Icon/LucideFamilyIcon.tsx +2 -0
- package/assets/components/Icon/SolarFamilyIcon.tsx +4 -0
- package/assets/components/Input/Input.module.css +33 -10
- package/assets/components/Input/Input.tsx +20 -9
- package/assets/components/MessageActions/MessageActions.module.css +2 -2
- package/assets/components/Onboarding/Onboarding.module.css +1 -1
- package/assets/components/ProgressBar/ProgressBar.module.css +38 -4
- package/assets/components/ProgressBar/ProgressBar.tsx +5 -1
- package/assets/components/RadioCard/RadioCard.module.css +18 -0
- package/assets/components/RadioCard/RadioCard.tsx +48 -7
- package/assets/components/Select/Select.module.css +9 -7
- package/assets/components/Select/Select.tsx +15 -2
- package/assets/components/Tabs/Tabs.module.css +1 -1
- package/assets/components/Tabs/Tabs.tsx +2 -2
- package/assets/components/Textarea/Textarea.module.css +28 -231
- package/assets/components/Textarea/Textarea.tsx +2 -2
- package/assets/components/TimePicker/TimePicker.module.css +16 -4
- package/assets/components/TimePicker/TimePicker.tsx +66 -8
- package/assets/components/Toast/Toast.module.css +18 -0
- package/assets/components/Toast/Toast.tsx +1 -1
- package/assets/components/Tooltip/Tooltip.tsx +33 -7
- package/assets/components/UserMessage/UserMessage.module.css +110 -1
- package/assets/components/UserMessage/UserMessage.tsx +138 -16
- package/assets/components/UserMessage/index.ts +4 -0
- package/assets/components/_data.ts +10 -5
- package/assets/components/_utils.css +31 -5
- package/assets/components/component-registry.json +1595 -107
- package/assets/components/index.ts +7 -0
- package/assets/components/tokens.css +83 -0
- package/assets/prompts/ASSEMBLY.md +11 -0
- package/assets/prompts/CATALOG.md +110 -106
- package/assets/prompts/PRINCIPLES.md +11 -1
- package/assets/prompts/TEMPLATE_PREVIEWS.md +21 -0
- package/assets/prompts/WORKFLOW_DESIGN.md +2 -0
- package/assets/prompts/axes/font.md +6 -0
- package/assets/prompts/axes/material.md +1 -1
- package/assets/prompts/axes/motion.md +2 -0
- package/assets/prompts/axes/palette.md +9 -2
- package/assets/prompts/axes/voice.md +4 -0
- package/assets/prompts/components/README.md +3 -3
- package/assets/prompts/components/_variants.md +35 -35
- package/assets/prompts/components/accordion.md +15 -15
- package/assets/prompts/components/ai-message.md +14 -12
- package/assets/prompts/components/app-frame.md +16 -16
- package/assets/prompts/components/attachment-item.md +36 -30
- package/assets/prompts/components/attachment-thumb.md +14 -12
- package/assets/prompts/components/avatar-upload.md +10 -10
- package/assets/prompts/components/avatar.md +16 -16
- package/assets/prompts/components/badge.md +4 -4
- package/assets/prompts/components/breadcrumb.md +24 -24
- package/assets/prompts/components/bubble.md +13 -13
- package/assets/prompts/components/button-group.md +1 -1
- package/assets/prompts/components/button.md +37 -36
- package/assets/prompts/components/calendar.md +29 -29
- package/assets/prompts/components/callout.md +39 -23
- package/assets/prompts/components/canvas-edge.md +5 -2
- package/assets/prompts/components/canvas-node.md +3 -3
- package/assets/prompts/components/canvas.md +5 -2
- package/assets/prompts/components/card.md +21 -21
- package/assets/prompts/components/chart-bar.md +7 -7
- package/assets/prompts/components/chart-pie.md +3 -3
- package/assets/prompts/components/chart-radar.md +3 -3
- package/assets/prompts/components/chart-radial.md +4 -4
- package/assets/prompts/components/chat-composer.md +71 -0
- package/assets/prompts/components/chat-input.md +82 -27
- package/assets/prompts/components/chat-message.md +48 -0
- package/assets/prompts/components/chat-reactions.md +38 -0
- package/assets/prompts/components/checkbox-card.md +3 -3
- package/assets/prompts/components/checkbox.md +17 -17
- package/assets/prompts/components/chip.md +32 -32
- package/assets/prompts/components/code-block.md +109 -66
- package/assets/prompts/components/code.md +4 -4
- package/assets/prompts/components/color-area.md +9 -9
- package/assets/prompts/components/color-field.md +17 -13
- package/assets/prompts/components/color-picker.md +6 -6
- package/assets/prompts/components/color-slider.md +8 -8
- package/assets/prompts/components/color-swatch-picker.md +8 -8
- package/assets/prompts/components/color-swatch.md +9 -9
- package/assets/prompts/components/combobox.md +5 -2
- package/assets/prompts/components/command-palette.md +26 -26
- package/assets/prompts/components/comment.md +5 -2
- package/assets/prompts/components/context-menu.md +22 -22
- package/assets/prompts/components/control-group.md +4 -4
- package/assets/prompts/components/date-picker.md +31 -23
- package/assets/prompts/components/disclosure.md +10 -10
- package/assets/prompts/components/drawer.md +19 -18
- package/assets/prompts/components/dropdown-menu.md +21 -21
- package/assets/prompts/components/emoji-picker.md +45 -0
- package/assets/prompts/components/empty-state.md +20 -18
- package/assets/prompts/components/event-chip.md +11 -11
- package/assets/prompts/components/event-list-item.md +21 -21
- package/assets/prompts/components/file-icon.md +18 -19
- package/assets/prompts/components/gallery-item.md +19 -19
- package/assets/prompts/components/generated-image.md +10 -10
- package/assets/prompts/components/hint.md +19 -19
- package/assets/prompts/components/icon-button.md +16 -16
- package/assets/prompts/components/icon.md +12 -9
- package/assets/prompts/components/input.md +49 -46
- package/assets/prompts/components/kanban.md +34 -34
- package/assets/prompts/components/list-item.md +39 -39
- package/assets/prompts/components/menu-item.md +41 -41
- package/assets/prompts/components/message-actions.md +6 -6
- package/assets/prompts/components/message-quote.md +7 -7
- package/assets/prompts/components/message-sources.md +10 -10
- package/assets/prompts/components/message-state.md +17 -17
- package/assets/prompts/components/message-table.md +5 -5
- package/assets/prompts/components/mini-calendar.md +6 -1
- package/assets/prompts/components/modal.md +39 -39
- package/assets/prompts/components/multi-select.md +4 -1
- package/assets/prompts/components/onboarding.md +19 -19
- package/assets/prompts/components/page-header.md +31 -31
- package/assets/prompts/components/pagination.md +17 -17
- package/assets/prompts/components/progress-bar.md +14 -11
- package/assets/prompts/components/quotation-bar.md +10 -10
- package/assets/prompts/components/radio-card.md +7 -6
- package/assets/prompts/components/radio.md +9 -9
- package/assets/prompts/components/select.md +28 -25
- package/assets/prompts/components/shortcut.md +11 -11
- package/assets/prompts/components/sidebar.md +56 -56
- package/assets/prompts/components/skeleton.md +7 -4
- package/assets/prompts/components/slider.md +18 -18
- package/assets/prompts/components/spinner.md +16 -16
- package/assets/prompts/components/stepper.md +14 -14
- package/assets/prompts/components/switch.md +19 -20
- package/assets/prompts/components/tab-strip.md +31 -31
- package/assets/prompts/components/table-cell.md +4 -4
- package/assets/prompts/components/table-header.md +16 -16
- package/assets/prompts/components/table-row-edit.md +19 -19
- package/assets/prompts/components/table-row-select.md +9 -9
- package/assets/prompts/components/table-row.md +18 -18
- package/assets/prompts/components/tabs.md +26 -25
- package/assets/prompts/components/tag.md +6 -6
- package/assets/prompts/components/textarea.md +16 -15
- package/assets/prompts/components/time-picker.md +21 -14
- package/assets/prompts/components/timeline-view.md +4 -4
- package/assets/prompts/components/toast.md +42 -41
- package/assets/prompts/components/toolbar.md +23 -23
- package/assets/prompts/components/tooltip.md +15 -14
- package/assets/prompts/components/top-loader.md +11 -11
- package/assets/prompts/components/topbar.md +35 -35
- package/assets/prompts/components/tree-nav.md +9 -9
- package/assets/prompts/components/user-message.md +23 -12
- package/assets/prompts/design-examples/README.md +1 -1
- package/assets/prompts/design-examples/ai-chat-full-page.png +0 -0
- package/assets/prompts/design-examples/catalog.json +124 -1
- package/assets/prompts/design-examples/sources/ai-chat-full-page/ChatExperience.module.css +346 -0
- package/assets/prompts/design-examples/sources/ai-chat-full-page/ChatExperience.tsx +375 -0
- package/assets/prompts/design-examples/sources/ai-chat-full-page/FullPageChat.tsx +8 -0
- package/assets/prompts/design-examples/sources/ai-chat-full-page/REFERENCE.md +19 -0
- package/assets/prompts/design-examples/sources/ai-chat-full-page/useChatDemo.ts +139 -0
- package/assets/prompts/design-examples/sources/ai-chat-full-page/useDemoTextStream.ts +30 -0
- package/assets/prompts/primitives/emerge.md +2 -0
- package/assets/prompts/templates/README.md +1 -1
- package/assets/prompts/templates/ains.md +7 -0
- package/assets/prompts/templates/minimal.md +6 -0
- package/assets/prompts/templates/onboarding.md +156 -0
- package/assets/prompts/templates/workspace.md +13 -8
- package/assets/prompts/tokens/color.md +7 -2
- package/assets/prompts/tokens/radius.md +22 -0
- package/assets/prompts/use-cases/chart-chart-area.md +40 -40
- package/assets/prompts/use-cases/chart-chart-bar.md +34 -34
- package/assets/prompts/use-cases/chart-chart-pie.md +14 -14
- package/assets/prompts/use-cases/chart-chart-radar.md +24 -24
- package/assets/prompts/use-cases/chart-chart-radial.md +14 -14
- package/assets/prompts/use-cases/chart-segmented-chart.md +32 -32
- package/assets/prompts/use-cases/chat-chat-composer.md +529 -0
- package/assets/prompts/use-cases/chat-chat-input.md +1766 -0
- package/assets/prompts/use-cases/data-comment.md +39 -39
- package/assets/prompts/use-cases/data-data-table.md +34 -34
- package/assets/prompts/use-cases/data-list-item.md +16 -16
- package/assets/prompts/use-cases/data-metric-card.md +18 -18
- package/assets/prompts/use-cases/data-table-row.md +19 -19
- package/assets/prompts/use-cases/data-table-toolbar.md +10 -10
- package/assets/prompts/use-cases/feedback-drawer.md +35 -30
- package/assets/prompts/use-cases/feedback-progress-bar.md +23 -18
- package/assets/prompts/use-cases/general-toolbar.md +16 -16
- package/assets/prompts/use-cases/general-tooltip.md +26 -26
- package/assets/prompts/use-cases/input-checkbox.md +27 -27
- package/assets/prompts/use-cases/structure-card.md +9 -9
- package/assets/prompts/use-cases/structure-page-header.md +17 -17
- package/assets/prompts/use-cases/structure-sidebar.md +20 -20
- package/assets/prompts/use-cases/structure-topbar.md +38 -42
- package/assets/skills/ovenn-wireframe/SKILL.md +17 -4
- package/package.json +6 -2
- package/src/utils/design-examples.js +3 -4
- package/assets/prompts/templates/glass-button.md +0 -337
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useLayoutEffect, useRef, useState } from "react";
|
|
4
|
+
import { Button } from "@/components/ovenn/Button";
|
|
5
|
+
import { DropdownMenu } from "@/components/ovenn/DropdownMenu";
|
|
6
|
+
import { Icon } from "@/components/ovenn/Icon";
|
|
7
|
+
import { IconButton } from "@/components/ovenn/IconButton";
|
|
8
|
+
import { Modal } from "@/components/ovenn/Modal";
|
|
9
|
+
import { UserMessage } from "@/components/ovenn/UserMessage";
|
|
10
|
+
import { AIMessage } from "@/components/ovenn/AIMessage";
|
|
11
|
+
import { useChatDemo } from "./useChatDemo";
|
|
12
|
+
import { Card } from "@/components/ovenn/Card";
|
|
13
|
+
import { AppFrame } from "@/components/ovenn/AppFrame";
|
|
14
|
+
import { Topbar } from "@/components/ovenn/Topbar";
|
|
15
|
+
import { Sidebar } from "@/components/ovenn/Sidebar";
|
|
16
|
+
import { Input } from "@/components/ovenn/Input";
|
|
17
|
+
import { MenuItem } from "@/components/ovenn/MenuItem";
|
|
18
|
+
import { EmptyState } from "@/components/ovenn/EmptyState";
|
|
19
|
+
import { AIChatInput } from "@/components/ovenn/ChatInput";
|
|
20
|
+
import { RadioCard } from "@/components/ovenn/RadioCard";
|
|
21
|
+
import styles from "./ChatExperience.module.css";
|
|
22
|
+
|
|
23
|
+
const content = {
|
|
24
|
+
en: {
|
|
25
|
+
title: "New chat",
|
|
26
|
+
history: "Chat history", searchChats: "Search chats", recentChats: "Recent chats", searchResults: "Search results", noChats: "No chats yet", noResults: "No matching chats", showHistory: "Open chat history", hideHistory: "Close chat history",
|
|
27
|
+
greeting: "Hello there.",
|
|
28
|
+
invitation: "What are we working on?",
|
|
29
|
+
placeholder: "Ask anything about your work",
|
|
30
|
+
suggestionsLabel: "Send a starting question",
|
|
31
|
+
switchThread: "Switch thread",
|
|
32
|
+
createThread: "New chat",
|
|
33
|
+
messagesLabel: "Conversation",
|
|
34
|
+
threadTitles: ["Meeting notes", "Follow-up email", "Document summary"],
|
|
35
|
+
replies: [
|
|
36
|
+
"Share your meeting notes and I’ll organize them into decisions and action items.\n\nFor each action, include the task, owner, and due date when available.",
|
|
37
|
+
"Who is the email for, and what should it cover?\n\nShare the purpose, key points, and preferred tone. I’ll help turn them into a clear follow-up.",
|
|
38
|
+
"Paste the document you want to summarize.\n\nI’ll organize it around the main points, supporting details, and anything that needs a follow-up.",
|
|
39
|
+
],
|
|
40
|
+
fallbackReply: "Tell me a little more about the result you need.\n\nYou can share the context, the key information, and the format you would like to work toward.",
|
|
41
|
+
questions: [
|
|
42
|
+
"Turn meeting notes into action items",
|
|
43
|
+
"Help me draft a follow-up email",
|
|
44
|
+
"Summarize the key points of a document",
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
ko: {
|
|
48
|
+
title: "새 대화",
|
|
49
|
+
history: "대화 기록", searchChats: "대화 검색", recentChats: "최근 대화", searchResults: "검색 결과", noChats: "아직 대화가 없어요", noResults: "검색 결과가 없어요", showHistory: "대화 기록 열기", hideHistory: "대화 기록 닫기",
|
|
50
|
+
greeting: "안녕하세요.",
|
|
51
|
+
invitation: "어떤 일을 도와드릴까요?",
|
|
52
|
+
placeholder: "도움이 필요한 일을 알려주세요",
|
|
53
|
+
suggestionsLabel: "추천 질문 바로 보내기",
|
|
54
|
+
switchThread: "대화 전환",
|
|
55
|
+
createThread: "새 대화",
|
|
56
|
+
messagesLabel: "대화 내용",
|
|
57
|
+
threadTitles: ["회의 메모 정리", "후속 메일 초안", "문서 요약"],
|
|
58
|
+
replies: [
|
|
59
|
+
"정리할 회의 메모를 보내주세요. 결정 사항과 실행 항목을 구분해 정리할게요.\n\n실행 항목마다 할 일, 담당자, 기한이 있다면 함께 알려주세요.",
|
|
60
|
+
"누구에게 어떤 목적으로 보내는 메일인가요?\n\n꼭 포함할 내용과 원하는 말투를 알려주시면 후속 업무 메일 초안을 작성할게요.",
|
|
61
|
+
"요약할 문서 내용을 붙여 넣어주세요.\n\n핵심 내용과 근거, 추가로 확인할 사항을 나누어 정리할게요.",
|
|
62
|
+
],
|
|
63
|
+
fallbackReply: "어떤 결과가 필요한지 조금 더 알려주세요.\n\n관련 맥락과 꼭 포함할 내용, 원하는 정리 형식을 함께 보내주시면 다음 내용을 구체화할 수 있어요.",
|
|
64
|
+
questions: [
|
|
65
|
+
"회의 메모를 실행 항목으로 정리하기",
|
|
66
|
+
"후속 업무 메일 초안 작성하기",
|
|
67
|
+
"문서의 핵심 내용 요약하기",
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export function ChatExperience({ lang, presentation = "card" }: { lang: "en" | "ko"; presentation?: "card" | "page" }) {
|
|
73
|
+
const isPage = presentation === "page";
|
|
74
|
+
const t = content[lang];
|
|
75
|
+
const [threadMenuOpen, setThreadMenuOpen] = useState(false);
|
|
76
|
+
const [mobileView, setMobileView] = useState<"chat" | "threads">("chat");
|
|
77
|
+
const [isMobile, setIsMobile] = useState(false);
|
|
78
|
+
const [threadSearch, setThreadSearch] = useState("");
|
|
79
|
+
const [renameTarget, setRenameTarget] = useState<string | null>(null);
|
|
80
|
+
const [threadName, setThreadName] = useState("");
|
|
81
|
+
const searchRef = useRef<HTMLInputElement>(null);
|
|
82
|
+
const pageTitleRef = useRef<HTMLSpanElement>(null);
|
|
83
|
+
const historyToggleRef = useRef<HTMLButtonElement>(null);
|
|
84
|
+
const threadActionsRef = useRef<HTMLButtonElement>(null);
|
|
85
|
+
const focusConversation = useRef(false);
|
|
86
|
+
useLayoutEffect(() => {
|
|
87
|
+
if (!isPage) return;
|
|
88
|
+
const media = window.matchMedia("(max-width: 700px)");
|
|
89
|
+
const update = () => setIsMobile(media.matches);
|
|
90
|
+
update();
|
|
91
|
+
media.addEventListener("change", update);
|
|
92
|
+
return () => media.removeEventListener("change", update);
|
|
93
|
+
}, [isPage]);
|
|
94
|
+
useLayoutEffect(() => {
|
|
95
|
+
if (focusConversation.current && (!isMobile || mobileView === "chat")) {
|
|
96
|
+
pageTitleRef.current?.focus({ preventScroll: true });
|
|
97
|
+
focusConversation.current = false;
|
|
98
|
+
}
|
|
99
|
+
}, [isMobile, mobileView]);
|
|
100
|
+
const getReply = (text: string) => t.replies[t.questions.indexOf(text)] ?? t.fallbackReply;
|
|
101
|
+
const getTitle = (text: string) => t.threadTitles[t.questions.indexOf(text)] ?? Array.from(text).slice(0, 18).join("");
|
|
102
|
+
const { threads, activeThread, setActiveId, createThread, renameThread, deleteThread, setDraft, send, stop, edit, regenerate, isStreaming } = useChatDemo(getReply, getTitle);
|
|
103
|
+
const viewportRef = useRef<HTMLDivElement>(null);
|
|
104
|
+
const pageRef = useRef<HTMLDivElement>(null);
|
|
105
|
+
useLayoutEffect(() => {
|
|
106
|
+
if (!isPage) return;
|
|
107
|
+
const viewport = window.visualViewport;
|
|
108
|
+
const resize = () => {
|
|
109
|
+
pageRef.current?.style.setProperty("--chat-page-height", `${viewport?.height ?? window.innerHeight}px`);
|
|
110
|
+
pageRef.current?.style.setProperty("--chat-page-offset", `${viewport?.offsetTop ?? 0}px`);
|
|
111
|
+
};
|
|
112
|
+
resize();
|
|
113
|
+
viewport?.addEventListener("resize", resize);
|
|
114
|
+
viewport?.addEventListener("scroll", resize);
|
|
115
|
+
window.addEventListener("resize", resize);
|
|
116
|
+
return () => {
|
|
117
|
+
viewport?.removeEventListener("resize", resize);
|
|
118
|
+
viewport?.removeEventListener("scroll", resize);
|
|
119
|
+
window.removeEventListener("resize", resize);
|
|
120
|
+
};
|
|
121
|
+
}, [isPage]);
|
|
122
|
+
const composerRef = useRef<HTMLDivElement>(null);
|
|
123
|
+
const scrollPositions = useRef(new Map<string, number>());
|
|
124
|
+
const previousThread = useRef(activeThread.id);
|
|
125
|
+
const navigationSuspended = useRef(false);
|
|
126
|
+
const followLatest = useRef(true);
|
|
127
|
+
const focusAfterSend = useRef(false);
|
|
128
|
+
const newMessageIds = useRef(new Set<string>());
|
|
129
|
+
const hasMessages = activeThread.messages.length > 0;
|
|
130
|
+
|
|
131
|
+
useLayoutEffect(() => {
|
|
132
|
+
const viewport = viewportRef.current;
|
|
133
|
+
if (!viewport) return;
|
|
134
|
+
if (isPage && isMobile && mobileView === "threads") {
|
|
135
|
+
navigationSuspended.current = true;
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if (previousThread.current !== activeThread.id || navigationSuspended.current) {
|
|
139
|
+
viewport.scrollTop = scrollPositions.current.get(activeThread.id) ?? viewport.scrollHeight;
|
|
140
|
+
followLatest.current = viewport.scrollHeight - viewport.scrollTop - viewport.clientHeight < viewport.clientHeight * 0.1;
|
|
141
|
+
previousThread.current = activeThread.id;
|
|
142
|
+
navigationSuspended.current = false;
|
|
143
|
+
} else if (followLatest.current) {
|
|
144
|
+
viewport.scrollTop = viewport.scrollHeight;
|
|
145
|
+
}
|
|
146
|
+
if (focusAfterSend.current) {
|
|
147
|
+
composerRef.current?.querySelector("textarea")?.focus({ preventScroll: true });
|
|
148
|
+
focusAfterSend.current = false;
|
|
149
|
+
}
|
|
150
|
+
}, [activeThread.id, activeThread.messages, isPage, isMobile, mobileView]);
|
|
151
|
+
|
|
152
|
+
const saveScroll = () => {
|
|
153
|
+
newMessageIds.current.clear();
|
|
154
|
+
if (viewportRef.current && !(isPage && isMobile && mobileView === "threads")) scrollPositions.current.set(activeThread.id, viewportRef.current.scrollTop);
|
|
155
|
+
};
|
|
156
|
+
const sendPrompt = (text: string, focusInput = true) => {
|
|
157
|
+
if (!text.trim() || isStreaming) return;
|
|
158
|
+
followLatest.current = true;
|
|
159
|
+
focusAfterSend.current = focusInput;
|
|
160
|
+
newMessageIds.current.add(`${activeThread.id}-${activeThread.messages.length}-user`);
|
|
161
|
+
send(text);
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
const toggleHistory = () => {
|
|
165
|
+
saveScroll();
|
|
166
|
+
setMobileView((view) => view === "chat" ? "threads" : "chat");
|
|
167
|
+
};
|
|
168
|
+
const newChat = () => {
|
|
169
|
+
saveScroll();
|
|
170
|
+
createThread();
|
|
171
|
+
setThreadSearch("");
|
|
172
|
+
focusConversation.current = isMobile;
|
|
173
|
+
setMobileView("chat");
|
|
174
|
+
};
|
|
175
|
+
const normalizedSearch = threadSearch.trim().toLocaleLowerCase();
|
|
176
|
+
const historyThreads = [...threads].reverse().filter((thread) => thread.title || thread.messages.length > 0 || thread.draft.trim());
|
|
177
|
+
const visibleThreads = historyThreads.filter((thread) => [thread.title, thread.draft, ...thread.messages.map((message) => message.text)].join(" ").toLocaleLowerCase().includes(normalizedSearch));
|
|
178
|
+
|
|
179
|
+
const header = (
|
|
180
|
+
<div className={styles.header}>
|
|
181
|
+
<DropdownMenu open={threadMenuOpen} onOpenChange={setThreadMenuOpen}>
|
|
182
|
+
<DropdownMenu.Trigger asChild>
|
|
183
|
+
<Button
|
|
184
|
+
variant="ghost"
|
|
185
|
+
size="md"
|
|
186
|
+
className={styles.threadTrigger}
|
|
187
|
+
rightIcon={<Icon name="caret-down" />}
|
|
188
|
+
aria-label={`${t.switchThread}: ${activeThread.title || t.title}`}
|
|
189
|
+
>
|
|
190
|
+
<span className={styles.threadTitle}>{activeThread.title || t.title}</span>
|
|
191
|
+
</Button>
|
|
192
|
+
</DropdownMenu.Trigger>
|
|
193
|
+
<DropdownMenu.Content align="start" size="sm">
|
|
194
|
+
<DropdownMenu.Item
|
|
195
|
+
leadingActions={[{ node: <Icon name="plus" />, key: "new-thread" }]}
|
|
196
|
+
onSelect={() => { saveScroll(); createThread(); setThreadMenuOpen(false); }}
|
|
197
|
+
>
|
|
198
|
+
{t.createThread}
|
|
199
|
+
</DropdownMenu.Item>
|
|
200
|
+
{threads.some((thread) => thread.messages.length > 0 || thread.draft.trim()) && (
|
|
201
|
+
<>
|
|
202
|
+
<DropdownMenu.Separator />
|
|
203
|
+
<DropdownMenu.Group>
|
|
204
|
+
{[...threads].reverse()
|
|
205
|
+
.filter((thread) => thread.messages.length > 0 || thread.draft.trim())
|
|
206
|
+
.map((thread) => (
|
|
207
|
+
<DropdownMenu.Item
|
|
208
|
+
key={thread.id}
|
|
209
|
+
onSelect={() => { saveScroll(); setActiveId(thread.id); setThreadMenuOpen(false); }}
|
|
210
|
+
>
|
|
211
|
+
{thread.title || Array.from(thread.draft.trim()).slice(0, 18).join("")}
|
|
212
|
+
</DropdownMenu.Item>
|
|
213
|
+
))}
|
|
214
|
+
</DropdownMenu.Group>
|
|
215
|
+
</>
|
|
216
|
+
)}
|
|
217
|
+
</DropdownMenu.Content>
|
|
218
|
+
</DropdownMenu>
|
|
219
|
+
</div>
|
|
220
|
+
);
|
|
221
|
+
const viewport = (
|
|
222
|
+
<div
|
|
223
|
+
ref={viewportRef}
|
|
224
|
+
className={styles.viewport}
|
|
225
|
+
data-chat-viewport
|
|
226
|
+
tabIndex={hasMessages ? 0 : undefined}
|
|
227
|
+
aria-label={t.messagesLabel}
|
|
228
|
+
onScroll={(event) => {
|
|
229
|
+
if (isPage && isMobile && mobileView === "threads") return;
|
|
230
|
+
const viewport = event.currentTarget;
|
|
231
|
+
scrollPositions.current.set(activeThread.id, viewport.scrollTop);
|
|
232
|
+
followLatest.current = viewport.scrollHeight - viewport.scrollTop - viewport.clientHeight < viewport.clientHeight * 0.1;
|
|
233
|
+
}}
|
|
234
|
+
>
|
|
235
|
+
{hasMessages ? (
|
|
236
|
+
<div className={styles.messages} role="log" aria-live="polite" aria-relevant="additions text" aria-label={t.messagesLabel}>
|
|
237
|
+
{activeThread.messages.map((message) => message.role === "user" ? (
|
|
238
|
+
<UserMessage key={message.id} actionsVisibility="hover" textValue={message.text}
|
|
239
|
+
onEdit={(text) => edit(message.id, text)} animate={newMessageIds.current.has(message.id)}>
|
|
240
|
+
<span className={styles.messageText}>{message.text}</span>
|
|
241
|
+
</UserMessage>
|
|
242
|
+
) : (
|
|
243
|
+
<AIMessage key={message.id} actionsVisibility="hover" actions={[
|
|
244
|
+
{ kind: "copy", onClick: () => navigator.clipboard.writeText(message.text), successLabel: lang === "ko" ? "복사됨" : "Copied", errorLabel: lang === "ko" ? "복사 실패" : "Copy failed" },
|
|
245
|
+
{ kind: "regenerate", onClick: () => regenerate(message.id) },
|
|
246
|
+
]} isStreaming={message.isStreaming} className={styles.assistant}>
|
|
247
|
+
{message.text}
|
|
248
|
+
</AIMessage>
|
|
249
|
+
))}
|
|
250
|
+
</div>
|
|
251
|
+
) : !isPage ? (
|
|
252
|
+
<div className={styles.welcome}>
|
|
253
|
+
<p className={styles.greeting}>{t.greeting}</p>
|
|
254
|
+
<p className={styles.invitation}>{t.invitation}</p>
|
|
255
|
+
</div>
|
|
256
|
+
) : null}
|
|
257
|
+
</div>
|
|
258
|
+
);
|
|
259
|
+
const bottom = (
|
|
260
|
+
<div className={styles.bottom}>
|
|
261
|
+
{!isPage && !hasMessages && (
|
|
262
|
+
<div className={styles.questions} role="group" aria-label={t.suggestionsLabel}>
|
|
263
|
+
{t.questions.map((question) => (
|
|
264
|
+
<RadioCard
|
|
265
|
+
key={question}
|
|
266
|
+
mode="button"
|
|
267
|
+
onClick={(event) => sendPrompt(question, event.detail === 0)}
|
|
268
|
+
onFocus={(event) => event.currentTarget.scrollIntoView({ block: "nearest", inline: "nearest" })}
|
|
269
|
+
align="start"
|
|
270
|
+
size="md"
|
|
271
|
+
title={question}
|
|
272
|
+
className={styles.question}
|
|
273
|
+
/>
|
|
274
|
+
))}
|
|
275
|
+
</div>
|
|
276
|
+
)}
|
|
277
|
+
<AIChatInput
|
|
278
|
+
ref={composerRef}
|
|
279
|
+
shape={isPage ? "multi" : "single"}
|
|
280
|
+
appearance={isPage ? "outline" : "filled"}
|
|
281
|
+
separateSend={!isPage}
|
|
282
|
+
value={activeThread.draft}
|
|
283
|
+
onChange={setDraft}
|
|
284
|
+
onSend={() => sendPrompt(activeThread.draft)}
|
|
285
|
+
isStreaming={isStreaming}
|
|
286
|
+
onStop={stop}
|
|
287
|
+
sendVariant="solid"
|
|
288
|
+
placeholder={t.placeholder}
|
|
289
|
+
className={styles.composer}
|
|
290
|
+
/>
|
|
291
|
+
</div>
|
|
292
|
+
);
|
|
293
|
+
|
|
294
|
+
if (isPage) return (
|
|
295
|
+
<AppFrame ref={pageRef} variant="flat" layout="sidebar-first" className={styles.fullPage} data-ai-chat-page data-chat-thread={activeThread.id} data-mobile-view={mobileView} lang={lang}>
|
|
296
|
+
<AppFrame.Topbar>
|
|
297
|
+
<Topbar size="sm">
|
|
298
|
+
<Topbar.Leading className={styles.threadHeading}>
|
|
299
|
+
<span ref={pageTitleRef} tabIndex={-1} className={styles.pageThreadTitle}>
|
|
300
|
+
{isMobile ? (
|
|
301
|
+
<Button ref={historyToggleRef} variant="ghost" size="md" className={styles.mobileThreadTrigger} aria-label={`${mobileView === "threads" ? t.hideHistory : t.showHistory}: ${activeThread.title || t.title}`} aria-expanded={mobileView === "threads"} aria-controls="chat-history" rightIcon={<Icon name={mobileView === "threads" ? "caret-up" : "caret-down"} />} onClick={toggleHistory}>
|
|
302
|
+
{activeThread.title || t.title}
|
|
303
|
+
</Button>
|
|
304
|
+
) : activeThread.title || t.title}
|
|
305
|
+
</span>
|
|
306
|
+
</Topbar.Leading>
|
|
307
|
+
<Topbar.Trailing>
|
|
308
|
+
<DropdownMenu modal={false}>
|
|
309
|
+
<DropdownMenu.Trigger asChild>
|
|
310
|
+
<IconButton ref={threadActionsRef} variant="ghost" size="sm" icon={<Icon name="dots-three" />} aria-label={lang === "ko" ? "대화 메뉴" : "Chat menu"} />
|
|
311
|
+
</DropdownMenu.Trigger>
|
|
312
|
+
<DropdownMenu.Content align="end" size="sm">
|
|
313
|
+
<DropdownMenu.Item leadingActions={[{ node: <Icon name="pencil" />, key: "rename" }]} onSelect={() => { setThreadName(activeThread.title || t.title); setRenameTarget(activeThread.id); }}>
|
|
314
|
+
{lang === "ko" ? "이름 변경" : "Rename"}
|
|
315
|
+
</DropdownMenu.Item>
|
|
316
|
+
<DropdownMenu.Item leadingActions={[{ node: <Icon name="trash" />, key: "delete" }]} onSelect={() => { scrollPositions.current.delete(activeThread.id); deleteThread(activeThread.id); setThreadSearch(""); }}>
|
|
317
|
+
{lang === "ko" ? "삭제" : "Delete"}
|
|
318
|
+
</DropdownMenu.Item>
|
|
319
|
+
</DropdownMenu.Content>
|
|
320
|
+
</DropdownMenu>
|
|
321
|
+
</Topbar.Trailing>
|
|
322
|
+
</Topbar>
|
|
323
|
+
<Modal open={renameTarget !== null} onOpenChange={(open) => { if (!open) setRenameTarget(null); }} onCloseAutoFocus={(event) => { event.preventDefault(); threadActionsRef.current?.focus(); }} size="sm" title={lang === "ko" ? "쓰레드 이름 변경" : "Rename thread"} dismissLabel={lang === "ko" ? "닫기" : "Close"}
|
|
324
|
+
footer={<><Button variant="outline" onClick={() => setRenameTarget(null)}>{lang === "ko" ? "취소" : "Cancel"}</Button><Button variant="primary" type="submit" form="rename-chat-thread" disabled={!threadName.trim()}>{lang === "ko" ? "저장" : "Save"}</Button></>}
|
|
325
|
+
>
|
|
326
|
+
<form id="rename-chat-thread" onSubmit={(event) => { event.preventDefault(); if (renameTarget && threadName.trim()) { renameThread(renameTarget, threadName); setRenameTarget(null); } }}>
|
|
327
|
+
<Input autoFocus aria-label={lang === "ko" ? "쓰레드 이름" : "Thread name"} variant="outline" value={threadName} onChange={(event) => setThreadName(event.target.value)} />
|
|
328
|
+
</form>
|
|
329
|
+
</Modal>
|
|
330
|
+
</AppFrame.Topbar>
|
|
331
|
+
<AppFrame.Sidebar>
|
|
332
|
+
<Sidebar id="chat-history" className={styles.history} aria-label={t.history} onKeyDown={(event) => {
|
|
333
|
+
if (event.key === "Escape" && isMobile) {
|
|
334
|
+
event.preventDefault();
|
|
335
|
+
setMobileView("chat");
|
|
336
|
+
historyToggleRef.current?.focus({ preventScroll: true });
|
|
337
|
+
}
|
|
338
|
+
}}>
|
|
339
|
+
<Sidebar.Header>
|
|
340
|
+
<div className={styles.historyHeaderInner}>
|
|
341
|
+
<h2 className={styles.historyTitle}>{t.history}</h2>
|
|
342
|
+
<Button variant="primary" size="md" fullWidth leftIcon={<Icon name="plus" />} onClick={newChat}>{t.createThread}</Button>
|
|
343
|
+
<form role="search" aria-label={t.searchChats} onSubmit={(event) => event.preventDefault()}>
|
|
344
|
+
<Input ref={searchRef} type="text" enterKeyHint="search" variant="outline" size="md" aria-label={t.searchChats} placeholder={t.searchChats} leftIcon={<Icon name="search" />} value={threadSearch} onChange={(event) => setThreadSearch(event.target.value)} clearable onClear={() => setThreadSearch("")} />
|
|
345
|
+
</form>
|
|
346
|
+
</div>
|
|
347
|
+
</Sidebar.Header>
|
|
348
|
+
<Sidebar.Body>
|
|
349
|
+
<div className={styles.historyBodyInner}>
|
|
350
|
+
<MenuItem.Section title={normalizedSearch ? t.searchResults : t.recentChats} size="sm" collapsible={false}>
|
|
351
|
+
{visibleThreads.map((thread) => (
|
|
352
|
+
<MenuItem key={thread.id} role="button" size="md" active={thread.id === activeThread.id} activeStyle="fill" aria-current={thread.id === activeThread.id ? "page" : undefined} leadingActions={[{ node: <Icon name="chat-circle" />, key: "thread" }]} onClick={() => {
|
|
353
|
+
saveScroll();
|
|
354
|
+
setActiveId(thread.id);
|
|
355
|
+
focusConversation.current = isMobile;
|
|
356
|
+
setMobileView("chat");
|
|
357
|
+
}}>{thread.title || Array.from(thread.draft.trim()).slice(0, 18).join("")}</MenuItem>
|
|
358
|
+
))}
|
|
359
|
+
</MenuItem.Section>
|
|
360
|
+
{visibleThreads.length === 0 && <EmptyState className={styles.historyEmpty} size="sm" icon={normalizedSearch ? "search" : "chat-circle"} title={normalizedSearch ? t.noResults : t.noChats} role="status" />}
|
|
361
|
+
</div>
|
|
362
|
+
</Sidebar.Body>
|
|
363
|
+
</Sidebar>
|
|
364
|
+
</AppFrame.Sidebar>
|
|
365
|
+
<AppFrame.Content>
|
|
366
|
+
<main className={styles.pageBody} aria-label={t.messagesLabel}>{viewport}{bottom}</main>
|
|
367
|
+
</AppFrame.Content>
|
|
368
|
+
</AppFrame>
|
|
369
|
+
);
|
|
370
|
+
return (
|
|
371
|
+
<Card variant="line" size="lg" className={styles.card} data-ai-chat-card data-chat-thread={activeThread.id} lang={lang}>
|
|
372
|
+
{header}{viewport}{bottom}
|
|
373
|
+
</Card>
|
|
374
|
+
);
|
|
375
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { ThemeLocaleProvider } from "@/components/ovenn/ThemeController";
|
|
4
|
+
import { ChatExperience } from "./ChatExperience";
|
|
5
|
+
|
|
6
|
+
export function FullPageChat({ lang = "ko" }: { lang?: "ko" | "en" }) {
|
|
7
|
+
return <ThemeLocaleProvider lang={lang}><ChatExperience lang={lang} presentation="page" /></ThemeLocaleProvider>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# 쓰레드 탐색형 풀페이지 AI 채팅
|
|
2
|
+
|
|
3
|
+
2026-11-09 사용자가 현재 화면을 참고 예시로 저장하도록 승인했다. 독립 경로 `/ai-chat`은 문서 메뉴·검색·사용사례에 노출하지 않는다.
|
|
4
|
+
|
|
5
|
+
## 참고 범위
|
|
6
|
+
|
|
7
|
+
- 왼쪽 전체 높이 Sidebar 옆에 얇은 Topbar와 대화 본문을 놓는 `sidebar-first` AppFrame 구성.
|
|
8
|
+
- Sidebar의 새 대화·검색·쓰레드 목록, 남은 목록 영역 중앙의 EmptyState.
|
|
9
|
+
- Topbar 왼쪽 쓰레드명과 오른쪽 이름 변경·삭제 메뉴.
|
|
10
|
+
- 본문만 스크롤하고 하단 ChatInput을 유지하는 구성. 풀페이지에는 인사말·추천 질문을 넣지 않는다.
|
|
11
|
+
- 모바일에서는 제목의 caret으로 쓰레드 목록과 대화 화면을 전환한다. Drawer를 사용하지 않는다.
|
|
12
|
+
|
|
13
|
+
## 소스와 의존성
|
|
14
|
+
|
|
15
|
+
catalog.json의 files.source가 저장소 원본이다. FullPageChat → ChatExperience → useChatDemo → useDemoTextStream 순으로 연결된다. 공유 Ovenn 컴포넌트와 tokens.css는 별도 의존성이며, 참고 코드를 복사할 때 현재 설치 API와 테마를 확인한다. ChatExperience의 카드 분기는 공용 소스에 포함되지만 이 승인 사례의 주 범위는 풀페이지다.
|
|
16
|
+
|
|
17
|
+
## 확인 한계
|
|
18
|
+
|
|
19
|
+
응답은 로컬 시나리오이며 실제 AI API·저장소·인증에 연결되어 있지 않다. 새로고침하면 대화가 초기화된다. 첨부 버튼은 연결되지 않았다. 이름 변경·삭제·검색·모바일 전환은 구현되어 있으나 이 등록이 모든 동작·테마·보조기술 검증을 뜻하지 않는다. 대표 캡처는 1440×900 라이트 모드의 한 쓰레드 대화 상태다.
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useRef, useState } from "react";
|
|
4
|
+
import { useDemoTextStream } from "./useDemoTextStream";
|
|
5
|
+
|
|
6
|
+
export type ChatDemoMessage = { id: string; role: "user" | "assistant"; text: string; isStreaming?: boolean };
|
|
7
|
+
export type ChatDemoThread = {
|
|
8
|
+
id: string;
|
|
9
|
+
title: string;
|
|
10
|
+
draft: string;
|
|
11
|
+
messages: ChatDemoMessage[];
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export function useChatDemo(getReply: (text: string) => string, getTitle: (text: string) => string) {
|
|
15
|
+
const sequence = useRef(1);
|
|
16
|
+
const delivery = useDemoTextStream();
|
|
17
|
+
const pendingThreads = useRef(new Set<string>());
|
|
18
|
+
const [threads, setThreads] = useState<ChatDemoThread[]>([
|
|
19
|
+
{ id: "chat-0", title: "", draft: "", messages: [] },
|
|
20
|
+
]);
|
|
21
|
+
const [activeId, setActiveId] = useState("chat-0");
|
|
22
|
+
const activeThread = threads.find((thread) => thread.id === activeId) ?? threads[0];
|
|
23
|
+
|
|
24
|
+
const setDraft = (draft: string) => {
|
|
25
|
+
setThreads((previous) => previous.map((thread) => thread.id === activeId ? { ...thread, draft } : thread));
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const send = (text: string) => {
|
|
29
|
+
const value = text.trim();
|
|
30
|
+
if (!value || pendingThreads.current.has(activeId)) return;
|
|
31
|
+
const targetId = activeId;
|
|
32
|
+
const baseMessages = activeThread.messages;
|
|
33
|
+
const messageId = `${targetId}-${baseMessages.length}`;
|
|
34
|
+
const assistantId = `${messageId}-assistant`;
|
|
35
|
+
pendingThreads.current.add(targetId);
|
|
36
|
+
setThreads((previous) => previous.map((thread) => {
|
|
37
|
+
if (thread.id !== activeId) return thread;
|
|
38
|
+
return {
|
|
39
|
+
...thread,
|
|
40
|
+
title: thread.title || getTitle(value),
|
|
41
|
+
draft: "",
|
|
42
|
+
messages: [
|
|
43
|
+
...baseMessages,
|
|
44
|
+
{ id: `${messageId}-user`, role: "user", text: value },
|
|
45
|
+
{ id: `${messageId}-assistant`, role: "assistant", text: "", isStreaming: true },
|
|
46
|
+
],
|
|
47
|
+
};
|
|
48
|
+
}));
|
|
49
|
+
delivery.start(targetId, getReply(value), (reply, isStreaming) => {
|
|
50
|
+
if (!isStreaming) pendingThreads.current.delete(targetId);
|
|
51
|
+
setThreads((previous) => previous.map((thread) => thread.id === targetId ? {
|
|
52
|
+
...thread,
|
|
53
|
+
messages: thread.messages.map((message) => message.id === assistantId ? { ...message, text: reply, isStreaming } : message),
|
|
54
|
+
} : thread));
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const stop = () => {
|
|
59
|
+
delivery.stop(activeId);
|
|
60
|
+
pendingThreads.current.delete(activeId);
|
|
61
|
+
setThreads((previous) => previous.map((thread) => thread.id === activeId ? {
|
|
62
|
+
...thread, messages: thread.messages.map((message) => message.isStreaming ? { ...message, isStreaming: false } : message),
|
|
63
|
+
} : thread));
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const edit = (messageId: string, text: string) => {
|
|
67
|
+
const value = text.trim();
|
|
68
|
+
const index = activeThread.messages.findIndex((message) => message.id === messageId && message.role === "user");
|
|
69
|
+
if (!value || index < 0) return;
|
|
70
|
+
const targetId = activeId;
|
|
71
|
+
const assistantId = `${targetId}-${index}-assistant`;
|
|
72
|
+
delivery.stop(targetId);
|
|
73
|
+
pendingThreads.current.add(targetId);
|
|
74
|
+
setThreads((previous) => previous.map((thread) => thread.id === targetId ? {
|
|
75
|
+
...thread,
|
|
76
|
+
messages: [
|
|
77
|
+
...thread.messages.slice(0, index),
|
|
78
|
+
{ id: messageId, role: "user", text: value },
|
|
79
|
+
{ id: assistantId, role: "assistant", text: "", isStreaming: true },
|
|
80
|
+
],
|
|
81
|
+
} : thread));
|
|
82
|
+
delivery.start(targetId, getReply(value), (reply, streaming) => {
|
|
83
|
+
if (!streaming) pendingThreads.current.delete(targetId);
|
|
84
|
+
setThreads((previous) => previous.map((thread) => thread.id === targetId ? {
|
|
85
|
+
...thread,
|
|
86
|
+
messages: thread.messages.map((message) => message.id === assistantId ? { ...message, text: reply, isStreaming: streaming } : message),
|
|
87
|
+
} : thread));
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const regenerate = (messageId: string) => {
|
|
92
|
+
if (pendingThreads.current.has(activeId)) return;
|
|
93
|
+
const index = activeThread.messages.findIndex((message) => message.id === messageId && message.role === "assistant");
|
|
94
|
+
const prompt = activeThread.messages[index - 1];
|
|
95
|
+
if (index < 1 || prompt?.role !== "user") return;
|
|
96
|
+
const targetId = activeId;
|
|
97
|
+
pendingThreads.current.add(targetId);
|
|
98
|
+
setThreads((previous) => previous.map((thread) => thread.id === targetId ? {
|
|
99
|
+
...thread,
|
|
100
|
+
messages: [...thread.messages.slice(0, index), { id: messageId, role: "assistant", text: "", isStreaming: true }],
|
|
101
|
+
} : thread));
|
|
102
|
+
delivery.start(targetId, getReply(prompt.text), (text, streaming) => {
|
|
103
|
+
if (!streaming) pendingThreads.current.delete(targetId);
|
|
104
|
+
setThreads((previous) => previous.map((thread) => thread.id === targetId ? {
|
|
105
|
+
...thread,
|
|
106
|
+
messages: thread.messages.map((message) => message.id === messageId ? { ...message, text, isStreaming: streaming } : message),
|
|
107
|
+
} : thread));
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const createThread = () => {
|
|
112
|
+
const empty = threads.find((thread) => thread.messages.length === 0 && !thread.draft && !thread.title);
|
|
113
|
+
if (empty) {
|
|
114
|
+
setActiveId(empty.id);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const id = `chat-${sequence.current++}`;
|
|
118
|
+
setThreads((previous) => [...previous, { id, title: "", draft: "", messages: [] }]);
|
|
119
|
+
setActiveId(id);
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const renameThread = (id: string, title: string) => {
|
|
123
|
+
if (!title.trim()) return;
|
|
124
|
+
setThreads((previous) => previous.map((thread) => thread.id === id ? { ...thread, title: title.trim() } : thread));
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const deleteThread = (id: string) => {
|
|
128
|
+
delivery.stop(id);
|
|
129
|
+
pendingThreads.current.delete(id);
|
|
130
|
+
const remaining = threads.filter((thread) => thread.id !== id);
|
|
131
|
+
if (!remaining.length) {
|
|
132
|
+
remaining.push({ id: `chat-${sequence.current++}`, title: "", draft: "", messages: [] });
|
|
133
|
+
}
|
|
134
|
+
setThreads(remaining);
|
|
135
|
+
if (activeId === id) setActiveId(remaining[remaining.length - 1].id);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
return { threads, activeThread, setActiveId, createThread, renameThread, deleteThread, setDraft, send, stop, edit, regenerate, isStreaming: activeThread.messages.some((message) => message.isStreaming) };
|
|
139
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useCallback, useEffect, useRef } from "react";
|
|
4
|
+
|
|
5
|
+
/** Local demo transport. UI components render incoming text without delaying real data. */
|
|
6
|
+
export function useDemoTextStream() {
|
|
7
|
+
const jobs = useRef(new Map<string, ReturnType<typeof setInterval>>());
|
|
8
|
+
const stop = useCallback((id: string) => {
|
|
9
|
+
clearInterval(jobs.current.get(id));
|
|
10
|
+
jobs.current.delete(id);
|
|
11
|
+
}, []);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
const pending = jobs.current;
|
|
14
|
+
return () => { pending.forEach(clearInterval); pending.clear(); };
|
|
15
|
+
}, []);
|
|
16
|
+
const start = useCallback((id: string, text: string, update: (text: string, streaming: boolean) => void) => {
|
|
17
|
+
stop(id);
|
|
18
|
+
const characters = Array.from(new Intl.Segmenter(undefined, { granularity: "grapheme" }).segment(text), (part) => part.segment);
|
|
19
|
+
let index = 0;
|
|
20
|
+
update("", characters.length > 0);
|
|
21
|
+
if (!characters.length) return;
|
|
22
|
+
jobs.current.set(id, setInterval(() => {
|
|
23
|
+
index += 1;
|
|
24
|
+
const streaming = index < characters.length;
|
|
25
|
+
if (!streaming) stop(id);
|
|
26
|
+
update(characters.slice(0, index).join(""), streaming);
|
|
27
|
+
}, 24));
|
|
28
|
+
}, [stop]);
|
|
29
|
+
return { start, stop };
|
|
30
|
+
}
|
|
@@ -41,3 +41,5 @@ Radix의 `data-side`가 앵커 위치 반대 방향에서 등장하도록 자동
|
|
|
41
41
|
| `bottom` | `m-emerge-from-top` | 위에서 내려옴 |
|
|
42
42
|
| `left` | `m-emerge-from-right` | 오른쪽에서 옴 |
|
|
43
43
|
| `right` | `m-emerge-from-left` | 왼쪽에서 옴 |
|
|
44
|
+
|
|
45
|
+
- 공용 m-float의 열기 시간은 --float-open-duration으로 좁은 scope에서 조절할 수 있다. 기본은 duration-base이며, 이모지 픽커처럼 즉시 선택하는 패널은 duration-fast를 사용한다. 기존 keyframes·닫기·reduced-motion 계약은 유지한다.
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
생성 원본: web/lib/templates/generated-artifacts.json. 이 목록은 부분 템플릿이며 전체 업무 화면을 대신하지 않는다.
|
|
4
4
|
|
|
5
|
+
- [onboarding@1.0.0](onboarding.md)
|
|
5
6
|
- [minimal@1.0.0](minimal.md)
|
|
6
7
|
- [workspace@1.0.0](workspace.md)
|
|
7
8
|
- [aurora@1.0.0](aurora.md)
|
|
8
9
|
- [ains@1.0.0](ains.md)
|
|
9
|
-
- [glass-button@1.0.0](glass-button.md)
|
|
@@ -461,6 +461,7 @@ export function AinsSidebar({ lang = "ko" as Locale }: { lang?: Locale } = {}) {
|
|
|
461
461
|
|
|
462
462
|
/* ───────── Rail ───────── */
|
|
463
463
|
.rail {
|
|
464
|
+
background: var(--fixed-white);
|
|
464
465
|
display: flex;
|
|
465
466
|
flex-direction: column;
|
|
466
467
|
align-items: center;
|
|
@@ -535,6 +536,7 @@ export function AinsSidebar({ lang = "ko" as Locale }: { lang?: Locale } = {}) {
|
|
|
535
536
|
|
|
536
537
|
/* ───────── Panel ───────── */
|
|
537
538
|
.panel {
|
|
539
|
+
background: var(--fixed-white);
|
|
538
540
|
display: flex;
|
|
539
541
|
flex-direction: column;
|
|
540
542
|
width: var(--sidebar-w);
|
|
@@ -545,6 +547,11 @@ export function AinsSidebar({ lang = "ko" as Locale }: { lang?: Locale } = {}) {
|
|
|
545
547
|
flex: 0 0 auto;
|
|
546
548
|
}
|
|
547
549
|
|
|
550
|
+
:global([data-mode="dark"]) .root .rail,
|
|
551
|
+
:global([data-mode="dark"]) .root .panel {
|
|
552
|
+
background: var(--fixed-black);
|
|
553
|
+
}
|
|
554
|
+
|
|
548
555
|
.panelHeader {
|
|
549
556
|
display: flex;
|
|
550
557
|
align-items: center;
|
|
@@ -167,11 +167,17 @@ export function MonographSidebar({ lang = "ko" as Locale }: { lang?: Locale } =
|
|
|
167
167
|
|
|
168
168
|
.nav > * {
|
|
169
169
|
padding-inline: var(--space-4) var(--space-2);
|
|
170
|
+
font-weight: var(--font-weight-medium);
|
|
170
171
|
corner-shape: var(--corner-shape);
|
|
171
172
|
border-radius: 0;
|
|
172
173
|
min-height: calc(var(--control-h-lg) + var(--space-1));
|
|
173
174
|
}
|
|
174
175
|
|
|
176
|
+
/* Preserve full-bleed alignment while pressing a menu item. */
|
|
177
|
+
.nav > :active:not([aria-disabled="true"]) {
|
|
178
|
+
transform: none;
|
|
179
|
+
}
|
|
180
|
+
|
|
175
181
|
/* active bar — 세로 거의 전체, 굵기는 얇게 (hairline). */
|
|
176
182
|
.nav > [data-active][data-active-style="plain"]::before {
|
|
177
183
|
top: 50%;
|