@benz-ai-x/dsh-research-graph 0.2.2-rc.3 → 0.2.2-rc.3.1

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/README.md CHANGED
@@ -43,7 +43,7 @@ flowchart LR
43
43
  </a>
44
44
  </p>
45
45
 
46
- Version 0.2.2-rc.3 with demo data. Click the image for the full-resolution screenshot.
46
+ Version 0.2.2-rc.3.1 with demo data. Click the image for the full-resolution screenshot.
47
47
 
48
48
  <a id="features"></a>
49
49
  <a id="what-it-adds"></a>
@@ -67,7 +67,7 @@ Version 0.2.2-rc.3 with demo data. Click the image for the full-resolution scree
67
67
 
68
68
  | Item | Details |
69
69
  | --- | --- |
70
- | Plugin release | [0.2.2-rc.3](https://github.com/benz-ai-x/dsh-research-graph/releases/tag/v0.2.2-rc.3), npm `latest` / `next` |
70
+ | Plugin release | [0.2.2-rc.3.1](https://github.com/benz-ai-x/dsh-research-graph/releases/tag/v0.2.2-rc.3.1), npm `next` |
71
71
  | Required Host | **DSH 0.2.2-rc.3 · Web**, Node.js `>=24.9.0` |
72
72
  | Data | Research records and Workspace folders live on the DSH Host; view preferences and working positions stay in the browser, and Topic arrangements require explicit saving |
73
73
  | Model calls | Browsing, manual capture, and export make no model call; AI generation and new discussions use models on demand |
@@ -81,7 +81,7 @@ Version 0.2.2-rc.3 with demo data. Click the image for the full-resolution scree
81
81
  Requires **DSH 0.2.2-rc.3** (Node.js `>=24.9.0`), with both `dsh` and `pnpm` on your `PATH`. Stop any running `dsh web`, then run:
82
82
 
83
83
  ```sh
84
- dsh plugin --profile web add @benz-ai-x/dsh-research-graph@0.2.2-rc.3
84
+ dsh plugin --profile web add @benz-ai-x/dsh-research-graph@0.2.2-rc.3.1
85
85
  dsh web
86
86
  ```
87
87
 
@@ -95,7 +95,8 @@ Install a release that matches your DSH Host with `dsh plugin --profile web add
95
95
 
96
96
  | Plugin release | Required DSH | Notes |
97
97
  | --- | --- | --- |
98
- | `0.2.2-rc.3` | `0.2.2-rc.3` | Current release — reusable Workspace picker Factory and New Session HOC; requires Node.js `>=24.9.0`; npm `latest` / `next` |
98
+ | `0.2.2-rc.3.1` | `0.2.2-rc.3` | Current release — restores Branch links for independent ordinary forks; requires Node.js `>=24.9.0`; npm `next` |
99
+ | `0.2.2-rc.3` | `0.2.2-rc.3` | Reusable Workspace picker Factory and New Session HOC; requires Node.js `>=24.9.0` |
99
100
  | `0.2.2-rc.2` | `0.2.2-rc.2` | Previous release — DSH rc.2 compatibility and Menu anchor migration; requires Node.js `>=24.9.0` |
100
101
  | `0.2.2-rc.1` | `0.2.2-rc.1` | First adaptation of DSH 0.2.2-rc.1; requires Node.js `>=24.9.0` |
101
102
  | `0.2.1-rc.5.2` | `0.2.1-rc.5` | **Breaking change**: replaces the official sidebar with the vendored copy and Workspace folders (supersedes sidebar categories; old category data stays dormant) |
@@ -104,4 +105,4 @@ See the [full release history](https://github.com/benz-ai-x/dsh-research-graph/r
104
105
 
105
106
  ## Docs and support
106
107
 
107
- [User guide](docs/user-guide.md) · [Troubleshooting](docs/user-guide.md#troubleshooting) · [Development and release](docs/development.md) · [Release acceptance](docs/reviews/release-0.2.2-rc.3.md) · [Report an issue](https://github.com/benz-ai-x/dsh-research-graph/issues)
108
+ [User guide](docs/user-guide.md) · [Troubleshooting](docs/user-guide.md#troubleshooting) · [Development and release](docs/development.md) · [Release acceptance](docs/reviews/release-0.2.2-rc.3.1.md) · [Report an issue](https://github.com/benz-ai-x/dsh-research-graph/issues)
package/README.zh.md CHANGED
@@ -43,7 +43,7 @@ flowchart LR
43
43
  </a>
44
44
  </p>
45
45
 
46
- 0.2.2-rc.3 的真实界面(演示数据),点击图片查看高清原图。
46
+ 0.2.2-rc.3.1 的真实界面(演示数据),点击图片查看高清原图。
47
47
 
48
48
  <a id="核心能力"></a>
49
49
 
@@ -66,7 +66,7 @@ flowchart LR
66
66
 
67
67
  | 项目 | 说明 |
68
68
  | --- | --- |
69
- | 当前插件 | [0.2.2-rc.3](https://github.com/benz-ai-x/dsh-research-graph/releases/tag/v0.2.2-rc.3),npm `latest` / `next` |
69
+ | 当前插件 | [0.2.2-rc.3.1](https://github.com/benz-ai-x/dsh-research-graph/releases/tag/v0.2.2-rc.3.1),npm `next` |
70
70
  | 适配宿主 | **DSH 0.2.2-rc.3 · Web**,Node.js `>=24.9.0` |
71
71
  | 数据保存 | 研究数据与工作区文件夹保存在 DSH Host;视图偏好和工作位置保存在浏览器,主题排列需显式保存 |
72
72
  | 模型调用 | 浏览、手工留卡、导出不调用模型;AI 生成与新讨论按需调用 |
@@ -80,7 +80,7 @@ flowchart LR
80
80
  需要 **DSH 0.2.2-rc.3**(Node.js `>=24.9.0`),并确保 `dsh`、`pnpm` 均在 `PATH` 中。如有正在运行的 `dsh web`,先停止,再执行:
81
81
 
82
82
  ```sh
83
- dsh plugin --profile web add @benz-ai-x/dsh-research-graph@0.2.2-rc.3
83
+ dsh plugin --profile web add @benz-ai-x/dsh-research-graph@0.2.2-rc.3.1
84
84
  dsh web
85
85
  ```
86
86
 
@@ -94,7 +94,8 @@ dsh web
94
94
 
95
95
  | 插件版本 | 要求的 DSH | 备注 |
96
96
  | --- | --- | --- |
97
- | `0.2.2-rc.3` | `0.2.2-rc.3` | 当前版本——可复用 Workspace Picker Factory 与新会话 HOC,要求 Node.js `>=24.9.0`;npm `latest` / `next` |
97
+ | `0.2.2-rc.3.1` | `0.2.2-rc.3` | 当前版本——恢复独立普通 fork 的分支连线,要求 Node.js `>=24.9.0`;npm `next` |
98
+ | `0.2.2-rc.3` | `0.2.2-rc.3` | 可复用 Workspace Picker Factory 与新会话 HOC,要求 Node.js `>=24.9.0` |
98
99
  | `0.2.2-rc.2` | `0.2.2-rc.2` | 上一版本——适配 DSH rc.2 并迁移 Menu 锚点,要求 Node.js `>=24.9.0` |
99
100
  | `0.2.2-rc.1` | `0.2.2-rc.1` | DSH 0.2.2-rc.1 首次适配,要求 Node.js `>=24.9.0` |
100
101
  | `0.2.1-rc.5.2` | `0.2.1-rc.5` | **破坏性变更**:以自带侧栏替换官方侧栏并提供工作区文件夹(取代侧栏分类,旧分类数据保留但不再显示) |
@@ -103,4 +104,4 @@ dsh web
103
104
 
104
105
  ## 文档与支持
105
106
 
106
- [使用指南](docs/user-guide.zh.md) · [故障排查](docs/user-guide.zh.md#故障排查) · [开发与发布](docs/development.zh.md) · [发布验收](docs/reviews/release-0.2.2-rc.3.md) · [问题反馈](https://github.com/benz-ai-x/dsh-research-graph/issues)
107
+ [使用指南](docs/user-guide.zh.md) · [故障排查](docs/user-guide.zh.md#故障排查) · [开发与发布](docs/development.zh.md) · [发布验收](docs/reviews/release-0.2.2-rc.3.1.md) · [问题反馈](https://github.com/benz-ai-x/dsh-research-graph/issues)
package/lib/client.js CHANGED
@@ -118,13 +118,134 @@ window.__ModuleLoader__.load({
118
118
  }
119
119
  };
120
120
  }
121
+ // src/branch-links.ts
122
+ /** Bounded Session identity accepted from a wire or storage record. */
123
+ const MAX_SESSION_ID_CHARS = 200;
124
+ /** Validate one Session identity without importing Host brand helpers into the browser bundle. */
125
+ function branchOriginSessionId(value) {
126
+ if (typeof value !== "string" || value.length === 0 || value.length > MAX_SESSION_ID_CHARS) return void 0;
127
+ if (value.trim() !== value || value.includes("\0")) return void 0;
128
+ return value;
129
+ }
130
+ // src/branch-links-codec.ts
131
+ /** Small shared Branch Origin wire codecs; keep Host libraries out of the lazy browser bundle. */
132
+ function invalid$9() {
133
+ throw new TypeError("Invalid Branch Origin value");
134
+ }
135
+ function object$12(value, keys) {
136
+ if (value === null || typeof value !== "object" || Array.isArray(value)) return invalid$9();
137
+ const record = value;
138
+ if (Object.keys(record).some((key) => !keys.includes(key))) return invalid$9();
139
+ return record;
140
+ }
141
+ function sessionId(value) {
142
+ return branchOriginSessionId(value) ?? invalid$9();
143
+ }
144
+ function timestamp(value) {
145
+ if (typeof value !== "number" || !Number.isFinite(value) || value < 0) return invalid$9();
146
+ return value;
147
+ }
148
+ /** Parse one exact origin request supplied by the plugin that initiated a fork. */
149
+ function parseRecord(value) {
150
+ const item = object$12(value, ["childSessionId", "parentSessionId"]);
151
+ const childSessionId = sessionId(item.childSessionId);
152
+ const parentSessionId = sessionId(item.parentSessionId);
153
+ if (childSessionId === parentSessionId) return invalid$9();
154
+ return {
155
+ childSessionId,
156
+ parentSessionId
157
+ };
158
+ }
159
+ /** Parse one stored Branch Origin record. */
160
+ function parseOrigin(value) {
161
+ const item = object$12(value, [
162
+ "childSessionId",
163
+ "parentSessionId",
164
+ "source",
165
+ "createdAt"
166
+ ]);
167
+ const childSessionId = sessionId(item.childSessionId);
168
+ const parentSessionId = sessionId(item.parentSessionId);
169
+ if (childSessionId === parentSessionId) return invalid$9();
170
+ if (item.source !== "recorded" && item.source !== "inferred") return invalid$9();
171
+ return {
172
+ childSessionId,
173
+ parentSessionId,
174
+ source: item.source,
175
+ createdAt: timestamp(item.createdAt)
176
+ };
177
+ }
178
+ /** Parse one origin query; omitted `sessionIds` asks for every stored origin. */
179
+ function parseQuery(value) {
180
+ const item = object$12(value, ["sessionIds"]);
181
+ if (item.sessionIds === void 0) return {};
182
+ if (!Array.isArray(item.sessionIds) || item.sessionIds.length > 120) return invalid$9();
183
+ const sessionIds = item.sessionIds.map(sessionId);
184
+ return { sessionIds: [...new Set(sessionIds)] };
185
+ }
186
+ /** Parse one origin list response. */
187
+ function parseList(value) {
188
+ const item = object$12(value, ["origins"]);
189
+ if (!Array.isArray(item.origins) || item.origins.length > 120) return invalid$9();
190
+ return { origins: item.origins.map((value) => parseOrigin(value)) };
191
+ }
192
+ /** Wire/storage schema for one exact origin request. */
193
+ const branchOriginRecordSchema = { parse: parseRecord };
194
+ /** Wire/storage schema for one stored Branch Origin. */
195
+ const branchOriginSchema = { parse: parseOrigin };
196
+ /** Wire schema for one origin query. */
197
+ const branchOriginQuerySchema = { parse: parseQuery };
198
+ /** Wire schema for one origin list response. */
199
+ const branchOriginListSchema = { parse: parseList };
200
+ // src/client/branch-links-remote.ts
201
+ const PACKAGE_NAME$10 = "@benz-ai-x/dsh-research-graph";
202
+ /** Read all requested origins in bounded sequential batches. */
203
+ async function readBranchOriginMap(read, sessionIds, signal) {
204
+ const origins = [];
205
+ for (let start = 0; start < sessionIds.length; start += 120) origins.push(...await read({ sessionIds: sessionIds.slice(start, start + 120) }, signal));
206
+ return new Map(origins.map((origin) => [origin.childSessionId, origin.parentSessionId]));
207
+ }
208
+ const BRANCH_ORIGIN_REMOTE = {
209
+ package: PACKAGE_NAME$10,
210
+ descriptors: [{
211
+ method: "record",
212
+ request: branchOriginRecordSchema,
213
+ result: branchOriginSchema
214
+ }, {
215
+ method: "list",
216
+ request: branchOriginQuerySchema,
217
+ result: branchOriginListSchema
218
+ }].map(({ method, request, result }) => ({
219
+ id: `${PACKAGE_NAME$10}#sessionGraphBranchOrigin/${method}`,
220
+ service: "sessionGraphBranchOrigin",
221
+ namespace: "sessionGraphBranchOrigin",
222
+ method,
223
+ invocation: { kind: "direct" },
224
+ parameters: [{
225
+ name: "request",
226
+ wire: "request",
227
+ source: "json",
228
+ codec: {
229
+ mode: "strict",
230
+ typeSymbol: `${PACKAGE_NAME$10}#BranchOrigin/${method}/Request`,
231
+ create: () => request
232
+ }
233
+ }],
234
+ cancellation: { parameter: "signal" },
235
+ result: {
236
+ mode: "strict",
237
+ typeSymbol: `${PACKAGE_NAME$10}#BranchOrigin/${method}/Result`,
238
+ create: () => result
239
+ }
240
+ }))
241
+ };
121
242
  // src/client/build-info.ts
