@bevel-software/platform-core-frontend 0.25.2 → 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.
- package/package.json +2 -2
- package/src/core/CoreAppShell.tsx +87 -25
- package/src/core/ProductName.tsx +49 -0
- package/src/core/__tests__/ShellRoutes.test.tsx +22 -0
- package/src/core/__tests__/core-contributions.test.ts +16 -0
- package/src/core/core-contributions.ts +17 -0
- package/src/core/registry.ts +51 -1
- package/src/index.css +23 -5
- package/src/index.ts +5 -0
- package/src/modules/access/__tests__/ManageAccessDialog.proposal.test.tsx +1 -1
- package/src/modules/access/components/ManageAccessDialog.tsx +1 -1
- package/src/modules/admin/__tests__/RolesCorruptedBanner.test.tsx +70 -0
- package/src/modules/admin/components/RolesCorruptedBanner.tsx +9 -4
- package/src/modules/auth/components/LoginScreen.tsx +4 -1
- package/src/modules/auth/services/account.api.ts +28 -1
- package/src/modules/auth/services/sso.ts +1 -2
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.sync-banner.test.tsx +176 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.unreadable.test.tsx +68 -0
- package/src/modules/change-requests/__tests__/ChangeRequestLink.test.tsx +182 -0
- package/src/modules/change-requests/__tests__/FileChangeBoxes.test.tsx +1 -1
- package/src/modules/change-requests/__tests__/readFileOnBranch.test.ts +79 -0
- package/src/modules/change-requests/components/ChangeBox.tsx +6 -1
- package/src/modules/change-requests/components/ChangeRequestDialog.tsx +45 -15
- package/src/modules/change-requests/components/ChangeRequestLink.tsx +151 -0
- package/src/modules/change-requests/components/CrFileTree.tsx +2 -1
- package/src/modules/change-requests/components/FileChangeBoxes.tsx +4 -2
- package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +6 -3
- package/src/modules/change-requests/services/change-requests.api.ts +15 -2
- package/src/modules/change-requests/utils/readFailure.ts +22 -0
- package/src/modules/embed/__tests__/EmbedLinkPage.test.tsx +74 -0
- package/src/modules/embed/__tests__/EmbedView.test.tsx +473 -0
- package/src/modules/embed/__tests__/embed-config.test.ts +128 -0
- package/src/modules/embed/__tests__/embed-host.test.ts +111 -0
- package/src/modules/embed/__tests__/mcp-app-view.test.ts +295 -0
- package/src/modules/embed/__tests__/mount.test.tsx +157 -0
- package/src/modules/embed/components/EmbedLinkPage.tsx +109 -0
- package/src/modules/embed/components/EmbedView.tsx +545 -0
- package/src/modules/embed/embed-config.ts +132 -0
- package/src/modules/embed/embed-host.ts +120 -0
- package/src/modules/embed/mount.tsx +80 -0
- package/src/modules/embed/services/embed-token.ts +22 -0
- package/src/modules/embed/services/embed.api.ts +158 -0
- package/src/modules/git/__tests__/BranchSwitcher.test.tsx +202 -4
- package/src/modules/git/__tests__/GitSyncFailedBanner.test.tsx +59 -1
- package/src/modules/git/__tests__/PullNeededBanner.test.tsx +39 -22
- package/src/modules/git/__tests__/useAutoPullUpdates.test.tsx +7 -2
- package/src/modules/git/branch-delete-menu-item.tsx +24 -0
- package/src/modules/git/components/BranchSwitcher.tsx +29 -5
- package/src/modules/git/components/GitSyncFailedBanner.tsx +53 -15
- package/src/modules/git/components/HistoryVersionPreview.tsx +5 -3
- package/src/modules/git/components/PullNeededBanner.tsx +15 -49
- package/src/modules/git/hooks/useAutoPullUpdates.ts +9 -5
- package/src/modules/git/index.ts +15 -0
- package/src/modules/git/services/__tests__/error-messages.test.ts +67 -0
- package/src/modules/git/services/__tests__/pull-failure.test.ts +36 -0
- package/src/modules/git/services/error-messages.ts +58 -1
- package/src/modules/git/services/pull-failure.ts +68 -0
- package/src/modules/git/state/branch-delete-confirm.ts +46 -0
- package/src/modules/layout/__tests__/HeaderAlignment.test.tsx +1 -0
- package/src/modules/layout/__tests__/breakpoints.test.ts +7 -1
- package/src/modules/layout/breakpoints.ts +8 -0
- package/src/modules/library/__tests__/PluginExtras.test.tsx +9 -9
- package/src/modules/library/__tests__/PluginPage.test.tsx +8 -1
- package/src/modules/library/__tests__/SkillsTree.test.tsx +13 -4
- package/src/modules/library/__tests__/ToolPage.test.tsx +53 -0
- package/src/modules/library/components/LibraryPage.tsx +22 -0
- package/src/modules/library/components/PluginExtras.tsx +23 -6
- package/src/modules/library/components/PluginPage.tsx +6 -1
- package/src/modules/library/components/tool-page/ToolPage.tsx +45 -1
- package/src/modules/library/routes/LibraryRoutes.tsx +8 -7
- package/src/modules/library/services/plugins.api.ts +4 -1
- package/src/modules/library/services/tools.api.ts +27 -0
- package/src/modules/library/state/plugins-revision.ts +28 -0
- package/src/modules/onboarding/__tests__/agent-connection-api.test.ts +55 -0
- package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +87 -82
- package/src/modules/onboarding/__tests__/first-page-prompt.test.ts +109 -0
- package/src/modules/onboarding/__tests__/get-started-column.test.tsx +1001 -0
- package/src/modules/onboarding/__tests__/invite-dialog.test.tsx +392 -0
- package/src/modules/onboarding/__tests__/onboarding.test.tsx +226 -193
- package/src/modules/onboarding/__tests__/starter-pack-card.test.tsx +136 -0
- package/src/modules/onboarding/components/CreatorWelcomePage.tsx +7 -11
- package/src/modules/onboarding/components/EmailChipsInput.tsx +138 -0
- package/src/modules/onboarding/components/GetStartedColumn.tsx +651 -0
- package/src/modules/onboarding/components/InviteButton.tsx +35 -0
- package/src/modules/onboarding/components/InviteDialog.tsx +424 -0
- package/src/modules/onboarding/components/RootLanding.tsx +8 -24
- package/src/modules/onboarding/components/StarterPackCard.tsx +98 -0
- package/src/modules/onboarding/components/WelcomePage.tsx +65 -154
- package/src/modules/onboarding/first-page-prompt.ts +89 -0
- package/src/modules/onboarding/invite-emails.ts +175 -0
- package/src/modules/onboarding/services/agent-connection.api.ts +53 -0
- package/src/modules/onboarding/services/starter-packs.api.ts +83 -0
- package/src/modules/onboarding/state/agent-connection.ts +167 -0
- package/src/modules/onboarding/state/invite-dialog.context.ts +32 -0
- package/src/modules/onboarding/state/invite-dialog.tsx +31 -0
- package/src/modules/onboarding/state/onboarding.ts +133 -59
- package/src/modules/onboarding/state/starter-packs.ts +169 -0
- package/src/modules/settings/settings-nav-items.tsx +8 -3
- package/src/modules/setup/__tests__/setup.first-run-storage.test.tsx +389 -0
- package/src/modules/setup/__tests__/setup.github.test.tsx +5 -5
- package/src/modules/setup/__tests__/setup.kept-draft.test.tsx +1 -1
- package/src/modules/setup/__tests__/setup.repository-change.test.tsx +1 -1
- package/src/modules/setup/__tests__/setup.repository.test.tsx +21 -21
- package/src/modules/setup/__tests__/setup.test.tsx +65 -81
- package/src/modules/setup/__tests__/useConnectionProbe.test.tsx +123 -0
- package/src/modules/setup/components/FirstRunStorage.tsx +560 -0
- package/src/modules/setup/components/SetupGate.tsx +46 -1
- package/src/modules/setup/components/SetupScreen.tsx +92 -152
- package/src/modules/setup/hooks/useConnectionProbe.ts +93 -0
- package/src/modules/setup/services/setup.api.ts +3 -3
- package/src/modules/setup/utils/suggested-branch.ts +27 -0
- package/src/modules/toolbar/commands/__tests__/actions.test.tsx +210 -0
- package/src/modules/toolbar/commands/actions.tsx +324 -0
- package/src/modules/toolbar/commands/command-menu.ts +44 -0
- package/src/modules/toolbar/commands/useCommandActions.ts +69 -0
- package/src/modules/toolbar/commands/useCommandShortcuts.ts +121 -0
- package/src/modules/toolbar/components/AppSwitcher.tsx +106 -22
- package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +1 -1
- package/src/modules/toolbar/components/ProfileMenu.tsx +9 -4
- package/src/modules/toolbar/components/SearchPalette.tsx +540 -0
- package/src/modules/toolbar/components/Toolbar.tsx +10 -0
- package/src/modules/toolbar/components/__tests__/AppSwitcher.test.tsx +187 -54
- package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +4 -4
- package/src/modules/toolbar/components/__tests__/ProfileMenu.test.tsx +64 -0
- package/src/modules/toolbar/components/__tests__/SearchPalette.test.tsx +832 -0
- package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +57 -2
- package/src/modules/toolbar/search/__tests__/rank.test.ts +93 -0
- package/src/modules/toolbar/search/__tests__/sources.test.ts +131 -0
- package/src/modules/toolbar/search/rank.ts +111 -0
- package/src/modules/toolbar/search/sources.ts +169 -0
- package/src/modules/workflow/hooks/useFileLock.ts +10 -7
- package/src/modules/workflow/services/__tests__/lock.api.test.ts +41 -0
- package/src/modules/workflow/services/lock.api.ts +17 -2
- package/src/modules/workspace/__tests__/useWorkspaceState.test.ts +49 -1
- package/src/modules/workspace/components/EditorTabs.tsx +39 -15
- package/src/modules/workspace/components/FileExplorer.tsx +39 -6
- package/src/modules/workspace/components/FilePaneCard.tsx +6 -2
- package/src/modules/workspace/components/FileRoute.tsx +12 -7
- package/src/modules/workspace/components/FileViewer.tsx +271 -74
- package/src/modules/workspace/components/KbPageHeader.tsx +13 -6
- package/src/modules/workspace/components/__tests__/EditorTabs.test.tsx +88 -21
- package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +101 -11
- package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +23 -3
- package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +330 -6
- package/src/modules/workspace/components/__tests__/KbPageHeader.test.tsx +17 -2
- package/src/modules/workspace/components/renderers/DocxRenderer.tsx +11 -16
- package/src/modules/workspace/components/renderers/DownloadFileButton.tsx +6 -0
- package/src/modules/workspace/components/renderers/EmailRenderer.tsx +23 -21
- package/src/modules/workspace/components/renderers/ImageRenderer.tsx +13 -29
- package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +9 -2
- package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +8 -0
- package/src/modules/workspace/components/renderers/PdfRenderer.tsx +14 -19
- package/src/modules/workspace/components/renderers/PptxRenderer.tsx +11 -17
- package/src/modules/workspace/components/renderers/ToolRenderer.tsx +35 -7
- package/src/modules/workspace/components/renderers/XlsxRenderer.tsx +11 -17
- package/src/modules/workspace/components/renderers/__tests__/EmailRenderer.links.test.tsx +73 -0
- package/src/modules/workspace/components/renderers/__tests__/ToolRenderer.scaffold.test.tsx +64 -0
- package/src/modules/workspace/components/renderers/__tests__/ToolRenderer.surface.test.tsx +82 -0
- package/src/modules/workspace/components/renderers/__tests__/bridgeHarness.ts +99 -0
- package/src/modules/workspace/components/renderers/__tests__/htmlSandbox.test.ts +129 -35
- package/src/modules/workspace/components/renderers/__tests__/htmlViewsGuide.test.ts +149 -0
- package/src/modules/workspace/components/renderers/__tests__/kbMarkdownLinkPolicy.test.tsx +100 -0
- package/src/modules/workspace/components/renderers/htmlSandbox.ts +76 -20
- package/src/modules/workspace/components/renderers/index.ts +26 -0
- package/src/modules/workspace/components/renderers/kbMarkdownPipeline.tsx +51 -1
- package/src/modules/workspace/components/renderers/rendererRawRead.ts +53 -0
- package/src/modules/workspace/components/renderers/rendererSurface.ts +109 -0
- package/src/modules/workspace/components/renderers/rendererWorkspace.ts +8 -2
- package/src/modules/workspace/hooks/__tests__/useWorkspaceState.test.tsx +126 -21
- package/src/modules/workspace/hooks/useCreatePage.ts +116 -0
- package/src/modules/workspace/hooks/useWorkspaceImageResolver.ts +24 -7
- package/src/modules/workspace/hooks/useWorkspaceState.ts +42 -8
- package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +10 -0
- package/src/modules/workspace/routing/__tests__/md-links-parity.test.tsx +113 -0
- package/src/modules/workspace/routing/kb-routes.ts +66 -12
- package/src/modules/workspace/state/editable-page.ts +42 -0
- package/src/modules/workspace/state/workspace.context.ts +13 -4
- package/src/modules/workspace/utils/__tests__/display-file-name.test.ts +60 -0
- package/src/modules/workspace/utils/__tests__/fileTree.test.ts +75 -0
- package/src/modules/workspace/utils/__tests__/treeConfirm.test.ts +26 -14
- package/src/modules/workspace/utils/display-file-name.ts +102 -0
- package/src/modules/workspace/utils/fileTree.ts +49 -14
- package/src/modules/workspace/utils/treeConfirm.ts +22 -5
- package/src/shared/__tests__/no-builtin-confirm.test.ts +102 -0
- package/src/shared/components/ConfirmProvider.tsx +156 -0
- package/src/shared/components/Dialog.tsx +7 -0
- package/src/shared/components/__tests__/ConfirmProvider.test.tsx +198 -0
- package/src/shared/components/confirm-context.ts +94 -0
- package/src/shared/components/index.ts +3 -0
- package/src/shared/mcp/__tests__/connect-snippets.test.ts +2 -2
- package/src/shared/mcp/connect-snippets.ts +8 -5
- package/src/modules/onboarding/components/WelcomeRoute.tsx +0 -57
- package/src/modules/onboarding/welcome-state.ts +0 -36
|
@@ -92,6 +92,8 @@ describe('GitSyncFailedBanner', () => {
|
|
|
92
92
|
expect(alert.textContent).toContain('saved here');
|
|
93
93
|
expect(alert.textContent).toContain('server logs');
|
|
94
94
|
expect(alert.textContent).toContain('feat/x');
|
|
95
|
+
expect(alert.textContent).toContain('aren’t reaching your git host');
|
|
96
|
+
expect(alert.textContent).not.toMatch(/remote repository/i);
|
|
95
97
|
});
|
|
96
98
|
|
|
97
99
|
it('shows the sanitised git reason as the detail line', () => {
|
|
@@ -204,8 +206,12 @@ describe('GitSyncFailedBanner — remote-sync conflict', () => {
|
|
|
204
206
|
bus.emit(CONFLICT);
|
|
205
207
|
const alert = screen.getByRole('alert');
|
|
206
208
|
// This one IS the author's to act on — no "check the server logs".
|
|
207
|
-
expect(alert.textContent).toContain('changed both here and
|
|
209
|
+
expect(alert.textContent).toContain('changed both here and on your git host');
|
|
208
210
|
expect(alert.textContent).not.toContain('server logs');
|
|
211
|
+
// Plain words: no branch name, no "in sync", no "reconcile".
|
|
212
|
+
expect(alert.textContent).not.toContain('feat/x');
|
|
213
|
+
expect(alert.textContent).not.toMatch(/\bsync|reconcile|repository/i);
|
|
214
|
+
expect(alert.textContent).toContain('open each one, keep the content you want');
|
|
209
215
|
expect(screen.getByRole('button', { name: 'Plugins/x/SKILL.md' })).toBeTruthy();
|
|
210
216
|
expect(screen.getByRole('button', { name: 'Docs/a.md' })).toBeTruthy();
|
|
211
217
|
});
|
|
@@ -243,3 +249,55 @@ describe('GitSyncFailedBanner — a conflict that arrives before the workspace h
|
|
|
243
249
|
expect(screen.queryByRole('button', { name: 'Docs/a.md' })).toBeNull();
|
|
244
250
|
});
|
|
245
251
|
});
|
|
252
|
+
|
|
253
|
+
describe('GitSyncFailedBanner — for a named workspace (the change-request view)', () => {
|
|
254
|
+
function renderFor(workspaceId: string, focused: Partial<WorkspaceContextValue> | null) {
|
|
255
|
+
const bus = makeBus();
|
|
256
|
+
const banner = <GitSyncFailedBanner workspaceId={workspaceId} />;
|
|
257
|
+
render(
|
|
258
|
+
<EventBusContext.Provider value={bus.ctx}>
|
|
259
|
+
{focused ? (
|
|
260
|
+
<WorkspaceContext.Provider value={makeWorkspaceFixture(focused)}>{banner}</WorkspaceContext.Provider>
|
|
261
|
+
) : (
|
|
262
|
+
banner
|
|
263
|
+
)}
|
|
264
|
+
</EventBusContext.Provider>,
|
|
265
|
+
);
|
|
266
|
+
return bus;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
it('follows the named workspace, not the focused one', () => {
|
|
270
|
+
const bus = renderFor('ali%2Fx', { workspaceId: 'main' });
|
|
271
|
+
bus.emit({ ...FAILED, workspaceId: 'main', branch: 'main' });
|
|
272
|
+
expect(screen.queryByRole('alert')).toBeNull();
|
|
273
|
+
bus.emit({ ...FAILED, workspaceId: 'ali/x', branch: 'ali/x' });
|
|
274
|
+
expect(screen.getByRole('alert').textContent).toContain('ali/x');
|
|
275
|
+
bus.emit({ kind: 'git-sync-recovered', workspaceId: 'ali/x', branch: 'ali/x' });
|
|
276
|
+
expect(screen.queryByRole('alert')).toBeNull();
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
it('needs no workspace context at all', () => {
|
|
280
|
+
const bus = renderFor('ali%2Fx', null);
|
|
281
|
+
bus.emit({ ...FAILED, workspaceId: 'ali/x', branch: 'ali/x' });
|
|
282
|
+
expect(screen.getByRole('alert')).toBeInTheDocument();
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
it("lists another branch's conflicted files as text — a link would open the focused branch's copy", () => {
|
|
286
|
+
const bus = renderFor('ali%2Fx', { workspaceId: 'main', kbDirName: 'knowledge-base' });
|
|
287
|
+
const conflict = {
|
|
288
|
+
kind: 'git-sync-failed',
|
|
289
|
+
workspaceId: 'ali/x',
|
|
290
|
+
branch: 'ali/x',
|
|
291
|
+
reason: 'conflict',
|
|
292
|
+
conflictedPaths: ['Docs/a.md'],
|
|
293
|
+
};
|
|
294
|
+
bus.emit(conflict);
|
|
295
|
+
expect(screen.getByText('Docs/a.md').tagName).toBe('SPAN');
|
|
296
|
+
expect(screen.queryByRole('button', { name: 'Docs/a.md' })).toBeNull();
|
|
297
|
+
// Nothing here opens, so the copy sends the person to the branch first —
|
|
298
|
+
// named, since it is not the one on screen.
|
|
299
|
+
const text = screen.getByRole('alert').textContent ?? '';
|
|
300
|
+
expect(text).toContain('switch to ali/x, open each one there');
|
|
301
|
+
expect(text).not.toContain('open each one, keep');
|
|
302
|
+
});
|
|
303
|
+
});
|
|
@@ -152,14 +152,14 @@ describe('PullNeededBanner: gating', () => {
|
|
|
152
152
|
expect(container.firstChild).toBeNull();
|
|
153
153
|
});
|
|
154
154
|
|
|
155
|
-
it('shows failed auto-update state with
|
|
155
|
+
it('shows failed auto-update state with Update', () => {
|
|
156
156
|
renderWith(makeGit({ status: makeStatus({ branch: 'current-company-state' }) }), {
|
|
157
157
|
autoUpdate: failedAutoUpdate(),
|
|
158
158
|
});
|
|
159
159
|
|
|
160
|
-
expect(screen.getByText(
|
|
160
|
+
expect(screen.getByText('Couldn’t get the latest changes')).toBeInTheDocument();
|
|
161
161
|
expect(screen.getByText('Network unreachable')).toBeInTheDocument();
|
|
162
|
-
expect(screen.getByRole('button', { name: '
|
|
162
|
+
expect(screen.getByRole('button', { name: 'Update' })).toBeEnabled();
|
|
163
163
|
});
|
|
164
164
|
|
|
165
165
|
// Removed: "shows passive guidance for dirty protected branches without a
|
|
@@ -174,9 +174,13 @@ describe('PullNeededBanner: gating', () => {
|
|
|
174
174
|
workspace: makeWorkspace({ hasUnsavedFileChanges: true }),
|
|
175
175
|
});
|
|
176
176
|
|
|
177
|
-
expect(screen.getByText(
|
|
178
|
-
expect(screen.getByText(
|
|
177
|
+
expect(screen.getByText('New changes available')).toBeInTheDocument();
|
|
178
|
+
expect(screen.getByText('Save your open page to get them.')).toBeInTheDocument();
|
|
179
179
|
expect(screen.queryByRole('button')).toBeNull();
|
|
180
|
+
// Plain words only: no branch name, no pull or sync.
|
|
181
|
+
const banner = screen.getByRole('status');
|
|
182
|
+
expect(banner.textContent).not.toContain('current-company-state');
|
|
183
|
+
expect(banner.textContent).not.toMatch(/\b(pull|sync|fetch|merge)/i);
|
|
180
184
|
});
|
|
181
185
|
});
|
|
182
186
|
|
|
@@ -188,7 +192,7 @@ describe('PullNeededBanner: protected branch (auto-update failed retry)', () =>
|
|
|
188
192
|
{ autoUpdate: failedAutoUpdate() },
|
|
189
193
|
);
|
|
190
194
|
|
|
191
|
-
fireEvent.click(screen.getByRole('button', { name: '
|
|
195
|
+
fireEvent.click(screen.getByRole('button', { name: 'Update' }));
|
|
192
196
|
|
|
193
197
|
await waitFor(() => expect(pull).toHaveBeenCalledTimes(1));
|
|
194
198
|
expect(resolvePullIssue).not.toHaveBeenCalled();
|
|
@@ -200,7 +204,7 @@ describe('PullNeededBanner: protected branch (auto-update failed retry)', () =>
|
|
|
200
204
|
autoUpdate: failedAutoUpdate('target-company-state'),
|
|
201
205
|
});
|
|
202
206
|
|
|
203
|
-
fireEvent.click(screen.getByRole('button', { name: '
|
|
207
|
+
fireEvent.click(screen.getByRole('button', { name: 'Update' }));
|
|
204
208
|
|
|
205
209
|
await waitFor(() => expect(pull).toHaveBeenCalledTimes(1));
|
|
206
210
|
});
|
|
@@ -217,15 +221,15 @@ describe('PullNeededBanner: protected branch (auto-update failed retry)', () =>
|
|
|
217
221
|
autoUpdate: failedAutoUpdate(),
|
|
218
222
|
});
|
|
219
223
|
|
|
220
|
-
fireEvent.click(screen.getByRole('button', { name: '
|
|
224
|
+
fireEvent.click(screen.getByRole('button', { name: 'Update' }));
|
|
221
225
|
|
|
222
226
|
await waitFor(() =>
|
|
223
|
-
expect(screen.getByRole('button', { name: '
|
|
227
|
+
expect(screen.getByRole('button', { name: 'Updating…' })).toBeDisabled(),
|
|
224
228
|
);
|
|
225
229
|
|
|
226
230
|
resolvePull();
|
|
227
231
|
await waitFor(() =>
|
|
228
|
-
expect(screen.getByRole('button', { name: '
|
|
232
|
+
expect(screen.getByRole('button', { name: 'Update' })).toBeEnabled(),
|
|
229
233
|
);
|
|
230
234
|
});
|
|
231
235
|
|
|
@@ -237,12 +241,17 @@ describe('PullNeededBanner: protected branch (auto-update failed retry)', () =>
|
|
|
237
241
|
autoUpdate: failedAutoUpdate(),
|
|
238
242
|
});
|
|
239
243
|
|
|
240
|
-
fireEvent.click(screen.getByRole('button', { name: '
|
|
244
|
+
fireEvent.click(screen.getByRole('button', { name: 'Update' }));
|
|
241
245
|
|
|
246
|
+
// In plain words, sorted by what kind of failure it was: never git's own
|
|
247
|
+
// sentence, scrubbed or not.
|
|
242
248
|
await waitFor(() =>
|
|
243
|
-
expect(screen.getByRole('alert')).toHaveTextContent(
|
|
249
|
+
expect(screen.getByRole('alert')).toHaveTextContent(
|
|
250
|
+
'Couldn’t get the latest changes. Your git host couldn’t be reached',
|
|
251
|
+
),
|
|
244
252
|
);
|
|
245
|
-
expect(screen.getByRole('
|
|
253
|
+
expect(screen.getByRole('alert').textContent).not.toContain('Network unreachable');
|
|
254
|
+
expect(screen.getByRole('button', { name: 'Update' })).toBeEnabled();
|
|
246
255
|
});
|
|
247
256
|
|
|
248
257
|
it('falls back to handing the failure to the change-request port when direct pull fails', async () => {
|
|
@@ -255,7 +264,7 @@ describe('PullNeededBanner: protected branch (auto-update failed retry)', () =>
|
|
|
255
264
|
{ autoUpdate: failedAutoUpdate(), resolvePullIssue },
|
|
256
265
|
);
|
|
257
266
|
|
|
258
|
-
fireEvent.click(screen.getByRole('button', { name: '
|
|
267
|
+
fireEvent.click(screen.getByRole('button', { name: 'Update' }));
|
|
259
268
|
|
|
260
269
|
await waitFor(() => expect(resolvePullIssue).toHaveBeenCalledTimes(1));
|
|
261
270
|
// The classified reason handed to the port must NOT leak git vocabulary
|
|
@@ -286,7 +295,7 @@ describe('PullNeededBanner: protected branch (auto-update failed retry)', () =>
|
|
|
286
295
|
{ autoUpdate: failedAutoUpdate(), resolvePullIssue },
|
|
287
296
|
);
|
|
288
297
|
|
|
289
|
-
fireEvent.click(screen.getByRole('button', { name: '
|
|
298
|
+
fireEvent.click(screen.getByRole('button', { name: 'Update' }));
|
|
290
299
|
|
|
291
300
|
await waitFor(() => expect(resolvePullIssue).toHaveBeenCalledTimes(1));
|
|
292
301
|
const reason = (resolvePullIssue.mock.calls[0][0] as { reason: string }).reason;
|
|
@@ -307,10 +316,10 @@ describe('PullNeededBanner: protected branch (auto-update failed retry)', () =>
|
|
|
307
316
|
autoUpdate: failedAutoUpdate(),
|
|
308
317
|
});
|
|
309
318
|
|
|
310
|
-
fireEvent.click(screen.getByRole('button', { name: '
|
|
319
|
+
fireEvent.click(screen.getByRole('button', { name: 'Update' }));
|
|
311
320
|
|
|
312
321
|
await waitFor(() =>
|
|
313
|
-
expect(screen.getByRole('alert')).toHaveTextContent(/
|
|
322
|
+
expect(screen.getByRole('alert')).toHaveTextContent(/Couldn’t get the latest changes/),
|
|
314
323
|
);
|
|
315
324
|
});
|
|
316
325
|
|
|
@@ -323,11 +332,11 @@ describe('PullNeededBanner: protected branch (auto-update failed retry)', () =>
|
|
|
323
332
|
autoUpdate: failedAutoUpdate(),
|
|
324
333
|
});
|
|
325
334
|
|
|
326
|
-
fireEvent.click(screen.getByRole('button', { name: '
|
|
335
|
+
fireEvent.click(screen.getByRole('button', { name: 'Update' }));
|
|
327
336
|
await waitFor(() => expect(screen.getByRole('alert')).toBeInTheDocument());
|
|
328
337
|
|
|
329
338
|
shouldFail = false;
|
|
330
|
-
fireEvent.click(screen.getByRole('button', { name: '
|
|
339
|
+
fireEvent.click(screen.getByRole('button', { name: 'Update' }));
|
|
331
340
|
await waitFor(() => expect(screen.queryByRole('alert')).not.toBeInTheDocument());
|
|
332
341
|
expect(pull).toHaveBeenCalledTimes(2);
|
|
333
342
|
});
|
|
@@ -351,7 +360,7 @@ describe('PullNeededBanner: workspace refresh after successful pull', () => {
|
|
|
351
360
|
workspace,
|
|
352
361
|
});
|
|
353
362
|
|
|
354
|
-
fireEvent.click(screen.getByRole('button', { name: '
|
|
363
|
+
fireEvent.click(screen.getByRole('button', { name: 'Update' }));
|
|
355
364
|
|
|
356
365
|
await waitFor(() => expect(workspace.refreshFileTree).toHaveBeenCalledTimes(1));
|
|
357
366
|
await waitFor(() => expect(workspace.bumpFsRevision).toHaveBeenCalledTimes(1));
|
|
@@ -366,7 +375,7 @@ describe('PullNeededBanner: workspace refresh after successful pull', () => {
|
|
|
366
375
|
autoUpdate: failedAutoUpdate(),
|
|
367
376
|
});
|
|
368
377
|
|
|
369
|
-
fireEvent.click(screen.getByRole('button', { name: '
|
|
378
|
+
fireEvent.click(screen.getByRole('button', { name: 'Update' }));
|
|
370
379
|
|
|
371
380
|
await waitFor(() => expect(onPrStale).toHaveBeenCalledTimes(1));
|
|
372
381
|
} finally {
|
|
@@ -387,7 +396,7 @@ describe('PullNeededBanner: workspace refresh after successful pull', () => {
|
|
|
387
396
|
workspace,
|
|
388
397
|
});
|
|
389
398
|
|
|
390
|
-
fireEvent.click(screen.getByRole('button', { name: '
|
|
399
|
+
fireEvent.click(screen.getByRole('button', { name: 'Update' }));
|
|
391
400
|
|
|
392
401
|
await waitFor(() => expect(screen.getByRole('alert')).toBeInTheDocument());
|
|
393
402
|
expect(workspace.refreshFileTree).not.toHaveBeenCalled();
|
|
@@ -431,6 +440,14 @@ describe('PullNeededBanner: feature branch (agent flow, REGRESSION)', () => {
|
|
|
431
440
|
}
|
|
432
441
|
});
|
|
433
442
|
|
|
443
|
+
it('announces the new changes in plain words on a draft', () => {
|
|
444
|
+
renderWith(makeGit({ status: makeStatus({ branch: 'alice/draft' }) }));
|
|
445
|
+
|
|
446
|
+
expect(screen.getByText('New changes available')).toBeInTheDocument();
|
|
447
|
+
expect(screen.getByText('Your draft doesn’t have them yet.')).toBeInTheDocument();
|
|
448
|
+
expect(screen.getByRole('status').textContent).not.toContain('alice/draft');
|
|
449
|
+
});
|
|
450
|
+
|
|
434
451
|
it('invokes the port for any non-protected branch name', () => {
|
|
435
452
|
const { resolvePullIssue } = renderWith(makeGit({ status: makeStatus({ branch: 'main' }) }));
|
|
436
453
|
|
|
@@ -129,7 +129,7 @@ describe('useAutoPullUpdates', () => {
|
|
|
129
129
|
await waitFor(() => expect(result.current.status).toBe('idle'));
|
|
130
130
|
});
|
|
131
131
|
|
|
132
|
-
it('exposes failed state with
|
|
132
|
+
it('exposes failed state with a plain-words reason when automatic pull fails', async () => {
|
|
133
133
|
const pull = vi.fn(async () => {
|
|
134
134
|
throw new Error(
|
|
135
135
|
'fatal: could not resolve host https://ghp_supersecrettoken1234567890abcdef@example.com/org/repo in /Users/alice/work/bevel token=ghp_supersecrettoken1234567890abcdef',
|
|
@@ -142,7 +142,12 @@ describe('useAutoPullUpdates', () => {
|
|
|
142
142
|
|
|
143
143
|
await waitFor(() => expect(result.current.status).toBe('failed'));
|
|
144
144
|
expect(result.current.branch).toBe('current-company-state');
|
|
145
|
-
|
|
145
|
+
// The reason is what the kind of failure means to a reader, not the
|
|
146
|
+
// error's own text scrubbed: nothing of the error reaches it at all.
|
|
147
|
+
expect(result.current.reason).toBe(
|
|
148
|
+
'Your git host couldn’t be reached, or refused this deployment. Check the connection and the repository access.',
|
|
149
|
+
);
|
|
150
|
+
expect(result.current.reason).not.toMatch(/fatal|resolve host|\[url\]/);
|
|
146
151
|
expect(result.current.reason).not.toContain('https://');
|
|
147
152
|
expect(result.current.reason).not.toContain('/Users/alice/work/bevel');
|
|
148
153
|
expect(result.current.reason).not.toContain('ghp_supersecrettoken');
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { GitBranch } from 'lucide-react';
|
|
2
|
+
import type { AdminMenuItem } from '../../core/registry';
|
|
3
|
+
import {
|
|
4
|
+
askBeforeBranchDelete,
|
|
5
|
+
isBranchDeleteConfirmSkipped,
|
|
6
|
+
} from './state/branch-delete-confirm';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The way back from the branch delete's "Don't ask again": a profile-menu row
|
|
10
|
+
* that is there exactly while this person's question is off in this browser.
|
|
11
|
+
* Git owns the preference, so git owns the row; the menu only renders it.
|
|
12
|
+
*/
|
|
13
|
+
export const BRANCH_DELETE_CONFIRM_MENU_ITEM: AdminMenuItem = {
|
|
14
|
+
id: 'ask-before-branch-delete',
|
|
15
|
+
// After Account (90): it undoes a choice rather than going somewhere.
|
|
16
|
+
order: 95,
|
|
17
|
+
icon: <GitBranch size={15} />,
|
|
18
|
+
label: 'Ask before deleting branches',
|
|
19
|
+
isShown: (user) => isBranchDeleteConfirmSkipped(user.email),
|
|
20
|
+
onSelect: ({ user, closeMenu }) => {
|
|
21
|
+
askBeforeBranchDelete(user.email);
|
|
22
|
+
closeMenu();
|
|
23
|
+
},
|
|
24
|
+
};
|
|
@@ -10,6 +10,8 @@ import {
|
|
|
10
10
|
DEFAULT_BRANCH,
|
|
11
11
|
} from '@bevel-software/platform-shared';
|
|
12
12
|
import { useGit } from '../state/git.context';
|
|
13
|
+
import { isBranchDeleteConfirmSkipped, skipBranchDeleteConfirm } from '../state/branch-delete-confirm';
|
|
14
|
+
import { useConfirm } from '../../../shared/components';
|
|
13
15
|
import { parseGitError, type GitErrorInfo } from '../services/error-messages';
|
|
14
16
|
import { useAuth } from '../../auth/state/auth.context';
|
|
15
17
|
import { useWorkspace } from '../../workspace/state/workspace.context';
|
|
@@ -143,10 +145,16 @@ export function BranchSwitcher() {
|
|
|
143
145
|
// descendant of `ref`. The click-outside handler needs this second ref to
|
|
144
146
|
// tell a click inside the panel from a click away from it.
|
|
145
147
|
const panelRef = useRef<HTMLDivElement>(null);
|
|
148
|
+
const confirm = useConfirm();
|
|
149
|
+
// True while the delete question is open. The dialog sits outside both refs,
|
|
150
|
+
// so without this its own clicks would read as "outside" and close the list
|
|
151
|
+
// — taking a failed deletion's error with it.
|
|
152
|
+
const askingRef = useRef(false);
|
|
146
153
|
|
|
147
154
|
useEffect(() => {
|
|
148
155
|
if (!open) return;
|
|
149
156
|
const handler = (e: MouseEvent) => {
|
|
157
|
+
if (askingRef.current) return;
|
|
150
158
|
const target = e.target as Node;
|
|
151
159
|
// The panel is portaled out of `ref`, so a click inside it would
|
|
152
160
|
// otherwise read as "outside" and close the menu on the first mousedown.
|
|
@@ -214,11 +222,27 @@ export function BranchSwitcher() {
|
|
|
214
222
|
// confirm needed), or (2) it's a draft authored by the current user
|
|
215
223
|
// who wants to discard it. Case 2 is destructive for the whole team
|
|
216
224
|
// (the remote ref goes away for everyone), so confirm explicitly.
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
225
|
+
//
|
|
226
|
+
// Asked in the app's own dialog: the browser's can be silenced by the
|
|
227
|
+
// browser, and a silenced one answered "no" to every delete without a
|
|
228
|
+
// word. "Don't ask again" really skips the question afterwards — per
|
|
229
|
+
// person, in this browser, until turned back on in the profile menu.
|
|
230
|
+
if (hasRemote && !isBranchDeleteConfirmSkipped(user?.email)) {
|
|
231
|
+
askingRef.current = true;
|
|
232
|
+
let answer;
|
|
233
|
+
try {
|
|
234
|
+
answer = await confirm({
|
|
235
|
+
title: 'Delete shared draft',
|
|
236
|
+
message: `Delete shared draft "${name}"? This removes it from the remote for everyone.`,
|
|
237
|
+
confirmLabel: 'Delete',
|
|
238
|
+
destructive: true,
|
|
239
|
+
offerDontAskAgain: true,
|
|
240
|
+
});
|
|
241
|
+
} finally {
|
|
242
|
+
askingRef.current = false;
|
|
243
|
+
}
|
|
244
|
+
if (!answer.confirmed) return;
|
|
245
|
+
if (answer.dontAskAgain) skipBranchDeleteConfirm(user?.email);
|
|
222
246
|
}
|
|
223
247
|
try {
|
|
224
248
|
await git.deleteBranch(name);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { useCallback, useState } from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import { useCallback, useContext, useState } from 'react';
|
|
2
|
+
import { AlertTriangle, CloudOff } from 'lucide-react';
|
|
3
3
|
import { useEventBusSubscription } from '../../workflow/hooks/useEventBusSubscription';
|
|
4
4
|
import { canonicalizeWorkspaceId } from '../../workflow/state/event-bus.context';
|
|
5
|
-
import { useWorkspace } from '../../workspace/state/workspace.context';
|
|
5
|
+
import { useWorkspace, WorkspaceContext } from '../../workspace/state/workspace.context';
|
|
6
6
|
import { useFileNav } from '../../workspace/routing/kb-routes';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -39,6 +39,23 @@ function ConflictFiles({ paths }: { paths: string[] }) {
|
|
|
39
39
|
);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
/**
|
|
43
|
+
* The same files as text. For a banner about a branch other than the one in
|
|
44
|
+
* the address bar: a link opens the path in the CURRENT workspace, which
|
|
45
|
+
* would be the wrong branch's copy.
|
|
46
|
+
*/
|
|
47
|
+
function ConflictFileNames({ paths }: { paths: string[] }) {
|
|
48
|
+
return (
|
|
49
|
+
<ul className="mt-1 ml-5 flex flex-wrap gap-x-3 gap-y-0.5">
|
|
50
|
+
{paths.map((p) => (
|
|
51
|
+
<li key={p}>
|
|
52
|
+
<span className="font-mono">{p}</span>
|
|
53
|
+
</li>
|
|
54
|
+
))}
|
|
55
|
+
</ul>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
42
59
|
/**
|
|
43
60
|
* Shown when a commit landed locally but could not be pushed to the remote.
|
|
44
61
|
*
|
|
@@ -61,10 +78,17 @@ function ConflictFiles({ paths }: { paths: string[] }) {
|
|
|
61
78
|
* succeeds after failing. No dismiss control, same as `PullNeededBanner`: the
|
|
62
79
|
* condition is real until the server says otherwise, and the next failing save
|
|
63
80
|
* would re-raise it anyway.
|
|
81
|
+
*
|
|
82
|
+
* `workspaceId` names the branch's workspace when the surface is about a
|
|
83
|
+
* branch other than the focused one — the change-request view shows its
|
|
84
|
+
* SOURCE branch's banner, and watches that workspace so its events arrive.
|
|
85
|
+
* Without it the banner follows the workspace in the address bar.
|
|
64
86
|
*/
|
|
65
|
-
export function GitSyncFailedBanner() {
|
|
66
|
-
|
|
67
|
-
|
|
87
|
+
export function GitSyncFailedBanner({ workspaceId: forWorkspaceId }: { workspaceId?: string } = {}) {
|
|
88
|
+
// Optional context: the change-request view can be mounted (and tested)
|
|
89
|
+
// outside a workspace, and names its workspace itself.
|
|
90
|
+
const focusedId = useContext(WorkspaceContext)?.workspaceId ?? null;
|
|
91
|
+
const workspaceId = forWorkspaceId ?? focusedId;
|
|
68
92
|
// Local state (`workspace.id`) is URL-encoded (`user%2Ffeat`); event ids
|
|
69
93
|
// arrive URL-decoded (`user/feat`, Express auto-decodes `req.params.id`).
|
|
70
94
|
// Comparing them raw drops every event on a slashed feature branch — the
|
|
@@ -131,21 +155,36 @@ export function GitSyncFailedBanner() {
|
|
|
131
155
|
// recovery is already running; if it does not clear, the person decides.
|
|
132
156
|
// Different copy, and the files themselves, each a link.
|
|
133
157
|
if (failure.conflictedPaths && failure.conflictedPaths.length > 0) {
|
|
158
|
+
// Shown for a branch other than the one in view (the change-request
|
|
159
|
+
// dialog's source branch), the files are names, not links — they open in
|
|
160
|
+
// that branch's workspace, so the copy says to go there first.
|
|
161
|
+
const elsewhere =
|
|
162
|
+
Boolean(forWorkspaceId) && (!focusedId || canonicalizeWorkspaceId(focusedId) !== canonId);
|
|
134
163
|
return (
|
|
135
164
|
<div
|
|
136
165
|
role="alert"
|
|
137
166
|
className="px-3 py-1.5 bg-sunken border-b border-line text-xs text-ink shrink-0"
|
|
138
167
|
>
|
|
139
168
|
<div className="flex items-center gap-2">
|
|
140
|
-
<
|
|
169
|
+
<AlertTriangle size={13} className="shrink-0" />
|
|
141
170
|
<span className="flex-1">
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
171
|
+
These pages were changed both here and on your git host. Hexis is trying to combine
|
|
172
|
+
them. If this notice stays,{' '}
|
|
173
|
+
{elsewhere ? (
|
|
174
|
+
<>
|
|
175
|
+
switch to <span className="font-mono font-semibold">{failure.branch}</span>, open each one
|
|
176
|
+
there, keep the content you want, and save.
|
|
177
|
+
</>
|
|
178
|
+
) : (
|
|
179
|
+
'open each one, keep the content you want, and save.'
|
|
180
|
+
)}
|
|
146
181
|
</span>
|
|
147
182
|
</div>
|
|
148
|
-
|
|
183
|
+
{elsewhere ? (
|
|
184
|
+
<ConflictFileNames paths={failure.conflictedPaths} />
|
|
185
|
+
) : (
|
|
186
|
+
<ConflictFiles paths={failure.conflictedPaths} />
|
|
187
|
+
)}
|
|
149
188
|
</div>
|
|
150
189
|
);
|
|
151
190
|
}
|
|
@@ -158,9 +197,8 @@ export function GitSyncFailedBanner() {
|
|
|
158
197
|
<div className="flex items-center gap-2">
|
|
159
198
|
<CloudOff size={13} className="shrink-0" />
|
|
160
199
|
<span className="flex-1">
|
|
161
|
-
Changes on <span className="font-mono font-semibold">{failure.branch}</span>
|
|
162
|
-
|
|
163
|
-
the server logs.
|
|
200
|
+
Changes on <span className="font-mono font-semibold">{failure.branch}</span> are saved
|
|
201
|
+
here but aren’t reaching your git host. An administrator should check the server logs.
|
|
164
202
|
</span>
|
|
165
203
|
</div>
|
|
166
204
|
<div className="mt-1 ml-5 text-ink-muted break-words">{failure.reason}</div>
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
type RendererFileRef,
|
|
24
24
|
} from '../../workspace/components/renderers';
|
|
25
25
|
import { useWorkspace } from '../../workspace/state/workspace.context';
|
|
26
|
+
import { displayFileName, fileNameTooltip } from '../../workspace/utils/display-file-name';
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
29
|
* One past save of a file, shown the way the FILE PAGE shows that file.
|
|
@@ -165,7 +166,7 @@ export interface HistoryVersionPreviewProps {
|
|
|
165
166
|
|
|
166
167
|
export function HistoryVersionPreview({ filePath, commit }: HistoryVersionPreviewProps) {
|
|
167
168
|
const { fetchFileDiff, fetchFileAtChange, status } = useGit();
|
|
168
|
-
const { workspaceId } = useWorkspace();
|
|
169
|
+
const { workspaceId, kbDirName } = useWorkspace();
|
|
169
170
|
const ext = extensionOf(filePath);
|
|
170
171
|
|
|
171
172
|
/**
|
|
@@ -257,7 +258,6 @@ export function HistoryVersionPreview({ filePath, commit }: HistoryVersionPrevie
|
|
|
257
258
|
const retry = useCallback(() => setAttempt((n) => n + 1), []);
|
|
258
259
|
|
|
259
260
|
const who = commit.authorName || commit.authorEmail || 'unknown';
|
|
260
|
-
const fileName = filePath.slice(filePath.lastIndexOf('/') + 1);
|
|
261
261
|
const kind = loaded === null ? null : previewKind(filePath, loaded.patch);
|
|
262
262
|
const canToggleSource = kind === 'viewer' && SOURCE_TOGGLE_EXTENSIONS.has(ext);
|
|
263
263
|
/**
|
|
@@ -369,7 +369,9 @@ export function HistoryVersionPreview({ filePath, commit }: HistoryVersionPrevie
|
|
|
369
369
|
// div is what stays mounted around it for focus to land on. See
|
|
370
370
|
// `RetryReadButton`.
|
|
371
371
|
<div {...READ_PANE} className="flex-1 overflow-auto p-3">
|
|
372
|
-
<FilePaneCard file={
|
|
372
|
+
<FilePaneCard file={displayFileName(filePath, kbDirName)} fileTitle={fileNameTooltip(filePath, kbDirName)}>
|
|
373
|
+
{viewer}
|
|
374
|
+
</FilePaneCard>
|
|
373
375
|
</div>
|
|
374
376
|
) : (
|
|
375
377
|
// A viewport (pdf, image, workbook, sandboxed page): it owns its own
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { RefreshCw } from 'lucide-react';
|
|
3
3
|
import { currentBranchModel, isProtectedBranch } from '@bevel-software/platform-shared';
|
|
4
4
|
import { useGit } from '../state/git.context';
|
|
5
5
|
import { useAutoUpdate } from '../state/auto-update.context';
|
|
@@ -7,35 +7,9 @@ import { useCrCreationPort } from '../../../core/registry';
|
|
|
7
7
|
import { PR_STALE_EVENT } from '../../../core/events';
|
|
8
8
|
import { useWorkspace } from '../../workspace/state/workspace.context';
|
|
9
9
|
import { sanitizeErrorText } from '../services/error-messages';
|
|
10
|
+
import { describePullFailure, pullFailurePhrase } from '../services/pull-failure';
|
|
10
11
|
import { Button } from '../../../shared/components';
|
|
11
12
|
|
|
12
|
-
/**
|
|
13
|
-
* Classify a pull failure into a short, user-safe phrase. Returned strings
|
|
14
|
-
* flow through the change-request port's `resolvePullIssue` (the enterprise
|
|
15
|
-
* registry splices them into the chat composer, where the user sees them), so
|
|
16
|
-
* the labels must not leak git vocabulary — no "merge conflict",
|
|
17
|
-
* "uncommitted", "working tree", "stash", "HEAD". The agent's own prompt
|
|
18
|
-
* knows the underlying mechanics; the user gets a workspace-level description
|
|
19
|
-
* of what happened.
|
|
20
|
-
*/
|
|
21
|
-
function classifyPullFailure(error: unknown): string {
|
|
22
|
-
const sanitized = sanitizeErrorText(error).toLowerCase();
|
|
23
|
-
if (/\b(conflict|conflicts|merge conflict|would be overwritten)\b/.test(sanitized)) {
|
|
24
|
-
return 'two versions of the same file need to be reconciled';
|
|
25
|
-
}
|
|
26
|
-
if (/\b(uncommitted|local changes|working tree|dirty|stash)\b/.test(sanitized)) {
|
|
27
|
-
return 'there are local changes that need to be sorted out first';
|
|
28
|
-
}
|
|
29
|
-
if (
|
|
30
|
-
/\b(network|auth|credential|permission denied|unauthorized|forbidden|timeout|timed out|could not resolve host|failed to connect|401|403)\b/.test(
|
|
31
|
-
sanitized,
|
|
32
|
-
)
|
|
33
|
-
) {
|
|
34
|
-
return 'a connection or permission problem';
|
|
35
|
-
}
|
|
36
|
-
return 'something unexpected went wrong';
|
|
37
|
-
}
|
|
38
|
-
|
|
39
13
|
/**
|
|
40
14
|
* Shown when the current branch is behind origin. On protected branches
|
|
41
15
|
* (current-company-state / target-company-state) the API guards block local
|
|
@@ -78,7 +52,7 @@ export function PullNeededBanner() {
|
|
|
78
52
|
setPending(true);
|
|
79
53
|
try {
|
|
80
54
|
// Pull is the only operation whose failure should hand off to the
|
|
81
|
-
// agent — that's the user-visible action they clicked
|
|
55
|
+
// agent — that's the user-visible action they clicked Update on, and
|
|
82
56
|
// a pull failure is the case where the agent has a real recovery
|
|
83
57
|
// (resolve conflicts, switch branches, etc.) to attempt. Wrap it
|
|
84
58
|
// alone so a transient post-pull refresh hiccup can't masquerade
|
|
@@ -87,12 +61,10 @@ export function PullNeededBanner() {
|
|
|
87
61
|
try {
|
|
88
62
|
await git.pull();
|
|
89
63
|
} catch (err) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
setError(reason);
|
|
95
|
-
const seedReason = classifyPullFailure(err);
|
|
64
|
+
// In the reader's words, never the sanitized error: scrubbed of
|
|
65
|
+
// secrets it still speaks git ("working tree has uncommitted changes").
|
|
66
|
+
setError(describePullFailure(err));
|
|
67
|
+
const seedReason = pullFailurePhrase(err);
|
|
96
68
|
// Hand off through the change-request port so the user always has a
|
|
97
69
|
// path forward — the enterprise registry seeds the agent chat, where
|
|
98
70
|
// the common rebase-refused case (dirty working tree from a mid-flow
|
|
@@ -126,8 +98,8 @@ export function PullNeededBanner() {
|
|
|
126
98
|
} catch (err) {
|
|
127
99
|
const reason =
|
|
128
100
|
err instanceof Error
|
|
129
|
-
? sanitizeErrorText(err) || '
|
|
130
|
-
: '
|
|
101
|
+
? sanitizeErrorText(err) || 'Got the latest changes, but couldn’t show them. Reload the page.'
|
|
102
|
+
: 'Got the latest changes, but couldn’t show them. Reload the page.';
|
|
131
103
|
setError(reason);
|
|
132
104
|
console.debug('[pull] post-pull refresh failed:', reason);
|
|
133
105
|
}
|
|
@@ -151,12 +123,8 @@ export function PullNeededBanner() {
|
|
|
151
123
|
const showAssistantAction = !onProtectedBranch && !!crPort?.resolvePullIssue;
|
|
152
124
|
const showAction = showRetry || showAssistantAction;
|
|
153
125
|
const handleClick = showRetry ? pullDirectly : askAgentToMerge;
|
|
154
|
-
const buttonLabel = pending ? '
|
|
155
|
-
const message = autoFailed
|
|
156
|
-
? 'Couldn’t update automatically'
|
|
157
|
-
: showAssistantAction
|
|
158
|
-
? 'Your draft is missing teammate updates'
|
|
159
|
-
: 'Updates are waiting';
|
|
126
|
+
const buttonLabel = pending ? 'Updating…' : showRetry ? 'Update' : 'Ask assistant';
|
|
127
|
+
const message = autoFailed ? 'Couldn’t get the latest changes' : 'New changes available';
|
|
160
128
|
// After save=share, the only thing that can keep auto-pull from running on
|
|
161
129
|
// a protected branch is in-memory tab edits. The previous fallback referred
|
|
162
130
|
// to "discard your local changes" — a dirty-tree / conflicted-paths exit
|
|
@@ -165,9 +133,9 @@ export function PullNeededBanner() {
|
|
|
165
133
|
const guidance = autoFailed
|
|
166
134
|
? autoUpdate.reason
|
|
167
135
|
: showAssistantAction
|
|
168
|
-
?
|
|
136
|
+
? 'Your draft doesn’t have them yet.'
|
|
169
137
|
: hasUnsavedEditorChanges
|
|
170
|
-
? '
|
|
138
|
+
? 'Save your open page to get them.'
|
|
171
139
|
: null;
|
|
172
140
|
|
|
173
141
|
return (
|
|
@@ -176,10 +144,8 @@ export function PullNeededBanner() {
|
|
|
176
144
|
className="px-3 py-1.5 bg-sunken border-b border-line text-xs text-ink shrink-0"
|
|
177
145
|
>
|
|
178
146
|
<div className="flex items-center gap-2">
|
|
179
|
-
<
|
|
180
|
-
<span className="flex-1">
|
|
181
|
-
{message} (<span className="font-mono font-semibold">{status.branch}</span>).
|
|
182
|
-
</span>
|
|
147
|
+
<RefreshCw size={13} className="shrink-0" />
|
|
148
|
+
<span className="flex-1">{message}</span>
|
|
183
149
|
{showAction && (
|
|
184
150
|
<Button variant="primary" size="tiny" onClick={handleClick} disabled={pending}>
|
|
185
151
|
{buttonLabel}
|