dsh-talk-map 0.1.93 → 0.1.95
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/client.js +27 -14
- package/lib/index.js +75 -5
- package/package.json +1 -1
package/client/client.js
CHANGED
|
@@ -276,8 +276,8 @@ var talkMapApi = {
|
|
|
276
276
|
* The last message the USER sent, per session — what the card body shows now
|
|
277
277
|
* that the LLM summary is gone. Read straight off the Host's session surface.
|
|
278
278
|
*/
|
|
279
|
-
lastUserMessages(
|
|
280
|
-
return postJson("/talk-map/last-user", { sessionIds });
|
|
279
|
+
lastUserMessages(ids) {
|
|
280
|
+
return postJson("/talk-map/last-user", { sessionIds: ids });
|
|
281
281
|
},
|
|
282
282
|
/**
|
|
283
283
|
* The live window: what the model is given right now, minus everything compaction
|
|
@@ -498,7 +498,7 @@ var zh = {
|
|
|
498
498
|
"digest.empty": "这条对话还没有摘要,先刷新摘要再来看。",
|
|
499
499
|
"digest.copy": "复制",
|
|
500
500
|
"digest.close": "关闭",
|
|
501
|
-
"global.searchPlaceholder": "
|
|
501
|
+
"global.searchPlaceholder": "b95 · 搜地图上的卡片(标题/正文)",
|
|
502
502
|
"global.searchRun": "搜索",
|
|
503
503
|
"global.searchTitle": "搜索地图",
|
|
504
504
|
"font.group": "文字大小",
|
|
@@ -691,7 +691,7 @@ var en = {
|
|
|
691
691
|
"menu.noGroup": "Remove from group (free card)",
|
|
692
692
|
"menu.open": "Open conversation",
|
|
693
693
|
"menu.markUnread": "Mark as unread",
|
|
694
|
-
"global.searchPlaceholder": "
|
|
694
|
+
"global.searchPlaceholder": "b95 · Search cards on the map",
|
|
695
695
|
"global.searchRun": "Search",
|
|
696
696
|
"global.searchTitle": "Search the map",
|
|
697
697
|
"font.group": "Text size",
|
|
@@ -11552,6 +11552,9 @@ var sessionActivity = {
|
|
|
11552
11552
|
|
|
11553
11553
|
// src/client/draft-watch.ts
|
|
11554
11554
|
var STORE_PREFIX = "dsh.conversation.";
|
|
11555
|
+
function draftMayBeEmpty(raw) {
|
|
11556
|
+
return raw.includes('"draft":""') || raw.includes('"draft":{}') || !raw.includes('"draft"');
|
|
11557
|
+
}
|
|
11555
11558
|
function draftTextOf(value) {
|
|
11556
11559
|
if (typeof value === "string") return value;
|
|
11557
11560
|
if (value !== null && typeof value === "object") {
|
|
@@ -11591,6 +11594,8 @@ function readDraftTexts() {
|
|
|
11591
11594
|
if (key === null || !key.startsWith(STORE_PREFIX)) continue;
|
|
11592
11595
|
const sessionId = key.slice(STORE_PREFIX.length);
|
|
11593
11596
|
if (sessionId === "") continue;
|
|
11597
|
+
const raw = localStorage.getItem(key);
|
|
11598
|
+
if (raw === null || draftMayBeEmpty(raw)) continue;
|
|
11594
11599
|
const text = readDraftText(sessionId);
|
|
11595
11600
|
if (text.trim() !== "") out[sessionId] = text;
|
|
11596
11601
|
}
|
|
@@ -11606,7 +11611,7 @@ function readDraftSessions() {
|
|
|
11606
11611
|
if (sessionId === "") continue;
|
|
11607
11612
|
try {
|
|
11608
11613
|
const raw = localStorage.getItem(key);
|
|
11609
|
-
if (raw === null) continue;
|
|
11614
|
+
if (raw === null || draftMayBeEmpty(raw)) continue;
|
|
11610
11615
|
const stored = JSON.parse(raw);
|
|
11611
11616
|
const draft = stored !== null && typeof stored === "object" ? stored.draft : void 0;
|
|
11612
11617
|
if (draftTextOf(draft).trim() !== "") out.add(sessionId);
|
|
@@ -14156,7 +14161,8 @@ function StatusRail(props) {
|
|
|
14156
14161
|
entry.preview !== void 0 && entry.preview !== "" ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: talk_map_default["cardSummary"], children: entry.preview }) : null,
|
|
14157
14162
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: talk_map_default["cardFooter"], children: [
|
|
14158
14163
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: talk_map_default["cardTime"], children: relativeTime(entry.updatedAt) }),
|
|
14159
|
-
entry.
|
|
14164
|
+
entry.draft === true ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: `${talk_map_default["cardChip"]} ${talk_map_default["cardChipDraft"]}`, children: t("card.draft") }) : null,
|
|
14165
|
+
entry.lamp === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { className: `${talk_map_default["cardChip"]} ${talk_map_default[LAMP_CHIP[entry.lamp].className]}`, children: [
|
|
14160
14166
|
LAMP_CHIP[entry.lamp].dot ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: talk_map_default["runningDot"] }) : null,
|
|
14161
14167
|
t(LAMP_CHIP[entry.lamp].key)
|
|
14162
14168
|
] })
|
|
@@ -14278,7 +14284,7 @@ function snap(value) {
|
|
|
14278
14284
|
return Math.round(value / GRID) * GRID;
|
|
14279
14285
|
}
|
|
14280
14286
|
var IMPORT_CAP = 120;
|
|
14281
|
-
var PREVIEW_BATCH =
|
|
14287
|
+
var PREVIEW_BATCH = 8;
|
|
14282
14288
|
function placeableSessionIds(sessions, archived) {
|
|
14283
14289
|
return sessions.ids.filter((id2) => {
|
|
14284
14290
|
const summary = sessions.byId[id2];
|
|
@@ -14489,6 +14495,7 @@ function CanvasInner(props) {
|
|
|
14489
14495
|
});
|
|
14490
14496
|
(0, import_react13.useEffect)(() => {
|
|
14491
14497
|
const tick = () => {
|
|
14498
|
+
if (typeof document !== "undefined" && document.hidden) return;
|
|
14492
14499
|
const { cards, sessions: latest } = previewInputs.current;
|
|
14493
14500
|
const pending = [];
|
|
14494
14501
|
const stamps = [];
|
|
@@ -14499,10 +14506,11 @@ function CanvasInner(props) {
|
|
|
14499
14506
|
stamps.push([card.sessionId, stamp]);
|
|
14500
14507
|
}
|
|
14501
14508
|
if (pending.length === 0) return;
|
|
14502
|
-
|
|
14509
|
+
stamps.sort((a, b) => b[1] - a[1]);
|
|
14503
14510
|
const batchStamps = stamps.slice(0, PREVIEW_BATCH);
|
|
14511
|
+
const batch = batchStamps.map(([id2]) => id2);
|
|
14504
14512
|
for (const [sessionId, stamp] of batchStamps) previewStamp.current.set(sessionId, stamp);
|
|
14505
|
-
void talkMapApi.lastUserMessages(
|
|
14513
|
+
void talkMapApi.lastUserMessages(batchStamps.map(([id2, stamp]) => ({ id: id2, stamp }))).then(({ texts }) => {
|
|
14506
14514
|
const cleaned = {};
|
|
14507
14515
|
for (const [sessionId, text] of Object.entries(texts)) {
|
|
14508
14516
|
const value = cleanPreviewText(text).slice(0, 240);
|
|
@@ -14903,6 +14911,8 @@ function CanvasInner(props) {
|
|
|
14903
14911
|
sessionId: card.sessionId,
|
|
14904
14912
|
title: renamedTitles[card.sessionId] ?? summary?.displayTitle ?? card.sessionId,
|
|
14905
14913
|
lamp,
|
|
14914
|
+
// A lamped card can still hold unsent text: the footer shows both chips.
|
|
14915
|
+
...(draftTexts[card.sessionId] ?? "").trim() !== "" ? { draft: true } : {},
|
|
14906
14916
|
stamp: summary?.updatedAt ?? 0,
|
|
14907
14917
|
...summary?.updatedAt !== void 0 ? { updatedAt: summary.updatedAt } : {},
|
|
14908
14918
|
...previews[card.sessionId] !== void 0 ? { preview: previews[card.sessionId] } : {},
|
|
@@ -16554,6 +16564,7 @@ function SidebarQueue() {
|
|
|
16554
16564
|
const askedRef = (0, import_react18.useRef)(/* @__PURE__ */ new Set());
|
|
16555
16565
|
(0, import_react18.useEffect)(() => {
|
|
16556
16566
|
const timer4 = setInterval(() => {
|
|
16567
|
+
if (typeof document !== "undefined" && document.hidden) return;
|
|
16557
16568
|
setDrafts(readDraftTexts());
|
|
16558
16569
|
}, 1500);
|
|
16559
16570
|
return () => {
|
|
@@ -16625,6 +16636,7 @@ function SidebarQueue() {
|
|
|
16625
16636
|
sessionId,
|
|
16626
16637
|
title: summary.displayTitle ?? sessionId,
|
|
16627
16638
|
...draftOnly ? { draft: true } : { lamp },
|
|
16639
|
+
...hasDraft ? { draft: true } : {},
|
|
16628
16640
|
...draftText !== void 0 ? { draftText } : {},
|
|
16629
16641
|
...summary.updatedAt !== void 0 ? { updatedAt: summary.updatedAt } : {}
|
|
16630
16642
|
});
|
|
@@ -16632,9 +16644,9 @@ function SidebarQueue() {
|
|
|
16632
16644
|
return sortQueueRows(out);
|
|
16633
16645
|
}, [canvasState.cards, sessions, statusById, alerts2, finished2, drafts, opened, archivedSessionIds]);
|
|
16634
16646
|
(0, import_react18.useEffect)(() => {
|
|
16635
|
-
const wanted = rows.slice(0, PREVIEW_LIMIT).
|
|
16647
|
+
const wanted = rows.slice(0, PREVIEW_LIMIT).filter((row) => !askedRef.current.has(row.sessionId)).map((row) => ({ id: row.sessionId, stamp: row.updatedAt ?? 0 }));
|
|
16636
16648
|
if (wanted.length === 0) return;
|
|
16637
|
-
for (const
|
|
16649
|
+
for (const item of wanted) askedRef.current.add(item.id);
|
|
16638
16650
|
void talkMapApi.lastUserMessages(wanted).then((page) => {
|
|
16639
16651
|
setPreviews((current) => {
|
|
16640
16652
|
const next = { ...current };
|
|
@@ -16729,9 +16741,10 @@ function SidebarQueue() {
|
|
|
16729
16741
|
body !== void 0 && body.trim() !== "" ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: talk_map_default["cardSummary"], children: body }) : null,
|
|
16730
16742
|
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: talk_map_default["cardFooter"], children: [
|
|
16731
16743
|
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: talk_map_default["cardTime"], children: relativeTime(row.updatedAt) }),
|
|
16732
|
-
|
|
16733
|
-
|
|
16734
|
-
|
|
16744
|
+
row.draft === true ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: `${talk_map_default["cardChip"]} ${talk_map_default["cardChipDraft"]}`, children: t("card.draft") }) : null,
|
|
16745
|
+
row.lamp === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { className: `${talk_map_default["cardChip"]} ${talk_map_default[LAMP_CHIP[row.lamp].className]}`, children: [
|
|
16746
|
+
LAMP_CHIP[row.lamp].dot ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: talk_map_default["runningDot"] }) : null,
|
|
16747
|
+
t(LAMP_CHIP[row.lamp].key)
|
|
16735
16748
|
] })
|
|
16736
16749
|
] })
|
|
16737
16750
|
]
|
package/lib/index.js
CHANGED
|
@@ -252,6 +252,49 @@ var DigestPipeline = class {
|
|
|
252
252
|
return text;
|
|
253
253
|
}
|
|
254
254
|
};
|
|
255
|
+
// src/host/preview.ts
|
|
256
|
+
/**
|
|
257
|
+
* Run `task` over `items` with at most `limit` in flight. Awaiting is sequential per worker,
|
|
258
|
+
* so peak memory stays around `limit` surfaces instead of `items.length`.
|
|
259
|
+
*/
|
|
260
|
+
async function runLimited(items, limit, task) {
|
|
261
|
+
const width = Math.max(1, Math.min(limit, items.length));
|
|
262
|
+
let cursor = 0;
|
|
263
|
+
const worker = async () => {
|
|
264
|
+
for (;;) {
|
|
265
|
+
const index = cursor;
|
|
266
|
+
cursor += 1;
|
|
267
|
+
if (index >= items.length) return;
|
|
268
|
+
await task(items[index]);
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
await Promise.all(Array.from({ length: width }, worker));
|
|
272
|
+
}
|
|
273
|
+
/** Insertion-ordered map used as an LRU: re-setting a key moves it to the end. */
|
|
274
|
+
function createPreviewCache(max) {
|
|
275
|
+
const store = /* @__PURE__ */ new Map();
|
|
276
|
+
return {
|
|
277
|
+
get(id) {
|
|
278
|
+
const hit = store.get(id);
|
|
279
|
+
if (hit === void 0) return void 0;
|
|
280
|
+
store.delete(id);
|
|
281
|
+
store.set(id, hit);
|
|
282
|
+
return hit;
|
|
283
|
+
},
|
|
284
|
+
set(id, entry) {
|
|
285
|
+
store.delete(id);
|
|
286
|
+
store.set(id, entry);
|
|
287
|
+
while (store.size > max) {
|
|
288
|
+
const oldest = store.keys().next();
|
|
289
|
+
if (oldest.done === true) break;
|
|
290
|
+
store.delete(oldest.value);
|
|
291
|
+
}
|
|
292
|
+
},
|
|
293
|
+
get size() {
|
|
294
|
+
return store.size;
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
}
|
|
255
298
|
// src/host/spawn.ts
|
|
256
299
|
/** Typed so the HTTP layer can answer with a structured code instead of
|
|
257
300
|
* clients substring-matching a stringified error. */
|
|
@@ -840,14 +883,36 @@ function mountTalkMapRoutes(services, storeReady, runtime) {
|
|
|
840
883
|
}
|
|
841
884
|
return;
|
|
842
885
|
}
|
|
886
|
+
const previewCache = createPreviewCache(400);
|
|
843
887
|
if (route === "POST /talk-map/last-user") {
|
|
844
888
|
const body = await readJsonBody(request);
|
|
845
|
-
const
|
|
889
|
+
const listed = Array.isArray(body.sessionIds) ? body.sessionIds : [];
|
|
890
|
+
const wanted = [];
|
|
891
|
+
for (const entry of listed) {
|
|
892
|
+
if (typeof entry === "string") {
|
|
893
|
+
wanted.push({ id: entry });
|
|
894
|
+
continue;
|
|
895
|
+
}
|
|
896
|
+
if (entry === null || typeof entry !== "object") continue;
|
|
897
|
+
const id = entry.id;
|
|
898
|
+
if (typeof id !== "string") continue;
|
|
899
|
+
const stamp = entry.stamp;
|
|
900
|
+
wanted.push(typeof stamp === "number" ? {
|
|
901
|
+
id,
|
|
902
|
+
stamp
|
|
903
|
+
} : { id });
|
|
904
|
+
}
|
|
846
905
|
const texts = {};
|
|
847
906
|
const query = runtime.sessionQuery;
|
|
848
|
-
if (query !== void 0) await
|
|
907
|
+
if (query !== void 0) await runLimited(wanted.filter((item) => {
|
|
908
|
+
if (item.stamp === void 0) return true;
|
|
909
|
+
const cached = previewCache.get(item.id);
|
|
910
|
+
if (cached === void 0 || cached.stamp !== item.stamp) return true;
|
|
911
|
+
texts[item.id] = cached.text;
|
|
912
|
+
return false;
|
|
913
|
+
}), 3, async (item) => {
|
|
849
914
|
try {
|
|
850
|
-
const surface = await query.readSurface(
|
|
915
|
+
const surface = await query.readSurface(item.id);
|
|
851
916
|
let text = "";
|
|
852
917
|
for (const raw of surface.events) {
|
|
853
918
|
const event = raw;
|
|
@@ -856,9 +921,14 @@ function mountTalkMapRoutes(services, storeReady, runtime) {
|
|
|
856
921
|
const body = textOfBlocks(event.data?.content);
|
|
857
922
|
if (body !== "") text = body;
|
|
858
923
|
}
|
|
859
|
-
|
|
924
|
+
const trimmed = text.length > 240 ? text.slice(0, 240) : text;
|
|
925
|
+
if (item.stamp !== void 0) previewCache.set(item.id, {
|
|
926
|
+
stamp: item.stamp,
|
|
927
|
+
text: trimmed
|
|
928
|
+
});
|
|
929
|
+
if (trimmed !== "") texts[item.id] = trimmed;
|
|
860
930
|
} catch {}
|
|
861
|
-
})
|
|
931
|
+
});
|
|
862
932
|
sendJson(response, 200, { texts });
|
|
863
933
|
return;
|
|
864
934
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-talk-map",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.95",
|
|
4
4
|
"description": "Visual conversation map for DeepSeek Harness: an infinite whiteboard where every session is a card — drag to arrange, double-click to start a chat in place, draw an edge to fork a new session with injected context. Built for ADHD-friendly spatial memory. · DSH 可视化对话地图:会话即卡片,双击即聊,连线分叉带上下文的新对话。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|