@bevel-software/platform-core-frontend 0.4.0 → 0.5.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 (326) hide show
  1. package/package.json +5 -3
  2. package/src/core/CoreAppShell.tsx +195 -56
  3. package/src/core/__tests__/AppChrome.test.tsx +125 -0
  4. package/src/core/__tests__/ShellRoutes.test.tsx +130 -95
  5. package/src/core/__tests__/bootstrap.test.ts +63 -0
  6. package/src/core/bootstrap.ts +73 -0
  7. package/src/core/events.ts +12 -0
  8. package/src/core/registry.ts +58 -9
  9. package/src/index.css +100 -11
  10. package/src/index.ts +24 -23
  11. package/src/lib/utils.ts +114 -138
  12. package/src/modules/access/__tests__/ManageAccessDialog.placement.test.tsx +281 -0
  13. package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +166 -1
  14. package/src/modules/access/api.ts +49 -0
  15. package/src/modules/access/components/ManageAccessDialog.tsx +786 -481
  16. package/src/modules/access/hooks/useFileAccess.ts +1 -1
  17. package/src/modules/admin/__tests__/AdminRolesPage.suggest.test.tsx +86 -0
  18. package/src/modules/admin/__tests__/UserAccountsPage.test.tsx +172 -156
  19. package/src/modules/admin/__tests__/admin.unread.test.tsx +61 -0
  20. package/src/modules/admin/components/AdminRolesPage.tsx +44 -38
  21. package/src/modules/admin/components/RolesCorruptedBanner.tsx +11 -10
  22. package/src/modules/admin/components/UserAccountsPage.tsx +361 -353
  23. package/src/modules/admin/state/admin.context.tsx +15 -6
  24. package/src/modules/auth/components/AccountPage.tsx +11 -11
  25. package/src/modules/auth/components/LoginScreen.tsx +12 -12
  26. package/src/modules/auth/services/sso.ts +47 -1
  27. package/src/modules/change-requests/__tests__/ChangeRequestDialog.test.tsx +277 -0
  28. package/src/modules/change-requests/__tests__/author.test.ts +48 -0
  29. package/src/modules/change-requests/__tests__/conflict.test.ts +73 -0
  30. package/src/modules/change-requests/__tests__/diff.test.ts +134 -0
  31. package/src/modules/change-requests/__tests__/propose.test.ts +93 -0
  32. package/src/modules/change-requests/__tests__/useFileOnBranch.test.tsx +72 -0
  33. package/src/modules/change-requests/change-requests.css +22 -0
  34. package/src/modules/change-requests/components/ChangeBox.tsx +277 -0
  35. package/src/modules/change-requests/components/ChangeRequestDialog.tsx +713 -0
  36. package/src/modules/change-requests/components/ConflictHelp.tsx +47 -0
  37. package/src/modules/change-requests/components/CrFileTree.tsx +398 -0
  38. package/src/modules/change-requests/components/FileChangeBoxes.tsx +168 -0
  39. package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +236 -0
  40. package/src/modules/change-requests/hooks/useCrFileDiffs.ts +79 -0
  41. package/src/modules/change-requests/hooks/useFileOnBranch.ts +80 -0
  42. package/src/modules/change-requests/services/change-requests.api.ts +45 -0
  43. package/src/modules/change-requests/services/propose.api.ts +162 -0
  44. package/src/modules/change-requests/utils/author.ts +47 -0
  45. package/src/modules/change-requests/utils/conflict.ts +38 -0
  46. package/src/modules/change-requests/utils/diff.ts +80 -0
  47. package/src/modules/git/__tests__/BranchSwitcher.test.tsx +27 -18
  48. package/src/modules/git/__tests__/FileHistoryPanel.test.tsx +36 -83
  49. package/src/modules/git/__tests__/PullNeededBanner.test.tsx +5 -5
  50. package/src/modules/git/__tests__/PullRequestsForMe.test.tsx +147 -0
  51. package/src/modules/git/__tests__/useAutoPullUpdates.test.tsx +2 -8
  52. package/src/modules/git/components/BranchSwitcher.tsx +68 -31
  53. package/src/modules/git/components/DiffView.tsx +4 -4
  54. package/src/modules/git/components/FileComparisonPanel.tsx +20 -20
  55. package/src/modules/git/components/FileHistoryPanel.tsx +71 -107
  56. package/src/modules/git/components/PullNeededBanner.tsx +6 -13
  57. package/src/modules/git/components/PullRequestsForMe.tsx +71 -36
  58. package/src/modules/git/components/UnifiedDiffView.tsx +4 -4
  59. package/src/modules/git/hooks/__tests__/useGitState.deleteBranch.test.tsx +2 -2
  60. package/src/modules/git/hooks/useGitState.ts +15 -14
  61. package/src/modules/git/services/__tests__/error-messages.test.ts +4 -4
  62. package/src/modules/git/services/error-messages.ts +7 -7
  63. package/src/modules/git/services/git.api.ts +17 -11
  64. package/src/modules/git/services/pr-prompts.ts +2 -2
  65. package/src/modules/git/state/git.context.ts +10 -1
  66. package/src/modules/layout/__tests__/SidebarFrameResponsive.test.tsx +224 -0
  67. package/src/modules/layout/__tests__/SidebarToggle.test.tsx +242 -0
  68. package/src/modules/layout/__tests__/breakpoints.test.ts +56 -0
  69. package/src/modules/layout/breakpoints.ts +6 -0
  70. package/src/modules/layout/components/AppLayout.tsx +17 -5
  71. package/src/modules/layout/components/DemoBanner.tsx +10 -1
  72. package/src/modules/layout/components/MaintenanceOverlay.tsx +104 -104
  73. package/src/modules/layout/components/MobileChatLayout.tsx +31 -26
  74. package/src/modules/layout/components/ResizableThreePaneLayout.tsx +59 -24
  75. package/src/modules/layout/components/SidebarFrame.tsx +317 -0
  76. package/src/modules/layout/components/SidebarToggle.tsx +86 -0
  77. package/src/modules/layout/components/SlideOverlay.tsx +1 -1
  78. package/src/modules/layout/components/__tests__/MobileChatLayout.test.tsx +40 -2
  79. package/src/modules/layout/components/__tests__/ResizableThreePaneLayout.test.tsx +19 -3
  80. package/src/modules/layout/state/sidebar.ts +200 -0
  81. package/src/modules/library/__tests__/AddToGroupDialog.test.tsx +313 -0
  82. package/src/modules/library/__tests__/ChangeRequestDock.test.tsx +84 -0
  83. package/src/modules/library/__tests__/GroupJoinRequests.test.tsx +178 -0
  84. package/src/modules/library/__tests__/GroupPage.test.tsx +479 -0
  85. package/src/modules/library/__tests__/GroupsIndexPage.test.tsx +283 -0
  86. package/src/modules/library/__tests__/GroupsSidebar.contextmenu.test.tsx +175 -0
  87. package/src/modules/library/__tests__/GroupsSidebar.locked.test.tsx +96 -0
  88. package/src/modules/library/__tests__/GroupsSidebar.test.tsx +142 -0
  89. package/src/modules/library/__tests__/GroupsSidebarMenu.test.tsx +142 -0
  90. package/src/modules/library/__tests__/LibraryCard.test.tsx +149 -0
  91. package/src/modules/library/__tests__/LibraryRoutes.test.tsx +378 -0
  92. package/src/modules/library/__tests__/LibrarySidebarMenu.test.tsx +347 -0
  93. package/src/modules/library/__tests__/LockedGroupView.test.tsx +203 -0
  94. package/src/modules/library/__tests__/NewGroupDialog.test.tsx +114 -0
  95. package/src/modules/library/__tests__/PersonalAddDialog.test.tsx +177 -0
  96. package/src/modules/library/__tests__/SkillPage.test.tsx +1063 -0
  97. package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +259 -0
  98. package/src/modules/library/__tests__/ToolLogo.test.tsx +63 -0
  99. package/src/modules/library/__tests__/ToolPage.test.tsx +315 -0
  100. package/src/modules/library/__tests__/ToolSharePanel.test.tsx +36 -0
  101. package/src/modules/library/__tests__/ToolVarRow.test.tsx +260 -0
  102. package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +197 -0
  103. package/src/modules/library/__tests__/auth-harness.tsx +37 -0
  104. package/src/modules/library/__tests__/oauth-fragment.test.ts +48 -0
  105. package/src/modules/library/__tests__/status.test.ts +210 -117
  106. package/src/modules/library/__tests__/useSkillDetail.test.tsx +102 -0
  107. package/src/modules/library/__tests__/useToolPage.test.tsx +146 -0
  108. package/src/modules/library/components/AccessRequestsBanner.tsx +101 -0
  109. package/src/modules/library/components/AddToGroupDialog.tsx +115 -0
  110. package/src/modules/library/components/ChangeRequestDock.tsx +71 -47
  111. package/src/modules/library/components/DeleteGroupDialog.tsx +87 -0
  112. package/src/modules/library/components/GroupIndexRow.tsx +63 -0
  113. package/src/modules/library/components/GroupJoinRequests.tsx +56 -0
  114. package/src/modules/library/components/GroupPage.tsx +373 -0
  115. package/src/modules/library/components/GroupsIndexPage.tsx +222 -0
  116. package/src/modules/library/components/GroupsSidebar.tsx +338 -0
  117. package/src/modules/library/components/GroupsSidebarMenu.tsx +160 -0
  118. package/src/modules/library/components/LibraryCard.tsx +153 -132
  119. package/src/modules/library/components/LibraryLayout.tsx +344 -0
  120. package/src/modules/library/components/LibraryPage.tsx +138 -254
  121. package/src/modules/library/components/LockGlyph.tsx +31 -0
  122. package/src/modules/library/components/LockedGroupView.tsx +159 -0
  123. package/src/modules/library/components/ManagedGroupRequests.tsx +70 -0
  124. package/src/modules/library/components/NewGroupDialog.tsx +112 -0
  125. package/src/modules/library/components/NewSkillPanel.tsx +151 -0
  126. package/src/modules/library/components/PageActions.tsx +156 -0
  127. package/src/modules/library/components/PendingSkillReview.tsx +63 -0
  128. package/src/modules/library/components/PersonalAddDialog.tsx +88 -0
  129. package/src/modules/library/components/PersonalGroupPage.tsx +125 -0
  130. package/src/modules/library/components/StatusDot.tsx +25 -0
  131. package/src/modules/library/components/ToolLogo.tsx +171 -0
  132. package/src/modules/library/components/group-page-parts.tsx +419 -0
  133. package/src/modules/library/components/skill-page/SkillFileEditor.tsx +134 -0
  134. package/src/modules/library/components/skill-page/SkillFilePane.tsx +117 -0
  135. package/src/modules/library/components/skill-page/SkillFileTabs.tsx +112 -0
  136. package/src/modules/library/components/skill-page/SkillPage.tsx +673 -0
  137. package/src/modules/library/components/skill-page/tab-ids.ts +33 -0
  138. package/src/modules/library/components/tool-page/ToolConnectionSection.tsx +175 -0
  139. package/src/modules/library/components/tool-page/ToolPage.tsx +228 -0
  140. package/src/modules/library/components/tool-page/ToolSharePanel.tsx +45 -0
  141. package/src/modules/library/components/tool-page/ToolVarRow.tsx +289 -0
  142. package/src/modules/library/hooks/useJoinRequests.ts +114 -0
  143. package/src/modules/library/hooks/useLibraryData.ts +134 -119
  144. package/src/modules/library/hooks/useSkillDetail.ts +119 -74
  145. package/src/modules/library/hooks/useToolPage.ts +145 -0
  146. package/src/modules/library/library.css +108 -320
  147. package/src/modules/library/routes/LibraryRoutes.tsx +134 -0
  148. package/src/modules/library/routes/WorkspaceItemRoute.tsx +74 -0
  149. package/src/modules/library/routes/library-paths.ts +191 -0
  150. package/src/modules/library/services/groups.api.ts +189 -0
  151. package/src/modules/library/services/library.api.ts +291 -164
  152. package/src/modules/library/services/tools.api.ts +60 -0
  153. package/src/modules/library/state/library-context.ts +22 -0
  154. package/src/modules/library/state/library-data.tsx +223 -0
  155. package/src/modules/library/state/toast.context.ts +32 -0
  156. package/src/modules/library/state/toast.tsx +84 -42
  157. package/src/modules/library/utils/clipboard.ts +33 -0
  158. package/src/modules/library/utils/group-summary.ts +68 -0
  159. package/src/modules/library/utils/names.ts +30 -0
  160. package/src/modules/library/utils/navigate-external.ts +15 -0
  161. package/src/modules/library/utils/oauth-fragment.ts +32 -0
  162. package/src/modules/library/utils/personal-group.ts +36 -0
  163. package/src/modules/library/utils/status.ts +199 -116
  164. package/src/modules/library/utils/toast-duration.ts +16 -0
  165. package/src/modules/onboarding/__tests__/onboarding.test.tsx +533 -0
  166. package/src/modules/onboarding/agent-clients.ts +48 -0
  167. package/src/modules/onboarding/components/ConnectAgentPill.tsx +133 -0
  168. package/src/modules/onboarding/components/RootLanding.tsx +54 -0
  169. package/src/modules/onboarding/components/WelcomePage.tsx +364 -0
  170. package/src/modules/onboarding/paths.ts +9 -0
  171. package/src/modules/onboarding/state/onboarding.ts +191 -0
  172. package/src/modules/pr/components/OpenChangeRequestDialog.tsx +10 -10
  173. package/src/modules/pr/services/pr-approvals.api.ts +19 -0
  174. package/src/modules/pr/services/pr-cancel.api.ts +11 -0
  175. package/src/modules/review/components/BinaryChangePlaceholder.tsx +3 -3
  176. package/src/modules/review/components/DiffViewer.tsx +4 -4
  177. package/src/modules/review/components/MarkdownDiffViewer.tsx +84 -26
  178. package/src/modules/review/components/ReviewFileRow.tsx +10 -10
  179. package/src/modules/review/components/ReviewPanel.tsx +49 -17
  180. package/src/modules/review/components/ReviewPanelSurface.tsx +1 -1
  181. package/src/modules/review/components/__tests__/MarkdownDiffViewer.test.tsx +122 -0
  182. package/src/modules/review/hooks/__tests__/useReviewState.test.ts +1 -1
  183. package/src/modules/secrets-vault/components/ConnectToolsPage.tsx +273 -171
  184. package/src/modules/secrets-vault/components/SecretsPage.tsx +313 -276
  185. package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +109 -92
  186. package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +82 -51
  187. package/src/modules/secrets-vault/services/connect.api.ts +24 -3
  188. package/src/modules/settings/components/DeploymentPage.tsx +90 -0
  189. package/src/modules/settings/components/SettingsLayout.tsx +135 -0
  190. package/src/modules/settings/components/SettingsNav.tsx +114 -0
  191. package/src/modules/settings/components/__tests__/DeploymentPage.test.tsx +110 -0
  192. package/src/modules/settings/components/__tests__/SettingsLayout.test.tsx +249 -0
  193. package/src/modules/settings/settings-nav-items.tsx +166 -0
  194. package/src/modules/setup/__tests__/setup.test.tsx +540 -0
  195. package/src/modules/setup/components/SetupGate.tsx +67 -0
  196. package/src/modules/setup/components/SetupScreen.tsx +573 -0
  197. package/src/modules/setup/services/setup.api.ts +106 -0
  198. package/src/modules/setup/utils/git-host.ts +34 -0
  199. package/src/modules/toolbar/components/AppSwitcher.tsx +131 -108
  200. package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +548 -548
  201. package/src/modules/toolbar/components/ProfileMenu.tsx +294 -0
  202. package/src/modules/toolbar/components/Toolbar.tsx +56 -54
  203. package/src/modules/toolbar/components/__tests__/AppSwitcher.test.tsx +176 -122
  204. package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +252 -77
  205. package/src/modules/tools/ToolsExplorerPage.tsx +45 -40
  206. package/src/modules/workspace/__tests__/design-system-parity.test.ts +133 -0
  207. package/src/modules/workspace/__tests__/testFixtures.ts +2 -0
  208. package/src/modules/workspace/components/EditorTabs.tsx +82 -50
  209. package/src/modules/workspace/components/FileExplorer.tsx +1292 -1068
  210. package/src/modules/workspace/components/FilePaneCard.tsx +53 -0
  211. package/src/modules/workspace/components/FileRoute.tsx +89 -84
  212. package/src/modules/workspace/components/FileViewer.tsx +1312 -906
  213. package/src/modules/workspace/components/KbDocumentShell.tsx +138 -0
  214. package/src/modules/workspace/components/KbFileRail.tsx +128 -0
  215. package/src/modules/workspace/components/KbPageHeader.tsx +390 -0
  216. package/src/modules/workspace/components/__tests__/EditorTabs.test.tsx +87 -3
  217. package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +293 -39
  218. package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +1 -16
  219. package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +462 -44
  220. package/src/modules/workspace/components/__tests__/KbDocumentShell.test.tsx +84 -0
  221. package/src/modules/workspace/components/__tests__/KbFileRail.test.tsx +83 -0
  222. package/src/modules/workspace/components/__tests__/KbPageHeader.test.tsx +192 -0
  223. package/src/modules/workspace/components/renderers/CopyAnchorButton.tsx +64 -0
  224. package/src/modules/workspace/components/renderers/CsvRenderer.tsx +8 -8
  225. package/src/modules/workspace/components/renderers/DocxRenderer.tsx +18 -9
  226. package/src/modules/workspace/components/renderers/HtmlRenderer.tsx +14 -14
  227. package/src/modules/workspace/components/renderers/ImageRenderer.tsx +2 -2
  228. package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +31 -165
  229. package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +18 -5
  230. package/src/modules/workspace/components/renderers/MermaidDiagram.tsx +27 -10
  231. package/src/modules/workspace/components/renderers/PdfRenderer.tsx +2 -2
  232. package/src/modules/workspace/components/renderers/TextRenderer.tsx +11 -5
  233. package/src/modules/workspace/components/renderers/ToolForm.tsx +24 -24
  234. package/src/modules/workspace/components/renderers/ToolRenderer.tsx +27 -27
  235. package/src/modules/workspace/components/renderers/XlsxRenderer.tsx +11 -11
  236. package/src/modules/workspace/components/renderers/__tests__/DocxRenderer.test.tsx +66 -0
  237. package/src/modules/workspace/components/renderers/__tests__/KbMarkdownView.test.tsx +17 -1
  238. package/src/modules/workspace/components/renderers/__tests__/MarkdownRenderer.test.tsx +1 -1
  239. package/src/modules/workspace/components/renderers/__tests__/MermaidDiagram.test.tsx +58 -0
  240. package/src/modules/workspace/components/renderers/__tests__/lazyRenderer.test.tsx +68 -0
  241. package/src/modules/workspace/components/renderers/__tests__/rendererLayout.test.ts +64 -0
  242. package/src/modules/workspace/components/renderers/__tests__/sanitizeDocxHtml.test.ts +0 -0
  243. package/src/modules/workspace/components/renderers/chunk-boundary.tsx +71 -0
  244. package/src/modules/workspace/components/renderers/index.ts +78 -2
  245. package/src/modules/workspace/components/renderers/kbMarkdownPipeline.tsx +241 -0
  246. package/src/modules/workspace/components/renderers/lazyRenderer.tsx +59 -0
  247. package/src/modules/workspace/components/renderers/sanitizeDocxHtml.ts +91 -0
  248. package/src/modules/workspace/hooks/__tests__/useLinksOut.test.ts +59 -0
  249. package/src/modules/workspace/hooks/__tests__/useOpenChangeRequests.test.tsx +237 -0
  250. package/src/modules/workspace/hooks/__tests__/useWorkspaceState.test.tsx +185 -0
  251. package/src/modules/workspace/hooks/useAutoGrowTextarea.ts +30 -0
  252. package/src/modules/workspace/hooks/useLastCommit.ts +66 -0
  253. package/src/modules/workspace/hooks/useLinksOut.ts +56 -0
  254. package/src/modules/workspace/hooks/useOpenChangeRequests.ts +20 -0
  255. package/src/modules/workspace/hooks/useWorkspaceState.ts +123 -14
  256. package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +1 -1
  257. package/src/modules/workspace/services/workspace.api.ts +9 -2
  258. package/src/modules/workspace/state/open-change-requests.context.ts +35 -0
  259. package/src/modules/workspace/state/open-change-requests.tsx +185 -0
  260. package/src/modules/workspace/state/workspace.context.ts +9 -0
  261. package/src/modules/workspace/utils/__tests__/diff.test.ts +87 -0
  262. package/src/modules/workspace/utils/diff.ts +130 -53
  263. package/src/modules/workspace/utils/fileTree.ts +182 -179
  264. package/src/modules/workspace/workspace.css +28 -0
  265. package/src/shared/components/Badge.tsx +62 -0
  266. package/src/shared/components/Banner.tsx +58 -0
  267. package/src/shared/components/Button.tsx +90 -0
  268. package/src/shared/components/Dialog.tsx +6 -6
  269. package/src/shared/components/Field.tsx +45 -0
  270. package/src/shared/components/IconButton.tsx +74 -0
  271. package/src/shared/components/ListRow.tsx +96 -0
  272. package/src/shared/components/Menu.tsx +88 -0
  273. package/src/shared/components/PageShell.tsx +54 -51
  274. package/src/shared/components/Surface.tsx +86 -0
  275. package/src/shared/components/__tests__/primitives.test.tsx +333 -0
  276. package/src/shared/components/index.ts +48 -0
  277. package/src/shared/components/useDismissableMenu.ts +71 -0
  278. package/src/shared/theme/__tests__/accent-contrast.test.ts +84 -0
  279. package/src/shared/theme/index.css +12 -0
  280. package/src/shared/theme/measure.ts +64 -0
  281. package/src/shared/theme/shadows.css +34 -0
  282. package/src/shared/theme/tokens.css +193 -0
  283. package/src/test-setup.ts +9 -0
  284. package/src/modules/access/components/AccessRestrictedBanner.tsx +0 -31
  285. package/src/modules/access/components/NodeOwnersBanner.tsx +0 -30
  286. package/src/modules/git/__tests__/ProtectedBranchBanner.test.tsx +0 -82
  287. package/src/modules/git/components/ProtectedBranchBanner.tsx +0 -42
  288. package/src/modules/library/__tests__/DetailDialog.test.tsx +0 -200
  289. package/src/modules/library/__tests__/diff.test.ts +0 -62
  290. package/src/modules/library/__tests__/loadout.test.tsx +0 -72
  291. package/src/modules/library/components/CompareView.tsx +0 -357
  292. package/src/modules/library/components/DetailDialog.tsx +0 -566
  293. package/src/modules/library/components/GearIcon.tsx +0 -12
  294. package/src/modules/library/components/LoadoutSidebar.tsx +0 -156
  295. package/src/modules/library/components/StatusGem.tsx +0 -21
  296. package/src/modules/library/components/SuggestChange.tsx +0 -171
  297. package/src/modules/library/components/particles.ts +0 -50
  298. package/src/modules/library/state/loadout.tsx +0 -129
  299. package/src/modules/library/utils/diff.ts +0 -102
  300. package/src/modules/pr/__tests__/PrApprovalBadge.test.tsx +0 -93
  301. package/src/modules/pr/__tests__/PrCancelButton.test.tsx +0 -158
  302. package/src/modules/pr/__tests__/PrCancelConfirmDialog.test.tsx +0 -44
  303. package/src/modules/pr/__tests__/PrMergeButton.test.tsx +0 -360
  304. package/src/modules/pr/__tests__/bucketize-comments.test.ts +0 -85
  305. package/src/modules/pr/__tests__/parsePatch.test.ts +0 -104
  306. package/src/modules/pr/__tests__/usePrViewerState.test.ts +0 -72
  307. package/src/modules/pr/components/PrApprovalBadge.tsx +0 -80
  308. package/src/modules/pr/components/PrCancelButton.tsx +0 -99
  309. package/src/modules/pr/components/PrCancelConfirmDialog.tsx +0 -119
  310. package/src/modules/pr/components/PrCommentComposer.tsx +0 -92
  311. package/src/modules/pr/components/PrCommentThread.tsx +0 -168
  312. package/src/modules/pr/components/PrCommentsPanel.tsx +0 -143
  313. package/src/modules/pr/components/PrDiffPane.tsx +0 -425
  314. package/src/modules/pr/components/PrFileRow.tsx +0 -164
  315. package/src/modules/pr/components/PrFilesList.tsx +0 -53
  316. package/src/modules/pr/components/PrHeader.tsx +0 -45
  317. package/src/modules/pr/components/PrHeaderOverflowMenu.tsx +0 -58
  318. package/src/modules/pr/components/PrMergeButton.tsx +0 -268
  319. package/src/modules/pr/components/PrMergeConfirmDialog.tsx +0 -112
  320. package/src/modules/pr/components/PrRefreshFromTargetButton.tsx +0 -110
  321. package/src/modules/pr/components/PrViewer.tsx +0 -364
  322. package/src/modules/pr/hooks/usePrViewerState.ts +0 -150
  323. package/src/modules/pr/state/pr-viewer.context.ts +0 -34
  324. package/src/modules/pr/utils/bucketize-comments.ts +0 -55
  325. package/src/modules/pr/utils/parsePatch.ts +0 -57
  326. package/src/modules/toolbar/components/AdminMenu.tsx +0 -271
