@bevel-software/platform-core-frontend 0.26.0 → 0.27.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 (187) hide show
  1. package/package.json +2 -2
  2. package/src/core/CoreAppShell.tsx +87 -25
  3. package/src/core/ProductName.tsx +49 -0
  4. package/src/core/__tests__/ShellRoutes.test.tsx +22 -0
  5. package/src/core/__tests__/core-contributions.test.ts +16 -0
  6. package/src/core/core-contributions.ts +17 -0
  7. package/src/core/registry.ts +51 -1
  8. package/src/index.css +23 -5
  9. package/src/index.ts +5 -0
  10. package/src/modules/access/__tests__/ManageAccessDialog.proposal.test.tsx +1 -1
  11. package/src/modules/access/components/ManageAccessDialog.tsx +1 -1
  12. package/src/modules/admin/__tests__/RolesCorruptedBanner.test.tsx +70 -0
  13. package/src/modules/admin/components/RolesCorruptedBanner.tsx +9 -4
  14. package/src/modules/auth/components/LoginScreen.tsx +4 -1
  15. package/src/modules/auth/services/account.api.ts +28 -1
  16. package/src/modules/auth/services/sso.ts +1 -2
  17. package/src/modules/change-requests/__tests__/ChangeRequestDialog.sync-banner.test.tsx +176 -0
  18. package/src/modules/change-requests/__tests__/ChangeRequestDialog.unreadable.test.tsx +68 -0
  19. package/src/modules/change-requests/__tests__/ChangeRequestLink.test.tsx +182 -0
  20. package/src/modules/change-requests/__tests__/FileChangeBoxes.test.tsx +1 -1
  21. package/src/modules/change-requests/__tests__/readFileOnBranch.test.ts +79 -0
  22. package/src/modules/change-requests/components/ChangeBox.tsx +6 -1
  23. package/src/modules/change-requests/components/ChangeRequestDialog.tsx +45 -15
  24. package/src/modules/change-requests/components/ChangeRequestLink.tsx +151 -0
  25. package/src/modules/change-requests/components/CrFileTree.tsx +2 -1
  26. package/src/modules/change-requests/components/FileChangeBoxes.tsx +4 -2
  27. package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +6 -3
  28. package/src/modules/change-requests/services/change-requests.api.ts +15 -2
  29. package/src/modules/change-requests/utils/readFailure.ts +22 -0
  30. package/src/modules/embed/__tests__/EmbedLinkPage.test.tsx +74 -0
  31. package/src/modules/embed/__tests__/EmbedView.test.tsx +473 -0
  32. package/src/modules/embed/__tests__/embed-config.test.ts +128 -0
  33. package/src/modules/embed/__tests__/embed-host.test.ts +111 -0
  34. package/src/modules/embed/__tests__/mcp-app-view.test.ts +295 -0
  35. package/src/modules/embed/__tests__/mount.test.tsx +157 -0
  36. package/src/modules/embed/components/EmbedLinkPage.tsx +109 -0
  37. package/src/modules/embed/components/EmbedView.tsx +545 -0
  38. package/src/modules/embed/embed-config.ts +132 -0
  39. package/src/modules/embed/embed-host.ts +120 -0
  40. package/src/modules/embed/mount.tsx +80 -0
  41. package/src/modules/embed/services/embed-token.ts +22 -0
  42. package/src/modules/embed/services/embed.api.ts +158 -0
  43. package/src/modules/git/__tests__/BranchSwitcher.test.tsx +202 -4
  44. package/src/modules/git/__tests__/GitSyncFailedBanner.test.tsx +59 -1
  45. package/src/modules/git/__tests__/PullNeededBanner.test.tsx +39 -22
  46. package/src/modules/git/__tests__/useAutoPullUpdates.test.tsx +7 -2
  47. package/src/modules/git/branch-delete-menu-item.tsx +24 -0
  48. package/src/modules/git/components/BranchSwitcher.tsx +29 -5
  49. package/src/modules/git/components/GitSyncFailedBanner.tsx +53 -15
  50. package/src/modules/git/components/HistoryVersionPreview.tsx +5 -3
  51. package/src/modules/git/components/PullNeededBanner.tsx +15 -49
  52. package/src/modules/git/hooks/useAutoPullUpdates.ts +9 -5
  53. package/src/modules/git/index.ts +15 -0
  54. package/src/modules/git/services/__tests__/error-messages.test.ts +67 -0
  55. package/src/modules/git/services/__tests__/pull-failure.test.ts +36 -0
  56. package/src/modules/git/services/error-messages.ts +58 -1
  57. package/src/modules/git/services/pull-failure.ts +68 -0
  58. package/src/modules/git/state/branch-delete-confirm.ts +46 -0
  59. package/src/modules/layout/__tests__/HeaderAlignment.test.tsx +1 -0
  60. package/src/modules/layout/__tests__/breakpoints.test.ts +7 -1
  61. package/src/modules/layout/breakpoints.ts +8 -0
  62. package/src/modules/library/__tests__/PluginExtras.test.tsx +9 -9
  63. package/src/modules/library/__tests__/PluginPage.test.tsx +8 -1
  64. package/src/modules/library/__tests__/SkillsTree.test.tsx +13 -4
  65. package/src/modules/library/components/LibraryPage.tsx +22 -0
  66. package/src/modules/library/components/PluginExtras.tsx +23 -6
  67. package/src/modules/library/components/PluginPage.tsx +6 -1
  68. package/src/modules/library/routes/LibraryRoutes.tsx +8 -7
  69. package/src/modules/library/services/plugins.api.ts +4 -1
  70. package/src/modules/library/state/plugins-revision.ts +28 -0
  71. package/src/modules/onboarding/__tests__/agent-connection-api.test.ts +55 -0
  72. package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +87 -82
  73. package/src/modules/onboarding/__tests__/first-page-prompt.test.ts +109 -0
  74. package/src/modules/onboarding/__tests__/get-started-column.test.tsx +1001 -0
  75. package/src/modules/onboarding/__tests__/invite-dialog.test.tsx +392 -0
  76. package/src/modules/onboarding/__tests__/onboarding.test.tsx +226 -193
  77. package/src/modules/onboarding/__tests__/starter-pack-card.test.tsx +136 -0
  78. package/src/modules/onboarding/components/CreatorWelcomePage.tsx +7 -11
  79. package/src/modules/onboarding/components/EmailChipsInput.tsx +138 -0
  80. package/src/modules/onboarding/components/GetStartedColumn.tsx +651 -0
  81. package/src/modules/onboarding/components/InviteButton.tsx +35 -0
  82. package/src/modules/onboarding/components/InviteDialog.tsx +424 -0
  83. package/src/modules/onboarding/components/RootLanding.tsx +8 -24
  84. package/src/modules/onboarding/components/StarterPackCard.tsx +98 -0
  85. package/src/modules/onboarding/components/WelcomePage.tsx +65 -154
  86. package/src/modules/onboarding/first-page-prompt.ts +89 -0
  87. package/src/modules/onboarding/invite-emails.ts +175 -0
  88. package/src/modules/onboarding/services/agent-connection.api.ts +53 -0
  89. package/src/modules/onboarding/services/starter-packs.api.ts +83 -0
  90. package/src/modules/onboarding/state/agent-connection.ts +167 -0
  91. package/src/modules/onboarding/state/invite-dialog.context.ts +32 -0
  92. package/src/modules/onboarding/state/invite-dialog.tsx +31 -0
  93. package/src/modules/onboarding/state/onboarding.ts +133 -59
  94. package/src/modules/onboarding/state/starter-packs.ts +169 -0
  95. package/src/modules/settings/settings-nav-items.tsx +8 -3
  96. package/src/modules/setup/__tests__/setup.first-run-storage.test.tsx +389 -0
  97. package/src/modules/setup/__tests__/setup.github.test.tsx +5 -5
  98. package/src/modules/setup/__tests__/setup.kept-draft.test.tsx +1 -1
  99. package/src/modules/setup/__tests__/setup.repository-change.test.tsx +1 -1
  100. package/src/modules/setup/__tests__/setup.repository.test.tsx +21 -21
  101. package/src/modules/setup/__tests__/setup.test.tsx +56 -15
  102. package/src/modules/setup/__tests__/useConnectionProbe.test.tsx +123 -0
  103. package/src/modules/setup/components/FirstRunStorage.tsx +560 -0
  104. package/src/modules/setup/components/SetupGate.tsx +46 -1
  105. package/src/modules/setup/components/SetupScreen.tsx +81 -84
  106. package/src/modules/setup/hooks/useConnectionProbe.ts +93 -0
  107. package/src/modules/setup/services/setup.api.ts +3 -3
  108. package/src/modules/setup/utils/suggested-branch.ts +27 -0
  109. package/src/modules/toolbar/commands/__tests__/actions.test.tsx +210 -0
  110. package/src/modules/toolbar/commands/actions.tsx +324 -0
  111. package/src/modules/toolbar/commands/command-menu.ts +44 -0
  112. package/src/modules/toolbar/commands/useCommandActions.ts +69 -0
  113. package/src/modules/toolbar/commands/useCommandShortcuts.ts +121 -0
  114. package/src/modules/toolbar/components/AppSwitcher.tsx +106 -22
  115. package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +1 -1
  116. package/src/modules/toolbar/components/ProfileMenu.tsx +9 -4
  117. package/src/modules/toolbar/components/SearchPalette.tsx +540 -0
  118. package/src/modules/toolbar/components/Toolbar.tsx +10 -0
  119. package/src/modules/toolbar/components/__tests__/AppSwitcher.test.tsx +187 -54
  120. package/src/modules/toolbar/components/__tests__/ProfileMenu.test.tsx +64 -0
  121. package/src/modules/toolbar/components/__tests__/SearchPalette.test.tsx +832 -0
  122. package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +57 -2
  123. package/src/modules/toolbar/search/__tests__/rank.test.ts +93 -0
  124. package/src/modules/toolbar/search/__tests__/sources.test.ts +131 -0
  125. package/src/modules/toolbar/search/rank.ts +111 -0
  126. package/src/modules/toolbar/search/sources.ts +169 -0
  127. package/src/modules/workflow/hooks/useFileLock.ts +10 -7
  128. package/src/modules/workflow/services/__tests__/lock.api.test.ts +41 -0
  129. package/src/modules/workflow/services/lock.api.ts +17 -2
  130. package/src/modules/workspace/__tests__/useWorkspaceState.test.ts +49 -1
  131. package/src/modules/workspace/components/EditorTabs.tsx +39 -15
  132. package/src/modules/workspace/components/FileExplorer.tsx +39 -6
  133. package/src/modules/workspace/components/FilePaneCard.tsx +6 -2
  134. package/src/modules/workspace/components/FileRoute.tsx +12 -7
  135. package/src/modules/workspace/components/FileViewer.tsx +271 -74
  136. package/src/modules/workspace/components/KbPageHeader.tsx +13 -6
  137. package/src/modules/workspace/components/__tests__/EditorTabs.test.tsx +88 -21
  138. package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +92 -4
  139. package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +23 -3
  140. package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +330 -6
  141. package/src/modules/workspace/components/__tests__/KbPageHeader.test.tsx +17 -2
  142. package/src/modules/workspace/components/renderers/DocxRenderer.tsx +11 -16
  143. package/src/modules/workspace/components/renderers/DownloadFileButton.tsx +6 -0
  144. package/src/modules/workspace/components/renderers/EmailRenderer.tsx +23 -21
  145. package/src/modules/workspace/components/renderers/ImageRenderer.tsx +13 -29
  146. package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +9 -2
  147. package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +8 -0
  148. package/src/modules/workspace/components/renderers/PdfRenderer.tsx +14 -19
  149. package/src/modules/workspace/components/renderers/PptxRenderer.tsx +11 -17
  150. package/src/modules/workspace/components/renderers/ToolRenderer.tsx +35 -7
  151. package/src/modules/workspace/components/renderers/XlsxRenderer.tsx +11 -17
  152. package/src/modules/workspace/components/renderers/__tests__/EmailRenderer.links.test.tsx +73 -0
  153. package/src/modules/workspace/components/renderers/__tests__/ToolRenderer.scaffold.test.tsx +64 -0
  154. package/src/modules/workspace/components/renderers/__tests__/ToolRenderer.surface.test.tsx +82 -0
  155. package/src/modules/workspace/components/renderers/__tests__/bridgeHarness.ts +99 -0
  156. package/src/modules/workspace/components/renderers/__tests__/htmlSandbox.test.ts +129 -35
  157. package/src/modules/workspace/components/renderers/__tests__/htmlViewsGuide.test.ts +149 -0
  158. package/src/modules/workspace/components/renderers/__tests__/kbMarkdownLinkPolicy.test.tsx +100 -0
  159. package/src/modules/workspace/components/renderers/htmlSandbox.ts +76 -20
  160. package/src/modules/workspace/components/renderers/index.ts +26 -0
  161. package/src/modules/workspace/components/renderers/kbMarkdownPipeline.tsx +51 -1
  162. package/src/modules/workspace/components/renderers/rendererRawRead.ts +53 -0
  163. package/src/modules/workspace/components/renderers/rendererSurface.ts +109 -0
  164. package/src/modules/workspace/components/renderers/rendererWorkspace.ts +8 -2
  165. package/src/modules/workspace/hooks/__tests__/useWorkspaceState.test.tsx +126 -21
  166. package/src/modules/workspace/hooks/useCreatePage.ts +116 -0
  167. package/src/modules/workspace/hooks/useWorkspaceImageResolver.ts +24 -7
  168. package/src/modules/workspace/hooks/useWorkspaceState.ts +42 -8
  169. package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +10 -0
  170. package/src/modules/workspace/routing/__tests__/md-links-parity.test.tsx +113 -0
  171. package/src/modules/workspace/routing/kb-routes.ts +66 -12
  172. package/src/modules/workspace/state/editable-page.ts +42 -0
  173. package/src/modules/workspace/state/workspace.context.ts +13 -4
  174. package/src/modules/workspace/utils/__tests__/display-file-name.test.ts +60 -0
  175. package/src/modules/workspace/utils/__tests__/fileTree.test.ts +75 -0
  176. package/src/modules/workspace/utils/__tests__/treeConfirm.test.ts +16 -0
  177. package/src/modules/workspace/utils/display-file-name.ts +102 -0
  178. package/src/modules/workspace/utils/fileTree.ts +49 -14
  179. package/src/modules/workspace/utils/treeConfirm.ts +15 -0
  180. package/src/shared/__tests__/no-builtin-confirm.test.ts +102 -0
  181. package/src/shared/components/ConfirmProvider.tsx +156 -0
  182. package/src/shared/components/Dialog.tsx +7 -0
  183. package/src/shared/components/__tests__/ConfirmProvider.test.tsx +198 -0
  184. package/src/shared/components/confirm-context.ts +94 -0
  185. package/src/shared/components/index.ts +3 -0
  186. package/src/modules/onboarding/components/WelcomeRoute.tsx +0 -57
  187. package/src/modules/onboarding/welcome-state.ts +0 -36