122
243
  /** Published package identity shown in the Graph header tooltip. */
123
244
  const SESSION_GRAPH_PACKAGE_NAME = "@benz-ai-x/dsh-research-graph";
124
245
  /** Package version from package.json at build time. */
125
- const SESSION_GRAPH_VERSION = "0.2.2-rc.3";
246
+ const SESSION_GRAPH_VERSION = "0.2.2-rc.3.1";
126
247
  /** Content-derived identifier for the exact local browser build. */
127
- const SESSION_GRAPH_BUILD_ID = "local-70cd4182";
248
+ const SESSION_GRAPH_BUILD_ID = "local-f77f15a1";
128
249
  /** Compact user-visible version badge. */
129
250
  const SESSION_GRAPH_BUILD_LABEL = `Research Graph v${SESSION_GRAPH_VERSION} · ${SESSION_GRAPH_BUILD_ID}`;
130
251
  /** Complete native-tooltip text for the version badge. */
@@ -5469,25 +5590,26 @@ window.__ModuleLoader__.load({
5469
5590
  * @param scope - the resolved graph scope, or undefined for the empty state.
5470
5591
  * @param viewedId - the Viewed Session (kept when blank, highlighted).
5471
5592
  * @param statuses - unified UI status facts (pending interaction, unread completion) keyed by Session id.
5593
+ * @param branchOrigins - plugin-owned child-to-parent origins for ordinary forks without Host parentage.
5472
5594
  * @returns the derived graph.
5473
5595
  */
5474
- function deriveSessionGraph(list, scope, viewedId, statuses) {
5596
+ function deriveSessionGraph(list, scope, viewedId, statuses, branchOrigins) {
5475
5597
  const visible = /* @__PURE__ */ new Map();
5476
5598
  if (scope !== void 0) for (const row of Object.values(list.byId)) {
5477
5599
  if (!scope.members.has(row.id)) continue;
5478
5600
  if (row.blank && row.id !== viewedId) continue;
5479
5601
  visible.set(row.id, row);
5480
5602
  }
5481
- return deriveRowsGraph(visible, viewedId, statuses);
5603
+ return deriveRowsGraph(visible, viewedId, statuses, void 0, void 0, branchOrigins);
5482
5604
  }
5483
5605
  /** Project explicit references without widening the scope-bound Canvas rules. */
5484
- function deriveTopicGraph(snapshot, list, viewedId, statuses) {
5606
+ function deriveTopicGraph(snapshot, list, viewedId, statuses, branchOrigins) {
5485
5607
  const sources = new Map(snapshot.sources.map((source) => [source.sessionId, source]));
5486
5608
  const visible = /* @__PURE__ */ new Map();
5487
5609
  for (const reference of snapshot.topic.references) {
5488
5610
  const source = sources.get(reference.sessionId);
5489
5611
  const row = source?.status === "listed" ? list.byId[reference.sessionId] : void 0;
5490
- const parent = source?.parentSessionId;
5612
+ const parent = row?.parentId ?? source?.parentSessionId ?? branchOrigins?.get(reference.sessionId);
5491
5613
  visible.set(reference.sessionId, {
5492
5614
  id: reference.sessionId,
5493
5615
  displayTitle: row?.displayTitle.trim() || reference.title,
@@ -5495,13 +5617,13 @@ window.__ModuleLoader__.load({
5495
5617
  running: row?.running ?? false,
5496
5618
  updatedAt: row?.updatedAt ?? 0,
5497
5619
  retainedBy: row?.retainedBy ?? {},
5498
- ...parent === void 0 || sources.get(parent)?.status !== "listed" ? {} : { parentId: parent },
5620
+ ...parent === void 0 ? {} : { parentId: parent },
5499
5621
  ...row?.projectionValues === void 0 ? {} : { projectionValues: row.projectionValues }
5500
5622
  });
5501
5623
  }
5502
- return deriveRowsGraph(visible, viewedId, statuses, sources, new Map(Object.values(list.byId).map((row) => [row.id, row])));
5624
+ return deriveRowsGraph(visible, viewedId, statuses, sources, new Map(Object.values(list.byId).map((row) => [row.id, row])), branchOrigins);
5503
5625
  }
5504
- function deriveRowsGraph(visible, viewedId, statuses, sources, hostRows) {
5626
+ function deriveRowsGraph(visible, viewedId, statuses, sources, hostRows, branchOrigins) {
5505
5627
  const badges = indexBadges(hostRows ?? visible);
5506
5628
  const nodes = /* @__PURE__ */ new Map();
5507
5629
  const children = /* @__PURE__ */ new Map();
@@ -5510,9 +5632,10 @@ window.__ModuleLoader__.load({
5510
5632
  const branchParent = /* @__PURE__ */ new Map();
5511
5633
  const branchChildren = /* @__PURE__ */ new Map();
5512
5634
  for (const row of visible.values()) {
5513
- if (row.origin === "subagent" || row.parentId === void 0) continue;
5514
- const parent = visible.get(row.parentId);
5515
- if (parent === void 0 || parent.origin === "subagent") continue;
5635
+ const parentId = row.parentId ?? branchOrigins?.get(row.id);
5636
+ if (row.origin === "subagent" || parentId === void 0) continue;
5637
+ const parent = visible.get(parentId);
5638
+ if (parent === void 0 || parent.origin === "subagent" || sources?.get(parent.id)?.status === "unavailable") continue;
5516
5639
  branchParent.set(row.id, parent.id);
5517
5640
  const siblings = branchChildren.get(parent.id);
5518
5641
  if (siblings === void 0) branchChildren.set(parent.id, [row]);
@@ -5525,7 +5648,7 @@ window.__ModuleLoader__.load({
5525
5648
  const status = statuses.get(row.id);
5526
5649
  const pending = status?.pendingInteraction !== void 0;
5527
5650
  const mergeSources = row.projectionValues?.sessionGraphMerge?.sources ?? [];
5528
- const inheritedMerge = (sources?.get(row.id)?.parentSessionId ?? hostRows?.get(row.id)?.parentId ?? row.parentId) !== void 0;
5651
+ const inheritedMerge = sources?.get(row.id)?.parentSessionId !== void 0 || hostRows?.get(row.id)?.parentId !== void 0 || row.parentId !== void 0 || branchOrigins?.has(row.id) === true;
5529
5652
  const projections = row.projectionValues;
5530
5653
  const stats = projections?.sessionStats;
5531
5654
  const model = projections?.modelSelection?.next ?? projections?.modelSelection?.lastUsed ?? void 0;
@@ -9743,6 +9866,23 @@ window.__ModuleLoader__.load({
9743
9866
  sessionIds: topic.references.map((item) => item.sessionId)
9744
9867
  }, revision + (reuse?.refresh ?? 0));
9745
9868
  const membership = JSON.stringify(topic.references.map((reference) => reference.sessionId));
9869
+ const [branchOrigins, setBranchOrigins] = (0, react.useState)(() => /* @__PURE__ */ new Map());
9870
+ const readBranchOrigins = context.actions.readBranchOrigins;
9871
+ (0, react.useEffect)(() => {
9872
+ if (readBranchOrigins === void 0) return;
9873
+ const controller = new AbortController();
9874
+ const sessionIds = topic.references.map((reference) => reference.sessionId);
9875
+ readBranchOriginMap(readBranchOrigins, sessionIds, controller.signal).then((origins) => {
9876
+ if (controller.signal.aborted) return;
9877
+ setBranchOrigins(origins);
9878
+ }, () => {
9879
+ if (controller.signal.aborted) return;
9880
+ setBranchOrigins((current) => current.size === 0 ? current : /* @__PURE__ */ new Map());
9881
+ });
9882
+ return () => {
9883
+ controller.abort();
9884
+ };
9885
+ }, [membership, readBranchOrigins]);
9746
9886
  const read = context.actions.topics.read;
9747
9887
  const searchCards = knowledge.api.search;
9748
9888
  const readCard = knowledge.api.read;
@@ -9791,7 +9931,7 @@ window.__ModuleLoader__.load({
9791
9931
  } }
9792
9932
  })),
9793
9933
  topic: snapshot.topic
9794
- }, context.sessions, context.viewedId, context.sessionStatus), [...cards, ...sourceCards], context.sessions, archived), relations.relations, context.sessions, context.workspaces);
9934
+ }, context.sessions, context.viewedId, context.sessionStatus, branchOrigins), [...cards, ...sourceCards], context.sessions, archived), relations.relations, context.sessions, context.workspaces);
9795
9935
  }, [
9796
9936
  snapshot,
9797
9937
  context.sessions,
@@ -9800,7 +9940,8 @@ window.__ModuleLoader__.load({
9800
9940
  context.sessionStatus,
9801
9941
  cards,
9802
9942
  sourceCards,
9803
- relations.relations
9943
+ relations.relations,
9944
+ branchOrigins
9804
9945
  ]);
9805
9946
  const laid = (0, react.useMemo)(() => graph === void 0 ? void 0 : layoutSessionGraph(graph), [graph]);
9806
9947
  const [presented, setPresented] = (0, react.useState)();
@@ -10509,7 +10650,7 @@ window.__ModuleLoader__.load({
10509
10650
  });
10510
10651
  }
10511
10652
  function GraphViewBody(props) {
10512
- const { sessionId, useSessions, useSessionStatus, useWorkspaces, hostId, openSession, branchSession, generateSessionDigest, readSessionHistory, searchDiscussion, mergeSessions, retrySessionMerge, topics, knowledge, reuse, t } = props;
10653
+ const { sessionId, useSessions, useSessionStatus, useWorkspaces, hostId, openSession, branchSession, generateSessionDigest, readSessionHistory, searchDiscussion, mergeSessions, retrySessionMerge, topics, knowledge, reuse, readBranchOrigins, t } = props;
10513
10654
  const knowledgeContext = useKnowledge();
10514
10655
  const sessions = useSessions((state) => state);
10515
10656
  const sessionStatus = useSessionStatus((state) => state);
@@ -10557,11 +10698,40 @@ window.__ModuleLoader__.load({
10557
10698
  sessions,
10558
10699
  workspaces
10559
10700
  ]);
10560
- const graph = (0, react.useMemo)(() => deriveSessionGraph(sessions, scope, sessionId, sessionStatus), [
10701
+ const [branchOrigins, setBranchOrigins] = (0, react.useState)(() => /* @__PURE__ */ new Map());
10702
+ const [branchOriginRevision, setBranchOriginRevision] = (0, react.useState)(0);
10703
+ const createBranch = async (id) => {
10704
+ await branchSession(id);
10705
+ setBranchOriginRevision((value) => value + 1);
10706
+ };
10707
+ const scopeSessionKey = (0, react.useMemo)(() => scope === void 0 ? "" : [...scope.members].sort().join("\0"), [scope]);
10708
+ (0, react.useEffect)(() => {
10709
+ if (scope === void 0 || readBranchOrigins === void 0) {
10710
+ setBranchOrigins((current) => current.size === 0 ? current : /* @__PURE__ */ new Map());
10711
+ return;
10712
+ }
10713
+ const controller = new AbortController();
10714
+ readBranchOriginMap(readBranchOrigins, [...scope.members], controller.signal).then((origins) => {
10715
+ if (controller.signal.aborted) return;
10716
+ setBranchOrigins(origins);
10717
+ }, () => {
10718
+ if (controller.signal.aborted) return;
10719
+ setBranchOrigins((current) => current.size === 0 ? current : /* @__PURE__ */ new Map());
10720
+ });
10721
+ return () => {
10722
+ controller.abort();
10723
+ };
10724
+ }, [
10725
+ scopeSessionKey,
10726
+ readBranchOrigins,
10727
+ branchOriginRevision
10728
+ ]);
10729
+ const graph = (0, react.useMemo)(() => deriveSessionGraph(sessions, scope, sessionId, sessionStatus, branchOrigins), [
10561
10730
  sessions,
10562
10731
  scope,
10563
10732
  sessionId,
10564
- sessionStatus
10733
+ sessionStatus,
10734
+ branchOrigins
10565
10735
  ]);
10566
10736
  const laid = (0, react.useMemo)(() => layoutSessionGraph(graph), [graph]);
10567
10737
  const refreshSessionProjections = props.refreshSessionProjections;
@@ -10846,7 +11016,7 @@ window.__ModuleLoader__.load({
10846
11016
  t,
10847
11017
  onOpen: openSession,
10848
11018
  onOpenSubagent: props.openSubagent,
10849
- onBranch: branchSession,
11019
+ onBranch: createBranch,
10850
11020
  onGenerateDigest: generateSessionDigest,
10851
11021
  onGenerateTitle: props.generateSessionTitle,
10852
11022
  onRenameTitle: props.renameSessionTitle,
@@ -20503,7 +20673,8 @@ window.__ModuleLoader__.load({
20503
20673
  ...WORKSPACE_FOLDERS_REMOTE.descriptors,
20504
20674
  ...KNOWLEDGE_REMOTE.descriptors,
20505
20675
  ...RESEARCH_REUSE_REMOTE.descriptors,
20506
- ...HISTORY_BRANCH_REMOTE.descriptors
20676
+ ...HISTORY_BRANCH_REMOTE.descriptors,
20677
+ ...BRANCH_ORIGIN_REMOTE.descriptors
20507
20678
  ]
20508
20679
  };
20509
20680
  /** Register the Graph view after its dynamically mounted Remote is injectable. */
@@ -20716,6 +20887,11 @@ window.__ModuleLoader__.load({
20716
20887
  if (!result.ok) throw new Error(result.error.message);
20717
20888
  return result.value;
20718
20889
  },
20890
+ readBranchOrigins: async (request, signal) => {
20891
+ const result = await ctx.remote.sessionGraphBranchOrigin.list(request, signal);
20892
+ if (!result.ok) throw new Error(result.error.message);
20893
+ return result.value.origins;
20894
+ },
20719
20895
  openSession: (id) => {
20720
20896
  ctx.uiWorkspace.openSession(id);
20721
20897
  },
@@ -20736,10 +20912,16 @@ window.__ModuleLoader__.load({
20736
20912
  });
20737
20913
  },
20738
20914
  branchSession: async (id) => {
20739
- await ctx.sessions.fork({
20915
+ const childId = await ctx.sessions.fork({
20740
20916
  sessionId: id,
20741
20917
  increaseTitle: true
20742
20918
  });
20919
+ try {
20920
+ await ctx.remote.sessionGraphBranchOrigin.record({
20921
+ childSessionId: childId,
20922
+ parentSessionId: id
20923
+ });
20924
+ } catch {}
20743
20925
  },
20744
20926
  generateSessionDigest: async (id, options, signal) => {
20745
20927
  const result = await ctx.remote.sessionGraphDigest.generate({
@@ -20830,7 +21012,8 @@ window.__ModuleLoader__.load({
20830
21012
  "remote.sessionGraphFolders",
20831
21013
  "remote.sessionGraphKnowledge",
20832
21014
  "remote.sessionGraphReuse",
20833
- "remote.sessionGraphBranch"
21015
+ "remote.sessionGraphBranch",
21016
+ "remote.sessionGraphBranchOrigin"
20834
21017
  ], registerUi);
20835
21018
  try {
20836
21019
  await ui;