@bevel-software/platform-core-frontend 0.26.0 → 0.28.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 (206) 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__/ProductName.test.tsx +46 -0
  5. package/src/core/__tests__/ShellRoutes.test.tsx +22 -0
  6. package/src/core/__tests__/core-contributions.test.ts +16 -0
  7. package/src/core/core-contributions.ts +17 -0
  8. package/src/core/maker-url.ts +30 -0
  9. package/src/core/registry.ts +78 -1
  10. package/src/index.css +23 -5
  11. package/src/index.ts +5 -0
  12. package/src/lib/__tests__/latest-request.test.ts +48 -0
  13. package/src/lib/latest-request.ts +45 -0
  14. package/src/modules/access/__tests__/ManageAccessDialog.no-sso-invite.test.tsx +222 -0
  15. package/src/modules/access/__tests__/ManageAccessDialog.proposal.test.tsx +1 -1
  16. package/src/modules/access/api.ts +19 -3
  17. package/src/modules/access/components/ManageAccessDialog.tsx +61 -8
  18. package/src/modules/admin/__tests__/AdminRolesPage.fixed-admin.test.tsx +16 -1
  19. package/src/modules/admin/__tests__/RolesCorruptedBanner.test.tsx +70 -0
  20. package/src/modules/admin/__tests__/UserAccountsPage.test.tsx +284 -39
  21. package/src/modules/admin/components/AdminRolesPage.tsx +13 -14
  22. package/src/modules/admin/components/RolesCorruptedBanner.tsx +9 -4
  23. package/src/modules/admin/components/UserAccountsPage.tsx +91 -107
  24. package/src/modules/admin/services/roles.api.ts +14 -1
  25. package/src/modules/auth/__tests__/LoginScreen.test.tsx +80 -5
  26. package/src/modules/auth/__tests__/sso-strict-probe.test.ts +66 -0
  27. package/src/modules/auth/components/LoginScreen.tsx +101 -73
  28. package/src/modules/auth/services/account.api.ts +59 -3
  29. package/src/modules/auth/services/sso.ts +30 -10
  30. package/src/modules/auth/state/use-sign-in-methods.ts +41 -0
  31. package/src/modules/change-requests/__tests__/ChangeRequestDialog.sync-banner.test.tsx +176 -0
  32. package/src/modules/change-requests/__tests__/ChangeRequestDialog.unreadable.test.tsx +68 -0
  33. package/src/modules/change-requests/__tests__/ChangeRequestLink.test.tsx +182 -0
  34. package/src/modules/change-requests/__tests__/FileChangeBoxes.test.tsx +1 -1
  35. package/src/modules/change-requests/__tests__/readFileOnBranch.test.ts +79 -0
  36. package/src/modules/change-requests/components/ChangeBox.tsx +6 -1
  37. package/src/modules/change-requests/components/ChangeRequestDialog.tsx +45 -15
  38. package/src/modules/change-requests/components/ChangeRequestLink.tsx +151 -0
  39. package/src/modules/change-requests/components/CrFileTree.tsx +2 -1
  40. package/src/modules/change-requests/components/FileChangeBoxes.tsx +4 -2
  41. package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +6 -3
  42. package/src/modules/change-requests/services/change-requests.api.ts +15 -2
  43. package/src/modules/change-requests/utils/readFailure.ts +22 -0
  44. package/src/modules/embed/__tests__/EmbedLinkPage.test.tsx +74 -0
  45. package/src/modules/embed/__tests__/EmbedView.test.tsx +473 -0
  46. package/src/modules/embed/__tests__/embed-config.test.ts +128 -0
  47. package/src/modules/embed/__tests__/embed-host.test.ts +111 -0
  48. package/src/modules/embed/__tests__/mcp-app-view.test.ts +295 -0
  49. package/src/modules/embed/__tests__/mount.test.tsx +157 -0
  50. package/src/modules/embed/components/EmbedLinkPage.tsx +109 -0
  51. package/src/modules/embed/components/EmbedView.tsx +545 -0
  52. package/src/modules/embed/embed-config.ts +132 -0
  53. package/src/modules/embed/embed-host.ts +120 -0
  54. package/src/modules/embed/mount.tsx +80 -0
  55. package/src/modules/embed/services/embed-token.ts +22 -0
  56. package/src/modules/embed/services/embed.api.ts +158 -0
  57. package/src/modules/git/__tests__/BranchSwitcher.test.tsx +202 -4
  58. package/src/modules/git/__tests__/GitSyncFailedBanner.test.tsx +59 -1
  59. package/src/modules/git/__tests__/PullNeededBanner.test.tsx +39 -22
  60. package/src/modules/git/__tests__/useAutoPullUpdates.test.tsx +7 -2
  61. package/src/modules/git/branch-delete-menu-item.tsx +24 -0
  62. package/src/modules/git/components/BranchSwitcher.tsx +29 -5
  63. package/src/modules/git/components/GitSyncFailedBanner.tsx +53 -15
  64. package/src/modules/git/components/HistoryVersionPreview.tsx +5 -3
  65. package/src/modules/git/components/PullNeededBanner.tsx +15 -49
  66. package/src/modules/git/hooks/useAutoPullUpdates.ts +9 -5
  67. package/src/modules/git/index.ts +15 -0
  68. package/src/modules/git/services/__tests__/error-messages.test.ts +67 -0
  69. package/src/modules/git/services/__tests__/pull-failure.test.ts +36 -0
  70. package/src/modules/git/services/error-messages.ts +58 -1
  71. package/src/modules/git/services/pull-failure.ts +68 -0
  72. package/src/modules/git/state/branch-delete-confirm.ts +46 -0
  73. package/src/modules/layout/__tests__/HeaderAlignment.test.tsx +1 -0
  74. package/src/modules/layout/__tests__/breakpoints.test.ts +7 -1
  75. package/src/modules/layout/breakpoints.ts +8 -0
  76. package/src/modules/library/__tests__/PluginExtras.test.tsx +9 -9
  77. package/src/modules/library/__tests__/PluginPage.test.tsx +8 -1
  78. package/src/modules/library/__tests__/SkillsTree.test.tsx +13 -4
  79. package/src/modules/library/components/LibraryPage.tsx +22 -0
  80. package/src/modules/library/components/PluginExtras.tsx +23 -6
  81. package/src/modules/library/components/PluginPage.tsx +6 -1
  82. package/src/modules/library/routes/LibraryRoutes.tsx +8 -7
  83. package/src/modules/library/services/plugins.api.ts +4 -1
  84. package/src/modules/library/state/plugins-revision.ts +28 -0
  85. package/src/modules/onboarding/__tests__/InviteButton.test.tsx +214 -0
  86. package/src/modules/onboarding/__tests__/agent-connection-api.test.ts +55 -0
  87. package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +87 -82
  88. package/src/modules/onboarding/__tests__/first-page-prompt.test.ts +164 -0
  89. package/src/modules/onboarding/__tests__/get-started-column.test.tsx +1458 -0
  90. package/src/modules/onboarding/__tests__/invite-dialog.test.tsx +811 -0
  91. package/src/modules/onboarding/__tests__/invite-emails.test.ts +247 -0
  92. package/src/modules/onboarding/__tests__/onboarding.test.tsx +226 -193
  93. package/src/modules/onboarding/__tests__/starter-pack-card.test.tsx +136 -0
  94. package/src/modules/onboarding/components/CreatorWelcomePage.tsx +7 -11
  95. package/src/modules/onboarding/components/EmailChipsInput.tsx +138 -0
  96. package/src/modules/onboarding/components/GetStartedColumn.tsx +670 -0
  97. package/src/modules/onboarding/components/InviteButton.tsx +139 -0
  98. package/src/modules/onboarding/components/InviteDialog.tsx +741 -0
  99. package/src/modules/onboarding/components/RootLanding.tsx +8 -24
  100. package/src/modules/onboarding/components/StarterPackCard.tsx +98 -0
  101. package/src/modules/onboarding/components/WelcomePage.tsx +65 -154
  102. package/src/modules/onboarding/first-page-prompt.ts +123 -0
  103. package/src/modules/onboarding/invite-emails.ts +313 -0
  104. package/src/modules/onboarding/services/agent-connection.api.ts +53 -0
  105. package/src/modules/onboarding/services/starter-packs.api.ts +83 -0
  106. package/src/modules/onboarding/state/agent-connection.ts +167 -0
  107. package/src/modules/onboarding/state/invite-dialog.context.ts +35 -0
  108. package/src/modules/onboarding/state/invite-dialog.tsx +39 -0
  109. package/src/modules/onboarding/state/onboarding.ts +133 -59
  110. package/src/modules/onboarding/state/starter-packs.ts +169 -0
  111. package/src/modules/settings/settings-nav-items.tsx +8 -3
  112. package/src/modules/setup/__tests__/setup.first-run-storage.test.tsx +389 -0
  113. package/src/modules/setup/__tests__/setup.github.test.tsx +5 -5
  114. package/src/modules/setup/__tests__/setup.kept-draft.test.tsx +1 -1
  115. package/src/modules/setup/__tests__/setup.repository-change.test.tsx +1 -1
  116. package/src/modules/setup/__tests__/setup.repository.test.tsx +21 -21
  117. package/src/modules/setup/__tests__/setup.test.tsx +56 -15
  118. package/src/modules/setup/__tests__/useConnectionProbe.test.tsx +123 -0
  119. package/src/modules/setup/components/FirstRunStorage.tsx +560 -0
  120. package/src/modules/setup/components/SetupGate.tsx +46 -1
  121. package/src/modules/setup/components/SetupScreen.tsx +81 -84
  122. package/src/modules/setup/hooks/useConnectionProbe.ts +93 -0
  123. package/src/modules/setup/services/setup.api.ts +3 -3
  124. package/src/modules/setup/utils/suggested-branch.ts +27 -0
  125. package/src/modules/toolbar/commands/__tests__/actions.test.tsx +210 -0
  126. package/src/modules/toolbar/commands/actions.tsx +330 -0
  127. package/src/modules/toolbar/commands/command-menu.ts +44 -0
  128. package/src/modules/toolbar/commands/useCommandActions.ts +71 -0
  129. package/src/modules/toolbar/commands/useCommandShortcuts.ts +121 -0
  130. package/src/modules/toolbar/components/AppSwitcher.tsx +125 -22
  131. package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +1 -1
  132. package/src/modules/toolbar/components/ProfileMenu.tsx +9 -4
  133. package/src/modules/toolbar/components/SearchPalette.tsx +540 -0
  134. package/src/modules/toolbar/components/Toolbar.tsx +10 -0
  135. package/src/modules/toolbar/components/__tests__/AppSwitcher.test.tsx +230 -52
  136. package/src/modules/toolbar/components/__tests__/ProfileMenu.test.tsx +64 -0
  137. package/src/modules/toolbar/components/__tests__/SearchPalette.test.tsx +864 -0
  138. package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +57 -2
  139. package/src/modules/toolbar/search/__tests__/rank.test.ts +93 -0
  140. package/src/modules/toolbar/search/__tests__/sources.test.ts +131 -0
  141. package/src/modules/toolbar/search/rank.ts +111 -0
  142. package/src/modules/toolbar/search/sources.ts +169 -0
  143. package/src/modules/workflow/hooks/useFileLock.ts +10 -7
  144. package/src/modules/workflow/services/__tests__/lock.api.test.ts +41 -0
  145. package/src/modules/workflow/services/lock.api.ts +17 -2
  146. package/src/modules/workspace/__tests__/useWorkspaceState.test.ts +49 -1
  147. package/src/modules/workspace/components/EditorTabs.tsx +39 -15
  148. package/src/modules/workspace/components/FileExplorer.tsx +39 -6
  149. package/src/modules/workspace/components/FilePaneCard.tsx +6 -2
  150. package/src/modules/workspace/components/FileRoute.tsx +12 -7
  151. package/src/modules/workspace/components/FileViewer.tsx +271 -74
  152. package/src/modules/workspace/components/KbPageHeader.tsx +13 -6
  153. package/src/modules/workspace/components/__tests__/EditorTabs.test.tsx +88 -21
  154. package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +92 -4
  155. package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +23 -3
  156. package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +330 -6
  157. package/src/modules/workspace/components/__tests__/KbPageHeader.test.tsx +17 -2
  158. package/src/modules/workspace/components/renderers/DocxRenderer.tsx +11 -16
  159. package/src/modules/workspace/components/renderers/DownloadFileButton.tsx +6 -0
  160. package/src/modules/workspace/components/renderers/EmailRenderer.tsx +23 -21
  161. package/src/modules/workspace/components/renderers/ImageRenderer.tsx +13 -29
  162. package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +9 -2
  163. package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +8 -0
  164. package/src/modules/workspace/components/renderers/PdfRenderer.tsx +14 -19
  165. package/src/modules/workspace/components/renderers/PptxRenderer.tsx +11 -17
  166. package/src/modules/workspace/components/renderers/ToolRenderer.tsx +35 -7
  167. package/src/modules/workspace/components/renderers/XlsxRenderer.tsx +11 -17
  168. package/src/modules/workspace/components/renderers/__tests__/EmailRenderer.links.test.tsx +73 -0
  169. package/src/modules/workspace/components/renderers/__tests__/ToolRenderer.scaffold.test.tsx +64 -0
  170. package/src/modules/workspace/components/renderers/__tests__/ToolRenderer.surface.test.tsx +82 -0
  171. package/src/modules/workspace/components/renderers/__tests__/bridgeHarness.ts +99 -0
  172. package/src/modules/workspace/components/renderers/__tests__/htmlSandbox.test.ts +129 -35
  173. package/src/modules/workspace/components/renderers/__tests__/htmlViewsGuide.test.ts +149 -0
  174. package/src/modules/workspace/components/renderers/__tests__/kbMarkdownLinkPolicy.test.tsx +100 -0
  175. package/src/modules/workspace/components/renderers/htmlSandbox.ts +76 -20
  176. package/src/modules/workspace/components/renderers/index.ts +26 -0
  177. package/src/modules/workspace/components/renderers/kbMarkdownPipeline.tsx +51 -1
  178. package/src/modules/workspace/components/renderers/rendererRawRead.ts +53 -0
  179. package/src/modules/workspace/components/renderers/rendererSurface.ts +109 -0
  180. package/src/modules/workspace/components/renderers/rendererWorkspace.ts +8 -2
  181. package/src/modules/workspace/hooks/__tests__/useCreatePage.test.ts +137 -0
  182. package/src/modules/workspace/hooks/__tests__/useKnowledgeWriteTarget.test.ts +302 -0
  183. package/src/modules/workspace/hooks/__tests__/useWorkspaceState.test.tsx +126 -21
  184. package/src/modules/workspace/hooks/useCreatePage.ts +206 -0
  185. package/src/modules/workspace/hooks/useKnowledgeWriteTarget.ts +238 -0
  186. package/src/modules/workspace/hooks/useWorkspaceImageResolver.ts +24 -7
  187. package/src/modules/workspace/hooks/useWorkspaceState.ts +42 -8
  188. package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +10 -0
  189. package/src/modules/workspace/routing/__tests__/md-links-parity.test.tsx +113 -0
  190. package/src/modules/workspace/routing/kb-routes.ts +66 -12
  191. package/src/modules/workspace/state/editable-page.ts +42 -0
  192. package/src/modules/workspace/state/workspace.context.ts +13 -4
  193. package/src/modules/workspace/utils/__tests__/display-file-name.test.ts +60 -0
  194. package/src/modules/workspace/utils/__tests__/fileTree.test.ts +75 -0
  195. package/src/modules/workspace/utils/__tests__/treeConfirm.test.ts +16 -0
  196. package/src/modules/workspace/utils/display-file-name.ts +102 -0
  197. package/src/modules/workspace/utils/fileTree.ts +49 -14
  198. package/src/modules/workspace/utils/treeConfirm.ts +15 -0
  199. package/src/shared/__tests__/no-builtin-confirm.test.ts +102 -0
  200. package/src/shared/components/ConfirmProvider.tsx +156 -0
  201. package/src/shared/components/Dialog.tsx +7 -0
  202. package/src/shared/components/__tests__/ConfirmProvider.test.tsx +198 -0
  203. package/src/shared/components/confirm-context.ts +94 -0
  204. package/src/shared/components/index.ts +3 -0
  205. package/src/modules/onboarding/components/WelcomeRoute.tsx +0 -57
  206. package/src/modules/onboarding/welcome-state.ts +0 -36
