@decentnetwork/beagle-ui 0.2.23 → 0.2.24
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/beagle-ui.js +72 -2
- package/package.json +1 -1
package/dist/beagle-ui.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const BEAGLE_UI_VERSION = "0.2.
|
|
1
|
+
export const BEAGLE_UI_VERSION = "0.2.24";
|
|
2
2
|
// src/icons.jsx
|
|
3
3
|
var ICON_PATHS = {
|
|
4
4
|
// ---- tab bar (the four must feel like one set) ----
|
|
@@ -877,6 +877,12 @@ var service_peers_default = {
|
|
|
877
877
|
kind: "node",
|
|
878
878
|
role: "server"
|
|
879
879
|
},
|
|
880
|
+
{
|
|
881
|
+
userid: "5SxEBHAx49Hknq1VzrA1HDtZHjW31vetX3iMEi4P6pK3",
|
|
882
|
+
name: "gfax118",
|
|
883
|
+
kind: "node",
|
|
884
|
+
role: "server"
|
|
885
|
+
},
|
|
880
886
|
{
|
|
881
887
|
userid: "72a4A7awtn6BqZnBt3eNhZH9MdYXRkM6Ht5HG2sqoiKR",
|
|
882
888
|
name: "nv4090-wsl",
|
|
@@ -1391,6 +1397,8 @@ ${cands.map((c) => `- ${nameOf(c)}`).join("\n")}`;
|
|
|
1391
1397
|
}
|
|
1392
1398
|
|
|
1393
1399
|
// src/chat.jsx
|
|
1400
|
+
var DK_CMD_HIST_KEY = "beagle.assistant.history";
|
|
1401
|
+
var DK_CMD_HIST_MAX = 50;
|
|
1394
1402
|
function RequestsBlock({ T, requests, onAct }) {
|
|
1395
1403
|
const [acted, setActed] = React.useState({});
|
|
1396
1404
|
const [failed, setFailed] = React.useState({});
|
|
@@ -2792,6 +2800,59 @@ function Conversation({ T, peer, lang, peers, onOpenChat, thread: threadProp, on
|
|
|
2792
2800
|
setSelMode(false);
|
|
2793
2801
|
};
|
|
2794
2802
|
const [draft, setDraft] = React.useState("");
|
|
2803
|
+
const [hist, setHist] = React.useState([]);
|
|
2804
|
+
const histIdx = React.useRef(null);
|
|
2805
|
+
const histStash = React.useRef("");
|
|
2806
|
+
React.useEffect(() => {
|
|
2807
|
+
histIdx.current = null;
|
|
2808
|
+
histStash.current = "";
|
|
2809
|
+
if (!peer.app) {
|
|
2810
|
+
setHist([]);
|
|
2811
|
+
return;
|
|
2812
|
+
}
|
|
2813
|
+
try {
|
|
2814
|
+
setHist(JSON.parse(localStorage.getItem(DK_CMD_HIST_KEY) || "[]"));
|
|
2815
|
+
} catch (e) {
|
|
2816
|
+
setHist([]);
|
|
2817
|
+
}
|
|
2818
|
+
}, [peer.id, peer.app]);
|
|
2819
|
+
const rememberCommand = (text) => {
|
|
2820
|
+
setHist((h) => {
|
|
2821
|
+
const next = (h[h.length - 1] === text ? h : h.concat(text)).slice(-DK_CMD_HIST_MAX);
|
|
2822
|
+
if (peer.app) {
|
|
2823
|
+
try {
|
|
2824
|
+
localStorage.setItem(DK_CMD_HIST_KEY, JSON.stringify(next));
|
|
2825
|
+
} catch (e) {
|
|
2826
|
+
}
|
|
2827
|
+
}
|
|
2828
|
+
return next;
|
|
2829
|
+
});
|
|
2830
|
+
histIdx.current = null;
|
|
2831
|
+
histStash.current = "";
|
|
2832
|
+
};
|
|
2833
|
+
const walkHistory = (dir) => {
|
|
2834
|
+
if (!hist.length)
|
|
2835
|
+
return false;
|
|
2836
|
+
let i = histIdx.current;
|
|
2837
|
+
if (i === null) {
|
|
2838
|
+
if (dir > 0)
|
|
2839
|
+
return false;
|
|
2840
|
+
histStash.current = draft;
|
|
2841
|
+
i = hist.length - 1;
|
|
2842
|
+
} else {
|
|
2843
|
+
i += dir;
|
|
2844
|
+
if (i >= hist.length) {
|
|
2845
|
+
histIdx.current = null;
|
|
2846
|
+
setDraft(histStash.current);
|
|
2847
|
+
return true;
|
|
2848
|
+
}
|
|
2849
|
+
if (i < 0)
|
|
2850
|
+
i = 0;
|
|
2851
|
+
}
|
|
2852
|
+
histIdx.current = i;
|
|
2853
|
+
setDraft(hist[i]);
|
|
2854
|
+
return true;
|
|
2855
|
+
};
|
|
2795
2856
|
const [dragOver, setDragOver] = React.useState(false);
|
|
2796
2857
|
const [sending, setSending] = React.useState(null);
|
|
2797
2858
|
const [theater, setTheater] = React.useState(null);
|
|
@@ -2814,6 +2875,7 @@ function Conversation({ T, peer, lang, peers, onOpenChat, thread: threadProp, on
|
|
|
2814
2875
|
const sendDraft = () => {
|
|
2815
2876
|
if (draft.trim()) {
|
|
2816
2877
|
followScrollRef.current = true;
|
|
2878
|
+
rememberCommand(draft.trim());
|
|
2817
2879
|
onSend(draft);
|
|
2818
2880
|
setDraft("");
|
|
2819
2881
|
requestAnimationFrame(scrollToBottom);
|
|
@@ -2999,11 +3061,19 @@ ${peer.address}`
|
|
|
2999
3061
|
"input",
|
|
3000
3062
|
{
|
|
3001
3063
|
value: draft,
|
|
3002
|
-
onChange: (e) =>
|
|
3064
|
+
onChange: (e) => {
|
|
3065
|
+
histIdx.current = null;
|
|
3066
|
+
setDraft(e.target.value);
|
|
3067
|
+
},
|
|
3003
3068
|
onKeyDown: (e) => {
|
|
3004
3069
|
if (e.key === "Enter" && !e.shiftKey) {
|
|
3005
3070
|
e.preventDefault();
|
|
3006
3071
|
sendDraft();
|
|
3072
|
+
return;
|
|
3073
|
+
}
|
|
3074
|
+
if (e.key === "ArrowUp" || e.key === "ArrowDown") {
|
|
3075
|
+
if (walkHistory(e.key === "ArrowUp" ? -1 : 1))
|
|
3076
|
+
e.preventDefault();
|
|
3007
3077
|
}
|
|
3008
3078
|
},
|
|
3009
3079
|
placeholder: phone ? `${T.message}\u2026` : `${T.message} ${peer.alias || shortKey(peer.userId, 6, 4)}\u2026`,
|
package/package.json
CHANGED