reifyui 0.13.3 → 0.13.5
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/harness.cjs +34 -25
- package/dist/harness.cjs.map +1 -1
- package/dist/harness.js +34 -25
- package/dist/harness.js.map +1 -1
- package/dist/index.cjs +53 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +53 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/ChatPanel.jsx +39 -4
- package/src/components/FilePreview.jsx +20 -1
- package/src/harness/index.js +31 -18
- package/styles/file.css +4 -0
package/dist/index.js
CHANGED
|
@@ -754,6 +754,7 @@ function ChatPanel(props) {
|
|
|
754
754
|
const [draft, setDraft] = useState3("");
|
|
755
755
|
const [busy, setBusy] = useState3(false);
|
|
756
756
|
const [connecting, setConnecting] = useState3(false);
|
|
757
|
+
const [dropped, setDropped] = useState3(false);
|
|
757
758
|
const [histLoading, setHistLoading] = useState3(true);
|
|
758
759
|
const [staged, setStaged] = useState3([]);
|
|
759
760
|
const [attachErr, setAttachErr] = useState3("");
|
|
@@ -825,12 +826,18 @@ function ChatPanel(props) {
|
|
|
825
826
|
}
|
|
826
827
|
pendingRef.current = null;
|
|
827
828
|
setConnecting(false);
|
|
829
|
+
if (out.dropped) {
|
|
830
|
+
setDropped(true);
|
|
831
|
+
return;
|
|
832
|
+
}
|
|
828
833
|
updateLastAsst((a) => a.status === "running" ? { ...a, status: "done" } : a);
|
|
829
834
|
api.current.onChanged?.();
|
|
830
|
-
} catch {
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
835
|
+
} catch (e) {
|
|
836
|
+
updateLastAsst((a) => ({
|
|
837
|
+
...a,
|
|
838
|
+
blocks: a.blocks.length ? a.blocks : withText([], e && e.message || "The turn could not be started."),
|
|
839
|
+
status: "failed"
|
|
840
|
+
}));
|
|
834
841
|
} finally {
|
|
835
842
|
setBusy(false);
|
|
836
843
|
}
|
|
@@ -892,6 +899,26 @@ function ChatPanel(props) {
|
|
|
892
899
|
}, RETRY_MS);
|
|
893
900
|
return () => window.clearInterval(iv);
|
|
894
901
|
}, [connecting, busy, deliver]);
|
|
902
|
+
useEffect3(() => {
|
|
903
|
+
if (!dropped) return void 0;
|
|
904
|
+
let dead = false;
|
|
905
|
+
const tick = () => Promise.resolve(api.current.loadHistory(sessionId)).then((hist) => {
|
|
906
|
+
if (dead || !hist?.length) return;
|
|
907
|
+
const last = hist[hist.length - 1];
|
|
908
|
+
const settled = !(last.role === "assistant" && last.status === "running") && !externalBusy;
|
|
909
|
+
setMessages(hist);
|
|
910
|
+
if (settled) {
|
|
911
|
+
setDropped(false);
|
|
912
|
+
api.current.onChanged?.();
|
|
913
|
+
}
|
|
914
|
+
}).catch(() => {
|
|
915
|
+
});
|
|
916
|
+
const iv = window.setInterval(tick, POLL_MS);
|
|
917
|
+
return () => {
|
|
918
|
+
dead = true;
|
|
919
|
+
window.clearInterval(iv);
|
|
920
|
+
};
|
|
921
|
+
}, [dropped, externalBusy, sessionId]);
|
|
895
922
|
useEffect3(() => {
|
|
896
923
|
let dead = false;
|
|
897
924
|
let poll;
|
|
@@ -1003,7 +1030,8 @@ function ChatPanel(props) {
|
|
|
1003
1030
|
toggle,
|
|
1004
1031
|
title ? /* @__PURE__ */ jsx5("span", { className: "uic-chat-title", title, children: title }) : null,
|
|
1005
1032
|
headerRight,
|
|
1006
|
-
connecting ? /* @__PURE__ */ jsx5("span", { className: "uic-chat-conn", children: connectingLabel }) : null
|
|
1033
|
+
connecting ? /* @__PURE__ */ jsx5("span", { className: "uic-chat-conn", children: connectingLabel }) : null,
|
|
1034
|
+
dropped ? /* @__PURE__ */ jsx5("span", { className: "uic-chat-conn", children: workingLabel }) : null
|
|
1007
1035
|
] }),
|
|
1008
1036
|
/* @__PURE__ */ jsxs5("div", { className: "uic-chat-body", ref: bodyRef, onScroll: onBodyScroll, role: "log", "aria-live": "polite", children: [
|
|
1009
1037
|
histLoading ? /* @__PURE__ */ jsx5(ChatMessagesSkeleton, {}) : empty && externalBusy ? busyState === void 0 ? defaultBusyState : busyState : empty ? emptyState : /* @__PURE__ */ jsx5(
|
|
@@ -2239,6 +2267,7 @@ function kindOf(name, mime = "") {
|
|
|
2239
2267
|
if (mime.startsWith("audio/") || ["mp3", "wav", "ogg", "m4a", "flac"].includes(e)) return "audio";
|
|
2240
2268
|
if (e === "csv" || e === "tsv") return "csv";
|
|
2241
2269
|
if (e === "md" || e === "markdown") return "markdown";
|
|
2270
|
+
if (e === "html" || e === "htm") return "html";
|
|
2242
2271
|
if (SHEET.has(e)) return "sheet";
|
|
2243
2272
|
if (OFFICE.has(e)) return "office";
|
|
2244
2273
|
if (mime.startsWith("text/") || LANG[e] || /^(txt|log|env|conf|cfg|gitignore)$/.test(e)) return "code";
|
|
@@ -2290,12 +2319,14 @@ function FilePreview({
|
|
|
2290
2319
|
const { url, name } = file || {};
|
|
2291
2320
|
const [st, setSt] = useState10({ kind: "loading" });
|
|
2292
2321
|
const [tab, setTab] = useState10(0);
|
|
2322
|
+
const [view, setView] = useState10("preview");
|
|
2293
2323
|
useEffect8(() => {
|
|
2294
2324
|
if (!url) return void 0;
|
|
2295
2325
|
let alive = true;
|
|
2296
2326
|
let obj;
|
|
2297
2327
|
setSt({ kind: "loading" });
|
|
2298
2328
|
setTab(0);
|
|
2329
|
+
setView("preview");
|
|
2299
2330
|
const get = fetchFile || ((u) => fetch(u, { cache: "no-store" }));
|
|
2300
2331
|
(async () => {
|
|
2301
2332
|
const res = await get(url);
|
|
@@ -2330,7 +2361,7 @@ function FilePreview({
|
|
|
2330
2361
|
}
|
|
2331
2362
|
return;
|
|
2332
2363
|
}
|
|
2333
|
-
if (kind === "csv" || kind === "markdown" || kind === "code") {
|
|
2364
|
+
if (kind === "csv" || kind === "markdown" || kind === "code" || kind === "html") {
|
|
2334
2365
|
const text = await res.text();
|
|
2335
2366
|
if (!alive) return;
|
|
2336
2367
|
if (kind === "csv") setSt({ kind: "csv", rows: delimitedToRows(text, extOf(name) === "tsv" ? " " : ",") });
|
|
@@ -2356,6 +2387,18 @@ function FilePreview({
|
|
|
2356
2387
|
/* @__PURE__ */ jsxs11("header", { className: "uic-fp-head", children: [
|
|
2357
2388
|
/* @__PURE__ */ jsx13("span", { className: "uic-fp-ic", children: /* @__PURE__ */ jsx13(FileTypeIcon, { name, size: 20 }) }),
|
|
2358
2389
|
/* @__PURE__ */ jsx13("span", { className: "uic-fp-name", title: name, children: name }),
|
|
2390
|
+
st.kind === "html" && /* @__PURE__ */ jsx13("div", { className: "uic-fp-seg", role: "tablist", "aria-label": "Show the page or its source", children: [["preview", "Preview"], ["source", "Source"]].map(([id, label]) => /* @__PURE__ */ jsx13(
|
|
2391
|
+
"button",
|
|
2392
|
+
{
|
|
2393
|
+
type: "button",
|
|
2394
|
+
role: "tab",
|
|
2395
|
+
"aria-selected": view === id,
|
|
2396
|
+
className: "uic-fp-seg-btn" + (view === id ? " is-on" : ""),
|
|
2397
|
+
onClick: () => setView(id),
|
|
2398
|
+
children: label
|
|
2399
|
+
},
|
|
2400
|
+
id
|
|
2401
|
+
)) }),
|
|
2359
2402
|
/* @__PURE__ */ jsx13(
|
|
2360
2403
|
"button",
|
|
2361
2404
|
{
|
|
@@ -2387,6 +2430,10 @@ function FilePreview({
|
|
|
2387
2430
|
st.kind === "audio" && st.objUrl && /* @__PURE__ */ jsx13("div", { className: "uic-fp-center", children: /* @__PURE__ */ jsx13("audio", { src: st.objUrl, controls: true }) }),
|
|
2388
2431
|
st.kind === "markdown" && /* @__PURE__ */ jsx13("div", { className: "uic-fp-doc", children: renderMarkdown ? renderMarkdown(st.text || "") : /* @__PURE__ */ jsx13("pre", { className: "uic-fp-pre", children: st.text }) }),
|
|
2389
2432
|
st.kind === "code" && /* @__PURE__ */ jsx13(CodeBlock, { code: st.text || "", lang: LANG[extOf(name)] || "plaintext" }),
|
|
2433
|
+
st.kind === "html" && view === "source" && /* @__PURE__ */ jsx13(CodeBlock, { code: st.text || "", lang: "xml" }),
|
|
2434
|
+
st.kind === "html" && view === "preview" && // The page runs in its own origin with scripts only: a mockup's own script and styles
|
|
2435
|
+
// work, and nothing in it can read the host page, its cookies or its storage.
|
|
2436
|
+
/* @__PURE__ */ jsx13("iframe", { className: "uic-fp-frame", title: name, sandbox: "allow-scripts", srcDoc: st.text || "" }),
|
|
2390
2437
|
st.kind === "csv" && /* @__PURE__ */ jsx13(Grid, { rows: st.rows }),
|
|
2391
2438
|
st.kind === "sheet" && st.sheets && /* @__PURE__ */ jsxs11("div", { className: "uic-fp-xlsx", children: [
|
|
2392
2439
|
st.sheets[tab]?.filled ? /* @__PURE__ */ jsx13(Grid, { rows: st.sheets[tab].rows }) : /* @__PURE__ */ jsx13("div", { className: "uic-fp-empty", children: "This sheet is empty." }),
|