@startsimpli/integrations 0.2.130 → 0.2.131

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 (37) hide show
  1. package/package.json +1 -1
  2. package/src/__tests__/task-tracker-connection.test.tsx +155 -0
  3. package/src/__tests__/task-tracker-shared.test.ts +108 -0
  4. package/src/__tests__/tracker-linear-chip.test.tsx +87 -0
  5. package/src/api/connections.ts +14 -0
  6. package/src/components/index.ts +4 -0
  7. package/src/components/pages/ConnectionsPage.tsx +26 -2
  8. package/src/components/pages/TrackerPage.tsx +18 -0
  9. package/src/components/pages/task-tracker/ExternalLinkChip.tsx +53 -0
  10. package/src/components/pages/task-tracker/TaskTrackerSettings.tsx +112 -0
  11. package/src/components/pages/types.ts +4 -0
  12. package/src/components/pages/work-items.tsx +8 -1
  13. package/src/corpus/entities.ts +15 -0
  14. package/src/corpus/types.ts +3 -0
  15. package/src/index.ts +2 -0
  16. package/src/native/__tests__/task-tracker.test.tsx +206 -0
  17. package/src/native/app/FoundryApp.tsx +1 -1
  18. package/src/native/app/data.ts +5 -1
  19. package/src/native/app/registry.tsx +4 -2
  20. package/src/native/corpus/fake-data.ts +3 -3
  21. package/src/native/corpus/fake-tenant.ts +3 -0
  22. package/src/native/screens/connections/ConnectionsScreens.tsx +52 -12
  23. package/src/native/screens/connections/controller.ts +71 -1
  24. package/src/native/screens/connections/fake.ts +38 -7
  25. package/src/native/screens/connections/tab.tsx +25 -7
  26. package/src/native/task-tracker/SyncChips.tsx +35 -0
  27. package/src/native/task-tracker/TrackerSettingsScreen.tsx +85 -0
  28. package/src/native/task-tracker/index.ts +2 -0
  29. package/src/native/tracker/TrackerDetailScreen.tsx +14 -1
  30. package/src/native/tracker/TrackerListScreen.tsx +7 -1
  31. package/src/native/tracker/tab.tsx +16 -7
  32. package/src/task-tracker/index.ts +5 -0
  33. package/src/task-tracker/item-sync.ts +87 -0
  34. package/src/task-tracker/links.ts +34 -0
  35. package/src/task-tracker/settings-controller.ts +138 -0
  36. package/src/task-tracker/sync-config.ts +95 -0
  37. package/src/task-tracker/useTrackerName.ts +29 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@startsimpli/integrations",
3
- "version": "0.2.130",
3
+ "version": "0.2.131",
4
4
  "description": "Provider-agnostic types, API clients, hooks, and UI primitives for email + calendar integrations across StartSimpli apps, plus foundry customer email (subpath ./comms).",
5
5
  "license": "MIT",
6
6
  "homepage": "https://startsimpli.com",