@@ -10,6 +10,7 @@ import {
10
10
  type OpenTab,
11
11
  } from '../../state/workspace.context';
12
12
  import { makeWorkspaceFixture } from '../../__tests__/testFixtures';
13
+ import { OpenChangeRequestsContext } from '../../state/open-change-requests.context';
13
14
 
14
15
  function makeTab(path: string, overrides: Partial<OpenTab> = {}): OpenTab {
15
16
  const content = overrides.content ?? `content:${path}`;
@@ -63,11 +64,24 @@ vi.mock('../../routing/kb-routes', () => ({
63
64
  }),
64
65
  }));
65
66
 
66
- function Wrap({ workspace, children }: { workspace: WorkspaceContextValue; children: ReactNode }) {
67
+ function Wrap({
68
+ workspace,
69
+ changeRequestPaths = [],
70
+ children,
71
+ }: {
72
+ workspace: WorkspaceContextValue;
73
+ /** Workspace-relative paths with an open change request. */
74
+ changeRequestPaths?: string[];
75
+ children: ReactNode;
76
+ }) {
67
77
  return (
68
78
  <MemoryRouter>
69
79
  <WorkspaceContext.Provider value={workspace}>
70
- {children}
80
+ <OpenChangeRequestsContext.Provider
81
+ value={{ paths: new Set(changeRequestPaths), forPath: () => [], minePaths: new Map(), mineNumbers: new Set() }}
82
+ >
83
+ {children}
84
+ </OpenChangeRequestsContext.Provider>
71
85
  </WorkspaceContext.Provider>
72
86
  </MemoryRouter>
73
87
  );
@@ -160,7 +174,11 @@ describe('EditorTabs', () => {
160
174
  render(<Wrap workspace={ws}><EditorTabs /></Wrap>);
161
175
  fireEvent.contextMenu(screen.getAllByRole('tab')[0]);
162
176
  expect(screen.getByRole('menu')).toBeInTheDocument();
163
- fireEvent.keyDown(window, { key: 'Escape' });
177
+ // Dispatched on `document` rather than `window`: the strip's dismissal now
178
+ // comes from the shared `useDismissableMenu`, which binds where `Dialog`
179
+ // binds. A real Escape keypress reaches both — only the synthetic target
180
+ // moved.
181
+ fireEvent.keyDown(document, { key: 'Escape' });
164
182
  expect(screen.queryByRole('menu')).not.toBeInTheDocument();
165
183
  });
166
184
 
@@ -238,4 +256,70 @@ describe('EditorTabs', () => {
238
256
 
239
257
  expect(reorderTab).toHaveBeenCalledWith(tabs[0], 2);
240
258
  });
259
+
260
+ // ── WP3: the strip becomes the prototype's `.kbtabs` ──
261
+
262
+ it('marks the active tab with aria-current', () => {
263
+ const tabs = [makeTab('a.md'), makeTab('b.md')];
264
+ render(<Wrap workspace={makeWorkspace(tabs, 'b.md')}><EditorTabs /></Wrap>);
265
+ const [a, b] = screen.getAllByRole('tab');
266
+ expect(a).toHaveAttribute('aria-current', 'false');
267
+ expect(b).toHaveAttribute('aria-current', 'true');
268
+ });
269
+
270
+ it('underlines the active tab instead of filling it', () => {
271
+ const tabs = [makeTab('a.md'), makeTab('b.md')];
272
+ render(<Wrap workspace={makeWorkspace(tabs, 'b.md')}><EditorTabs /></Wrap>);
273
+ const [a, b] = screen.getAllByRole('tab');
274
+ expect(b.className).toContain('shadow-[inset_0_-2px_0_var(--color-ink)]');
275
+ expect(b.className).not.toContain('bg-sunken');
276
+ expect(a.className).not.toContain('shadow-[inset');
277
+ });
278
+
279
+ // Suppressing the scrollbar removes the only cue that more strip exists, so
280
+ // activation has to bring an off-screen tab to the user. Shipping the
281
+ // suppression without this makes a 20-tab strip worse than it was.
282
+ it('brings the active tab into view when it changes', () => {
283
+ const scrollIntoView = vi.fn();
284
+ // happy-dom does not implement scrollIntoView.
285
+ Object.defineProperty(HTMLElement.prototype, 'scrollIntoView', {
286
+ value: scrollIntoView,
287
+ configurable: true,
288
+ writable: true,
289
+ });
290
+ const tabs = [makeTab('a.md'), makeTab('b.md'), makeTab('c.md')];
291
+ render(<Wrap workspace={makeWorkspace(tabs, 'c.md')}><EditorTabs /></Wrap>);
292
+ expect(scrollIntoView).toHaveBeenCalledWith({ inline: 'nearest', block: 'nearest' });
293
+ });
294
+
295
+ it('reveals the close control to the keyboard, not to the mouse click', () => {
296
+ const tabs = [makeTab('a.md')];
297
+ render(<Wrap workspace={makeWorkspace(tabs, 'a.md')}><EditorTabs /></Wrap>);
298
+ const close = screen.getByRole('button', { name: 'Close a.md' });
299
+ // Reachable by name (the frozen a11y handle) whatever its opacity is.
300
+ expect(close.className).toContain('group-hover:opacity-100');
301
+ expect(close.className).toContain('focus-visible:opacity-100');
302
+ expect(close.className).not.toContain(' focus:opacity-100');
303
+ });
304
+
305
+ it('draws no scrollbar over the labels but keeps the strip scrollable', () => {
306
+ const tabs = [makeTab('a.md')];
307
+ render(<Wrap workspace={makeWorkspace(tabs, 'a.md')}><EditorTabs /></Wrap>);
308
+ const strip = screen.getByRole('tablist');
309
+ expect(strip.className).toContain('kb-tabstrip');
310
+ expect(strip.className).toContain('overflow-x-auto');
311
+ });
312
+
313
+ // WP6: the third place a file with an open request says so.
314
+ it('marks a tab whose file has an open change request', () => {
315
+ const tabs = [makeTab('a.md'), makeTab('b.md')];
316
+ render(
317
+ <Wrap workspace={makeWorkspace(tabs, 'a.md')} changeRequestPaths={['b.md']}>
318
+ <EditorTabs />
319
+ </Wrap>,
320
+ );
321
+ const [a, b] = screen.getAllByRole('tab');
322
+ expect(within(b).getByTitle('Open change request')).toBeInTheDocument();
323
+ expect(within(a).queryByTitle('Open change request')).toBeNull();
324
+ });
241
325
  });
