@bevel-software/platform-core-frontend 0.33.0 → 0.35.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 (67) hide show
  1. package/package.json +2 -2
  2. package/src/lib/__tests__/api.test.ts +28 -1
  3. package/src/lib/api.ts +4 -2
  4. package/src/modules/access/__tests__/ManageAccessDialog.add-row-picking.test.tsx +53 -1
  5. package/src/modules/access/api.ts +27 -8
  6. package/src/modules/access/components/ManageAccessDialog.tsx +7 -7
  7. package/src/modules/access/index.ts +1 -1
  8. package/src/modules/admin/__tests__/DirectoryGroupsPage.test.tsx +51 -0
  9. package/src/modules/admin/components/DirectoryGroupsPage.tsx +42 -5
  10. package/src/modules/admin/index.ts +1 -1
  11. package/src/modules/admin/services/groups.api.ts +11 -1
  12. package/src/modules/agents/__tests__/useConnectAsChoice.test.ts +56 -0
  13. package/src/modules/agents/components/ConnectAsChoice.tsx +88 -0
  14. package/src/modules/agents/connect-as.ts +15 -0
  15. package/src/modules/agents/index.ts +5 -0
  16. package/src/modules/agents/services/agent-choices.api.ts +39 -0
  17. package/src/modules/agents/useConnectAsChoice.ts +66 -0
  18. package/src/modules/audit/__tests__/AuditLogPage.test.tsx +16 -2
  19. package/src/modules/audit/components/AuditLogPage.tsx +11 -0
  20. package/src/modules/audit/services/audit.api.ts +5 -0
  21. package/src/modules/auth/__tests__/AccountPage.test.tsx +21 -0
  22. package/src/modules/auth/__tests__/account.api.test.ts +69 -0
  23. package/src/modules/auth/components/AccountPage.tsx +8 -2
  24. package/src/modules/auth/index.ts +1 -1
  25. package/src/modules/auth/services/account.api.ts +18 -2
  26. package/src/modules/git/__tests__/BranchSwitcher.test.tsx +0 -14
  27. package/src/modules/git/__tests__/git.api.test.ts +2 -2
  28. package/src/modules/git/hooks/__tests__/useGitState.deleteBranch.test.tsx +1 -1
  29. package/src/modules/library/__tests__/SkillPage.test.tsx +229 -24
  30. package/src/modules/library/__tests__/ToolVarRow.test.tsx +51 -5
  31. package/src/modules/library/components/skill-page/SkillFilePane.tsx +57 -9
  32. package/src/modules/library/components/skill-page/SkillPage.tsx +65 -25
  33. package/src/modules/library/components/tool-page/ToolVarRow.tsx +22 -14
  34. package/src/modules/review/components/MarkdownDiffViewer.tsx +23 -1
  35. package/src/modules/review/components/ReviewPanel.tsx +8 -2
  36. package/src/modules/review/components/__tests__/MarkdownDiffViewer.test.tsx +31 -0
  37. package/src/modules/secrets-vault/components/ConnectToolsPage.tsx +79 -16
  38. package/src/modules/secrets-vault/components/__tests__/ConnectToolsPage.test.tsx +122 -2
  39. package/src/modules/secrets-vault/services/connect.api.ts +20 -5
  40. package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +45 -4
  41. package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +127 -12
  42. package/src/modules/toolbar/services/external-api-keys.api.ts +5 -2
  43. package/src/modules/workspace/components/FileViewer.tsx +1 -1
  44. package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +58 -8
  45. package/src/modules/workspace/components/renderers/HtmlRenderer.tsx +40 -7
  46. package/src/modules/workspace/components/renderers/KbAppLink.tsx +56 -0
  47. package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +30 -10
  48. package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +37 -40
  49. package/src/modules/workspace/components/renderers/__tests__/HtmlRenderer.links.test.tsx +185 -0
  50. package/src/modules/workspace/components/renderers/__tests__/MarkdownRenderer.sectionReclick.test.tsx +88 -0
  51. package/src/modules/workspace/components/renderers/__tests__/MarkdownRenderer.test.tsx +199 -29
  52. package/src/modules/workspace/components/renderers/__tests__/bridgeHarness.ts +37 -4
  53. package/src/modules/workspace/components/renderers/__tests__/htmlSandbox.test.ts +59 -0
  54. package/src/modules/workspace/components/renderers/__tests__/htmlViewsGuide.test.ts +15 -1
  55. package/src/modules/workspace/components/renderers/__tests__/liveDataReferencePage.test.ts +397 -0
  56. package/src/modules/workspace/components/renderers/htmlSandbox.ts +48 -15
  57. package/src/modules/workspace/components/renderers/htmlToolBridge.ts +19 -0
  58. package/src/modules/workspace/components/renderers/kbMarkdownPipeline.tsx +35 -28
  59. package/src/modules/workspace/components/renderers/scrollToHeading.ts +35 -0
  60. package/src/modules/workspace/hooks/__tests__/useLinksOut.test.ts +6 -0
  61. package/src/modules/workspace/hooks/useLinksOut.ts +12 -6
  62. package/src/modules/workspace/index.ts +21 -2
  63. package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +262 -25
  64. package/src/modules/workspace/routing/kb-routes.ts +221 -53
  65. package/src/modules/workspace/utils/__tests__/treeConfirm.test.ts +32 -48
  66. package/src/modules/workspace/utils/fileTree.ts +1 -1
  67. package/src/modules/workspace/utils/treeConfirm.ts +24 -28