@@ -0,0 +1,182 @@
1
+ import { describe, it, expect, vi, beforeEach } from 'vitest';
2
+ import { render, screen, waitFor } from '@testing-library/react';
3
+ import userEvent from '@testing-library/user-event';
4
+ import { MemoryRouter, Route, Routes, useLocation, useNavigate } from 'react-router-dom';
5
+ import type { PullRequestSummary } from '@bevel-software/platform-shared';
6
+ import { GitApiError } from '../../git/services/git.api';
7
+
8
+ const api = vi.hoisted(() => ({ getPullRequest: vi.fn() }));
9
+ vi.mock('../../git/services/pr.api', () => ({ getPullRequest: api.getPullRequest }));
10
+
11
+ // The view itself is covered where it lives; here it is a stand-in that shows
12
+ // which request it was handed and lets a test close it.
13
+ vi.mock('../components/ChangeRequestDialog', () => ({
14
+ ChangeRequestDialog: ({
15
+ cr,
16
+ onClose,
17
+ onResolved,
18
+ }: {
19
+ cr: PullRequestSummary;
20
+ onClose(): void;
21
+ onResolved(): void;
22
+ }) => (
23
+ <div role="dialog" aria-label={`change request ${cr.number}`}>
24
+ {cr.title}
25
+ <button onClick={onClose}>Close</button>
26
+ <button onClick={onResolved}>Apply</button>
27
+ </div>
28
+ ),
29
+ }));
30
+
31
+ import { ChangeRequestLink } from '../components/ChangeRequestLink';
32
+
33
+ /**
34
+ * `/change-requests/<number>` is the address every agent hands a person for a
35
+ * change request. Until this route existed the shell's catch-all sent it to
36
+ * the workspace with nothing open — "the link didn't open anything". These
37
+ * pin what the address does now: the request opens, a bad or hidden one says
38
+ * so in one sentence, and leaving the view lands in Knowledge.
39
+ */
40
+
41
+ const CR = { number: 276, title: 'Add the Q3 roadmap', author: { login: 'bot' } } as PullRequestSummary;
42
+
43
+ /** The address, and a way to change it the way a link in the app would. */
44
+ function LocationProbe() {
45
+ const location = useLocation();
46
+ const navigate = useNavigate();
47
+ return (
48
+ <>
49
+ <div data-testid="pathname">{location.pathname}</div>
50
+ <button onClick={() => navigate('/change-requests/277')}>Go to 277</button>
51
+ <button onClick={() => navigate(-1)}>Back</button>
52
+ </>
53
+ );
54
+ }
55
+
56
+ function renderAt(path: string) {
57
+ return render(
58
+ <MemoryRouter initialEntries={['/somewhere-before', path]} initialIndex={1}>
59
+ <Routes>
60
+ <Route path="/change-requests/:number" element={<ChangeRequestLink />} />
61
+ <Route path="*" element={<div data-testid="elsewhere" />} />
62
+ </Routes>
63
+ <LocationProbe />
64
+ </MemoryRouter>,
65
+ );
66
+ }
67
+
68
+ beforeEach(() => {
69
+ api.getPullRequest.mockReset();
70
+ });
71
+
72
+ describe('ChangeRequestLink', () => {
73
+ it('opens the request the address names, in the change-request view', async () => {
74
+ api.getPullRequest.mockResolvedValue(CR);
75
+ renderAt('/change-requests/276');
76
+ expect(screen.getByText('Opening change request #276…')).toBeInTheDocument();
77
+ const dialog = await screen.findByRole('dialog', { name: 'change request 276' });
78
+ expect(dialog).toHaveTextContent('Add the Q3 roadmap');
79
+ expect(api.getPullRequest).toHaveBeenCalledWith(276);
80
+ });
81
+
82
+ it.each(['Close', 'Apply'])(
83
+ 'goes to Knowledge on %s — there is nothing under the view to return to',
84
+ async (verb) => {
85
+ api.getPullRequest.mockResolvedValue(CR);
86
+ renderAt('/change-requests/276');
87
+ await userEvent.click(await screen.findByRole('button', { name: verb }));
88
+ expect(screen.getByTestId('pathname')).toHaveTextContent(/^\/workspace$/);
89
+ expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
90
+ },
91
+ );
92
+
93
+ // The link's entry is replaced, not pushed: Back after closing must not
94
+ // land on the address again and reopen the request.
95
+ it('leaves no history entry behind, so Back goes to where the person was before the link', async () => {
96
+ api.getPullRequest.mockResolvedValue(CR);
97
+ renderAt('/change-requests/276');
98
+ await userEvent.click(await screen.findByRole('button', { name: 'Close' }));
99
+ await userEvent.click(screen.getByRole('button', { name: 'Back' }));
100
+ expect(screen.getByTestId('pathname')).toHaveTextContent(/^\/somewhere-before$/);
101
+ expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
102
+ });
103
+
104
+ // The page's own way out behaves the same as the dialog's.
105
+ it('leaves no history entry behind through "Back to the knowledge base" either', async () => {
106
+ api.getPullRequest.mockRejectedValue(new GitApiError(404, 'nope'));
107
+ renderAt('/change-requests/276');
108
+ // Once the answer is on screen: the loading page has the same link, and
109
+ // a click that lands while the answer replaces it hits a detached node.
110
+ await screen.findByText(/There is no change request #276/);
111
+ await userEvent.click(screen.getByRole('link', { name: 'Back to the knowledge base' }));
112
+ expect(screen.getByTestId('pathname')).toHaveTextContent(/^\/workspace$/);
113
+ await userEvent.click(screen.getByRole('button', { name: 'Back' }));
114
+ expect(screen.getByTestId('pathname')).toHaveTextContent(/^\/somewhere-before$/);
115
+ });
116
+
117
+ // A request that is not there and one the viewer may not see read the
118
+ // same: the address must not tell someone a request they may not see
119
+ // exists.
120
+ it.each([404, 403])('says there is no such request on a %s, naming the number', async (status) => {
121
+ api.getPullRequest.mockRejectedValue(new GitApiError(status, 'nope'));
122
+ renderAt('/change-requests/276');
123
+ expect(
124
+ await screen.findByText(/There is no change request #276 — it does not exist, or you may not see it\./),
125
+ ).toBeInTheDocument();
126
+ expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
127
+ expect(screen.getByRole('link', { name: 'Back to the knowledge base' })).toHaveAttribute('href', '/workspace');
128
+ });
129
+
130
+ it('keeps the platform\'s own words for any other failure', async () => {
131
+ api.getPullRequest.mockRejectedValue(new GitApiError(502, 'the repository host is unreachable'));
132
+ renderAt('/change-requests/276');
133
+ expect(await screen.findByText(/could not be opened: the repository host is unreachable/)).toBeInTheDocument();
134
+ });
135
+
136
+ it('asks the server nothing for an address that names no request', async () => {
137
+ for (const bad of [
138
+ '/change-requests/abc',
139
+ '/change-requests/0',
140
+ '/change-requests/-3',
141
+ '/change-requests/12x',
142
+ // One past the database sequence's maximum.
143
+ '/change-requests/2147483648',
144
+ ]) {
145
+ const { unmount } = renderAt(bad);
146
+ expect(screen.getByText(/There is no change request/)).toBeInTheDocument();
147
+ unmount();
148
+ }
149
+ expect(api.getPullRequest).not.toHaveBeenCalled();
150
+ });
151
+
152
+ it('accepts every number the database can hand out', async () => {
153
+ api.getPullRequest.mockResolvedValue({ ...CR, number: 2147483647, title: 'The last one' });
154
+ renderAt('/change-requests/2147483647');
155
+ expect(await screen.findByRole('dialog', { name: 'change request 2147483647' })).toBeInTheDocument();
156
+ });
157
+
158
+ // The router reuses the element across a change of the parameter. A new
159
+ // number must start from "loading", and the first request's answer, if it
160
+ // lands late, must not replace the second's.
161
+ it('shows the request the address names now, not the one it named before', async () => {
162
+ // Both lookups answer when the test says, so each step is observable.
163
+ const pending = new Map<number, (cr: PullRequestSummary) => void>();
164
+ api.getPullRequest.mockImplementation(
165
+ (num: number) => new Promise<PullRequestSummary>((resolve) => pending.set(num, resolve)),
166
+ );
167
+ renderAt('/change-requests/276');
168
+ expect(screen.getByText('Opening change request #276…')).toBeInTheDocument();
169
+
170
+ await userEvent.click(screen.getByRole('button', { name: 'Go to 277' }));
171
+ expect(screen.getByText('Opening change request #277…')).toBeInTheDocument();
172
+ expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
173
+
174
+ pending.get(277)!({ ...CR, number: 277, title: 'The next one' });
175
+ expect(await screen.findByRole('dialog', { name: 'change request 277' })).toHaveTextContent('The next one');
176
+
177
+ // The first answer, late: it belongs to an address the page has left.
178
+ pending.get(276)!(CR);
179
+ await waitFor(() => expect(screen.queryByRole('dialog', { name: 'change request 276' })).not.toBeInTheDocument());
180
+ expect(screen.getByRole('dialog', { name: 'change request 277' })).toHaveTextContent('The next one');
181
+ });
182
+ });
@@ -157,7 +157,7 @@ describe('FileChangeBoxes: who may decide', () => {
157
157
  bus.emit({ kind: 'change-request-merged', number: CR.number } as unknown as WorkflowEvent);
158
158
  });
159
159
  expect(
160
- await screen.findByText('Applied: the file now reads with that change.'),
160
+ await screen.findByText('Published: the file now reads with that change.'),
161
161
  ).toBeInTheDocument();
162
162
  });