@@ -8,7 +8,7 @@ import { WorkspaceContext, type UploadError, type WorkspaceContextValue } from '
8
8
  import { makeWorkspaceFixture } from '../../__tests__/testFixtures';
9
9
  import { GitContext, type GitContextValue } from '../../../git/state/git.context';
10
10
  import { AuthContext, type AuthContextValue } from '../../../auth/state/auth.context';
11
- import { PrViewerContext, type PrViewerContextValue } from '../../../pr/state/pr-viewer.context';
11
+ import { OpenChangeRequestsContext } from '../../state/open-change-requests.context';
12
12
 
13
13
  // PullRequestsForMe pulls in router/git wiring we don't want to exercise here;
14
14
  // stub it so the toolbar can be tested in isolation.
@@ -57,27 +57,13 @@ function makeGit(): GitContextValue {
57
57
  deleteBranch: async () => {},
58
58
  pull: async () => {},
59
59
  fetchForkBase: async () => null,
60
- revert: async () => ({ sha: 'a', authorName: 'n', authorEmail: 'e', subject: 's', committedAt: '2026-04-29T00:00:00Z' }),
61
60
  fetchFileHistory: async () => [],
62
61
  fetchFileDiff: async () => '',
62
+ fetchFileAtChange: async () => ({ baseline: null, current: null }),
63
63
  fetchFileComparison: async () => '',
64
64
  };
