hermium 0.2.0 → 0.3.1
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/bin/hermium.mjs +103 -58
- package/dist/api.mjs +35 -0
- package/dist/public/assets/css/styles-o9LLzp-x.css +1 -0
- package/dist/public/assets/js/{ChatInputBlock-Bw7AL70H.js → ChatInputBlock-BgJMx5nW.js} +1 -1
- package/dist/public/assets/js/{MarkdownMessage-8d7Y6VL-.js → MarkdownMessage-Dd6VsKhk.js} +1 -1
- package/dist/public/assets/js/{base-ui-BvQbAt_1.js → base-ui-Ls-HE_Zl.js} +1 -1
- package/dist/public/assets/js/{chat._sessionId-BG6lVraH.js → chat._sessionId-Yif-J0_7.js} +1 -1
- package/dist/public/assets/js/{chat.index-D2zdMPTT.js → chat.index-QgwoSqOs.js} +1 -1
- package/dist/public/assets/js/{index-C0AK45FU.js → index-BDLsrzTe.js} +26 -26
- package/dist/public/assets/js/{index-Cx5En4FK.js → index-DRH0t4ti.js} +1 -1
- package/dist/public/assets/js/{memory-CeSRdTkW.js → memory-CHpNNtU2.js} +1 -1
- package/dist/public/assets/js/{router-8uDKazL-.js → router-B8BATVn7.js} +1 -1
- package/dist/public/assets/js/{settings-Bc3Y5zXO.js → settings-CRV3Pp8x.js} +1 -1
- package/dist/public/assets/js/{skills-DZv7sA_5.js → skills-C8G72gXr.js} +1 -1
- package/dist/public/assets/js/{usage-DXQsT9_b.js → usage-Bev8hqwh.js} +1 -1
- package/dist/server/__23tanstack-start-plugin-adapters-Cwee5PKy.mjs +6 -0
- package/dist/server/_chunks/ssr-renderer.mjs +22 -0
- package/dist/server/_libs/bail.mjs +8 -0
- package/dist/server/_libs/base-ui__react.mjs +9858 -0
- package/dist/server/_libs/base-ui__utils.mjs +1106 -0
- package/dist/server/_libs/ccount.mjs +16 -0
- package/dist/server/_libs/character-entities.mjs +2130 -0
- package/dist/server/_libs/class-variance-authority.mjs +44 -0
- package/dist/server/_libs/clsx.mjs +16 -0
- package/dist/server/_libs/comma-separated-tokens.mjs +10 -0
- package/dist/server/_libs/cookie-es.mjs +1 -0
- package/dist/server/_libs/croner.mjs +1 -0
- package/dist/server/_libs/crossws.mjs +1 -0
- package/dist/server/_libs/decode-named-character-reference+[...].mjs +8 -0
- package/dist/server/_libs/devlop.mjs +8 -0
- package/dist/server/_libs/escape-string-regexp.mjs +9 -0
- package/dist/server/_libs/estree-util-is-identifier-name.mjs +11 -0
- package/dist/server/_libs/extend.mjs +97 -0
- package/dist/server/_libs/floating-ui__core.mjs +663 -0
- package/dist/server/_libs/floating-ui__dom.mjs +624 -0
- package/dist/server/_libs/floating-ui__react-dom.mjs +279 -0
- package/dist/server/_libs/floating-ui__utils.mjs +322 -0
- package/dist/server/_libs/h3.mjs +408 -0
- package/dist/server/_libs/hast-util-is-element.mjs +75 -0
- package/dist/server/_libs/hast-util-to-jsx-runtime.mjs +388 -0
- package/dist/server/_libs/hast-util-to-text.mjs +305 -0
- package/dist/server/_libs/hast-util-whitespace.mjs +10 -0
- package/dist/server/_libs/highlight.js.mjs +14756 -0
- package/dist/server/_libs/hookable.mjs +1 -0
- package/dist/server/_libs/html-url-attributes.mjs +26 -0
- package/dist/server/_libs/inline-style-parser.mjs +142 -0
- package/dist/server/_libs/is-plain-obj.mjs +10 -0
- package/dist/server/_libs/isbot.mjs +21 -0
- package/dist/server/_libs/longest-streak.mjs +25 -0
- package/dist/server/_libs/lowlight.mjs +262 -0
- package/dist/server/_libs/markdown-table.mjs +142 -0
- package/dist/server/_libs/mdast-util-find-and-replace.mjs +109 -0
- package/dist/server/_libs/mdast-util-from-markdown.mjs +717 -0
- package/dist/server/_libs/mdast-util-gfm-autolink-literal+[...].mjs +156 -0
- package/dist/server/_libs/mdast-util-gfm-footnote.mjs +117 -0
- package/dist/server/_libs/mdast-util-gfm-strikethrough.mjs +54 -0
- package/dist/server/_libs/mdast-util-gfm-table.mjs +157 -0
- package/dist/server/_libs/mdast-util-gfm-task-list-item.mjs +77 -0
- package/dist/server/_libs/mdast-util-gfm.mjs +29 -0
- package/dist/server/_libs/mdast-util-phrasing.mjs +30 -0
- package/dist/server/_libs/mdast-util-to-hast.mjs +710 -0
- package/dist/server/_libs/mdast-util-to-markdown.mjs +798 -0
- package/dist/server/_libs/mdast-util-to-string.mjs +38 -0
- package/dist/server/_libs/micromark-core-commonmark.mjs +2259 -0
- package/dist/server/_libs/micromark-extension-gfm-autolink-literal+[...].mjs +344 -0
- package/dist/server/_libs/micromark-extension-gfm-footnote+[...].mjs +279 -0
- package/dist/server/_libs/micromark-extension-gfm-strikethrough+[...].mjs +98 -0
- package/dist/server/_libs/micromark-extension-gfm-table.mjs +491 -0
- package/dist/server/_libs/micromark-extension-gfm-tagfilter+[...].mjs +1 -0
- package/dist/server/_libs/micromark-extension-gfm-task-list-item+[...].mjs +77 -0
- package/dist/server/_libs/micromark-extension-gfm.mjs +18 -0
- package/dist/server/_libs/micromark-factory-destination.mjs +94 -0
- package/dist/server/_libs/micromark-factory-label.mjs +63 -0
- package/dist/server/_libs/micromark-factory-space.mjs +24 -0
- package/dist/server/_libs/micromark-factory-title.mjs +65 -0
- package/dist/server/_libs/micromark-factory-whitespace.mjs +22 -0
- package/dist/server/_libs/micromark-util-character.mjs +44 -0
- package/dist/server/_libs/micromark-util-chunked.mjs +36 -0
- package/dist/server/_libs/micromark-util-classify-character+[...].mjs +12 -0
- package/dist/server/_libs/micromark-util-combine-extensions+[...].mjs +41 -0
- package/dist/server/_libs/micromark-util-decode-numeric-character-reference+[...].mjs +19 -0
- package/dist/server/_libs/micromark-util-decode-string.mjs +21 -0
- package/dist/server/_libs/micromark-util-encode.mjs +1 -0
- package/dist/server/_libs/micromark-util-html-tag-name.mjs +69 -0
- package/dist/server/_libs/micromark-util-normalize-identifier+[...].mjs +6 -0
- package/dist/server/_libs/micromark-util-resolve-all.mjs +15 -0
- package/dist/server/_libs/micromark-util-sanitize-uri.mjs +41 -0
- package/dist/server/_libs/micromark-util-subtokenize.mjs +346 -0
- package/dist/server/_libs/micromark.mjs +906 -0
- package/dist/server/_libs/ocache.mjs +1 -0
- package/dist/server/_libs/ohash.mjs +1 -0
- package/dist/server/_libs/property-information.mjs +1209 -0
- package/dist/server/_libs/react-dom.mjs +10779 -0
- package/dist/server/_libs/react-markdown.mjs +147 -0
- package/dist/server/_libs/react.mjs +513 -0
- package/dist/server/_libs/rehype-highlight.mjs +94 -0
- package/dist/server/_libs/remark-gfm.mjs +20 -0
- package/dist/server/_libs/remark-parse.mjs +19 -0
- package/dist/server/_libs/remark-rehype.mjs +21 -0
- package/dist/server/_libs/reselect.mjs +1 -0
- package/dist/server/_libs/rou3.mjs +8 -0
- package/dist/server/_libs/seroval-plugins.mjs +1 -0
- package/dist/server/_libs/seroval.mjs +1 -0
- package/dist/server/_libs/space-separated-tokens.mjs +6 -0
- package/dist/server/_libs/srvx.mjs +781 -0
- package/dist/server/_libs/style-to-js.mjs +72 -0
- package/dist/server/_libs/style-to-object.mjs +38 -0
- package/dist/server/_libs/tabler__icons-react.mjs +140 -0
- package/dist/server/_libs/tailwind-merge.mjs +3255 -0
- package/dist/server/_libs/tanstack__history.mjs +29 -0
- package/dist/server/_libs/tanstack__react-router.mjs +1120 -0
- package/dist/server/_libs/tanstack__react-store.mjs +2 -0
- package/dist/server/_libs/tanstack__router-core.mjs +3594 -0
- package/dist/server/_libs/tanstack__store.mjs +1 -0
- package/dist/server/_libs/trim-lines.mjs +41 -0
- package/dist/server/_libs/trough.mjs +85 -0
- package/dist/server/_libs/ufo.mjs +54 -0
- package/dist/server/_libs/unctx.mjs +1 -0
- package/dist/server/_libs/ungap__structured-clone.mjs +224 -0
- package/dist/server/_libs/unified.mjs +661 -0
- package/dist/server/_libs/unist-util-find-after.mjs +41 -0
- package/dist/server/_libs/unist-util-is.mjs +100 -0
- package/dist/server/_libs/unist-util-position.mjs +27 -0
- package/dist/server/_libs/unist-util-stringify-position.mjs +27 -0
- package/dist/server/_libs/unist-util-visit-parents.mjs +83 -0
- package/dist/server/_libs/unist-util-visit.mjs +24 -0
- package/dist/server/_libs/unstorage.mjs +1 -0
- package/dist/server/_libs/use-sync-external-store.mjs +139 -0
- package/dist/server/_libs/vfile-message.mjs +138 -0
- package/dist/server/_libs/vfile.mjs +467 -0
- package/dist/server/_libs/zustand.mjs +43 -0
- package/dist/server/_libs/zwitch.mjs +1 -0
- package/dist/server/_ssr/ChatInputBlock-Bu2-iop_.mjs +220 -0
- package/dist/server/_ssr/MarkdownMessage-CNS7OSKN.mjs +68 -0
- package/dist/server/_ssr/chat._sessionId-P02iSfut.mjs +477 -0
- package/dist/server/_ssr/chat.index-BYB_48NC.mjs +64 -0
- package/dist/server/_ssr/index-C1mT_2d8.mjs +4890 -0
- package/dist/server/_ssr/index-DFV9_oCk.mjs +43 -0
- package/dist/server/_ssr/memory-CW_fSOG9.mjs +257 -0
- package/dist/server/_ssr/router-CUAfx91O.mjs +2035 -0
- package/dist/server/_ssr/settings-DoXurzvn.mjs +10 -0
- package/dist/server/_ssr/skills-Cs7A5ZwO.mjs +422 -0
- package/dist/server/_ssr/theme-BK4-7E2h.mjs +42 -0
- package/dist/server/_ssr/usage-Bs2-LXGz.mjs +298 -0
- package/dist/server/_tanstack-start-manifest_v-C7Upe2TI.mjs +4 -0
- package/dist/server/index.mjs +506 -0
- package/dist/server/public/assets/css/index-Dfs9RUU9.css +1 -0
- package/dist/server/public/assets/css/styles-o9LLzp-x.css +1 -0
- package/dist/server/public/assets/js/ChatInputBlock-BgJMx5nW.js +1 -0
- package/dist/server/public/assets/js/MarkdownMessage-Dd6VsKhk.js +1 -0
- package/dist/server/public/assets/js/base-ui-Ls-HE_Zl.js +1 -0
- package/dist/server/public/assets/js/chat._sessionId-Yif-J0_7.js +1 -0
- package/dist/server/public/assets/js/chat.index-QgwoSqOs.js +1 -0
- package/dist/server/public/assets/js/index-BDLsrzTe.js +60 -0
- package/dist/server/public/assets/js/index-DRH0t4ti.js +1 -0
- package/dist/server/public/assets/js/memory-CHpNNtU2.js +3 -0
- package/dist/server/public/assets/js/router-B8BATVn7.js +1 -0
- package/dist/server/public/assets/js/settings-CRV3Pp8x.js +1 -0
- package/dist/server/public/assets/js/skills-C8G72gXr.js +1 -0
- package/dist/server/public/assets/js/theme-CPkdkpaj.js +1 -0
- package/dist/server/public/assets/js/usage-Bev8hqwh.js +1 -0
- package/dist/server/public/assets/woff2/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
- package/dist/server/public/assets/woff2/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
- package/dist/server/public/assets/woff2/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
- package/dist/server/public/assets/woff2/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
- package/dist/server/public/assets/woff2/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
- package/dist/server/public/favicon.ico +0 -0
- package/dist/server/public/logo.png +0 -0
- package/dist/server/public/manifest.json +25 -0
- package/dist/server/public/robots.txt +3 -0
- package/package.json +4 -3
- package/dist/public/assets/css/styles-B8p6jk5Z.css +0 -1
|
@@ -0,0 +1,477 @@
|
|
|
1
|
+
import { r as reactExports, j as jsxRuntimeExports } from "../_libs/react.mjs";
|
|
2
|
+
import { R as Route, u as useChatStore, d as useSidebar, S as SidebarTrigger, c as cn } from "./router-CUAfx91O.mjs";
|
|
3
|
+
import { M as MarkdownMessage } from "./MarkdownMessage-CNS7OSKN.mjs";
|
|
4
|
+
import { C as ChatInputBlock } from "./ChatInputBlock-Bu2-iop_.mjs";
|
|
5
|
+
import "./index-C1mT_2d8.mjs";
|
|
6
|
+
import { k as IconFile, f as IconChevronRight, m as IconLoader2, d as IconCheck, i as IconCopy } from "../_libs/tabler__icons-react.mjs";
|
|
7
|
+
import "../_libs/tanstack__react-router.mjs";
|
|
8
|
+
import "../_libs/tanstack__router-core.mjs";
|
|
9
|
+
import "../_libs/tanstack__history.mjs";
|
|
10
|
+
import "node:stream/web";
|
|
11
|
+
import "node:stream";
|
|
12
|
+
import "../_libs/react-dom.mjs";
|
|
13
|
+
import "util";
|
|
14
|
+
import "crypto";
|
|
15
|
+
import "async_hooks";
|
|
16
|
+
import "stream";
|
|
17
|
+
import "../_libs/isbot.mjs";
|
|
18
|
+
import "../_libs/clsx.mjs";
|
|
19
|
+
import "../_libs/tailwind-merge.mjs";
|
|
20
|
+
import "../_libs/class-variance-authority.mjs";
|
|
21
|
+
import "../_libs/zustand.mjs";
|
|
22
|
+
import "../_libs/base-ui__react.mjs";
|
|
23
|
+
import "../_libs/base-ui__utils.mjs";
|
|
24
|
+
import "../_libs/use-sync-external-store.mjs";
|
|
25
|
+
import "../_libs/floating-ui__utils.mjs";
|
|
26
|
+
import "../_libs/floating-ui__react-dom.mjs";
|
|
27
|
+
import "../_libs/floating-ui__dom.mjs";
|
|
28
|
+
import "../_libs/floating-ui__core.mjs";
|
|
29
|
+
import "../_libs/react-markdown.mjs";
|
|
30
|
+
import "../_libs/devlop.mjs";
|
|
31
|
+
import "../_libs/unified.mjs";
|
|
32
|
+
import "../_libs/bail.mjs";
|
|
33
|
+
import "../_libs/extend.mjs";
|
|
34
|
+
import "../_libs/is-plain-obj.mjs";
|
|
35
|
+
import "../_libs/trough.mjs";
|
|
36
|
+
import "../_libs/vfile.mjs";
|
|
37
|
+
import "../_libs/vfile-message.mjs";
|
|
38
|
+
import "../_libs/unist-util-stringify-position.mjs";
|
|
39
|
+
import "node:process";
|
|
40
|
+
import "node:path";
|
|
41
|
+
import "node:url";
|
|
42
|
+
import "../_libs/remark-parse.mjs";
|
|
43
|
+
import "../_libs/mdast-util-from-markdown.mjs";
|
|
44
|
+
import "../_libs/micromark-util-decode-numeric-character-reference+[...].mjs";
|
|
45
|
+
import "../_libs/micromark-util-decode-string.mjs";
|
|
46
|
+
import "../_libs/decode-named-character-reference+[...].mjs";
|
|
47
|
+
import "../_libs/character-entities.mjs";
|
|
48
|
+
import "../_libs/micromark-util-normalize-identifier+[...].mjs";
|
|
49
|
+
import "../_libs/micromark.mjs";
|
|
50
|
+
import "../_libs/micromark-util-combine-extensions+[...].mjs";
|
|
51
|
+
import "../_libs/micromark-util-chunked.mjs";
|
|
52
|
+
import "../_libs/micromark-factory-space.mjs";
|
|
53
|
+
import "../_libs/micromark-util-character.mjs";
|
|
54
|
+
import "../_libs/micromark-core-commonmark.mjs";
|
|
55
|
+
import "../_libs/micromark-util-classify-character+[...].mjs";
|
|
56
|
+
import "../_libs/micromark-util-resolve-all.mjs";
|
|
57
|
+
import "../_libs/micromark-util-subtokenize.mjs";
|
|
58
|
+
import "../_libs/micromark-factory-destination.mjs";
|
|
59
|
+
import "../_libs/micromark-factory-label.mjs";
|
|
60
|
+
import "../_libs/micromark-factory-title.mjs";
|
|
61
|
+
import "../_libs/micromark-factory-whitespace.mjs";
|
|
62
|
+
import "../_libs/micromark-util-html-tag-name.mjs";
|
|
63
|
+
import "../_libs/mdast-util-to-string.mjs";
|
|
64
|
+
import "../_libs/remark-rehype.mjs";
|
|
65
|
+
import "../_libs/mdast-util-to-hast.mjs";
|
|
66
|
+
import "../_libs/ungap__structured-clone.mjs";
|
|
67
|
+
import "../_libs/micromark-util-sanitize-uri.mjs";
|
|
68
|
+
import "../_libs/unist-util-position.mjs";
|
|
69
|
+
import "../_libs/trim-lines.mjs";
|
|
70
|
+
import "../_libs/unist-util-visit.mjs";
|
|
71
|
+
import "../_libs/unist-util-visit-parents.mjs";
|
|
72
|
+
import "../_libs/unist-util-is.mjs";
|
|
73
|
+
import "../_libs/hast-util-to-jsx-runtime.mjs";
|
|
74
|
+
import "../_libs/comma-separated-tokens.mjs";
|
|
75
|
+
import "../_libs/property-information.mjs";
|
|
76
|
+
import "../_libs/space-separated-tokens.mjs";
|
|
77
|
+
import "../_libs/style-to-js.mjs";
|
|
78
|
+
import "../_libs/style-to-object.mjs";
|
|
79
|
+
import "../_libs/inline-style-parser.mjs";
|
|
80
|
+
import "../_libs/hast-util-whitespace.mjs";
|
|
81
|
+
import "../_libs/estree-util-is-identifier-name.mjs";
|
|
82
|
+
import "../_libs/html-url-attributes.mjs";
|
|
83
|
+
import "../_libs/rehype-highlight.mjs";
|
|
84
|
+
import "../_libs/lowlight.mjs";
|
|
85
|
+
import "../_libs/highlight.js.mjs";
|
|
86
|
+
import "../_libs/hast-util-to-text.mjs";
|
|
87
|
+
import "../_libs/hast-util-is-element.mjs";
|
|
88
|
+
import "../_libs/unist-util-find-after.mjs";
|
|
89
|
+
import "../_libs/remark-gfm.mjs";
|
|
90
|
+
import "../_libs/micromark-extension-gfm.mjs";
|
|
91
|
+
import "../_libs/micromark-extension-gfm-autolink-literal+[...].mjs";
|
|
92
|
+
import "../_libs/micromark-extension-gfm-footnote+[...].mjs";
|
|
93
|
+
import "../_libs/micromark-extension-gfm-strikethrough+[...].mjs";
|
|
94
|
+
import "../_libs/micromark-extension-gfm-table.mjs";
|
|
95
|
+
import "../_libs/micromark-extension-gfm-task-list-item+[...].mjs";
|
|
96
|
+
import "../_libs/mdast-util-gfm.mjs";
|
|
97
|
+
import "../_libs/mdast-util-gfm-autolink-literal+[...].mjs";
|
|
98
|
+
import "../_libs/ccount.mjs";
|
|
99
|
+
import "../_libs/mdast-util-find-and-replace.mjs";
|
|
100
|
+
import "../_libs/escape-string-regexp.mjs";
|
|
101
|
+
import "../_libs/mdast-util-gfm-footnote.mjs";
|
|
102
|
+
import "../_libs/mdast-util-gfm-strikethrough.mjs";
|
|
103
|
+
import "../_libs/mdast-util-gfm-table.mjs";
|
|
104
|
+
import "../_libs/markdown-table.mjs";
|
|
105
|
+
import "../_libs/mdast-util-to-markdown.mjs";
|
|
106
|
+
import "../_libs/longest-streak.mjs";
|
|
107
|
+
import "../_libs/mdast-util-phrasing.mjs";
|
|
108
|
+
import "../_libs/mdast-util-gfm-task-list-item.mjs";
|
|
109
|
+
import "node:async_hooks";
|
|
110
|
+
function BubbleCopyButton({ text }) {
|
|
111
|
+
const [copied, setCopied] = reactExports.useState(false);
|
|
112
|
+
const handleCopy = async () => {
|
|
113
|
+
await navigator.clipboard.writeText(text);
|
|
114
|
+
setCopied(true);
|
|
115
|
+
setTimeout(() => setCopied(false), 2e3);
|
|
116
|
+
};
|
|
117
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
118
|
+
"button",
|
|
119
|
+
{
|
|
120
|
+
onClick: handleCopy,
|
|
121
|
+
className: "inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] text-muted-foreground/50 hover:text-foreground hover:bg-muted transition-colors",
|
|
122
|
+
"aria-label": "Copy message",
|
|
123
|
+
children: [
|
|
124
|
+
copied ? /* @__PURE__ */ jsxRuntimeExports.jsx(IconCheck, { className: "size-3" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(IconCopy, { className: "size-3" }),
|
|
125
|
+
copied ? "Copied" : "Copy"
|
|
126
|
+
]
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
function formatThinkingDuration(ms) {
|
|
131
|
+
const s = Math.floor(ms / 1e3);
|
|
132
|
+
if (s < 60) return `${s}s`;
|
|
133
|
+
const m = Math.floor(s / 60);
|
|
134
|
+
const r = s % 60;
|
|
135
|
+
return r === 0 ? `${m}m` : `${m}m ${r}s`;
|
|
136
|
+
}
|
|
137
|
+
function ThinkingCard({
|
|
138
|
+
reasoning,
|
|
139
|
+
isStreaming,
|
|
140
|
+
startedAt,
|
|
141
|
+
endedAt
|
|
142
|
+
}) {
|
|
143
|
+
const [open, setOpen] = reactExports.useState(isStreaming ?? false);
|
|
144
|
+
const [now, setNow] = reactExports.useState(Date.now());
|
|
145
|
+
const tickRef = reactExports.useRef(null);
|
|
146
|
+
reactExports.useEffect(() => {
|
|
147
|
+
setOpen(isStreaming ?? false);
|
|
148
|
+
}, [isStreaming]);
|
|
149
|
+
reactExports.useEffect(() => {
|
|
150
|
+
if (isStreaming && startedAt && !endedAt) {
|
|
151
|
+
tickRef.current = setInterval(() => setNow(Date.now()), 1e3);
|
|
152
|
+
return () => {
|
|
153
|
+
if (tickRef.current) clearInterval(tickRef.current);
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
if (tickRef.current) {
|
|
157
|
+
clearInterval(tickRef.current);
|
|
158
|
+
tickRef.current = null;
|
|
159
|
+
}
|
|
160
|
+
}, [isStreaming, startedAt, endedAt]);
|
|
161
|
+
if (!reasoning.trim()) return null;
|
|
162
|
+
const durationMs = startedAt ? Math.max(0, (endedAt ?? (isStreaming ? now : startedAt)) - startedAt) : null;
|
|
163
|
+
const charCount = [...reasoning].length;
|
|
164
|
+
const hasThinking = isStreaming && startedAt && !endedAt;
|
|
165
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-1", children: [
|
|
166
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
167
|
+
"button",
|
|
168
|
+
{
|
|
169
|
+
onClick: () => setOpen(!open),
|
|
170
|
+
className: cn(
|
|
171
|
+
"inline-flex items-center gap-1.5 text-[11px] transition-colors",
|
|
172
|
+
hasThinking ? "text-amber-500 dark:text-amber-400 font-medium" : "text-muted-foreground/70 hover:text-foreground"
|
|
173
|
+
),
|
|
174
|
+
children: [
|
|
175
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
176
|
+
IconChevronRight,
|
|
177
|
+
{
|
|
178
|
+
className: cn(
|
|
179
|
+
"size-3 shrink-0 transition-transform",
|
|
180
|
+
open && "rotate-90"
|
|
181
|
+
)
|
|
182
|
+
}
|
|
183
|
+
),
|
|
184
|
+
hasThinking ? /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "inline-flex items-center gap-1", children: [
|
|
185
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(IconLoader2, { className: "size-2.5 animate-spin" }),
|
|
186
|
+
"thinking…"
|
|
187
|
+
] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "thought" }),
|
|
188
|
+
durationMs !== null && durationMs > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-muted-foreground/60 tabular-nums", children: [
|
|
189
|
+
"· ",
|
|
190
|
+
formatThinkingDuration(durationMs)
|
|
191
|
+
] }),
|
|
192
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-muted-foreground/60", children: [
|
|
193
|
+
"· ",
|
|
194
|
+
charCount.toLocaleString(),
|
|
195
|
+
" chars"
|
|
196
|
+
] })
|
|
197
|
+
]
|
|
198
|
+
}
|
|
199
|
+
),
|
|
200
|
+
open && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-1 rounded-md bg-amber-50 dark:bg-amber-950/20 px-2.5 py-1.5 text-[11px] text-muted-foreground leading-relaxed whitespace-pre-wrap font-mono border border-amber-200 dark:border-amber-800/30", children: reasoning })
|
|
201
|
+
] });
|
|
202
|
+
}
|
|
203
|
+
function formatToolPayload(raw) {
|
|
204
|
+
if (!raw) return null;
|
|
205
|
+
try {
|
|
206
|
+
const parsed = JSON.parse(raw);
|
|
207
|
+
return { text: JSON.stringify(parsed, null, 2), isJson: true };
|
|
208
|
+
} catch {
|
|
209
|
+
return { text: raw, isJson: false };
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
function ToolInvocationCard({
|
|
213
|
+
tools
|
|
214
|
+
}) {
|
|
215
|
+
const [open, setOpen] = reactExports.useState(false);
|
|
216
|
+
if (!tools?.length) return null;
|
|
217
|
+
const runningCount = tools.filter((t) => t.status === "running").length;
|
|
218
|
+
const doneCount = tools.filter((t) => t.status === "done").length;
|
|
219
|
+
const errorCount = tools.filter((t) => t.status === "error").length;
|
|
220
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-1", children: [
|
|
221
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
222
|
+
"button",
|
|
223
|
+
{
|
|
224
|
+
onClick: () => setOpen(!open),
|
|
225
|
+
className: "inline-flex items-center gap-1 text-[11px] text-muted-foreground/70 hover:text-foreground transition-colors",
|
|
226
|
+
children: [
|
|
227
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
228
|
+
IconChevronRight,
|
|
229
|
+
{
|
|
230
|
+
className: cn("size-3 shrink-0 transition-transform", open && "rotate-90")
|
|
231
|
+
}
|
|
232
|
+
),
|
|
233
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [
|
|
234
|
+
"used ",
|
|
235
|
+
tools.length,
|
|
236
|
+
" tool",
|
|
237
|
+
tools.length > 1 ? "s" : ""
|
|
238
|
+
] }),
|
|
239
|
+
runningCount > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "inline-flex items-center gap-0.5 text-amber-500", children: [
|
|
240
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(IconLoader2, { className: "size-2.5 animate-spin" }),
|
|
241
|
+
runningCount
|
|
242
|
+
] }),
|
|
243
|
+
doneCount > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-emerald-500", children: [
|
|
244
|
+
doneCount,
|
|
245
|
+
" done"
|
|
246
|
+
] }),
|
|
247
|
+
errorCount > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-red-500", children: [
|
|
248
|
+
errorCount,
|
|
249
|
+
" error"
|
|
250
|
+
] }),
|
|
251
|
+
tools.length > 0 && runningCount === 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-muted-foreground/50 truncate max-w-[200px]", children: [
|
|
252
|
+
"— ",
|
|
253
|
+
tools.map((t) => t.name).join(", ")
|
|
254
|
+
] })
|
|
255
|
+
]
|
|
256
|
+
}
|
|
257
|
+
),
|
|
258
|
+
open && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-1 flex flex-col gap-1.5", children: tools.map((t, i) => {
|
|
259
|
+
const formattedArgs = formatToolPayload(t.preview);
|
|
260
|
+
const formattedOutput = formatToolPayload(t.output);
|
|
261
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
262
|
+
"div",
|
|
263
|
+
{
|
|
264
|
+
className: "rounded-md bg-muted/40 border border-border/50 overflow-hidden",
|
|
265
|
+
children: [
|
|
266
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 px-2.5 py-1.5", children: [
|
|
267
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-[11px] font-semibold text-foreground/80 font-mono", children: t.name }),
|
|
268
|
+
t.status === "running" && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "inline-flex items-center gap-1 text-[10px] text-amber-500", children: [
|
|
269
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(IconLoader2, { className: "size-2.5 animate-spin" }),
|
|
270
|
+
"running"
|
|
271
|
+
] }),
|
|
272
|
+
t.status === "done" && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-[10px] text-emerald-500", children: "✓ done" }),
|
|
273
|
+
t.status === "error" && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-[10px] text-red-500", children: "✗ error" })
|
|
274
|
+
] }),
|
|
275
|
+
formattedArgs && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "border-t border-border/30", children: [
|
|
276
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "px-2.5 py-0.5 text-[9px] uppercase tracking-wider text-muted-foreground/60", children: "Arguments" }),
|
|
277
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "px-2.5 pb-1.5", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
278
|
+
"pre",
|
|
279
|
+
{
|
|
280
|
+
className: cn(
|
|
281
|
+
"text-[10px] leading-relaxed overflow-x-auto font-mono whitespace-pre-wrap max-h-[200px] overflow-y-auto rounded",
|
|
282
|
+
formattedArgs.isJson ? "bg-slate-900/10 dark:bg-slate-900/40 text-foreground/80 px-2 py-1" : "text-muted-foreground/70"
|
|
283
|
+
),
|
|
284
|
+
children: formattedArgs.text
|
|
285
|
+
}
|
|
286
|
+
) })
|
|
287
|
+
] }),
|
|
288
|
+
formattedOutput && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "border-t border-border/30", children: [
|
|
289
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "px-2.5 py-0.5 text-[9px] uppercase tracking-wider text-muted-foreground/60", children: "Result" }),
|
|
290
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "px-2.5 pb-1.5", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
291
|
+
"pre",
|
|
292
|
+
{
|
|
293
|
+
className: cn(
|
|
294
|
+
"text-[10px] leading-relaxed overflow-x-auto font-mono whitespace-pre-wrap max-h-[200px] overflow-y-auto rounded",
|
|
295
|
+
formattedOutput.isJson ? "bg-slate-900/10 dark:bg-slate-900/40 text-foreground/80 px-2 py-1" : "text-muted-foreground/70"
|
|
296
|
+
),
|
|
297
|
+
children: formattedOutput.text
|
|
298
|
+
}
|
|
299
|
+
) })
|
|
300
|
+
] })
|
|
301
|
+
]
|
|
302
|
+
},
|
|
303
|
+
t.callId || `${t.name}-${i}`
|
|
304
|
+
);
|
|
305
|
+
}) })
|
|
306
|
+
] });
|
|
307
|
+
}
|
|
308
|
+
function MessageBody({
|
|
309
|
+
content,
|
|
310
|
+
isStreaming,
|
|
311
|
+
isAssistant
|
|
312
|
+
}) {
|
|
313
|
+
if (isAssistant && !isStreaming && content) {
|
|
314
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(MarkdownMessage, { content });
|
|
315
|
+
}
|
|
316
|
+
if (isStreaming && content) {
|
|
317
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-base leading-relaxed", children: /* @__PURE__ */ jsxRuntimeExports.jsx(MarkdownMessage, { content, isStreaming: true }) });
|
|
318
|
+
}
|
|
319
|
+
if (isStreaming && !content) {
|
|
320
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "inline-flex items-center gap-1.5 text-sm text-muted-foreground", children: [
|
|
321
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(IconLoader2, { className: "h-3.5 w-3.5 animate-spin" }),
|
|
322
|
+
"Thinking…"
|
|
323
|
+
] });
|
|
324
|
+
}
|
|
325
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-base leading-relaxed whitespace-pre-wrap", children: content });
|
|
326
|
+
}
|
|
327
|
+
function formatTime(ts) {
|
|
328
|
+
if (!ts || isNaN(ts)) return null;
|
|
329
|
+
try {
|
|
330
|
+
return new Date(ts).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
|
|
331
|
+
} catch {
|
|
332
|
+
return null;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
function MessageList() {
|
|
336
|
+
const messages = useChatStore((s) => s.messages);
|
|
337
|
+
if (messages.length === 0) {
|
|
338
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center py-12 text-muted-foreground", children: "Start a conversation" });
|
|
339
|
+
}
|
|
340
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col", children: messages.map((msg) => {
|
|
341
|
+
const isUser = msg.role === "user";
|
|
342
|
+
const isSystem = msg.role === "system";
|
|
343
|
+
const isTool = msg.role === "tool";
|
|
344
|
+
const hasContent = !!msg.content?.trim();
|
|
345
|
+
const hasReasoning = !!msg.reasoning?.trim();
|
|
346
|
+
const hasToolCalls = !!msg.toolCalls?.length;
|
|
347
|
+
const timeLabel = formatTime(msg.timestamp);
|
|
348
|
+
const isMinimal = isTool || !isUser && !hasContent && (hasReasoning || hasToolCalls);
|
|
349
|
+
if (isSystem) {
|
|
350
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "px-4 py-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mx-auto max-w-3xl rounded-lg border border-destructive/30 bg-destructive/10 px-4 py-2.5 text-sm text-destructive", children: msg.content }) }, msg.id);
|
|
351
|
+
}
|
|
352
|
+
if (isMinimal) {
|
|
353
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "px-4 py-1", children: [
|
|
354
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mx-auto max-w-3xl flex flex-col gap-1", children: [
|
|
355
|
+
hasReasoning && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
356
|
+
ThinkingCard,
|
|
357
|
+
{
|
|
358
|
+
reasoning: msg.reasoning,
|
|
359
|
+
isStreaming: msg.isStreaming,
|
|
360
|
+
startedAt: msg.reasoningStartedAt,
|
|
361
|
+
endedAt: msg.reasoningEndedAt
|
|
362
|
+
}
|
|
363
|
+
),
|
|
364
|
+
!isTool && hasToolCalls && /* @__PURE__ */ jsxRuntimeExports.jsx(ToolInvocationCard, { tools: msg.toolCalls }),
|
|
365
|
+
isTool && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-md bg-muted/40 px-2.5 py-1.5 text-xs text-muted-foreground leading-relaxed whitespace-pre-wrap font-mono border border-border/50", children: msg.content })
|
|
366
|
+
] }),
|
|
367
|
+
timeLabel && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mx-auto max-w-3xl", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "mt-0.5 text-[10px] text-muted-foreground/40", children: timeLabel }) })
|
|
368
|
+
] }, msg.id);
|
|
369
|
+
}
|
|
370
|
+
if (isUser) {
|
|
371
|
+
const hasAttachments = !!msg.attachments?.length;
|
|
372
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex px-4 py-2 justify-end", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex min-w-0 flex-col max-w-[80%] items-end gap-1.5", children: [
|
|
373
|
+
hasAttachments && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-wrap justify-end gap-1.5", children: msg.attachments.map((att) => {
|
|
374
|
+
const isImage = att.type.startsWith("image/");
|
|
375
|
+
return isImage ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
376
|
+
"a",
|
|
377
|
+
{
|
|
378
|
+
href: att.url,
|
|
379
|
+
target: "_blank",
|
|
380
|
+
rel: "noopener noreferrer",
|
|
381
|
+
className: "block rounded-xl overflow-hidden border border-border/50 hover:border-border transition-colors",
|
|
382
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
383
|
+
"img",
|
|
384
|
+
{
|
|
385
|
+
src: att.url,
|
|
386
|
+
alt: att.name,
|
|
387
|
+
className: "max-h-[200px] max-w-[260px] object-cover"
|
|
388
|
+
}
|
|
389
|
+
)
|
|
390
|
+
},
|
|
391
|
+
att.id
|
|
392
|
+
) : /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
393
|
+
"a",
|
|
394
|
+
{
|
|
395
|
+
href: att.url,
|
|
396
|
+
target: "_blank",
|
|
397
|
+
rel: "noopener noreferrer",
|
|
398
|
+
className: "inline-flex items-center gap-1.5 rounded-lg border bg-card px-2.5 py-1.5 text-xs text-foreground hover:bg-muted transition-colors",
|
|
399
|
+
children: [
|
|
400
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(IconFile, { className: "size-3.5 text-muted-foreground shrink-0" }),
|
|
401
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "truncate max-w-[180px]", children: att.name })
|
|
402
|
+
]
|
|
403
|
+
},
|
|
404
|
+
att.id
|
|
405
|
+
);
|
|
406
|
+
}) }),
|
|
407
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-2xl px-4 py-2.5 text-sm leading-relaxed bg-primary text-primary-foreground", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "whitespace-pre-wrap", children: msg.content }) }),
|
|
408
|
+
timeLabel && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-[10px] text-muted-foreground/50 px-1", children: timeLabel })
|
|
409
|
+
] }) }, msg.id);
|
|
410
|
+
}
|
|
411
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex px-4 py-4 justify-start", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex min-w-0 flex-col w-full max-w-3xl gap-1", children: [
|
|
412
|
+
hasReasoning && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
413
|
+
ThinkingCard,
|
|
414
|
+
{
|
|
415
|
+
reasoning: msg.reasoning,
|
|
416
|
+
isStreaming: msg.isStreaming,
|
|
417
|
+
startedAt: msg.reasoningStartedAt,
|
|
418
|
+
endedAt: msg.reasoningEndedAt
|
|
419
|
+
}
|
|
420
|
+
),
|
|
421
|
+
hasToolCalls && /* @__PURE__ */ jsxRuntimeExports.jsx(ToolInvocationCard, { tools: msg.toolCalls }),
|
|
422
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(MessageBody, { content: msg.content, isStreaming: msg.isStreaming, isAssistant: true }),
|
|
423
|
+
hasContent && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-1 flex items-center gap-2 px-1", children: /* @__PURE__ */ jsxRuntimeExports.jsx(BubbleCopyButton, { text: msg.content }) }),
|
|
424
|
+
timeLabel && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "mt-0.5 text-[10px] text-muted-foreground/50 px-1", children: timeLabel })
|
|
425
|
+
] }) }, msg.id);
|
|
426
|
+
}) });
|
|
427
|
+
}
|
|
428
|
+
function ChatPanel() {
|
|
429
|
+
const { activeSessionId, isStreaming } = useChatStore();
|
|
430
|
+
const syncFromDb = useChatStore((s) => s.syncFromDb);
|
|
431
|
+
const { state } = useSidebar();
|
|
432
|
+
const isCollapsed = state === "collapsed";
|
|
433
|
+
reactExports.useEffect(() => {
|
|
434
|
+
if (!activeSessionId || !isStreaming) return;
|
|
435
|
+
const interval = setInterval(() => {
|
|
436
|
+
syncFromDb(activeSessionId);
|
|
437
|
+
}, 2e3);
|
|
438
|
+
return () => clearInterval(interval);
|
|
439
|
+
}, [activeSessionId, isStreaming, syncFromDb]);
|
|
440
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex h-full flex-col ", children: [
|
|
441
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("header", { className: "flex items-center justify-between border-b px-4 py-3 shrink-0", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 min-w-0", children: [
|
|
442
|
+
isCollapsed && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
443
|
+
SidebarTrigger,
|
|
444
|
+
{
|
|
445
|
+
className: cn(
|
|
446
|
+
"mr-1 -ml-1 text-muted-foreground hover:text-foreground hover:bg-muted transition-colors shrink-0"
|
|
447
|
+
)
|
|
448
|
+
}
|
|
449
|
+
),
|
|
450
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("h2", { className: "truncate font-medium", children: activeSessionId ? `Chat ${activeSessionId.slice(0, 8)}` : "New Chat" }),
|
|
451
|
+
isStreaming && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "shrink-0 text-xs text-muted-foreground", children: "Streaming…" })
|
|
452
|
+
] }) }),
|
|
453
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 min-h-0 overflow-y-auto", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mx-auto max-w-3xl", children: /* @__PURE__ */ jsxRuntimeExports.jsx(MessageList, {}) }) }),
|
|
454
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "shrink-0 bg-background px-4 py-3", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mx-auto max-w-3xl", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ChatInputBlock, {}) }) })
|
|
455
|
+
] });
|
|
456
|
+
}
|
|
457
|
+
function SessionChatPage() {
|
|
458
|
+
const {
|
|
459
|
+
sessionId
|
|
460
|
+
} = Route.useParams();
|
|
461
|
+
const switchSession = useChatStore((s) => s.switchSession);
|
|
462
|
+
const loadSessions = useChatStore((s) => s.loadSessions);
|
|
463
|
+
const sessionsLoaded = useChatStore((s) => s.sessionsLoaded);
|
|
464
|
+
reactExports.useEffect(() => {
|
|
465
|
+
if (!sessionsLoaded) {
|
|
466
|
+
loadSessions();
|
|
467
|
+
}
|
|
468
|
+
}, [sessionsLoaded, loadSessions]);
|
|
469
|
+
reactExports.useEffect(() => {
|
|
470
|
+
if (!sessionId) return;
|
|
471
|
+
switchSession(sessionId);
|
|
472
|
+
}, [sessionId, switchSession]);
|
|
473
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(ChatPanel, {});
|
|
474
|
+
}
|
|
475
|
+
export {
|
|
476
|
+
SessionChatPage as component
|
|
477
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { r as reactExports, j as jsxRuntimeExports } from "../_libs/react.mjs";
|
|
2
|
+
import { d as useNavigate } from "../_libs/tanstack__react-router.mjs";
|
|
3
|
+
import { u as useChatStore, a as createSession } from "./router-CUAfx91O.mjs";
|
|
4
|
+
import "../_libs/tanstack__router-core.mjs";
|
|
5
|
+
import "../_libs/tanstack__history.mjs";
|
|
6
|
+
import "node:stream/web";
|
|
7
|
+
import "node:stream";
|
|
8
|
+
import "../_libs/react-dom.mjs";
|
|
9
|
+
import "util";
|
|
10
|
+
import "crypto";
|
|
11
|
+
import "async_hooks";
|
|
12
|
+
import "stream";
|
|
13
|
+
import "../_libs/isbot.mjs";
|
|
14
|
+
import "../_libs/clsx.mjs";
|
|
15
|
+
import "../_libs/tailwind-merge.mjs";
|
|
16
|
+
import "../_libs/class-variance-authority.mjs";
|
|
17
|
+
import "../_libs/zustand.mjs";
|
|
18
|
+
import "../_libs/tabler__icons-react.mjs";
|
|
19
|
+
import "../_libs/base-ui__react.mjs";
|
|
20
|
+
import "../_libs/base-ui__utils.mjs";
|
|
21
|
+
import "../_libs/use-sync-external-store.mjs";
|
|
22
|
+
import "../_libs/floating-ui__utils.mjs";
|
|
23
|
+
import "../_libs/floating-ui__react-dom.mjs";
|
|
24
|
+
import "../_libs/floating-ui__dom.mjs";
|
|
25
|
+
import "../_libs/floating-ui__core.mjs";
|
|
26
|
+
function ChatIndexPage() {
|
|
27
|
+
const navigate = useNavigate();
|
|
28
|
+
const sessionsLoaded = useChatStore((s) => s.sessionsLoaded);
|
|
29
|
+
const sessions = useChatStore((s) => s.sessions);
|
|
30
|
+
const creatingRef = reactExports.useRef(false);
|
|
31
|
+
reactExports.useEffect(() => {
|
|
32
|
+
if (!sessionsLoaded) return;
|
|
33
|
+
if (sessions.length > 0) {
|
|
34
|
+
navigate({
|
|
35
|
+
to: "/chat/$sessionId",
|
|
36
|
+
params: {
|
|
37
|
+
sessionId: sessions[0].id
|
|
38
|
+
},
|
|
39
|
+
replace: true
|
|
40
|
+
});
|
|
41
|
+
} else {
|
|
42
|
+
if (creatingRef.current) return;
|
|
43
|
+
creatingRef.current = true;
|
|
44
|
+
createSession({
|
|
45
|
+
title: "",
|
|
46
|
+
source: "api_server"
|
|
47
|
+
}).then((data) => {
|
|
48
|
+
navigate({
|
|
49
|
+
to: "/chat/$sessionId",
|
|
50
|
+
params: {
|
|
51
|
+
sessionId: data.id
|
|
52
|
+
},
|
|
53
|
+
replace: true
|
|
54
|
+
});
|
|
55
|
+
}).catch(() => {
|
|
56
|
+
creatingRef.current = false;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}, [sessionsLoaded, sessions, navigate]);
|
|
60
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-1 items-center justify-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-muted-foreground", children: "Loading conversations…" }) });
|
|
61
|
+
}
|
|
62
|
+
export {
|
|
63
|
+
ChatIndexPage as component
|
|
64
|
+
};
|