163
163
  });
@@ -0,0 +1,79 @@
1
+ import { describe, it, expect, vi, beforeEach } from 'vitest';
2
+
3
+ /**
4
+ * `readFileOnBranch` is two reads: open the branch's workspace, then read the
5
+ * file in it. Both can answer 404, for opposite reasons — "there is no branch
6
+ * named X" and "this branch has no such file" — and the callers that treat a
7
+ * file-read 404 as a deletion (the change-request pane, the diff boxes) must
8
+ * never be handed the branch's 404 in that shape. The branch failure is told
9
+ * apart as its own error, status kept.
10
+ */
11
+
12
+ const wsMock = vi.hoisted(() => ({ getOrCreateWorkspace: vi.fn(), readFile: vi.fn() }));
13
+ vi.mock('../../workspace/services/workspace.api', async (importOriginal) => ({
14
+ ...(await importOriginal<typeof import('../../workspace/services/workspace.api')>()),
15
+ getOrCreateWorkspace: wsMock.getOrCreateWorkspace,
16
+ readFile: wsMock.readFile,
17
+ }));
18
+
19
+ import { readFileOnBranch } from '../services/change-requests.api';
20
+ import { WorkspaceApiError } from '../../workspace/services/workspace.api';
21
+ import { BranchUnavailableError, failureReason, isDenial, statusOf } from '../utils/readFailure';
22
+
23
+ beforeEach(() => {
24
+ wsMock.getOrCreateWorkspace.mockReset();
25
+ wsMock.readFile.mockReset();
26
+ wsMock.getOrCreateWorkspace.mockResolvedValue({
27
+ workspace: { id: 'ws-7', kbDirName: 'knowledge-base' },
28
+ fileTree: null,
29
+ });
30
+ });
31
+
32
+ describe('readFileOnBranch', () => {
33
+ it('reads the file inside the branch workspace, under its knowledge-base folder', async () => {
34
+ wsMock.readFile.mockResolvedValue('bands:\n');
35
+ await expect(readFileOnBranch('ali/payroll', 'Finance/bands.yaml')).resolves.toBe('bands:\n');
36
+ expect(wsMock.getOrCreateWorkspace).toHaveBeenCalledWith('ali/payroll');
37
+ expect(wsMock.readFile).toHaveBeenCalledWith('ws-7', 'knowledge-base/Finance/bands.yaml');
38
+ });
39
+
40
+ it("passes the FILE read's 404 through as it is — that is the branch saying it has no such file", async () => {
41
+ wsMock.readFile.mockRejectedValue(new WorkspaceApiError(404));
42
+ const err = await readFileOnBranch('ali/payroll', 'Finance/bands.yaml').catch((e: unknown) => e);
43
+ expect(err).toBeInstanceOf(WorkspaceApiError);
44
+ expect(err).not.toBeInstanceOf(BranchUnavailableError);
45
+ expect(statusOf(err)).toBe(404);
46
+ });
47
+
48
+ it("answers a branch that could not be opened apart from the file's own errors", async () => {
49
+ wsMock.getOrCreateWorkspace.mockRejectedValue(
50
+ new WorkspaceApiError(404, 'There is no branch named ali/payroll.'),
51
+ );
52
+ const err = await readFileOnBranch('ali/payroll', 'Finance/bands.yaml').catch((e: unknown) => e);
53
+ // Not the shape a deletion is read from.
54
+ expect(err).toBeInstanceOf(BranchUnavailableError);
55
+ expect(err).not.toBeInstanceOf(WorkspaceApiError);
56
+ expect((err as BranchUnavailableError).branch).toBe('ali/payroll');
57
+ // The reason the retryable sentence prints names the branch and the cause.
58
+ expect(failureReason(err)).toBe(
59
+ "the branch ali/payroll couldn't be opened (There is no branch named ali/payroll.)",
60
+ );
61
+ // The file was never asked for.
62
+ expect(wsMock.readFile).not.toHaveBeenCalled();
63
+ });
64
+
65
+ it('keeps the status of a refused branch, so a refusal still reads as one', async () => {
66
+ wsMock.getOrCreateWorkspace.mockRejectedValue(new WorkspaceApiError(403));
67
+ const err = await readFileOnBranch('ali/payroll', 'Finance/bands.yaml').catch((e: unknown) => e);
68
+ expect(err).toBeInstanceOf(BranchUnavailableError);
69
+ expect(isDenial(err)).toBe(true);
70
+ });
71
+
72
+ it('carries no status for a branch open that never completed', async () => {
73
+ wsMock.getOrCreateWorkspace.mockRejectedValue(new TypeError('Failed to fetch'));
74
+ const err = await readFileOnBranch('ali/payroll', 'Finance/bands.yaml').catch((e: unknown) => e);
75
+ expect(err).toBeInstanceOf(BranchUnavailableError);
76
+ expect(statusOf(err)).toBeNull();
77
+ expect(isDenial(err)).toBe(false);
78
+ });
79
+ });
@@ -9,6 +9,8 @@ import { ConflictHelp } from './ConflictHelp';
9
9
  export interface ChangeBoxProps {
10
10
  /** File the proposal is against, relative to the skill folder. */
11
11
  file: string;
12
+ /** The file's real name, for hover, when `file` is a platform file's plain name. */
13
+ fileTitle?: string;
12
14
  /** Display name of whoever proposed it. */
13
15
  author: string;
14
16
  /** Already-formatted, e.g. "today" or "2 Aug". */
@@ -105,6 +107,7 @@ export interface ChangeBoxProps {
105
107
  */
106
108
  export function ChangeBox({
107
109
  file,
110
+ fileTitle,
108
111
  author,
109
112
  when,
110
113
  mine,
@@ -143,7 +146,9 @@ export function ChangeBox({
143
146
  <span className="text-detail text-ink">
144
147
  <b className="font-semibold">{who}</b> proposed a change · {when}
145
148
  </span>
146
- <span className="ml-auto truncate font-mono text-meta text-ink-faint">{file}</span>
149
+ <span className="ml-auto truncate font-mono text-meta text-ink-faint" title={fileTitle}>
150
+ {file}
151
+ </span>
147
152
  </div>
148
153
 
149
154
  {/* No diff area when there is no difference — an empty pane under a
@@ -17,8 +17,11 @@ import { approvePrFile, revertPrFile, unapprovePrFile } from '../../pr/services/
17
17
  import { deleteChangeRequest } from '../../pr/services/pr-cancel.api';
18
18
  import { refreshChangeRequestFromTarget } from '../../pr/services/pr-merge.api';
19
19
  import { GitApiError } from '../../git/services/git.api';
20
+ import { friendlyGitError, friendlyGitMessage } from '../../git/services/error-messages';
21
+ import { GitSyncFailedBanner } from '../../git/components/GitSyncFailedBanner';
20
22
  import { useApplyChangeRequest } from '../hooks/useApplyChangeRequest';
21
23
  import { readFileOnBranch } from '../services/change-requests.api';
24
+ import { WorkspaceApiError } from '../../workspace/services/workspace.api';
22
25
  import { describeReadFailure } from '../services/denied-file.api';
23
26
  import { deniedSentence, readErrorLead, type ReadFailure } from '../utils/readFailure';
24
27
  import { changeAuthorName } from '../utils/author';
@@ -237,6 +240,16 @@ export function ChangeRequestDialog({
237
240
  };
238
241
  }, [bus, cr.number]);
239
242
 
243
+ // The request's verbs (revert, update) push its SOURCE branch, which is
244
+ // rarely the branch in the address bar. Watch that workspace while the
245
+ // dialog is open, so a push the host refuses raises the sync banner here —
246
+ // and the push that later lands clears it here.
247
+ const sourceWorkspaceId = encodeURIComponent(cr.branch);
248
+ useEffect(() => {
249
+ if (!bus) return;
250
+ return bus.watchWorkspace(sourceWorkspaceId);
251
+ }, [bus, sourceWorkspaceId]);
252
+
240
253
  // EVERYTHING is repo-relative, scoped or not — the scope's baseFiles are
241
254
  // lifted to full paths, and every touched file lists whatever folder it is
242
255
  // in. The dialog is a decision about the WHOLE request; a file it touches
@@ -337,22 +350,35 @@ export function ChangeRequestDialog({
337
350
  const token = {};
338
351
  asked.current.set(selected, token);
339
352
  const current = () => asked.current.get(selected) === token;
353
+ const removes = detail.files.some((f) => f.path === selected && f.status === 'removed');
340
354
  readFileOnBranch(cr.branch, selected)
341
355
  .then((content) => {
342
356
  if (current()) setBranchContents((c) => ({ ...c, [selected]: content }));
343
357
  })
344
- // NOT `''`. An unreadable branch copy stored as empty would diff as
345
- // "every line deleted" — a change request that erases the file.
346
- //
347
- // The failure is described before it is published: naming the folder
348
- // to ask about is a second read, and the pane stays on "Loading…"
349
- // until it settles rather than saying "couldn't be read" and then
350
- // rewriting it as "you don't have access" a moment later.
351
- .catch((err: unknown) =>
352
- describeReadFailure(err, cr.branch, selected).then((failure) => {
358
+ .catch((err: unknown) => {
359
+ if (!current()) return;
360
+ // A file the request REMOVES is not on its branch, and the FILE read
361
+ // says so with a 404. That is the proposal, not a failed read: the
362
+ // branch copy is empty, and the current copy diffs against it as
363
+ // every line deleted — the same rule the diff boxes apply. A branch
364
+ // that could not be opened is not a `WorkspaceApiError` here
365
+ // (`readFileOnBranch` answers that apart), so it stays a failure.
366
+ if (removes && err instanceof WorkspaceApiError && err.status === 404) {
367
+ setBranchContents((c) => ({ ...c, [selected]: '' }));
368
+ return;
369
+ }
370
+ // Anything else is NOT `''`. An unreadable branch copy stored as
371
+ // empty would diff as "every line deleted" — a change request that
372
+ // erases the file.
373
+ //
374
+ // The failure is described before it is published: naming the
375
+ // folder to ask about is a second read, and the pane stays on
376
+ // "Loading…" until it settles rather than saying "couldn't be read"
377
+ // and then rewriting it as "you don't have access" a moment later.
378
+ void describeReadFailure(err, cr.branch, selected).then((failure) => {
353
379
  if (current()) setBranchFailure((m) => new Map(m).set(selected, failure));
354
- }),
355
- );
380
+ });
381
+ });
356
382
  }
357
383
  }, [selected, selectedIsBinary, cr.branch, branchRevision, detail]);
358
384
 
@@ -674,7 +700,7 @@ export function ChangeRequestDialog({
674
700
  : await approvePrFile(cr.number, path);
675
701
  setDetail((d) => (d ? { ...d, approvals } : d));
676
702
  } catch (err) {
677
- setVerbError(err instanceof Error ? err.message : "Couldn't record that.");
703
+ setVerbError(err instanceof Error ? friendlyGitError(err) : "Couldn't record that.");
678
704
  } finally {
679
705
  setVerbBusy(false);
680
706
  }
@@ -696,7 +722,7 @@ export function ChangeRequestDialog({
696
722
  setDetail((d) => (d ? { ...d, approvals } : d));
697
723
  }
698
724
  } catch (err) {
699
- setVerbError(err instanceof Error ? err.message : "Couldn't record that.");
725
+ setVerbError(err instanceof Error ? friendlyGitError(err) : "Couldn't record that.");
700
726
  } finally {
701
727
  setVerbBusy(false);
702
728
  }
@@ -1088,6 +1114,10 @@ export function ChangeRequestDialog({
1088
1114
  )}
1089
1115
  </p>
1090
1116
 
1117
+ <div className="mx-8 mt-4 empty:hidden overflow-hidden rounded-lg">
1118
+ <GitSyncFailedBanner workspaceId={sourceWorkspaceId} />
1119
+ </div>
1120
+
1091
1121
  {error && (
1092
1122
  <Banner tone="danger" role="alert" className="mx-8 mt-4">
1093
1123
  {error}
@@ -1104,7 +1134,7 @@ export function ChangeRequestDialog({
1104
1134
  ? `${detail.lastApplyFailure.byName} could not apply this`
1105
1135
  : 'The last apply did not land'}
1106
1136
  </b>
1107
- : {detail.lastApplyFailure.reason}
1137
+ : {friendlyGitMessage(detail.lastApplyFailure.reason)}
1108
1138
  </Banner>
1109
1139
  )}
1110
1140
 
@@ -1374,7 +1404,7 @@ export function ChangeRequestDialog({
1374
1404
  ? `Your approval is needed on ${mine.length} file${mine.length === 1 ? '' : 's'}`
1375
1405
  : waitingOn.length > 0
1376
1406
  ? `Waiting on ${waitingOn.join(', ')}`
1377
- : (detail.mergeWarnings[0] ??
1407
+ : ((detail.mergeWarnings[0] && friendlyGitMessage(detail.mergeWarnings[0])) ??
1378
1408
  'Waiting on approval from the files’ owners — applying is theirs to do.')}
1379
1409
  </p>
1380
1410
  {mine.length > 1 && (
@@ -0,0 +1,151 @@
1
+ import { useEffect, useState } from 'react';
2
+ import { Link, useNavigate, useParams } from 'react-router-dom';
3
+ import type { PullRequestSummary } from '@bevel-software/platform-shared';
4
+ import { getPullRequest } from '../../git/services/pr.api';
5
+ import { GitApiError } from '../../git/services/git.api';
6
+ import { KB_ROUTE_PREFIX } from '../../workspace/routing/kb-routes';
7
+ import { ChangeRequestDialog } from './ChangeRequestDialog';
8
+
9
+ /**
10
+ * `/change-requests/<number>` — the link a person is handed for a change
11
+ * request: by `open_change_request` and the change-request read tools (the
12
+ * `url` on every summary), and by anything else that uses the backend's
13
+ * change-request-link helper. The backend has built that address since the
14
+ * link became absolute, and no route ever matched it: the shell's catch-all
15
+ * sent it to the workspace with nothing open and no word about why, so an
16
+ * agent's "here is the request" link opened nothing.
17
+ *
18
+ * What it opens is THE change-request view — {@link ChangeRequestDialog},
19
+ * the same one the explorer and the skill page open — over a quiet page, on
20
+ * the request's first changed file. Closing it, or applying the request,
21
+ * goes to the workspace: there is nothing under the dialog to go back to.
22
+ *
23
+ * A number that is not one, a request that is not there, and one the
24
+ * viewer may not see all read the same way: there is no request at this
25
+ * address for them, and which of the three it is would tell a person who
26
+ * may not see a request that it exists. Any other failure keeps its own
27
+ * message, since it is the platform's, not the link's.
28
+ */
29
+ export function ChangeRequestLink() {
30
+ const { number: raw } = useParams();
31
+ const number = changeRequestNumber(raw);
32
+ // Keyed by the number: the router reuses this element across a change of
33
+ // the parameter, and a lookup that had resolved would otherwise keep the
34
+ // previous request on screen under the new address until the new fetch
35
+ // settled. A new number is a fresh lookup from "loading".
36
+ return number === null ? (
37
+ <NoSuchRequest raw={raw ?? ''} />
38
+ ) : (
39
+ <OpenRequest key={number} number={number} />
40
+ );
41
+ }
42
+
43
+ /** The largest number a request can have: the database sequence is a 32-bit integer. */
44
+ const MAX_CHANGE_REQUEST_NUMBER = 2_147_483_647;
45
+
46
+ /** A positive integer, spelled plainly — the only thing the link helper ever puts in the path. */
47
+ function changeRequestNumber(raw: string | undefined): number | null {
48
+ if (!raw || !/^[1-9]\d*$/.test(raw)) return null;
49
+ const number = Number(raw);
50
+ return number <= MAX_CHANGE_REQUEST_NUMBER ? number : null;
51
+ }
52
+
53
+ type Lookup =
54
+ | { kind: 'loading' }
55
+ | { kind: 'open'; cr: PullRequestSummary }
56
+ | { kind: 'missing' }
57
+ | { kind: 'failed'; message: string };
58
+
59
+ function OpenRequest({ number }: { number: number }) {
60
+ const navigate = useNavigate();
61
+ const [lookup, setLookup] = useState<Lookup>({ kind: 'loading' });
62
+
63
+ useEffect(() => {
64
+ let cancelled = false;
65
+ getPullRequest(number).then(
66
+ (cr) => {
67
+ if (!cancelled) setLookup({ kind: 'open', cr });
68
+ },
69
+ (err: unknown) => {
70
+ if (cancelled) return;
71
+ // Not there. A 403 takes the same path for a deployment whose summary
72
+ // route is viewer-scoped; core's is not — every member sees the
73
+ // request list, and the FILES behind a request are what access rules
74
+ // gate, in the detail the dialog then reads — so the same sentence
75
+ // serves both and the address never says which.
76
+ const hidden = err instanceof GitApiError && (err.status === 404 || err.status === 403);
77
+ setLookup(
78
+ hidden
79
+ ? { kind: 'missing' }
80
+ : { kind: 'failed', message: err instanceof Error ? err.message : String(err) },
81
+ );
82
+ },
83
+ );
84
+ return () => {
85
+ cancelled = true;
86
+ };
87
+ }, [number]);
88
+
89
+ // `replace`: the link's entry leaves history with the view, so Back after
90
+ // closing does not land on the address again and reopen the request.
91
+ const leave = () => navigate(KB_ROUTE_PREFIX, { replace: true });
92
+
93
+ if (lookup.kind === 'missing') return <NoSuchRequest raw={String(number)} />;
94
+ if (lookup.kind === 'failed') {
95
+ return (
96
+ <Quiet>
97
+ <p>Change request #{number} could not be opened: {lookup.message}</p>
98
+ <BackToKnowledge />
99
+ </Quiet>
100
+ );
101
+ }
102
+ return (
103
+ <>
104
+ <Quiet>
105
+ <p>{lookup.kind === 'loading' ? `Opening change request #${number}…` : lookup.cr.title}</p>
106
+ <BackToKnowledge />
107
+ </Quiet>
108
+ {lookup.kind === 'open' && (
109
+ <ChangeRequestDialog cr={lookup.cr} onClose={leave} onResolved={leave} />
110
+ )}
111
+ </>
112
+ );
113
+ }
114
+
115
+ function NoSuchRequest({ raw }: { raw: string }) {
116
+ return (
117
+ <Quiet>
118
+ <p>
119
+ There is no change request {raw ? `#${raw}` : 'at this address'} — it does not exist, or
120
+ you may not see it.
121
+ </p>
122
+ <BackToKnowledge />
123
+ </Quiet>
124
+ );
125
+ }
126
+
127
+ /**
128
+ * The page under the dialog: a sentence and a way out, nothing to be read as
129
+ * content. A landmark with a heading all the same, and the sentence in a
130
+ * live region: somebody arriving by the address, or by keyboard, is told what
131
+ * page this is and hears the state change from "opening" to the request.
132
+ */
133
+ function Quiet({ children }: { children: React.ReactNode }) {
134
+ return (
135
+ <main className="flex h-full flex-col items-center justify-center gap-2 bg-white text-sm text-ink-muted">
136
+ <h1 className="text-base font-semibold text-ink">Change request</h1>
137
+ <div aria-live="polite" className="contents">
138
+ {children}
139
+ </div>
140
+ </main>
141
+ );
142
+ }
143
+
144
+ /** The way out of the quiet page. `replace`, like the dialog's exits: the link's entry leaves with the page. */
145
+ function BackToKnowledge() {
146
+ return (
147
+ <Link to={KB_ROUTE_PREFIX} replace className="underline hover:text-ink">
148
+ Back to the knowledge base
149
+ </Link>
150
+ );
151
+ }
@@ -13,6 +13,7 @@ import {
13
13
  import type { FileApprovalState, PrFileStatus } from '@bevel-software/platform-shared';
14
14
  import { cn } from '../../../lib/utils';
15
15
  import { hasOwnApproval } from '../utils/approval';
16
+ import { displayFileName } from '../../workspace/utils/display-file-name';
16
17
 
17
18
  /**
18
19
  * The change request's files as a TREE — the Knowledge sidebar's visual
@@ -205,7 +206,7 @@ function Level({
205
206
  );
206
207
  })}
207
208
  {folder.files.map((file) => {
208
- const name = file.path.slice(file.path.lastIndexOf('/') + 1);
209
+ const name = displayFileName(file.path);
209
210
  const on = selected === file.path;
210
211
  const eligible = file.changed && file.approval?.viewerCanApprove === true;
211
212
  // The viewer's own state wins the slot when there is one: approved
@@ -11,6 +11,7 @@ import { conflictResolutionPrompt } from '../utils/conflict';
11
11
  import { isBinaryFile } from '../../workspace/components/renderers';
12
12
  import { ChangeBox } from './ChangeBox';
13
13
  import { ChangeRequestDialog } from './ChangeRequestDialog';
14
+ import { displayFileName, fileNameTooltip } from '../../workspace/utils/display-file-name';
14
15
 
15
16
  export interface FileChangeBoxesProps {
16
17
  /** Repo-root-relative path of the open file (kbDirName stripped). */
@@ -105,7 +106,7 @@ export function FileChangeBoxes({
105
106
  {applied && (
106
107
  <Banner role="status" tone="ok" aria-live="polite" className="mt-3">
107
108
  <div className="flex items-center gap-2">
108
- <span className="flex-1">Applied: the file now reads with that change.</span>
109
+ <span className="flex-1">Published: the file now reads with that change.</span>
109
110
  <Button variant="quiet" size="sm" title="Dismiss" onClick={() => setApplied(false)}>
110
111
  Dismiss
111
112
  </Button>
@@ -128,7 +129,8 @@ export function FileChangeBoxes({
128
129
  return (
129
130
  <ChangeBox
130
131
  key={cr.number}
131
- file={repoRelativePath.slice(repoRelativePath.lastIndexOf('/') + 1)}
132
+ file={displayFileName(repoRelativePath)}
133
+ fileTitle={fileNameTooltip(repoRelativePath)}
132
134
  author={changeAuthorName(cr)}
133
135
  when={formatWhen(cr.createdAt)}
134
136
  mine={mine}
@@ -4,6 +4,7 @@ import { useEventBus } from '../../workflow/state/event-bus.context';
4
4
  import { fetchPrDetail } from '../../pr/services/pr-detail.api';
5
5
  import { approvePrFile } from '../../pr/services/pr-approvals.api';
6
6
  import { mergePullRequest } from '../../pr/services/pr-merge.api';
7
+ import { friendlyGitError, friendlyGitMessage } from '../../git/services/error-messages';
7
8
 
8
9
  /**
9
10
  * Safety net for the async apply: if neither a `change-request-merged` nor a
@@ -45,7 +46,9 @@ export function refusalLine(
45
46
  const own = refusals.get(cr.number);
46
47
  const persisted = cr.lastApplyFailure ?? null;
47
48
  if (own && !isLater(persisted?.at, own.at)) return own.conflicts ? null : own.reason;
48
- return persisted?.reason ?? null;
49
+ // The server stored this one as the gate said it; the reader gets it in the
50
+ // same words the dialog's banner uses.
51
+ return persisted?.reason ? friendlyGitMessage(persisted.reason) : null;
49
52
  }
50
53
 
51
54
  /** True when `a` is a strictly later instant than `b`; unknown is never later. */
@@ -165,7 +168,7 @@ export function useApplyChangeRequest(opts: {
165
168
  const offFailed = bus.subscribe('change-request-merge-failed', (e) => {
166
169
  if (runningRef.current !== e.number) return;
167
170
  fail(e.number, {
168
- reason: e.reason || "Couldn't apply this change.",
171
+ reason: e.reason ? friendlyGitMessage(e.reason) : "Couldn't apply this change.",
169
172
  conflicts: e.conflicts === true,
170
173
  at: e.at,
171
174
  });
@@ -257,7 +260,7 @@ export function useApplyChangeRequest(opts: {
257
260
  // instead of waiting for an event that will never come.
258
261
  if (runningRef.current !== cr.number) return;
259
262
  fail(cr.number, {
260
- reason: err instanceof Error ? err.message : "Couldn't apply this change.",
263
+ reason: err instanceof Error ? friendlyGitError(err) : "Couldn't apply this change.",
261
264
  conflicts: false,
262
265
  });
263
266
  }