@@ -11,6 +11,7 @@ import {
11
11
  } from '../../state/workspace.context';
12
12
  import { makeWorkspaceFixture } from '../../__tests__/testFixtures';
13
13
  import { OpenChangeRequestsContext } from '../../state/open-change-requests.context';
14
+ import { ConfirmProvider } from '../../../../shared/components';
14
15
 
15
16
  function makeTab(path: string, overrides: Partial<OpenTab> = {}): OpenTab {
16
17
  const content = overrides.content ?? `content:${path}`;
@@ -76,6 +77,7 @@ function Wrap({
76
77
  }) {
77
78
  return (
78
79
  <MemoryRouter>
80
+ <ConfirmProvider>
79
81
  <WorkspaceContext.Provider value={workspace}>
80
82
  <OpenChangeRequestsContext.Provider
81
83
  value={{ paths: new Set(changeRequestPaths), forPath: () => [], minePaths: new Map(), mineNumbers: new Set() }}
@@ -83,6 +85,7 @@ function Wrap({
83
85
  {children}
84
86
  </OpenChangeRequestsContext.Provider>
85
87
  </WorkspaceContext.Provider>
88
+ </ConfirmProvider>
86
89
  </MemoryRouter>
87
90
  );
88
91
  }
@@ -114,6 +117,28 @@ describe('EditorTabs', () => {
114
117
  expect(activeTab.getAttribute('aria-selected')).toBe('true');
115
118
  });
116
119
 
120
+ it("names a plugin's plugin.json Plugin settings, the path on hover", () => {
121
+ const tabs = [makeTab('knowledge-base/Plugins/GTM/plugin.json'), makeTab('knowledge-base/Plugins/GTM/mcp.json')];
122
+ const ws = makeWorkspace(tabs, 'knowledge-base/Plugins/GTM/plugin.json');
123
+ render(<Wrap workspace={ws}><EditorTabs /></Wrap>);
124
+
125
+ const [settings, mcp] = screen.getAllByRole('tab');
126
+ expect(settings.querySelector('.truncate')?.textContent).toBe('Plugin settings');
127
+ expect(settings).toHaveAttribute('title', 'knowledge-base/Plugins/GTM/plugin.json');
128
+ expect(screen.getByRole('button', { name: 'Close Plugin settings' })).toBeInTheDocument();
129
+ expect(mcp.querySelector('.truncate')?.textContent).toBe('mcp.json');
130
+ });
131
+
132
+ it("names a folder's access.md Who has access", () => {
133
+ const tabs = [makeTab('knowledge-base/KnowledgeBase/Legal/access.md')];
134
+ const ws = makeWorkspace(tabs, 'knowledge-base/KnowledgeBase/Legal/access.md');
135
+ render(<Wrap workspace={ws}><EditorTabs /></Wrap>);
136
+
137
+ const tab = screen.getByRole('tab');
138
+ expect(tab.querySelector('.truncate')?.textContent).toBe('Who has access');
139
+ expect(tab).toHaveAttribute('title', 'knowledge-base/KnowledgeBase/Legal/access.md');
140
+ });
141
+
117
142
  it('shows a dirty dot when a tab has unsaved changes', () => {
118
143
  const tabs = [makeTab('a.md', { isDirty: true })];
119
144
  const ws = makeWorkspace(tabs, 'a.md');
@@ -193,8 +218,29 @@ describe('EditorTabs', () => {
193
218
  await user.click(screen.getByText('Close others'));
194
219
 
195
220
  expect(closeTab).toHaveBeenCalledTimes(2);
196
- expect(closeTab.mock.calls[0]).toEqual([tabs[0], { skipConfirm: true }]);
197
- expect(closeTab.mock.calls[1]).toEqual([tabs[2], { skipConfirm: true }]);
221
+ // Pinned to the workspace the tabs were picked in.
222
+ expect(closeTab.mock.calls[0]).toEqual([tabs[0], { skipConfirm: true, workspaceId: 'ws-1' }]);
223
+ expect(closeTab.mock.calls[1]).toEqual([tabs[2], { skipConfirm: true, workspaceId: 'ws-1' }]);
224
+ });
225
+
226
+ it('a bulk close leaves the URL alone when the workspace moves partway through', async () => {
227
+ const user = userEvent.setup();
228
+ mockNavigate.mockClear();
229
+ // The first close lands; then the workspace moves to another branch and
230
+ // closeTab refuses the rest.
231
+ const closeTab = vi
232
+ .fn<WorkspaceContextValue['closeTab']>()
233
+ .mockResolvedValueOnce({ closed: true, newActivePath: 'b.md' })
234
+ .mockResolvedValue({ closed: false, newActivePath: 'elsewhere.md' });
235
+ const tabs = [makeTab('a.md'), makeTab('b.md'), makeTab('c.md')];
236
+ const ws = makeWorkspace(tabs, 'c.md', { closeTab });
237
+ render(<Wrap workspace={ws}><EditorTabs /></Wrap>);
238
+
239
+ fireEvent.contextMenu(screen.getAllByRole('tab')[0]); // right-click on a
240
+ await user.click(screen.getByText('Close all'));
241
+
242
+ await vi.waitFor(() => expect(closeTab).toHaveBeenCalledTimes(3));
243
+ expect(mockNavigate).not.toHaveBeenCalled();
198
244
  });
199
245
 
200
246
  it('"Close tabs to the right" only closes tabs after the target', async () => {
@@ -212,26 +258,47 @@ describe('EditorTabs', () => {
212
258
  expect(closeTab.mock.calls[1][0]).toEqual(tabs[2]);
213
259
  });
214
260
 
215
- it('bulk close shows ONE confirm when multiple tabs are dirty', async () => {
216
- const user = userEvent.setup();
217
- const closeTab = vi.fn<WorkspaceContextValue['closeTab']>(async () => ({ closed: true, newActivePath: null }));
218
- const confirmSpy = vi.spyOn(window, 'confirm').mockReturnValue(true);
219
- const tabs = [
220
- makeTab('a.md', { isDirty: true }),
221
- makeTab('b.md'),
222
- makeTab('c.md', { isDirty: true }),
223
- ];
224
- const ws = makeWorkspace(tabs, 'b.md', { closeTab });
225
- render(<Wrap workspace={ws}><EditorTabs /></Wrap>);
226
-
227
- fireEvent.contextMenu(screen.getAllByRole('tab')[1]); // right-click on b
228
- await user.click(screen.getByText('Close all'));
261
+ describe("bulk close with unsaved tabs asks ONE question in the app's dialog", () => {
262
+ async function openCloseAll() {
263
+ const user = userEvent.setup();
264
+ const closeTab = vi.fn<WorkspaceContextValue['closeTab']>(async () => ({ closed: true, newActivePath: null }));
265
+ // The browser's dialogs suppressed: never the thing that answers.
266
+ const confirmSpy = vi.spyOn(window, 'confirm').mockReturnValue(false);
267
+ const tabs = [
268
+ makeTab('a.md', { isDirty: true }),
269
+ makeTab('b.md'),
270
+ makeTab('c.md', { isDirty: true }),
271
+ ];
272
+ const ws = makeWorkspace(tabs, 'b.md', { closeTab });
273
+ render(<Wrap workspace={ws}><EditorTabs /></Wrap>);
274
+
275
+ fireEvent.contextMenu(screen.getAllByRole('tab')[1]); // right-click on b
276
+ await user.click(screen.getByText('Close all'));
277
+ const dialog = await screen.findByRole('dialog');
278
+ return { user, closeTab, confirmSpy, dialog };
279
+ }
280
+
281
+ it('lists the unsaved files with today\'s wording, and Close anyway closes every tab', async () => {
282
+ const { user, closeTab, confirmSpy, dialog } = await openCloseAll();
283
+ expect(screen.getAllByRole('dialog')).toHaveLength(1);
284
+ expect(dialog.textContent).toContain('You have unsaved changes in:\n - a.md\n - c.md\nClose anyway?');
285
+ expect(within(dialog).queryByText("Don't ask again")).toBeNull();
286
+ await user.click(within(dialog).getByRole('button', { name: 'Close anyway' }));
287
+ // All three tabs requested for close, with skipConfirm.
288
+ await vi.waitFor(() => expect(closeTab).toHaveBeenCalledTimes(3));
289
+ expect(closeTab.mock.calls.every((c) => c[1]?.skipConfirm === true)).toBe(true);
290
+ // Pinned to the workspace the question was asked in, so a branch switch
291
+ // while it was up closes nothing on the new branch.
292
+ expect(closeTab.mock.calls.every((c) => c[1]?.workspaceId === 'ws-1')).toBe(true);
293
+ expect(confirmSpy).not.toHaveBeenCalled();
294
+ });
229
295
 
230
- expect(confirmSpy).toHaveBeenCalledTimes(1);
231
- expect(confirmSpy.mock.calls[0][0]).toMatch(/a\.md/);
232
- expect(confirmSpy.mock.calls[0][0]).toMatch(/c\.md/);
233
- // All three tabs requested for close, with skipConfirm.
234
- expect(closeTab).toHaveBeenCalledTimes(3);
296
+ it('Cancel closes nothing', async () => {
297
+ const { user, closeTab, dialog } = await openCloseAll();
298
+ await user.click(within(dialog).getByRole('button', { name: 'Cancel' }));
299
+ expect(screen.queryByRole('dialog')).toBeNull();
300
+ expect(closeTab).not.toHaveBeenCalled();
301
+ });
235
302
  });
236
303
 
237
304
  it('reorders via drag and drop', () => {
@@ -3162,6 +3162,8 @@ describe('FileExplorer: platform files stay put', () => {
3162
3162
  });
3163
3163
 
3164
3164
  const PLATFORM = ['access.md', 'roles.yaml', '.bevelignore'];
3165
+ /** What a platform file's row says: access.md reads as "Who has access". */
3166
+ const shown = (name: string) => (name === 'access.md' ? 'Who has access' : name);
3165
3167
 
3166
3168
  let alertSpy: ReturnType<typeof vi.spyOn>;
3167
3169
 
@@ -3180,7 +3182,7 @@ describe('FileExplorer: platform files stay put', () => {
3180
3182
 
3181
3183
  it.each(PLATFORM)('%s cannot be dragged: the row refuses to start one', (name) => {
3182
3184
  renderExplorer({ fileTree: TREE });
3183
- expect(row(name)).toHaveAttribute('draggable', 'false');
3185
+ expect(row(shown(name))).toHaveAttribute('draggable', 'false');
3184
3186
  });
3185
3187
 
3186
3188
  it.each(PLATFORM)('a drop carrying %s is refused with the sentence, and nothing is sent', async (name) => {
@@ -3200,7 +3202,7 @@ describe('FileExplorer: platform files stay put', () => {
3200
3202
 
3201
3203
  it.each(PLATFORM)('the Rename action on %s says the sentence and opens nothing', async (name) => {
3202
3204
  const { moveEntry } = renderExplorer({ fileTree: TREE });
3203
- fireEvent.contextMenu(row(name));
3205
+ fireEvent.contextMenu(row(shown(name)));
3204
3206
  const rename = screen.getByRole('menuitem', { name: /Rename/i });
3205
3207
  expect(rename).toHaveAttribute('aria-disabled', 'true');
3206
3208
  expect(rename).toHaveAttribute('title', sentence(name));
@@ -3208,7 +3210,7 @@ describe('FileExplorer: platform files stay put', () => {
3208
3210
  fireEvent.click(rename);
3209
3211
  });
3210
3212
  // No rename box: the row still shows its name, and nothing was sent.
3211
- expect(screen.getAllByText(name)[0]).toBeInTheDocument();
3213
+ expect(screen.getAllByText(shown(name))[0]).toBeInTheDocument();
3212
3214
  expect(moveEntry).not.toHaveBeenCalled();
3213
3215
  });
3214
3216
 
@@ -3311,7 +3313,7 @@ describe('FileExplorer: platform files stay put', () => {
3311
3313
 
3312
3314
  it("the root's own copy still cannot be dragged, admin or not", () => {
3313
3315
  renderExplorer({ fileTree: MISPLACED, isAdmin: true });
3314
- expect(row('access.md')).toHaveAttribute('draggable', 'false');
3316
+ expect(row('Who has access')).toHaveAttribute('draggable', 'false');
3315
3317
  });
3316
3318
 
3317
3319
  it('a non-admin gets no exception: the misplaced row is refused like any other', async () => {
@@ -3365,6 +3367,16 @@ describe('FileExplorer: platform files stay put', () => {
3365
3367
  expect(rename).toHaveAttribute('title', sentence('access.md'));
3366
3368
  });
3367
3369
 
3370
+ it('an access.md row reads Who has access, with the file name on hover', () => {
3371
+ renderExplorer({ fileTree: TREE });
3372
+ const access = row('Who has access');
3373
+ expect(access).toHaveAttribute('data-tree-path', `${KB}/access.md`);
3374
+ expect(access).toHaveAttribute('title', 'access.md');
3375
+ expect(screen.queryByText('access.md')).not.toBeInTheDocument();
3376
+ // Other platform files are not renamed for display.
3377
+ expect(row('roles.yaml')).not.toHaveAttribute('title');
3378
+ });
3379
+
3368
3380
  it('an AGENTS.md is content, not a platform file, at the root and nested: it drags like any other row', () => {
3369
3381
  renderExplorer({ fileTree: TREE });
3370
3382
  const rows = screen.getAllByText('AGENTS.md').map((n) => n.closest('button')!);
@@ -4069,3 +4081,79 @@ describe("FileExplorer folder menu: a deployment's own entries", () => {
4069
4081
  expect(screen.queryByRole('menu')).toBeNull();
4070
4082
  });
4071
4083
  });
4084
+
4085
+ // Delete follows its own rule, narrower than the move's: the root's
4086
+ // `access.md` and `roles.yaml` are the repository's own and deleted by nobody,
4087
+ // with the sentence the server refuses with; a nested `access.md` is deleted
4088
+ // like any file its caller may write — the server's write gate decides.
4089
+ describe('FileExplorer: deleting platform files', () => {
4090
+ const KB = 'knowledge-base';
4091
+ const sentence = (name: string) => `${name} is the repository's own file and cannot be deleted.`;
4092
+ const file = (p: string): FileTreeEntry => ({ name: p.slice(p.lastIndexOf('/') + 1), relativePath: p, type: 'file' });
4093
+
4094
+ const TREE: FileTreeEntry = rootedAtCheckout({
4095
+ name: '.',
4096
+ relativePath: '.',
4097
+ type: 'directory',
4098
+ children: [
4099
+ {
4100
+ name: KB,
4101
+ relativePath: KB,
4102
+ type: 'directory',
4103
+ children: [
4104
+ file(`${KB}/access.md`),
4105
+ file(`${KB}/roles.yaml`),
4106
+ {
4107
+ name: 'Team',
4108
+ relativePath: `${KB}/Team`,
4109
+ type: 'directory',
4110
+ children: [file(`${KB}/Team/access.md`), file(`${KB}/Team/roles.yaml`)],
4111
+ },
4112
+ ],
4113
+ },
4114
+ ],
4115
+ });
4116
+
4117
+ beforeEach(() => {
4118
+ cleanup();
4119
+ mockAuthFetch.mockReset();
4120
+ });
4121
+
4122
+ // The rows show the file's plain name (`access.md` reads "Who has access");
4123
+ // the sentence keeps the file's own.
4124
+ it.each([
4125
+ ['access.md', 'Who has access'],
4126
+ ['roles.yaml', 'roles.yaml'],
4127
+ ])('the root %s shows Delete disabled with the sentence, for an admin too', async (name, label) => {
4128
+ const deleteEntry = vi.fn(async () => {});
4129
+ renderExplorer({ fileTree: TREE, deleteEntry, isAdmin: true });
4130
+ // The root's copy is the first row of that name.
4131
+ fireEvent.contextMenu(screen.getAllByText(label)[0].closest('button')!);
4132
+ const del = screen.getByRole('menuitem', { name: /Delete/i });
4133
+ expect(del).toHaveAttribute('aria-disabled', 'true');
4134
+ expect(del).toHaveAttribute('title', sentence(name));
4135
+ await act(async () => {
4136
+ fireEvent.click(del);
4137
+ });
4138
+ expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
4139
+ expect(deleteEntry).not.toHaveBeenCalled();
4140
+ });
4141
+
4142
+ it('a nested access.md offers Delete, and deletes once confirmed', async () => {
4143
+ const deleteEntry = vi.fn(async () => {});
4144
+ renderExplorer({ fileTree: TREE, deleteEntry, isAdmin: true });
4145
+ const rows = screen.getAllByText('Who has access');
4146
+ expect(rows).toHaveLength(2);
4147
+ fireEvent.contextMenu(rows[1].closest('button')!);
4148
+ const del = screen.getByRole('menuitem', { name: /Delete/i });
4149
+ expect(del).not.toHaveAttribute('aria-disabled');
4150
+ expect(del).not.toHaveAttribute('title');
4151
+ await act(async () => {
4152
+ fireEvent.click(del);
4153
+ });
4154
+ await act(async () => {
4155
+ fireEvent.click(screen.getByRole('button', { name: 'Delete' }));
4156
+ });
4157
+ expect(deleteEntry).toHaveBeenCalledWith(`${KB}/Team/access.md`);
4158
+ });
4159
+ });
@@ -101,7 +101,12 @@ function makeHydrateResult(overrides: Partial<HydrateResult> = {}): HydrateResul
101
101
 
102
102
  function LocationProbe() {
103
103
  const location = useLocation();
104
- return <div aria-label="pathname">{location.pathname}</div>;
104
+ return (
105
+ <>
106
+ <div aria-label="pathname">{location.pathname}</div>
107
+ <div aria-label="location-state">{JSON.stringify(location.state)}</div>
108
+ </>
109
+ );
105
110
  }
106
111
 
107
112
  /** Stands in for a file-tree click: navigates to a clean file URL. */
@@ -133,7 +138,13 @@ function SameBranchClickProbe() {
133
138
 
134
139
  function renderAt(
135
140
  url: string,
136
- opts: { git?: GitContextValue; workspace?: WorkspaceContextValue; canonicalize?: boolean } = {},
141
+ opts: {
142
+ git?: GitContextValue;
143
+ workspace?: WorkspaceContextValue;
144
+ canonicalize?: boolean;
145
+ /** Router state on the first entry, as a navigation would have left it. */
146
+ state?: unknown;
147
+ } = {},
137
148
  ): {
138
149
  workspace: WorkspaceContextValue;
139
150
  git: GitContextValue;
@@ -192,7 +203,7 @@ function renderAt(
192
203
  }
193
204
 
194
205
  const tree = () => (
195
- <MemoryRouter initialEntries={[url]}>
206
+ <MemoryRouter initialEntries={[opts.state === undefined ? url : { pathname: url, state: opts.state }]}>
196
207
  <Tree>
197
208
  <Routes>
198
209
  <Route path="/workspace/:branch/*" element={<FileRoute canonicalize={opts.canonicalize} />} />
@@ -247,6 +258,15 @@ describe('FileRoute: the canonical id URL', () => {
247
258
  );
248
259
  });
249
260
 
261
+ it('keeps the entry’s router state across the swap, so a request not yet acted on survives it', async () => {
262
+ routesMock.fetchNodeId.mockResolvedValue('web_search');
263
+ renderAt(`/workspace/main/${PATH}`, { ...openOn(), state: { rawFile: true } });
264
+ await waitFor(() =>
265
+ expect(screen.getByLabelText('pathname')).toHaveTextContent('/workspace/main/web_search'),
266
+ );
267
+ expect(screen.getByLabelText('location-state')).toHaveTextContent('{"rawFile":true}');
268
+ });
269
+
250
270
  it('keeps the path URL when canonicalising is off — the Library frame renders it there, and an id URL is no library location', async () => {
251
271
  routesMock.fetchNodeId.mockResolvedValue('web_search');
252
272
  renderAt(`/workspace/main/${PATH}`, { ...openOn(), canonicalize: false });