dsh-talk-map 0.1.88 → 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 +105 -76
  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": "b88 · 搜地图上的卡片(标题/正文)",
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": "b88 · 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 }],
@@ -13885,6 +13887,28 @@ function StackNode(props) {
13885
13887
 
13886
13888
  // src/client/StatusRail.tsx
13887
13889
  var import_react11 = require("react");
13890
+
13891
+ // src/client/queue-order.ts
13892
+ function queueRank(lamp, draft) {
13893
+ if (lamp === "error") return 0;
13894
+ if (lamp === "waiting") return 1;
13895
+ if (lamp === "done") return 2;
13896
+ if (lamp === "running") return 3;
13897
+ return draft ? 4 : 5;
13898
+ }
13899
+ function compareQueueRows(a, b) {
13900
+ const byRank = queueRank(a.lamp, a.draft === true) - queueRank(b.lamp, b.draft === true);
13901
+ if (byRank !== 0) return byRank;
13902
+ const aIndex = a.manualIndex ?? Number.MAX_SAFE_INTEGER;
13903
+ const bIndex = b.manualIndex ?? Number.MAX_SAFE_INTEGER;
13904
+ if (aIndex !== bIndex) return aIndex - bIndex;
13905
+ return (b.updatedAt ?? 0) - (a.updatedAt ?? 0);
13906
+ }
13907
+ function sortQueueRows(rows) {
13908
+ return [...rows].sort(compareQueueRows);
13909
+ }
13910
+
13911
+ // src/client/StatusRail.tsx
13888
13912
  var import_jsx_runtime15 = require("react/jsx-runtime");
13889
13913
  var OPEN_KEY = "dsh.talk-map.status-rail.open.v1";
13890
13914
  var ORDER_KEY = "dsh.talk-map.status-rail.order.v1";
@@ -13987,17 +14011,14 @@ function StatusRail(props) {
13987
14011
  }
13988
14012
  }, [signature]);
13989
14013
  const ordered = (0, import_react11.useMemo)(() => {
13990
- const byId2 = new Map(props.entries.map((entry) => [entry.cardId, entry]));
13991
- const rows = [];
13992
- for (const cardId of order) {
13993
- const entry = byId2.get(cardId);
13994
- if (entry !== void 0 && entry.lamp !== void 0) rows.push(entry);
13995
- }
13996
- for (const entry of props.entries) {
13997
- if (entry.lamp !== void 0 && !order.includes(entry.cardId)) rows.push(entry);
13998
- }
13999
- const drafts = props.entries.filter((entry) => entry.lamp === void 0).sort((a, b) => b.stamp - a.stamp);
14000
- return [...rows, ...drafts];
14014
+ const manualIndex = (cardId) => {
14015
+ const index2 = order.indexOf(cardId);
14016
+ return index2 < 0 ? Number.MAX_SAFE_INTEGER : index2;
14017
+ };
14018
+ return sortQueueRows(props.entries.map((entry) => ({
14019
+ ...entry,
14020
+ manualIndex: manualIndex(entry.cardId)
14021
+ })));
14001
14022
  }, [order, props.entries]);
