@ykurilov/agent-chat-flows 0.62.0 → 0.63.0
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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @ykurilov/agent-chat-flows
|
|
2
2
|
|
|
3
|
+
## 0.63.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 8a9e399: Доска сценария больше не показывает «Сохранено» для несохранённых правок после возвращения на вкладку: новое необязательное `savedValue` у `FlowEditor` и функция `sameFlow` из `@ykurilov/agent-chat-flows/react`.
|
|
8
|
+
|
|
9
|
+
### Как обновить приложение
|
|
10
|
+
|
|
11
|
+
Если `FlowEditor` стоит на отдельной вкладке и размонтируется при уходе, передайте `savedValue={сценарий, как он лежит на сервере}`. Без него поведение прежнее.
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- @ykurilov/agent-chat-core@0.63.0
|
|
16
|
+
- @ykurilov/agent-chat-react@0.63.0
|
|
17
|
+
|
|
3
18
|
## 0.62.0
|
|
4
19
|
|
|
5
20
|
### Minor Changes
|
package/dist/react.js
CHANGED
|
@@ -825,6 +825,21 @@ function flowToJson(flow) {
|
|
|
825
825
|
return `${JSON.stringify(keepJudgeText(compactFlow(flow)), null, 2)}
|
|
826
826
|
`;
|
|
827
827
|
}
|
|
828
|
+
function sortKeys(value) {
|
|
829
|
+
if (Array.isArray(value)) return value.map(sortKeys);
|
|
830
|
+
if (value && typeof value === "object") {
|
|
831
|
+
return Object.fromEntries(
|
|
832
|
+
Object.entries(value).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([key, inner]) => [key, sortKeys(inner)])
|
|
833
|
+
);
|
|
834
|
+
}
|
|
835
|
+
return value;
|
|
836
|
+
}
|
|
837
|
+
function flowFingerprint(flow) {
|
|
838
|
+
return JSON.stringify(sortKeys(keepJudgeText(compactFlow(flow))));
|
|
839
|
+
}
|
|
840
|
+
function sameFlow(a, b) {
|
|
841
|
+
return flowFingerprint(a) === flowFingerprint(b);
|
|
842
|
+
}
|
|
828
843
|
function keepJudgeText(json) {
|
|
829
844
|
const fix = (exits) => exits?.forEach((exit) => {
|
|
830
845
|
if (exit.when?.type === "judge" && exit.when.text === void 0) exit.when.text = "";
|
|
@@ -1729,7 +1744,10 @@ function useFlowEditor(options) {
|
|
|
1729
1744
|
const [jsonErrors, setJsonErrors] = useState3([]);
|
|
1730
1745
|
const [simulation, setSimulation] = useState3(null);
|
|
1731
1746
|
const [saving, setSaving] = useState3(false);
|
|
1732
|
-
const [
|
|
1747
|
+
const [mountedPrint] = useState3(() => flowFingerprint(flow));
|
|
1748
|
+
const savedPrint = useMemo3(() => options.savedValue ? flowFingerprint(options.savedValue) : void 0, [options.savedValue]);
|
|
1749
|
+
const [sent, setSent] = useState3(null);
|
|
1750
|
+
const savedJson = sent && sent.base === savedPrint ? sent.print : savedPrint ?? mountedPrint;
|
|
1733
1751
|
const [rejection, setRejection] = useState3(null);
|
|
1734
1752
|
const readOnly = options.readOnly === true;
|
|
1735
1753
|
const checks = options.checks;
|
|
@@ -1741,7 +1759,8 @@ function useFlowEditor(options) {
|
|
|
1741
1759
|
);
|
|
1742
1760
|
const issueCount = useMemo3(() => countIssues(issues), [issues]);
|
|
1743
1761
|
const json = useMemo3(() => flowToJson(flow), [flow]);
|
|
1744
|
-
const
|
|
1762
|
+
const print = useMemo3(() => flowFingerprint(flow), [flow]);
|
|
1763
|
+
const dirty = print !== savedJson;
|
|
1745
1764
|
const visibleSelection = selection.kind === "state" && !flow.states.some((state) => state.id === selection.stateId) ? { kind: "overview" } : selection;
|
|
1746
1765
|
const edit = useCallback3((change) => {
|
|
1747
1766
|
if (latest.current.readOnly) return;
|
|
@@ -1862,7 +1881,7 @@ function useFlowEditor(options) {
|
|
|
1862
1881
|
return;
|
|
1863
1882
|
}
|
|
1864
1883
|
setRejection(null);
|
|
1865
|
-
|
|
1884
|
+
setSent({ print: flowFingerprint(value), base: latest.current.savedValue ? flowFingerprint(latest.current.savedValue) : void 0 });
|
|
1866
1885
|
} catch (error) {
|
|
1867
1886
|
console.warn("[flow] onSave failed", error);
|
|
1868
1887
|
setRejection({ flow: value, issues: [] });
|
|
@@ -2640,6 +2659,7 @@ export {
|
|
|
2640
2659
|
formatDuration,
|
|
2641
2660
|
nextQuestionField,
|
|
2642
2661
|
russianFlowLabels,
|
|
2662
|
+
sameFlow,
|
|
2643
2663
|
setKnownValue,
|
|
2644
2664
|
simulationChoices,
|
|
2645
2665
|
startSimulation,
|