@runfusion/fusion 0.23.0 → 0.24.0

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 (204) hide show
  1. package/dist/bin.js +26610 -20597
  2. package/dist/client/assets/AgentDetailView-BwJaLqZh.css +1 -0
  3. package/dist/client/assets/AgentDetailView-gy_5SUj2.js +18 -0
  4. package/dist/client/assets/AgentsView-BkB9FiMT.js +29 -0
  5. package/dist/client/assets/{AgentsView-DSGQWObq.css → AgentsView-CV3vm7Qk.css} +1 -1
  6. package/dist/client/assets/ChatView-B_-B8fqu.js +1 -0
  7. package/dist/client/assets/ChatView-DwJAd5G1.css +1 -0
  8. package/dist/client/assets/{DevServerView-C9lzHrcT.js → DevServerView-BkvtjZBa.js} +1 -1
  9. package/dist/client/assets/{DirectoryPicker-aVdFaV37.js → DirectoryPicker-BK-KbnhP.js} +1 -1
  10. package/dist/client/assets/{DocumentsView-DIpg3NSP.js → DocumentsView-BEg1CQAk.js} +1 -1
  11. package/dist/client/assets/{DocumentsView-BrhyOdeE.css → DocumentsView-gv4zG3aT.css} +1 -1
  12. package/dist/client/assets/EvalsView-Berf9bQm.js +1 -0
  13. package/dist/client/assets/EvalsView-CUNJ1TLc.css +1 -0
  14. package/dist/client/assets/{agentSkills-DDHJnrkn.css → ExperimentalAgentOnboardingModal-B-APN_lM.css} +1 -1
  15. package/dist/client/assets/ExperimentalAgentOnboardingModal-jcInE50G.js +499 -0
  16. package/dist/client/assets/InsightsView-B0J4mhzV.css +1 -0
  17. package/dist/client/assets/InsightsView-BX5bSF1J.js +11 -0
  18. package/dist/client/assets/{MemoryView-nXlTqebk.js → MemoryView-CKElJY_3.js} +2 -2
  19. package/dist/client/assets/NodesView-DLUOBLf6.js +14 -0
  20. package/dist/client/assets/NodesView-DT4pXowv.css +1 -0
  21. package/dist/client/assets/{PiExtensionsManager-Buopv-jb.js → PiExtensionsManager-COlJf0Kx.js} +2 -2
  22. package/dist/client/assets/PluginManager-CfW55BF4.js +1 -0
  23. package/dist/client/assets/PluginManager-DtRQXia5.css +1 -0
  24. package/dist/client/assets/{ResearchView-_BHXUv2j.js → ResearchView-B256Lr8I.js} +1 -1
  25. package/dist/client/assets/SettingsModal-BeA_nQtW.js +31 -0
  26. package/dist/client/assets/SettingsModal-DzsLquBu.css +1 -0
  27. package/dist/client/assets/{SettingsModal-C89Ikhfm.js → SettingsModal-yRqM4DV8.js} +1 -1
  28. package/dist/client/assets/SetupWizardModal-uUZk3TKT.js +1 -0
  29. package/dist/client/assets/{SkillsView-hDpTBdFT.js → SkillsView-CP8JX0P_.js} +1 -1
  30. package/dist/client/assets/TodoView-Cx9cVhq7.css +1 -0
  31. package/dist/client/assets/TodoView-DCRIkDZ-.js +6 -0
  32. package/dist/client/assets/createLucideIcon-BazL2hk5.js +21 -0
  33. package/dist/client/assets/dashboard-view-BkTMSZYn.css +1 -0
  34. package/dist/client/assets/dashboard-view-CyWN-d02.js +63 -0
  35. package/dist/client/assets/dashboard-view-lR7YYmSC.js +21 -0
  36. package/dist/client/assets/{folder-open-usZkXdq2.js → folder-open-DHjELt8-.js} +1 -1
  37. package/dist/client/assets/index-CQyVRLOb.js +692 -0
  38. package/dist/client/assets/index-CxA2Nn0_.css +1 -0
  39. package/dist/client/assets/projectDetection-G3XuxD2X.js +1 -0
  40. package/dist/client/assets/{star-BAT_ObKE.js → star-DYesq1AV.js} +1 -1
  41. package/dist/client/assets/{upload-BC2YKNEV.js → upload-DTWF3Db5.js} +1 -1
  42. package/dist/client/assets/{users-Dkd4rtrN.js → users--syrel4l.js} +1 -1
  43. package/dist/client/index.html +12 -20
  44. package/dist/client/theme-data.css +106 -0
  45. package/dist/client/version.json +1 -1
  46. package/dist/droid-cli/package.json +1 -1
  47. package/dist/extension.js +14287 -9568
  48. package/dist/pi-claude-cli/package.json +1 -1
  49. package/dist/plugins/fusion-plugin-cursor-runtime/bundled.js +218 -0
  50. package/dist/plugins/fusion-plugin-cursor-runtime/manifest.json +6 -0
  51. package/dist/plugins/fusion-plugin-cursor-runtime/package.json +11 -0
  52. package/dist/plugins/fusion-plugin-dependency-graph/manifest.json +1 -1
  53. package/dist/plugins/fusion-plugin-dependency-graph/package.json +6 -4
  54. package/dist/plugins/fusion-plugin-dependency-graph/src/DependencyGraph.css +58 -0
  55. package/dist/plugins/fusion-plugin-dependency-graph/src/DependencyGraph.tsx +301 -0
  56. package/dist/plugins/fusion-plugin-dependency-graph/src/GraphHighlight.css +27 -0
  57. package/dist/plugins/fusion-plugin-dependency-graph/src/GraphTaskNode.css +157 -0
  58. package/dist/plugins/fusion-plugin-dependency-graph/src/GraphTaskNode.tsx +126 -0
  59. package/dist/plugins/fusion-plugin-dependency-graph/src/GraphToolbar.css +35 -0
  60. package/dist/plugins/fusion-plugin-dependency-graph/src/GraphToolbar.tsx +36 -0
  61. package/dist/plugins/fusion-plugin-dependency-graph/src/__tests__/DependencyGraph.highlighting.test.tsx +112 -0
  62. package/dist/plugins/fusion-plugin-dependency-graph/src/__tests__/DependencyGraph.persistence.test.tsx +115 -0
  63. package/dist/plugins/fusion-plugin-dependency-graph/src/__tests__/DependencyGraph.test.tsx +128 -0
  64. package/dist/plugins/fusion-plugin-dependency-graph/src/__tests__/GraphTaskNode.drag.test.tsx +82 -0
  65. package/dist/plugins/fusion-plugin-dependency-graph/src/__tests__/GraphTaskNode.test.tsx +307 -0
  66. package/dist/plugins/fusion-plugin-dependency-graph/src/__tests__/GraphToolbar.test.tsx +60 -0
  67. package/dist/plugins/fusion-plugin-dependency-graph/src/__tests__/edges.test.tsx +75 -0
  68. package/dist/plugins/fusion-plugin-dependency-graph/src/__tests__/filtering.test.tsx +62 -0
  69. package/dist/plugins/fusion-plugin-dependency-graph/src/__tests__/filters.test.ts +78 -0
  70. package/dist/plugins/fusion-plugin-dependency-graph/src/__tests__/graphPositionStorage.test.ts +95 -0
  71. package/dist/plugins/fusion-plugin-dependency-graph/src/__tests__/host-integration.test.ts +74 -0
  72. package/dist/plugins/fusion-plugin-dependency-graph/src/__tests__/index.test.ts +58 -0
  73. package/dist/plugins/fusion-plugin-dependency-graph/src/__tests__/interactions.test.tsx +121 -0
  74. package/dist/plugins/fusion-plugin-dependency-graph/src/__tests__/layout.test.ts +70 -0
  75. package/dist/plugins/fusion-plugin-dependency-graph/src/__tests__/persistence.test.tsx +89 -0
  76. package/dist/plugins/fusion-plugin-dependency-graph/src/__tests__/useGraphData.test.ts +86 -0
  77. package/dist/plugins/fusion-plugin-dependency-graph/src/__tests__/useGraphInteraction.test.ts +167 -0
  78. package/dist/plugins/fusion-plugin-dependency-graph/src/__tests__/useGraphPositions.test.ts +66 -0
  79. package/dist/plugins/fusion-plugin-dependency-graph/src/__tests__/useNodeDrag.test.ts +81 -0
  80. package/dist/plugins/fusion-plugin-dependency-graph/src/dashboard-interop.d.ts +35 -0
  81. package/dist/plugins/fusion-plugin-dependency-graph/src/dashboard-view.tsx +19 -0
  82. package/dist/plugins/fusion-plugin-dependency-graph/src/edges.tsx +70 -0
  83. package/dist/plugins/fusion-plugin-dependency-graph/src/filters.ts +8 -0
  84. package/dist/plugins/fusion-plugin-dependency-graph/src/hooks/__tests__/useDependencyChain.test.ts +53 -0
  85. package/dist/plugins/fusion-plugin-dependency-graph/src/hooks/useDependencyChain.ts +60 -0
  86. package/dist/plugins/fusion-plugin-dependency-graph/src/hooks/useGraphPositions.ts +45 -0
  87. package/dist/plugins/fusion-plugin-dependency-graph/src/hooks/useNodeDrag.ts +114 -0
  88. package/dist/plugins/fusion-plugin-dependency-graph/src/index.ts +1 -2
  89. package/dist/plugins/fusion-plugin-dependency-graph/src/layout.ts +91 -0
  90. package/dist/plugins/fusion-plugin-dependency-graph/src/styles/drag.css +15 -0
  91. package/dist/plugins/fusion-plugin-dependency-graph/src/types.ts +21 -0
  92. package/dist/plugins/fusion-plugin-dependency-graph/src/useGraphData.ts +17 -0
  93. package/dist/plugins/fusion-plugin-dependency-graph/src/useGraphInteraction.ts +292 -0
  94. package/dist/plugins/fusion-plugin-dependency-graph/src/utils/graphPositionStorage.ts +65 -0
  95. package/dist/plugins/fusion-plugin-droid-runtime/bundled.js +136680 -0
  96. package/dist/plugins/fusion-plugin-droid-runtime/manifest.json +13 -0
  97. package/dist/plugins/fusion-plugin-droid-runtime/mcp-schema-server.cjs +49 -0
  98. package/dist/plugins/fusion-plugin-droid-runtime/package.json +11 -0
  99. package/dist/plugins/fusion-plugin-hermes-runtime/package.json +1 -1
  100. package/dist/plugins/fusion-plugin-openclaw-runtime/bundled.js +93 -6
  101. package/dist/plugins/fusion-plugin-openclaw-runtime/mcp-schema-server.cjs +59 -0
  102. package/dist/plugins/fusion-plugin-openclaw-runtime/package.json +1 -1
  103. package/dist/plugins/fusion-plugin-paperclip-runtime/package.json +1 -1
  104. package/dist/plugins/fusion-plugin-reports/manifest.json +33 -0
  105. package/dist/plugins/fusion-plugin-reports/package.json +26 -0
  106. package/dist/plugins/fusion-plugin-reports/src/__tests__/manifest.test.ts +51 -0
  107. package/dist/plugins/fusion-plugin-reports/src/__tests__/review-panel.test.ts +166 -0
  108. package/dist/plugins/fusion-plugin-reports/src/__tests__/settings.test.ts +157 -0
  109. package/dist/plugins/fusion-plugin-reports/src/index.ts +41 -0
  110. package/dist/plugins/fusion-plugin-reports/src/review-panel.ts +294 -0
  111. package/dist/plugins/fusion-plugin-reports/src/review-types.ts +75 -0
  112. package/dist/plugins/fusion-plugin-reports/src/settings.ts +105 -0
  113. package/dist/plugins/fusion-plugin-roadmap/manifest.json +16 -0
  114. package/dist/plugins/fusion-plugin-roadmap/package.json +48 -0
  115. package/dist/plugins/fusion-plugin-roadmap/src/__tests__/api-client.test.ts +101 -0
  116. package/dist/plugins/fusion-plugin-roadmap/src/__tests__/index.test.ts +92 -0
  117. package/dist/plugins/fusion-plugin-roadmap/src/__tests__/roadmap-routes.test.ts +48 -0
  118. package/dist/plugins/fusion-plugin-roadmap/src/__tests__/roadmap-suggestions.test.ts +31 -0
  119. package/dist/plugins/fusion-plugin-roadmap/src/dashboard/RoadmapsView.css +1299 -0
  120. package/dist/plugins/fusion-plugin-roadmap/src/dashboard/RoadmapsView.tsx +2559 -0
  121. package/dist/plugins/fusion-plugin-roadmap/src/dashboard/__tests__/RoadmapsView.test.tsx +1144 -0
  122. package/dist/plugins/fusion-plugin-roadmap/src/dashboard/__tests__/useRoadmaps.test.ts +1756 -0
  123. package/dist/plugins/fusion-plugin-roadmap/src/dashboard/api.ts +70 -0
  124. package/dist/plugins/fusion-plugin-roadmap/src/dashboard/test-setup.ts +7 -0
  125. package/dist/plugins/fusion-plugin-roadmap/src/dashboard/types.ts +1 -0
  126. package/dist/plugins/fusion-plugin-roadmap/src/dashboard/useConfirm.ts +8 -0
  127. package/dist/plugins/fusion-plugin-roadmap/src/dashboard/useRoadmaps.ts +1188 -0
  128. package/dist/plugins/fusion-plugin-roadmap/src/dashboard/useViewportMode.ts +20 -0
  129. package/dist/plugins/fusion-plugin-roadmap/src/dashboard-view.tsx +6 -0
  130. package/dist/plugins/fusion-plugin-roadmap/src/index.ts +74 -0
  131. package/dist/plugins/fusion-plugin-roadmap/src/roadmap-routes.ts +1 -0
  132. package/dist/plugins/fusion-plugin-roadmap/src/roadmap-schema.ts +41 -0
  133. package/dist/plugins/fusion-plugin-roadmap/src/roadmap-suggestions.d.ts +15 -0
  134. package/dist/plugins/fusion-plugin-roadmap/src/roadmap-suggestions.ts +15 -0
  135. package/dist/plugins/fusion-plugin-roadmap/src/roadmap-types.d.ts +283 -0
  136. package/dist/plugins/fusion-plugin-roadmap/src/roadmap-types.d.ts.map +1 -0
  137. package/dist/plugins/fusion-plugin-roadmap/src/roadmap-types.js +21 -0
  138. package/dist/plugins/fusion-plugin-roadmap/src/roadmap-types.js.map +1 -0
  139. package/dist/plugins/fusion-plugin-roadmap/src/roadmap-types.ts +310 -0
  140. package/dist/plugins/fusion-plugin-roadmap/src/routes/roadmap-routes.d.ts +5 -0
  141. package/dist/plugins/fusion-plugin-roadmap/src/routes/roadmap-routes.d.ts.map +1 -0
  142. package/dist/plugins/fusion-plugin-roadmap/src/routes/roadmap-routes.js +361 -0
  143. package/dist/plugins/fusion-plugin-roadmap/src/routes/roadmap-routes.js.map +1 -0
  144. package/dist/plugins/fusion-plugin-roadmap/src/routes/roadmap-routes.ts +408 -0
  145. package/dist/plugins/fusion-plugin-roadmap/src/routes/roadmap-suggestions.d.ts +68 -0
  146. package/dist/plugins/fusion-plugin-roadmap/src/routes/roadmap-suggestions.d.ts.map +1 -0
  147. package/dist/plugins/fusion-plugin-roadmap/src/routes/roadmap-suggestions.js +300 -0
  148. package/dist/plugins/fusion-plugin-roadmap/src/routes/roadmap-suggestions.js.map +1 -0
  149. package/dist/plugins/fusion-plugin-roadmap/src/routes/roadmap-suggestions.ts +381 -0
  150. package/dist/plugins/fusion-plugin-roadmap/src/server/index.d.ts +3 -0
  151. package/dist/plugins/fusion-plugin-roadmap/src/server/index.ts +1 -0
  152. package/dist/plugins/fusion-plugin-roadmap/src/store/__tests__/roadmap-handoff.test.ts +445 -0
  153. package/dist/plugins/fusion-plugin-roadmap/src/store/__tests__/roadmap-ordering.test.ts +334 -0
  154. package/dist/plugins/fusion-plugin-roadmap/src/store/__tests__/roadmap-store.test.ts +1318 -0
  155. package/dist/plugins/fusion-plugin-roadmap/src/store/roadmap-handoff.ts +163 -0
  156. package/dist/plugins/fusion-plugin-roadmap/src/store/roadmap-ordering.d.ts +37 -0
  157. package/dist/plugins/fusion-plugin-roadmap/src/store/roadmap-ordering.d.ts.map +1 -0
  158. package/dist/plugins/fusion-plugin-roadmap/src/store/roadmap-ordering.js +188 -0
  159. package/dist/plugins/fusion-plugin-roadmap/src/store/roadmap-ordering.js.map +1 -0
  160. package/dist/plugins/fusion-plugin-roadmap/src/store/roadmap-ordering.ts +311 -0
  161. package/dist/plugins/fusion-plugin-roadmap/src/store/roadmap-store.d.ts +299 -0
  162. package/dist/plugins/fusion-plugin-roadmap/src/store/roadmap-store.d.ts.map +1 -0
  163. package/dist/plugins/fusion-plugin-roadmap/src/store/roadmap-store.js +765 -0
  164. package/dist/plugins/fusion-plugin-roadmap/src/store/roadmap-store.js.map +1 -0
  165. package/dist/plugins/fusion-plugin-roadmap/src/store/roadmap-store.ts +1001 -0
  166. package/dist/plugins/fusion-plugin-whatsapp-chat/manifest.json +8 -0
  167. package/dist/plugins/fusion-plugin-whatsapp-chat/package.json +34 -0
  168. package/dist/plugins/fusion-plugin-whatsapp-chat/src/__tests__/auth-state.test.ts +99 -0
  169. package/dist/plugins/fusion-plugin-whatsapp-chat/src/__tests__/connection.test.ts +145 -0
  170. package/dist/plugins/fusion-plugin-whatsapp-chat/src/__tests__/index.test.ts +216 -0
  171. package/dist/plugins/fusion-plugin-whatsapp-chat/src/__tests__/reply.test.ts +52 -0
  172. package/dist/plugins/fusion-plugin-whatsapp-chat/src/auth-state.ts +89 -0
  173. package/dist/plugins/fusion-plugin-whatsapp-chat/src/connection.ts +253 -0
  174. package/dist/plugins/fusion-plugin-whatsapp-chat/src/index.ts +262 -0
  175. package/dist/plugins/fusion-plugin-whatsapp-chat/src/qrcode.d.ts +1 -0
  176. package/dist/plugins/fusion-plugin-whatsapp-chat/src/reply.ts +37 -0
  177. package/package.json +2 -2
  178. package/skill/fusion/SKILL.md +2 -2
  179. package/skill/fusion/references/engine-tools.md +3 -0
  180. package/skill/fusion/references/extension-tools.md +39 -0
  181. package/skill/fusion/references/fusion-capabilities.md +3 -0
  182. package/dist/client/assets/AgentDetailView-C1XceMgi.js +0 -18
  183. package/dist/client/assets/AgentDetailView-CeO_1MK7.css +0 -1
  184. package/dist/client/assets/AgentsView-Deh125ss.js +0 -527
  185. package/dist/client/assets/ChatView-7D_RQDqT.js +0 -1
  186. package/dist/client/assets/InsightsView-AWo5o_81.css +0 -1
  187. package/dist/client/assets/InsightsView-jKjEFAx_.js +0 -11
  188. package/dist/client/assets/NodesView-Di2SvOhg.js +0 -14
  189. package/dist/client/assets/NodesView-fXqDk9ur.css +0 -1
  190. package/dist/client/assets/PluginManager-B9-NbQ8f.js +0 -1
  191. package/dist/client/assets/PluginManager-C1DbPaar.css +0 -1
  192. package/dist/client/assets/RoadmapsView-DHWjUoc8.js +0 -6
  193. package/dist/client/assets/SettingsModal-DHitIpsa.css +0 -1
  194. package/dist/client/assets/SettingsModal-DR_yirvK.js +0 -31
  195. package/dist/client/assets/SetupWizardModal-BtDMY9pa.js +0 -1
  196. package/dist/client/assets/agentSkills-B-w5wFHh.js +0 -1
  197. package/dist/client/assets/index-Bc6ZdGMz.css +0 -1
  198. package/dist/client/assets/index-D__RMku8.js +0 -694
  199. package/dist/plugins/fusion-plugin-dependency-graph/src/DependencyGraphView.css +0 -141
  200. package/dist/plugins/fusion-plugin-dependency-graph/src/DependencyGraphView.tsx +0 -428
  201. package/dist/plugins/fusion-plugin-dependency-graph/src/__tests__/DependencyGraphView.test.tsx +0 -261
  202. package/dist/plugins/fusion-plugin-dependency-graph/src/__tests__/storage.test.ts +0 -41
  203. package/dist/plugins/fusion-plugin-dependency-graph/src/storage.ts +0 -22
  204. /package/dist/client/assets/{RoadmapsView-DdGlfuu-.css → dashboard-view-DdGlfuu-.css} +0 -0