@@ -0,0 +1,66 @@
1
+ import { useCallback, useMemo, useState } from 'react';
2
+ import { canConnectAs, type UnavailableChoice } from './connect-as';
3
+ import type { AgentChoice } from './services/agent-choices.api';
4
+
5
+ /** What the agents on offer answered: the list, or that they could not be loaded. */
6
+ export interface AgentChoicesAnswer {
7
+ agents: readonly AgentChoice[];
8
+ /** The agents could not be listed: `agents` is then empty for that reason, not because there are none. */
9
+ failed?: boolean;
10
+ }
11
+
12
+ /**
13
+ * The "Connect as" state a connection is made with — the one shape both
14
+ * forms (the OAuth consent step, the connection-key form) hold, so the
15
+ * agents module owns the consent state and each page only says when its
16
+ * agents answered and what it does with the choice.
17
+ */
18
+ export interface ConnectAsChoiceState {
19
+ /** The agents on offer; Everything is always offered first. */
20
+ agents: readonly AgentChoice[];
21
+ /** The chosen agent's path, or null for Everything. */
22
+ value: string | null;
23
+ setValue: (agentPath: string | null) => void;
24
+ /** Set when the agents could not be loaded: Everything waits for the person to confirm it. */
25
+ unavailable: UnavailableChoice | undefined;
26
+ /** Whether a connection may be made with the choice as it stands (see {@link canConnectAs}). */
27
+ mayConnect: boolean;
28
+ /**
29
+ * The agents on offer have answered. `requestKey` names the request they
30
+ * answered for, when the page waits on one in particular (the consent
31
+ * step's authorization state): until that request's own answer is in,
32
+ * Everything is not yet a choice anyone made.
33
+ */
34
+ settle: (answer: AgentChoicesAnswer, requestKey?: string) => void;
35
+ }
36
+
37
+ /**
38
+ * The "Connect as" choice: Everything (null) unless the person picks an
39
+ * agent, settled once the agents on offer answer. A remembered choice that is
40
+ * no longer on offer falls back to Everything. With `expect`, the state is
41
+ * settled only when the answer named that request; without it, by any answer.
42
+ */
43
+ export function useConnectAsChoice(opts: { initial?: string | null | (() => string | null); expect?: string | null } = {}): ConnectAsChoiceState {
44
+ const [agents, setAgents] = useState<readonly AgentChoice[]>([]);
45
+ const [value, setValue] = useState<string | null>(opts.initial ?? null);
46
+ const [failed, setFailed] = useState(false);
47
+ const [settledFor, setSettledFor] = useState<string | null>(null);
48
+ const [everythingConfirmed, setEverythingConfirmed] = useState(false);
49
+
50
+ const settle = useCallback((answer: AgentChoicesAnswer, requestKey = '') => {
51
+ setAgents(answer.agents);
52
+ setFailed(answer.failed === true);
53
+ // A remembered choice that is no longer on offer falls back to Everything.
54
+ setValue((current) => (current && answer.agents.some((a) => a.path === current) ? current : null));
55
+ setSettledFor(requestKey);
56
+ }, []);
57
+
58
+ const unavailable = useMemo<UnavailableChoice | undefined>(
59
+ () => (failed ? { confirmed: everythingConfirmed, onConfirm: setEverythingConfirmed } : undefined),
60
+ [failed, everythingConfirmed],
61
+ );
62
+ const settled = opts.expect === undefined ? settledFor !== null : opts.expect != null && settledFor === opts.expect;
63
+ const mayConnect = canConnectAs({ settled, unavailable });
64
+
65
+ return { agents, value, setValue, unavailable, mayConnect, settle };
66
+ }
@@ -4,8 +4,8 @@ import userEvent from '@testing-library/user-event';
4
4
  import { MemoryRouter } from 'react-router-dom';
