@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
@@ -138,7 +138,7 @@ function CopyButton({ text }: { text: string }) {
138
138
  scheduleReset();
139
139
  });
140
140
  }}
141
- className="text-[10px] font-medium px-2 py-0.5 rounded border border-slate-200 text-slate-500 hover:bg-slate-50"
141
+ className="text-[10px] font-medium px-2 py-0.5 rounded border border-line text-ink-muted hover:bg-hover"
142
142
  >
143
143
  {status === 'copied' ? 'Copied' : status === 'failed' ? 'Copy failed' : 'Copy'}
144
144
  </button>
@@ -148,23 +148,23 @@ function CopyButton({ text }: { text: string }) {
148
148
  function SchemaView({ schema, depth = 0 }: { schema: JsonSchema; depth?: number }) {
149
149
  const props = schema.properties;
150
150
  if (!props || Object.keys(props).length === 0) {
151
- return <div className="text-xs text-slate-400 italic">no fields</div>;
151
+ return <div className="text-xs text-ink-faint italic">no fields</div>;
152
152
  }
153
153
  const required = new Set(schema.required ?? []);
154
154
  return (
155
- <div className={depth > 0 ? 'pl-3 border-l border-slate-200 space-y-1.5' : 'space-y-1.5'}>
155
+ <div className={depth > 0 ? 'pl-3 border-l border-line space-y-1.5' : 'space-y-1.5'}>
156
156
  {Object.entries(props).map(([name, sub]) => (
157
157
  <div key={name} className="text-xs">
158
158
  <div className="flex items-baseline gap-2 flex-wrap">
159
- <code className="font-medium text-slate-800">{name}</code>
160
- <span className="text-slate-400 font-mono">{typeLabel(sub)}</span>
159
+ <code className="font-medium text-ink">{name}</code>
160
+ <span className="text-ink-faint font-mono">{typeLabel(sub)}</span>
161
161
  {required.has(name) ? (
162
162
  <span className="text-[10px] uppercase tracking-wide text-amber-600">required</span>
163
163
  ) : (
164
- <span className="text-[10px] uppercase tracking-wide text-slate-300">optional</span>
164
+ <span className="text-[10px] uppercase tracking-wide text-ink-faint">optional</span>
165
165
  )}
166
166
  </div>
167
- {sub.description && <div className="text-slate-500 leading-snug mt-0.5">{sub.description}</div>}
167
+ {sub.description && <div className="text-ink-muted leading-snug mt-0.5">{sub.description}</div>}
168
168
  {sub.type === 'object' && sub.properties && <SchemaView schema={sub} depth={depth + 1} />}
169
169
  {sub.type === 'array' && itemSchema(sub)?.properties && (
170
170
  <SchemaView schema={itemSchema(sub)!} depth={depth + 1} />
@@ -180,73 +180,73 @@ function ToolCard({ tool }: { tool: UtcpTool }) {
180
180
  const http = httpPath(tool);
181
181
  const input = unwrapBody(tool.inputs);
182
182
  return (
183
- <div className="border border-slate-200 rounded-lg bg-white">
183
+ <div className="border border-line rounded-lg bg-white">
184
184
  <button onClick={() => setOpen((v) => !v)} className="w-full text-left px-4 py-3 flex items-start gap-3">
185
- <span className="text-slate-300 mt-0.5">{open ? '▾' : '▸'}</span>
185
+ <span className="text-ink-faint mt-0.5">{open ? '▾' : '▸'}</span>
186
186
  <span className="flex-1 min-w-0">
187
187
  <span className="flex items-center gap-2 flex-wrap">
188
- <code className="text-sm font-semibold text-slate-800">{tool.name}</code>
189
- <span className="text-[10px] font-mono uppercase tracking-wide text-slate-400">
188
+ <code className="text-sm font-semibold text-ink">{tool.name}</code>
189
+ <span className="text-[10px] font-mono uppercase tracking-wide text-ink-faint">
190
190
  {http ? `${http.method} ${http.path}` : tool.tool_call_template?.call_template_type ?? 'unknown'}
191
191
  </span>
192
192
  {tool.tags?.map((t) => (
193
- <span key={t} className="text-[10px] px-1.5 py-0.5 rounded bg-slate-100 text-slate-500">{t}</span>
193
+ <span key={t} className="text-[10px] px-1.5 py-0.5 rounded bg-sunken text-ink-muted">{t}</span>
194
194
  ))}
195
195
  </span>
196
- <span className="block text-xs text-slate-500 leading-snug mt-1 line-clamp-2">{tool.description}</span>
196
+ <span className="block text-xs text-ink-muted leading-snug mt-1 line-clamp-2">{tool.description}</span>
197
197
  </span>
198
198
  </button>
199
199
  {open && (
200
- <div className="px-4 pb-4 pt-1 space-y-4 border-t border-slate-100">
201
- <p className="text-xs text-slate-600 leading-snug whitespace-pre-wrap">{tool.description}</p>
200
+ <div className="px-4 pb-4 pt-1 space-y-4 border-t border-line">
201
+ <p className="text-xs text-ink-muted leading-snug whitespace-pre-wrap">{tool.description}</p>
202
202
  <section>
203
- <h4 className="text-xs font-semibold text-slate-700 mb-1.5">Input</h4>
203
+ <h4 className="text-xs font-semibold text-ink mb-1.5">Input</h4>
204
204
  <SchemaView schema={input} />
205
205
  </section>
206
206
  {tool.outputs && (
207
207
  <section>
208
- <h4 className="text-xs font-semibold text-slate-700 mb-1.5">Output</h4>
208
+ <h4 className="text-xs font-semibold text-ink mb-1.5">Output</h4>
209
209
  <SchemaView schema={tool.outputs} />
210
210
  </section>
211
211
  )}
212
212
  <section>
213
- <h4 className="text-xs font-semibold text-slate-700 mb-1.5">How to call</h4>
213
+ <h4 className="text-xs font-semibold text-ink mb-1.5">How to call</h4>
214
214
  {http ? (
215
215
  <div className="space-y-2">
216
- <p className="text-xs text-slate-500 leading-snug">
216
+ <p className="text-xs text-ink-muted leading-snug">
217
217
  <code className="text-emerald-700 font-semibold">{http.method}</code>{' '}
218
- <code className="text-slate-600">{http.path}</code> with{' '}
219
- <code className="text-slate-600">Authorization: Bearer &lt;key&gt;</code> and the input above as the JSON
218
+ <code className="text-ink-muted">{http.path}</code> with{' '}
219
+ <code className="text-ink-muted">Authorization: Bearer &lt;key&gt;</code> and the input above as the JSON
220
220
  body. Or call it through any UTCP client / the MCP server at <code>/api/mcp</code>.
221
221
  </p>
222
222
  <div className="relative">
223
223
  <div className="absolute top-1.5 right-1.5">
224
224
  <CopyButton text={curlSnippet(http, input)} />
225
225
  </div>
226
- <pre className="text-[11px] font-mono text-slate-700 bg-slate-50 border border-slate-200 rounded p-2.5 overflow-auto whitespace-pre">
226
+ <pre className="text-[11px] font-mono text-ink bg-sunken border border-line rounded p-2.5 overflow-auto whitespace-pre">
227
227
  {curlSnippet(http, input)}
228
228
  </pre>
229
229
  </div>
230
230
  </div>
231
231
  ) : (
232
- <p className="text-xs text-slate-500 leading-snug">
233
- Transport <code>{tool.tool_call_template?.call_template_type ?? 'unknown'}</code> — invoke it with a UTCP
232
+ <p className="text-xs text-ink-muted leading-snug">
233
+ Transport <code>{tool.tool_call_template?.call_template_type ?? 'unknown'}</code>. Invoke it with a UTCP
234
234
  client (or via the MCP server at <code>/api/mcp</code>), not a plain HTTP request.
235
235
  </p>
236
236
  )}
237
237
  </section>
238
238
  <section>
239
239
  <div className="flex items-center justify-between mb-1.5">
240
- <h4 className="text-xs font-semibold text-slate-700">Raw UTCP schema</h4>
240
+ <h4 className="text-xs font-semibold text-ink">Raw UTCP schema</h4>
241
241
  <CopyButton text={JSON.stringify(tool, null, 2)} />
242
242
  </div>
243
- <p className="text-[11px] text-slate-400 leading-snug mb-1.5">
244
- The full tool definition served by <code>/api/agent/utcp</code> — inputs, outputs and the{' '}
243
+ <p className="text-[11px] text-ink-faint leading-snug mb-1.5">
244
+ The full tool definition served by <code>/api/agent/utcp</code>: inputs, outputs and the{' '}
245
245
  <code>tool_call_template</code> (endpoint, method, headers, body wrapping). Resolve{' '}
246
246
  <code>${'{API_URL}'}</code> to this server&apos;s origin and <code>${'{CONNECTION_KEY}'}</code> to your{' '}
247
247
  <code>{'<tenant>_…'}</code> key to call it from a script.
248
248
  </p>
249
- <pre className="text-[11px] font-mono text-slate-700 bg-slate-50 border border-slate-200 rounded p-2.5 overflow-auto whitespace-pre max-h-80">
249
+ <pre className="text-[11px] font-mono text-ink bg-sunken border border-line rounded p-2.5 overflow-auto whitespace-pre max-h-80">
250
250
  {JSON.stringify(tool, null, 2)}
251
251
  </pre>
252
252
  </section>
@@ -320,20 +320,25 @@ export function ToolsExplorerPage() {
320
320
  }, [tools, filter]);
321
321
 
322
322
  return (
323
- <div className="h-full overflow-auto bg-slate-50">
323
+ <div className="h-full overflow-auto bg-sunken">
324
324
  <div className="max-w-3xl mx-auto px-6 py-8 space-y-6">
325
325
  <header className="space-y-1">
326
- <h1 className="text-lg font-semibold text-slate-800">Bevel tools</h1>
327
- <p className="text-sm text-slate-500">
328
- Every tool Bevel exposes to external agents — the same surface available over MCP at{' '}
329
- <code className="text-slate-600">/api/mcp</code>. Loaded with your session below; or browse as a specific
326
+ {/* Matches the nav row that reaches it. Nothing used to put the two
327
+ on screen together, so the mismatch was invisible; with a
328
+ persistent nav, a row marked `aria-current` beside a heading with
329
+ a different name reads as a broken link — and a screen reader
330
+ hears the nav assert one name and the page answer with another. */}
331
+ <h1 className="text-lg font-semibold text-ink">Browse available tools</h1>
332
+ <p className="text-sm text-ink-muted">
333
+ Every tool Bevel exposes to external agents. The same surface available over MCP at{' '}
334
+ <code className="text-ink-muted">/api/mcp</code>. Loaded with your session below; or browse as a specific
330
335
  external API key to see exactly what it can reach.
331
336
  </p>
332
337
  </header>
333
338
 
334
- <div className="bg-white border border-slate-200 rounded-lg p-3 space-y-2">
335
- <label className="block text-xs font-medium text-slate-700">
336
- Browse as a specific external API key (<code>{'<tenant>_…'}</code>) — optional
339
+ <div className="bg-white border border-line rounded-lg p-3 space-y-2">
340
+ <label className="block text-xs font-medium text-ink">
341
+ Browse as a specific external API key (<code>{'<tenant>_…'}</code>). Optional
337
342
  </label>
338
343
  <div className="flex gap-2">
339
344
  <input
@@ -343,12 +348,12 @@ export function ToolsExplorerPage() {
343
348
  onKeyDown={(e) => e.key === 'Enter' && !loading && void load()}
344
349
  placeholder="<tenant>_…"
345
350
  spellCheck={false}
346
- className="flex-1 text-xs font-mono border border-slate-200 rounded px-2 py-1.5 text-slate-800"
351
+ className="flex-1 text-xs font-mono border border-line rounded px-2 py-1.5 text-ink"
347
352
  />
348
353
  <button
349
354
  onClick={() => void load()}
350
355
  disabled={loading || !bearer.trim()}
351
- className="text-xs font-medium px-3 py-1.5 rounded bg-slate-800 text-white disabled:opacity-40"
356
+ className="text-xs font-medium px-3 py-1.5 rounded bg-ink text-white disabled:opacity-40"
352
357
  >
353
358
  {loading ? 'Loading…' : 'Load'}
354
359
  </button>
@@ -363,9 +368,9 @@ export function ToolsExplorerPage() {
363
368
  value={filter}
364
369
  onChange={(e) => setFilter(e.target.value)}
365
370
  placeholder="Filter tools…"
366
- className="text-xs border border-slate-200 rounded px-2 py-1.5 text-slate-800 w-56"
371
+ className="text-xs border border-line rounded px-2 py-1.5 text-ink w-56"
367
372
  />
368
- <span className="text-xs text-slate-400">{shown.length} of {tools.length} tools</span>
373
+ <span className="text-xs text-ink-faint">{shown.length} of {tools.length} tools</span>
369
374
  </div>
370
375
  <div className="space-y-2">
371
376
  {shown.map((t) => (
@@ -0,0 +1,133 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { readdirSync, readFileSync, statSync } from 'node:fs';
3
+ import { join, dirname, relative } from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+
6
+ /**
7
+ * Knowledge holds the design system, not a second one.
8
+ *
9
+ * The repo-wide `ds:check` ratchet is a COUNTER with slack — it would happily
10
+ * accept a raw `bg-amber-50` reappearing here as long as something else
11
+ * elsewhere went down. This is the module-scoped version of the same rule, and
12
+ * it is a hard zero: the slate palette taught us that an off-system colour
13
+ * fails SILENTLY (Tailwind emits no rule, the text renders at the inherited
14
+ * colour, nothing errors), so counting is the only thing that catches it.
15
+ *
16
+ * If a genuinely new status colour is ever needed, it goes in
17
+ * `shared/theme/tokens.css` and gets a name — it does not come back as a
18
+ * number.
19
+ */
20
+
21
+ const MODULE_DIR = join(dirname(fileURLToPath(import.meta.url)), '..');
22
+
23
+ const RAW_PALETTE =
24
+ /\b(?:bg|text|border|ring|divide|from|via|to|outline|fill|stroke)-(?:slate|gray|zinc|neutral|stone|red|amber|yellow|green|emerald|teal|cyan|blue|indigo|violet|purple|fuchsia|pink|rose|orange|lime|sky)-\d{2,3}\b/g;
25
+
26
+ function sourceFiles(dir: string, out: string[] = []): string[] {
27
+ for (const entry of readdirSync(dir)) {
28
+ const full = join(dir, entry);
29
+ if (statSync(full).isDirectory()) {
30
+ if (entry === '__tests__') continue;
31
+ sourceFiles(full, out);
32
+ } else if (/\.tsx?$/.test(entry) && !/\.test\.tsx?$/.test(entry)) {
33
+ out.push(full);
34
+ }
35
+ }
36
+ return out;
37
+ }
38
+
39
+ /**
40
+ * The module, walked and read ONCE. Three checks over the same few dozen files
41
+ * is three walks and three reads of every one of them otherwise, for an answer
42
+ * that cannot have changed between them.
43
+ */
44
+ const FILES = sourceFiles(MODULE_DIR).map((file) => ({
45
+ name: relative(MODULE_DIR, file),
46
+ source: readFileSync(file, 'utf8'),
47
+ }));
48
+
49
+ /**
50
+ * The string literals in a file, comments excluded.
51
+ *
52
+ * `rounded` is also an ordinary English word, and these files carry more prose
53
+ * than code — matching the raw source flags every sentence that uses it. Class
54
+ * names only ever live inside a string, so that is the only place worth
55
+ * looking. It is a scanner rather than a regex because a regex cannot skip
56
+ * comments, and one apostrophe in one of them ("doesn't") opens a quote that
57
+ * swallows the rest of the file.
58
+ *
59
+ * What it does NOT do is tell a class list from an English sentence that
60
+ * happens to be a string literal. Deliberate: the failure it would trade for
61
+ * is a MISSED bare `rounded`, and this check exists because that one fails
62
+ * silently. A false positive costs one glance — which is why the failure
63
+ * prints the literal it matched.
64
+ */
65
+ function stringLiterals(source: string): string[] {
66
+ const out: string[] = [];
67
+ for (let i = 0; i < source.length; i++) {
68
+ const c = source[i];
69
+ if (c === '/' && source[i + 1] === '/') {
70
+ const eol = source.indexOf('\n', i);
71
+ if (eol === -1) break;
72
+ i = eol;
73
+ } else if (c === '/' && source[i + 1] === '*') {
74
+ const end = source.indexOf('*/', i + 2);
75
+ if (end === -1) break;
76
+ i = end + 1;
77
+ } else if (c === '"' || c === "'" || c === '`') {
78
+ let value = '';
79
+ i++;
80
+ while (i < source.length && source[i] !== c) {
81
+ if (source[i] === '\\') {
82
+ i += 2;
83
+ continue;
84
+ }
85
+ value += source[i];
86
+ i++;
87
+ }
88
+ out.push(value);
89
+ }
90
+ }
91
+ return out;
92
+ }
93
+
94
+ /** Every distinct match of `re` in `source`, or null when there are none. */
95
+ function offendersIn(source: string, re: RegExp): string[] | null {
96
+ const matches = source.match(re);
97
+ return matches ? [...new Set(matches)] : null;
98
+ }
99
+
100
+ describe('modules/workspace design-system parity', () => {
101
+ it('uses no raw Tailwind palette colours anywhere', () => {
102
+ const offenders: string[] = [];
103
+ for (const { name, source } of FILES) {
104
+ const matches = offendersIn(source, RAW_PALETTE);
105
+ if (matches) offenders.push(`${name}: ${matches.join(', ')}`);
106
+ }
107
+ expect(offenders).toEqual([]);
108
+ });
109
+
110
+ it('uses no off-scale font sizes', () => {
111
+ const offenders: string[] = [];
112
+ for (const { name, source } of FILES) {
113
+ const matches = offendersIn(source, /\btext-\[[0-9.]+px\]/g);
114
+ if (matches) offenders.push(`${name}: ${matches.join(', ')}`);
115
+ }
116
+ expect(offenders).toEqual([]);
117
+ });
118
+
119
+ it('uses no bare `rounded`', () => {
120
+ const offenders: string[] = [];
121
+ for (const { name, source } of FILES) {
122
+ // Anchored on a class-list boundary rather than `\b`, so `rounded` as a
123
+ // standalone utility is caught and `rounded-lg` is not.
124
+ const hits = stringLiterals(source).filter((literal) =>
125
+ /(?:^|\s)rounded(?=\s|$)/.test(literal),
126
+ );
127
+ // Report WHAT matched, like the other two — a bare filename leaves you
128
+ // grepping a 900-line component for a word that is also in its prose.
129
+ if (hits.length) offenders.push(`${name}: ${[...new Set(hits)].join(' | ')}`);
130
+ }
131
+ expect(offenders).toEqual([]);
132
+ });
133
+ });
@@ -26,6 +26,8 @@ export function makeWorkspaceFixture(
26
26
  setPersistenceBranch: () => {},
27
27
  fsRevision: 0,
28
28
  uploadError: null,
29
+ uploadNotice: null,
30
+ clearUploadNotice: () => {},
29
31
  isUploading: false,
30
32
  uploadProgress: null,
31
33
  pendingUploads: new Map(),
@@ -1,8 +1,13 @@
1
1
  import { useEffect, useLayoutEffect, useRef, useState } from 'react';
2
2
  import { X } from 'lucide-react';
3
+ import { cn } from '../../../lib/utils';
4
+ import { MenuPanel, MenuItem } from '../../../shared/components';
5
+ import { useDismissableMenu } from '../../../shared/components';
6
+ import { useOpenChangeRequests } from '../hooks/useOpenChangeRequests';
3
7
  import { useWorkspace } from '../state/workspace.context';
4
8
  import { useFileNav } from '../routing/kb-routes';
5
9
  import type { OpenTab } from '../state/workspace.context';
10
+ import '../workspace.css';
6
11
 
7
12
  const DRAG_MIME = 'application/x-bevel-tab-path';
8
13
 
@@ -32,17 +37,25 @@ export function EditorTabs() {
32
37
  const [draggingPath, setDraggingPath] = useState<string | null>(null);
33
38
  const [dragOverPath, setDragOverPath] = useState<string | null>(null);
34
39
  const [menu, setMenu] = useState<MenuState | null>(null);
40
+ // The tab the menu was opened from. A ref rather than part of `MenuState`
41
+ // because `useDismissableMenu` wants a ref box, and because the tabs are a
42
+ // list — there is no single element a `useRef` on the tab could name.
43
+ const menuTriggerRef = useRef<HTMLElement | null>(null);
35
44
 
36
45
  // Hide the tabs strip entirely when there are no tabs — keeps the empty
37
46
  // state from looking like a chrome-only viewer.
38
47
  if (openTabs.length === 0) return null;
39
48
 
40
49
  return (
41
- <div className="border-b border-slate-200 bg-slate-50/50 shrink-0">
50
+ // The prototype's `.kbtabs` (proto:712-723): transparent, one hairline
51
+ // under it, an 18px gap to the content, and no scrollbar drawn over the
52
+ // labels. It sits INSIDE the document column, so its left edge is the
53
+ // title's left edge.
54
+ <div className="shrink-0">
42
55
  <div
43
56
  role="tablist"
44
57
  aria-label="Open files"
45
- className="flex items-stretch overflow-x-auto"
58
+ className="kb-tabstrip mb-[18px] flex items-center gap-0.5 overflow-x-auto border-b border-line"
46
59
  >
47
60
  {openTabs.map((tab) => (
48
61
  <TabPill
@@ -68,6 +81,7 @@ export function EditorTabs() {
68
81
  }}
69
82
  onContextMenu={(e) => {
70
83
  e.preventDefault();
84
+ menuTriggerRef.current = e.currentTarget;
71
85
  setMenu({ tab, x: e.clientX, y: e.clientY });
72
86
  }}
73
87
  onDragStart={(e) => {
@@ -118,6 +132,7 @@ export function EditorTabs() {
118
132
  <ContextMenu
119
133
  state={menu}
120
134
  openTabs={openTabs}
135
+ returnFocusTo={menuTriggerRef}
121
136
  onClose={() => setMenu(null)}
122
137
  onCloseTab={async (tab) => {
123
138
  const wasActive = tab.path === activeTab?.path;
@@ -182,7 +197,7 @@ interface TabPillProps {
182
197
  isDragTarget: boolean;
183
198
  onActivate: () => void;
184
199
  onClose: () => void;
185
- onContextMenu: (e: React.MouseEvent) => void;
200
+ onContextMenu: (e: React.MouseEvent<HTMLDivElement>) => void;
186
201
  onDragStart: (e: React.DragEvent) => void;
187
202
  onDragOver: (e: React.DragEvent) => void;
188
203
  onDragEnter: (e: React.DragEvent) => void;
@@ -210,11 +225,23 @@ function TabPill(props: TabPillProps) {
210
225
 
211
226
  const filename = basename(tab.path);
212
227
  const hasPending = tab.pendingFileContent !== null;
228
+ const hasChangeRequest = useOpenChangeRequests().paths.has(tab.path);
229
+ const ref = useRef<HTMLDivElement>(null);
230
+
231
+ // Suppressing the scrollbar removes the one cue that more strip exists, so
232
+ // activation has to bring the tab to the user instead. There was no
233
+ // scroll-into-view here before — with 20 tabs, activating one that was
234
+ // scrolled off-screen simply left it off-screen.
235
+ useEffect(() => {
236
+ if (isActive) ref.current?.scrollIntoView({ inline: 'nearest', block: 'nearest' });
237
+ }, [isActive]);
213
238
 
214
239
  return (
215
240
  <div
241
+ ref={ref}
216
242
  role="tab"
217
243
  aria-selected={isActive}
244
+ aria-current={isActive}
218
245
  tabIndex={isActive ? 0 : -1}
219
246
  title={tab.path}
220
247
  draggable
@@ -239,26 +266,37 @@ function TabPill(props: TabPillProps) {
239
266
  onClose();
240
267
  }
241
268
  }}
242
- className={[
243
- 'group relative flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium border-r border-slate-200 cursor-pointer select-none whitespace-nowrap shrink-0 min-w-[8rem]',
269
+ className={cn(
270
+ 'group relative flex shrink-0 cursor-pointer select-none items-center gap-[7px]',
271
+ 'whitespace-nowrap rounded-t-sm px-2.5 pt-[7px] pb-2.5 text-detail transition-colors',
272
+ // Active is weight and a 2px underline, not a filled pill: the tab is
273
+ // part of the page, and a pill would make the strip its own object.
244
274
  isActive
245
- ? 'bg-slate-100 text-slate-900'
246
- : 'text-slate-600 hover:bg-slate-100/80',
247
- isDragging ? 'opacity-40' : '',
248
- isDragTarget ? 'border-l-2 border-l-slate-400' : '',
249
- ].join(' ')}
275
+ ? 'font-semibold text-ink shadow-[inset_0_-2px_0_var(--color-ink)]'
276
+ : 'text-ink-faint hover:bg-hover hover:text-ink-muted',
277
+ isDragging && 'opacity-40',
278
+ isDragTarget && 'border-l-2 border-l-accent',
279
+ )}
250
280
  >
281
+ {/* The accent dot marks the file you ARE looking at as having an open
282
+ request; the tree's amber one marks files you are not (proto:723). */}
283
+ {hasChangeRequest && (
284
+ <span
285
+ title="Open change request"
286
+ className="h-1.5 w-1.5 flex-none rounded-full bg-accent"
287
+ />
288
+ )}
251
289
  <span className="truncate max-w-[16rem]">{filename}</span>
252
290
  {tab.isDirty && (
253
291
  <span
254
292
  aria-label="Unsaved changes"
255
- className="w-1.5 h-1.5 rounded-full bg-amber-400 shrink-0"
293
+ className="h-1.5 w-1.5 shrink-0 rounded-full bg-wait-dot"
256
294
  />
257
295
  )}
258
296
  {hasPending && (
259
297
  <span
260
298
  aria-label="Agent has pending changes"
261
- className="px-1 py-0 rounded bg-emerald-100 text-emerald-700 text-[9px] font-bold shrink-0"
299
+ className="shrink-0 rounded-xs bg-ok-soft px-1 text-micro font-bold text-ok"
262
300
  >
263
301
  AI
264
302
  </span>
@@ -271,7 +309,10 @@ function TabPill(props: TabPillProps) {
271
309
  e.stopPropagation();
272
310
  onClose();
273
311
  }}
274
- className="ml-0.5 p-0.5 rounded hover:bg-slate-200 text-slate-400 hover:text-slate-700 opacity-0 group-hover:opacity-100 focus:opacity-100 transition-opacity shrink-0"
312
+ // `focus-visible:` rather than `focus:` so the control does not pop
313
+ // open on a mouse click — it should appear for the keyboard, which is
314
+ // the case that cannot hover.
315
+ className="ml-0.5 shrink-0 rounded-xs p-0.5 text-ink-faint opacity-0 transition-opacity hover:bg-line hover:text-ink group-hover:opacity-100 focus-visible:opacity-100"
275
316
  >
276
317
  <X size={11} />
277
318
  </button>
@@ -285,10 +326,19 @@ interface ContextMenuProps {
285
326
  onClose: () => void;
286
327
  onCloseTab: (tab: OpenTab) => void | Promise<void>;
287
328
  onCloseMany: (tabs: OpenTab[]) => void | Promise<void>;
329
+ /** The tab this menu was opened from — Escape hands focus back to it. */
330
+ returnFocusTo?: React.RefObject<HTMLElement | null>;
288
331
  }
289
332
 
290
- function ContextMenu({ state, openTabs, onClose, onCloseTab, onCloseMany }: ContextMenuProps) {
291
- const ref = useRef<HTMLDivElement>(null);
333
+ function ContextMenu({
334
+ state,
335
+ openTabs,
336
+ onClose,
337
+ onCloseTab,
338
+ onCloseMany,
339
+ returnFocusTo,
340
+ }: ContextMenuProps) {
341
+ const ref = useDismissableMenu<HTMLDivElement>({ open: true, onClose, returnFocusTo });
292
342
  const [pos, setPos] = useState<{ left: number; top: number }>({ left: state.x, top: state.y });
293
343
 
294
344
  // After the menu mounts, measure it and clamp into the viewport so a click
@@ -301,22 +351,9 @@ function ContextMenu({ state, openTabs, onClose, onCloseTab, onCloseMany }: Cont
301
351
  const left = Math.max(0, Math.min(state.x, window.innerWidth - w));
302
352
  const top = Math.max(0, Math.min(state.y, window.innerHeight - h));
303
353
  setPos({ left, top });
304
- }, [state.x, state.y]);
305
-
306
- useEffect(() => {
307
- function onMouseDown(e: MouseEvent) {
308
- if (ref.current && !ref.current.contains(e.target as Node)) onClose();
309
- }
310
- function onKey(e: KeyboardEvent) {
311
- if (e.key === 'Escape') onClose();
312
- }
313
- window.addEventListener('mousedown', onMouseDown);
314
- window.addEventListener('keydown', onKey);
315
- return () => {
316
- window.removeEventListener('mousedown', onMouseDown);
317
- window.removeEventListener('keydown', onKey);
318
- };
319
- }, [onClose]);
354
+ // `ref` comes from `useDismissableMenu` now, so it has to be declared —
355
+ // it is a stable `useRef` box, so listing it changes nothing at runtime.
356
+ }, [state.x, state.y, ref]);
320
357
 
321
358
  const targetIdx = openTabs.findIndex((t) => t.path === state.tab.path);
322
359
  // If the target tab is gone (closed under us between menu open and click),
@@ -360,25 +397,20 @@ function ContextMenu({ state, openTabs, onClose, onCloseTab, onCloseMany }: Cont
360
397
  ];
361
398
 
362
399
  return (
363
- <div
364
- ref={ref}
365
- role="menu"
366
- aria-label="Tab actions"
367
- style={{ left: pos.left, top: pos.top }}
368
- className="fixed z-50 min-w-[12rem] rounded border border-slate-200 bg-white shadow-lg py-1 text-xs"
369
- >
370
- {items.map((item) => (
371
- <button
372
- key={item.label}
373
- type="button"
374
- role="menuitem"
375
- disabled={item.disabled}
376
- onClick={item.onClick}
377
- className="w-full text-left px-3 py-1.5 text-slate-700 hover:bg-slate-100 disabled:text-slate-400 disabled:hover:bg-transparent disabled:cursor-default"
378
- >
379
- {item.label}
380
- </button>
381
- ))}
400
+ // Positioning is the caller's — `MenuPanel` is presentation only.
401
+ <div ref={ref} style={{ left: pos.left, top: pos.top }} className="fixed z-50">
402
+ <MenuPanel role="menu" aria-label="Tab actions" className="min-w-[12rem]">
403
+ {items.map((item) => (
404
+ <MenuItem
405
+ key={item.label}
406
+ role="menuitem"
407
+ disabled={item.disabled}
408
+ onClick={item.onClick}
409
+ >
410
+ {item.label}
411
+ </MenuItem>
412
+ ))}
413
+ </MenuPanel>
382
414
  </div>
383
415
  );
384
416
  }