@surfishs/dsh-prompt-enhance 0.0.4 → 0.0.6
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/README.en.md +41 -10
- package/README.md +40 -9
- package/docs/images/panel-en-915.png +0 -0
- package/docs/images/panel.png +0 -0
- package/lib/client.js +433 -163
- package/package.json +1 -1
- package/src/client/ResultDock.tsx +3 -93
- package/src/client/ResultPanel.tsx +27 -25
- package/src/client/UndoBar.tsx +14 -7
- package/src/client/locales.ts +10 -6
- package/src/client/settings-page.tsx +212 -14
- package/src/client/styles.ts +94 -10
- package/src/client/useDockAlignment.ts +103 -0
package/lib/client.js
CHANGED
|
@@ -610,7 +610,7 @@ function EnhanceButton(props) {
|
|
|
610
610
|
}
|
|
611
611
|
|
|
612
612
|
// src/client/ResultDock.tsx
|
|
613
|
-
var
|
|
613
|
+
var import_react5 = require("react");
|
|
614
614
|
|
|
615
615
|
// src/client/ResultPanel.tsx
|
|
616
616
|
var import_react3 = require("react");
|
|
@@ -761,17 +761,19 @@ function ResultPanel(props) {
|
|
|
761
761
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(SparkleFishIcon, { size: 15 }),
|
|
762
762
|
t("panel.title")
|
|
763
763
|
] }),
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
t("panel.elapsed", { ms: formatMs(state.result.elapsedMs) }),
|
|
768
|
-
state.result.usage === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
764
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "dsh-pe-head-actions", children: [
|
|
765
|
+
state.phase === "result" && state.result !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "dsh-pe-badge", children: [
|
|
766
|
+
t("panel.model", { provider: state.result.provider, model: state.result.model }),
|
|
769
767
|
" \xB7 ",
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
768
|
+
t("panel.elapsed", { ms: formatMs(state.result.elapsedMs) }),
|
|
769
|
+
state.result.usage === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
770
|
+
" \xB7 ",
|
|
771
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { title: tokenDetail(state.result.usage), children: t("panel.tokens", { total: formatTokens(totalTokensOf(state.result.usage)) }) })
|
|
772
|
+
] })
|
|
773
|
+
] }),
|
|
774
|
+
copied === "ok" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "dsh-pe-applied", children: t("panel.copiedShort") }) : regenerated ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "dsh-pe-applied", children: t("panel.regeneratedShort") }) : applied ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "dsh-pe-applied", children: t("panel.appliedShort") }) : undone ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "dsh-pe-applied", children: t("panel.undoneShort") }) : null,
|
|
775
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", className: "dsh-pe-close", "aria-label": t("panel.close"), onClick: onCancel, children: "\u2715" })
|
|
776
|
+
] })
|
|
775
777
|
] }),
|
|
776
778
|
state.phase === "loading" && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "dsh-pe-loading", children: state.streaming === void 0 || state.streaming === "" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
777
779
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "dsh-pe-spin", "aria-hidden": true }),
|
|
@@ -822,17 +824,83 @@ function ResultPanel(props) {
|
|
|
822
824
|
] });
|
|
823
825
|
}
|
|
824
826
|
|
|
827
|
+
// src/client/useDockAlignment.ts
|
|
828
|
+
var import_react4 = require("react");
|
|
829
|
+
function useDockAlignment(active) {
|
|
830
|
+
const rootRef = (0, import_react4.useRef)(null);
|
|
831
|
+
(0, import_react4.useEffect)(() => {
|
|
832
|
+
if (!active) return;
|
|
833
|
+
const root = rootRef.current;
|
|
834
|
+
if (root === null) return;
|
|
835
|
+
let frame = 0;
|
|
836
|
+
const align = () => {
|
|
837
|
+
const parent = root.parentElement;
|
|
838
|
+
if (parent === null) return;
|
|
839
|
+
root.style.transform = "";
|
|
840
|
+
const previousMargin = parseFloat(root.style.marginLeft) || 0;
|
|
841
|
+
const rootRect = root.getBoundingClientRect();
|
|
842
|
+
const editors = Array.from(document.querySelectorAll('textarea, [contenteditable="true"], [role="textbox"]'));
|
|
843
|
+
const editor = editors.find((node2) => {
|
|
844
|
+
const rect = node2.getBoundingClientRect();
|
|
845
|
+
return rect.width > 0 && rect.height > 0 && rect.top >= rootRect.bottom - 4;
|
|
846
|
+
});
|
|
847
|
+
if (editor === void 0) {
|
|
848
|
+
root.style.width = "";
|
|
849
|
+
root.style.marginLeft = "";
|
|
850
|
+
root.style.transform = "";
|
|
851
|
+
return;
|
|
852
|
+
}
|
|
853
|
+
const editorRect = editor.getBoundingClientRect();
|
|
854
|
+
const candidates = [];
|
|
855
|
+
let node = editor;
|
|
856
|
+
for (let depth = 0; depth < 12 && node !== null; depth++) {
|
|
857
|
+
const rect = node.getBoundingClientRect();
|
|
858
|
+
const style = getComputedStyle(node);
|
|
859
|
+
if (rect.width >= editorRect.width && rect.width > 360 && rect.height > 48 && (parseFloat(style.borderTopLeftRadius) || 0) >= 4 && style.backgroundColor !== "rgba(0, 0, 0, 0)") {
|
|
860
|
+
candidates.push({ node, rect });
|
|
861
|
+
}
|
|
862
|
+
node = node.parentElement;
|
|
863
|
+
}
|
|
864
|
+
const editorCenter = editorRect.left + editorRect.width / 2;
|
|
865
|
+
const cardEntry = candidates.filter((candidate) => candidate.rect.width <= window.innerWidth * 0.8 && Math.abs(candidate.rect.left + candidate.rect.width / 2 - editorCenter) < 40).sort((a, b) => b.rect.width - a.rect.width)[0] ?? candidates.sort((a, b) => b.rect.width - a.rect.width)[0];
|
|
866
|
+
if (cardEntry === void 0) return;
|
|
867
|
+
const cardRect = cardEntry.rect;
|
|
868
|
+
const width = `${cardRect.width}px`;
|
|
869
|
+
if (root.style.width !== width) root.style.width = width;
|
|
870
|
+
const afterWidth = root.getBoundingClientRect();
|
|
871
|
+
const currentMargin = parseFloat(root.style.marginLeft) || 0;
|
|
872
|
+
const marginLeft = `${cardRect.left - (afterWidth.left - currentMargin)}px`;
|
|
873
|
+
if (root.style.marginLeft !== marginLeft) root.style.marginLeft = marginLeft;
|
|
874
|
+
};
|
|
875
|
+
const schedule = () => {
|
|
876
|
+
cancelAnimationFrame(frame);
|
|
877
|
+
frame = requestAnimationFrame(align);
|
|
878
|
+
};
|
|
879
|
+
schedule();
|
|
880
|
+
schedule();
|
|
881
|
+
window.addEventListener("resize", schedule);
|
|
882
|
+
const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(schedule);
|
|
883
|
+
observer?.observe(document.documentElement);
|
|
884
|
+
return () => {
|
|
885
|
+
cancelAnimationFrame(frame);
|
|
886
|
+
window.removeEventListener("resize", schedule);
|
|
887
|
+
observer?.disconnect();
|
|
888
|
+
};
|
|
889
|
+
}, [active]);
|
|
890
|
+
return rootRef;
|
|
891
|
+
}
|
|
892
|
+
|
|
825
893
|
// src/client/ResultDock.tsx
|
|
826
894
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
827
895
|
function ResultDock(props) {
|
|
828
896
|
const { t, sessionId, useInput, inputActions } = props;
|
|
829
897
|
const uiKey = useSessionKey(sessionId, inputActions);
|
|
830
|
-
const
|
|
831
|
-
const
|
|
832
|
-
const [
|
|
833
|
-
const [
|
|
834
|
-
const
|
|
835
|
-
const
|
|
898
|
+
const panel = (0, import_react5.useSyncExternalStore)(subscribe, getPanel);
|
|
899
|
+
const rootRef = useDockAlignment(panel !== void 0 && panel.sessionId === uiKey);
|
|
900
|
+
const [undone, setUndone] = (0, import_react5.useState)(false);
|
|
901
|
+
const [regenerated, setRegenerated] = (0, import_react5.useState)(false);
|
|
902
|
+
const [pendingRegenerate, setPendingRegenerate] = (0, import_react5.useState)(false);
|
|
903
|
+
const previousResultRef = (0, import_react5.useRef)(void 0);
|
|
836
904
|
const draft = useInput((state) => {
|
|
837
905
|
const value = state.draft;
|
|
838
906
|
return typeof value === "string" ? value : "";
|
|
@@ -846,8 +914,8 @@ function ResultDock(props) {
|
|
|
846
914
|
const sessionQueued = useSession === void 0 ? 0 : Number(useSession((state) => state.queue?.length ?? 0));
|
|
847
915
|
const entry = peekUndo(uiKey);
|
|
848
916
|
const applied = entry !== void 0 && entry.applied === draft;
|
|
849
|
-
const prevSession = (0,
|
|
850
|
-
(0,
|
|
917
|
+
const prevSession = (0, import_react5.useRef)({ running: sessionRunning, queued: sessionQueued });
|
|
918
|
+
(0, import_react5.useEffect)(() => {
|
|
851
919
|
const prev = prevSession.current;
|
|
852
920
|
prevSession.current = { running: sessionRunning, queued: sessionQueued };
|
|
853
921
|
if (panel === void 0 || panel.sessionId !== uiKey) return;
|
|
@@ -855,7 +923,7 @@ function ResultDock(props) {
|
|
|
855
923
|
closePanel();
|
|
856
924
|
}
|
|
857
925
|
}, [phase, sessionRunning, sessionQueued, panel, uiKey]);
|
|
858
|
-
(0,
|
|
926
|
+
(0, import_react5.useEffect)(() => {
|
|
859
927
|
if (panel === void 0 || panel.sessionId !== uiKey) return;
|
|
860
928
|
const onKeyDown = (event) => {
|
|
861
929
|
if (event.defaultPrevented || event.isComposing || event.key !== "Escape") return;
|
|
@@ -865,12 +933,12 @@ function ResultDock(props) {
|
|
|
865
933
|
document.addEventListener("keydown", onKeyDown);
|
|
866
934
|
return () => document.removeEventListener("keydown", onKeyDown);
|
|
867
935
|
}, [panel, uiKey]);
|
|
868
|
-
(0,
|
|
936
|
+
(0, import_react5.useEffect)(() => {
|
|
869
937
|
if (!undone) return;
|
|
870
938
|
const timer = setTimeout(() => setUndone(false), 2500);
|
|
871
939
|
return () => clearTimeout(timer);
|
|
872
940
|
}, [undone]);
|
|
873
|
-
(0,
|
|
941
|
+
(0, import_react5.useEffect)(() => {
|
|
874
942
|
if (!pendingRegenerate) return;
|
|
875
943
|
if (panel === void 0 || panel.sessionId !== uiKey) {
|
|
876
944
|
setPendingRegenerate(false);
|
|
@@ -885,76 +953,16 @@ function ResultDock(props) {
|
|
|
885
953
|
setRegenerated(true);
|
|
886
954
|
}
|
|
887
955
|
}, [panel, pendingRegenerate, uiKey]);
|
|
888
|
-
(0,
|
|
956
|
+
(0, import_react5.useEffect)(() => {
|
|
889
957
|
if (!regenerated) return;
|
|
890
958
|
const timer = setTimeout(() => setRegenerated(false), 2500);
|
|
891
959
|
return () => clearTimeout(timer);
|
|
892
960
|
}, [regenerated]);
|
|
893
|
-
(0,
|
|
961
|
+
(0, import_react5.useEffect)(() => {
|
|
894
962
|
if (!pendingRegenerate) return;
|
|
895
963
|
const timer = setTimeout(() => setPendingRegenerate(false), 15e3);
|
|
896
964
|
return () => clearTimeout(timer);
|
|
897
965
|
}, [pendingRegenerate]);
|
|
898
|
-
(0, import_react4.useEffect)(() => {
|
|
899
|
-
if (panel === void 0 || panel.sessionId !== uiKey) return;
|
|
900
|
-
const root = rootRef.current;
|
|
901
|
-
if (root === null) return;
|
|
902
|
-
let frame = 0;
|
|
903
|
-
const align = () => {
|
|
904
|
-
const parent = root.parentElement;
|
|
905
|
-
if (parent === null) return;
|
|
906
|
-
root.style.transform = "";
|
|
907
|
-
const previousMargin = parseFloat(root.style.marginLeft) || 0;
|
|
908
|
-
const rootRect = root.getBoundingClientRect();
|
|
909
|
-
const baseLeft = rootRect.left - previousMargin;
|
|
910
|
-
const editors = Array.from(document.querySelectorAll('textarea, [contenteditable="true"], [role="textbox"]'));
|
|
911
|
-
const editor = editors.find((node2) => {
|
|
912
|
-
const rect = node2.getBoundingClientRect();
|
|
913
|
-
return rect.width > 0 && rect.height > 0 && rect.top >= rootRect.bottom - 4;
|
|
914
|
-
});
|
|
915
|
-
if (editor === void 0) {
|
|
916
|
-
root.style.width = "";
|
|
917
|
-
root.style.marginLeft = "";
|
|
918
|
-
root.style.transform = "";
|
|
919
|
-
return;
|
|
920
|
-
}
|
|
921
|
-
const editorRect = editor.getBoundingClientRect();
|
|
922
|
-
const candidates = [];
|
|
923
|
-
let node = editor;
|
|
924
|
-
for (let depth = 0; depth < 12 && node !== null; depth++) {
|
|
925
|
-
const rect = node.getBoundingClientRect();
|
|
926
|
-
const style = getComputedStyle(node);
|
|
927
|
-
if (rect.width >= editorRect.width && rect.width > 360 && rect.height > 48 && (parseFloat(style.borderTopLeftRadius) || 0) >= 4 && style.backgroundColor !== "rgba(0, 0, 0, 0)") {
|
|
928
|
-
candidates.push({ node, rect });
|
|
929
|
-
}
|
|
930
|
-
node = node.parentElement;
|
|
931
|
-
}
|
|
932
|
-
const editorCenter = editorRect.left + editorRect.width / 2;
|
|
933
|
-
const cardEntry = candidates.filter((candidate) => candidate.rect.width <= window.innerWidth * 0.8 && Math.abs(candidate.rect.left + candidate.rect.width / 2 - editorCenter) < 40).sort((a, b) => b.rect.width - a.rect.width)[0] ?? candidates.sort((a, b) => b.rect.width - a.rect.width)[0];
|
|
934
|
-
if (cardEntry === void 0) return;
|
|
935
|
-
const cardRect = cardEntry.rect;
|
|
936
|
-
const width = `${cardRect.width}px`;
|
|
937
|
-
if (root.style.width !== width) root.style.width = width;
|
|
938
|
-
const afterWidth = root.getBoundingClientRect();
|
|
939
|
-
const currentMargin = parseFloat(root.style.marginLeft) || 0;
|
|
940
|
-
const marginLeft = `${cardRect.left - (afterWidth.left - currentMargin)}px`;
|
|
941
|
-
if (root.style.marginLeft !== marginLeft) root.style.marginLeft = marginLeft;
|
|
942
|
-
};
|
|
943
|
-
const schedule = () => {
|
|
944
|
-
cancelAnimationFrame(frame);
|
|
945
|
-
frame = requestAnimationFrame(align);
|
|
946
|
-
};
|
|
947
|
-
schedule();
|
|
948
|
-
schedule();
|
|
949
|
-
window.addEventListener("resize", schedule);
|
|
950
|
-
const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(schedule);
|
|
951
|
-
observer?.observe(document.documentElement);
|
|
952
|
-
return () => {
|
|
953
|
-
cancelAnimationFrame(frame);
|
|
954
|
-
window.removeEventListener("resize", schedule);
|
|
955
|
-
observer?.disconnect();
|
|
956
|
-
};
|
|
957
|
-
}, [panel, uiKey]);
|
|
958
966
|
if (panel === void 0 || panel.sessionId !== uiKey) return null;
|
|
959
967
|
const apply2 = () => {
|
|
960
968
|
if (panel.phase !== "result" || panel.result === void 0) return;
|
|
@@ -995,7 +1003,7 @@ function ResultDock(props) {
|
|
|
995
1003
|
}
|
|
996
1004
|
|
|
997
1005
|
// src/client/UndoBar.tsx
|
|
998
|
-
var
|
|
1006
|
+
var import_react6 = require("react");
|
|
999
1007
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1000
1008
|
function UndoBar(props) {
|
|
1001
1009
|
const { t, sessionId, useInput, inputActions } = props;
|
|
@@ -1004,14 +1012,15 @@ function UndoBar(props) {
|
|
|
1004
1012
|
const value = state.draft;
|
|
1005
1013
|
return typeof value === "string" ? value : "";
|
|
1006
1014
|
});
|
|
1007
|
-
(0,
|
|
1015
|
+
(0, import_react6.useSyncExternalStore)(subscribe, getVersion);
|
|
1008
1016
|
const entry = peekUndo(uiKey);
|
|
1009
|
-
(0,
|
|
1017
|
+
(0, import_react6.useEffect)(() => {
|
|
1010
1018
|
if (entry !== void 0 && entry.applied !== draft) popUndo(uiKey);
|
|
1011
1019
|
}, [draft, entry, uiKey]);
|
|
1012
1020
|
const panel = getPanel();
|
|
1013
|
-
|
|
1014
|
-
|
|
1021
|
+
const visible = (panel === void 0 || panel.sessionId !== uiKey) && entry !== void 0 && entry.applied === draft;
|
|
1022
|
+
const rootRef = useDockAlignment(visible);
|
|
1023
|
+
if (!visible) return null;
|
|
1015
1024
|
const undo = () => {
|
|
1016
1025
|
inputActions.setDraft(entry.original);
|
|
1017
1026
|
popUndo(uiKey);
|
|
@@ -1019,12 +1028,15 @@ function UndoBar(props) {
|
|
|
1019
1028
|
const dismiss = () => {
|
|
1020
1029
|
popUndo(uiKey);
|
|
1021
1030
|
};
|
|
1022
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "dsh-pe-undo", children: [
|
|
1031
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { ref: rootRef, className: "dsh-pe-dock", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "dsh-pe-undo", children: [
|
|
1023
1032
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "dsh-pe-undo-check", "aria-hidden": true, children: "\u2713" }),
|
|
1024
1033
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: t("undo.applied") }),
|
|
1025
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.
|
|
1034
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { type: "button", className: "dsh-pe-undo-link", onClick: undo, children: [
|
|
1035
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UndoIcon, {}),
|
|
1036
|
+
t("undo.undo")
|
|
1037
|
+
] }),
|
|
1026
1038
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: "dsh-pe-undo-x", "aria-label": t("undo.dismiss"), onClick: dismiss, children: "\u2715" })
|
|
1027
|
-
] });
|
|
1039
|
+
] }) });
|
|
1028
1040
|
}
|
|
1029
1041
|
|
|
1030
1042
|
// src/client/locales.ts
|
|
@@ -1060,7 +1072,7 @@ var zh = {
|
|
|
1060
1072
|
"panel.tokens.output": "\u8F93\u51FA {count}",
|
|
1061
1073
|
"panel.tokens.cacheRead": "\u7F13\u5B58\u8BFB\u53D6 {count}",
|
|
1062
1074
|
"panel.tokens.cacheWrite": "\u7F13\u5B58\u5199\u5165 {count}",
|
|
1063
|
-
"undo.applied": "\u5DF2\
|
|
1075
|
+
"undo.applied": "\u5DF2\u66FF\u6362\u539F\u63D0\u793A\u8BCD",
|
|
1064
1076
|
"undo.undo": "\u64A4\u9500",
|
|
1065
1077
|
"undo.dismiss": "\u5173\u95ED\u63D0\u793A",
|
|
1066
1078
|
"error.empty": "\u8F93\u5165\u6846\u4E3A\u7A7A\uFF0C\u8BF7\u5148\u8F93\u5165\u8981\u589E\u5F3A\u7684\u63D0\u793A\u8BCD\u3002",
|
|
@@ -1091,7 +1103,9 @@ var zh = {
|
|
|
1091
1103
|
"settings.description": "\u628A\u8F93\u5165\u6846\u8349\u7A3F\u6539\u5199\u4E3A\u7ED3\u6784\u5316\u63D0\u793A\u8BCD\uFF1A\u89D2\u8272\u4E0E\u76EE\u6807\u3001\u53EF\u6267\u884C\u6B65\u9AA4\u3001\u8F93\u51FA\u683C\u5F0F\u3001\u9A8C\u6536\u6807\u51C6\u3001\u8FB9\u754C\u6761\u4EF6\u3002\u539F\u6587\u4FDD\u7559\uFF0C\u5931\u8D25\u4E0D\u6539\u8349\u7A3F\uFF1B\u4FDD\u5B58\u540E\u4E0B\u4E00\u6B21\u8C03\u7528\u5373\u751F\u6548\u3002",
|
|
1092
1104
|
"settings.save": "\u4FDD\u5B58",
|
|
1093
1105
|
"settings.saving": "\u4FDD\u5B58\u4E2D\u2026",
|
|
1106
|
+
"settings.saved": "\u5DF2\u4FDD\u5B58",
|
|
1094
1107
|
"settings.saveFailed": "\u672C\u90E8\u7F72\u6CA1\u6709\u63A5\u53D7\u8FD9\u4E9B\u503C\uFF0C\u5DF2\u4FDD\u7559\u4F9B\u4F60\u4FEE\u6539\u3002",
|
|
1108
|
+
"settings.saveFailedShort": "\u4FDD\u5B58\u5931\u8D25",
|
|
1095
1109
|
"settings.readOnly": "\u672C\u90E8\u7F72\u7684\u8BBE\u7F6E\u4E3A\u53EA\u8BFB\u3002",
|
|
1096
1110
|
"settings.unavailable": "\u8BE5\u63D2\u4EF6\u5F53\u524D\u672A\u52A0\u8F7D\uFF0C\u6682\u65F6\u65E0\u6CD5\u914D\u7F6E\u3002",
|
|
1097
1111
|
"settings.reset": "\u6062\u590D\u9ED8\u8BA4",
|
|
@@ -1129,7 +1143,7 @@ var zh = {
|
|
|
1129
1143
|
"settings.row.temperature.label": "\u6E29\u5EA6",
|
|
1130
1144
|
"settings.row.temperature.hint": "\u91C7\u6837\u6E29\u5EA6\uFF080~1\uFF0C\u6B65\u8FDB 0.05\uFF09\uFF0C\u8D8A\u4F4E\u8D8A\u5FE0\u5B9E\u539F\u6587\uFF1B\u9ED8\u8BA4 0.3\u3002",
|
|
1131
1145
|
"settings.row.reasoningEffort.label": "\u63A8\u7406\u9884\u7B97",
|
|
1132
|
-
"settings.row.reasoningEffort.hint": "\u6863\u4F4D\u9009\u9879\u6765\u81EA\u5F53\u524D provider/model \u7684\u58F0\u660E\uFF1B\u81EA\u5B9A\u4E49\u6A21\u578B\u65F6\u6309\u9700\u8BFB\u53D6\u3002\
|
|
1146
|
+
"settings.row.reasoningEffort.hint": "\u6863\u4F4D\u9009\u9879\u6765\u81EA\u5F53\u524D provider/model \u7684\u58F0\u660E\uFF1B\u81EA\u5B9A\u4E49\u6A21\u578B\u65F6\u6309\u9700\u8BFB\u53D6\u3002\u63D0\u4F9B\u65B9\u9ED8\u8BA4\u8868\u793A\u4E0D\u4F20\u8BE5\u5B57\u6BB5\u3002",
|
|
1133
1147
|
"settings.row.maxOutputTokens.label": "\u8F93\u51FA token \u4E0A\u9650",
|
|
1134
1148
|
"settings.row.maxOutputTokens.hint": "\u5355\u6B21\u589E\u5F3A\u7684\u8F93\u51FA\u9884\u7B97\uFF1B\u9ED8\u8BA4 8192\u3002",
|
|
1135
1149
|
"settings.row.maxInputChars.label": "\u8F93\u5165\u5B57\u7B26\u4E0A\u9650",
|
|
@@ -1140,7 +1154,7 @@ var zh = {
|
|
|
1140
1154
|
"settings.row.strategyMode.hint": "\u81EA\u5B9A\u4E49\u7CFB\u7EDF\u63D0\u793A\u8BCD\u975E\u7A7A\u65F6\uFF1A\u6574\u4F53\u66FF\u6362\u5185\u7F6E\u7B56\u7565\uFF08\u4ECD\u4FDD\u7559\u6700\u5C0F\u8F93\u51FA\u5951\u7EA6\uFF09\uFF0C\u6216\u8FFD\u52A0\u5728\u5185\u7F6E\u7B56\u7565\u4E4B\u540E\uFF08\u5185\u7F6E\u89C4\u5219\u7EE7\u7EED\u751F\u6548\uFF09\u3002",
|
|
1141
1155
|
"settings.row.systemPrompt.label": "\u81EA\u5B9A\u4E49\u7CFB\u7EDF\u63D0\u793A\u8BCD",
|
|
1142
1156
|
"settings.row.systemPrompt.hint": "\u7559\u7A7A\u4F7F\u7528\u5185\u7F6E\u589E\u5F3A\u7B56\u7565\u3002",
|
|
1143
|
-
"settings.row.systemPrompt.placeholder": "\u4F8B\uFF1A\u628A\u7528\u6237\u7684\u4E2D\u6587\
|
|
1157
|
+
"settings.row.systemPrompt.placeholder": "\u4F8B\uFF1A\u628A\u7528\u6237\u7684\u4E2D\u6587\u8F93\u5165\u7FFB\u8BD1\u6210\u82F1\u6587\u3002",
|
|
1144
1158
|
"settings.row.contextMaxMessages.label": "\u4E0A\u4E0B\u6587\u6D88\u606F\u6761\u6570",
|
|
1145
1159
|
"settings.row.contextMaxMessages.hint": "\u6700\u591A\u53C2\u8003\u6700\u8FD1\u591A\u5C11\u8F6E\u5BF9\u8BDD\uFF1B0 \u8868\u793A\u4E0D\u53C2\u8003\uFF1B\u9ED8\u8BA4 8\u3002",
|
|
1146
1160
|
"settings.row.contextMaxChars.label": "\u4E0A\u4E0B\u6587\u5B57\u7B26\u4E0A\u9650",
|
|
@@ -1154,7 +1168,7 @@ var zh = {
|
|
|
1154
1168
|
"settings.row.shortcut.placeholder": "\u4F8B\uFF1Actrl+alt+shift+e",
|
|
1155
1169
|
"settings.strategy.replace": "\u66FF\u6362\u5185\u7F6E\u7B56\u7565",
|
|
1156
1170
|
"settings.strategy.extend": "\u8FFD\u52A0\u5728\u5185\u7F6E\u7B56\u7565\u540E",
|
|
1157
|
-
"settings.reasoning.inherit": "\
|
|
1171
|
+
"settings.reasoning.inherit": "\u63D0\u4F9B\u65B9\u9ED8\u8BA4",
|
|
1158
1172
|
"settings.reasoning.loading": "\u6B63\u5728\u8BFB\u53D6\u8BE5\u6A21\u578B\u7684\u6863\u4F4D\u2026",
|
|
1159
1173
|
"settings.reasoning.unavailable": "\u65E0\u6CD5\u8BFB\u53D6\u8BE5\u6A21\u578B\u7684\u6863\u4F4D\uFF0C\u4EC5\u53EF\u8DDF\u968F\u63D0\u4F9B\u65B9\u9ED8\u8BA4\u3002",
|
|
1160
1174
|
"settings.reasoning.noTiers": "\u8BE5\u6A21\u578B\u672A\u58F0\u660E\u63A8\u7406\u6863\u4F4D\uFF0C\u8C03\u7528\u65F6\u5C06\u8DDF\u968F\u63D0\u4F9B\u65B9\u9ED8\u8BA4\u3002",
|
|
@@ -1198,7 +1212,7 @@ var en = {
|
|
|
1198
1212
|
"panel.tokens.output": "Output {count}",
|
|
1199
1213
|
"panel.tokens.cacheRead": "Cache read {count}",
|
|
1200
1214
|
"panel.tokens.cacheWrite": "Cache write {count}",
|
|
1201
|
-
"undo.applied": "Original
|
|
1215
|
+
"undo.applied": "Original draft replaced",
|
|
1202
1216
|
"undo.undo": "Undo",
|
|
1203
1217
|
"undo.dismiss": "Dismiss",
|
|
1204
1218
|
"error.empty": "The input box is empty \u2014 type a prompt to enhance first.",
|
|
@@ -1229,7 +1243,9 @@ var en = {
|
|
|
1229
1243
|
"settings.description": "Turns a composer draft into a structured prompt: role and goal, executable steps, output format, acceptance criteria, edge cases. The draft is preserved, failures never touch it, and saved values apply to the next call.",
|
|
1230
1244
|
"settings.save": "Save",
|
|
1231
1245
|
"settings.saving": "Saving\u2026",
|
|
1246
|
+
"settings.saved": "Saved",
|
|
1232
1247
|
"settings.saveFailed": "The deployment did not accept these values; they were left for you to correct.",
|
|
1248
|
+
"settings.saveFailedShort": "Save failed",
|
|
1233
1249
|
"settings.readOnly": "This deployment stores settings read-only.",
|
|
1234
1250
|
"settings.unavailable": "This plugin is not loaded, so it cannot be configured right now.",
|
|
1235
1251
|
"settings.reset": "Reset to default",
|
|
@@ -1267,7 +1283,7 @@ var en = {
|
|
|
1267
1283
|
"settings.row.temperature.label": "Temperature",
|
|
1268
1284
|
"settings.row.temperature.hint": "Sampling temperature (0\u20131, step 0.05); lower stays closer to the original. Default 0.3.",
|
|
1269
1285
|
"settings.row.reasoningEffort.label": "Reasoning effort",
|
|
1270
|
-
"settings.row.reasoningEffort.hint": "Tier choices come from what the configured provider/model declares; custom models are read on demand.
|
|
1286
|
+
"settings.row.reasoningEffort.hint": "Tier choices come from what the configured provider/model declares; custom models are read on demand. Provider default omits the field.",
|
|
1271
1287
|
"settings.row.maxOutputTokens.label": "Output token budget",
|
|
1272
1288
|
"settings.row.maxOutputTokens.hint": "Output budget for one enhancement call. Default 8192.",
|
|
1273
1289
|
"settings.row.maxInputChars.label": "Input character cap",
|
|
@@ -1358,8 +1374,15 @@ var CSS = `
|
|
|
1358
1374
|
font-weight: 600;
|
|
1359
1375
|
}
|
|
1360
1376
|
.dsh-pe-head .dsh-pe-title { display: inline-flex; align-items: center; gap: 6px; }
|
|
1361
|
-
.dsh-pe-head .dsh-pe-
|
|
1377
|
+
.dsh-pe-head .dsh-pe-head-actions {
|
|
1378
|
+
display: flex;
|
|
1379
|
+
align-items: center;
|
|
1380
|
+
gap: 8px;
|
|
1362
1381
|
margin-left: auto;
|
|
1382
|
+
min-width: 0;
|
|
1383
|
+
}
|
|
1384
|
+
.dsh-pe-head .dsh-pe-badge {
|
|
1385
|
+
margin-left: 0;
|
|
1363
1386
|
border: 1px solid var(--pe-border);
|
|
1364
1387
|
border-radius: 999px;
|
|
1365
1388
|
padding: 1px 8px;
|
|
@@ -1510,22 +1533,99 @@ var CSS = `
|
|
|
1510
1533
|
display: flex;
|
|
1511
1534
|
align-items: center;
|
|
1512
1535
|
gap: 8px;
|
|
1513
|
-
|
|
1536
|
+
width: fit-content;
|
|
1537
|
+
margin-left: auto;
|
|
1538
|
+
padding: 3px 6px 3px 10px;
|
|
1539
|
+
border: 1px solid var(--dsw-alias-border-l2, rgba(128, 128, 128, 0.32));
|
|
1540
|
+
border-radius: 12px;
|
|
1541
|
+
background: var(--dsw-alias-bg-layer-1, transparent);
|
|
1514
1542
|
font-size: 12px;
|
|
1515
1543
|
color: inherit;
|
|
1516
|
-
opacity: 0.85;
|
|
1517
1544
|
}
|
|
1518
|
-
.dsh-pe-undo .dsh-pe-undo-check {
|
|
1545
|
+
.dsh-pe-undo .dsh-pe-undo-check {
|
|
1546
|
+
color: var(--dsw-alias-state-success-primary, #2da44e);
|
|
1547
|
+
font-weight: 600;
|
|
1548
|
+
}
|
|
1519
1549
|
.dsh-pe-undo-link {
|
|
1520
|
-
|
|
1521
|
-
|
|
1550
|
+
display: inline-flex;
|
|
1551
|
+
align-items: center;
|
|
1552
|
+
justify-content: center;
|
|
1553
|
+
gap: 6px;
|
|
1554
|
+
height: 28px;
|
|
1555
|
+
padding: 0 10px;
|
|
1556
|
+
border: 1px solid var(--dsw-alias-border-l2, rgba(128, 128, 128, 0.32));
|
|
1557
|
+
border-radius: 6px;
|
|
1558
|
+
background: transparent;
|
|
1559
|
+
color: inherit;
|
|
1560
|
+
font-size: 12px;
|
|
1561
|
+
cursor: pointer;
|
|
1562
|
+
transition: background-color 120ms ease;
|
|
1522
1563
|
}
|
|
1523
|
-
.dsh-pe-undo-link:hover { background: rgba(127,127,127,0.
|
|
1564
|
+
.dsh-pe-undo-link:hover { background: rgba(127, 127, 127, 0.16); }
|
|
1565
|
+
.dsh-pe-undo-link:active { background: rgba(127, 127, 127, 0.22); }
|
|
1524
1566
|
.dsh-pe-undo-x {
|
|
1525
|
-
|
|
1526
|
-
|
|
1567
|
+
display: inline-flex;
|
|
1568
|
+
align-items: center;
|
|
1569
|
+
justify-content: center;
|
|
1570
|
+
width: 28px;
|
|
1571
|
+
height: 28px;
|
|
1572
|
+
border: none;
|
|
1573
|
+
border-radius: 6px;
|
|
1574
|
+
background: transparent;
|
|
1575
|
+
color: inherit;
|
|
1576
|
+
opacity: 0.55;
|
|
1577
|
+
cursor: pointer;
|
|
1578
|
+
padding: 0;
|
|
1579
|
+
font-size: 12px;
|
|
1580
|
+
}
|
|
1581
|
+
.dsh-pe-undo-x:hover { opacity: 1; background: var(--dsw-alias-bg-layer-2, rgba(128, 128, 128, 0.12)); }
|
|
1582
|
+
.dsh-pe-segmented-labels [role="tab"] {
|
|
1583
|
+
min-width: 0;
|
|
1584
|
+
overflow: hidden;
|
|
1585
|
+
text-overflow: ellipsis;
|
|
1586
|
+
text-align: center;
|
|
1587
|
+
white-space: nowrap;
|
|
1588
|
+
}
|
|
1589
|
+
.dsh-pe-form-footer {
|
|
1590
|
+
display: flex;
|
|
1591
|
+
justify-content: flex-end;
|
|
1592
|
+
margin-top: 12px;
|
|
1593
|
+
padding-top: 10px;
|
|
1594
|
+
border-top: 1px solid var(--dsw-alias-border-l3, rgba(128, 128, 128, 0.22));
|
|
1595
|
+
}
|
|
1596
|
+
.dsh-pe-save-group {
|
|
1597
|
+
display: flex;
|
|
1598
|
+
align-items: center;
|
|
1599
|
+
justify-content: flex-end;
|
|
1600
|
+
flex-wrap: wrap;
|
|
1601
|
+
gap: 8px;
|
|
1602
|
+
min-width: 0;
|
|
1603
|
+
max-width: 100%;
|
|
1604
|
+
margin-left: auto;
|
|
1527
1605
|
}
|
|
1528
|
-
.dsh-pe-
|
|
1606
|
+
.dsh-pe-save-status {
|
|
1607
|
+
min-width: 0;
|
|
1608
|
+
max-width: 100%;
|
|
1609
|
+
font-size: 12px;
|
|
1610
|
+
color: var(--dsw-alias-label-secondary, inherit);
|
|
1611
|
+
text-align: right;
|
|
1612
|
+
overflow-wrap: anywhere;
|
|
1613
|
+
}
|
|
1614
|
+
.dsh-pe-save-button {
|
|
1615
|
+
flex: none;
|
|
1616
|
+
margin-left: 0;
|
|
1617
|
+
height: 28px;
|
|
1618
|
+
padding: 0 14px;
|
|
1619
|
+
border: 1px solid var(--dsw-alias-border-l2, rgba(128, 128, 128, 0.32));
|
|
1620
|
+
border-radius: 8px;
|
|
1621
|
+
background: var(--dsw-alias-bg-layer-1, transparent);
|
|
1622
|
+
color: inherit;
|
|
1623
|
+
font: inherit;
|
|
1624
|
+
font-size: 12px;
|
|
1625
|
+
cursor: pointer;
|
|
1626
|
+
}
|
|
1627
|
+
.dsh-pe-save-button:hover:not(:disabled) { background: rgba(127, 127, 127, 0.12); }
|
|
1628
|
+
.dsh-pe-save-button:disabled { opacity: 0.5; cursor: default; }
|
|
1529
1629
|
`;
|
|
1530
1630
|
function ensureStyles() {
|
|
1531
1631
|
if (document.getElementById(STYLE_ID) !== null) return false;
|
|
@@ -1716,7 +1816,7 @@ function installClientSettingsSource(ctx, options) {
|
|
|
1716
1816
|
}
|
|
1717
1817
|
|
|
1718
1818
|
// src/client/settings-page.tsx
|
|
1719
|
-
var
|
|
1819
|
+
var import_react8 = require("react");
|
|
1720
1820
|
|
|
1721
1821
|
// src/shared/defaults.ts
|
|
1722
1822
|
var DEFAULT_VALUES = {
|
|
@@ -1790,7 +1890,7 @@ async function fetchReasoningCapabilities(provider, model, options = {}) {
|
|
|
1790
1890
|
}
|
|
1791
1891
|
|
|
1792
1892
|
// src/client/llm-catalog.ts
|
|
1793
|
-
var
|
|
1893
|
+
var import_react7 = require("react");
|
|
1794
1894
|
|
|
1795
1895
|
// src/shared/catalog.ts
|
|
1796
1896
|
var LLM_PROVIDERS_ENDPOINT = "/dsh-prompt-enhance/llm-providers";
|
|
@@ -1836,17 +1936,17 @@ async function fetchRouteCheck(provider, model, signal) {
|
|
|
1836
1936
|
return value;
|
|
1837
1937
|
}
|
|
1838
1938
|
function useLlmRouting(provider, model) {
|
|
1839
|
-
const [providers, setProviders] = (0,
|
|
1840
|
-
const [providersLoading, setProvidersLoading] = (0,
|
|
1841
|
-
const [providersFailed, setProvidersFailed] = (0,
|
|
1842
|
-
const [providersToken, setProvidersToken] = (0,
|
|
1843
|
-
const [models, setModels] = (0,
|
|
1844
|
-
const [modelsLoading, setModelsLoading] = (0,
|
|
1845
|
-
const [modelsFailed, setModelsFailed] = (0,
|
|
1846
|
-
const [modelsToken, setModelsToken] = (0,
|
|
1847
|
-
const [routeChecking, setRouteChecking] = (0,
|
|
1848
|
-
const [routeAvailable, setRouteAvailable] = (0,
|
|
1849
|
-
(0,
|
|
1939
|
+
const [providers, setProviders] = (0, import_react7.useState)([]);
|
|
1940
|
+
const [providersLoading, setProvidersLoading] = (0, import_react7.useState)(true);
|
|
1941
|
+
const [providersFailed, setProvidersFailed] = (0, import_react7.useState)(false);
|
|
1942
|
+
const [providersToken, setProvidersToken] = (0, import_react7.useState)(0);
|
|
1943
|
+
const [models, setModels] = (0, import_react7.useState)([]);
|
|
1944
|
+
const [modelsLoading, setModelsLoading] = (0, import_react7.useState)(false);
|
|
1945
|
+
const [modelsFailed, setModelsFailed] = (0, import_react7.useState)(false);
|
|
1946
|
+
const [modelsToken, setModelsToken] = (0, import_react7.useState)(0);
|
|
1947
|
+
const [routeChecking, setRouteChecking] = (0, import_react7.useState)(false);
|
|
1948
|
+
const [routeAvailable, setRouteAvailable] = (0, import_react7.useState)(void 0);
|
|
1949
|
+
(0, import_react7.useEffect)(() => {
|
|
1850
1950
|
const controller = new AbortController();
|
|
1851
1951
|
setProvidersLoading(true);
|
|
1852
1952
|
setProvidersFailed(false);
|
|
@@ -1862,7 +1962,7 @@ function useLlmRouting(provider, model) {
|
|
|
1862
1962
|
});
|
|
1863
1963
|
return () => controller.abort();
|
|
1864
1964
|
}, [providersToken]);
|
|
1865
|
-
(0,
|
|
1965
|
+
(0, import_react7.useEffect)(() => {
|
|
1866
1966
|
if (provider === "") {
|
|
1867
1967
|
setModels([]);
|
|
1868
1968
|
setModelsLoading(false);
|
|
@@ -1885,7 +1985,7 @@ function useLlmRouting(provider, model) {
|
|
|
1885
1985
|
});
|
|
1886
1986
|
return () => controller.abort();
|
|
1887
1987
|
}, [provider, modelsToken]);
|
|
1888
|
-
(0,
|
|
1988
|
+
(0, import_react7.useEffect)(() => {
|
|
1889
1989
|
if (provider === "" || model === "") {
|
|
1890
1990
|
setRouteChecking(false);
|
|
1891
1991
|
setRouteAvailable(void 0);
|
|
@@ -1977,8 +2077,8 @@ var ROWS = [
|
|
|
1977
2077
|
{ key: "streaming", kind: "boolean", label: "settings.row.streaming.label", hint: "settings.row.streaming.hint" },
|
|
1978
2078
|
{ key: "provider", kind: "provider", label: "settings.row.provider.label", hint: "settings.row.provider.hint" },
|
|
1979
2079
|
{ key: "model", kind: "model", label: "settings.row.model.label", hint: "settings.row.model.hint" },
|
|
1980
|
-
{ key: "temperature", kind: "number", label: "settings.row.temperature.label", hint: "settings.row.temperature.hint" },
|
|
1981
2080
|
{ key: "reasoningEffort", kind: "reasoning", label: "settings.row.reasoningEffort.label", hint: "settings.row.reasoningEffort.hint" },
|
|
2081
|
+
{ key: "temperature", kind: "number", label: "settings.row.temperature.label", hint: "settings.row.temperature.hint" },
|
|
1982
2082
|
{ key: "maxOutputTokens", kind: "number", label: "settings.row.maxOutputTokens.label", hint: "settings.row.maxOutputTokens.hint" },
|
|
1983
2083
|
{ key: "maxInputChars", kind: "number", label: "settings.row.maxInputChars.label", hint: "settings.row.maxInputChars.hint" },
|
|
1984
2084
|
{ key: "timeoutMs", kind: "number", label: "settings.row.timeoutMs.label", hint: "settings.row.timeoutMs.hint" },
|
|
@@ -2025,8 +2125,10 @@ function sectionCopy(t, chinese) {
|
|
|
2025
2125
|
unavailable: t("settings.unavailable"),
|
|
2026
2126
|
readOnly: t("settings.readOnly"),
|
|
2027
2127
|
saveFailed: t("settings.saveFailed"),
|
|
2128
|
+
saveFailedShort: t("settings.saveFailedShort"),
|
|
2028
2129
|
save: t("settings.save"),
|
|
2029
2130
|
saving: t("settings.saving"),
|
|
2131
|
+
saved: t("settings.saved"),
|
|
2030
2132
|
reset: t("settings.reset"),
|
|
2031
2133
|
invalidNumber: t("settings.invalidNumber")
|
|
2032
2134
|
},
|
|
@@ -2043,8 +2145,10 @@ function pageCopy(t) {
|
|
|
2043
2145
|
unavailable: t("settings.unavailable"),
|
|
2044
2146
|
readOnly: t("settings.readOnly"),
|
|
2045
2147
|
saveFailed: t("settings.saveFailed"),
|
|
2148
|
+
saveFailedShort: t("settings.saveFailedShort"),
|
|
2046
2149
|
save: t("settings.save"),
|
|
2047
2150
|
saving: t("settings.saving"),
|
|
2151
|
+
saved: t("settings.saved"),
|
|
2048
2152
|
reset: t("settings.reset"),
|
|
2049
2153
|
invalidNumber: t("settings.invalidNumber")
|
|
2050
2154
|
},
|
|
@@ -2133,7 +2237,7 @@ var REPOSITORY_URL = "https://github.com/surfishs/dsh-prompt-enhance";
|
|
|
2133
2237
|
var NPM_URL = "https://www.npmjs.com/package/@surfishs/dsh-prompt-enhance";
|
|
2134
2238
|
var GITHUB_MARK = "M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82a7.6 7.6 0 0 1 2-.27c.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8z";
|
|
2135
2239
|
var NPM_MARK = "M1.763 0C.786 0 0 .786 0 1.763v20.474C0 23.214.786 24 1.763 24h20.474c.977 0 1.763-.786 1.763-1.763V1.763C24 .786 23.214 0 22.237 0zM5.13 5.323l13.837.019-.009 13.836h-3.464l.01-10.382h-3.456L12.04 19.17H5.113z";
|
|
2136
|
-
var PLUGIN_VERSION = true ? "0.0.
|
|
2240
|
+
var PLUGIN_VERSION = true ? "0.0.6" : "0.0.0";
|
|
2137
2241
|
var HEADER_STYLE = { display: "flex", flexDirection: "column", gap: 12, padding: "2px 0" };
|
|
2138
2242
|
var HEADER_ROW_STYLE = { display: "flex", alignItems: "center", gap: 10, flexWrap: "wrap" };
|
|
2139
2243
|
var HEADER_TITLE_STYLE = {
|
|
@@ -2258,8 +2362,9 @@ function ChoiceRow(props) {
|
|
|
2258
2362
|
import_dsh_client_ui_primitives.SegmentedControl,
|
|
2259
2363
|
{
|
|
2260
2364
|
id: props.id,
|
|
2365
|
+
className: "dsh-pe-segmented-labels",
|
|
2261
2366
|
value: props.view.text,
|
|
2262
|
-
options: props.options,
|
|
2367
|
+
options: props.options.map((option) => ({ ...option, title: option.title ?? option.label })),
|
|
2263
2368
|
disabled: props.disabled,
|
|
2264
2369
|
label: props.label,
|
|
2265
2370
|
onChange: (next) => props.onEdit(next)
|
|
@@ -2270,13 +2375,13 @@ function ChoiceRow(props) {
|
|
|
2270
2375
|
}
|
|
2271
2376
|
function ReasoningRow(props) {
|
|
2272
2377
|
const pair = props.provider !== "" && props.model !== "" ? `${props.provider}/${props.model}` : "";
|
|
2273
|
-
const [phase, setPhase] = (0,
|
|
2274
|
-
const [capabilities, setCapabilities] = (0,
|
|
2275
|
-
const [refreshToken, setRefreshToken] = (0,
|
|
2276
|
-
const [feedback, setFeedback] = (0,
|
|
2277
|
-
const forceRef = (0,
|
|
2278
|
-
const feedbackTimer = (0,
|
|
2279
|
-
(0,
|
|
2378
|
+
const [phase, setPhase] = (0, import_react8.useState)("loading");
|
|
2379
|
+
const [capabilities, setCapabilities] = (0, import_react8.useState)(void 0);
|
|
2380
|
+
const [refreshToken, setRefreshToken] = (0, import_react8.useState)(0);
|
|
2381
|
+
const [feedback, setFeedback] = (0, import_react8.useState)("idle");
|
|
2382
|
+
const forceRef = (0, import_react8.useRef)(false);
|
|
2383
|
+
const feedbackTimer = (0, import_react8.useRef)(void 0);
|
|
2384
|
+
(0, import_react8.useEffect)(() => {
|
|
2280
2385
|
const controller = new AbortController();
|
|
2281
2386
|
const force = forceRef.current;
|
|
2282
2387
|
forceRef.current = false;
|
|
@@ -2334,11 +2439,15 @@ function ReasoningRow(props) {
|
|
|
2334
2439
|
options.push({
|
|
2335
2440
|
value: effort.id,
|
|
2336
2441
|
label: effort.name,
|
|
2337
|
-
|
|
2442
|
+
title: effort.description === void 0 ? effort.name : `${effort.name} \u2014 ${effort.description}`
|
|
2338
2443
|
});
|
|
2339
2444
|
}
|
|
2340
2445
|
}
|
|
2341
|
-
options.push({
|
|
2446
|
+
options.push({
|
|
2447
|
+
value: "inherit",
|
|
2448
|
+
label: props.copy.choice("settings.reasoning.inherit"),
|
|
2449
|
+
title: props.copy.choice("settings.reasoning.inherit")
|
|
2450
|
+
});
|
|
2342
2451
|
const unsupported = !noTiers && phase === "ready" && capabilities?.source !== "unavailable" && current2 !== "" && current2 !== "inherit" && !realTierKnown;
|
|
2343
2452
|
const refreshing = feedback === "refreshing";
|
|
2344
2453
|
const refresh = () => {
|
|
@@ -2364,6 +2473,7 @@ function ReasoningRow(props) {
|
|
|
2364
2473
|
import_dsh_client_ui_primitives.SegmentedControl,
|
|
2365
2474
|
{
|
|
2366
2475
|
id: props.id,
|
|
2476
|
+
className: "dsh-pe-segmented-labels",
|
|
2367
2477
|
value: noTiers ? "inherit" : props.view.text,
|
|
2368
2478
|
options,
|
|
2369
2479
|
disabled: props.disabled,
|
|
@@ -2380,7 +2490,7 @@ function ReasoningRow(props) {
|
|
|
2380
2490
|
] });
|
|
2381
2491
|
}
|
|
2382
2492
|
function SelectControl(props) {
|
|
2383
|
-
const [focused, setFocused] = (0,
|
|
2493
|
+
const [focused, setFocused] = (0, import_react8.useState)(false);
|
|
2384
2494
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2385
2495
|
"select",
|
|
2386
2496
|
{
|
|
@@ -2425,7 +2535,7 @@ function ProviderRow(props) {
|
|
|
2425
2535
|
function ModelRow(props) {
|
|
2426
2536
|
const current2 = props.view.text;
|
|
2427
2537
|
const provider = props.providerValue;
|
|
2428
|
-
const [customMode, setCustomMode] = (0,
|
|
2538
|
+
const [customMode, setCustomMode] = (0, import_react8.useState)(false);
|
|
2429
2539
|
const known = props.routing.models.entries.some((entry) => entry.id === current2);
|
|
2430
2540
|
const showCustom = provider !== "" && (customMode || current2 !== "" && !known);
|
|
2431
2541
|
const pairIncomplete = provider !== "" && current2 === "";
|
|
@@ -2474,15 +2584,20 @@ function ModelRow(props) {
|
|
|
2474
2584
|
] });
|
|
2475
2585
|
}
|
|
2476
2586
|
function TextControl(props) {
|
|
2477
|
-
const [focused, setFocused] = (0,
|
|
2478
|
-
const
|
|
2587
|
+
const [focused, setFocused] = (0, import_react8.useState)(false);
|
|
2588
|
+
const [revealedInvalid, setRevealedInvalid] = (0, import_react8.useState)(false);
|
|
2589
|
+
(0, import_react8.useEffect)(() => {
|
|
2590
|
+
if (props.invalid !== true) setRevealedInvalid(false);
|
|
2591
|
+
}, [props.invalid]);
|
|
2592
|
+
const showInvalid = props.invalid === true && revealedInvalid;
|
|
2593
|
+
const borderColor = showInvalid ? "var(--dsw-alias-state-error-primary, #f85149)" : focused ? "var(--dsw-alias-state-business-primary, #4f8cff)" : void 0;
|
|
2479
2594
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2480
2595
|
"input",
|
|
2481
2596
|
{
|
|
2482
2597
|
id: props.id,
|
|
2483
2598
|
type: "text",
|
|
2484
2599
|
inputMode: props.numeric === true ? "numeric" : void 0,
|
|
2485
|
-
"aria-invalid":
|
|
2600
|
+
"aria-invalid": showInvalid || void 0,
|
|
2486
2601
|
disabled: props.disabled,
|
|
2487
2602
|
placeholder: props.placeholder,
|
|
2488
2603
|
value: props.value,
|
|
@@ -2492,7 +2607,17 @@ function TextControl(props) {
|
|
|
2492
2607
|
...borderColor === void 0 ? {} : { borderColor }
|
|
2493
2608
|
},
|
|
2494
2609
|
onFocus: () => setFocused(true),
|
|
2495
|
-
onBlur: () =>
|
|
2610
|
+
onBlur: () => {
|
|
2611
|
+
setFocused(false);
|
|
2612
|
+
if (props.invalid === true) setRevealedInvalid(true);
|
|
2613
|
+
props.onCommit?.();
|
|
2614
|
+
},
|
|
2615
|
+
onKeyDown: (event) => {
|
|
2616
|
+
if (event.key !== "Enter") return;
|
|
2617
|
+
event.preventDefault();
|
|
2618
|
+
if (props.invalid === true) setRevealedInvalid(true);
|
|
2619
|
+
props.onCommit?.();
|
|
2620
|
+
},
|
|
2496
2621
|
onChange: (event) => props.onChange(event.target.value)
|
|
2497
2622
|
}
|
|
2498
2623
|
);
|
|
@@ -2513,7 +2638,8 @@ function ValueRow(props) {
|
|
|
2513
2638
|
numeric: props.numeric,
|
|
2514
2639
|
invalid,
|
|
2515
2640
|
disabled: props.disabled,
|
|
2516
|
-
onChange: props.onEdit
|
|
2641
|
+
onChange: props.onEdit,
|
|
2642
|
+
onCommit: props.onCommit
|
|
2517
2643
|
}
|
|
2518
2644
|
),
|
|
2519
2645
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { style: HINT_STYLE, children: props.hint }),
|
|
@@ -2529,7 +2655,8 @@ function SettingsRow(props) {
|
|
|
2529
2655
|
view: props.view,
|
|
2530
2656
|
disabled: props.disabled,
|
|
2531
2657
|
onEdit: props.onEdit,
|
|
2532
|
-
onReset: props.onReset
|
|
2658
|
+
onReset: props.onReset,
|
|
2659
|
+
onCommit: props.onCommit
|
|
2533
2660
|
};
|
|
2534
2661
|
switch (props.row.kind) {
|
|
2535
2662
|
case "boolean":
|
|
@@ -2550,24 +2677,140 @@ function SettingsRows(props) {
|
|
|
2550
2677
|
const provider = viewOf(props.state, "provider").text.trim();
|
|
2551
2678
|
const model = viewOf(props.state, "model").text.trim();
|
|
2552
2679
|
const routing = useLlmRouting(provider, model);
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
disabled: !props.state.writable,
|
|
2563
|
-
reasoningPair: { provider, model },
|
|
2564
|
-
routing,
|
|
2565
|
-
providerValue: provider,
|
|
2566
|
-
onEdit: (text) => props.edit(row.key, text),
|
|
2567
|
-
onReset: () => props.resetField(row.key)
|
|
2680
|
+
const [saveState, setSaveState] = (0, import_react8.useState)("idle");
|
|
2681
|
+
const timers = (0, import_react8.useRef)(/* @__PURE__ */ new Map());
|
|
2682
|
+
const savedTimer = (0, import_react8.useRef)(void 0);
|
|
2683
|
+
const savedValues = (0, import_react8.useRef)(/* @__PURE__ */ new Map());
|
|
2684
|
+
const sequence = (0, import_react8.useRef)(0);
|
|
2685
|
+
(0, import_react8.useEffect)(() => {
|
|
2686
|
+
for (const row of ROWS) {
|
|
2687
|
+
if (!savedValues.current.has(row.key)) {
|
|
2688
|
+
savedValues.current.set(row.key, viewOf(props.state, row.key).text);
|
|
2568
2689
|
}
|
|
2569
|
-
|
|
2570
|
-
}
|
|
2690
|
+
}
|
|
2691
|
+
}, [props.state]);
|
|
2692
|
+
const runSave = async (key, text) => {
|
|
2693
|
+
if (props.writeField === void 0) return;
|
|
2694
|
+
if (savedValues.current.get(key) === text) return;
|
|
2695
|
+
const ticket = ++sequence.current;
|
|
2696
|
+
setSaveState("saving");
|
|
2697
|
+
const result = await props.writeField(key, text);
|
|
2698
|
+
if (ticket !== sequence.current) return;
|
|
2699
|
+
if (result === "invalid") {
|
|
2700
|
+
setSaveState("idle");
|
|
2701
|
+
return;
|
|
2702
|
+
}
|
|
2703
|
+
if (result === "failed") {
|
|
2704
|
+
setSaveState("failed");
|
|
2705
|
+
return;
|
|
2706
|
+
}
|
|
2707
|
+
savedValues.current.set(key, text);
|
|
2708
|
+
markSaved();
|
|
2709
|
+
};
|
|
2710
|
+
const markSaved = () => {
|
|
2711
|
+
setSaveState("saved");
|
|
2712
|
+
if (savedTimer.current !== void 0) clearTimeout(savedTimer.current);
|
|
2713
|
+
savedTimer.current = setTimeout(() => {
|
|
2714
|
+
setSaveState("idle");
|
|
2715
|
+
savedTimer.current = void 0;
|
|
2716
|
+
}, 2e3);
|
|
2717
|
+
};
|
|
2718
|
+
const manualSave = async () => {
|
|
2719
|
+
if (props.writeField === void 0) {
|
|
2720
|
+
props.save?.();
|
|
2721
|
+
markSaved();
|
|
2722
|
+
return;
|
|
2723
|
+
}
|
|
2724
|
+
const changed = ROWS.map((row) => ({ key: row.key, text: viewOf(props.state, row.key).text })).filter((item) => savedValues.current.get(item.key) !== item.text);
|
|
2725
|
+
if (changed.length === 0) {
|
|
2726
|
+
markSaved();
|
|
2727
|
+
return;
|
|
2728
|
+
}
|
|
2729
|
+
const ticket = ++sequence.current;
|
|
2730
|
+
setSaveState("saving");
|
|
2731
|
+
let failed = false;
|
|
2732
|
+
let invalid = false;
|
|
2733
|
+
for (const item of changed) {
|
|
2734
|
+
const result = await props.writeField(item.key, item.text);
|
|
2735
|
+
if (result === "saved") savedValues.current.set(item.key, item.text);
|
|
2736
|
+
else if (result === "failed") failed = true;
|
|
2737
|
+
else invalid = true;
|
|
2738
|
+
}
|
|
2739
|
+
if (ticket !== sequence.current) return;
|
|
2740
|
+
if (failed) setSaveState("failed");
|
|
2741
|
+
else if (invalid && changed.every((item) => savedValues.current.get(item.key) !== item.text)) setSaveState("idle");
|
|
2742
|
+
else markSaved();
|
|
2743
|
+
};
|
|
2744
|
+
const scheduleSave = (key, text, immediate) => {
|
|
2745
|
+
const pending = timers.current.get(key);
|
|
2746
|
+
if (pending !== void 0) clearTimeout(pending);
|
|
2747
|
+
if (immediate) {
|
|
2748
|
+
timers.current.delete(key);
|
|
2749
|
+
void runSave(key, text);
|
|
2750
|
+
return;
|
|
2751
|
+
}
|
|
2752
|
+
const timer = setTimeout(() => {
|
|
2753
|
+
timers.current.delete(key);
|
|
2754
|
+
void runSave(key, text);
|
|
2755
|
+
}, 800);
|
|
2756
|
+
timers.current.set(key, timer);
|
|
2757
|
+
};
|
|
2758
|
+
const onEdit = (key, text) => {
|
|
2759
|
+
props.edit(key, text);
|
|
2760
|
+
const row = ROWS.find((item) => item.key === key);
|
|
2761
|
+
const debounced = row !== void 0 && (row.kind === "text" || row.kind === "number");
|
|
2762
|
+
scheduleSave(key, text, !debounced);
|
|
2763
|
+
};
|
|
2764
|
+
const flushField = (key, text) => {
|
|
2765
|
+
const pending = timers.current.get(key);
|
|
2766
|
+
if (pending !== void 0) {
|
|
2767
|
+
clearTimeout(pending);
|
|
2768
|
+
timers.current.delete(key);
|
|
2769
|
+
}
|
|
2770
|
+
void runSave(key, text ?? viewOf(props.state, key).text);
|
|
2771
|
+
};
|
|
2772
|
+
(0, import_react8.useEffect)(() => () => {
|
|
2773
|
+
for (const timer of timers.current.values()) clearTimeout(timer);
|
|
2774
|
+
timers.current.clear();
|
|
2775
|
+
if (savedTimer.current !== void 0) clearTimeout(savedTimer.current);
|
|
2776
|
+
}, []);
|
|
2777
|
+
const statusText = props.state.writable === false ? props.copy.labels.readOnly : saveState === "saving" ? props.copy.labels.saving : saveState === "saved" ? props.copy.labels.saved : saveState === "failed" ? props.copy.labels.saveFailedShort : "";
|
|
2778
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "dsh-pe-form", children: [
|
|
2779
|
+
ROWS.map((row, index) => {
|
|
2780
|
+
const raw = viewOf(props.state, row.key);
|
|
2781
|
+
const view = raw.overridden && atDefaultValue(row.key, raw.text) ? { ...raw, overridden: false } : raw;
|
|
2782
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: index === 0 ? void 0 : SEPARATOR_STYLE, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2783
|
+
SettingsRow,
|
|
2784
|
+
{
|
|
2785
|
+
row,
|
|
2786
|
+
copy: props.copy,
|
|
2787
|
+
view,
|
|
2788
|
+
disabled: !props.state.writable,
|
|
2789
|
+
reasoningPair: { provider, model },
|
|
2790
|
+
routing,
|
|
2791
|
+
providerValue: provider,
|
|
2792
|
+
onEdit: (text) => onEdit(row.key, text),
|
|
2793
|
+
onReset: () => props.resetField(row.key),
|
|
2794
|
+
onCommit: () => flushField(row.key, viewOf(props.state, row.key).text)
|
|
2795
|
+
}
|
|
2796
|
+
) }, row.key);
|
|
2797
|
+
}),
|
|
2798
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "dsh-pe-form-footer", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "dsh-pe-save-group", children: [
|
|
2799
|
+
statusText === "" ? null : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "dsh-pe-save-status", role: "status", "aria-live": "polite", children: statusText }),
|
|
2800
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2801
|
+
"button",
|
|
2802
|
+
{
|
|
2803
|
+
type: "button",
|
|
2804
|
+
className: "dsh-pe-save-button",
|
|
2805
|
+
disabled: props.save === void 0 || props.state.writable === false,
|
|
2806
|
+
onClick: () => {
|
|
2807
|
+
void manualSave();
|
|
2808
|
+
},
|
|
2809
|
+
children: props.copy.labels.save
|
|
2810
|
+
}
|
|
2811
|
+
)
|
|
2812
|
+
] }) })
|
|
2813
|
+
] });
|
|
2571
2814
|
}
|
|
2572
2815
|
function SettingsSection(props) {
|
|
2573
2816
|
const read = props.usePromptEnhance;
|
|
@@ -2593,7 +2836,8 @@ function SettingsSection(props) {
|
|
|
2593
2836
|
edit,
|
|
2594
2837
|
resetField,
|
|
2595
2838
|
save: props.save,
|
|
2596
|
-
discard: props.discard
|
|
2839
|
+
discard: props.discard,
|
|
2840
|
+
writeField: props.writeField
|
|
2597
2841
|
}
|
|
2598
2842
|
)
|
|
2599
2843
|
] });
|
|
@@ -2618,7 +2862,8 @@ function SettingsPage(props) {
|
|
|
2618
2862
|
edit,
|
|
2619
2863
|
resetField,
|
|
2620
2864
|
save: props.save,
|
|
2621
|
-
discard: props.discard
|
|
2865
|
+
discard: props.discard,
|
|
2866
|
+
writeField: props.writeField
|
|
2622
2867
|
}
|
|
2623
2868
|
);
|
|
2624
2869
|
}
|
|
@@ -2629,9 +2874,11 @@ var SettingsPageController = class {
|
|
|
2629
2874
|
*/
|
|
2630
2875
|
constructor(scope, getLocale) {
|
|
2631
2876
|
__publicField(this, "form");
|
|
2877
|
+
__publicField(this, "scope");
|
|
2632
2878
|
__publicField(this, "store");
|
|
2633
2879
|
__publicField(this, "getLocale");
|
|
2634
2880
|
this.getLocale = getLocale;
|
|
2881
|
+
this.scope = scope;
|
|
2635
2882
|
this.form = createSettingsForm(scope);
|
|
2636
2883
|
this.store = this.form.bind(() => {
|
|
2637
2884
|
const out = this.form.shell();
|
|
@@ -2647,7 +2894,11 @@ var SettingsPageController = class {
|
|
|
2647
2894
|
/** The props the slots hand their pages. */
|
|
2648
2895
|
inject() {
|
|
2649
2896
|
const face = this.getLocale?.();
|
|
2650
|
-
const props = {
|
|
2897
|
+
const props = {
|
|
2898
|
+
hooks: { promptEnhance: this.store },
|
|
2899
|
+
...this.form.actions(),
|
|
2900
|
+
writeField: (key, text) => this.writeField(key, text)
|
|
2901
|
+
};
|
|
2651
2902
|
if (face !== void 0) {
|
|
2652
2903
|
;
|
|
2653
2904
|
props.hooks.promptEnhanceLocale = {
|
|
@@ -2658,6 +2909,25 @@ var SettingsPageController = class {
|
|
|
2658
2909
|
}
|
|
2659
2910
|
return props;
|
|
2660
2911
|
}
|
|
2912
|
+
/** Write one field through the host's per-field mutation API. */
|
|
2913
|
+
async writeField(key, text) {
|
|
2914
|
+
const descriptor = FIELD_SPECS.find((item) => item.field === key);
|
|
2915
|
+
if (descriptor === void 0) return "failed";
|
|
2916
|
+
const parsed = descriptor.parse(text);
|
|
2917
|
+
if (parsed === void 0) return "invalid";
|
|
2918
|
+
if (this.scope.set === void 0) return "failed";
|
|
2919
|
+
try {
|
|
2920
|
+
if (parsed.kind === "clear") {
|
|
2921
|
+
if (this.scope.unset === void 0) return "failed";
|
|
2922
|
+
if (!await this.scope.unset(key)) return "failed";
|
|
2923
|
+
} else {
|
|
2924
|
+
if (!await this.scope.set(key, parsed.value)) return "failed";
|
|
2925
|
+
}
|
|
2926
|
+
return "saved";
|
|
2927
|
+
} catch {
|
|
2928
|
+
return "failed";
|
|
2929
|
+
}
|
|
2930
|
+
}
|
|
2661
2931
|
/** Release the form's subscriptions. */
|
|
2662
2932
|
dispose() {
|
|
2663
2933
|
try {
|