5
5
  import { AuditLogPage } from '../components/AuditLogPage';
6
6
  import { groupByAccount } from '../components/principal-grouping';
7
- import { AdminContext } from '../../admin/state/admin.context';
8
- import { AuthContext } from '../../auth/state/auth.context';
7
+ import { AdminContext } from '../../admin';
8
+ import { AuthContext } from '../../auth';
9
9
  import {
10
10
  listPrincipals,
11
11
  listEvents,
@@ -177,6 +177,20 @@ describe('AuditLogPage', () => {
177
177
  expect(screen.queryByRole('button', { name: /Revoke key for Old script/ })).not.toBeInTheDocument();
178
178
  });
179
179
 
180
+ it('shows what each connection and key connects as: Everything, or the agent file it was made as', async () => {
181
+ vi.mocked(listPrincipals).mockResolvedValue([
182
+ { ...ALICE_CLAUDE, agentPath: 'Agents/delivery-mechanic.agent' },
183
+ { ...ALICE_CI, agentPath: null },
184
+ ]);
185
+ renderPage({ isAdmin: true });
186
+ await waitFor(() => expect(screen.getByText('CI pipeline')).toBeInTheDocument());
187
+ const rowOf = (label: string) => screen.getByText(label).closest('li') as HTMLElement;
188
+ expect(rowOf('Claude')).toHaveTextContent('As delivery-mechanic');
189
+ expect(within(rowOf('Claude')).getByTitle('Agents/delivery-mechanic.agent')).toBeInTheDocument();
190
+ // Everything is what a connection is unless it says otherwise: no tag.
191
+ expect(rowOf('CI pipeline')).not.toHaveTextContent('As ');
192
+ });
193
+
180
194
  it('shows an admin a key its owner deleted for good, marked as such, with its history intact', async () => {
181
195
  vi.mocked(listPrincipals).mockResolvedValue([{ ...BOB_OLD, deletedAt: NOW - 10 * DAY, eventCount: 18 }]);
182
196
  renderPage({ isAdmin: true });
@@ -8,6 +8,7 @@ import { GITHUB_LINK_KIND } from '../../../shared/marketplace-url';
8
8
  import { useAdmin } from '../../admin';
9
9
  import { useAuth } from '../../auth';
10
10
  import { listPrincipals, revokeAgent, revokeKey, type AuditPrincipal } from '../services/audit.api';
11
+ import { connectedAsLabel } from '../../agents';
11
12
  import { groupByAccount, principalKey } from './principal-grouping';
12
13
  import { AuditEventsPanel } from './AuditEventsPanel';
13
14
 
@@ -276,6 +277,16 @@ export function AuditLogPage() {
276
277
  {p.deletedAt != null && <Badge tone="outline">Deleted by owner</Badge>}
277
278
  </span>
278
279
  <span className="block text-meta text-ink-muted">
280
+ {/* The agent configuration the connection was made as, when it was
281
+ made as one; a connection made as Everything, which is what a
282
+ connection is unless it says otherwise, carries no tag. A page
283
+ acts as its viewer, so it never has one. */}
284
+ {p.kind !== 'page' && p.agentPath && (
285
+ <>
286
+ <span title={p.agentPath}>As {connectedAsLabel(p.agentPath)}</span>
287
+ {' · '}
288
+ </>
289
+ )}
279
290
  <span title={formatAbsolute(p.createdAt)}>
280
291
  {p.kind === 'agent' ? 'Connected' : p.kind === 'page' ? 'First call' : 'Created'}{' '}
281
292
  {formatRelative(p.createdAt)}
@@ -29,6 +29,11 @@ export interface AuditPrincipal {
29
29
  /** Events on record for it. */
30
30
  eventCount: number;
31
31
  user: { id: string; email: string; name: string };
32
+ /**
33
+ * For a key or an agent: the agent configuration it connects as (a knowledge-base
34
+ * path), or null for Everything. Absent for a page.
35
+ */
36
+ agentPath?: string | null;
32
37
  }
33
38
 
34
39
  export type AgentEventKind = 'capability' | 'tool' | 'skill';
@@ -75,6 +75,27 @@ describe('AccountPage', () => {
75
75
  await userEvent.click(screen.getByRole('button', { name: 'Change password' }));
76
76
  expect(await screen.findByRole('alert')).toHaveTextContent('Current password is incorrect');
77
77
  });
78
+
79
+ it('disables the submit while a change is in flight, and sends one change for a double click', async () => {
80
+ let finish!: () => void;
81
+ vi.mocked(changePassword).mockImplementation(
82
+ () => new Promise<void>((resolve) => (finish = resolve)),
83
+ );
84
+ renderPage();
85
+ await userEvent.type(screen.getByLabelText(/Current password/), 'old-password');
86
+ await userEvent.type(screen.getByLabelText(/New password/), 'new-password-1');
87
+ await userEvent.type(screen.getByLabelText(/Confirm new password/), 'new-password-1');
88
+ await userEvent.dblClick(screen.getByRole('button', { name: 'Change password' }));
89
+ // A second submit straight from the form, as a click landing before the
90
+ // disabled button rendered would be.
91
+ screen.getByRole('button', { name: 'Saving…' }).closest('form')!.requestSubmit();
92
+ expect(screen.getByRole('button', { name: 'Saving…' })).toBeDisabled();
93
+ expect(changePassword).toHaveBeenCalledTimes(1);
94
+
95
+ finish();
96
+ expect(await screen.findByRole('status')).toHaveTextContent('Password changed.');
97
+ expect(screen.getByRole('button', { name: 'Change password' })).toBeEnabled();
98
+ });
78
99
  });
79
100
 
80
101
  /**
@@ -0,0 +1,69 @@
1
+ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
2
+ import { changePassword } from '../services/account.api';
3
+ import { authFetch, getToken, setToken } from '../../../lib/api';
4
+
5
+ /**
6
+ * A password change ends every session opened before it, the changer's old
7
+ * token included, so the page keeps working only if the token the change
8
+ * hands back is what the NEXT request carries. Only `fetch` is stubbed: the
9
+ * real `changePassword` and `authFetch` read and write the stored token.
10
+ */
11
+ describe('changePassword and the token it hands back', () => {
12
+ beforeEach(() => {
13
+ localStorage.clear();
14
+ });
15
+
16
+ afterEach(() => {
17
+ vi.restoreAllMocks();
18
+ localStorage.clear();
19
+ });
20
+
21
+ it('authenticates the next request with the replacement token', async () => {
22
+ setToken('token-before-the-change');
23
+ const fetchMock = vi
24
+ .spyOn(globalThis, 'fetch')
25
+ .mockResolvedValueOnce(new Response(JSON.stringify({ ok: true, token: 'token-after-the-change' }), { status: 200 }))
26
+ .mockResolvedValueOnce(new Response(JSON.stringify({ user: {} }), { status: 200 }));
27
+
28
+ await changePassword('old-password-1', 'new-password-1');
29
+ await authFetch('/api/auth/me');
30
+
31
+ const authorization = (call: number) =>
32
+ new Headers((fetchMock.mock.calls[call][1] as RequestInit).headers).get('Authorization');
33
+ expect(authorization(0)).toBe('Bearer token-before-the-change');
34
+ expect(authorization(1)).toBe('Bearer token-after-the-change');
35
+ expect(getToken()).toBe('token-after-the-change');
36
+ });
37
+
38
+ it('keeps a sign-in another tab made while the change was in flight, rather than overwriting it', async () => {
39
+ setToken('token-before-the-change');
40
+ vi.spyOn(globalThis, 'fetch').mockImplementationOnce(async () => {
41
+ // The other tab signs in as someone else before this response arrives.
42
+ setToken('other-account-token');
43
+ return new Response(JSON.stringify({ ok: true, token: 'token-after-the-change' }), { status: 200 });
44
+ });
45
+
46
+ await changePassword('old-password-1', 'new-password-1');
47
+ expect(getToken()).toBe('other-account-token');
48
+ });
49
+
50
+ it('keeps the stored token when a success answer carries no token, rather than storing "undefined"', async () => {
51
+ setToken('token-before-the-change');
52
+ vi.spyOn(globalThis, 'fetch').mockResolvedValueOnce(new Response(JSON.stringify({ ok: true }), { status: 200 }));
53
+
54
+ await changePassword('old-password-1', 'new-password-1');
55
+ expect(getToken()).toBe('token-before-the-change');
56
+ });
57
+
58
+ it('keeps the stored token when the change is refused', async () => {
59
+ setToken('token-before-the-change');
60
+ vi.spyOn(globalThis, 'fetch').mockResolvedValueOnce(
61
+ new Response(JSON.stringify({ error: 'Your password was changed from another session; nothing was changed.' }), {
62
+ status: 409,
63
+ }),
64
+ );
65
+
66
+ await expect(changePassword('old-password-1', 'new-password-1')).rejects.toThrow(/another session/);
67
+ expect(getToken()).toBe('token-before-the-change');
68
+ });
69
+ });
@@ -1,4 +1,4 @@
1
- import { useState, type FormEvent } from 'react';
1
+ import { useRef, useState, type FormEvent } from 'react';
2
2
  import { PageShell } from '../../../shared/components/PageShell';
3
3
  import { useAuth } from '../state/auth.context';
4
4
  import { changePassword } from '../services/account.api';
@@ -25,15 +25,20 @@ export function AccountPage() {
25
25
  const [error, setError] = useState<string | null>(null);
26
26
  const [saved, setSaved] = useState(false);
27
27
  const [submitting, setSubmitting] = useState(false);
28
+ // Set synchronously, so a second click landing before the disabled button
29
+ // renders is dropped too: one change at a time, never two racing.
30
+ const inFlight = useRef(false);
28
31
 
29
32
  async function handleSubmit(e: FormEvent<HTMLFormElement>) {
30
33
  e.preventDefault();
34
+ if (inFlight.current) return;
31
35
  setError(null);
32
36
  setSaved(false);
33
37
  if (newPassword !== confirmPassword) {
34
38
  setError('New passwords do not match');
35
39
  return;
36
40
  }
41
+ inFlight.current = true;
37
42
  setSubmitting(true);
38
43
  try {
39
44
  await changePassword(currentPassword || undefined, newPassword);
@@ -44,6 +49,7 @@ export function AccountPage() {
44
49
  } catch (err) {
45
50
  setError(err instanceof Error ? err.message : 'Could not change password');
46
51
  } finally {
52
+ inFlight.current = false;
47
53
  setSubmitting(false);
48
54
  }
49
55
  }
@@ -113,7 +119,7 @@ export function AccountPage() {
113
119
  )}
114
120
  {saved && (
115
121
  <div className="text-sm text-emerald-700" role="status">
116
- Password changed.
122
+ Password changed. Every other session has been signed out.
117
123
  </div>
118
124
  )}
119
125
 
@@ -8,5 +8,5 @@ export { createAccount, deactivateAccount, deleteAccount, getAccountReferences,
8
8
  export type { AccountReferences, AccountSummary } from './services/account.api';
9
9
  export { takePostLoginRedirect } from './services/sso';
10
10
  export type { LoginProviders } from './services/sso';
11
- export { AuthContext, useAuth } from './state/auth.context';
11
+ export { AuthContext, useAuth, type AuthContextValue } from './state/auth.context';
12
12
  export { useSignInMethods } from './state/use-sign-in-methods';
@@ -1,4 +1,4 @@
1
- import { authFetch } from '../../../lib/api';
1
+ import { authFetch, getToken, setToken } from '../../../lib/api';
2
2
 
3
3
  /** One row of the admin Accounts list (`GET /api/admin/accounts`). */
4
4
  export interface AccountSummary {
@@ -48,17 +48,33 @@ async function readError(res: Response, fallback: string): Promise<string> {
48
48
  return (body as { error?: string }).error || fallback;
49
49
  }
50
50
 
51
- /** Self-service password change. `currentPassword` is required once one is set. */
51
+ /**
52
+ * Self-service password change. `currentPassword` is required once one is set.
53
+ * The change ends every session opened before it, this one's included, so the
54
+ * fresh token the server hands back replaces the stored one — but only the
55
+ * one this request sent: the stored token is one key shared by every tab, and
56
+ * a tab that signed in as someone else while this request was in flight has
57
+ * replaced it already. That sign-in is kept; this change's token belongs to
58
+ * a session that tab no longer has.
59
+ */
52
60
  export async function changePassword(
53
61
  currentPassword: string | undefined,
54
62
  newPassword: string,
55
63
  ): Promise<void> {
64
+ const sent = getToken();
56
65
  const res = await authFetch('/api/auth/change-password', {
57
66
  method: 'POST',
58
67
  headers: { 'Content-Type': 'application/json' },
59
68
  body: JSON.stringify({ currentPassword, newPassword }),
60
69
  });
61
70
  if (!res.ok) throw new Error(await readError(res, 'Could not change password'));
71
+ const body = (await res.json().catch(() => ({}))) as { token?: unknown };
72
+ // The change is written by now. Only a token the server actually handed
73
+ // back replaces the stored one: an answer without one (a replica from
74
+ // before the change handed tokens back, mid-deploy) must not turn the
75
+ // stored token into the string "undefined" and sign the person out.
76
+ const token = typeof body.token === 'string' && body.token ? body.token : null;
77
+ if (token && getToken() === sent) setToken(token);
62
78
  }
63
79
 
64
80
  export async function listAccounts(): Promise<AccountSummary[]> {
@@ -219,8 +219,6 @@ describe('BranchSwitcher: author-can-delete affordance', () => {
219
219
  {
220
220
  name: 'alice/my-draft',
221
221
  isProtected: false,
222
- ahead: 0,
223
- behind: 0,
224
222
  hasRemote: true,
225
223
  },
226
224
  ]));
@@ -239,8 +237,6 @@ describe('BranchSwitcher: author-can-delete affordance', () => {
239
237
  {
240
238
  name: 'bob/other-draft',
241
239
  isProtected: false,
242
- ahead: 0,
243
- behind: 0,
244
240
  hasRemote: true,
245
241
  },
246
242
  ]));
@@ -260,8 +256,6 @@ describe('BranchSwitcher: author-can-delete affordance', () => {
260
256
  {
261
257
  name: 'bob/merged-and-pruned',
262
258
  isProtected: false,
263
- ahead: 0,
264
- behind: 0,
265
259
  hasRemote: false,
266
260
  },
267
261
  ]));
@@ -307,8 +301,6 @@ describe('BranchSwitcher: admin-can-delete affordance', () => {
307
301
  {
308
302
  name: 'bob/other-draft',
309
303
  isProtected: false,
310
- ahead: 0,
311
- behind: 0,
312
304
  hasRemote: true,
313
305
  },
314
306
  ]));
@@ -326,8 +318,6 @@ describe('BranchSwitcher: admin-can-delete affordance', () => {
326
318
  {
327
319
  name: 'fix/some-cli-branch',
328
320
  isProtected: false,
329
- ahead: 0,
330
- behind: 0,
331
321
  hasRemote: true,
332
322
  },
333
323
  ]));
@@ -344,8 +334,6 @@ describe('BranchSwitcher: admin-can-delete affordance', () => {
344
334
  {
345
335
  name: 'current-company-state',
346
336
  isProtected: true,
347
- ahead: 0,
348
- behind: 0,
349
337
  hasRemote: true,
350
338
  },
351
339
  ]));
