@bevel-software/platform-core-frontend 0.4.1 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (327) hide show
  1. package/THIRD-PARTY-NOTICES.md +5366 -0
  2. package/package.json +7 -4
  3. package/src/core/CoreAppShell.tsx +195 -56
  4. package/src/core/__tests__/AppChrome.test.tsx +125 -0
  5. package/src/core/__tests__/ShellRoutes.test.tsx +37 -2
  6. package/src/core/__tests__/bootstrap.test.ts +63 -0
  7. package/src/core/bootstrap.ts +73 -0
  8. package/src/core/events.ts +12 -0
  9. package/src/core/registry.ts +58 -9
  10. package/src/index.css +100 -11
  11. package/src/index.ts +24 -23
  12. package/src/lib/utils.ts +93 -117
  13. package/src/modules/access/__tests__/ManageAccessDialog.placement.test.tsx +281 -0
  14. package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +166 -1
  15. package/src/modules/access/api.ts +49 -0
  16. package/src/modules/access/components/ManageAccessDialog.tsx +786 -481
  17. package/src/modules/access/hooks/useFileAccess.ts +1 -1
  18. package/src/modules/admin/__tests__/AdminRolesPage.suggest.test.tsx +86 -0
  19. package/src/modules/admin/__tests__/UserAccountsPage.test.tsx +17 -1
  20. package/src/modules/admin/__tests__/admin.unread.test.tsx +61 -0
  21. package/src/modules/admin/components/AdminRolesPage.tsx +44 -38
  22. package/src/modules/admin/components/RolesCorruptedBanner.tsx +11 -10
  23. package/src/modules/admin/components/UserAccountsPage.tsx +36 -28
  24. package/src/modules/admin/state/admin.context.tsx +15 -6
  25. package/src/modules/auth/components/AccountPage.tsx +11 -11
  26. package/src/modules/auth/components/LoginScreen.tsx +12 -12
  27. package/src/modules/auth/services/sso.ts +47 -1
  28. package/src/modules/change-requests/__tests__/ChangeRequestDialog.test.tsx +277 -0
  29. package/src/modules/change-requests/__tests__/author.test.ts +48 -0
  30. package/src/modules/change-requests/__tests__/conflict.test.ts +73 -0
  31. package/src/modules/change-requests/__tests__/diff.test.ts +134 -0
  32. package/src/modules/change-requests/__tests__/propose.test.ts +93 -0
  33. package/src/modules/change-requests/__tests__/useFileOnBranch.test.tsx +72 -0
  34. package/src/modules/change-requests/change-requests.css +22 -0
  35. package/src/modules/change-requests/components/ChangeBox.tsx +277 -0
  36. package/src/modules/change-requests/components/ChangeRequestDialog.tsx +713 -0
  37. package/src/modules/change-requests/components/ConflictHelp.tsx +47 -0
  38. package/src/modules/change-requests/components/CrFileTree.tsx +398 -0
  39. package/src/modules/change-requests/components/FileChangeBoxes.tsx +168 -0
  40. package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +236 -0
  41. package/src/modules/change-requests/hooks/useCrFileDiffs.ts +79 -0
  42. package/src/modules/change-requests/hooks/useFileOnBranch.ts +80 -0
  43. package/src/modules/change-requests/services/change-requests.api.ts +45 -0
  44. package/src/modules/change-requests/services/propose.api.ts +162 -0
  45. package/src/modules/change-requests/utils/author.ts +47 -0
  46. package/src/modules/change-requests/utils/conflict.ts +38 -0
  47. package/src/modules/change-requests/utils/diff.ts +80 -0
  48. package/src/modules/git/__tests__/BranchSwitcher.test.tsx +27 -18
  49. package/src/modules/git/__tests__/FileHistoryPanel.test.tsx +36 -83
  50. package/src/modules/git/__tests__/PullNeededBanner.test.tsx +5 -5
  51. package/src/modules/git/__tests__/PullRequestsForMe.test.tsx +147 -0
  52. package/src/modules/git/__tests__/useAutoPullUpdates.test.tsx +2 -8
  53. package/src/modules/git/components/BranchSwitcher.tsx +68 -31
  54. package/src/modules/git/components/DiffView.tsx +4 -4
  55. package/src/modules/git/components/FileComparisonPanel.tsx +20 -20
  56. package/src/modules/git/components/FileHistoryPanel.tsx +71 -107
  57. package/src/modules/git/components/PullNeededBanner.tsx +6 -13
  58. package/src/modules/git/components/PullRequestsForMe.tsx +71 -36
  59. package/src/modules/git/components/UnifiedDiffView.tsx +4 -4
  60. package/src/modules/git/hooks/__tests__/useGitState.deleteBranch.test.tsx +2 -2
  61. package/src/modules/git/hooks/useGitState.ts +15 -14
  62. package/src/modules/git/services/__tests__/error-messages.test.ts +4 -4
  63. package/src/modules/git/services/error-messages.ts +7 -7
  64. package/src/modules/git/services/git.api.ts +17 -11
  65. package/src/modules/git/services/pr-prompts.ts +2 -2
  66. package/src/modules/git/state/git.context.ts +10 -1
  67. package/src/modules/layout/__tests__/SidebarFrameResponsive.test.tsx +224 -0
  68. package/src/modules/layout/__tests__/SidebarToggle.test.tsx +242 -0
  69. package/src/modules/layout/__tests__/breakpoints.test.ts +56 -0
  70. package/src/modules/layout/breakpoints.ts +6 -0
  71. package/src/modules/layout/components/AppLayout.tsx +17 -5
  72. package/src/modules/layout/components/DemoBanner.tsx +10 -1
  73. package/src/modules/layout/components/MaintenanceOverlay.tsx +3 -3
  74. package/src/modules/layout/components/MobileChatLayout.tsx +31 -26
  75. package/src/modules/layout/components/ResizableThreePaneLayout.tsx +59 -24
  76. package/src/modules/layout/components/SidebarFrame.tsx +317 -0
  77. package/src/modules/layout/components/SidebarToggle.tsx +86 -0
  78. package/src/modules/layout/components/SlideOverlay.tsx +1 -1
  79. package/src/modules/layout/components/__tests__/MobileChatLayout.test.tsx +40 -2
  80. package/src/modules/layout/components/__tests__/ResizableThreePaneLayout.test.tsx +19 -3
  81. package/src/modules/layout/state/sidebar.ts +200 -0
  82. package/src/modules/library/__tests__/AddToGroupDialog.test.tsx +313 -0
  83. package/src/modules/library/__tests__/ChangeRequestDock.test.tsx +84 -0
  84. package/src/modules/library/__tests__/GroupJoinRequests.test.tsx +178 -0
  85. package/src/modules/library/__tests__/GroupPage.test.tsx +479 -0
  86. package/src/modules/library/__tests__/GroupsIndexPage.test.tsx +283 -0
  87. package/src/modules/library/__tests__/GroupsSidebar.contextmenu.test.tsx +175 -0
  88. package/src/modules/library/__tests__/GroupsSidebar.locked.test.tsx +96 -0
  89. package/src/modules/library/__tests__/GroupsSidebar.test.tsx +142 -0
  90. package/src/modules/library/__tests__/GroupsSidebarMenu.test.tsx +142 -0
  91. package/src/modules/library/__tests__/LibraryCard.test.tsx +149 -0
  92. package/src/modules/library/__tests__/LibraryRoutes.test.tsx +378 -0
  93. package/src/modules/library/__tests__/LibrarySidebarMenu.test.tsx +347 -0
  94. package/src/modules/library/__tests__/LockedGroupView.test.tsx +203 -0
  95. package/src/modules/library/__tests__/NewGroupDialog.test.tsx +114 -0
  96. package/src/modules/library/__tests__/PersonalAddDialog.test.tsx +177 -0
  97. package/src/modules/library/__tests__/SkillPage.test.tsx +1063 -0
  98. package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +259 -0
  99. package/src/modules/library/__tests__/ToolLogo.test.tsx +63 -0
  100. package/src/modules/library/__tests__/ToolPage.test.tsx +315 -0
  101. package/src/modules/library/__tests__/ToolSharePanel.test.tsx +36 -0
  102. package/src/modules/library/__tests__/ToolVarRow.test.tsx +260 -0
  103. package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +197 -0
  104. package/src/modules/library/__tests__/auth-harness.tsx +37 -0
  105. package/src/modules/library/__tests__/oauth-fragment.test.ts +48 -0
  106. package/src/modules/library/__tests__/status.test.ts +113 -20
  107. package/src/modules/library/__tests__/useSkillDetail.test.tsx +102 -0
  108. package/src/modules/library/__tests__/useToolPage.test.tsx +146 -0
  109. package/src/modules/library/components/AccessRequestsBanner.tsx +101 -0
  110. package/src/modules/library/components/AddToGroupDialog.tsx +115 -0
  111. package/src/modules/library/components/ChangeRequestDock.tsx +52 -28
  112. package/src/modules/library/components/DeleteGroupDialog.tsx +87 -0
  113. package/src/modules/library/components/GroupIndexRow.tsx +63 -0
  114. package/src/modules/library/components/GroupJoinRequests.tsx +56 -0
  115. package/src/modules/library/components/GroupPage.tsx +373 -0
  116. package/src/modules/library/components/GroupsIndexPage.tsx +222 -0
  117. package/src/modules/library/components/GroupsSidebar.tsx +338 -0
  118. package/src/modules/library/components/GroupsSidebarMenu.tsx +160 -0
  119. package/src/modules/library/components/LibraryCard.tsx +123 -102
  120. package/src/modules/library/components/LibraryLayout.tsx +344 -0
  121. package/src/modules/library/components/LibraryPage.tsx +111 -227
  122. package/src/modules/library/components/LockGlyph.tsx +31 -0
  123. package/src/modules/library/components/LockedGroupView.tsx +159 -0
  124. package/src/modules/library/components/ManagedGroupRequests.tsx +70 -0
  125. package/src/modules/library/components/NewGroupDialog.tsx +112 -0
  126. package/src/modules/library/components/NewSkillPanel.tsx +151 -0
  127. package/src/modules/library/components/PageActions.tsx +156 -0
  128. package/src/modules/library/components/PendingSkillReview.tsx +63 -0
  129. package/src/modules/library/components/PersonalAddDialog.tsx +88 -0
  130. package/src/modules/library/components/PersonalGroupPage.tsx +125 -0
  131. package/src/modules/library/components/StatusDot.tsx +25 -0
  132. package/src/modules/library/components/ToolLogo.tsx +171 -0
  133. package/src/modules/library/components/group-page-parts.tsx +419 -0
  134. package/src/modules/library/components/skill-page/SkillFileEditor.tsx +134 -0
  135. package/src/modules/library/components/skill-page/SkillFilePane.tsx +117 -0
  136. package/src/modules/library/components/skill-page/SkillFileTabs.tsx +112 -0
  137. package/src/modules/library/components/skill-page/SkillPage.tsx +673 -0
  138. package/src/modules/library/components/skill-page/tab-ids.ts +33 -0
  139. package/src/modules/library/components/tool-page/ToolConnectionSection.tsx +175 -0
  140. package/src/modules/library/components/tool-page/ToolPage.tsx +228 -0
  141. package/src/modules/library/components/tool-page/ToolSharePanel.tsx +45 -0
  142. package/src/modules/library/components/tool-page/ToolVarRow.tsx +289 -0
  143. package/src/modules/library/hooks/useJoinRequests.ts +114 -0
  144. package/src/modules/library/hooks/useLibraryData.ts +134 -119
  145. package/src/modules/library/hooks/useSkillDetail.ts +119 -74
  146. package/src/modules/library/hooks/useToolPage.ts +145 -0
  147. package/src/modules/library/library.css +33 -245
  148. package/src/modules/library/routes/LibraryRoutes.tsx +134 -0
  149. package/src/modules/library/routes/WorkspaceItemRoute.tsx +74 -0
  150. package/src/modules/library/routes/library-paths.ts +191 -0
  151. package/src/modules/library/services/groups.api.ts +189 -0
  152. package/src/modules/library/services/library.api.ts +291 -164
  153. package/src/modules/library/services/tools.api.ts +60 -0
  154. package/src/modules/library/state/library-context.ts +22 -0
  155. package/src/modules/library/state/library-data.tsx +223 -0
  156. package/src/modules/library/state/toast.context.ts +32 -0
  157. package/src/modules/library/state/toast.tsx +84 -42
  158. package/src/modules/library/utils/clipboard.ts +33 -0
  159. package/src/modules/library/utils/group-summary.ts +68 -0
  160. package/src/modules/library/utils/names.ts +30 -0
  161. package/src/modules/library/utils/navigate-external.ts +15 -0
  162. package/src/modules/library/utils/oauth-fragment.ts +32 -0
  163. package/src/modules/library/utils/personal-group.ts +36 -0
  164. package/src/modules/library/utils/status.ts +108 -25
  165. package/src/modules/library/utils/toast-duration.ts +16 -0
  166. package/src/modules/onboarding/__tests__/onboarding.test.tsx +533 -0
  167. package/src/modules/onboarding/agent-clients.ts +48 -0
  168. package/src/modules/onboarding/components/ConnectAgentPill.tsx +133 -0
  169. package/src/modules/onboarding/components/RootLanding.tsx +54 -0
  170. package/src/modules/onboarding/components/WelcomePage.tsx +364 -0
  171. package/src/modules/onboarding/paths.ts +9 -0
  172. package/src/modules/onboarding/state/onboarding.ts +191 -0
  173. package/src/modules/pr/components/OpenChangeRequestDialog.tsx +10 -10
  174. package/src/modules/pr/services/pr-approvals.api.ts +19 -0
  175. package/src/modules/pr/services/pr-cancel.api.ts +11 -0
  176. package/src/modules/review/components/BinaryChangePlaceholder.tsx +3 -3
  177. package/src/modules/review/components/DiffViewer.tsx +4 -4
  178. package/src/modules/review/components/MarkdownDiffViewer.tsx +84 -26
  179. package/src/modules/review/components/ReviewFileRow.tsx +10 -10
  180. package/src/modules/review/components/ReviewPanel.tsx +49 -17
  181. package/src/modules/review/components/ReviewPanelSurface.tsx +1 -1
  182. package/src/modules/review/components/__tests__/MarkdownDiffViewer.test.tsx +122 -0
  183. package/src/modules/review/hooks/__tests__/useReviewState.test.ts +1 -1
  184. package/src/modules/secrets-vault/components/ConnectToolsPage.tsx +273 -171
  185. package/src/modules/secrets-vault/components/SecretsPage.tsx +147 -110
  186. package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +109 -92
  187. package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +35 -4
  188. package/src/modules/secrets-vault/services/connect.api.ts +24 -3
  189. package/src/modules/settings/components/DeploymentPage.tsx +90 -0
  190. package/src/modules/settings/components/SettingsLayout.tsx +135 -0
  191. package/src/modules/settings/components/SettingsNav.tsx +114 -0
  192. package/src/modules/settings/components/__tests__/DeploymentPage.test.tsx +110 -0
  193. package/src/modules/settings/components/__tests__/SettingsLayout.test.tsx +249 -0
  194. package/src/modules/settings/settings-nav-items.tsx +166 -0
  195. package/src/modules/setup/__tests__/setup.test.tsx +540 -0
  196. package/src/modules/setup/components/SetupGate.tsx +67 -0
  197. package/src/modules/setup/components/SetupScreen.tsx +573 -0
  198. package/src/modules/setup/services/setup.api.ts +106 -0
  199. package/src/modules/setup/utils/git-host.ts +34 -0
  200. package/src/modules/toolbar/components/AppSwitcher.tsx +38 -15
  201. package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +50 -50
  202. package/src/modules/toolbar/components/ProfileMenu.tsx +294 -0
  203. package/src/modules/toolbar/components/Toolbar.tsx +56 -54
  204. package/src/modules/toolbar/components/__tests__/AppSwitcher.test.tsx +176 -122
  205. package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +252 -77
  206. package/src/modules/tools/ToolsExplorerPage.tsx +45 -40
  207. package/src/modules/workspace/__tests__/design-system-parity.test.ts +133 -0
  208. package/src/modules/workspace/__tests__/testFixtures.ts +2 -0
  209. package/src/modules/workspace/components/EditorTabs.tsx +82 -50
  210. package/src/modules/workspace/components/FileExplorer.tsx +413 -189
  211. package/src/modules/workspace/components/FilePaneCard.tsx +53 -0
  212. package/src/modules/workspace/components/FileRoute.tsx +89 -84
  213. package/src/modules/workspace/components/FileViewer.tsx +700 -294
  214. package/src/modules/workspace/components/KbDocumentShell.tsx +138 -0
  215. package/src/modules/workspace/components/KbFileRail.tsx +128 -0
  216. package/src/modules/workspace/components/KbPageHeader.tsx +390 -0
  217. package/src/modules/workspace/components/__tests__/EditorTabs.test.tsx +87 -3
  218. package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +293 -39
  219. package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +1 -16
  220. package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +462 -44
  221. package/src/modules/workspace/components/__tests__/KbDocumentShell.test.tsx +84 -0
  222. package/src/modules/workspace/components/__tests__/KbFileRail.test.tsx +83 -0
  223. package/src/modules/workspace/components/__tests__/KbPageHeader.test.tsx +192 -0
  224. package/src/modules/workspace/components/renderers/CopyAnchorButton.tsx +64 -0
  225. package/src/modules/workspace/components/renderers/CsvRenderer.tsx +8 -8
  226. package/src/modules/workspace/components/renderers/DocxRenderer.tsx +18 -9
  227. package/src/modules/workspace/components/renderers/HtmlRenderer.tsx +14 -14
  228. package/src/modules/workspace/components/renderers/ImageRenderer.tsx +2 -2
  229. package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +31 -165
  230. package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +18 -5
  231. package/src/modules/workspace/components/renderers/MermaidDiagram.tsx +27 -10
  232. package/src/modules/workspace/components/renderers/PdfRenderer.tsx +2 -2
  233. package/src/modules/workspace/components/renderers/TextRenderer.tsx +11 -5
  234. package/src/modules/workspace/components/renderers/ToolForm.tsx +24 -24
  235. package/src/modules/workspace/components/renderers/ToolRenderer.tsx +27 -27
  236. package/src/modules/workspace/components/renderers/XlsxRenderer.tsx +11 -11
  237. package/src/modules/workspace/components/renderers/__tests__/DocxRenderer.test.tsx +66 -0
  238. package/src/modules/workspace/components/renderers/__tests__/KbMarkdownView.test.tsx +17 -1
  239. package/src/modules/workspace/components/renderers/__tests__/MarkdownRenderer.test.tsx +1 -1
  240. package/src/modules/workspace/components/renderers/__tests__/MermaidDiagram.test.tsx +58 -0
  241. package/src/modules/workspace/components/renderers/__tests__/lazyRenderer.test.tsx +68 -0
  242. package/src/modules/workspace/components/renderers/__tests__/rendererLayout.test.ts +64 -0
  243. package/src/modules/workspace/components/renderers/__tests__/sanitizeDocxHtml.test.ts +0 -0
  244. package/src/modules/workspace/components/renderers/chunk-boundary.tsx +71 -0
  245. package/src/modules/workspace/components/renderers/index.ts +78 -2
  246. package/src/modules/workspace/components/renderers/kbMarkdownPipeline.tsx +241 -0
  247. package/src/modules/workspace/components/renderers/lazyRenderer.tsx +59 -0
  248. package/src/modules/workspace/components/renderers/sanitizeDocxHtml.ts +91 -0
  249. package/src/modules/workspace/hooks/__tests__/useLinksOut.test.ts +59 -0
  250. package/src/modules/workspace/hooks/__tests__/useOpenChangeRequests.test.tsx +237 -0
  251. package/src/modules/workspace/hooks/__tests__/useWorkspaceState.test.tsx +185 -0
  252. package/src/modules/workspace/hooks/useAutoGrowTextarea.ts +30 -0
  253. package/src/modules/workspace/hooks/useLastCommit.ts +66 -0
  254. package/src/modules/workspace/hooks/useLinksOut.ts +56 -0
  255. package/src/modules/workspace/hooks/useOpenChangeRequests.ts +20 -0
  256. package/src/modules/workspace/hooks/useWorkspaceState.ts +123 -14
  257. package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +1 -1
  258. package/src/modules/workspace/services/workspace.api.ts +9 -2
  259. package/src/modules/workspace/state/open-change-requests.context.ts +35 -0
  260. package/src/modules/workspace/state/open-change-requests.tsx +185 -0
  261. package/src/modules/workspace/state/workspace.context.ts +9 -0
  262. package/src/modules/workspace/utils/__tests__/diff.test.ts +87 -0
  263. package/src/modules/workspace/utils/diff.ts +130 -53
  264. package/src/modules/workspace/utils/fileTree.ts +7 -4
  265. package/src/modules/workspace/workspace.css +28 -0
  266. package/src/shared/components/Badge.tsx +62 -0
  267. package/src/shared/components/Banner.tsx +58 -0
  268. package/src/shared/components/Button.tsx +90 -0
  269. package/src/shared/components/Dialog.tsx +6 -6
  270. package/src/shared/components/Field.tsx +45 -0
  271. package/src/shared/components/IconButton.tsx +74 -0
  272. package/src/shared/components/ListRow.tsx +96 -0
  273. package/src/shared/components/Menu.tsx +88 -0
  274. package/src/shared/components/PageShell.tsx +8 -5
  275. package/src/shared/components/Surface.tsx +86 -0
  276. package/src/shared/components/__tests__/primitives.test.tsx +333 -0
  277. package/src/shared/components/index.ts +48 -0
  278. package/src/shared/components/useDismissableMenu.ts +71 -0
  279. package/src/shared/theme/__tests__/accent-contrast.test.ts +84 -0
  280. package/src/shared/theme/index.css +12 -0
  281. package/src/shared/theme/measure.ts +64 -0
  282. package/src/shared/theme/shadows.css +34 -0
  283. package/src/shared/theme/tokens.css +193 -0
  284. package/src/test-setup.ts +9 -0
  285. package/src/modules/access/components/AccessRestrictedBanner.tsx +0 -31
  286. package/src/modules/access/components/NodeOwnersBanner.tsx +0 -30
  287. package/src/modules/git/__tests__/ProtectedBranchBanner.test.tsx +0 -82
  288. package/src/modules/git/components/ProtectedBranchBanner.tsx +0 -42
  289. package/src/modules/library/__tests__/DetailDialog.test.tsx +0 -200
  290. package/src/modules/library/__tests__/diff.test.ts +0 -62
  291. package/src/modules/library/__tests__/loadout.test.tsx +0 -72
  292. package/src/modules/library/components/CompareView.tsx +0 -357
  293. package/src/modules/library/components/DetailDialog.tsx +0 -566
  294. package/src/modules/library/components/GearIcon.tsx +0 -12
  295. package/src/modules/library/components/LoadoutSidebar.tsx +0 -156
  296. package/src/modules/library/components/StatusGem.tsx +0 -21
  297. package/src/modules/library/components/SuggestChange.tsx +0 -171
  298. package/src/modules/library/components/particles.ts +0 -50
  299. package/src/modules/library/state/loadout.tsx +0 -129
  300. package/src/modules/library/utils/diff.ts +0 -102
  301. package/src/modules/pr/__tests__/PrApprovalBadge.test.tsx +0 -93
  302. package/src/modules/pr/__tests__/PrCancelButton.test.tsx +0 -158
  303. package/src/modules/pr/__tests__/PrCancelConfirmDialog.test.tsx +0 -44
  304. package/src/modules/pr/__tests__/PrMergeButton.test.tsx +0 -360
  305. package/src/modules/pr/__tests__/bucketize-comments.test.ts +0 -85
  306. package/src/modules/pr/__tests__/parsePatch.test.ts +0 -104
  307. package/src/modules/pr/__tests__/usePrViewerState.test.ts +0 -72
  308. package/src/modules/pr/components/PrApprovalBadge.tsx +0 -80
  309. package/src/modules/pr/components/PrCancelButton.tsx +0 -99
  310. package/src/modules/pr/components/PrCancelConfirmDialog.tsx +0 -119
  311. package/src/modules/pr/components/PrCommentComposer.tsx +0 -92
  312. package/src/modules/pr/components/PrCommentThread.tsx +0 -168
  313. package/src/modules/pr/components/PrCommentsPanel.tsx +0 -143
  314. package/src/modules/pr/components/PrDiffPane.tsx +0 -425
  315. package/src/modules/pr/components/PrFileRow.tsx +0 -164
  316. package/src/modules/pr/components/PrFilesList.tsx +0 -53
  317. package/src/modules/pr/components/PrHeader.tsx +0 -45
  318. package/src/modules/pr/components/PrHeaderOverflowMenu.tsx +0 -58
  319. package/src/modules/pr/components/PrMergeButton.tsx +0 -268
  320. package/src/modules/pr/components/PrMergeConfirmDialog.tsx +0 -112
  321. package/src/modules/pr/components/PrRefreshFromTargetButton.tsx +0 -110
  322. package/src/modules/pr/components/PrViewer.tsx +0 -364
  323. package/src/modules/pr/hooks/usePrViewerState.ts +0 -150
  324. package/src/modules/pr/state/pr-viewer.context.ts +0 -34
  325. package/src/modules/pr/utils/bucketize-comments.ts +0 -55
  326. package/src/modules/pr/utils/parsePatch.ts +0 -57
  327. package/src/modules/toolbar/components/AdminMenu.tsx +0 -271