@@ -0,0 +1,155 @@
1
+ /**
2
+ * The web side of a connected TASK TRACKER (bd startsim-2nn3h): the catalog card,
3
+ * the sync settings (team, project, personal destination, state mapping) and the
4
+ * disconnect wording. Nothing here may name a vendor in the component: the
5
+ * label comes from the catalog and the connection.
6
+ */
7
+ import { describe, expect, it, vi } from 'vitest';
8
+ import { render, screen, waitFor, within } from '@testing-library/react';
9
+ import userEvent from '@testing-library/user-event';
10
+
11
+ import { ConnectionsPage } from '../components/pages/ConnectionsPage';
12
+ import type { MemberConnectionsApi } from '../components/pages/types';
13
+
14
+ const ENTRY = {
15
+ key: 'tracker-x', name: 'Trackly', description: 'Task tracker', logo_url: '', docs_url: '',
16
+ capabilities: ['poll', 'push'], auth_mode: 'oauth', kind: 'task_tracker',
17
+ credential_schema: { version: 1, fields: [] },
18
+ config_schema: { version: 1, fields: [{ key: 'poll_interval_minutes', label: 'Reconcile interval', type: 'number', required: false }] },
19
+ record_types: [], supports_webhooks: true, availability: { available: true, reason: '' },
20
+ };
21
+
22
+ const CONN = {
23
+ id: 'c1', public_id: 'p1', name: 'Trackly', connector_key: 'tracker-x', connector_name: 'Trackly',
24
+ external_account_id: 'org', account_label: 'Acme', capabilities_enabled: ['poll', 'push'],
25
+ config: { task_sync: { default_container_id: 't1', project_focus: { p1: 'f1' } } },
26
+ status: 'connected', health: 'ok', auth_mode: 'oauth',
27
+ } as const;
28
+
29
+ const CHOICES: Record<string, Array<{ id: string; label: string; detail?: object }>> = {
30
+ team: [{ id: 't1', label: 'Engineering (ENG)' }, { id: 't2', label: 'Personal (PER)' }],
31
+ project: [{ id: 'pr1', label: 'Tandem' }],
32
+ state: [
33
+ { id: 's1', label: 'Todo', detail: { state_type: 'unstarted' } },
34
+ { id: 's2', label: 'In Progress', detail: { state_type: 'started' } },
35
+ ],
36
+ user: [{ id: 'u1', label: 'Quinn' }],
37
+ };
38
+
39
+ function api(overrides: Partial<MemberConnectionsApi> = {}): MemberConnectionsApi {
40
+ return {
41
+ connectorCatalog: vi.fn().mockResolvedValue({ results: [ENTRY] }),
42
+ connections: vi.fn().mockResolvedValue({ results: [CONN], permissions: { view: true, manage: true, issue_tokens: false } }),
43
+ connect: vi.fn(), checkConnection: vi.fn(), rotateCredential: vi.fn(), disconnect: vi.fn().mockResolvedValue(undefined),
44
+ connectionRuns: vi.fn().mockResolvedValue({ results: [] }),
45
+ startOAuth: vi.fn().mockResolvedValue({ authorization_url: 'https://t.example/auth', state: 's', redirect_uri: 'r' }),
46
+ connectionChoices: vi.fn(async (_id: string, p?: { kind?: string }) => ({
47
+ results: (CHOICES[p?.kind ?? 'team'] ?? []).map((c) => ({ ...c, kind: p?.kind ?? 'team', selectable: true, reason: '', remediation: '', hidden_by_default: false, detail: c.detail ?? {} })),
48
+ kind: p?.kind ?? 'team', cursor: null, has_more: false,
49
+ })),
50
+ updateConnectionConfig: vi.fn().mockResolvedValue(CONN),
51
+ syncConnectionNow: vi.fn().mockResolvedValue({ queued: true }),
52
+ ...overrides,
53
+ } as unknown as MemberConnectionsApi;
54
+ }
55
+
56
+ async function myCard(): Promise<HTMLElement> {
57
+ return waitFor(() => {
58
+ const el = document.querySelector('div[data-connection="c1"]');
59
+ if (!el) throw new Error('card not rendered yet');
60
+ return el as HTMLElement;
61
+ });
62
+ }
63
+
64
+ async function openSettings(a: MemberConnectionsApi) {
65
+ render(<ConnectionsPage mode="personal" api={a} />);
66
+ const card = await myCard();
67
+ await userEvent.click(within(card).getByRole('button', { name: /^settings$/i }));
68
+ const group = await screen.findByRole('group', { name: /Trackly sync settings/i });
69
+ await waitFor(() => expect(within(group).getAllByRole('option', { name: 'Engineering (ENG)' }).length).toBeGreaterThan(0));
70
+ return { card, group };
71
+ }
72
+
73
+ describe('the catalog card for a task tracker', () => {
74
+ it('lists the card with a Connect button from catalog data alone', async () => {
75
+ render(<ConnectionsPage mode="personal" api={api({ connections: vi.fn().mockResolvedValue({ results: [], permissions: { view: true, manage: true, issue_tokens: false } }) })} />);
76
+ expect(await screen.findByText('Trackly')).toBeInTheDocument();
77
+ await userEvent.click(screen.getByRole('button', { name: /^connect$/i }));
78
+ expect(screen.getByRole('button', { name: /continue to trackly/i })).toBeInTheDocument();
79
+ });
80
+ });
81
+
82
+ describe('sync settings', () => {
83
+ it('picks team, project and personal destination and saves task_sync, keeping the rest of the block', async () => {
84
+ const a = api();
85
+ const { group } = await openSettings(a);
86
+ await userEvent.selectOptions(within(group).getByLabelText(/default project/i), 'pr1');
87
+ await userEvent.selectOptions(within(group).getByLabelText(/personal to-dos go to/i), 't2');
88
+ await userEvent.selectOptions(within(group).getByLabelText(/new to-dos go to team/i), 't2');
89
+ await userEvent.click(within(group).getByRole('button', { name: /save sync settings/i }));
90
+ await waitFor(() => expect(a.updateConnectionConfig).toHaveBeenCalled());
91
+ const [id, config] = (a.updateConnectionConfig as ReturnType<typeof vi.fn>).mock.calls[0];
92
+ expect(id).toBe('c1');
93
+ // The server replaces the block whole: project_focus must ride along.
94
+ expect(config).toEqual({ task_sync: {
95
+ default_container_id: 't2', default_project_id: 'pr1', personal_container_id: 't2', project_focus: { p1: 'f1' },
96
+ } });
97
+ });
98
+
99
+ it('shows the stored team as selected and nothing to save until something changes', async () => {
100
+ const { group } = await openSettings(api());
101
+ expect((within(group).getByLabelText(/new to-dos go to team/i) as HTMLSelectElement).value).toBe('t1');
102
+ expect(within(group).getByRole('button', { name: /save sync settings/i })).toBeDisabled();
103
+ });
104
+
105
+ it('state mapping shows the type default and lets one state be overridden', async () => {
106
+ const a = api();
107
+ const { group } = await openSettings(a);
108
+ const row = within(group).getByLabelText('Tandem status for In Progress') as HTMLSelectElement;
109
+ expect(row.value).toBe('in_progress');
110
+ expect(within(row).getByRole('option', { name: 'In progress (default)' })).toBeInTheDocument();
111
+ await userEvent.selectOptions(row, 'blocked');
112
+ await userEvent.click(within(group).getByRole('button', { name: /save sync settings/i }));
113
+ await waitFor(() => expect(a.updateConnectionConfig).toHaveBeenCalled());
114
+ const [, config] = (a.updateConnectionConfig as ReturnType<typeof vi.fn>).mock.calls[0];
115
+ expect(config.task_sync.state_overrides).toEqual({ s2: 'blocked' });
116
+ });
117
+
118
+ it('puts a state back to its default by deleting the override', async () => {
119
+ const a = api({ connections: vi.fn().mockResolvedValue({ results: [{ ...CONN, config: { task_sync: { state_overrides: { s2: 'blocked' } } } }], permissions: { view: true, manage: true, issue_tokens: false } }) });
120
+ const { group } = await openSettings(a);
121
+ await userEvent.selectOptions(within(group).getByLabelText('Tandem status for In Progress'), 'in_progress');
122
+ await userEvent.click(within(group).getByRole('button', { name: /save sync settings/i }));
123
+ await waitFor(() => expect(a.updateConnectionConfig).toHaveBeenCalled());
124
+ // An empty block is unset with null rather than saved as {}.
125
+ expect((a.updateConnectionConfig as ReturnType<typeof vi.fn>).mock.calls[0][1]).toEqual({ task_sync: null });
126
+ });
127
+
128
+ it('shows the server refusal and a Sync now button that calls the narrow route', async () => {
129
+ const a = api({ updateConnectionConfig: vi.fn().mockRejectedValue(new Error('unknown task_sync field(s): bogus')) });
130
+ const { group } = await openSettings(a);
131
+ await userEvent.selectOptions(within(group).getByLabelText(/default project/i), 'pr1');
132
+ await userEvent.click(within(group).getByRole('button', { name: /save sync settings/i }));
133
+ expect(await within(group).findByRole('alert')).toHaveTextContent(/unknown task_sync/);
134
+ await userEvent.click(within(group).getByRole('button', { name: /sync now/i }));
135
+ await waitFor(() => expect(a.syncConnectionNow).toHaveBeenCalledWith('c1'));
136
+ });
137
+
138
+ it('is not rendered for a connector the catalog does not call a task tracker', async () => {
139
+ const a = api({ connectorCatalog: vi.fn().mockResolvedValue({ results: [{ ...ENTRY, kind: '' }] }) });
140
+ render(<ConnectionsPage mode="personal" api={a} />);
141
+ const card = await myCard();
142
+ await userEvent.click(within(card).getByRole('button', { name: /^settings$/i }));
143
+ expect(screen.queryByRole('group', { name: /sync settings/i })).not.toBeInTheDocument();
144
+ expect(a.connectionChoices).not.toHaveBeenCalled();
145
+ });
146
+ });
147
+
148
+ describe('disconnect', () => {
149
+ it('says the items stay in Tandem and nothing is deleted in the tracker', async () => {
150
+ render(<ConnectionsPage mode="personal" api={api()} />);
151
+ const card = await myCard();
152
+ await userEvent.click(within(card).getByRole('button', { name: /^disconnect$/i }));
153
+ expect(within(card).getByText(/Your to-dos stay in Tandem\. Nothing is deleted in Trackly/)).toBeInTheDocument();
154
+ });
155
+ });
@@ -0,0 +1,108 @@
1
+ import { describe, expect, it, vi } from 'vitest';
2
+ import { readItemSync, syncChip } from '../task-tracker/item-sync';
3
+ import { appLinkFor, openTrackerLink } from '../task-tracker/links';
4
+ import { isTaskTracker, readTaskSync, stateRows, withTaskSync } from '../task-tracker/sync-config';
5
+
6
+ describe('item sync facts', () => {
7
+ it('reads key, url, state and error off the entity data', () => {
8
+ expect(readItemSync({
9
+ external_id: 'x', external_key: 'ENG-7', external_url: 'https://linear.app/eng/issue/ENG-7/a',
10
+ state_name: 'In Progress', sync_state: 'error', sync_error: 'rate limited',
11
+ })).toEqual({ state: 'error', key: 'ENG-7', url: 'https://linear.app/eng/issue/ENG-7/a', stateName: 'In Progress', error: 'rate limited' });
12
+ });
13
+
14
+ it('a row with no sync fields reads as nothing at all', () => {
15
+ expect(readItemSync({ title: 'Call John', status: 'open' })).toBeUndefined();
16
+ expect(readItemSync({ sync_state: '' })).toBeUndefined();
17
+ });
18
+
19
+ it('unsynced is only ever explicit', () => {
20
+ expect(readItemSync({ sync_state: 'unsynced' })).toEqual({ state: 'unsynced' });
21
+ });
22
+
23
+ it('pending and conflict and remote_deleted are known states; garbage is ignored', () => {
24
+ expect(readItemSync({ sync_state: 'pending', external_id: 'x' })?.state).toBe('pending');
25
+ expect(readItemSync({ sync_state: 'conflict', external_id: 'x' })?.state).toBe('conflict');
26
+ expect(readItemSync({ sync_state: 'weird' })).toBeUndefined();
27
+ });
28
+ });
29
+
30
+ describe('the chip', () => {
31
+ it('names the tracker from data, never from a constant', () => {
32
+ const chip = syncChip({ state: 'synced', key: 'ENG-7', url: 'https://x/y', stateName: 'Todo' }, 'Linear');
33
+ expect(chip.identifier).toBe('ENG-7');
34
+ expect(chip.stateLabel).toBe('Todo');
35
+ expect(chip.openLabel).toBe('Open in Linear');
36
+ expect(chip.badge).toMatchObject({ text: 'Synced', tone: 'ok' });
37
+ expect(syncChip({ state: 'synced', key: 'A-1' }, 'Asana').openLabel).toBe('Open in Asana');
38
+ expect(syncChip({ state: 'synced', key: 'A-1', url: 'u' }).openLabel).toBe('Open in tracker');
39
+ });
40
+
41
+ it('error and conflict read Out of sync and carry the last error', () => {
42
+ const e = syncChip({ state: 'error', error: 'boom' }, 'Linear');
43
+ expect(e.badge).toMatchObject({ text: 'Out of sync', tone: 'error', detail: 'boom' });
44
+ expect(e.badge.a11y).toBe('Out of sync with Linear: boom');
45
+ const c = syncChip({ state: 'conflict' }, 'Linear');
46
+ expect(c.badge).toMatchObject({ text: 'Out of sync', tone: 'warn' });
47
+ expect(c.badge.a11y).toBe('Sync conflict with Linear');
48
+ });
49
+
50
+ it('unsynced is the Tandem only chip; pending is Syncing', () => {
51
+ expect(syncChip({ state: 'unsynced' }, 'Linear').badge).toMatchObject({ text: 'Tandem only', tone: 'muted' });
52
+ expect(syncChip({ state: 'pending', key: 'A-1' }, 'Linear').badge).toMatchObject({ text: 'Syncing', tone: 'pending' });
53
+ expect(syncChip({ state: 'remote_deleted', key: 'A-1' }, 'Linear').badge.text).toBe('Removed in Linear');
54
+ });
55
+ });
56
+
57
+ describe('links', () => {
58
+ it('maps a tracker https url to its app scheme from one table', () => {
59
+ expect(appLinkFor('https://linear.app/eng/issue/ENG-7/slug')).toBe('linear://eng/issue/ENG-7/slug');
60
+ expect(appLinkFor('https://example.com/a')).toBeNull();
61
+ expect(appLinkFor('not a url')).toBeNull();
62
+ });
63
+
64
+ it('opens the app link, falling back to https when it rejects', async () => {
65
+ const openURL = vi.fn().mockRejectedValueOnce(new Error('no app')).mockResolvedValue(undefined);
66
+ await openTrackerLink('https://linear.app/eng/issue/ENG-7/s', openURL);
67
+ expect(openURL.mock.calls.map((c) => c[0])).toEqual(['linear://eng/issue/ENG-7/s', 'https://linear.app/eng/issue/ENG-7/s']);
68
+ });
69
+
70
+ it('opens https straight away for an unmapped host', async () => {
71
+ const openURL = vi.fn().mockResolvedValue(undefined);
72
+ await openTrackerLink('https://example.com/t/1', openURL);
73
+ expect(openURL.mock.calls.map((c) => c[0])).toEqual(['https://example.com/t/1']);
74
+ });
75
+ });
76
+
77
+ describe('task_sync config', () => {
78
+ it('reads the block off the connection and defaults it', () => {
79
+ expect(readTaskSync({ config: {} })).toEqual({});
80
+ expect(readTaskSync({ config: { task_sync: { default_container_id: 't1', project_focus: { p: 'f' } } } }))
81
+ .toEqual({ default_container_id: 't1', project_focus: { p: 'f' } });
82
+ });
83
+
84
+ it('edits keep every other field (the server replaces the block whole)', () => {
85
+ const next = withTaskSync({ config: { task_sync: { default_container_id: 't1', assignee_id: 'u1', state_overrides: { s: 'blocked' } } } }, { default_project_id: 'p1' });
86
+ expect(next).toEqual({ default_container_id: 't1', assignee_id: 'u1', state_overrides: { s: 'blocked' }, default_project_id: 'p1' });
87
+ });
88
+
89
+ it('empty values are dropped rather than saved as blanks', () => {
90
+ expect(withTaskSync({ config: { task_sync: { default_container_id: 't1' } } }, { default_container_id: '' })).toEqual({});
91
+ });
92
+
93
+ it('state rows show the type default and the override', () => {
94
+ const rows = stateRows([
95
+ { id: 's1', name: 'Todo', type: 'unstarted' }, { id: 's2', name: 'In Progress', type: 'started' },
96
+ ], { s2: 'blocked' });
97
+ expect(rows).toEqual([
98
+ { id: 's1', name: 'Todo', type: 'unstarted', defaultStatus: 'open', status: 'open', overridden: false },
99
+ { id: 's2', name: 'In Progress', type: 'started', defaultStatus: 'in_progress', status: 'blocked', overridden: true },
100
+ ]);
101
+ });
102
+
103
+ it('a task tracker is whatever the catalog says kind is', () => {
104
+ expect(isTaskTracker({ kind: 'task_tracker' })).toBe(true);
105
+ expect(isTaskTracker({ kind: '' })).toBe(false);
106
+ expect(isTaskTracker(undefined)).toBe(false);
107
+ });
108
+ });
@@ -0,0 +1,87 @@
1
+ /**
2
+ * To-do rows show their tracker truth (bd startsim-2nn3h): identifier, the
3
+ * tracker's state, a deep link, and an honest sync badge. The tracker's name is
4
+ * data (`trackerName`), never a constant in the row.
5
+ */
6
+ import { describe, expect, it } from 'vitest';
7
+ import { render, screen } from '@testing-library/react';
8
+
9
+ import { WorkItemRow, WORK_ITEM_DEFAULTS } from '../components/pages/work-items';
10
+ import { toCommitment, type TenantEntity } from '../corpus/entities';
11
+
12
+ const entity = (data: Record<string, unknown>): TenantEntity => ({
13
+ id: 'e1', external_id: 'commit:e1', name: 'Call John', entity_type: 'commitment', version: 1,
14
+ data: { title: 'Call John', status: 'open', subtype: 'action', mentions: [], ...data },
15
+ } as unknown as TenantEntity);
16
+
17
+ const row = (data: Record<string, unknown>, trackerName?: string) =>
18
+ render(<WorkItemRow item={toCommitment(entity(data), { orgId: 'o' })} now={Date.parse('2026-11-05T00:00:00Z')} classNames={WORK_ITEM_DEFAULTS} trackerName={trackerName} />);
19
+
20
+ describe('a to-do linked to a tracker', () => {
21
+ it('shows the identifier, the tracker state and a deep link', () => {
22
+ row({ external_id: 'x', external_key: 'ENG-7', external_url: 'https://linear.app/eng/issue/ENG-7/call', state_name: 'In Progress', sync_state: 'synced' }, 'Linear');
23
+ const link = screen.getByRole('link', { name: 'Open in Linear: ENG-7' });
24
+ expect(link).toHaveAttribute('href', 'https://linear.app/eng/issue/ENG-7/call');
25
+ expect(screen.getByText('In Progress')).toBeInTheDocument();
26
+ expect(screen.getByLabelText('Synced with Linear')).toHaveTextContent('Synced');
27
+ });
28
+
29
+ it('flags out-of-sync with the last error as its tooltip', () => {
30
+ row({ external_id: 'x', external_key: 'ENG-7', sync_state: 'error', sync_error: 'rate limited' }, 'Linear');
31
+ const badge = screen.getByLabelText('Out of sync with Linear: rate limited');
32
+ expect(badge).toHaveTextContent('Out of sync');
33
+ expect(badge).toHaveAttribute('title', 'rate limited');
34
+ });
35
+
36
+ it('flags a conflict as out of sync too', () => {
37
+ row({ external_id: 'x', external_key: 'ENG-7', sync_state: 'conflict' }, 'Linear');
38
+ expect(screen.getByLabelText('Sync conflict with Linear')).toHaveTextContent('Out of sync');
39
+ });
40
+
41
+ it('reads camelCased keys the browser client produces', () => {
42
+ row({ externalId: 'x', externalKey: 'ENG-9', syncState: 'pending' }, 'Linear');
43
+ expect(screen.getByText('ENG-9')).toBeInTheDocument();
44
+ expect(screen.getByLabelText('Waiting to sync with Linear')).toBeInTheDocument();
45
+ });
46
+ });
47
+
48
+ describe('a Tandem-only to-do', () => {
49
+ it('gets the Tandem only chip when the engine marked it unsynced', () => {
50
+ row({ sync_state: 'unsynced' }, 'Linear');
51
+ expect(screen.getByLabelText('Only in Tandem, not sent to Linear')).toHaveTextContent('Tandem only');
52
+ });
53
+
54
+ it('a workspace with no tracker renders no chip at all', () => {
55
+ const { container } = row({});
56
+ expect(container.querySelector('[data-sync-state]')).toBeNull();
57
+ expect(screen.queryByRole('status')).toBeNull();
58
+ });
59
+ });
60
+
61
+ describe('naming the tracker', () => {
62
+ it('finds the connected tracker through the member connections client', async () => {
63
+ const { renderHook, waitFor } = await import('@testing-library/react');
64
+ const { useTrackerName } = await import('../task-tracker/useTrackerName');
65
+ const api = {
66
+ connectorCatalog: async () => ({ results: [{ key: 'a', kind: 'task_tracker' }, { key: 'b', kind: '' }] }),
67
+ connections: async () => ({ results: [
68
+ { connector_key: 'b', connector_name: 'Mail', status: 'connected' },
69
+ { connector_key: 'a', connector_name: 'Trackly', status: 'connected' },
70
+ ] }),
71
+ } as never;
72
+ const { result } = renderHook(() => useTrackerName(api));
73
+ await waitFor(() => expect(result.current).toBe('Trackly'));
74
+ });
75
+
76
+ it('is undefined with no tracker connected', async () => {
77
+ const { renderHook, waitFor } = await import('@testing-library/react');
78
+ const { useTrackerName } = await import('../task-tracker/useTrackerName');
79
+ const api = {
80
+ connectorCatalog: async () => ({ results: [{ key: 'a', kind: 'task_tracker' }] }),
81
+ connections: async () => ({ results: [{ connector_key: 'a', connector_name: 'Trackly', status: 'disabled' }] }),
82
+ } as never;
83
+ const { result } = renderHook(() => useTrackerName(api));
84
+ await new Promise((r) => setTimeout(r, 20));
85
+ expect(result.current).toBeUndefined();
86
+ });
87
+ });
@@ -38,6 +38,7 @@
38
38
  */