@@ -0,0 +1,86 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { renderHook } from "@testing-library/react";
3
+ import type { Task } from "@fusion/core";
4
+ import { useGraphData } from "../useGraphData";
5
+
6
+ function createTask(id: string, column: Task["column"] = "todo", dependencies: string[] = []): Task {
7
+ return {
8
+ id,
9
+ description: id,
10
+ column,
11
+ dependencies,
12
+ steps: [],
13
+ currentStep: 0,
14
+ log: [],
15
+ } as Task;
16
+ }
17
+
18
+ describe("useGraphData", () => {
19
+ it("returns empty graph for empty tasks", () => {
20
+ const { result } = renderHook(() => useGraphData([]));
21
+ expect(result.current).toEqual({ nodes: [], edges: [] });
22
+ });
23
+
24
+ it("creates node for single task with no deps", () => {
25
+ const { result } = renderHook(() => useGraphData([createTask("A")]));
26
+ expect(result.current.nodes.map((node) => node.task.id)).toEqual(["A"]);
27
+ expect(result.current.edges).toEqual([]);
28
+ });
29
+
30
+ describe("orphan dependencies to excluded tasks", () => {
31
+ it("drops dependency edge to done task while keeping dependent node", () => {
32
+ const filteredTasks = [createTask("A", "in-progress", ["DONE-1"])];
33
+ const { result } = renderHook(() => useGraphData(filteredTasks));
34
+
35
+ expect(result.current.nodes.map((node) => node.task.id)).toEqual(["A"]);
36
+ expect(result.current.edges).toEqual([]);
37
+ });
38
+
39
+ it("drops dependency edge to archived task while keeping dependent node", () => {
40
+ const filteredTasks = [createTask("A", "triage", ["ARCH-1"])];
41
+ const { result } = renderHook(() => useGraphData(filteredTasks));
42
+
43
+ expect(result.current.nodes.map((node) => node.task.id)).toEqual(["A"]);
44
+ expect(result.current.edges).toEqual([]);
45
+ });
46
+
47
+ it("keeps only included dependency edges when mixed dependencies are present", () => {
48
+ const filteredTasks = [createTask("A", "in-progress", ["B", "DONE-1", "ARCH-1"]), createTask("B", "todo")];
49
+ const { result } = renderHook(() => useGraphData(filteredTasks));
50
+
51
+ expect(result.current.nodes.map((node) => node.task.id)).toEqual(["A", "B"]);
52
+ expect(result.current.edges).toEqual([{ source: "A", target: "B" }]);
53
+ });
54
+
55
+ it("shows zero edges when all dependencies are excluded", () => {
56
+ const filteredTasks = [createTask("A", "in-progress", ["DONE-1", "ARCH-1"])];
57
+ const { result } = renderHook(() => useGraphData(filteredTasks));
58
+
59
+ expect(result.current.nodes.map((node) => node.task.id)).toEqual(["A"]);
60
+ expect(result.current.edges).toEqual([]);
61
+ });
62
+ });
63
+
64
+ describe("in-review dependency edges", () => {
65
+ it("renders edges between in-review tasks", () => {
66
+ const tasks = [createTask("A", "in-review", ["B"]), createTask("B", "in-review")];
67
+ const { result } = renderHook(() => useGraphData(tasks));
68
+
69
+ expect(result.current.edges).toEqual([{ source: "A", target: "B" }]);
70
+ });
71
+
72
+ it("renders edge from in-review task to in-progress task", () => {
73
+ const tasks = [createTask("A", "in-review", ["B"]), createTask("B", "in-progress")];
74
+ const { result } = renderHook(() => useGraphData(tasks));
75
+
76
+ expect(result.current.edges).toEqual([{ source: "A", target: "B" }]);
77
+ });
78
+
79
+ it("renders edge from in-progress task to in-review task", () => {
80
+ const tasks = [createTask("A", "in-progress", ["B"]), createTask("B", "in-review")];
81
+ const { result } = renderHook(() => useGraphData(tasks));
82
+
83
+ expect(result.current.edges).toEqual([{ source: "A", target: "B" }]);
84
+ });
85
+ });
86
+ });
@@ -0,0 +1,167 @@
1
+ import { describe, expect, it, vi } from "vitest";
2
+ import { act, renderHook } from "@testing-library/react";
3
+ import type React from "react";
4
+ import { useGraphInteraction } from "../useGraphInteraction";
5
+
6
+ function createKeyEvent(
7
+ key: string,
8
+ options?: { ctrlKey?: boolean; metaKey?: boolean; shiftKey?: boolean; target?: EventTarget | null },
9
+ ) {
10
+ return {
11
+ key,
12
+ ctrlKey: Boolean(options?.ctrlKey),
13
+ metaKey: Boolean(options?.metaKey),
14
+ shiftKey: Boolean(options?.shiftKey),
15
+ target: options?.target ?? document.createElement("div"),
16
+ preventDefault: vi.fn(),
17
+ } as unknown as React.KeyboardEvent;
18
+ }
19
+
20
+ describe("useGraphInteraction", () => {
21
+ it("starts with default pan/zoom", () => {
22
+ const { result } = renderHook(() => useGraphInteraction());
23
+ expect(result.current.zoom).toBe(1);
24
+ expect(result.current.zoomPercent).toBe(100);
25
+ expect(result.current.pan).toEqual({ x: 0, y: 0 });
26
+ });
27
+
28
+ it("clamps zoom between 0.1 and 3", () => {
29
+ const { result } = renderHook(() => useGraphInteraction());
30
+
31
+ act(() => {
32
+ for (let i = 0; i < 100; i += 1) result.current.zoomOut();
33
+ });
34
+ expect(result.current.zoom).toBe(0.1);
35
+
36
+ act(() => {
37
+ for (let i = 0; i < 100; i += 1) result.current.zoomIn();
38
+ });
39
+ expect(result.current.zoom).toBe(3);
40
+ });
41
+
42
+ it("keeps wheel zoom anchored to cursor position", () => {
43
+ const { result } = renderHook(() => useGraphInteraction());
44
+
45
+ act(() => {
46
+ result.current.onWheelZoom(-120, { x: 200, y: 150 }, 800, 600);
47
+ });
48
+
49
+ expect(result.current.zoom).toBe(1.1);
50
+ expect(result.current.pan.x).toBeCloseTo(-20, 5);
51
+ expect(result.current.pan.y).toBeCloseTo(-15, 5);
52
+ });
53
+
54
+ it("supports pinch zoom with stationary midpoint", () => {
55
+ const { result } = renderHook(() => useGraphInteraction());
56
+
57
+ act(() => {
58
+ result.current.onPointerDown(1, { x: 100, y: 100 });
59
+ result.current.onPointerDown(2, { x: 200, y: 100 });
60
+ result.current.onPointerMove(2, { x: 250, y: 100 }, 800, 600);
61
+ });
62
+
63
+ expect(result.current.zoom).toBe(1.5);
64
+ expect(result.current.pan).toEqual({ x: -50, y: -50 });
65
+ });
66
+
67
+ it("applies animation state for fit and reset", () => {
68
+ vi.useFakeTimers();
69
+ const { result } = renderHook(() => useGraphInteraction());
70
+
71
+ act(() => {
72
+ result.current.fitToGraph(new Map([["A", { x: 0, y: 0 }]]), 800, 600);
73
+ });
74
+ expect(result.current.transitioning).toBe(true);
75
+
76
+ act(() => {
77
+ vi.advanceTimersByTime(210);
78
+ });
79
+ expect(result.current.transitioning).toBe(false);
80
+
81
+ act(() => {
82
+ result.current.resetView();
83
+ });
84
+ expect(result.current.transitioning).toBe(true);
85
+
86
+ act(() => {
87
+ vi.advanceTimersByTime(210);
88
+ });
89
+ expect(result.current.transitioning).toBe(false);
90
+ vi.useRealTimers();
91
+ });
92
+
93
+ it("fits wide graph", () => {
94
+ const { result } = renderHook(() => useGraphInteraction());
95
+ act(() => {
96
+ result.current.fitToGraph(new Map([
97
+ ["A", { x: 0, y: 0 }],
98
+ ["B", { x: 2000, y: 0 }],
99
+ ]), 800, 600);
100
+ });
101
+
102
+ expect(result.current.zoom).toBeLessThan(1);
103
+ });
104
+
105
+ it("handles keyboard shortcuts for zoom in/out, reset, fit, and escape", () => {
106
+ const { result } = renderHook(() => useGraphInteraction());
107
+ const positions = new Map([
108
+ ["A", { x: 0, y: 0 }],
109
+ ["B", { x: 500, y: 200 }],
110
+ ]);
111
+
112
+ act(() => {
113
+ result.current.handleKeyDown(createKeyEvent("=", { ctrlKey: true }), 800, 600, positions);
114
+ });
115
+ expect(result.current.zoom).toBe(1.2);
116
+
117
+ act(() => {
118
+ result.current.handleKeyDown(createKeyEvent("-", { ctrlKey: true }), 800, 600, positions);
119
+ });
120
+ expect(result.current.zoom).toBeCloseTo(1, 5);
121
+
122
+ act(() => {
123
+ result.current.handleKeyDown(createKeyEvent("F", { ctrlKey: true, shiftKey: true }), 800, 600, positions, { nodeWidth: 280, nodeHeight: 100 });
124
+ });
125
+ expect(result.current.zoom).toBeLessThan(1);
126
+
127
+ act(() => {
128
+ result.current.handleKeyDown(createKeyEvent("0", { ctrlKey: true }), 800, 600, positions);
129
+ });
130
+ expect(result.current.zoom).toBe(1);
131
+ expect(result.current.pan).toEqual({ x: 0, y: 0 });
132
+
133
+ act(() => {
134
+ result.current.zoomIn();
135
+ result.current.handleKeyDown(createKeyEvent("Escape"), 800, 600, positions);
136
+ });
137
+ expect(result.current.zoom).toBe(1);
138
+ expect(result.current.pan).toEqual({ x: 0, y: 0 });
139
+ });
140
+
141
+ it("does not run shortcuts when focused on editable targets", () => {
142
+ const { result } = renderHook(() => useGraphInteraction());
143
+ const input = document.createElement("input");
144
+ const positions = new Map([["A", { x: 0, y: 0 }]]);
145
+
146
+ act(() => {
147
+ result.current.handleKeyDown(createKeyEvent("=", { ctrlKey: true, target: input }), 800, 600, positions);
148
+ });
149
+
150
+ expect(result.current.zoom).toBe(1);
151
+ });
152
+
153
+ it("resets when positions are empty", () => {
154
+ const { result } = renderHook(() => useGraphInteraction());
155
+
156
+ act(() => {
157
+ result.current.zoomIn();
158
+ result.current.onPointerDown(1, { x: 10, y: 10 });
159
+ result.current.onPointerMove(1, { x: 110, y: 60 }, 800, 600);
160
+ result.current.onPointerUp(1);
161
+ result.current.fitToGraph(new Map(), 800, 600);
162
+ });
163
+
164
+ expect(result.current.zoom).toBe(1);
165
+ expect(result.current.pan).toEqual({ x: 0, y: 0 });
166
+ });
167
+ });
@@ -0,0 +1,66 @@
1
+ import { act, renderHook } from "@testing-library/react";
2
+ import { beforeEach, describe, expect, it, vi } from "vitest";
3
+ import { useGraphPositions } from "../hooks/useGraphPositions";
4
+ import * as storage from "../utils/graphPositionStorage";
5
+
6
+ vi.mock("../utils/graphPositionStorage", () => ({
7
+ loadPositions: vi.fn(),
8
+ savePositions: vi.fn(),
9
+ clearPositions: vi.fn(),
10
+ }));
11
+
12
+ describe("useGraphPositions", () => {
13
+ beforeEach(() => {
14
+ vi.clearAllMocks();
15
+ });
16
+
17
+ it("loads saved positions on mount with project scope", () => {
18
+ vi.mocked(storage.loadPositions).mockReturnValue({ a: { x: 1, y: 2 } });
19
+
20
+ const { result } = renderHook(() => useGraphPositions({ projectId: "p1", visibleTaskIds: new Set(["a"]) }));
21
+
22
+ expect(storage.loadPositions).toHaveBeenCalledWith("p1");
23
+ expect(result.current.savedPositions).toEqual({ a: { x: 1, y: 2 } });
24
+ });
25
+
26
+ it("reloads positions when project id changes", () => {
27
+ vi.mocked(storage.loadPositions).mockReturnValueOnce({ a: { x: 1, y: 1 } }).mockReturnValueOnce({ b: { x: 2, y: 2 } });
28
+
29
+ const { result, rerender } = renderHook(
30
+ ({ projectId }) => useGraphPositions({ projectId, visibleTaskIds: new Set(["a", "b"]) }),
31
+ { initialProps: { projectId: "p1" } },
32
+ );
33
+
34
+ rerender({ projectId: "p2" });
35
+
36
+ expect(storage.loadPositions).toHaveBeenNthCalledWith(1, "p1");
37
+ expect(storage.loadPositions).toHaveBeenNthCalledWith(2, "p2");
38
+ expect(result.current.savedPositions).toEqual({ b: { x: 2, y: 2 } });
39
+ });
40
+
41
+ it("persistPositions writes scoped and filters non-visible ids", () => {
42
+ vi.mocked(storage.loadPositions).mockReturnValue({});
43
+
44
+ const { result } = renderHook(() => useGraphPositions({ projectId: "p1", visibleTaskIds: new Set(["a"]) }));
45
+
46
+ act(() => {
47
+ result.current.persistPositions({ a: { x: 1, y: 2 }, hidden: { x: 9, y: 9 } });
48
+ });
49
+
50
+ expect(storage.savePositions).toHaveBeenCalledWith({ a: { x: 1, y: 2 }, hidden: { x: 9, y: 9 } }, new Set(["a"]), "p1");
51
+ expect(result.current.savedPositions).toEqual({ a: { x: 1, y: 2 } });
52
+ });
53
+
54
+ it("clearSavedPositions clears storage and resets state", () => {
55
+ vi.mocked(storage.loadPositions).mockReturnValue({ a: { x: 1, y: 2 } });
56
+
57
+ const { result } = renderHook(() => useGraphPositions({ projectId: "p1", visibleTaskIds: new Set(["a"]) }));
58
+
59
+ act(() => {
60
+ result.current.clearSavedPositions();
61
+ });
62
+
63
+ expect(storage.clearPositions).toHaveBeenCalledWith("p1");
64
+ expect(result.current.savedPositions).toBeNull();
65
+ });
66
+ });
@@ -0,0 +1,81 @@
1
+ import { act, renderHook } from "@testing-library/react";
2
+ import type React from "react";
3
+ import { describe, expect, it, vi } from "vitest";
4
+ import { __internal, useNodeDrag } from "../hooks/useNodeDrag";
5
+
6
+ function pointerEvent(overrides: Partial<PointerEvent> = {}) {
7
+ const target = {
8
+ setPointerCapture: vi.fn(),
9
+ releasePointerCapture: vi.fn(),
10
+ hasPointerCapture: vi.fn(() => true),
11
+ };
12
+ return {
13
+ isPrimary: true,
14
+ pointerId: 1,
15
+ clientX: 0,
16
+ clientY: 0,
17
+ stopPropagation: vi.fn(),
18
+ currentTarget: target,
19
+ ...overrides,
20
+ } as unknown as React.PointerEvent<HTMLElement>;
21
+ }
22
+
23
+ describe("useNodeDrag", () => {
24
+ it("transitions pending to dragging and back on pointer up", () => {
25
+ const onPositionChange = vi.fn();
26
+ const onDragStateChange = vi.fn();
27
+ const { result } = renderHook(() =>
28
+ useNodeDrag({ taskId: "A", position: { x: 10, y: 10 }, scale: 1, onPositionChange, onDragStateChange }),
29
+ );
30
+
31
+ act(() => result.current.onPointerDown(pointerEvent({ clientX: 10, clientY: 20 })));
32
+ act(() => result.current.onPointerMove(pointerEvent({ clientX: 16, clientY: 26 })));
33
+ expect(result.current.isDragging).toBe(true);
34
+ expect(onPositionChange).toHaveBeenCalledWith("A", { x: 16, y: 16 });
35
+
36
+ act(() => result.current.onPointerUp(pointerEvent({ clientX: 16, clientY: 26 })));
37
+ expect(result.current.isDragging).toBe(false);
38
+ expect(onDragStateChange).toHaveBeenCalledWith(true);
39
+ expect(onDragStateChange).toHaveBeenCalledWith(false);
40
+ });
41
+
42
+ it("stays click-only below threshold", () => {
43
+ const onPositionChange = vi.fn();
44
+ const { result } = renderHook(() =>
45
+ useNodeDrag({ taskId: "A", position: { x: 0, y: 0 }, scale: 1, onPositionChange }),
46
+ );
47
+
48
+ act(() => result.current.onPointerDown(pointerEvent()));
49
+ act(() => result.current.onPointerMove(pointerEvent({ clientX: __internal.DRAG_THRESHOLD_PX - 1, clientY: 0 })));
50
+ act(() => result.current.onPointerUp(pointerEvent({ clientX: __internal.DRAG_THRESHOLD_PX - 1, clientY: 0 })));
51
+
52
+ expect(result.current.isDragging).toBe(false);
53
+ expect(onPositionChange).not.toHaveBeenCalled();
54
+ });
55
+
56
+ it("divides pointer delta by zoom scale", () => {
57
+ const onPositionChange = vi.fn();
58
+ const { result } = renderHook(() =>
59
+ useNodeDrag({ taskId: "A", position: { x: 0, y: 0 }, scale: 2, onPositionChange }),
60
+ );
61
+
62
+ act(() => result.current.onPointerDown(pointerEvent()));
63
+ act(() => result.current.onPointerMove(pointerEvent({ clientX: 10, clientY: 6 })));
64
+
65
+ expect(onPositionChange).toHaveBeenCalledWith("A", { x: 5, y: 3 });
66
+ });
67
+
68
+ it("cancels drag cleanly on pointer cancel", () => {
69
+ const onPositionChange = vi.fn();
70
+ const { result } = renderHook(() =>
71
+ useNodeDrag({ taskId: "A", position: { x: 0, y: 0 }, scale: 1, onPositionChange }),
72
+ );
73
+
74
+ act(() => result.current.onPointerDown(pointerEvent()));
75
+ act(() => result.current.onPointerMove(pointerEvent({ clientX: 8, clientY: 0 })));
76
+ expect(result.current.isDragging).toBe(true);
77
+
78
+ act(() => result.current.onPointerCancel(pointerEvent({ clientX: 8, clientY: 0 })));
79
+ expect(result.current.isDragging).toBe(false);
80
+ });
81
+ });
@@ -0,0 +1,35 @@
1
+ declare module "@fusion/dashboard/app/utils/taskStuck" {
2
+ import type { Task } from "@fusion/core";
3
+
4
+ export function isTaskStuck(task: Task, taskStuckTimeoutMs?: number, lastFetchTimeMs?: number): boolean;
5
+ }
6
+
7
+ declare module "@fusion/dashboard/app/components/TaskCard" {
8
+ import type { Column, Task, TaskDetail } from "@fusion/core";
9
+ import type { ReactElement } from "react";
10
+
11
+ interface TaskCardProps {
12
+ task: Task;
13
+ projectId?: string;
14
+ onOpenDetail: (task: Task | TaskDetail) => void;
15
+ addToast: (message: string, type?: "success" | "error" | "info" | "warning") => void;
16
+ globalPaused?: boolean;
17
+ onUpdateTask?: (
18
+ id: string,
19
+ updates: { title?: string; description?: string; dependencies?: string[] }
20
+ ) => Promise<Task>;
21
+ onArchiveTask?: (id: string) => Promise<Task>;
22
+ onUnarchiveTask?: (id: string) => Promise<Task>;
23
+ onDeleteTask?: (id: string, options?: { removeDependencyReferences?: boolean }) => Promise<Task>;
24
+ onRetryTask?: (id: string) => Promise<Task>;
25
+ onOpenDetailWithTab?: (task: Task | TaskDetail, initialTab: "changes") => void;
26
+ taskStuckTimeoutMs?: number;
27
+ onOpenMission?: (missionId: string) => void;
28
+ onMoveTask?: (id: string, column: Column, optionsOrPosition?: { preserveProgress?: boolean } | number) => Promise<Task>;
29
+ lastFetchTimeMs?: number;
30
+ workflowStepNameLookup?: ReadonlyMap<string, string>;
31
+ disableDrag?: boolean;
32
+ }
33
+
34
+ export function TaskCard(props: TaskCardProps): ReactElement;
35
+ }
@@ -0,0 +1,19 @@
1
+ import type { Task, TaskDetail, WorkflowStep } from "@fusion/core";
2
+ import type { PluginDashboardViewContext } from "@fusion/dashboard/app/plugins/types";
3
+ import { createElement } from "react";
4
+ import { DependencyGraph } from "./DependencyGraph";
5
+
6
+ function createWorkflowStepNameLookup(workflowSteps: WorkflowStep[] | undefined): ReadonlyMap<string, string> {
7
+ return new Map((workflowSteps ?? []).map((step) => [step.id, step.name] as const));
8
+ }
9
+
10
+ export function DependencyGraphDashboardView({ context }: { context?: PluginDashboardViewContext }) {
11
+ return createElement(DependencyGraph, {
12
+ tasks: context?.tasks ?? [],
13
+ projectId: context?.projectId,
14
+ workflowStepNameLookup: createWorkflowStepNameLookup(context?.workflowSteps),
15
+ onOpenDetail: context?.openTaskDetail as ((task: Task | TaskDetail) => void) | undefined,
16
+ });
17
+ }
18
+
19
+ export { DependencyGraph };
@@ -0,0 +1,70 @@
1
+ import type { GraphEdge, GraphPosition } from "./types";
2
+ import "./GraphHighlight.css";
3
+
4
+ interface GraphEdgesProps {
5
+ edges: GraphEdge[];
6
+ positions: Map<string, GraphPosition>;
7
+ nodeWidth?: number;
8
+ nodeHeight?: number;
9
+ highlightedEdgeIds?: Set<string>;
10
+ }
11
+
12
+ const DEFAULT_NODE_WIDTH = 280;
13
+ const DEFAULT_NODE_HEIGHT = 100;
14
+
15
+ export function GraphEdges({
16
+ edges,
17
+ positions,
18
+ nodeWidth = DEFAULT_NODE_WIDTH,
19
+ nodeHeight = DEFAULT_NODE_HEIGHT,
20
+ highlightedEdgeIds,
21
+ }: GraphEdgesProps) {
22
+ const hasHighlights = Boolean(highlightedEdgeIds && highlightedEdgeIds.size > 0);
23
+
24
+ return (
25
+ <svg className="dependency-graph-edges" aria-hidden="true">
26
+ <defs>
27
+ <marker
28
+ id="dependency-graph-arrowhead"
29
+ markerWidth="10"
30
+ markerHeight="7"
31
+ refX="10"
32
+ refY="3.5"
33
+ orient="auto"
34
+ markerUnits="strokeWidth"
35
+ >
36
+ <path d="M 0 0 L 10 3.5 L 0 7 z" fill="var(--border)" />
37
+ </marker>
38
+ </defs>
39
+ {edges.map((edge) => {
40
+ const source = positions.get(edge.source);
41
+ const target = positions.get(edge.target);
42
+ if (!source || !target) return null;
43
+
44
+ const edgeId = `${edge.source}->${edge.target}`;
45
+ const isActiveHighlight = hasHighlights && (highlightedEdgeIds?.has(edgeId) ?? false);
46
+ const x1 = source.x + nodeWidth / 2;
47
+ const y1 = source.y + nodeHeight;
48
+ const x2 = target.x + nodeWidth / 2;
49
+ const y2 = target.y;
50
+ const controlY = y1 + (y2 - y1) / 2;
51
+
52
+ return (
53
+ <path
54
+ key={edgeId}
55
+ data-testid="dependency-edge"
56
+ data-edge-id={edgeId}
57
+ className={`dependency-graph-edge${isActiveHighlight ? " graph-edge--highlighted" : ""}${hasHighlights && !isActiveHighlight ? " graph-edge--dimmed" : ""}`}
58
+ d={`M ${x1} ${y1} C ${x1} ${controlY}, ${x2} ${controlY}, ${x2} ${y2}`}
59
+ fill="none"
60
+ stroke={isActiveHighlight ? "var(--todo)" : "var(--border)"}
61
+ strokeWidth={isActiveHighlight ? "var(--space-xs)" : "var(--btn-border-width)"}
62
+ opacity={hasHighlights && !isActiveHighlight ? 0.15 : 1}
63
+ markerEnd="url(#dependency-graph-arrowhead)"
64
+ style={{ transition: "opacity var(--transition-fast), stroke var(--transition-fast), stroke-width var(--transition-fast)" }}
65
+ />
66
+ );
67
+ })}
68
+ </svg>
69
+ );
70
+ }
@@ -0,0 +1,8 @@
1
+ import type { Column, Task } from "@fusion/core";
2
+
3
+ export const INCLUDED_COLUMNS: ReadonlySet<Column> = new Set(["triage", "todo", "in-progress", "in-review"]);
4
+ export const EXCLUDED_COLUMNS: ReadonlySet<Column> = new Set(["done", "archived"]);
5
+
6
+ export function filterGraphTasks(tasks: Task[]): Task[] {
7
+ return tasks.filter((task) => INCLUDED_COLUMNS.has(task.column));
8
+ }
@@ -0,0 +1,53 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { renderHook } from "@testing-library/react";
3
+ import type { Task } from "@fusion/core";
4
+ import { useDependencyChain } from "../useDependencyChain";
5
+
6
+ function createTask(id: string, dependencies: string[] = []): Task {
7
+ return {
8
+ id,
9
+ description: id,
10
+ column: "todo",
11
+ dependencies,
12
+ steps: [],
13
+ currentStep: 0,
14
+ log: [],
15
+ createdAt: new Date().toISOString(),
16
+ updatedAt: new Date().toISOString(),
17
+ } as Task;
18
+ }
19
+
20
+ describe("useDependencyChain", () => {
21
+ it("returns empty set for unknown task in empty list", () => {
22
+ const { result } = renderHook(() => useDependencyChain([]));
23
+ expect(result.current.getChain("A").size).toBe(0);
24
+ });
25
+
26
+ it("returns single task when no dependencies", () => {
27
+ const { result } = renderHook(() => useDependencyChain([createTask("A")]));
28
+ expect(result.current.getChain("A")).toEqual(new Set(["A"]));
29
+ });
30
+
31
+ it("returns full linear chain", () => {
32
+ const tasks = [createTask("A"), createTask("B", ["A"]), createTask("C", ["B"]), createTask("D")];
33
+ const { result } = renderHook(() => useDependencyChain(tasks));
34
+ expect(result.current.getChain("C")).toEqual(new Set(["A", "B", "C"]));
35
+ });
36
+
37
+ it("returns full diamond chain", () => {
38
+ const tasks = [createTask("A"), createTask("B", ["A"]), createTask("C", ["A"]), createTask("D", ["B", "C"]), createTask("E")];
39
+ const { result } = renderHook(() => useDependencyChain(tasks));
40
+ expect(result.current.getChain("D")).toEqual(new Set(["A", "B", "C", "D"]));
41
+ });
42
+
43
+ it("does not include disconnected tasks", () => {
44
+ const { result } = renderHook(() => useDependencyChain([createTask("A"), createTask("B")]));
45
+ expect(result.current.getChain("A")).toEqual(new Set(["A"]));
46
+ });
47
+
48
+ it("handles circular dependencies safely", () => {
49
+ const tasks = [createTask("A", ["B"]), createTask("B", ["A"]), createTask("C")];
50
+ const { result } = renderHook(() => useDependencyChain(tasks));
51
+ expect(result.current.getChain("A")).toEqual(new Set(["A", "B"]));
52
+ });
53
+ });
@@ -0,0 +1,60 @@
1
+ import { useCallback, useMemo } from "react";
2
+ import type { Task } from "@fusion/core";
3
+
4
+ export function useDependencyChain(tasks: Task[]) {
5
+ const { upstreamMap, downstreamMap } = useMemo(() => {
6
+ const upstream = new Map<string, Set<string>>();
7
+ const downstream = new Map<string, Set<string>>();
8
+
9
+ for (const task of tasks) {
10
+ upstream.set(task.id, new Set(task.dependencies ?? []));
11
+ if (!downstream.has(task.id)) downstream.set(task.id, new Set());
12
+ }
13
+
14
+ for (const task of tasks) {
15
+ for (const dependencyId of task.dependencies ?? []) {
16
+ if (!downstream.has(dependencyId)) downstream.set(dependencyId, new Set());
17
+ downstream.get(dependencyId)?.add(task.id);
18
+ }
19
+ }
20
+
21
+ return { upstreamMap: upstream, downstreamMap: downstream };
22
+ }, [tasks]);
23
+
24
+ const getChain = useCallback(
25
+ (taskId: string): Set<string> => {
26
+ if (!upstreamMap.has(taskId) && !downstreamMap.has(taskId)) {
27
+ return new Set();
28
+ }
29
+
30
+ const chain = new Set<string>([taskId]);
31
+
32
+ const visit = (origin: string, adjacency: Map<string, Set<string>>) => {
33
+ const queue = [origin];
34
+ const visited = new Set<string>([origin]);
35
+
36
+ while (queue.length > 0) {
37
+ const current = queue.shift();
38
+ if (!current) continue;
39
+ const neighbors = adjacency.get(current);
40
+ if (!neighbors) continue;
41
+
42
+ for (const neighbor of neighbors) {
43
+ if (visited.has(neighbor)) continue;
44
+ visited.add(neighbor);
45
+ chain.add(neighbor);
46
+ queue.push(neighbor);
47
+ }
48
+ }
49
+ };
50
+
51
+ visit(taskId, upstreamMap);
52
+ visit(taskId, downstreamMap);
53
+
54
+ return chain;
55
+ },
56
+ [downstreamMap, upstreamMap],
57
+ );
58
+
59
+ return { getChain };
60
+ }