14002
14023
  (0, import_react11.useLayoutEffect)(() => {
14003
14024
  if (drag !== null) return;
@@ -14256,10 +14277,12 @@ var lastActivitySeen = /* @__PURE__ */ new Map();
14256
14277
  function snap(value) {
14257
14278
  return Math.round(value / GRID) * GRID;
14258
14279
  }
14259
- function placeableSessionIds(sessions) {
14280
+ var IMPORT_CAP = 120;
14281
+ var PREVIEW_BATCH = 40;
14282
+ function placeableSessionIds(sessions, archived) {
14260
14283
  return sessions.ids.filter((id2) => {
14261
14284
  const summary = sessions.byId[id2];
14262
- return summary !== void 0 && !summary.blank && summary.origin !== "subagent";
14285
+ return summary !== void 0 && !summary.blank && summary.origin !== "subagent" && !(archived?.has(id2) ?? false);
14263
14286
  });
14264
14287
  }
14265
14288
  function sessionWorkspaceIndex(workspaces) {
@@ -14422,6 +14445,10 @@ function CanvasInner(props) {
14422
14445
  );
14423
14446
  const workspacesReady = workspaces.baselinesReady !== false;
14424
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
+ );
14425
14452
  const boardSessionIds = (0, import_react13.useMemo)(
14426
14453
  () => new Set(Object.values(canvasState.cards).map((card) => card.sessionId)),
14427
14454
  [canvasState.cards]
@@ -14451,10 +14478,11 @@ function CanvasInner(props) {
14451
14478
  const out = {};
14452
14479
  for (const [cardId, card] of Object.entries(canvasState.cards)) {
14453
14480
  if (sessions.byId[card.sessionId]?.blank === true) continue;
14481
+ if (archivedSessionIds.has(card.sessionId)) continue;
14454
14482
  out[cardId] = card;
14455
14483
  }
14456
14484
  return out;
14457
- }, [canvasState.cards, sessions]);
14485
+ }, [canvasState.cards, sessions, archivedSessionIds]);
14458
14486
  const previewInputs = (0, import_react13.useRef)({ cards: visibleCards, sessions });
14459
14487
  previewInputs.current = { cards: visibleCards, sessions };
14460
14488
  const previewTick = (0, import_react13.useRef)(() => {
@@ -14471,8 +14499,10 @@ function CanvasInner(props) {
14471
14499
  stamps.push([card.sessionId, stamp]);
14472
14500
  }
14473
14501
  if (pending.length === 0) return;
14474
- for (const [sessionId, stamp] of stamps) previewStamp.current.set(sessionId, stamp);
14475
- 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 }) => {
14476
14506
  const cleaned = {};
14477
14507
  for (const [sessionId, text] of Object.entries(texts)) {
14478
14508
  const value = cleanPreviewText(text).slice(0, 240);
@@ -14615,7 +14645,7 @@ function CanvasInner(props) {
14615
14645
  const remembered = canvasState.global?.layoutMemory ?? {};
14616
14646
  const framed = new Set(Object.keys(wsFrames));
14617
14647
  const newcomers = /* @__PURE__ */ new Map();
14618
- for (const sessionId of placeableSessionIds(sessions)) {
14648
+ for (const sessionId of placeableSessionIds(sessions, archivedSessionIds)) {
14619
14649
  const groupId = sessionWs.get(sessionId);
14620
14650
  if (groupId === void 0 || framed.has(groupId) || boardSessionIds.has(sessionId)) continue;
14621
14651
  newcomers.set(groupId, [...newcomers.get(groupId) ?? [], sessionId]);
@@ -14646,7 +14676,7 @@ function CanvasInner(props) {
14646
14676
  const rect = frameRects[groupId];
14647
14677
  if (rect === void 0) continue;
14648
14678
  const existing = (membersByGroup.get(groupId) ?? []).map((cardId) => canvasState.cards[cardId]).filter((card) => card !== void 0);
14649
- 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));
14650
14680
  if (missing.length === 0) continue;
14651
14681
  const pitchY = CARD_H + GAP_Y;
14652
14682
  const topY = existing.length === 0 ? rect.y + FRAME_PAD + FRAME_LABEL_H : Math.min(...existing.map((card) => card.y));
@@ -15623,7 +15653,9 @@ function CanvasInner(props) {
15623
15653
  };
15624
15654
  const folderAt = (flowX, flowY) => groupAtPoint(flowX, flowY);
15625
15655
  const importWorkspace = (workspaceId, atX, atY) => {
15626
- 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;
15627
15659
  const memory = canvasState.global?.layoutMemory ?? {};
15628
15660
  const remembered = memberSessions.filter((id2) => memory[id2] !== void 0);
15629
15661
  const fresh = memberSessions.filter((id2) => memory[id2] === void 0);
@@ -15658,6 +15690,9 @@ function CanvasInner(props) {
15658
15690
  if (placed.length > 0) canvas.addCards(added);
15659
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 };
15660
15692
  canvas.setWsFrameRect(workspaceId, rect);
15693
+ if (skipped > 0) {
15694
+ showToast(t("toast.importCapped", { n: String(placed.length), more: String(skipped) }));
15695
+ }
15661
15696
  };
15662
15697
  const importSession = (sessionId, atX, atY) => {
15663
15698
  canvas.addCards({
@@ -15673,7 +15708,7 @@ function CanvasInner(props) {
15673
15708
  const syncGroup = (groupId) => {
15674
15709
  const rect = frameRects[groupId] ?? wsFrames[groupId];
15675
15710
  if (rect === void 0) return;
15676
- 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);
15677
15712
  if (fresh.length === 0) return;
15678
15713
  const members = (membersByGroup.get(groupId) ?? []).map((id2) => canvasState.cards[id2]).filter((card) => card !== void 0);
15679
15714
  const pitchY = CARD_H + GAP_Y;
@@ -15773,7 +15808,7 @@ function CanvasInner(props) {
15773
15808
  if (services2 === void 0 || parentDir === "") throw new Error("no workspace root available");
15774
15809
  const path = `${parentDir}/${value}`;
15775
15810
  await talkMapApi.ensureDir(path);
15776
- const created = await callRpc2("workspace/create", { path });
15811
+ const created = await callRpc("workspace/create", { path });
15777
15812
  importWorkspace(created.workspace.workspaceId, menu.flowX, menu.flowY);
15778
15813
  close();
15779
15814
  }
@@ -15805,7 +15840,7 @@ function CanvasInner(props) {
15805
15840
  }
15806
15841
  } else if (menu.view === "import-session") {
15807
15842
  title = t("menu.importSession");
15808
- 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);
15809
15844
  for (const sessionId of candidates) {
15810
15845
  items.push({
15811
15846
  key: sessionId,
@@ -16575,13 +16610,7 @@ function SidebarQueue() {
16575
16610
  ...summary?.updatedAt !== void 0 ? { updatedAt: summary.updatedAt } : {}
16576
16611
  });
16577
16612
  }
16578
- out.sort((a, b) => {
16579
- const aDraft = a.draft === true ? 1 : 0;
16580
- const bDraft = b.draft === true ? 1 : 0;
16581
- if (aDraft !== bDraft) return aDraft - bDraft;
16582
- return (b.updatedAt ?? 0) - (a.updatedAt ?? 0);
16583
- });
16584
- return out;
16613
+ return sortQueueRows(out);
16585
16614
  }, [canvasState.cards, sessions, statusById, alerts2, finished2, drafts, opened]);
16586
16615
  (0, import_react18.useEffect)(() => {
16587
16616
  const wanted = rows.slice(0, PREVIEW_LIMIT).map((row) => row.sessionId).filter((id2) => !askedRef.current.has(id2));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-talk-map",
3
- "version": "0.1.88",
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",