dsh-talk-map 0.1.4 → 0.1.6

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 +456 -141
  2. package/package.json +1 -1
package/client/client.js CHANGED
@@ -1245,7 +1245,7 @@ function allCards() {
1245
1245
  }
1246
1246
 
1247
1247
  // src/client/MapOverlay.tsx
1248
- var import_react15 = require("react");
1248
+ var import_react14 = require("react");
1249
1249
 
1250
1250
  // src/client/font-scale.ts
1251
1251
  var STORAGE_KEY = "dsh.talk-map.font-step";
@@ -1651,7 +1651,7 @@ function GlobalSearch(props) {
1651
1651
  }
1652
1652
 
1653
1653
  // src/client/MapCanvas.tsx
1654
- var import_react13 = require("react");
1654
+ var import_react12 = require("react");
1655
1655
 
1656
1656
  // node_modules/@xyflow/react/dist/esm/index.js
1657
1657
  var import_jsx_runtime4 = require("react/jsx-runtime");
@@ -11008,7 +11008,7 @@ async function trashSessions(sessionIds, onStopping) {
11008
11008
  onStopping?.();
11009
11009
  await stopWork(ids);
11010
11010
  let last = error;
11011
- for (let round = 0; round < STOP_RETRIES; round += 1) {
11011
+ for (let round2 = 0; round2 < STOP_RETRIES; round2 += 1) {
11012
11012
  await new Promise((resolve) => setTimeout(resolve, STOP_RETRY_DELAY_MS));
11013
11013
  try {
11014
11014
  return await attempt();
@@ -11738,13 +11738,323 @@ function ContextMenu(props) {
11738
11738
  );
11739
11739
  }
11740
11740
 
11741
+ // src/client/edge-route.ts
11742
+ var DEFAULTS = { margin: 10, stub: 14, minCorridor: 28 };
11743
+ function anchorOf(rect, face) {
11744
+ switch (face) {
11745
+ case "r":
11746
+ return { x: rect.x + rect.w, y: rect.y + rect.h / 2 };
11747
+ case "l":
11748
+ return { x: rect.x, y: rect.y + rect.h / 2 };
11749
+ case "t":
11750
+ return { x: rect.x + rect.w / 2, y: rect.y };
11751
+ default:
11752
+ return { x: rect.x + rect.w / 2, y: rect.y + rect.h };
11753
+ }
11754
+ }
11755
+ function normalOf(face) {
11756
+ switch (face) {
11757
+ case "r":
11758
+ return { x: 1, y: 0 };
11759
+ case "l":
11760
+ return { x: -1, y: 0 };
11761
+ case "t":
11762
+ return { x: 0, y: -1 };
11763
+ default:
11764
+ return { x: 0, y: 1 };
11765
+ }
11766
+ }
11767
+ function expand(rect, by) {
11768
+ return { x: rect.x - by, y: rect.y - by, w: rect.w + by * 2, h: rect.h + by * 2 };
11769
+ }
11770
+ function insideStrict(rect, point) {
11771
+ return point.x > rect.x && point.x < rect.x + rect.w && point.y > rect.y && point.y < rect.y + rect.h;
11772
+ }
11773
+ function hitsHorizontal(rects, y, x1, x2) {
11774
+ const lo = Math.min(x1, x2);
11775
+ const hi = Math.max(x1, x2);
11776
+ for (const rect of rects) {
11777
+ if (y <= rect.y || y >= rect.y + rect.h) continue;
11778
+ if (hi <= rect.x || lo >= rect.x + rect.w) continue;
11779
+ return true;
11780
+ }
11781
+ return false;
11782
+ }
11783
+ function hitsVertical(rects, x, y1, y2) {
11784
+ const lo = Math.min(y1, y2);
11785
+ const hi = Math.max(y1, y2);
11786
+ for (const rect of rects) {
11787
+ if (x <= rect.x || x >= rect.x + rect.w) continue;
11788
+ if (hi <= rect.y || lo >= rect.y + rect.h) continue;
11789
+ return true;
11790
+ }
11791
+ return false;
11792
+ }
11793
+ function bands(rects, axis) {
11794
+ const spans = rects.map((rect) => axis === "x" ? { start: rect.x, end: rect.x + rect.w } : { start: rect.y, end: rect.y + rect.h }).sort((a, b) => a.start - b.start);
11795
+ const out = [];
11796
+ for (const span of spans) {
11797
+ const last = out[out.length - 1];
11798
+ if (last !== void 0 && span.start <= last.end) {
11799
+ last.end = Math.max(last.end, span.end);
11800
+ } else {
11801
+ out.push({ ...span });
11802
+ }
11803
+ }
11804
+ return out;
11805
+ }
11806
+ function corridors(rects, axis, minCorridor) {
11807
+ const merged = bands(rects, axis);
11808
+ const out = [];
11809
+ for (let index2 = 1; index2 < merged.length; index2 += 1) {
11810
+ const gap = merged[index2].start - merged[index2 - 1].end;
11811
+ if (gap >= minCorridor) out.push((merged[index2 - 1].end + merged[index2].start) / 2);
11812
+ }
11813
+ return out;
11814
+ }
11815
+ function outerLines(rects, axis, clearance) {
11816
+ const merged = bands(rects, axis);
11817
+ const out = [];
11818
+ for (const band of merged) {
11819
+ out.push(band.start - clearance, band.end + clearance);
11820
+ }
11821
+ return out;
11822
+ }
11823
+ var Heap = class {
11824
+ items = [];
11825
+ push(cost, key, node) {
11826
+ this.items.push({ cost, key, node });
11827
+ let index2 = this.items.length - 1;
11828
+ while (index2 > 0) {
11829
+ const parent = index2 - 1 >> 1;
11830
+ if (this.items[parent].cost <= this.items[index2].cost) break;
11831
+ const tmp = this.items[parent];
11832
+ this.items[parent] = this.items[index2];
11833
+ this.items[index2] = tmp;
11834
+ index2 = parent;
11835
+ }
11836
+ }
11837
+ pop() {
11838
+ if (this.items.length === 0) return void 0;
11839
+ const top = this.items[0];
11840
+ const last = this.items.pop();
11841
+ if (this.items.length > 0) {
11842
+ this.items[0] = last;
11843
+ let index2 = 0;
11844
+ for (; ; ) {
11845
+ const left = index2 * 2 + 1;
11846
+ const right = left + 1;
11847
+ let smallest = index2;
11848
+ if (left < this.items.length && this.items[left].cost < this.items[smallest].cost) smallest = left;
11849
+ if (right < this.items.length && this.items[right].cost < this.items[smallest].cost) smallest = right;
11850
+ if (smallest === index2) break;
11851
+ const tmp = this.items[smallest];
11852
+ this.items[smallest] = this.items[index2];
11853
+ this.items[index2] = tmp;
11854
+ index2 = smallest;
11855
+ }
11856
+ }
11857
+ return { key: top.key, node: top.node };
11858
+ }
11859
+ get size() {
11860
+ return this.items.length;
11861
+ }
11862
+ };
11863
+ function dedupe(values, epsilon = 0.5) {
11864
+ const sorted = [...values].sort((a, b) => a - b);
11865
+ const out = [];
11866
+ for (const value of sorted) {
11867
+ if (out.length === 0 || Math.abs(value - out[out.length - 1]) > epsilon) out.push(value);
11868
+ }
11869
+ return out;
11870
+ }
11871
+ function simplify(points) {
11872
+ const out = [];
11873
+ for (const point of points) {
11874
+ const last = out[out.length - 1];
11875
+ if (last !== void 0 && Math.abs(last.x - point.x) < 0.5 && Math.abs(last.y - point.y) < 0.5) continue;
11876
+ out.push(point);
11877
+ }
11878
+ for (let index2 = 1; index2 < out.length - 1; ) {
11879
+ const a = out[index2 - 1];
11880
+ const b = out[index2];
11881
+ const c = out[index2 + 1];
11882
+ const collinear = Math.abs(a.x - b.x) < 0.5 && Math.abs(b.x - c.x) < 0.5 || Math.abs(a.y - b.y) < 0.5 && Math.abs(b.y - c.y) < 0.5;
11883
+ if (collinear) out.splice(index2, 1);
11884
+ else index2 += 1;
11885
+ }
11886
+ return out;
11887
+ }
11888
+ function routeEdge(from, to, fromFace, toFace, obstacles, options = {}) {
11889
+ return routeBetween(
11890
+ { start: anchorOf(from, fromFace), startFace: fromFace, end: anchorOf(to, toFace), endFace: toFace },
11891
+ from,
11892
+ to,
11893
+ obstacles,
11894
+ options
11895
+ );
11896
+ }
11897
+ function routeBetween(ends, from, to, obstacles, options = {}) {
11898
+ const margin = options.margin ?? DEFAULTS.margin;
11899
+ const stub = options.stub ?? DEFAULTS.stub;
11900
+ const minCorridor = options.minCorridor ?? DEFAULTS.minCorridor;
11901
+ const start2 = ends.start;
11902
+ const end = ends.end;
11903
+ const startNormal = normalOf(ends.startFace);
11904
+ const endNormal = normalOf(ends.endFace);
11905
+ const startStub = { x: start2.x + startNormal.x * stub, y: start2.y + startNormal.y * stub };
11906
+ const endStub = { x: end.x + endNormal.x * stub, y: end.y + endNormal.y * stub };
11907
+ const sameRect = (a, b) => Math.abs(a.x - b.x) < 0.5 && Math.abs(a.y - b.y) < 0.5 && Math.abs(a.w - b.w) < 0.5 && Math.abs(a.h - b.h) < 0.5;
11908
+ const blocked = obstacles.filter((rect) => !sameRect(rect, from) && !sameRect(rect, to)).map((rect) => expand(rect, margin));
11909
+ const fallback = simplify([start2, startStub, { x: endStub.x, y: startStub.y }, endStub, end]);
11910
+ const pad = 260;
11911
+ const window2 = {
11912
+ x1: Math.min(start2.x, end.x) - pad,
11913
+ x2: Math.max(start2.x, end.x) + pad,
11914
+ y1: Math.min(start2.y, end.y) - pad,
11915
+ y2: Math.max(start2.y, end.y) + pad
11916
+ };
11917
+ const near = obstacles.filter((rect) => rect.x + rect.w >= window2.x1 && rect.x <= window2.x2 && rect.y + rect.h >= window2.y1 && rect.y <= window2.y2);
11918
+ const withinX = (value) => value >= window2.x1 && value <= window2.x2;
11919
+ const withinY = (value) => value >= window2.y1 && value <= window2.y2;
11920
+ const xs = corridors(near, "x", minCorridor).filter(withinX);
11921
+ const ys = corridors(near, "y", minCorridor).filter(withinY);
11922
+ const xOuter = outerLines(near, "x", margin + 6).filter(withinX);
11923
+ const yOuter = outerLines(near, "y", margin + 6).filter(withinY);
11924
+ const xCands = dedupe([start2.x, end.x, startStub.x, endStub.x, ...xs, ...xOuter]);
11925
+ const yCands = dedupe([start2.y, end.y, startStub.y, endStub.y, ...ys, ...yOuter]);
11926
+ if (xCands.length > 96 || yCands.length > 96) return fallback;
11927
+ const corridorX = new Set(xs.map((value) => Math.round(value)));
11928
+ const corridorY = new Set(ys.map((value) => Math.round(value)));
11929
+ const nodeId = (ix, iy) => `${ix},${iy}`;
11930
+ const pointAt = (id2) => {
11931
+ const [ix, iy] = id2.split(",").map(Number);
11932
+ return { x: xCands[ix], y: yCands[iy] };
11933
+ };
11934
+ const startIndex = { x: xCands.findIndex((value) => Math.abs(value - startStub.x) < 0.5), y: yCands.findIndex((value) => Math.abs(value - startStub.y) < 0.5) };
11935
+ const endIndex = { x: xCands.findIndex((value) => Math.abs(value - endStub.x) < 0.5), y: yCands.findIndex((value) => Math.abs(value - endStub.y) < 0.5) };
11936
+ if (startIndex.x < 0 || startIndex.y < 0 || endIndex.x < 0 || endIndex.y < 0) return fallback;
11937
+ const goal = { x: endStub.x, y: endStub.y };
11938
+ const startNode = nodeId(startIndex.x, startIndex.y);
11939
+ const goalNode = nodeId(endIndex.x, endIndex.y);
11940
+ const best = /* @__PURE__ */ new Map();
11941
+ const cameFrom = /* @__PURE__ */ new Map();
11942
+ const heap = new Heap();
11943
+ const withDir = (node, dir) => `${node}|${dir}`;
11944
+ best.set(withDir(startNode, "x"), 0);
11945
+ heap.push(0, 0, withDir(startNode, "x"));
11946
+ const estimate = (point) => Math.abs(point.x - goal.x) + Math.abs(point.y - goal.y);
11947
+ while (heap.size > 0) {
11948
+ const popped = heap.pop();
11949
+ const state3 = popped.node;
11950
+ const [node, dir] = state3.split("|");
11951
+ const cost = best.get(state3);
11952
+ if (cost === void 0) continue;
11953
+ if (node === goalNode) {
11954
+ const path = [];
11955
+ let cursor = state3;
11956
+ while (cursor !== void 0) {
11957
+ const [cell] = cursor.split("|");
11958
+ path.push(pointAt(cell));
11959
+ cursor = cameFrom.get(cursor);
11960
+ }
11961
+ path.reverse();
11962
+ return simplify([start2, startStub, ...path.slice(1), endStub, end]);
11963
+ }
11964
+ const [ix, iy] = node.split(",").map(Number);
11965
+ const here = pointAt(node);
11966
+ const steps = [
11967
+ { dx: 1, dy: 0, axis: "x" },
11968
+ { dx: -1, dy: 0, axis: "x" },
11969
+ { dx: 0, dy: 1, axis: "y" },
11970
+ { dx: 0, dy: -1, axis: "y" }
11971
+ ];
11972
+ for (const step2 of steps) {
11973
+ const nx = ix + step2.dx;
11974
+ const ny = iy + step2.dy;
11975
+ if (nx < 0 || ny < 0 || nx >= xCands.length || ny >= yCands.length) continue;
11976
+ const next = { x: xCands[nx], y: yCands[ny] };
11977
+ const nextNode = nodeId(nx, ny);
11978
+ if (nextNode !== goalNode && blocked.some((rect) => insideStrict(rect, next))) continue;
11979
+ const clear = step2.axis === "x" ? !hitsHorizontal(blocked, here.y, here.x, next.x) : !hitsVertical(blocked, here.x, here.y, next.y);
11980
+ if (!clear) continue;
11981
+ const distance2 = Math.abs(next.x - here.x) + Math.abs(next.y - here.y);
11982
+ const onCorridor = step2.axis === "x" ? corridorY.has(Math.round(here.y)) : corridorX.has(Math.round(here.x));
11983
+ const turn = dir === step2.axis ? 0 : 18;
11984
+ const prefer = onCorridor ? 0 : 6;
11985
+ const nextCost = cost + distance2 + turn + prefer;
11986
+ const nextState = withDir(nextNode, step2.axis);
11987
+ const known = best.get(nextState);
11988
+ if (known !== void 0 && known <= nextCost) continue;
11989
+ best.set(nextState, nextCost);
11990
+ cameFrom.set(nextState, state3);
11991
+ heap.push(nextCost + estimate(next), nextCost, nextState);
11992
+ }
11993
+ }
11994
+ return fallback;
11995
+ }
11996
+ function roundedPath(points, radius = 10) {
11997
+ if (points.length === 0) return "";
11998
+ if (points.length === 1) return `M ${round(points[0].x)} ${round(points[0].y)}`;
11999
+ const parts = [`M ${round(points[0].x)} ${round(points[0].y)}`];
12000
+ for (let index2 = 1; index2 < points.length - 1; index2 += 1) {
12001
+ const prev = points[index2 - 1];
12002
+ const here = points[index2];
12003
+ const next = points[index2 + 1];
12004
+ const inLength = Math.hypot(here.x - prev.x, here.y - prev.y);
12005
+ const outLength = Math.hypot(next.x - here.x, next.y - here.y);
12006
+ const corner = Math.min(radius, inLength / 2, outLength / 2);
12007
+ if (corner < 0.5) {
12008
+ parts.push(`L ${round(here.x)} ${round(here.y)}`);
12009
+ continue;
12010
+ }
12011
+ const enter = {
12012
+ x: here.x + (prev.x - here.x) / (inLength || 1) * corner,
12013
+ y: here.y + (prev.y - here.y) / (inLength || 1) * corner
12014
+ };
12015
+ const leave = {
12016
+ x: here.x + (next.x - here.x) / (outLength || 1) * corner,
12017
+ y: here.y + (next.y - here.y) / (outLength || 1) * corner
12018
+ };
12019
+ parts.push(`L ${round(enter.x)} ${round(enter.y)}`);
12020
+ parts.push(`Q ${round(here.x)} ${round(here.y)} ${round(leave.x)} ${round(leave.y)}`);
12021
+ }
12022
+ const last = points[points.length - 1];
12023
+ parts.push(`L ${round(last.x)} ${round(last.y)}`);
12024
+ return parts.join(" ");
12025
+ }
12026
+ function round(value) {
12027
+ return Math.round(value * 100) / 100;
12028
+ }
12029
+
11741
12030
  // src/client/TalkMapEdge.tsx
11742
12031
  var import_jsx_runtime8 = require("react/jsx-runtime");
11743
12032
  function TalkMapEdge(props) {
11744
12033
  const data = props.data ?? {};
11745
12034
  const synced = data.sync === "synced";
11746
12035
  const hidden = synced && data.structural !== true;
11747
- const [path] = getSmoothStepPath({
12036
+ const faceOf = (position) => {
12037
+ const name2 = String(position ?? "left");
12038
+ if (name2 === "right") return "r";
12039
+ if (name2 === "top") return "t";
12040
+ if (name2 === "bottom") return "b";
12041
+ return "l";
12042
+ };
12043
+ const obstacles = data.obstacles;
12044
+ const route = obstacles === void 0 ? void 0 : routeBetween(
12045
+ {
12046
+ start: { x: props.sourceX, y: props.sourceY },
12047
+ startFace: faceOf(props.sourcePosition),
12048
+ end: { x: props.targetX, y: props.targetY },
12049
+ endFace: faceOf(props.targetPosition)
12050
+ },
12051
+ // Endpoint bodies for the corridor maths; the router skips them by value.
12052
+ { x: props.sourceX, y: props.sourceY, w: 0, h: 0 },
12053
+ { x: props.targetX, y: props.targetY, w: 0, h: 0 },
12054
+ obstacles
12055
+ );
12056
+ const routed = route !== void 0 && route.length > 1;
12057
+ const [smoothPath] = getSmoothStepPath({
11748
12058
  sourceX: props.sourceX,
11749
12059
  sourceY: props.sourceY,
11750
12060
  sourcePosition: props.sourcePosition,
@@ -11752,7 +12062,16 @@ function TalkMapEdge(props) {
11752
12062
  targetY: props.targetY,
11753
12063
  targetPosition: props.targetPosition
11754
12064
  });
12065
+ const path = routed ? roundedPath(route, 10) : smoothPath;
11755
12066
  const arrowAngle = (() => {
12067
+ if (routed) {
12068
+ const end = route[route.length - 1];
12069
+ const before = route[route.length - 2];
12070
+ const dx = end.x - before.x;
12071
+ const dy = end.y - before.y;
12072
+ if (Math.abs(dx) >= Math.abs(dy)) return dx >= 0 ? 0 : 180;
12073
+ return dy >= 0 ? 90 : -90;
12074
+ }
11756
12075
  const position = String(props.targetPosition ?? "left");
11757
12076
  if (position === "right") return 180;
11758
12077
  if (position === "top") return 90;
@@ -12406,59 +12725,43 @@ function StackDrawer(props) {
12406
12725
  rect.height
12407
12726
  );
12408
12727
  };
12728
+ const cardsInDrawer = [...scroller.querySelectorAll("[data-card-id]")].map((element) => {
12729
+ const box = element.getBoundingClientRect();
12730
+ const base = scroller.getBoundingClientRect();
12731
+ return {
12732
+ id: element.getAttribute("data-card-id") ?? "",
12733
+ x: box.left - base.left + scroller.scrollLeft,
12734
+ y: box.top - base.top + scroller.scrollTop,
12735
+ w: box.width,
12736
+ h: box.height
12737
+ };
12738
+ });
12409
12739
  const next = [];
12410
12740
  for (const link2 of links) {
12411
12741
  const from = boxOf(link2.from);
12412
12742
  const to = boxOf(link2.to);
12413
12743
  if (from === null || to === null) continue;
12414
- const fromCx = from.x + from.width / 2;
12415
- const fromCy = from.y + from.height / 2;
12416
- const toCx = to.x + to.width / 2;
12417
- const toCy = to.y + to.height / 2;
12418
- const dx = toCx - fromCx;
12419
- const dy = toCy - fromCy;
12420
- const gapX = Math.abs(dx) - (from.width + to.width) / 2;
12421
- const gapY = Math.abs(dy) - (from.height + to.height) / 2;
12422
- const MIN_SPAN = 96;
12423
- const horizontalDominant = Math.abs(dx) >= Math.abs(dy);
12424
- let sourceX = fromCx;
12425
- let sourceY = fromCy;
12426
- let targetX = toCx;
12427
- let targetY = toCy;
12428
- let sourcePosition = Position.Right;
12429
- let targetPosition = Position.Left;
12430
- if (horizontalDominant && gapX >= MIN_SPAN) {
12431
- const right = dx >= 0;
12432
- sourceX = right ? from.x + from.width : from.x;
12433
- targetX = right ? to.x : to.x + to.width;
12434
- sourcePosition = right ? Position.Right : Position.Left;
12435
- targetPosition = right ? Position.Left : Position.Right;
12436
- targetY = toCy;
12437
- } else if (!horizontalDominant && gapY >= MIN_SPAN) {
12438
- const down = dy >= 0;
12439
- sourceY = down ? from.y + from.height : from.y;
12440
- targetY = down ? to.y : to.y + to.height;
12441
- sourcePosition = down ? Position.Bottom : Position.Top;
12442
- targetPosition = down ? Position.Top : Position.Bottom;
12443
- targetX = toCx;
12444
- } else {
12445
- const down = from.y + from.height <= to.y + to.height;
12446
- sourceY = down ? from.y + from.height : from.y;
12447
- targetY = down ? to.y + to.height : to.y;
12448
- sourcePosition = down ? Position.Bottom : Position.Top;
12449
- targetPosition = down ? Position.Bottom : Position.Top;
12450
- }
12451
- const [wirePath] = getSmoothStepPath({
12452
- sourceX,
12453
- sourceY,
12454
- sourcePosition,
12455
- targetX,
12456
- targetY,
12457
- targetPosition,
12458
- borderRadius: 8
12459
- });
12460
- const angle = targetPosition === Position.Left ? 0 : targetPosition === Position.Right ? 180 : targetPosition === Position.Top ? 90 : -90;
12461
- next.push({ d: wirePath, ax: targetX, ay: targetY, angle });
12744
+ const rectOf = (box) => ({ x: box.x, y: box.y, w: box.width, h: box.height });
12745
+ const fromRect = rectOf(from);
12746
+ const toRect = rectOf(to);
12747
+ const obstacles = cardsInDrawer.filter((card) => card.id !== link2.from && card.id !== link2.to).map(rectOf);
12748
+ const faces = pickFaces(
12749
+ { id: link2.from, x: fromRect.x, y: fromRect.y },
12750
+ { id: link2.to, x: toRect.x, y: toRect.y },
12751
+ cardsInDrawer.map((card) => ({ id: card.id, x: card.x, y: card.y })),
12752
+ { cardWidth: fromRect.w, cardHeight: fromRect.h }
12753
+ );
12754
+ const points = routeEdge(
12755
+ fromRect,
12756
+ toRect,
12757
+ faces.fromHandle,
12758
+ faces.toHandle,
12759
+ [fromRect, toRect, ...obstacles]
12760
+ );
12761
+ const tip = points[points.length - 1];
12762
+ const prev = points[points.length - 2];
12763
+ const angle = Math.abs(tip.x - prev.x) >= Math.abs(tip.y - prev.y) ? tip.x >= prev.x ? 0 : 180 : tip.y >= prev.y ? 90 : -90;
12764
+ next.push({ d: roundedPath(points, 8), ax: tip.x, ay: tip.y, angle });
12462
12765
  }
12463
12766
  setWires((current) => {
12464
12767
  if (current.length === next.length && current.every((wire, index2) => wire.d === next[index2]?.d)) {
@@ -12825,7 +13128,7 @@ function StackNode(props) {
12825
13128
  }
12826
13129
 
12827
13130
  // src/client/use-dark.ts
12828
- var import_react12 = require("react");
13131
+ var import_react11 = require("react");
12829
13132
  var DARK_ATTRIBUTE = "data-ds-dark-theme";
12830
13133
  function subscribe(listener) {
12831
13134
  if (typeof document === "undefined") return () => {
@@ -12841,7 +13144,7 @@ function getSnapshot() {
12841
13144
  return document.body.hasAttribute(DARK_ATTRIBUTE);
12842
13145
  }
12843
13146
  function useDsDarkTheme() {
12844
- return (0, import_react12.useSyncExternalStore)(subscribe, getSnapshot);
13147
+ return (0, import_react11.useSyncExternalStore)(subscribe, getSnapshot);
12845
13148
  }
12846
13149
 
12847
13150
  // src/client/MapCanvas.tsx
@@ -12900,14 +13203,14 @@ function fitRect(members) {
12900
13203
  }
12901
13204
  function CanvasInner(props) {
12902
13205
  const dark = useDsDarkTheme();
12903
- const canvasState = (0, import_react13.useSyncExternalStore)(canvas.subscribe, canvas.get);
13206
+ const canvasState = (0, import_react12.useSyncExternalStore)(canvas.subscribe, canvas.get);
12904
13207
  const sessions = props.useSessions((state3) => state3);
12905
13208
  const workspaces = props.useWorkspaces((state3) => state3);
12906
13209
  const statusById = typeof props.useSessionStatus === "function" ? props.useSessionStatus((status) => status) : EMPTY_SESSION_STATUS;
12907
- const alertById = (0, import_react13.useSyncExternalStore)(sessionAlerts.subscribe, sessionAlerts.getSnapshot);
12908
- const finishedById = (0, import_react13.useSyncExternalStore)(sessionActivity.subscribe, sessionActivity.getSnapshot);
12909
- const interruptedById = (0, import_react13.useSyncExternalStore)(sessionActivity.subscribe, sessionActivity.getInterrupted);
12910
- (0, import_react13.useEffect)(() => {
13210
+ const alertById = (0, import_react12.useSyncExternalStore)(sessionAlerts.subscribe, sessionAlerts.getSnapshot);
13211
+ const finishedById = (0, import_react12.useSyncExternalStore)(sessionActivity.subscribe, sessionActivity.getSnapshot);
13212
+ const interruptedById = (0, import_react12.useSyncExternalStore)(sessionActivity.subscribe, sessionActivity.getInterrupted);
13213
+ (0, import_react12.useEffect)(() => {
12911
13214
  const onUnload = () => {
12912
13215
  sessionActivity.recordShutdown(statusById, sessions.byId);
12913
13216
  };
@@ -12916,14 +13219,14 @@ function CanvasInner(props) {
12916
13219
  window.removeEventListener("beforeunload", onUnload);
12917
13220
  };
12918
13221
  }, [statusById, sessions]);
12919
- (0, import_react13.useEffect)(() => {
13222
+ (0, import_react12.useEffect)(() => {
12920
13223
  sessionActivity.beginPanelSession();
12921
13224
  }, []);
12922
- (0, import_react13.useEffect)(() => {
13225
+ (0, import_react12.useEffect)(() => {
12923
13226
  sessionActivity.observe(statusById, sessions.byId);
12924
13227
  }, [statusById, sessions]);
12925
- const draftSessions = (0, import_react13.useSyncExternalStore)(draftWatch.subscribe, draftWatch.getSnapshot);
12926
- (0, import_react13.useEffect)(() => {
13228
+ const draftSessions = (0, import_react12.useSyncExternalStore)(draftWatch.subscribe, draftWatch.getSnapshot);
13229
+ (0, import_react12.useEffect)(() => {
12927
13230
  draftWatch.refresh();
12928
13231
  const timer4 = setInterval(() => {
12929
13232
  draftWatch.refresh();
@@ -12932,22 +13235,22 @@ function CanvasInner(props) {
12932
13235
  clearInterval(timer4);
12933
13236
  };
12934
13237
  }, []);
12935
- const [previews, setPreviews] = (0, import_react13.useState)(readPreviewTexts);
12936
- const previewStamp = (0, import_react13.useRef)(
13238
+ const [previews, setPreviews] = (0, import_react12.useState)(readPreviewTexts);
13239
+ const previewStamp = (0, import_react12.useRef)(
12937
13240
  // Only entries that still make a usable body count as cached: a rule fix that
12938
13241
  // empties an old entry must trigger a refetch, not leave a blank card.
12939
13242
  new Map(Object.entries(loadPreviewCache()).filter(([, entry]) => typeof entry?.text === "string" && cleanPreviewText(entry.text) !== "").map(([sessionId, entry]) => [sessionId, entry.stamp]))
12940
13243
  );
12941
13244
  const { screenToFlowPosition, zoomTo, setNodes } = useReactFlow();
12942
- const [selectedIds, setSelectedIds] = (0, import_react13.useState)(/* @__PURE__ */ new Set());
12943
- const [selectedEdgeIds, setSelectedEdgeIds] = (0, import_react13.useState)(/* @__PURE__ */ new Set());
12944
- const [connecting, setConnecting] = (0, import_react13.useState)(false);
12945
- const connectCancelledRef = (0, import_react13.useRef)(false);
12946
- const [toast, setToast] = (0, import_react13.useState)(null);
12947
- const toastTimer = (0, import_react13.useRef)(void 0);
12948
- const [pendingSpawn, setPendingSpawn] = (0, import_react13.useState)(null);
12949
- const [menu, setMenu] = (0, import_react13.useState)(null);
12950
- const [drawer, setDrawer] = (0, import_react13.useState)(() => {
13245
+ const [selectedIds, setSelectedIds] = (0, import_react12.useState)(/* @__PURE__ */ new Set());
13246
+ const [selectedEdgeIds, setSelectedEdgeIds] = (0, import_react12.useState)(/* @__PURE__ */ new Set());
13247
+ const [connecting, setConnecting] = (0, import_react12.useState)(false);
13248
+ const connectCancelledRef = (0, import_react12.useRef)(false);
13249
+ const [toast, setToast] = (0, import_react12.useState)(null);
13250
+ const toastTimer = (0, import_react12.useRef)(void 0);
13251
+ const [pendingSpawn, setPendingSpawn] = (0, import_react12.useState)(null);
13252
+ const [menu, setMenu] = (0, import_react12.useState)(null);
13253
+ const [drawer, setDrawer] = (0, import_react12.useState)(() => {
12951
13254
  const remembered = drawerState.readGroup();
12952
13255
  return remembered === null ? null : { groupId: remembered };
12953
13256
  });
@@ -12955,11 +13258,11 @@ function CanvasInner(props) {
12955
13258
  setDrawer(null);
12956
13259
  drawerState.clear();
12957
13260
  };
12958
- const [digestTarget, setDigestTarget] = (0, import_react13.useState)(null);
12959
- const [pushEpoch, setPushEpoch] = (0, import_react13.useState)(0);
13261
+ const [digestTarget, setDigestTarget] = (0, import_react12.useState)(null);
13262
+ const [pushEpoch, setPushEpoch] = (0, import_react12.useState)(0);
12960
13263
  const LINEAGE_KEY = "dsh.talk-map.lineage-hidden.v1";
12961
13264
  const LINEAGE_CUT_KEY = "dsh.talk-map.lineage-cut.v1";
12962
- const [lineageCut, setLineageCut] = (0, import_react13.useState)(() => {
13265
+ const [lineageCut, setLineageCut] = (0, import_react12.useState)(() => {
12963
13266
  try {
12964
13267
  const raw = window.localStorage.getItem(LINEAGE_CUT_KEY);
12965
13268
  const parsed = raw === null ? [] : JSON.parse(raw);
@@ -12980,7 +13283,7 @@ function CanvasInner(props) {
12980
13283
  return next;
12981
13284
  });
12982
13285
  };
12983
- const [lineageHidden, setLineageHiddenState] = (0, import_react13.useState)(() => {
13286
+ const [lineageHidden, setLineageHiddenState] = (0, import_react12.useState)(() => {
12984
13287
  try {
12985
13288
  return localStorage.getItem("dsh.talk-map.lineage-hidden.v1") === "1";
12986
13289
  } catch {
@@ -12994,34 +13297,34 @@ function CanvasInner(props) {
12994
13297
  } catch {
12995
13298
  }
12996
13299
  };
12997
- const [renameTarget, setRenameTarget] = (0, import_react13.useState)(null);
12998
- const [renamedTitles, setRenamedTitles] = (0, import_react13.useState)({});
12999
- const [renamedWorkspaces, setRenamedWorkspaces] = (0, import_react13.useState)({});
13000
- const [batchMode, setBatchMode] = (0, import_react13.useState)(false);
13001
- const [batchPicks, setBatchPicks] = (0, import_react13.useState)(/* @__PURE__ */ new Set());
13002
- const [batchBusy, setBatchBusy] = (0, import_react13.useState)(false);
13003
- const wrapperRef = (0, import_react13.useRef)(null);
13004
- const [draggingCardId, setDraggingCardId] = (0, import_react13.useState)(null);
13005
- const [liveFrame, setLiveFrame] = (0, import_react13.useState)(null);
13006
- const [blockedFrame, setBlockedFrame] = (0, import_react13.useState)(null);
13007
- const [dragCenter, setDragCenter] = (0, import_react13.useState)(null);
13008
- const [isSelecting, setIsSelecting] = (0, import_react13.useState)(false);
13009
- const frozenRef = (0, import_react13.useRef)(null);
13010
- const locale = (0, import_react13.useSyncExternalStore)(subscribeLocale, activeLocale, activeLocale);
13011
- const sessionWs = (0, import_react13.useMemo)(() => sessionWorkspaceIndex(workspaces), [workspaces]);
13012
- const wsTitles = (0, import_react13.useMemo)(
13300
+ const [renameTarget, setRenameTarget] = (0, import_react12.useState)(null);
13301
+ const [renamedTitles, setRenamedTitles] = (0, import_react12.useState)({});
13302
+ const [renamedWorkspaces, setRenamedWorkspaces] = (0, import_react12.useState)({});
13303
+ const [batchMode, setBatchMode] = (0, import_react12.useState)(false);
13304
+ const [batchPicks, setBatchPicks] = (0, import_react12.useState)(/* @__PURE__ */ new Set());
13305
+ const [batchBusy, setBatchBusy] = (0, import_react12.useState)(false);
13306
+ const wrapperRef = (0, import_react12.useRef)(null);
13307
+ const [draggingCardId, setDraggingCardId] = (0, import_react12.useState)(null);
13308
+ const [liveFrame, setLiveFrame] = (0, import_react12.useState)(null);
13309
+ const [blockedFrame, setBlockedFrame] = (0, import_react12.useState)(null);
13310
+ const [dragCenter, setDragCenter] = (0, import_react12.useState)(null);
13311
+ const [isSelecting, setIsSelecting] = (0, import_react12.useState)(false);
13312
+ const frozenRef = (0, import_react12.useRef)(null);
13313
+ const locale = (0, import_react12.useSyncExternalStore)(subscribeLocale, activeLocale, activeLocale);
13314
+ const sessionWs = (0, import_react12.useMemo)(() => sessionWorkspaceIndex(workspaces), [workspaces]);
13315
+ const wsTitles = (0, import_react12.useMemo)(
13013
13316
  () => new Map(workspaces.items.map((item) => [item.workspaceId, item.title])),
13014
13317
  [workspaces]
13015
13318
  );
13016
13319
  const workspacesReady = workspaces.baselinesReady !== false;
13017
- const pinnedSessions = (0, import_react13.useMemo)(() => new Set(workspaces.pinnedSessionIds ?? []), [workspaces]);
13018
- const boardSessionIds = (0, import_react13.useMemo)(
13320
+ const pinnedSessions = (0, import_react12.useMemo)(() => new Set(workspaces.pinnedSessionIds ?? []), [workspaces]);
13321
+ const boardSessionIds = (0, import_react12.useMemo)(
13019
13322
  () => new Set(Object.values(canvasState.cards).map((card) => card.sessionId)),
13020
13323
  [canvasState.cards]
13021
13324
  );
13022
13325
  const wsFrames = canvasState.global?.wsFrames ?? {};
13023
13326
  const layoutVersion = canvasState.global?.layoutVersion ?? 1;
13024
- (0, import_react13.useEffect)(() => {
13327
+ (0, import_react12.useEffect)(() => {
13025
13328
  if (canvasState.phase !== "ready" || layoutVersion >= LAYOUT_VERSION || !workspacesReady) return;
13026
13329
  const byGroup = /* @__PURE__ */ new Map();
13027
13330
  for (const card of Object.values(canvasState.cards)) {
@@ -13040,7 +13343,7 @@ function CanvasInner(props) {
13040
13343
  }
13041
13344
  canvas.patchGlobalNow({ layoutVersion: LAYOUT_VERSION, wsFrames: framesNext });
13042
13345
  }, [canvasState.phase, layoutVersion, workspacesReady, canvasState.cards, canvasState.global, sessionWs]);
13043
- const visibleCards = (0, import_react13.useMemo)(() => {
13346
+ const visibleCards = (0, import_react12.useMemo)(() => {
13044
13347
  const out = {};
13045
13348
  for (const [cardId, card] of Object.entries(canvasState.cards)) {
13046
13349
  if (sessions.byId[card.sessionId]?.blank === true) continue;
@@ -13048,11 +13351,11 @@ function CanvasInner(props) {
13048
13351
  }
13049
13352
  return out;
13050
13353
  }, [canvasState.cards, sessions]);
13051
- const previewInputs = (0, import_react13.useRef)({ cards: visibleCards, sessions });
13354
+ const previewInputs = (0, import_react12.useRef)({ cards: visibleCards, sessions });
13052
13355
  previewInputs.current = { cards: visibleCards, sessions };
13053
- const previewTick = (0, import_react13.useRef)(() => {
13356
+ const previewTick = (0, import_react12.useRef)(() => {
13054
13357
  });
13055
- (0, import_react13.useEffect)(() => {
13358
+ (0, import_react12.useEffect)(() => {
13056
13359
  const tick = () => {
13057
13360
  const { cards, sessions: latest } = previewInputs.current;
13058
13361
  const pending = [];
@@ -13084,10 +13387,10 @@ function CanvasInner(props) {
13084
13387
  clearInterval(timer4);
13085
13388
  };
13086
13389
  }, []);
13087
- (0, import_react13.useEffect)(() => {
13390
+ (0, import_react12.useEffect)(() => {
13088
13391
  previewTick.current();
13089
13392
  }, [visibleCards]);
13090
- const membersByGroup = (0, import_react13.useMemo)(() => {
13393
+ const membersByGroup = (0, import_react12.useMemo)(() => {
13091
13394
  const index2 = /* @__PURE__ */ new Map();
13092
13395
  for (const [cardId, card] of Object.entries(visibleCards)) {
13093
13396
  const groupId = sessionWs.get(card.sessionId);
@@ -13096,7 +13399,7 @@ function CanvasInner(props) {
13096
13399
  }
13097
13400
  return index2;
13098
13401
  }, [visibleCards, sessionWs]);
13099
- const frameRects = (0, import_react13.useMemo)(() => {
13402
+ const frameRects = (0, import_react12.useMemo)(() => {
13100
13403
  const out = {};
13101
13404
  for (const [groupId, stored] of Object.entries(wsFrames)) {
13102
13405
  const base = liveFrame !== null && liveFrame.groupId === groupId ? liveFrame.rect : stored;
@@ -13104,7 +13407,7 @@ function CanvasInner(props) {
13104
13407
  }
13105
13408
  return out;
13106
13409
  }, [wsFrames, liveFrame]);
13107
- const folderLayouts = (0, import_react13.useMemo)(() => {
13410
+ const folderLayouts = (0, import_react12.useMemo)(() => {
13108
13411
  const out = {};
13109
13412
  for (const [groupId, rect] of Object.entries(frameRects)) {
13110
13413
  const members = (membersByGroup.get(groupId) ?? []).map((cardId) => {
@@ -13136,21 +13439,21 @@ function CanvasInner(props) {
13136
13439
  }
13137
13440
  return out;
13138
13441
  }, [frameRects, membersByGroup, visibleCards, pinnedSessions, draggingCardId, dragCenter]);
13139
- const cardLayout = (0, import_react13.useMemo)(() => {
13442
+ const cardLayout = (0, import_react12.useMemo)(() => {
13140
13443
  const out = {};
13141
13444
  for (const layout of Object.values(folderLayouts)) {
13142
13445
  Object.assign(out, layoutFor(layout.rect, layout.ordered));
13143
13446
  }
13144
13447
  return out;
13145
13448
  }, [folderLayouts]);
13146
- const foldedCards = (0, import_react13.useMemo)(() => {
13449
+ const foldedCards = (0, import_react12.useMemo)(() => {
13147
13450
  const out = {};
13148
13451
  for (const [groupId, layout] of Object.entries(folderLayouts)) {
13149
13452
  if (layout.folded.length > 0) out[groupId] = layout.folded;
13150
13453
  }
13151
13454
  return out;
13152
13455
  }, [folderLayouts]);
13153
- (0, import_react13.useEffect)(() => {
13456
+ (0, import_react12.useEffect)(() => {
13154
13457
  if (canvasState.phase !== "ready") return;
13155
13458
  if (draggingCardId !== null || liveFrame !== null) return;
13156
13459
  const stale = {};
@@ -13161,8 +13464,8 @@ function CanvasInner(props) {
13161
13464
  }
13162
13465
  if (Object.keys(stale).length > 0) canvas.moveCards(stale);
13163
13466
  }, [cardLayout, canvasState.cards, canvasState.phase, draggingCardId, liveFrame]);
13164
- const foldedSet = (0, import_react13.useMemo)(() => new Set(Object.values(foldedCards).flat()), [foldedCards]);
13165
- (0, import_react13.useEffect)(() => {
13467
+ const foldedSet = (0, import_react12.useMemo)(() => new Set(Object.values(foldedCards).flat()), [foldedCards]);
13468
+ (0, import_react12.useEffect)(() => {
13166
13469
  if (canvasState.phase !== "ready") return;
13167
13470
  if (draggingCardId !== null || liveFrame !== null) return;
13168
13471
  const seen = lastActivitySeen;
@@ -13197,8 +13500,8 @@ function CanvasInner(props) {
13197
13500
  for (const [sessionId, stamp] of stamps) seen.set(sessionId, stamp);
13198
13501
  if (Object.keys(promoted).length > 0) canvas.moveCards(promoted);
13199
13502
  }, [canvasState.phase, visibleCards, sessions, folderLayouts, draggingCardId, liveFrame, pinnedSessions]);
13200
- const autoSyncedRef = (0, import_react13.useRef)(false);
13201
- (0, import_react13.useEffect)(() => {
13503
+ const autoSyncedRef = (0, import_react12.useRef)(false);
13504
+ (0, import_react12.useEffect)(() => {
13202
13505
  if (canvasState.phase !== "ready" || !workspacesReady || autoSyncedRef.current) return;
13203
13506
  autoSyncedRef.current = true;
13204
13507
  const remembered = canvasState.global?.layoutMemory ?? {};
@@ -13258,7 +13561,7 @@ function CanvasInner(props) {
13258
13561
  }
13259
13562
  if (Object.keys(added).length > 0) canvas.addCards(added);
13260
13563
  }, [canvasState.phase, canvasState.cards, canvasState.global, workspacesReady, wsFrames, frameRects, membersByGroup, sessions, sessionWs, boardSessionIds]);
13261
- (0, import_react13.useEffect)(() => {
13564
+ (0, import_react12.useEffect)(() => {
13262
13565
  if (!connecting) return;
13263
13566
  const release = mapUi.claimEscape("connecting");
13264
13567
  const onKeyDown = (event) => {
@@ -13279,7 +13582,7 @@ function CanvasInner(props) {
13279
13582
  release();
13280
13583
  };
13281
13584
  }, [connecting]);
13282
- (0, import_react13.useEffect)(() => {
13585
+ (0, import_react12.useEffect)(() => {
13283
13586
  const onKeyDown = (event) => {
13284
13587
  if (!(event.metaKey || event.ctrlKey) || event.code !== "KeyZ") return;
13285
13588
  const target = event.target;
@@ -13294,7 +13597,7 @@ function CanvasInner(props) {
13294
13597
  window.removeEventListener("keydown", onKeyDown, { capture: true });
13295
13598
  };
13296
13599
  }, []);
13297
- const liveSelectedIds = (0, import_react13.useMemo)(() => {
13600
+ const liveSelectedIds = (0, import_react12.useMemo)(() => {
13298
13601
  const next = /* @__PURE__ */ new Set();
13299
13602
  for (const id2 of selectedIds) {
13300
13603
  if (id2.startsWith("frame-")) {
@@ -13305,7 +13608,7 @@ function CanvasInner(props) {
13305
13608
  }
13306
13609
  return next;
13307
13610
  }, [selectedIds, visibleCards, wsFrames]);
13308
- const liveSelectedEdgeIds = (0, import_react13.useMemo)(() => {
13611
+ const liveSelectedEdgeIds = (0, import_react12.useMemo)(() => {
13309
13612
  const next = /* @__PURE__ */ new Set();
13310
13613
  for (const id2 of selectedEdgeIds) {
13311
13614
  if (canvasState.edges[id2] !== void 0) next.add(id2);
@@ -13313,7 +13616,7 @@ function CanvasInner(props) {
13313
13616
  return next;
13314
13617
  }, [selectedEdgeIds, canvasState.edges]);
13315
13618
  const hasSelection = liveSelectedIds.size > 0 || liveSelectedEdgeIds.size > 0;
13316
- (0, import_react13.useEffect)(() => {
13619
+ (0, import_react12.useEffect)(() => {
13317
13620
  if (!hasSelection) return;
13318
13621
  const release = mapUi.claimEscape("selection");
13319
13622
  const onKeyDown = (event) => {
@@ -13342,7 +13645,7 @@ function CanvasInner(props) {
13342
13645
  release();
13343
13646
  };
13344
13647
  });
13345
- (0, import_react13.useEffect)(() => {
13648
+ (0, import_react12.useEffect)(() => {
13346
13649
  if (!batchMode) return;
13347
13650
  const release = mapUi.claimEscape("batch-mode");
13348
13651
  const onKeyDown = (event) => {
@@ -13435,7 +13738,7 @@ function CanvasInner(props) {
13435
13738
  if (status?.completionUnread === true || finishedById.has(sessionId)) return "done";
13436
13739
  return void 0;
13437
13740
  };
13438
- const liveNodes = (0, import_react13.useMemo)(() => {
13741
+ const liveNodes = (0, import_react12.useMemo)(() => {
13439
13742
  const wsColors = canvasState.global?.wsColors ?? {};
13440
13743
  const frameNodes = Object.entries(frameRects).map(([groupId, rect]) => {
13441
13744
  const members = membersByGroup.get(groupId) ?? [];
@@ -13546,7 +13849,7 @@ function CanvasInner(props) {
13546
13849
  });
13547
13850
  return [...frameNodes, ...cardNodes, ...stackNodes];
13548
13851
  }, [frameRects, folderLayouts, foldedCards, foldedSet, cardLayout, draggingCardId, membersByGroup, wsTitles, visibleCards, canvasState.digests, canvasState.global, sessions, statusById, alertById, finishedById, interruptedById, draftSessions, previews, pinnedSessions, renamedTitles, renamedWorkspaces, liveSelectedIds, batchMode, batchPicks, locale]);
13549
- const sessionIdToCardId = (0, import_react13.useMemo)(() => {
13852
+ const sessionIdToCardId = (0, import_react12.useMemo)(() => {
13550
13853
  const index2 = /* @__PURE__ */ new Map();
13551
13854
  for (const [cardId, card] of Object.entries(visibleCards)) {
13552
13855
  if (!index2.has(card.sessionId)) index2.set(card.sessionId, cardId);
@@ -13565,6 +13868,7 @@ function CanvasInner(props) {
13565
13868
  if (card === void 0) return void 0;
13566
13869
  return sessions.byId[card.sessionId]?.updatedAt;
13567
13870
  };
13871
+ const obstaclesFor = (fromCardId, toCardId) => Object.entries(canvasState.cards).filter(([id2]) => id2 !== fromCardId && id2 !== toCardId).filter(([id2]) => !foldedSet.has(id2)).map(([, card]) => ({ x: card.x, y: card.y, w: CARD_W, h: CARD_H }));
13568
13872
  const routingObstacles = () => Object.entries(canvasState.cards).map(([id2, card]) => ({
13569
13873
  id: id2,
13570
13874
  x: card.x,
@@ -13589,7 +13893,7 @@ function CanvasInner(props) {
13589
13893
  const picked = sideHandles(fromCardId, toCardId);
13590
13894
  return { sourceHandle: picked.fromHandle, targetHandle: picked.toHandle };
13591
13895
  };
13592
- const liveEdges = (0, import_react13.useMemo)(() => {
13896
+ const liveEdges = (0, import_react12.useMemo)(() => {
13593
13897
  const out = [];
13594
13898
  const present = new Set(Object.keys(visibleCards).filter((cardId) => !foldedSet.has(cardId)));
13595
13899
  const explicitPairs = /* @__PURE__ */ new Set();
@@ -13614,7 +13918,12 @@ function CanvasInner(props) {
13614
13918
  selected: liveSelectedEdgeIds.has(edgeId),
13615
13919
  // Endpoints ride along for the edge context menu (id parsing would
13616
13920
  // be ambiguous — card ids contain dashes); `sync` drives the look.
13617
- data: { fromCardId: edge.fromCardId, toCardId: edge.toCardId, sync },
13921
+ data: {
13922
+ fromCardId: edge.fromCardId,
13923
+ toCardId: edge.toCardId,
13924
+ sync,
13925
+ obstacles: obstaclesFor(edge.fromCardId, edge.toCardId)
13926
+ },
13618
13927
  // Every line carries its direction now: 「推送摘要」 always travels
13619
13928
  // source → target, so a link edge gets a lighter arrow instead of none.
13620
13929
  markerEnd: {
@@ -13663,7 +13972,13 @@ function CanvasInner(props) {
13663
13972
  // Same two looks as any other line.
13664
13973
  // structural: a fork link is part of the map, not a transfer, so it
13665
13974
  // stays visible even when the pair is in sync.
13666
- data: { fromCardId: parentCardId, toCardId: cardId, sync: lineageSync, structural: true },
13975
+ data: {
13976
+ fromCardId: parentCardId,
13977
+ toCardId: cardId,
13978
+ sync: lineageSync,
13979
+ structural: true,
13980
+ obstacles: obstaclesFor(parentCardId, cardId)
13981
+ },
13667
13982
  // No inline stroke: inline style beats everything the renderer draws.
13668
13983
  style: { opacity: 0.85 }
13669
13984
  });
@@ -13671,7 +13986,7 @@ function CanvasInner(props) {
13671
13986
  }
13672
13987
  return out;
13673
13988
  }, [visibleCards, canvasState.edges, sessions, sessionIdToCardId, liveSelectedEdgeIds, foldedSet, locale, pushEpoch, lineageHidden]);
13674
- const drawerWireLinks = (0, import_react13.useMemo)(() => {
13989
+ const drawerWireLinks = (0, import_react12.useMemo)(() => {
13675
13990
  if (drawer === null) return [];
13676
13991
  const layout = folderLayouts[drawer.groupId];
13677
13992
  const inFolder = new Set(layout === void 0 ? [] : [...layout.shown, ...layout.folded]);
@@ -13801,8 +14116,8 @@ function CanvasInner(props) {
13801
14116
  }
13802
14117
  if (removedIds.length > 0) canvas.removeEdges(removedIds);
13803
14118
  };
13804
- const mountedRef = (0, import_react13.useRef)(true);
13805
- (0, import_react13.useEffect)(() => {
14119
+ const mountedRef = (0, import_react12.useRef)(true);
14120
+ (0, import_react12.useEffect)(() => {
13806
14121
  mountedRef.current = true;
13807
14122
  return () => {
13808
14123
  mountedRef.current = false;
@@ -13958,7 +14273,7 @@ function CanvasInner(props) {
13958
14273
  agent: hit.agent,
13959
14274
  depth: hit.depth
13960
14275
  });
13961
- (0, import_react13.useEffect)(() => {
14276
+ (0, import_react12.useEffect)(() => {
13962
14277
  setTitleResolver((sessionId) => renamedTitles[sessionId] ?? sessions.byId[sessionId]?.displayTitle);
13963
14278
  setCardTable(Object.entries(canvasState.cards).map(([cardId, card]) => ({
13964
14279
  cardId,
@@ -14068,11 +14383,11 @@ function CanvasInner(props) {
14068
14383
  canvas.moveCard(id2, point.x, point.y);
14069
14384
  });
14070
14385
  };
14071
- const selectedCardIds = (0, import_react13.useMemo)(
14386
+ const selectedCardIds = (0, import_react12.useMemo)(
14072
14387
  () => [...batchPicks].filter((id2) => visibleCards[id2] !== void 0),
14073
14388
  [batchPicks, visibleCards]
14074
14389
  );
14075
- const selectedFrameWs = (0, import_react13.useMemo)(
14390
+ const selectedFrameWs = (0, import_react12.useMemo)(
14076
14391
  () => [...liveSelectedIds].filter((id2) => id2.startsWith("frame-")).map((id2) => id2.slice("frame-".length)),
14077
14392
  [liveSelectedIds]
14078
14393
  );
@@ -14209,7 +14524,7 @@ function CanvasInner(props) {
14209
14524
  view: "root"
14210
14525
  });
14211
14526
  };
14212
- const menuState = (0, import_react13.useMemo)(() => {
14527
+ const menuState = (0, import_react12.useMemo)(() => {
14213
14528
  if (menu === null) return null;
14214
14529
  const close = () => {
14215
14530
  setMenu(null);
@@ -14734,8 +15049,8 @@ function BatchBar(props) {
14734
15049
  ] });
14735
15050
  }
14736
15051
  function MapCanvas(props) {
14737
- const canvasState = (0, import_react13.useSyncExternalStore)(canvas.subscribe, canvas.get);
14738
- (0, import_react13.useEffect)(() => {
15052
+ const canvasState = (0, import_react12.useSyncExternalStore)(canvas.subscribe, canvas.get);
15053
+ (0, import_react12.useEffect)(() => {
14739
15054
  canvas.ensureLoaded();
14740
15055
  canvas.refresh();
14741
15056
  return canvas.connect();
@@ -14768,7 +15083,7 @@ function MapCanvas(props) {
14768
15083
  // src/client/MapOverlay.tsx
14769
15084
  var import_jsx_runtime16 = require("react/jsx-runtime");
14770
15085
  function FontSizeButtons() {
14771
- const step2 = (0, import_react15.useSyncExternalStore)(fontScale.subscribe, fontScale.getSnapshot);
15086
+ const step2 = (0, import_react14.useSyncExternalStore)(fontScale.subscribe, fontScale.getSnapshot);
14772
15087
  return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: talk_map_default["fontGroup"], role: "group", "aria-label": t("font.group"), children: [
14773
15088
  /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
14774
15089
  "button",
@@ -14827,9 +15142,9 @@ function CloseIcon() {
14827
15142
  return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("path", { d: "M6 6l12 12M18 6L6 18" }) });
14828
15143
  }
14829
15144
  function MapOverlay(props) {
14830
- (0, import_react15.useSyncExternalStore)(subscribeLocale, activeLocale, activeLocale);
14831
- const fontStep = (0, import_react15.useSyncExternalStore)(fontScale.subscribe, fontScale.getSnapshot);
14832
- (0, import_react15.useEffect)(() => {
15145
+ (0, import_react14.useSyncExternalStore)(subscribeLocale, activeLocale, activeLocale);
15146
+ const fontStep = (0, import_react14.useSyncExternalStore)(fontScale.subscribe, fontScale.getSnapshot);
15147
+ (0, import_react14.useEffect)(() => {
14833
15148
  mapUi.setOpen(true);
14834
15149
  hideSidebarForMap();
14835
15150
  return () => {
@@ -14837,7 +15152,7 @@ function MapOverlay(props) {
14837
15152
  restoreSidebarAfterMap();
14838
15153
  };
14839
15154
  }, []);
14840
- (0, import_react15.useEffect)(() => {
15155
+ (0, import_react14.useEffect)(() => {
14841
15156
  const onKeyDown = (event) => {
14842
15157
  if (event.key !== "Escape") return;
14843
15158
  if (mapUi.escapeClaimed()) return;
@@ -14897,7 +15212,7 @@ function MapOverlay(props) {
14897
15212
  }
14898
15213
 
14899
15214
  // src/client/MapToggleButton.tsx
14900
- var import_react16 = require("react");
15215
+ var import_react15 = require("react");
14901
15216
  var import_jsx_runtime17 = require("react/jsx-runtime");
14902
15217
  function MapIcon() {
14903
15218
  return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("svg", { className: talk_map_default["toggleIcon"], viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
@@ -14907,10 +15222,10 @@ function MapIcon() {
14907
15222
  ] });
14908
15223
  }
14909
15224
  function MapToggleButton(props) {
14910
- const open = (0, import_react16.useSyncExternalStore)(mapUi.subscribe, () => mapUi.get().open);
14911
- const locale = (0, import_react16.useSyncExternalStore)(subscribeLocale, activeLocale, activeLocale);
15225
+ const open = (0, import_react15.useSyncExternalStore)(mapUi.subscribe, () => mapUi.get().open);
15226
+ const locale = (0, import_react15.useSyncExternalStore)(subscribeLocale, activeLocale, activeLocale);
14912
15227
  const wide = props.wide;
14913
- (0, import_react16.useEffect)(() => {
15228
+ (0, import_react15.useEffect)(() => {
14914
15229
  reportSidebarWide(wide);
14915
15230
  }, [wide]);
14916
15231
  const classNames = [wide ? talk_map_default["toggleRow"] : talk_map_default["toggleButton"]];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-talk-map",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
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",