39
39
  import type {
40
40
  Connection,
41
+ ConnectionChoicePage,
41
42
  ConnectionInstructions,
42
43
  ConnectionPermissions,
43
44
  ConnectionRun,
@@ -161,6 +162,19 @@ function build(request: Requester): MemberConnectionsApi {
161
162
  return request<{ queued: boolean }>(`${BASE}/${id}/sync/`, { method: 'POST', body: {} });
162
163
  },
163
164
 
165
+ /**
166
+ * What my task-tracker account reaches: `kind` is team, project, state or user.
167
+ * Read-only, and the server refuses it on any connector that is not a task
168
+ * tracker (bd startsim-v95xs.5).
169
+ */
170
+ connectionChoices(id: string, params?: { kind?: string; cursor?: string }): Promise<ConnectionChoicePage> {
171
+ const q = new URLSearchParams();
172
+ if (params?.kind) q.set('kind', params.kind);
173
+ if (params?.cursor) q.set('cursor', params.cursor);
174
+ const qs = q.toString();
175
+ return request<ConnectionChoicePage>(`${BASE}/${id}/choices/${qs ? `?${qs}` : ''}`);
176
+ },
177
+
164
178
  /**
165
179
  * Rotate MY key. The old one stays live until the new one passes `check()`,
166
180
  * so a bad paste changes nothing. A PARTIAL map is legal and normal: send the
@@ -42,6 +42,10 @@ export { FolderTree, folderTrail } from './FolderTree';
42
42
  export type { FolderSource, FolderTreeProps, FolderTreeSlot } from './FolderTree';
43
43
  export * from './pages/AskPage';
44
44
  export * from './pages/TrackerPage';
45
+ // Task-tracker pieces (bd startsim-2nn3h): the sync settings and the link chip.
46
+ export { TaskTrackerSettings } from './pages/task-tracker/TaskTrackerSettings';
47
+ export type { TaskTrackerSettingsApi, TaskTrackerSettingsProps } from './pages/task-tracker/TaskTrackerSettings';
48
+ export { ExternalLinkChip } from './pages/task-tracker/ExternalLinkChip';
45
49
 
46
50
  // The planning toolset (bd startsim-8l6ef): focuses, and the items filed under
47
51
  // them. `work-items` carries the pieces the tracker and the planner SHARE — the
@@ -57,6 +57,8 @@ import type {
57
57
  MemberConnectionsApi,
58
58
  } from './types';
59
59
  import { MemberConnectionRoster } from './MemberConnectionRoster';
60
+ import { TaskTrackerSettings } from './task-tracker/TaskTrackerSettings';
61
+ import { isTaskTracker } from '../../task-tracker/sync-config';
60
62
 
61
63
  type ClassNames = Partial<Record<
62
64
  'root' | 'section' | 'heading' | 'card' | 'button' | 'muted' | 'error', string
@@ -128,6 +130,8 @@ interface BoundApi {
128
130
  ): Promise<Connection>;
129
131
  connectionChoices?(id: string, params?: { kind?: string; cursor?: string }):
130
132
  Promise<ConnectionChoicePage>;
133
+ /** Task-tracker connections: sync now (bd startsim-el0zf). */
134
+ syncConnectionNow?(id: string): Promise<{ queued: boolean }>;
131
135
  wireTarget?(id: string, input: {
132
136
  choice_id: string; name?: string; options?: Record<string, unknown>;
133
137
  }): Promise<ConnectionTarget>;
@@ -1162,6 +1166,12 @@ function ConnectionCard({
1162
1166
  }
1163
1167
 
1164
1168
  const configFields = schemaFields(entry?.config_schema);
1169
+ // A TASK TRACKER (the catalog says `kind: task_tracker`; no vendor is named here)
1170
+ // also gets its sync settings: team, project, personal destination, state mapping.
1171
+ const trackerApi = isTaskTracker(entry) && api.connectionChoices && api.updateConnectionConfig
1172
+ ? { connectionChoices: api.connectionChoices, updateConnectionConfig: api.updateConnectionConfig,
1173
+ ...(api.syncConnectionNow ? { syncConnectionNow: api.syncConnectionNow } : {}) }
1174
+ : null;
1165
1175
 
1166
1176
  return (
1167
1177
  <div className={cn.card} data-connection={connection.id}>
@@ -1268,7 +1278,7 @@ function ConnectionCard({
1268
1278
  name and what it may do stay the foundry's. One gate for both
1269
1279
  would have made opening this control open the capability Save
1270
1280
  beside it, which is a decision this change did not make. */}
1271
- {configFields.length && api.updateConnectionConfig ? (
1281
+ {(configFields.length || trackerApi) && api.updateConnectionConfig ? (
1272
1282
  <button
1273
1283
  type="button"
1274
1284
  className={cn.button}
@@ -1340,7 +1350,16 @@ function ConnectionCard({
1340
1350
  </div>
1341
1351
  ) : null}
1342
1352
 
1343
- {settingsOpen ? (
1353
+ {settingsOpen && trackerApi ? (
1354
+ <TaskTrackerSettings
1355
+ api={trackerApi}
1356
+ connection={connection}
1357
+ classNames={cn}
1358
+ onSaved={() => { setNotice('Sync settings saved.'); onChanged(); }}
1359
+ />
1360
+ ) : null}
1361
+
1362
+ {settingsOpen && configFields.length ? (
1344
1363
  <ConnectionSettingsForm
1345
1364
  api={api}
1346
1365
  connection={connection}
@@ -1380,6 +1399,11 @@ function ConnectionCard({
1380
1399
  here, marked disabled, and you can connect it again later with a new
1381
1400
  key.
1382
1401
  </p>
1402
+ {trackerApi ? (
1403
+ <p className={cn.muted}>
1404
+ {`Your to-dos stay in Tandem. Nothing is deleted in ${connection.connector_name}; they simply stop syncing.`}
1405
+ </p>
1406
+ ) : null}
1383
1407
  <div className="flex gap-2">
1384
1408
  <button
1385
1409
  type="button"
@@ -28,6 +28,8 @@ import * as React from 'react';
28
28
 
29
29
  import { isStalled, runCoverage, runProgress } from '../../corpus/runs';
30
30
  import { stripMarkdown } from '../Markdown';
31
+ import { useTrackerName } from '../../task-tracker/useTrackerName';
32
+ import type { MemberConnectionsApi } from './types';
31
33
  import {
32
34
  UnfilteredNotice,
33
35
  WorkItemRow,
@@ -78,6 +80,17 @@ export interface TrackerPageProps {
78
80
  * over a day of ten-minute sweeps.
79
81
  */
80
82
  maxAutoResumes?: number;
83
+ /**
84
+ * The display name of the task tracker this workspace syncs with (the
85
+ * connection's `connector_name`). Rows that carry a tracker link name it in
86
+ * "Open in <tracker>"; unset reads "Open in tracker".
87
+ */
88
+ trackerName?: string;
89
+ /**
90
+ * Pass the member connections client and the page finds the connected tracker's
91
+ * name itself (when `trackerName` is not given).
92
+ */
93
+ memberConnections?: Pick<MemberConnectionsApi, 'connections' | 'connectorCatalog'>;
81
94
  classNames?: Partial<Record<TrackerSlot, string>>;
82
95
  }
83
96
 
@@ -125,8 +138,12 @@ export function TrackerPage({
125
138
  now,
126
139
  pollMs = 3_000,
127
140
  maxAutoResumes = 24,
141
+ trackerName: trackerNameProp,
142
+ memberConnections,
128
143
  classNames = {},
129
144
  }: TrackerPageProps) {
145
+ const foundTracker = useTrackerName(trackerNameProp ? undefined : memberConnections);
146
+ const trackerName = trackerNameProp ?? foundTracker;
130
147
  const cn = { ...DEFAULTS, ...classNames };
131
148
  const [sweepEpoch, setSweepEpoch] = React.useState(0);
132
149
 
@@ -463,6 +480,7 @@ export function TrackerPage({
463
480
  now={clock}
464
481
  classNames={cn}
465
482
  onOpenDocument={onOpenDocument}
483
+ trackerName={trackerName}
466
484
  />
467
485
  ))}
468
486
  </section>
@@ -0,0 +1,53 @@
1
+ /**
2
+ * A to-do's link to its task tracker: identifier, the tracker's own state, a deep
3
+ * link out and the sync badge (bd startsim-2nn3h). Reads the shared chip model, so
4
+ * the web and the phone say the same thing. Renders nothing for an item with no
5
+ * sync facts.
6
+ */
7
+ import * as React from 'react';
8
+
9
+ import { syncChip, type BadgeTone, type ItemSync } from '../../../task-tracker/item-sync';
10
+
11
+ const TONES: Record<BadgeTone, string> = {
12
+ ok: 'border-green-300 text-green-800',
13
+ pending: 'border-blue-300 text-blue-800',
14
+ warn: 'border-amber-400 text-amber-900 bg-amber-50',
15
+ error: 'border-red-400 text-red-800 bg-red-50',
16
+ muted: 'border-gray-300 text-gray-600',
17
+ };
18
+
19
+ export function ExternalLinkChip({ sync, trackerName, className }: {
20
+ sync: ItemSync | undefined;
21
+ /** The tracker's display name (the connection's `connector_name`). */
22
+ trackerName?: string;
23
+ className?: string;
24
+ }) {
25
+ if (!sync) return null;
26
+ const chip = syncChip(sync, trackerName);
27
+ const base = className ?? 'inline-flex items-center rounded-full border px-2 py-0.5 text-xs';
28
+ return (
29
+ <span className="inline-flex flex-wrap items-center gap-1.5" data-sync-state={sync.state}>
30
+ {chip.identifier ? (
31
+ chip.url ? (
32
+ <a
33
+ href={chip.url} target="_blank" rel="noreferrer"
34
+ className={`${base} border-gray-300 text-blue-700 underline`}
35
+ aria-label={`${chip.openLabel}: ${chip.identifier}`}
36
+ title={chip.openLabel}
37
+ >
38
+ {chip.identifier}
39
+ </a>
40
+ ) : <span className={`${base} border-gray-300 text-gray-700`}>{chip.identifier}</span>
41
+ ) : null}
42
+ {chip.stateLabel ? <span className={`${base} border-gray-300 text-gray-700`}>{chip.stateLabel}</span> : null}
43
+ <span
44
+ className={`${base} ${TONES[chip.badge.tone]}`}
45
+ title={chip.badge.detail}
46
+ aria-label={chip.badge.a11y}
47
+ role="status"
48
+ >
49
+ {chip.badge.text}
50
+ </span>
51
+ </span>
52
+ );
53
+ }