@@ -0,0 +1,419 @@
1
+ import { useState, type ReactNode } from 'react';
2
+ import { Link } from 'react-router-dom';
3
+ import { Funnel, RotateCw, Trash2 } from 'lucide-react';
4
+ import { cn } from '../../../lib/utils';
5
+ import { Banner, Button, Dialog, IconButton } from '../../../shared/components';
6
+ import { pathForGroupsIndex } from '../routes/library-paths';
7
+ import type { LibraryItem } from '../state/library-data';
8
+ import { removeLibraryItem } from '../services/library.api';
9
+ import { LibraryCard } from './LibraryCard';
10
+
11
+ /**
12
+ * The furniture a group page is made of, shared by the two pages that are one.
13
+ *
14
+ * `GroupPage` (a folder in the KB) and `PersonalGroupPage` (the items in no
15
+ * folder at all) are different QUERIES over the same catalog, and the user
16
+ * asked for the second to look like the first. Shared components rather than a
17
+ * copy: a group page is a promise about layout, and two implementations of one
18
+ * promise drift the first time either is touched.
19
+ */
20
+
21
+ /** `All groups › {name}` — the page's place in the Library, and the way back. */
22
+ export function GroupBreadcrumb({ name }: { name: string }) {
23
+ return (
24
+ <nav aria-label="Breadcrumb" className="flex items-center gap-1.5 text-detail text-ink-faint">
25
+ <Link to={pathForGroupsIndex()} className="rounded-xs hover:text-ink">
26
+ All groups
27
+ </Link>
28
+ <span aria-hidden="true">›</span>
29
+ <span aria-current="page" className="truncate text-ink-muted">
30
+ {name}
31
+ </span>
32
+ </nav>
33
+ );
34
+ }
35
+
36
+ /**
37
+ * A titled band. The count sits beside — not inside — the heading, so the
38
+ * heading's accessible name stays exactly "Skills" / "Tools".
39
+ *
40
+ * The count and the controls are QUIET: invisible until you hover or focus
41
+ * into the row (proto:145-156). On a band of cards you can already see roughly
42
+ * how many there are, and you only reach for a filter when you want it, so
43
+ * neither earns permanent ink beside a heading. They are hidden with `opacity`
44
+ * rather than `display` so nothing shifts under the cursor as the row lights
45
+ * up. `focus-within` is what keeps that honest for anyone who never hovers.
46
+ *
47
+ * The exceptions are the CALLER's to declare, and they have to be declared
48
+ * here: `opacity` composites, so an `opacity-100` on a control nested inside an
49
+ * `opacity-0` wrapper multiplies to zero and changes nothing. A filter that is
50
+ * switched on has to stay lit — a filter you cannot see is a page lying about
51
+ * what it is showing — so `controlsActive` lifts the whole wrapper instead.
52
+ */
53
+ export function GroupSection({
54
+ title,
55
+ count,
56
+ controls,
57
+ controlsActive = false,
58
+ children,
59
+ }: {
60
+ title: string;
61
+ count: number;
62
+ /** Filter / refresh, right of the count. Fades with it. */
63
+ controls?: ReactNode;
64
+ /**
65
+ * Keep `controls` visible without hover or focus — for when one of them is
66
+ * doing something the reader has to be able to see (a filter that is on, a
67
+ * refresh in flight).
68
+ */
69
+ controlsActive?: boolean;
70
+ children: ReactNode;
71
+ }) {
72
+ return (
73
+ <section className="mt-7">
74
+ <div className="group/band mb-2.5 flex items-center gap-2">
75
+ <h2 className="text-label uppercase text-ink-faint">{title}</h2>
76
+ <span
77
+ className={cn(
78
+ 'text-meta tabular-nums text-ink-faint opacity-0 transition-opacity',
79
+ 'group-hover/band:opacity-100 group-focus-within/band:opacity-100',
80
+ )}
81
+ >
82
+ {count}
83
+ </span>
84
+ {controls && (
85
+ <span
86
+ className={cn(
87
+ 'flex items-center gap-0.5 transition-opacity',
88
+ controlsActive
89
+ ? 'opacity-100'
90
+ : 'opacity-0 group-hover/band:opacity-100 group-focus-within/band:opacity-100',
91
+ )}
92
+ >
93
+ {controls}
94
+ </span>
95
+ )}
96
+ </div>
97
+ {children}
98
+ </section>
99
+ );
100
+ }
101
+
102
+ /**
103
+ * The auto-filling card track a group's contents sit in.
104
+ *
105
+ * The track floor is `min(236px, 100%)` rather than a flat 236px so a
106
+ * container narrower than one card still gets a single column that fits,
107
+ * instead of one card overflowing its own grid on a phone.
108
+ */
109
+ export function CardGrid({
110
+ items,
111
+ onOpen,
112
+ onRemove,
113
+ }: {
114
+ items: LibraryItem[];
115
+ onOpen(item: LibraryItem): void;
116
+ /**
117
+ * The manager's "remove from this place". Present only when the caller
118
+ * runs the page the grid is on — the pages decide that, not the grid.
119
+ * Rendered as an overlay SIBLING of the card, never inside it: the whole
120
+ * card is one <button>, and a button inside a button is not HTML.
121
+ */
122
+ onRemove?(item: LibraryItem): void;
123
+ }) {
124
+ return (
125
+ <div
126
+ className={cn(
127
+ 'grid gap-2.5',
128
+ 'grid-cols-[repeat(auto-fill,minmax(min(236px,100%),1fr))]',
129
+ )}
130
+ >
131
+ {items.map((item) => {
132
+ // The change-request number is part of the key, not decoration: two
133
+ // people can propose a skill of the same name into different groups,
134
+ // and until one of them merges neither is in the catalog to collide
135
+ // with — so the name alone is not yet unique.
136
+ const key = `${item.kind}:${item.id}:${item.pending?.changeRequestNumber ?? ''}`;
137
+ const card = (
138
+ <LibraryCard
139
+ key={key}
140
+ kind={item.kind}
141
+ id={item.id}
142
+ name={item.name}
143
+ description={item.description}
144
+ owned={item.owned}
145
+ status={item.status}
146
+ version={item.version}
147
+ pending={
148
+ item.pending && {
149
+ authorName: item.pending.authorName,
150
+ mine: item.pending.mine,
151
+ }
152
+ }
153
+ onOpen={() => onOpen(item)}
154
+ />
155
+ );
156
+ // A pending proposal is not IN the place yet — there is nothing to
157
+ // remove; declining it lives with the review.
158
+ if (!onRemove || item.pending) return card;
159
+ return (
160
+ // `grid`, not a plain block: the wrapper takes the card's place as
161
+ // the grid item, and only a grid (or flex) container stretches its
162
+ // child the way the outer grid stretched the bare card — without it
163
+ // the <button> shrinks to its content and the overlay floats in the
164
+ // leftover width, off the card's own edge.
165
+ <div key={key} className="group/removable relative grid">
166
+ {card}
167
+ <button
168
+ type="button"
169
+ aria-label={`Remove ${item.name}`}
170
+ title={`Remove ${item.name}`}
171
+ onClick={() => onRemove(item)}
172
+ className={cn(
173
+ 'absolute right-1.5 top-1.5 rounded-sm border border-line bg-surface p-1 text-ink-faint',
174
+ 'opacity-0 transition-opacity hover:text-danger focus-visible:opacity-100 group-hover/removable:opacity-100',
175
+ )}
176
+ >
177
+ <Trash2 size={13} />
178
+ </button>
179
+ </div>
180
+ );
181
+ })}
182
+ </div>
183
+ );
184
+ }
185
+
186
+ /**
187
+ * The "are you sure" a removal deserves: deleting a skill or tool from a
188
+ * group takes it from EVERYONE in the group, not from a personal shelf, and
189
+ * there is no undo shortcut — the content survives only in git history.
190
+ */
191
+ export function RemoveLibraryItemDialog({
192
+ item,
193
+ place,
194
+ onClose,
195
+ onRemoved,
196
+ }: {
197
+ item: LibraryItem;
198
+ /** Where it is being removed from, for the copy: a group name, or "your space". */
199
+ place: string;
200
+ onClose(): void;
201
+ /** Fired after the delete lands; the host page reloads and says so. */
202
+ onRemoved(): void;
203
+ }) {
204
+ const [busy, setBusy] = useState(false);
205
+ const [error, setError] = useState<string | null>(null);
206
+ const what = item.kind === 'skill' ? 'skill' : 'tool';
207
+
208
+ async function remove() {
209
+ setBusy(true);
210
+ setError(null);
211
+ try {
212
+ await removeLibraryItem(item.path);
213
+ onRemoved();
214
+ onClose();
215
+ } catch (err) {
216
+ // The backend's refusal names the rule (access, a held lock); a
217
+ // generic apology would hide the one thing worth reading.
218
+ setError(err instanceof Error ? err.message : `Couldn't remove the ${what}.`);
219
+ setBusy(false);
220
+ }
221
+ }
222
+
223
+ return (
224
+ <Dialog
225
+ open
226
+ onClose={onClose}
227
+ title={`Remove ${item.name}?`}
228
+ size="md"
229
+ busy={busy}
230
+ footer={
231
+ <>
232
+ <Button variant="quiet" onClick={onClose} disabled={busy}>
233
+ Cancel
234
+ </Button>
235
+ <Button variant="danger" onClick={() => void remove()} disabled={busy}>
236
+ {busy ? 'Removing…' : 'Remove'}
237
+ </Button>
238
+ </>
239
+ }
240
+ >
241
+ <p className="text-ui text-ink-muted">
242
+ {item.kind === 'skill'
243
+ ? `This deletes the skill and its files from ${place}. Everyone here loses it the next time their agent connects.`
244
+ : `This deletes the tool and its connection settings from ${place}. Skills here that need it will ask for setup again.`}
245
+ </p>
246
+ {error && (
247
+ <Banner tone="danger" role="alert" className="mt-3">
248
+ {error}
249
+ </Banner>
250
+ )}
251
+ </Dialog>
252
+ );
253
+ }
254
+
255
+ /**
256
+ * The Skills and Tools bands, in that order, with their empty states.
257
+ *
258
+ * The empty copy differs per page (a group can be filled by an agent; your own
259
+ * space is filled by you), so it arrives as props rather than being derived
260
+ * from a name here.
261
+ */
262
+ export function GroupItemSections({
263
+ skillItems,
264
+ toolItems,
265
+ onOpen,
266
+ onRemove,
267
+ emptySkills,
268
+ emptyTools = 'No tools yet.',
269
+ hideEmpty = false,
270
+ skillControls,
271
+ skillControlsActive = false,
272
+ }: {
273
+ skillItems: LibraryItem[];
274
+ toolItems: LibraryItem[];
275
+ onOpen(item: LibraryItem): void;
276
+ /** See {@link CardGrid} — present only when the caller manages this place. */
277
+ onRemove?(item: LibraryItem): void;
278
+ emptySkills: string;
279
+ emptyTools?: string;
280
+ /**
281
+ * Filter / refresh for the Skills band only. Tools deliberately gets none
282
+ * (proto:3078 carries the count alone): a tool that needs setup already says
283
+ * so on its own card, and there is nothing to re-check that the card does not
284
+ * already show.
285
+ */
286
+ skillControls?: ReactNode;
287
+ /** One of `skillControls` is mid-act — keep the row visible. See `GroupSection`. */
288
+ skillControlsActive?: boolean;
289
+ /**
290
+ * Drop a band with nothing in it instead of showing its empty state.
291
+ *
292
+ * A GROUP says "No skills yet" because the absence is a fact about that
293
+ * group and an invitation to fix it. A SEARCH RESULT says nothing, because
294
+ * "No tools yet" under a query for `rfi` is not a fact about your library.
295
+ */
296
+ hideEmpty?: boolean;
297
+ }) {
298
+ return (
299
+ <>
300
+ {!(hideEmpty && skillItems.length === 0) && (
301
+ <GroupSection
302
+ title="Skills"
303
+ count={skillItems.length}
304
+ controls={skillControls}
305
+ controlsActive={skillControlsActive}
306
+ >
307
+ {skillItems.length === 0 ? (
308
+ <p className="text-ui text-ink-faint">{emptySkills}</p>
309
+ ) : (
310
+ <CardGrid items={skillItems} onOpen={onOpen} onRemove={onRemove} />
311
+ )}
312
+ </GroupSection>
313
+ )}
314
+
315
+ {!(hideEmpty && toolItems.length === 0) && (
316
+ <GroupSection title="Tools" count={toolItems.length}>
317
+ {toolItems.length === 0 ? (
318
+ <p className="text-ui text-ink-faint">{emptyTools}</p>
319
+ ) : (
320
+ <CardGrid items={toolItems} onOpen={onOpen} onRemove={onRemove} />
321
+ )}
322
+ </GroupSection>
323
+ )}
324
+ </>
325
+ );
326
+ }
327
+
328
+ /**
329
+ * The centred, quiet line a page shows when it has nothing else to say —
330
+ * empty, loading, or unreachable. One component so those three states are
331
+ * spaced and toned identically instead of each page inventing its own.
332
+ */
333
+ export function PageNote({ children }: { children: ReactNode }) {
334
+ return <div className="py-16 text-center text-ui text-ink-faint">{children}</div>;
335
+ }
336
+
337
+ /**
338
+ * Three nodes and the lines between them — the prototype's `SHARE_SVG`
339
+ * (line 1640), unchanged. Inline for the same reason as `LockGlyph`: it
340
+ * inherits `currentColor` from the button it sits in.
341
+ */
342
+ export function ShareGlyph({ className }: { className?: string }) {
343
+ return (
344
+ <svg
345
+ className={className}
346
+ aria-hidden="true"
347
+ focusable="false"
348
+ viewBox="0 0 16 16"
349
+ fill="none"
350
+ stroke="currentColor"
351
+ strokeWidth="1.35"
352
+ >
353
+ <circle cx="4" cy="8" r="2" />
354
+ <circle cx="12" cy="3.5" r="2" />
355
+ <circle cx="12" cy="12.5" r="2" />
356
+ <path d="m5.8 7 4.4-2.4M5.8 9l4.4 2.4" />
357
+ </svg>
358
+ );
359
+ }
360
+
361
+ /**
362
+ * The two controls that ride the Skills heading (proto:2584-2589).
363
+ *
364
+ * `filter` narrows the band to the items waiting on you, and it STAYS LIT when
365
+ * on — a filter you cannot see is a page lying about what it is showing. The
366
+ * opting-out is `GroupSection`'s `controlsActive`, because that is the element
367
+ * carrying the fade; an `opacity-100` on the button inside it would multiply
368
+ * against the wrapper's zero and do nothing.
369
+ *
370
+ * `refresh` re-reads the library and then says when it last did, because
371
+ * "nothing changed" and "nothing was checked" look identical otherwise. It
372
+ * only appears once there is something to filter — a filter that empties the
373
+ * page is a trap (proto:2579).
374
+ */
375
+ export function BandControls({
376
+ attention,
377
+ filterOn,
378
+ onToggleFilter,
379
+ onRefresh,
380
+ refreshState,
381
+ }: {
382
+ /** How many items need the reader. Zero hides the filter entirely. */
383
+ attention: number;
384
+ filterOn: boolean;
385
+ onToggleFilter(): void;
386
+ onRefresh(): void;
387
+ refreshState: 'idle' | 'spin' | 'done';
388
+ }) {
389
+ return (
390
+ <>
391
+ {attention > 0 && (
392
+ <IconButton
393
+ size={18}
394
+ aria-label={filterOn ? 'Show everything' : 'Show only what needs you'}
395
+ title={filterOn ? 'Show everything' : 'Show only what needs you'}
396
+ aria-pressed={filterOn}
397
+ active={filterOn}
398
+ className={cn(filterOn && 'opacity-100')}
399
+ onClick={onToggleFilter}
400
+ >
401
+ <Funnel size={12} />
402
+ </IconButton>
403
+ )}
404
+ {refreshState === 'done' ? (
405
+ <span className="text-meta text-ink-faint opacity-100">Last updated just now</span>
406
+ ) : (
407
+ <IconButton
408
+ size={18}
409
+ aria-label="Check for updates"
410
+ title="Check for updates"
411
+ className={cn(refreshState === 'spin' && 'opacity-100')}
412
+ onClick={onRefresh}
413
+ >
414
+ <RotateCw size={12} className={cn(refreshState === 'spin' && 'animate-spin')} />
415
+ </IconButton>
416
+ )}
417
+ </>
418
+ );
419
+ }
@@ -0,0 +1,134 @@
1
+ import { useState } from 'react';
2
+ import { Banner, Button, Surface } from '../../../../shared/components';
3
+
4
+ interface SkillFileEditorProps {
5
+ file: string;
6
+ /** The text as it stands now — what the submitted text will be diffed against. */
7
+ base: string;
8
+ /**
9
+ * What submitting DOES — the same editor serves both verdicts of the
10
+ * per-file ACL:
11
+ * - `propose`: the text lands on the caller's suggestion branch as a
12
+ * change request; nothing moves until the owner approves.
13
+ * - `edit`: the text saves straight to the default branch — the caller
14
+ * may write the file, so there is nobody to wait on.
15
+ * The mode only changes the words (button, reassurance line): what gets
16
+ * submitted and how the diff is computed are identical.
17
+ */
18
+ mode: 'edit' | 'propose';
19
+ /** Who has to say yes — read only in `propose` mode, for the line under the editor. */
20
+ owner: string;
21
+ onCancel(): void;
22
+ /** Resolves when the text has landed (on the branch, or on the default branch). */
23
+ onSubmit(next: string): Promise<void>;
24
+ }
25
+
26
+ /**
27
+ * Propose a change by editing the file — the prototype's `.editbox` (line 284).
28
+ *
29
+ * The whole file is editable rather than one selected phrase, because the unit
30
+ * people actually propose in is a passage: rewriting a step usually means
31
+ * touching the sentence before it. What gets stored is still a diff; the
32
+ * textarea is only how you say what you mean.
33
+ *
34
+ * The line under it is the entire reassurance this flow needs. Editing a file
35
+ * in a shared library reads as destructive, and it isn't — nothing moves until
36
+ * the owner says so — so the editor says that where the fear is, not in a
37
+ * tooltip somewhere.
38
+ */
39
+ export function SkillFileEditor({
40
+ file,
41
+ base,
42
+ mode,
43
+ owner,
44
+ onCancel,
45
+ onSubmit,
46
+ }: SkillFileEditorProps) {
47
+ const [text, setText] = useState(base);
48
+ const [busy, setBusy] = useState(false);
49
+ const [error, setError] = useState<string | null>(null);
50
+
51
+ /**
52
+ * A `<textarea>` hands its value back with LF endings whatever went in, so a
53
+ * CRLF file would come back rewritten line-for-line. Both comparisons and the
54
+ * submitted text are put back into the file's OWN convention, which keeps a
55
+ * one-word edit a one-line diff.
56
+ */
57
+ const crlf = base.includes('\r\n');
58
+ const toFileEndings = (s: string) => (crlf ? s.replace(/\r?\n/g, '\r\n') : s);
59
+ const lf = (s: string) => s.replace(/\r\n?/g, '\n');
60
+
61
+ /**
62
+ * Exact comparison — NOT trimmed. Adding a trailing newline, stripping
63
+ * trailing spaces, or fixing the indent on the first line are real edits, and
64
+ * a trimmed guard answered every one of them with "Nothing changed yet".
65
+ *
66
+ * The LF normalisation is not the same kind of leniency and has to stay: the
67
+ * textarea can only ever produce LF, so against a CRLF `base` a raw `===`
68
+ * would report "changed" on a file nobody touched — and since `toFileEndings`
69
+ * converts back on the way out, that would open a change request git sees no
70
+ * diff in at all.
71
+ */
72
+ const unchanged = lf(text) === lf(base);
73
+
74
+ async function submit() {
75
+ if (unchanged) {
76
+ setError('Nothing changed yet: edit the text first.');
77
+ return;
78
+ }
79
+ setBusy(true);
80
+ setError(null);
81
+ try {
82
+ await onSubmit(toFileEndings(text));
83
+ } catch (err) {
84
+ setError(
85
+ err instanceof Error
86
+ ? err.message
87
+ : mode === 'edit'
88
+ ? "Couldn't save your change."
89
+ : "Couldn't send your change.",
90
+ );
91
+ setBusy(false);
92
+ }
93
+ }
94
+
95
+ return (
96
+ <Surface tone="surface" radius="lg" elevation="card" className="mt-4 overflow-hidden">
97
+ <div className="flex min-h-11 items-center gap-3 border-b border-line px-3.5 py-2">
98
+ <span className="truncate font-mono text-meta text-ink-muted">{file}: editing</span>
99
+ </div>
100
+
101
+ {/* `rows` rather than a height class alone: the intrinsic row count is
102
+ what a textarea falls back to, so a class that fails to apply leaves a
103
+ two-line box to edit a whole file in. */}
104
+ <textarea
105
+ aria-label={mode === 'edit' ? `Edit ${file}` : `Propose changes to ${file}`}
106
+ spellCheck={false}
107
+ rows={22}
108
+ className="block max-h-[60vh] min-h-64 w-full resize-y bg-sunken px-6 py-4 font-mono text-detail leading-relaxed text-ink outline-none"
109
+ value={text}
110
+ onChange={(e) => setText(e.target.value)}
111
+ />
112
+
113
+ {error && (
114
+ <Banner tone="danger" role="alert" className="mx-3.5 mt-3">
115
+ {error}
116
+ </Banner>
117
+ )}
118
+
119
+ <div className="flex flex-wrap items-center gap-2 border-t border-line px-3 py-2.5">
120
+ <span className="mr-auto text-meta text-ink-faint">
121
+ {mode === 'edit'
122
+ ? 'Saves for everyone. Agents pick it up the next time they connect.'
123
+ : `Nothing changes until ${owner} approves it.`}
124
+ </span>
125
+ <Button variant="quiet" size="sm" onClick={onCancel} disabled={busy}>
126
+ Cancel
127
+ </Button>
128
+ <Button variant="primary" size="sm" onClick={() => void submit()} disabled={busy}>
129
+ {mode === 'edit' ? (busy ? 'Saving…' : 'Save') : busy ? 'Sending…' : 'Propose changes'}
130
+ </Button>
131
+ </div>
132
+ </Surface>
133
+ );
134
+ }
@@ -0,0 +1,117 @@
1
+ import type { ReactNode } from 'react';
2
+ import '../../../change-requests/change-requests.css';
3
+ import { FilePaneCard } from '../../../workspace/components/FilePaneCard';
4
+ import { KbMarkdownView } from '../../../workspace/components/renderers/KbMarkdownView';
5
+ import { HtmlRenderer } from '../../../workspace/components/renderers/HtmlRenderer';
6
+ import type { DiffLine } from '../../../change-requests/utils/diff';
7
+
8
+ /** The pane never writes — editing goes through the page's Edit / Propose. */
9
+ const NOOP_SAVE = async () => {};
10
+
11
+ interface SkillFilePaneProps {
12
+ /** Repo-relative-to-the-skill file name, e.g. `SKILL.md`. */
13
+ file: string;
14
+ /** Raw file content, or null while it loads. */
15
+ raw: string | null;
16
+ /**
17
+ * The caller's own pending suggestion rendered against `raw`, or null when
18
+ * there is none. Present ⇒ the pane shows the diff INSTEAD of the file: you
19
+ * are looking at what you proposed, not at what is there today.
20
+ */
21
+ suggestion: DiffLine[] | null;
22
+ /** Right-hand side of the file bar — Edit, Propose changes, whatever the page owns. */
23
+ actions?: ReactNode;
24
+ /** Sits between the bar and the body: the "your suggestions are inline" strip. */
25
+ notice?: ReactNode;
26
+ /** Follow a relative link out of rendered markdown. */
27
+ onOpenLink?(href: string): void;
28
+ /** Resolve a bare `[text](node-id)` link — same contract as `KbMarkdownView`. */
29
+ onOpenNodeId?(id: string): void;
30
+ /** Heading deep-link builder; present ⇒ headings get the copy-anchor button. */
31
+ headingLink?(slug: string): string;
32
+ }
33
+
34
+ /**
35
+ * One file, in a box — the prototype's `.filepane` (line 253): a bar naming the
36
+ * file with its actions, and the file itself below.
37
+ *
38
+ * The box is the point. A skill is a FOLDER of files, and the tabs above only
39
+ * make sense if the thing they switch has an edge you can see; without it the
40
+ * body reads as page content that happens to change when you click a tab.
41
+ *
42
+ * The box itself is `FilePaneCard` — the same frame the Knowledge viewer
43
+ * mounts around its documents, so the two surfaces cannot drift apart.
44
+ */
45
+ export function SkillFilePane({
46
+ file,
47
+ raw,
48
+ suggestion,
49
+ actions,
50
+ notice,
51
+ onOpenLink,
52
+ onOpenNodeId,
53
+ headingLink,
54
+ }: SkillFilePaneProps) {
55
+ return (
56
+ <FilePaneCard file={file} actions={actions} notice={notice} className="mt-4">
57
+ {raw === null ? (
58
+ <p className="py-4 text-center text-detail text-ink-faint">Loading…</p>
59
+ ) : suggestion ? (
60
+ <SuggestionDiff lines={suggestion} />
61
+ ) : file.endsWith('.md') ? (
62
+ // The SAME renderer, in the same configuration, as the Knowledge
63
+ // view of this file: raw source (so the frontmatter panel shows),
64
+ // id-link resolution, heading copy-anchors. `scroll={false}`
65
+ // because the library page is the scroller — a nested scrollbox
66
+ // here would trap the wheel inside the pane.
67
+ <KbMarkdownView
68
+ source={raw}
69
+ onOpenFile={(href) => onOpenLink?.(href)}
70
+ onOpenNodeId={onOpenNodeId}
71
+ headingLink={headingLink}
72
+ scroll={false}
73
+ />
74
+ ) : /\.html?$/i.test(file) ? (
75
+ // The same sandboxed preview the Knowledge viewer gives `.html` — a
76
+ // skill's bundled template (a deck, a report shell) is meant to be
77
+ // SEEN; the renderer's own Code tab keeps the source one click away.
78
+ // Sized wrapper because the renderer fills its parent, and this card
79
+ // has no height of its own.
80
+ <div className="h-[70vh]">
81
+ <HtmlRenderer content={raw} filePath={file} readOnly onSave={NOOP_SAVE} />
82
+ </div>
83
+ ) : (
84
+ <pre className="whitespace-pre-wrap break-words font-mono text-detail leading-relaxed text-ink-muted">
85
+ {raw}
86
+ </pre>
87
+ )}
88
+ </FilePaneCard>
89
+ );
90
+ }
91
+
92
+ /**
93
+ * Removed and added lines as `<del>` / `<ins>`, not coloured `<div>`s: what is
94
+ * on screen is a claim about what changed, and the elements that MEAN that are
95
+ * the ones a screen reader announces as such. The colours come from `.lib-sug`
96
+ * in `library.css` — the same rule the compare view's marks use, so an inline
97
+ * suggestion and a reviewed one never drift apart visually.
98
+ */
99
+ function SuggestionDiff({ lines }: { lines: DiffLine[] }) {
100
+ return (
101
+ <pre className="lib-sug whitespace-pre-wrap break-words font-mono text-detail leading-relaxed text-ink-muted">
102
+ {lines.map((l, i) =>
103
+ l.kind === 'same' ? (
104
+ <div key={i}>{l.text || ' '}</div>
105
+ ) : l.kind === 'removed' ? (
106
+ <del key={i} className="block">
107
+ {l.text || ' '}
108
+ </del>
109
+ ) : (
110
+ <ins key={i} className="block">
111
+ {l.text || ' '}
112
+ </ins>
113
+ ),
114
+ )}
115
+ </pre>
116
+ );
117
+ }