dsh-tdai-memory 0.2.5 → 0.2.7
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/client.js +18 -10
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -126,10 +126,7 @@ window.__ModuleLoader__.load({
|
|
|
126
126
|
var t = props.t;
|
|
127
127
|
var scope = props.scope;
|
|
128
128
|
var api = props.api;
|
|
129
|
-
var snapshot = react.
|
|
130
|
-
function (cb) { return scope.subscribe(cb); },
|
|
131
|
-
function () { return scope.getSnapshot(); }
|
|
132
|
-
);
|
|
129
|
+
var [snapshot, setSnapshot] = react.useState(function () { return scope.getSnapshot(); });
|
|
133
130
|
var ready = snapshot.status === "ready" && snapshot.value !== void 0;
|
|
134
131
|
var [draft, setDraft] = react.useState({});
|
|
135
132
|
var [busy, setBusy] = react.useState(false);
|
|
@@ -138,12 +135,19 @@ window.__ModuleLoader__.load({
|
|
|
138
135
|
|
|
139
136
|
react.useEffect(function () {
|
|
140
137
|
scope.load();
|
|
141
|
-
|
|
138
|
+
var alive = true;
|
|
139
|
+
var sync = function () { if (alive) setSnapshot(scope.getSnapshot()); };
|
|
140
|
+
var un = typeof scope.subscribe === "function" ? scope.subscribe(sync) : null;
|
|
141
|
+
return function () { alive = false; if (un) un(); if (scope.dispose) scope.dispose(); };
|
|
142
142
|
}, [scope]);
|
|
143
|
+
// Initialize the draft ONLY when the snapshot becomes ready — never on
|
|
144
|
+
// value churn. settingsScope.getSnapshot() returns a fresh object per
|
|
145
|
+
// call, so depending on snapshot.value would reset user input on every
|
|
146
|
+
// render (typing appears dead).
|
|
143
147
|
react.useEffect(function () {
|
|
144
148
|
if (ready) setDraft(Object.assign({}, valueToDraft(snapshot.value)));
|
|
145
149
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
146
|
-
}, [ready
|
|
150
|
+
}, [ready]);
|
|
147
151
|
|
|
148
152
|
if (snapshot.status === "unavailable") {
|
|
149
153
|
return h("p", { className: "__tm_unavailable" }, t("unavailable"));
|
|
@@ -198,6 +202,7 @@ window.__ModuleLoader__.load({
|
|
|
198
202
|
return;
|
|
199
203
|
}
|
|
200
204
|
setNotice(t("saved"));
|
|
205
|
+
if (response.result.value) setDraft(Object.assign({}, valueToDraft(response.result.value)));
|
|
201
206
|
scope.load();
|
|
202
207
|
}).catch(function (e) {
|
|
203
208
|
setBusy(false); setError(t("error") + ": " + String(e && e.message || e));
|
|
@@ -214,6 +219,7 @@ window.__ModuleLoader__.load({
|
|
|
214
219
|
setBusy(false);
|
|
215
220
|
if (!response.result.ok) { setError(t("error")); return; }
|
|
216
221
|
setNotice(t("saved"));
|
|
222
|
+
if (response.result.value) setDraft(Object.assign({}, valueToDraft(response.result.value)));
|
|
217
223
|
scope.load();
|
|
218
224
|
}).catch(function (e) {
|
|
219
225
|
setBusy(false); setError(t("error") + ": " + String(e && e.message || e));
|
|
@@ -222,8 +228,10 @@ window.__ModuleLoader__.load({
|
|
|
222
228
|
|
|
223
229
|
var nodes = [];
|
|
224
230
|
var lastGroup = null;
|
|
225
|
-
|
|
226
|
-
|
|
231
|
+
// forEach callback gives each handler its own `f` — a `for (var i)`
|
|
232
|
+
// loop would share one `f` across every onChange closure, so typing
|
|
233
|
+
// updated the LAST field's draft and the input appeared dead.
|
|
234
|
+
FIELDS.forEach(function (f) {
|
|
227
235
|
if (f.group !== lastGroup) {
|
|
228
236
|
lastGroup = f.group;
|
|
229
237
|
nodes.push(h("div", { key: "g" + f.group, className: "__tm_group" }, t(f.group)));
|
|
@@ -237,7 +245,7 @@ window.__ModuleLoader__.load({
|
|
|
237
245
|
overridden ? h("span", { className: "__tm_override" }, t("overridden")) : null
|
|
238
246
|
)
|
|
239
247
|
));
|
|
240
|
-
|
|
248
|
+
return;
|
|
241
249
|
}
|
|
242
250
|
nodes.push(h("label", { key: f.path.join("."), className: "__tm_field" },
|
|
243
251
|
h("span", { className: "__tm_label" },
|
|
@@ -253,7 +261,7 @@ window.__ModuleLoader__.load({
|
|
|
253
261
|
}),
|
|
254
262
|
f.type === "password" ? h("span", { className: "__tm_hint" }, t("secretHint")) : null
|
|
255
263
|
));
|
|
256
|
-
}
|
|
264
|
+
});
|
|
257
265
|
|
|
258
266
|
return h("div", { className: "__tm_root" },
|
|
259
267
|
h("p", { className: "__tm_hint", style: { margin: "0 0 4px" } }, t("intro")),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-tdai-memory",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"description": "DeepSeek Harness 的 TencentDB Agent Memory 移植:L0 对话捕获 → L1 结构化记忆提取 → L2 场景/L3 画像,自动召回注入 + 记忆/对话搜索工具;复用现有 ~/.memory-tencentdb/memory-tdai 数据;附 Web UI 设置栏。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|