dsh-talk-map 0.1.89 → 0.1.90

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.
Files changed (2) hide show
  1. package/client/client.js +74 -58
  2. package/package.json +1 -1
package/client/client.js CHANGED
@@ -351,6 +351,7 @@ var zh = {
351
351
  "confirm.removeGroup.okHard": "直接删除",
352
352
  "confirm.cancel": "取消",
353
353
  "toast.workspaceTrashed": "已把 {n} 个会话移入回收站,分组已从地图移除",
354
+ "toast.importCapped": "已放入 {n} 张卡片,另有 {more} 个会话留到下次导入或同步",
354
355
  "toast.workspaceDeleted": "已直接删除 {n} 个会话,分组已从地图移除",
355
356
  "statusRail.open": "展开状态栏",
356
357
  "statusRail.close": "收起状态栏",
@@ -497,7 +498,7 @@ var zh = {
497
498
  "digest.empty": "这条对话还没有摘要,先刷新摘要再来看。",
498
499
  "digest.copy": "复制",
499
500
  "digest.close": "关闭",
500
- "global.searchPlaceholder": "b89 · 搜地图上的卡片(标题/正文)",
501
+ "global.searchPlaceholder": "b90 · 搜地图上的卡片(标题/正文)",
501
502
  "global.searchRun": "搜索",
502
503
  "global.searchTitle": "搜索地图",
503
504
  "font.group": "文字大小",
@@ -550,6 +551,7 @@ var en = {
550
551
  "confirm.removeGroup.okHard": "Delete for good",
551
552
  "confirm.cancel": "Cancel",
552
553
  "toast.workspaceTrashed": "Moved {n} conversations to the recycle bin; the group is off the map",
554
+ "toast.importCapped": "placed {n} cards; {more} sessions left for a later import or sync",
553
555
  "toast.workspaceDeleted": "Deleted {n} conversations outright; the group is off the map",
554
556
  "statusRail.open": "Open the status rail",
555
557
  "statusRail.close": "Close the status rail",
@@ -689,7 +691,7 @@ var en = {
689
691
  "menu.noGroup": "Remove from group (free card)",
690
692
  "menu.open": "Open conversation",
691
693
  "menu.markUnread": "Mark as unread",
692
- "global.searchPlaceholder": "b89 · Search cards on the map",
694
+ "global.searchPlaceholder": "b90 · Search cards on the map",
693
695
  "global.searchRun": "Search",
694
696
  "global.searchTitle": "Search the map",
695
697
  "font.group": "Text size",
@@ -11032,6 +11034,49 @@ function DigestDialog(props) {
11032
11034
  );
11033
11035
  }
11034
11036
 
11037
+ // src/client/rpc.ts
11038
+ async function callRpc(endpoint, request = {}) {
11039
+ const rpc = connectionService()?.rpc;
11040
+ if (rpc === void 0) throw new Error(t("spawn.apiUnavailable"));
11041
+ const controller = new AbortController();
11042
+ const result = await rpc.call("/api", endpoint, { args: { request } }, controller.signal);
11043
+ if (result.ok !== true) {
11044
+ const failure = result.error;
11045
+ throw new Error(`${endpoint}: ${failure?.message ?? failure?.code ?? "failed"}`);
11046
+ }
11047
+ return result.value;
11048
+ }
11049
+ function reportToHost(payload) {
11050
+ try {
11051
+ void fetch("/talk-map/client-boot", {
11052
+ method: "POST",
11053
+ headers: { "content-type": "application/json" },
11054
+ body: JSON.stringify({ at: (/* @__PURE__ */ new Date()).toISOString(), ...payload })
11055
+ }).catch(() => {
11056
+ });
11057
+ } catch {
11058
+ }
11059
+ }
11060
+ async function fetchSearchContext(sessionId, seq, query) {
11061
+ try {
11062
+ const page = await talkMapApi.searchContext(sessionId, seq, query);
11063
+ return Array.isArray(page.lines) ? page.lines.filter((line) => typeof line === "string" && line !== "") : [];
11064
+ } catch (error) {
11065
+ reportToHost({ phase: "search-context-failed", sessionId, seq, message: String(error?.message ?? error) });
11066
+ return [];
11067
+ }
11068
+ }
11069
+ async function fetchSessionHits(sessionId, query) {
11070
+ try {
11071
+ const page = await talkMapApi.searchSessionHits(sessionId, query);
11072
+ const blocks = (page.blocks ?? []).filter((block) => Array.isArray(block) && block.length > 0);
11073
+ return { blocks, seqs: blocks.map((_, index2) => typeof page.seqs?.[index2] === "number" ? page.seqs[index2] : null) };
11074
+ } catch (error) {
11075
+ reportToHost({ phase: "search-session-failed", sessionId, message: String(error?.message ?? error) });
11076
+ return { blocks: [], seqs: [] };
11077
+ }
11078
+ }
11079
+
11035
11080
  // src/client/session-actions.ts
11036
11081
  var RECYCLE_BIN_ROUTE = "dsh-session-recycle-bin/api";
11037
11082
  async function postRecycleBin(body) {
@@ -11185,49 +11230,6 @@ var drawerState = {
11185
11230
  }
11186
11231
  };
11187
11232
 
11188
- // src/client/rpc.ts
11189
- async function callRpc2(endpoint, request = {}) {
11190
- const rpc = connectionService()?.rpc;
11191
- if (rpc === void 0) throw new Error(t("spawn.apiUnavailable"));
11192
- const controller = new AbortController();
11193
- const result = await rpc.call("/api", endpoint, { args: { request } }, controller.signal);
11194
- if (result.ok !== true) {
11195
- const failure = result.error;
11196
- throw new Error(`${endpoint}: ${failure?.message ?? failure?.code ?? "failed"}`);
11197
- }
11198
- return result.value;
11199
- }
11200
- function reportToHost(payload) {
11201
- try {
11202
- void fetch("/talk-map/client-boot", {
11203
- method: "POST",
11204
- headers: { "content-type": "application/json" },
11205
- body: JSON.stringify({ at: (/* @__PURE__ */ new Date()).toISOString(), ...payload })
11206
- }).catch(() => {
11207
- });
11208
- } catch {
11209
- }
11210
- }
11211
- async function fetchSearchContext(sessionId, seq, query) {
11212
- try {
11213
- const page = await talkMapApi.searchContext(sessionId, seq, query);
11214
- return Array.isArray(page.lines) ? page.lines.filter((line) => typeof line === "string" && line !== "") : [];
11215
- } catch (error) {
11216
- reportToHost({ phase: "search-context-failed", sessionId, seq, message: String(error?.message ?? error) });
11217
- return [];
11218
- }
11219
- }
11220
- async function fetchSessionHits(sessionId, query) {
11221
- try {
11222
- const page = await talkMapApi.searchSessionHits(sessionId, query);
11223
- const blocks = (page.blocks ?? []).filter((block) => Array.isArray(block) && block.length > 0);
11224
- return { blocks, seqs: blocks.map((_, index2) => typeof page.seqs?.[index2] === "number" ? page.seqs[index2] : null) };
11225
- } catch (error) {
11226
- reportToHost({ phase: "search-session-failed", sessionId, message: String(error?.message ?? error) });
11227
- return { blocks: [], seqs: [] };
11228
- }
11229
- }
11230
-
11231
11233
  // src/client/state-persist.ts
11232
11234
  var STORAGE_KEY2 = "dsh.talk-map.lamp-state.v1";
11233
11235
  var MAX_AGE_MS = 14 * 24 * 60 * 60 * 1e3;
@@ -12890,7 +12892,7 @@ ${t("inject.contextNote")}`);
12890
12892
  setBusy(true);
12891
12893
  setError(void 0);
12892
12894
  try {
12893
- const createSession = async () => callRpc2(
12895
+ const createSession = async () => callRpc(
12894
12896
  "session/create",
12895
12897
  pending.parentWorkspaceId !== void 0 ? { workspaceId: pending.parentWorkspaceId } : {}
12896
12898
  );
@@ -12931,7 +12933,7 @@ ${t("inject.contextNote")}`);
12931
12933
  if (firstMessage.trim() === "") throw new Error(t("spawn.needFirstMessage"));
12932
12934
  const created = await createSession();
12933
12935
  addCardAndEdge(created.sessionId, "none");
12934
- await callRpc2("session/prompt", {
12936
+ await callRpc("session/prompt", {
12935
12937
  sessionId: created.sessionId,
12936
12938
  mode: "queue",
12937
12939
  content: [{ type: "text", text: firstMessage }],
@@ -14275,10 +14277,12 @@ var lastActivitySeen = /* @__PURE__ */ new Map();
14275
14277
  function snap(value) {
14276
14278
  return Math.round(value / GRID) * GRID;
14277
14279
  }
14278
- function placeableSessionIds(sessions) {
14280
+ var IMPORT_CAP = 120;
14281
+ var PREVIEW_BATCH = 40;
14282
+ function placeableSessionIds(sessions, archived) {
14279
14283
  return sessions.ids.filter((id2) => {
14280
14284
  const summary = sessions.byId[id2];
14281
- return summary !== void 0 && !summary.blank && summary.origin !== "subagent";
14285
+ return summary !== void 0 && !summary.blank && summary.origin !== "subagent" && !(archived?.has(id2) ?? false);
14282
14286
  });
14283
14287
  }
14284
14288
  function sessionWorkspaceIndex(workspaces) {
@@ -14441,6 +14445,10 @@ function CanvasInner(props) {
14441
14445
  );
14442
14446
  const workspacesReady = workspaces.baselinesReady !== false;
14443
14447
  const pinnedSessions = (0, import_react13.useMemo)(() => new Set(workspaces.pinnedSessionIds ?? []), [workspaces]);
14448
+ const archivedSessionIds = (0, import_react13.useMemo)(
14449
+ () => new Set(workspaces.archivedSessionIds ?? []),
14450
+ [workspaces]
14451
+ );
14444
14452
  const boardSessionIds = (0, import_react13.useMemo)(
14445
14453
  () => new Set(Object.values(canvasState.cards).map((card) => card.sessionId)),
14446
14454
  [canvasState.cards]
@@ -14470,10 +14478,11 @@ function CanvasInner(props) {
14470
14478
  const out = {};
14471
14479
  for (const [cardId, card] of Object.entries(canvasState.cards)) {
14472
14480
  if (sessions.byId[card.sessionId]?.blank === true) continue;
14481
+ if (archivedSessionIds.has(card.sessionId)) continue;
14473
14482
  out[cardId] = card;
14474
14483
  }
14475
14484
  return out;
14476
- }, [canvasState.cards, sessions]);
14485
+ }, [canvasState.cards, sessions, archivedSessionIds]);
14477
14486
  const previewInputs = (0, import_react13.useRef)({ cards: visibleCards, sessions });
14478
14487
  previewInputs.current = { cards: visibleCards, sessions };
14479
14488
  const previewTick = (0, import_react13.useRef)(() => {
@@ -14490,8 +14499,10 @@ function CanvasInner(props) {
14490
14499
  stamps.push([card.sessionId, stamp]);
14491
14500
  }
14492
14501
  if (pending.length === 0) return;
14493
- for (const [sessionId, stamp] of stamps) previewStamp.current.set(sessionId, stamp);
14494
- void talkMapApi.lastUserMessages(pending).then(({ texts }) => {
14502
+ const batch = pending.slice(0, PREVIEW_BATCH);
14503
+ const batchStamps = stamps.slice(0, PREVIEW_BATCH);
14504
+ for (const [sessionId, stamp] of batchStamps) previewStamp.current.set(sessionId, stamp);
14505
+ void talkMapApi.lastUserMessages(batch).then(({ texts }) => {
14495
14506
  const cleaned = {};
14496
14507
  for (const [sessionId, text] of Object.entries(texts)) {
14497
14508
  const value = cleanPreviewText(text).slice(0, 240);
@@ -14634,7 +14645,7 @@ function CanvasInner(props) {
14634
14645
  const remembered = canvasState.global?.layoutMemory ?? {};
14635
14646
  const framed = new Set(Object.keys(wsFrames));
14636
14647
  const newcomers = /* @__PURE__ */ new Map();
14637
- for (const sessionId of placeableSessionIds(sessions)) {
14648
+ for (const sessionId of placeableSessionIds(sessions, archivedSessionIds)) {
14638
14649
  const groupId = sessionWs.get(sessionId);
14639
14650
  if (groupId === void 0 || framed.has(groupId) || boardSessionIds.has(sessionId)) continue;
14640
14651
  newcomers.set(groupId, [...newcomers.get(groupId) ?? [], sessionId]);
@@ -14665,7 +14676,7 @@ function CanvasInner(props) {
14665
14676
  const rect = frameRects[groupId];
14666
14677
  if (rect === void 0) continue;
14667
14678
  const existing = (membersByGroup.get(groupId) ?? []).map((cardId) => canvasState.cards[cardId]).filter((card) => card !== void 0);
14668
- const missing = placeableSessionIds(sessions).filter((id2) => sessionWs.get(id2) === groupId && !boardSessionIds.has(id2)).sort((a, b) => (sessions.byId[b]?.updatedAt ?? 0) - (sessions.byId[a]?.updatedAt ?? 0));
14679
+ const missing = placeableSessionIds(sessions, archivedSessionIds).filter((id2) => sessionWs.get(id2) === groupId && !boardSessionIds.has(id2)).sort((a, b) => (sessions.byId[b]?.updatedAt ?? 0) - (sessions.byId[a]?.updatedAt ?? 0));
14669
14680
  if (missing.length === 0) continue;
14670
14681
  const pitchY = CARD_H + GAP_Y;
14671
14682
  const topY = existing.length === 0 ? rect.y + FRAME_PAD + FRAME_LABEL_H : Math.min(...existing.map((card) => card.y));
@@ -15642,7 +15653,9 @@ function CanvasInner(props) {
15642
15653
  };
15643
15654
  const folderAt = (flowX, flowY) => groupAtPoint(flowX, flowY);
15644
15655
  const importWorkspace = (workspaceId, atX, atY) => {
15645
- const memberSessions = placeableSessionIds(sessions).filter((id2) => sessionWs.get(id2) === workspaceId && !boardSessionIds.has(id2)).sort((a, b) => (sessions.byId[b]?.updatedAt ?? 0) - (sessions.byId[a]?.updatedAt ?? 0));
15656
+ const allMembers = placeableSessionIds(sessions, archivedSessionIds).filter((id2) => sessionWs.get(id2) === workspaceId && !boardSessionIds.has(id2)).sort((a, b) => (sessions.byId[b]?.updatedAt ?? 0) - (sessions.byId[a]?.updatedAt ?? 0));
15657
+ const memberSessions = allMembers.slice(0, IMPORT_CAP);
15658
+ const skipped = allMembers.length - memberSessions.length;
15646
15659
  const memory = canvasState.global?.layoutMemory ?? {};
15647
15660
  const remembered = memberSessions.filter((id2) => memory[id2] !== void 0);
15648
15661
  const fresh = memberSessions.filter((id2) => memory[id2] === void 0);
@@ -15677,6 +15690,9 @@ function CanvasInner(props) {
15677
15690
  if (placed.length > 0) canvas.addCards(added);
15678
15691
  const rect = placed.length > 0 ? fitRect(placed) : { x: snap(atX) - FRAME_PAD, y: snap(atY) - FRAME_PAD - FRAME_LABEL_H, width: 400, height: 260 };
15679
15692
  canvas.setWsFrameRect(workspaceId, rect);
15693
+ if (skipped > 0) {
15694
+ showToast(t("toast.importCapped", { n: String(placed.length), more: String(skipped) }));
15695
+ }
15680
15696
  };
15681
15697
  const importSession = (sessionId, atX, atY) => {
15682
15698
  canvas.addCards({
@@ -15692,7 +15708,7 @@ function CanvasInner(props) {
15692
15708
  const syncGroup = (groupId) => {
15693
15709
  const rect = frameRects[groupId] ?? wsFrames[groupId];
15694
15710
  if (rect === void 0) return;
15695
- const fresh = placeableSessionIds(sessions).filter((id2) => sessionWs.get(id2) === groupId && !boardSessionIds.has(id2)).sort((a, b) => (sessions.byId[b]?.updatedAt ?? 0) - (sessions.byId[a]?.updatedAt ?? 0));
15711
+ const fresh = placeableSessionIds(sessions, archivedSessionIds).filter((id2) => sessionWs.get(id2) === groupId && !boardSessionIds.has(id2)).sort((a, b) => (sessions.byId[b]?.updatedAt ?? 0) - (sessions.byId[a]?.updatedAt ?? 0)).slice(0, IMPORT_CAP);
15696
15712
  if (fresh.length === 0) return;
15697
15713
  const members = (membersByGroup.get(groupId) ?? []).map((id2) => canvasState.cards[id2]).filter((card) => card !== void 0);
15698
15714
  const pitchY = CARD_H + GAP_Y;
@@ -15792,7 +15808,7 @@ function CanvasInner(props) {
15792
15808
  if (services2 === void 0 || parentDir === "") throw new Error("no workspace root available");
15793
15809
  const path = `${parentDir}/${value}`;
15794
15810
  await talkMapApi.ensureDir(path);
15795
- const created = await callRpc2("workspace/create", { path });
15811
+ const created = await callRpc("workspace/create", { path });
15796
15812
  importWorkspace(created.workspace.workspaceId, menu.flowX, menu.flowY);
15797
15813
  close();
15798
15814
  }
@@ -15824,7 +15840,7 @@ function CanvasInner(props) {
15824
15840
  }
15825
15841
  } else if (menu.view === "import-session") {
15826
15842
  title = t("menu.importSession");
15827
- const candidates = placeableSessionIds(sessions).filter((id2) => !boardSessionIds.has(id2)).slice(0, 200);
15843
+ const candidates = placeableSessionIds(sessions, archivedSessionIds).filter((id2) => !boardSessionIds.has(id2)).slice(0, 200);
15828
15844
  for (const sessionId of candidates) {
15829
15845
  items.push({
15830
15846
  key: sessionId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-talk-map",
3
- "version": "0.1.89",
3
+ "version": "0.1.90",
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",