65
65
  }
66
66
 
67
- function makePrViewer(): PrViewerContextValue {
68
- return {
69
- openPrNumber: null,
70
- detail: null,
71
- notFound: false,
72
- selectedPath: null,
73
- isLoading: false,
74
- lastError: null,
75
- openPr: () => {},
76
- closeViewer: () => {},
77
- selectPath: () => {},
78
- refresh: async () => {},
79
- };
80
- }
81
67
 
82
68
  interface RenderOptions {
83
69
  dispatchUpload?: ReturnType<typeof vi.fn>;
@@ -86,35 +72,73 @@ interface RenderOptions {
86
72
  uploadError?: UploadError | null;
87
73
  fileTree?: FileTreeEntry | null;
88
74
  createFile?: ReturnType<typeof vi.fn>;
75
+ deleteEntry?: ReturnType<typeof vi.fn>;
76
+ openFilePath?: string | null;
77
+ /** Workspace-relative paths with an open change request. */
78
+ openChangeRequestPaths?: string[];
79
+ /** The caller's own open requests: workspace-relative path → CR number. */
80
+ minePaths?: Map<string, number>;
89
81
  }
90
82
 
91
83
  function renderExplorer(opts: RenderOptions = {}) {
92
84
  const dispatchUpload = opts.dispatchUpload ?? vi.fn().mockResolvedValue(undefined);
93
85
  const clearUploadError = opts.clearUploadError ?? vi.fn();
94
86
  const createFile = opts.createFile ?? vi.fn().mockResolvedValue(undefined);
87
+ const deleteEntry = opts.deleteEntry ?? vi.fn().mockResolvedValue(undefined);
95
88
  // Distinguish "caller wants null tree" from "caller didn't pass anything".
96
89
  const fileTree = 'fileTree' in opts ? opts.fileTree ?? null : EMPTY_TREE;
97
90
  const workspace: WorkspaceContextValue = makeWorkspaceFixture({
98
91
  fileTree,
99
92
  uploadError: opts.uploadError ?? null,
100
93
  isUploading: opts.isUploading ?? false,
94
+ openFilePath: opts.openFilePath ?? null,
101
95
  refreshFileTree: async () => fileTree,
102
96
  dispatchUpload,
103
97
  clearUploadError,
104
98
  createFile,
99
+ deleteEntry,
105
100
  });
106
101
  return {
107
102
  dispatchUpload,
108
103
  clearUploadError,
109
104
  createFile,
105
+ deleteEntry,
110
106
  ...render(
111
107
  <MemoryRouter>
112
108
  <AuthContext.Provider value={makeAuth()}>
113
109
  <WorkspaceContext.Provider value={workspace}>
114
110
  <GitContext.Provider value={makeGit()}>
115
- <PrViewerContext.Provider value={makePrViewer()}>
116
- <FileExplorer />
117
- </PrViewerContext.Provider>
111
+ <OpenChangeRequestsContext.Provider
112
+ value={{
113
+ paths: new Set(opts.openChangeRequestPaths ?? []),
114
+ // A suggestion row resolves its request through forPath —
115
+ // synthesize a summary for every minePaths entry so the
116
+ // shared dialog has something to open.
117
+ forPath: (p) => {
118
+ const n = opts.minePaths?.get(p);
119
+ return n === undefined
120
+ ? []
121
+ : ([
122
+ {
123
+ number: n,
124
+ title: 'Suggested change',
125
+ branch: 'suggestions/me/knowledge',
126
+ base: 'main',
127
+ state: 'open',
128
+ createdAt: '2026-08-01T00:00:00.000Z',
129
+ touchedNodePaths: [p],
130
+ author: { login: 'user-x' },
131
+ review: { approvals: 0, changesRequested: 0, pendingLogins: [] },
132
+ url: '',
133
+ },
134
+ ] as never);
135
+ },
136
+ minePaths: opts.minePaths ?? new Map(),
137
+ mineNumbers: new Set(opts.minePaths?.values() ?? []),
138
+ }}
139
+ >
140
+ <FileExplorer />
141
+ </OpenChangeRequestsContext.Provider>
118
142
  </GitContext.Provider>
119
143
  </WorkspaceContext.Provider>
120
144
  </AuthContext.Provider>
@@ -132,6 +156,21 @@ describe('FileExplorer toolbar', () => {
132
156
  cleanup();
133
157
  });
134
158
 
159
+ /**
160
+ * A `//` comment placed among JSX CHILDREN is not a comment — it is text,
161
+ * and it renders. TypeScript accepts it, the ratchet ignores it, and every
162
+ * existing test here queries by role or test id, so a four-line source
163
+ * comment once shipped to the top of the file tree in full view. The check
164
+ * is cheap and the failure mode is invisible to everything else.
165
+ */
166
+ it('renders no source comments as page text', () => {
167
+ // The whole container, not the root div: the comment that prompted this
168
+ // was a SIBLING of the tree inside the top-level fragment, so anything
169
+ // scoped to the tree itself would have walked straight past it.
170
+ const { container } = renderExplorer();
171
+ expect(container.textContent ?? '').not.toMatch(/\/\//);
172
+ });
173
+
135
174
  it('renders the Add files button and the hidden file input', () => {
136
175
  renderExplorer();
137
176
  const button = screen.getByRole('button', { name: /Add files/i });
@@ -243,7 +282,7 @@ describe('FileExplorer toolbar', () => {
243
282
  it('routes root-level drag-and-drop through dispatchUpload (parity with the button)', async () => {
244
283
  const dispatchUpload = vi.fn().mockResolvedValue(undefined);
245
284
  renderExplorer({ dispatchUpload });
246
- const aside = screen.getByRole('complementary');
285
+ const aside = screen.getByTestId('file-explorer-root');
247
286
  const file = new File(['drop'], 'dropped.md');
248
287
  await act(async () => {
249
288
  fireEvent.drop(aside, {
@@ -270,7 +309,7 @@ describe('FileExplorer toolbar', () => {
270
309
  });
271
310
  });
272
311
 
273
- describe('FileExplorer right-click — Download menu (per-path access)', () => {
312
+ describe('FileExplorer right-click: Download menu (per-path access)', () => {
274
313
  beforeEach(() => {
275
314
  cleanup();
276
315
  mockAuthFetch.mockReset();
@@ -423,7 +462,7 @@ describe('FileExplorer right-click — Download menu (per-path access)', () => {
423
462
  // The fix introduces a tri-state `userIntent` that overrides auto-expand and
424
463
  // resets when the auto-expand trigger transitions. These tests would have
425
464
  // caught the original regression.
426
- describe('FileExplorer chevron collapse — userIntent vs autoExpanded', () => {
465
+ describe('FileExplorer chevron collapse: userIntent vs autoExpanded', () => {
427
466
  beforeEach(() => {
428
467
  cleanup();
429
468
  });
@@ -458,9 +497,7 @@ describe('FileExplorer chevron collapse — userIntent vs autoExpanded', () => {
458
497
  <AuthContext.Provider value={makeAuth()}>
459
498
  <WorkspaceContext.Provider value={workspace}>
460
499
  <GitContext.Provider value={makeGit()}>
461
- <PrViewerContext.Provider value={makePrViewer()}>
462
500
  <FileExplorer />
463
- </PrViewerContext.Provider>
464
501
  </GitContext.Provider>
465
502
  </WorkspaceContext.Provider>
466
503
  </AuthContext.Provider>
@@ -574,9 +611,8 @@ describe('FileExplorer chevron collapse — userIntent vs autoExpanded', () => {
574
611
  });
575
612
 
576
613
  // The KB level splits the well-known root folders into labelled top-level
577
- // sections. `Data/`, `Agents/` and `Pipelines/` get their own sections like
578
- // Skills/Tools — they must not fold into the Knowledge section.
579
- describe('FileExplorer sections — root folders', () => {
614
+ // sections — with one deliberate exception, `Groups/`.
615
+ describe('FileExplorer sections: root folders', () => {
580
616
  beforeEach(() => {
581
617
  cleanup();
582
618
  });
@@ -588,27 +624,59 @@ describe('FileExplorer sections — root folders', () => {
588
624
  children: [],
589
625
  });
590
626
 
591
- it('renders Data, Agents and Pipelines as their own top-level sections', () => {
627
+ /**
628
+ * `Data/`, `Agents/` and `Pipelines/` are never created by core — a
629
+ * deployment that owns the agentic execution layer seeds them. When they ARE
630
+ * there they get their own sections, and in particular must not fold into
631
+ * Knowledge the way a stray content folder does.
632
+ */
633
+ it('renders Data, Agents and Pipelines as their own sections when present', () => {
592
634
  const tree: FileTreeEntry = {
593
635
  name: '.',
594
636
  relativePath: '.',
595
637
  type: 'directory',
596
- children: [
597
- dir('KnowledgeBase'),
598
- dir('Data'),
599
- dir('Agents'),
600
- dir('Pipelines'),
601
- dir('Skills'),
602
- dir('Tools'),
603
- ],
638
+ children: [dir('KnowledgeBase'), dir('Data'), dir('Agents'), dir('Pipelines')],
604
639
  };
605
640
  renderExplorer({ fileTree: tree });
606
641
  expect(screen.getByText('Knowledge')).toBeInTheDocument();
607
642
  expect(screen.getByText('Data')).toBeInTheDocument();
608
643
  expect(screen.getByText('Agents')).toBeInTheDocument();
609
644
  expect(screen.getByText('Pipelines')).toBeInTheDocument();
610
- expect(screen.getByText('Skills')).toBeInTheDocument();
611
- expect(screen.getByText('Tools')).toBeInTheDocument();
645
+ });
646
+
647
+ /**
648
+ * `Groups/` is the Skills & Tools app's storage, and that app presents it as
649
+ * groups, skills and tools. Listing it here offered a second, worse way in —
650
+ * raw markdown editing of a SKILL.md, on a folder whose access is managed
651
+ * from the group page.
652
+ *
653
+ * Not shown, and NOT folded into Knowledge either: it is a reserved root, so
654
+ * the "stray content folder" path must not pick it up. Both halves are
655
+ * asserted, because dropping it from the reserved set would still hide the
656
+ * section while quietly moving the whole folder under Knowledge.
657
+ */
658
+ it('never shows Groups in the knowledge view', () => {
659
+ const tree: FileTreeEntry = {
660
+ name: '.',
661
+ relativePath: '.',
662
+ type: 'directory',
663
+ children: [dir('KnowledgeBase'), dir('Groups')],
664
+ };
665
+ renderExplorer({ fileTree: tree });
666
+ expect(screen.getByText('Knowledge')).toBeInTheDocument();
667
+ expect(screen.queryByText('Groups')).not.toBeInTheDocument();
668
+ });
669
+
670
+ /** A KB whose only root is Groups still has a knowledge view — an empty one. */
671
+ it('does not fall back to the flat tree when Groups is the only root', () => {
672
+ const tree: FileTreeEntry = {
673
+ name: '.',
674
+ relativePath: '.',
675
+ type: 'directory',
676
+ children: [dir('Groups')],
677
+ };
678
+ renderExplorer({ fileTree: tree });
679
+ expect(screen.queryByText('Groups')).not.toBeInTheDocument();
612
680
  });
613
681
  });
614
682
 
@@ -619,7 +687,7 @@ describe('FileExplorer sections — root folders', () => {
619
687
  // the same doomed create, which re-alerted, forever. The fix closes the
620
688
  // input (setCreating(null)) BEFORE the fallible create, so there's nothing
621
689
  // left to re-blur-submit.
622
- describe('FileExplorer create — no alert loop on a write-denied path', () => {
690
+ describe('FileExplorer create: no alert loop on a write-denied path', () => {
623
691
  beforeEach(() => {
624
692
  cleanup();
625
693
  });
@@ -664,3 +732,189 @@ describe('FileExplorer create — no alert loop on a write-denied path', () => {
664
732
  }
665
733
  });
666
734
  });
735
+
736
+ // ── WP2: names and one caret, nothing else ──
737
+
738
+ describe('FileExplorer rows: the prototype tree', () => {
739
+ const TREE: FileTreeEntry = {
740
+ name: '.',
741
+ relativePath: '.',
742
+ type: 'directory',
743
+ children: [
744
+ { name: 'reports', relativePath: 'reports', type: 'directory', children: [] },
745
+ {
746
+ name: 'docs',
747
+ relativePath: 'docs',
748
+ type: 'directory',
749
+ children: [{ name: 'a.md', relativePath: 'docs/a.md', type: 'file' }],
750
+ },
751
+ { name: 'brief.md', relativePath: 'brief.md', type: 'file' },
752
+ ],
753
+ };
754
+
755
+ beforeEach(() => {
756
+ cleanup();
757
+ mockAuthFetch.mockReset();
758
+ });
759
+
760
+ // The folder icon repeated what the caret said and the file icon repeated
761
+ // what the extension said. Both are gone; the row is a name and a caret.
762
+ it('renders no folder or per-extension file icons', () => {
763
+ const { container } = renderExplorer({ fileTree: TREE });
764
+ // The iconify glyphs mounted as <svg> siblings of the name; lucide's
765
+ // Folder/FolderOpen did too. What survives in a row is at most the caret.
766
+ expect(container.querySelector('.iconify')).toBeNull();
767
+ const row = screen.getByText('brief.md').closest('button')!;
768
+ expect(row.querySelectorAll('svg')).toHaveLength(0);
769
+ });
770
+
771
+ it('gives a childless folder no caret and does not toggle it', async () => {
772
+ renderExplorer({ fileTree: TREE });
773
+ const empty = screen.getByText('reports').closest('button')!;
774
+ expect(empty.querySelectorAll('svg')).toHaveLength(0);
775
+ expect(empty).toHaveAttribute('aria-expanded');
776
+
777
+ const withKids = screen.getByText('docs').closest('button')!;
778
+ expect(withKids.querySelectorAll('svg')).toHaveLength(1);
779
+ });
780
+
781
+ it('marks directory rows with aria-expanded and the open file with aria-current', () => {
782
+ renderExplorer({ fileTree: TREE, openFilePath: 'docs/a.md' });
783
+ expect(screen.getByText('docs').closest('button')).toHaveAttribute('aria-expanded', 'true');
784
+ expect(screen.getByText('a.md').closest('button')).toHaveAttribute('aria-current', 'true');
785
+ expect(screen.getByText('brief.md').closest('button')).toHaveAttribute('aria-current', 'false');
786
+ });
787
+
788
+ // The one prototype context-menu item the platform never had.
789
+ it('offers Copy path in the context menu and writes the entry path', async () => {
790
+ const writeText = vi.fn(async () => {});
791
+ Object.defineProperty(navigator, 'clipboard', {
792
+ value: { writeText },
793
+ configurable: true,
794
+ });
795
+ renderExplorer({ fileTree: TREE });
796
+
797
+ fireEvent.contextMenu(screen.getByText('brief.md'));
798
+ await act(async () => {
799
+ fireEvent.click(screen.getByRole('menuitem', { name: /Copy path/i }));
800
+ });
801
+ expect(writeText).toHaveBeenCalledWith('brief.md');
802
+ });
803
+
804
+ it('offers Copy path on a folder row too', () => {
805
+ renderExplorer({ fileTree: TREE });
806
+ fireEvent.contextMenu(screen.getByText('reports'));
807
+ expect(screen.getByRole('menuitem', { name: /Copy path/i })).toBeInTheDocument();
808
+ });
809
+
810
+ // MenuPanel is presentation only, so the dismissal is the caller's — and a
811
+ // menu you can only close by picking something is a keyboard trap.
812
+ it('closes the context menu on Escape and hands focus back to the row', async () => {
813
+ renderExplorer({ fileTree: TREE });
814
+ const row = screen.getByText('brief.md').closest('button')!;
815
+ fireEvent.contextMenu(screen.getByText('brief.md'));
816
+ expect(screen.getByRole('menu')).toBeInTheDocument();
817
+
818
+ await act(async () => {
819
+ fireEvent.keyDown(document, { key: 'Escape' });
820
+ });
821
+ expect(screen.queryByRole('menu')).not.toBeInTheDocument();
822
+ expect(document.activeElement).toBe(row);
823
+ });
824
+
825
+ it('closes the context menu on an outside click', async () => {
826
+ renderExplorer({ fileTree: TREE });
827
+ fireEvent.contextMenu(screen.getByText('brief.md'));
828
+ expect(screen.getByRole('menu')).toBeInTheDocument();
829
+
830
+ await act(async () => {
831
+ fireEvent.mouseDown(document.body);
832
+ });
833
+ expect(screen.queryByRole('menu')).not.toBeInTheDocument();
834
+ });
835
+
836
+ it('still deletes from the context menu', async () => {
837
+ const deleteEntry = vi.fn(async () => {});
838
+ renderExplorer({ fileTree: TREE, deleteEntry });
839
+ fireEvent.contextMenu(screen.getByText('brief.md'));
840
+ await act(async () => {
841
+ fireEvent.click(screen.getByRole('menuitem', { name: /Delete/i }));
842
+ });
843
+ expect(deleteEntry).toHaveBeenCalledWith('brief.md');
844
+ });
845
+
846
+ // WP6: the tree consumes the SHARED, workspace-relative set. The two path
847
+ // spaces are joined in the provider; here the row just has to light up for
848
+ // the path the tree actually holds.
849
+ it('marks a row whose file has an open change request', () => {
850
+ renderExplorer({
851
+ fileTree: TREE,
852
+ openChangeRequestPaths: ['brief.md'],
853
+ });
854
+ const marked = screen.getByText('brief.md').closest('button')!;
855
+ expect(marked.querySelector('[title="Open change request"]')).not.toBeNull();
856
+ const unmarked = screen.getByText('docs').closest('button')!;
857
+ expect(unmarked.querySelector('[title="Open change request"]')).toBeNull();
858
+ });
859
+
860
+ /**
861
+ * The tree shows files from two places: this branch, and the caller's own
862
+ * open change requests. A proposed file that does not exist on the branch
863
+ * is synthesized in — coloured differently, and a click opens the change
864
+ * request, because there is no content on this branch to open.
865
+ */
866
+ it('shows my proposed-only file as a suggestion row that opens the change request', async () => {
867
+ renderExplorer({
868
+ fileTree: TREE,
869
+ minePaths: new Map([['docs/new-idea.md', 12]]),
870
+ });
871
+
872
+ // Synthesized into its real place in the tree, under `docs/`.
873
+ const row = screen
874
+ .getByTitle('Proposed by you: opens the change request')
875
+ .closest('button')!;
876
+ expect(row).toHaveTextContent('new-idea.md');
877
+ expect(row.className).toContain('text-accent');
878
+
879
+ // The click opens the SHARED change-request dialog — there is no content
880
+ // on this branch to open.
881
+ fireEvent.click(row);
882
+ expect(
883
+ await screen.findByRole('dialog', { name: /Change request: Suggested change/ }),
884
+ ).toBeInTheDocument();
885
+ });
886
+
887
+ /**
888
+ * "Not in the tree" is ambiguous: new on the suggestions branch, or FILTERED
889
+ * by the server (.bevelignore, read gates). The overlay may only resurrect
890
+ * the first — a proposal under a hidden root folder must not conjure that
891
+ * folder back into the sidebar.
892
+ */
893
+ it('does not synthesize a row under a root folder the server hid', () => {
894
+ renderExplorer({
895
+ fileTree: TREE,
896
+ // `Groups` is not in TREE — the server filtered it (bevelignored). The
897
+ // touched file underneath must NOT appear.
898
+ minePaths: new Map([['Groups/newsletter/SKILL.md', 12]]),
899
+ });
900
+ expect(screen.queryByTitle('Proposed by you: opens the change request')).toBeNull();
901
+ expect(screen.queryByText('Groups')).toBeNull();
902
+ expect(screen.queryByText('SKILL.md')).toBeNull();
903
+ });
904
+
905
+ it('keeps a file that exists on the branch as a normal row even when my request touches it', () => {
906
+ renderExplorer({
907
+ fileTree: TREE,
908
+ minePaths: new Map([['brief.md', 12]]),
909
+ });
910
+
911
+ // Not synthesized, not recoloured — the branch's own file wins, and the
912
+ // open-request signal for it stays the amber dot (asserted above).
913
+ expect(screen.queryByTitle('Proposed by you: opens the change request')).toBeNull();
914
+ const row = screen.getByText('brief.md').closest('button')!;
915
+ expect(row.className).not.toContain('text-accent');
916
+ // A normal row opens the FILE, never the dialog.
917
+ fireEvent.click(row);
918
+ expect(screen.queryByRole('dialog')).toBeNull();
919
+ });
920
+ });
@@ -10,7 +10,6 @@ import { WorkspaceContext, type WorkspaceContextValue, type OpenTab } from '../.
10
10
  import { makeWorkspaceFixture } from '../../__tests__/testFixtures';
11
11
  import { ReviewContext, type ReviewContextValue } from '../../../review/state/review.context';
12
12
  import { AuthContext, type AuthContextValue } from '../../../auth/state/auth.context';
13
- import { PrViewerContext, type PrViewerContextValue } from '../../../pr/state/pr-viewer.context';
14
13
 
15
14
  function makeStatus(branch = 'alice/draft'): WorkingTreeStatus {
16
15
  return { branch, hasUpstream: true, unmergedFromUpstream: false };
@@ -29,9 +28,9 @@ function makeGit(overrides: Partial<GitContextValue> = {}): GitContextValue {
29
28
  deleteBranch: async () => {},
30
29
  pull: async () => {},
31
30
  fetchForkBase: async () => null,
32
- revert: async () => ({ sha: 'a', authorName: 'n', authorEmail: 'e', subject: 's', committedAt: '2026-04-20T00:00:00.000Z' }),
33
31
  fetchFileHistory: async () => [],
34
32
  fetchFileDiff: async () => '',
33
+ fetchFileAtChange: async () => ({ baseline: null, current: null }),
35
34
  fetchFileComparison: async () => '',
36
35
  ...overrides,
37
36
  };
@@ -105,18 +104,6 @@ function renderAt(
105
104
  login: async () => {},
106
105
  logout: () => {},
107
106
  };
108
- const prViewer: PrViewerContextValue = {
109
- openPrNumber: null,
110
- detail: null,
111
- notFound: false,
112
- selectedPath: null,
113
- isLoading: false,
114
- lastError: null,
115
- openPr: () => {},
116
- closeViewer: () => {},
117
- selectPath: () => {},
118
- refresh: async () => {},
119
- };
120
107
 
121
108
  function Tree({ children }: { children: ReactNode }) {
122
109
  return (
@@ -124,9 +111,7 @@ function renderAt(
124
111
  <WorkspaceContext.Provider value={workspace}>
125
112
  <GitContext.Provider value={git}>
126
113
  <ReviewContext.Provider value={review}>
127
- <PrViewerContext.Provider value={prViewer}>
128
114
  {children}
129
- </PrViewerContext.Provider>
130
115
  </ReviewContext.Provider>
131
116
  </GitContext.Provider>
132
117
  </WorkspaceContext.Provider>