@@ -369,8 +357,6 @@ describe('BranchSwitcher: deleting a shared branch asks in the app', () => {
369
357
  const shared = (name: string): BranchInfo => ({
370
358
  name,
371
359
  isProtected: false,
372
- ahead: 0,
373
- behind: 0,
374
360
  hasRemote: true,
375
361
  });
376
362
 
@@ -46,7 +46,7 @@ describe('git.api', () => {
46
46
  it('fetchBranches returns the array body', async () => {
47
47
  fetchMock.mockResolvedValueOnce(
48
48
  ok([
49
- { name: 'current-company-state', isCurrent: true, isProtected: true, ahead: 0, behind: 0 },
49
+ { name: 'current-company-state', isCurrent: true, isProtected: true },
50
50
  ]),
51
51
  );
52
52
  const bs = await fetchBranches('ws-1');
@@ -56,7 +56,7 @@ describe('git.api', () => {
56
56
 
57
57
  it('createBranch POSTs JSON body', async () => {
58
58
  fetchMock.mockResolvedValueOnce(
59
- ok({ name: 'feature/x', isCurrent: false, isProtected: false, ahead: null, behind: null }),
59
+ ok({ name: 'feature/x', isCurrent: false, isProtected: false }),
60
60
  );
61
61
  await createBranch('ws-1', 'feature/x');
62
62
  const [, init] = fetchMock.mock.calls[0];
@@ -34,7 +34,7 @@ const mockFetchStatus = vi.mocked(fetchStatus);
34
34
  const mockDeleteBranch = vi.mocked(apiDeleteBranch);
35
35
 
36
36
  function mkBranch(name: string): BranchInfo {
37
- return { name, isProtected: false, ahead: 0, behind: 0, hasRemote: true };
37
+ return { name, isProtected: false, hasRemote: true };
38
38
  }
39
39
 
40
40
  describe('useGitState: optimistic deleteBranch', () => {