@startsimpli/integrations 0.2.130 → 0.2.132

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 (40) hide show
  1. package/package.json +4 -4
  2. package/src/__tests__/connectable-entries.test.tsx +45 -0
  3. package/src/__tests__/connections.test.tsx +5 -1
  4. package/src/__tests__/task-tracker-connection.test.tsx +155 -0
  5. package/src/__tests__/task-tracker-shared.test.ts +108 -0
  6. package/src/__tests__/tracker-linear-chip.test.tsx +87 -0
  7. package/src/api/connections.ts +14 -0
  8. package/src/components/index.ts +4 -0
  9. package/src/components/pages/ConnectionsPage.tsx +28 -3
  10. package/src/components/pages/TrackerPage.tsx +18 -0
  11. package/src/components/pages/connectable-entries.ts +19 -0
  12. package/src/components/pages/task-tracker/ExternalLinkChip.tsx +53 -0
  13. package/src/components/pages/task-tracker/TaskTrackerSettings.tsx +112 -0
  14. package/src/components/pages/types.ts +4 -0
  15. package/src/components/pages/work-items.tsx +8 -1
  16. package/src/corpus/entities.ts +15 -0
  17. package/src/corpus/types.ts +3 -0
  18. package/src/index.ts +2 -0
  19. package/src/native/__tests__/task-tracker.test.tsx +206 -0
  20. package/src/native/app/FoundryApp.tsx +1 -1
  21. package/src/native/app/data.ts +5 -1
  22. package/src/native/app/registry.tsx +4 -2
  23. package/src/native/corpus/fake-data.ts +3 -3
  24. package/src/native/corpus/fake-tenant.ts +3 -0
  25. package/src/native/screens/connections/ConnectionsScreens.tsx +52 -12
  26. package/src/native/screens/connections/controller.ts +71 -1
  27. package/src/native/screens/connections/fake.ts +38 -7
  28. package/src/native/screens/connections/tab.tsx +25 -7
  29. package/src/native/task-tracker/SyncChips.tsx +35 -0
  30. package/src/native/task-tracker/TrackerSettingsScreen.tsx +85 -0
  31. package/src/native/task-tracker/index.ts +2 -0
  32. package/src/native/tracker/TrackerDetailScreen.tsx +14 -1
  33. package/src/native/tracker/TrackerListScreen.tsx +7 -1
  34. package/src/native/tracker/tab.tsx +16 -7
  35. package/src/task-tracker/index.ts +5 -0
  36. package/src/task-tracker/item-sync.ts +87 -0
  37. package/src/task-tracker/links.ts +34 -0
  38. package/src/task-tracker/settings-controller.ts +138 -0
  39. package/src/task-tracker/sync-config.ts +95 -0
  40. package/src/task-tracker/useTrackerName.ts +29 -0
@@ -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
+ }
@@ -0,0 +1,112 @@
1
+ /**
2
+ * The settings of a connected TASK TRACKER, from data alone (bd startsim-2nn3h).
3
+ *
4
+ * Team, default project, personal destination, assignee and the state mapping are
5
+ * all PICKED from what the connection's own account reaches (`connectionChoices`),
6
+ * never typed as ids. They save as `config.task_sync`, which the server replaces
7
+ * whole, so every save sends the stored block with the edit laid over it.
8
+ *
9
+ * Names no vendor: labels come from the choices, and the tracker's name (for
10
+ * sentences) from the connection's `connector_name`.
11
+ */
12
+ import * as React from 'react';
13
+
14
+ import type { Connection } from '../types';
15
+ import {
16
+ STATUS_OPTIONS, type TaskSyncConfig, type TrackerStatus,
17
+ } from '../../../task-tracker/sync-config';
18
+ import {
19
+ createSettingsController, type SettingsApi,
20
+ } from '../../../task-tracker/settings-controller';
21
+
22
+ export type TaskTrackerSettingsApi = SettingsApi;
23
+
24
+ export interface TaskTrackerSettingsProps {
25
+ api: TaskTrackerSettingsApi;
26
+ connection: Connection;
27
+ classNames: { button: string; muted: string; error: string };
28
+ onSaved: (saved: Connection) => void;
29
+ }
30
+
31
+ export function TaskTrackerSettings({ api, connection, classNames: cn, onSaved }: TaskTrackerSettingsProps) {
32
+ const tracker = connection.connector_name || 'the tracker';
33
+ const controller = React.useMemo(
34
+ () => createSettingsController({ api, connection, onSaved }),
35
+ // One controller per connection: a re-render with the same card keeps the edits.
36
+ // eslint-disable-next-line react-hooks/exhaustive-deps
37
+ [api, connection.id],
38
+ );
39
+ const s = React.useSyncExternalStore(controller.subscribe, controller.getState, controller.getState);
40
+ React.useEffect(() => { void controller.load(); }, [controller]);
41
+
42
+ function picker(label: string, key: 'default_container_id' | 'default_project_id' | 'personal_container_id' | 'assignee_id',
43
+ kind: 'team' | 'project' | 'user', none: string) {
44
+ const rows = s.choices[kind] ?? [];
45
+ return (
46
+ <label className="block text-sm">
47
+ <span className="block font-medium text-gray-900">{label}</span>
48
+ <select
49
+ className="mt-1 w-full rounded-md border border-gray-300 p-2 text-sm"
50
+ value={(s.value[key] as string | undefined) ?? ''}
51
+ disabled={s.loading}
52
+ onChange={(e) => controller.set({ [key]: e.target.value } as Partial<TaskSyncConfig>)}
53
+ >
54
+ <option value="">{none}</option>
55
+ {rows.map((r) => <option key={r.id} value={r.id}>{r.label}</option>)}
56
+ </select>
57
+ </label>
58
+ );
59
+ }
60
+
61
+ return (
62
+ <div className="mt-3 space-y-3 border-t pt-3" role="group" aria-label={`${tracker} sync settings`}>
63
+ {s.loading ? <p className={cn.muted}>{`Reading your ${tracker} workspace…`}</p> : null}
64
+ {picker('New to-dos go to team', 'default_container_id', 'team', 'Not set (to-dos stay in Tandem)')}
65
+ {picker('Default project', 'default_project_id', 'project', 'No project')}
66
+ {picker('Personal to-dos go to', 'personal_container_id', 'team', 'Keep personal to-dos in Tandem only')}
67
+ {picker(`Also bring in ${tracker} issues assigned to`, 'assignee_id', 'user', 'Nobody in particular')}
68
+
69
+ <div>
70
+ <p className="text-sm font-medium text-gray-900">{`${tracker} states and Tandem status`}</p>
71
+ {s.rows.length === 0 && !s.loading ? <p className={cn.muted}>No states found.</p> : null}
72
+ <table className="mt-1 w-full text-sm" aria-label="State mapping">
73
+ <tbody>
74
+ {s.rows.map((row) => (
75
+ <tr key={row.id} data-state={row.id}>
76
+ <td className="py-1 pr-3">{row.name}</td>
77
+ <td className="py-1">
78
+ <select
79
+ aria-label={`Tandem status for ${row.name}`}
80
+ className="rounded-md border border-gray-300 p-1 text-sm"
81
+ value={row.status}
82
+ onChange={(e) => controller.setStatus(row.id, e.target.value as TrackerStatus)}
83
+ >
84
+ {STATUS_OPTIONS.map((o) => (
85
+ <option key={o.value} value={o.value}>
86
+ {o.label}{o.value === row.defaultStatus ? ' (default)' : ''}
87
+ </option>
88
+ ))}
89
+ </select>
90
+ </td>
91
+ </tr>
92
+ ))}
93
+ </tbody>
94
+ </table>
95
+ </div>
96
+
97
+ {s.error ? <p className={cn.error} role="alert">{s.error}</p> : null}
98
+ {s.note ? <p className={cn.muted} role="status">{s.note}</p> : null}
99
+ <div className="flex flex-wrap items-center gap-2">
100
+ <button type="button" className={cn.button} disabled={s.saving || s.syncing || !s.changed} onClick={() => void controller.save()}>
101
+ {s.saving ? 'Saving…' : 'Save sync settings'}
102
+ </button>
103
+ {s.canSync ? (
104
+ <button type="button" className={cn.button} disabled={s.saving || s.syncing} onClick={() => void controller.syncNow()}>
105
+ {s.syncing ? 'Syncing…' : 'Sync now'}
106
+ </button>
107
+ ) : null}
108
+ {!s.changed ? <span className={cn.muted}>Nothing changed yet.</span> : null}
109
+ </div>
110
+ </div>
111
+ );
112
+ }
@@ -87,6 +87,8 @@ export interface ConnectorCatalogEntry {
87
87
  docs_url: string;
88
88
  capabilities: string[];
89
89
  auth_mode: string;
90
+ /** `task_tracker` for a connector that syncs to-dos; empty for the rest. */
91
+ kind?: string;
90
92
  credential_schema: ConnectorSchemaLike;
91
93
  config_schema: ConnectorSchemaLike;
92
94
  record_types: string[];
@@ -440,6 +442,8 @@ export interface MemberConnectionsApi {
440
442
  }>;
441
443
  /** Task-tracker connections: push what is pending now (bd startsim-el0zf). Optional for older clients. */
442
444
  syncConnectionNow?(id: string): Promise<{ queued: boolean }>;
445
+ /** What a task-tracker account reaches (teams, projects, states, users): `kind` picks the list. */
446
+ connectionChoices?(id: string, params?: { kind?: string; cursor?: string }): Promise<ConnectionChoicePage>;
443
447
  rotateCredential(id: string, credentials: Record<string, unknown>): Promise<Connection>;
444
448
  disconnect(id: string): Promise<void>;
445
449
  connectionRuns(id: string): Promise<{ results: ConnectionRun[] }>;
@@ -22,6 +22,7 @@ import * as React from 'react';
22
22
  import { isAuthored } from '../../corpus/planning';
23
23
  import { stripMarkdown } from '../Markdown';
24
24
  import type { Commitment } from '../../corpus/types';
25
+ import { ExternalLinkChip } from './task-tracker/ExternalLinkChip';
25
26
 
26
27
  export type WorkItemSlot =
27
28
  | 'badge' | 'muted' | 'row' | 'due' | 'warning';
@@ -98,7 +99,7 @@ export function UnfilteredNotice<K extends string>({
98
99
  * tell you which is which.
99
100
  */
100
101
  export function WorkItemRow({
101
- item, now, classNames: cn, onOpenDocument, actions,
102
+ item, now, classNames: cn, onOpenDocument, actions, trackerName,
102
103
  }: {
103
104
  item: Commitment;
104
105
  now: number;
@@ -106,6 +107,8 @@ export function WorkItemRow({
106
107
  onOpenDocument?: (documentId: string) => void;
107
108
  /** Per-row controls the host screen owns (file, edit, complete). */
108
109
  actions?: React.ReactNode;
110
+ /** The task tracker's display name, for the link chip ("Open in <tracker>"). */
111
+ trackerName?: string;
109
112
  }) {
110
113
  const overdue = isOverdue(item, now);
111
114
  const age = item.firstSeenAt ? Math.floor((now - Date.parse(item.firstSeenAt)) / DAY_MS) : null;
@@ -150,6 +153,10 @@ export function WorkItemRow({
150
153
  ) : null}
151
154
  </div>
152
155
 
156
+ {item.sync ? (
157
+ <div className="mt-2"><ExternalLinkChip sync={item.sync} trackerName={trackerName} className={cn.badge} /></div>
158
+ ) : null}
159
+
153
160
  {item.detail ? <p className="mt-2 text-sm text-gray-700">{item.detail}</p> : null}
154
161
 
155
162
  {item.statusReason ? (
@@ -23,6 +23,7 @@
23
23
  * row with a missing subtitle.
24
24
  */
25
25
  import { withSourceEntity } from './source-entity';
26
+ import { readItemSync, type ItemSync } from '../task-tracker/item-sync';
26
27
  import { filingsFromRow } from './voice-sections';
27
28
  import type {
28
29
  Commitment,
@@ -735,6 +736,7 @@ export function toCommitment(
735
736
  // server-side fetch does not.
736
737
  ...(pick(data, ORIGIN_KEY, 'Origin')
737
738
  ? { origin: asText(pick(data, ORIGIN_KEY, 'Origin')) } : {}),
739
+ ...withSync(data),
738
740
  mentions,
739
741
  firstSeenAt: asIso(pick(data, 'first_seen_at', 'firstSeenAt')),
740
742
  lastSeenAt: asIso(pick(data, 'last_seen_at', 'lastSeenAt')),
@@ -746,6 +748,19 @@ export function toCommitment(
746
748
  }, entity);
747
749
  }
748
750
 
751
+ /** The tracker link facts, in either key spelling (the browser client camelCases data keys). */
752
+ function withSync(data: Record<string, unknown>): { sync?: ItemSync } {
753
+ const sync = readItemSync({
754
+ external_id: pick(data, 'external_id', 'externalId'),
755
+ external_key: pick(data, 'external_key', 'externalKey'),
756
+ external_url: pick(data, 'external_url', 'externalUrl'),
757
+ state_name: pick(data, 'state_name', 'stateName'),
758
+ sync_state: pick(data, 'sync_state', 'syncState'),
759
+ sync_error: pick(data, 'sync_error', 'syncError'),
760
+ });
761
+ return sync ? { sync } : {};
762
+ }
763
+
749
764
  function toMention(value: unknown): CommitmentMention | null {
750
765
  if (!value || typeof value !== 'object') return null;
751
766
  const data = value as Record<string, unknown>;
@@ -24,6 +24,7 @@
24
24
  * how a `SourceDocument` is stored. When bd startsim-768w.38.2 lands and the
25
25
  * attribute names shift, `./entities.ts` is the one file that changes.
26
26
  */
27
+ import type { ItemSync } from '../task-tracker/item-sync';
27
28
 
28
29
  /**
29
30
  * Which connector filled a record. FREE-FORM on purpose — `granola`, `dropbox`,
@@ -729,6 +730,8 @@ export interface Commitment {
729
730
  * underscore is load-bearing and why this arrives from a browser as `Origin`.
730
731
  */
731
732
  origin?: string;
733
+ /** Its link to a task tracker (identifier, state, sync health); absent when it has none. */
734
+ sync?: ItemSync;
732
735
  mentions: CommitmentMention[];
733
736
  firstSeenAt: string | null;
734
737
  lastSeenAt: string | null;
package/src/index.ts CHANGED
@@ -12,6 +12,8 @@ export * from './types/index';
12
12
  export * from './api/index';
13
13
  export * from './hooks/index';
14
14
  export * from './components/index';
15
+ // Task-tracker sync (bd startsim-v95xs): what a to-do says about its tracker link, and `config.task_sync`.
16
+ export * from './task-tracker/index';
15
17
 
16
18
  /**
17
19
  * The corpus layer — the READ side of connections (bd startsim-768w.38.6 and
@@ -0,0 +1,206 @@
1
+ /** startsim-04dfc: the phone shows the same task-tracker truth as the web: connect, settings, chips, badge states. */
2
+ import { describe, expect, it, vi } from 'vitest';
3
+ import { act, allText, hostById, maybeById, press, render } from '../../../../ui-native/test/render';
4
+ import { createConnectionsController } from '../screens/connections/controller';
5
+ import { createFakeConnectionsApi } from '../screens/connections/fake';
6
+ import { ConnectionDetailScreen, ConnectionsListScreen } from '../screens/connections/ConnectionsScreens';
7
+ import { createSettingsController } from '../../task-tracker/settings-controller';
8
+ import { TrackerSettingsScreen } from '../task-tracker/TrackerSettingsScreen';
9
+ import { SyncChips } from '../task-tracker/SyncChips';
10
+ import { openTrackerLink } from '../../task-tracker/links';
11
+ import { TrackerListScreen } from '../tracker/TrackerListScreen';
12
+ import { createTrackerController } from '../tracker/controller';
13
+ import { createFakeNativeCorpusApi } from '../corpus/fake';
14
+ import type { Connection } from '../../components/pages/types';
15
+
16
+ const tick = () => new Promise((r) => setTimeout(r, 0));
17
+ const settle = () => act(async () => { await tick(); await tick(); });
18
+ async function until(check: () => boolean) { for (let i = 0; i < 50 && !check(); i += 1) await tick(); }
19
+ const entry = (api: ReturnType<typeof createFakeConnectionsApi>) => api.connectorCatalog().then((c) => c.results.find((e) => e.key === 'linear')!);
20
+
21
+ describe('connect a tracker from the Connections list', () => {
22
+ it('shows a Connect row from the catalog and opens the server consent url untouched', async () => {
23
+ const api = createFakeConnectionsApi();
24
+ const openUrl = vi.fn().mockResolvedValue(undefined);
25
+ const c = createConnectionsController({ api, openUrl, returnTo: 'tandemgo://connections' });
26
+ await until(() => !c.getState().loading);
27
+ const r = render(<ConnectionsListScreen controller={c} onOpen={vi.fn()} />);
28
+ await settle();
29
+ expect(allText(r)).toContain('Connect Linear');
30
+ await act(async () => { press(hostById(r, 'connect-linear')); await tick(); });
31
+ expect(api.calls.started).toEqual(['linear']);
32
+ expect(openUrl).toHaveBeenCalledWith('https://consent.example/linear/authorize?state=fake');
33
+ expect(c.getState().awaitingConsent).toBe(true);
34
+ });
35
+
36
+ it('no opener, no Connect row: the pointer to the web stays', async () => {
37
+ const c = createConnectionsController({ api: createFakeConnectionsApi() });
38
+ await until(() => !c.getState().loading);
39
+ const r = render(<ConnectionsListScreen controller={c} onOpen={vi.fn()} />);
40
+ await settle();
41
+ expect(maybeById(r, 'connect-linear')).toHaveLength(0);
42
+ expect(allText(r)).toContain('Add new accounts on the web');
43
+ });
44
+
45
+ it('coming back from the browser reads the connections and shows it connected', async () => {
46
+ const api = createFakeConnectionsApi();
47
+ const c = createConnectionsController({ api, openUrl: vi.fn().mockResolvedValue(undefined) });
48
+ await until(() => !c.getState().loading);
49
+ await c.connect(await entry(api));
50
+ expect(c.getState().rows.some((r) => r.connector_key === 'linear')).toBe(false);
51
+ api.completeConsent(); // the vendor redirected back to the web page
52
+ await c.returned(); // the app came to the foreground
53
+ expect(c.getState().rows.find((r) => r.connector_key === 'linear')).toMatchObject({ status: 'connected' });
54
+ expect(c.getState().awaitingConsent).toBe(false);
55
+ });
56
+
57
+ it('a sign-in that finishes inside the app is read at once', async () => {
58
+ const api = createFakeConnectionsApi();
59
+ const c = createConnectionsController({ api, openUrl: async () => { api.completeConsent(); return { completed: true }; } });
60
+ await until(() => !c.getState().loading);
61
+ await c.connect(await entry(api));
62
+ expect(c.getState().rows.some((r) => r.connector_key === 'linear')).toBe(true);
63
+ });
64
+
65
+ it('returned() does nothing when no sign-in was started (no needless reads)', async () => {
66
+ const api = createFakeConnectionsApi();
67
+ const c = createConnectionsController({ api, openUrl: vi.fn() });
68
+ await until(() => !c.getState().loading);
69
+ await c.returned();
70
+ expect(api.calls.connections).toBe(1);
71
+ });
72
+
73
+ it('a refused start shows the reason and opens nothing', async () => {
74
+ const api = createFakeConnectionsApi();
75
+ api.startOAuth = vi.fn().mockRejectedValue(new Error('This connector is not open to members.'));
76
+ const openUrl = vi.fn();
77
+ const c = createConnectionsController({ api, openUrl });
78
+ await until(() => !c.getState().loading);
79
+ await c.connect(await entry(api));
80
+ expect(openUrl).not.toHaveBeenCalled();
81
+ expect(c.getState().actionError).toBe('This connector is not open to members.');
82
+ });
83
+ });
84
+
85
+ async function connectedLinear() {
86
+ const api = createFakeConnectionsApi();
87
+ const openUrl = async () => { api.completeConsent(); return { completed: true }; };
88
+ const c = createConnectionsController({ api, openUrl });
89
+ await until(() => !c.getState().loading);
90
+ await c.connect(await entry(api));
91
+ const conn = c.getState().rows.find((r) => r.connector_key === 'linear') as Connection;
92
+ return { api, c, conn };
93
+ }
94
+
95
+ describe('sync settings on the phone', () => {
96
+ it('loads team, project, state and user choices; saving sends the whole task_sync block', async () => {
97
+ const { api, conn } = await connectedLinear();
98
+ await api.updateConnectionConfig!(conn.id, { task_sync: { default_container_id: 'team-eng', project_focus: { p: 'f' } } });
99
+ const stored = (await api.connections()).results.find((r) => r.id === conn.id)!;
100
+ const s = createSettingsController({ api, connection: stored });
101
+ await s.load();
102
+ expect(Object.keys(s.getState().choices)).toEqual(['team', 'project', 'state', 'user']);
103
+ s.set({ default_project_id: 'proj-tandem', personal_container_id: 'team-per' });
104
+ await s.save();
105
+ expect(api.calls.saved.at(-1)).toEqual({ task_sync: {
106
+ default_container_id: 'team-eng', project_focus: { p: 'f' }, default_project_id: 'proj-tandem', personal_container_id: 'team-per',
107
+ } });
108
+ });
109
+
110
+ it('shows the state mapping with defaults and an override', async () => {
111
+ const { api, conn } = await connectedLinear();
112
+ const s = createSettingsController({ api, connection: conn });
113
+ await s.load();
114
+ s.setStatus('st-prog', 'blocked');
115
+ expect(s.getState().rows.map((r) => [r.name, r.status, r.overridden])).toEqual([
116
+ ['Todo', 'open', false], ['In Progress', 'blocked', true], ['Done', 'done', false],
117
+ ]);
118
+ s.setStatus('st-prog', 'in_progress');
119
+ expect(s.getState().rows[1].overridden).toBe(false);
120
+ });
121
+
122
+ it('renders the screen, saves, and Sync now calls the narrow route', async () => {
123
+ const { api, conn } = await connectedLinear();
124
+ const s = createSettingsController({ api, connection: conn });
125
+ const r = render(<TrackerSettingsScreen controller={s} connection={conn} onBack={vi.fn()} />);
126
+ await settle();
127
+ expect(allText(r)).toContain('Where new to-dos go');
128
+ expect(allText(r)).toContain('In Progress');
129
+ await act(async () => { s.set({ default_container_id: 'team-eng' }); });
130
+ await act(async () => { press(hostById(r, 'settings-save')); await tick(); });
131
+ expect(api.calls.saved.at(-1)).toEqual({ task_sync: { default_container_id: 'team-eng' } });
132
+ await act(async () => { press(hostById(r, 'settings-sync-now')); await tick(); });
133
+ expect(api.calls.sync).toEqual([conn.id]);
134
+ });
135
+
136
+ it('the connection screen offers Sync settings and Sync now only for a task tracker, and says nothing is deleted', async () => {
137
+ const { c, conn } = await connectedLinear();
138
+ const open = vi.fn();
139
+ const r = render(<ConnectionDetailScreen controller={c} id={conn.id} onBack={vi.fn()} onOpenSettings={open} />);
140
+ await settle();
141
+ await act(async () => { press(hostById(r, 'connection-sync-settings')); });
142
+ expect(open).toHaveBeenCalledWith(expect.objectContaining({ id: conn.id }));
143
+ await act(async () => { press(hostById(r, 'connection-sync-now')); await tick(); });
144
+ expect(c.getState().syncNote).toMatch(/Syncing with Linear now/);
145
+ await act(async () => { press(hostById(r, 'connection-disconnect')); });
146
+ expect(allText(r)).toContain('Your to-dos stay in Tandem. Nothing is deleted in Linear');
147
+ });
148
+
149
+ it('a calendar connection has neither', async () => {
150
+ const api = createFakeConnectionsApi();
151
+ const c = createConnectionsController({ api });
152
+ await until(() => !c.getState().loading);
153
+ const r = render(<ConnectionDetailScreen controller={c} id="cn1" onBack={vi.fn()} onOpenSettings={vi.fn()} />);
154
+ await settle();
155
+ expect(maybeById(r, 'connection-sync-settings')).toHaveLength(0);
156
+ expect(maybeById(r, 'connection-sync-now')).toHaveLength(0);
157
+ });
158
+ });
159
+
160
+ describe('to-do chips', () => {
161
+ const sync = { state: 'synced' as const, key: 'ENG-12', url: 'https://linear.app/eng/issue/ENG-12/x', stateName: 'In Progress' };
162
+
163
+ it('shows the identifier and state, and tapping the identifier opens the url', () => {
164
+ const open = vi.fn();
165
+ const r = render(<SyncChips sync={sync} trackerName="Linear" onOpen={open} />);
166
+ expect(allText(r)).toContain('ENG-12');
167
+ expect(allText(r)).toContain('In Progress');
168
+ press(hostById(r, 'sync-chips-open'));
169
+ expect(open).toHaveBeenCalledWith(sync.url);
170
+ expect(hostById(r, 'sync-chips-open').props.accessibilityLabel).toBe('Open in Linear: ENG-12');
171
+ });
172
+
173
+ it('the app link is tried first and https is the fallback', async () => {
174
+ const openURL = vi.fn().mockRejectedValueOnce(new Error('no app')).mockResolvedValue(true);
175
+ await openTrackerLink(sync.url, openURL);
176
+ expect(openURL.mock.calls.map((c) => c[0])).toEqual(['linear://eng/issue/ENG-12/x', sync.url]);
177
+ });
178
+
179
+ it.each([
180
+ ['synced', undefined, 'Synced', 'Synced with Linear'],
181
+ ['pending', undefined, 'Syncing', 'Waiting to sync with Linear'],
182
+ ['error', 'rate limited', 'Out of sync', 'Out of sync with Linear: rate limited'],
183
+ ['conflict', undefined, 'Out of sync', 'Sync conflict with Linear'],
184
+ ] as const)('badge %s has text and a spoken label', (state, error, text, a11y) => {
185
+ const r = render(<SyncChips sync={{ state, key: 'ENG-1', ...(error ? { error } : {}) }} trackerName="Linear" />);
186
+ const badge = hostById(r, 'sync-chips-badge');
187
+ expect(allText(r)).toContain(text);
188
+ expect(badge.props.accessibilityLabel).toBe(a11y);
189
+ });
190
+
191
+ it('nothing renders for a to-do with no tracker', () => {
192
+ const r = render(<SyncChips sync={undefined} />);
193
+ expect(maybeById(r, 'sync-chips')).toHaveLength(0);
194
+ });
195
+
196
+ it('the to-do list shows the chips on linked rows only', async () => {
197
+ const controller = createTrackerController({ api: createFakeNativeCorpusApi() });
198
+ const r = render(<TrackerListScreen controller={controller} onOpen={vi.fn()} trackerName="Linear" onOpenLink={vi.fn()} />);
199
+ await act(async () => { await controller.start(); });
200
+ await settle();
201
+ expect(allText(r)).toContain('ENG-12');
202
+ expect(allText(r)).toContain('Out of sync');
203
+ expect(allText(r)).toContain('Tandem only');
204
+ expect(maybeById(r, 'todo-sync-c3')).toHaveLength(0); // an unlinked to-do carries no chip
205
+ });
206
+ });
@@ -131,7 +131,7 @@ function Root({ config, device, registry }: { config: FoundryAppConfig; device:
131
131
  const recordRef = useRef<ReactNode>(record);
132
132
  recordRef.current = record;
133
133
  const tabs = useMemo(
134
- () => buildFoundryTabs({ config: appConfig, corpus: data.corpus, notes: data.notes, record: () => recordRef.current, member: data.member }, registry),
134
+ () => buildFoundryTabs({ config: appConfig, corpus: data.corpus, notes: data.notes, record: () => recordRef.current, member: data.member, openUrl: data.openUrl ?? ((url) => Linking.openURL(url)) }, registry),
135
135
  [appConfig, data, registry],
136
136
  );
137
137
 
@@ -18,6 +18,8 @@ export interface FoundryData {
18
18
  corpus: NativeCorpusApi;
19
19
  notes: VoiceNotesController | null;
20
20
  member: { connections: MemberConnectionsApi; mcpTokens: McpTokensApi };
21
+ /** Replaces the app's URL opener (fakes: a sign-in page that "finishes" in place, since a simulator has no account to sign in with). */
22
+ openUrl?: (url: string) => Promise<unknown>;
21
23
  }
22
24
 
23
25
  /**
@@ -28,11 +30,13 @@ export function createFoundryData(deps: { config: FoundryAppConfig; authorizedFe
28
30
  const { config, authorizedFetch, fake, scenario } = deps;
29
31
  const wantsNotes = config.tabs.some((t) => t.screen === 'notes');
30
32
  if (fake) {
33
+ const fakeConnections = createFakeConnectionsApi({ connections: scenario === 'empty' ? [] : undefined });
31
34
  return {
35
+ openUrl: async () => { fakeConnections.completeConsent(); return { completed: true }; },
32
36
  corpus: createFakeNativeCorpusApi({ scenario, extraEntities: fakeEntityRows(config) }),
33
37
  notes: wantsNotes ? createVoiceNotesController({ api: createFakeVoiceApi({ scenario }) }) : null,
34
38
  member: {
35
- connections: withScenario(createFakeConnectionsApi({ connections: scenario === 'empty' ? [] : undefined }), scenario),
39
+ connections: withScenario(fakeConnections, scenario),
36
40
  mcpTokens: withScenario(createFakeMcpTokensApi(), scenario),
37
41
  },
38
42
  };
@@ -28,6 +28,8 @@ export interface ScreenDeps {
28
28
  record: () => ReactNode;
29
29
  /** Member-level APIs for Connections and Connect Claude. */
30
30
  member: { connections: MemberConnectionsApi; mcpTokens: McpTokensApi };
31
+ /** Opens a URL outside the app (`Linking.openURL`): a vendor's sign-in page, a tracker item. Absent in tests. */
32
+ openUrl?: (url: string) => Promise<unknown>;
31
33
  }
32
34
 
33
35
  /** Builds one shell tab from its config entry. */
@@ -59,11 +61,11 @@ export const BUILTIN_FACTORIES: Record<string, ScreenFactory> = {
59
61
  : <NotesListScreen controller={notes} displays={corpus.schema?.displays} onOpen={(n) => push(n.id)} />),
60
62
  };
61
63
  },
62
- tracker: ({ config, corpus }, tab) => trackerTab({ api: corpus, key: tab.key, label: tabLabel(tab), notesKey: firstKey(config, 'notes') }),
64
+ tracker: ({ config, corpus, member, openUrl }, tab) => trackerTab({ api: corpus, key: tab.key, label: tabLabel(tab), notesKey: firstKey(config, 'notes'), memberConnections: member.connections, openUrl }),
63
65
  library: ({ corpus }, tab) => libraryTab(corpus, { key: tab.key, label: tabLabel(tab) }),
64
66
  ask: ({ corpus }, tab) => askTab(corpus, { key: tab.key, label: tabLabel(tab) }),
65
67
  planning: ({ config, corpus }, tab) => createPlanningTab({ api: corpus, key: tab.key, label: tabLabel(tab), documentTab: firstKey(config, 'library') }),
66
- connections: ({ member }, tab) => createConnectionsTab({ api: member.connections, key: tab.key, label: tabLabel(tab) }),
68
+ connections: ({ config, member, openUrl }, tab) => createConnectionsTab({ api: member.connections, key: tab.key, label: tabLabel(tab), openUrl, returnTo: `${config.app.scheme}://${tab.key}` }),
67
69
  'connect-claude': ({ member }, tab) => createConnectClaudeTab({ api: member.mcpTokens, key: tab.key, label: tab.label ?? `Claude` }),
68
70
  entity: ({ config, corpus }, tab) => {
69
71
  const type = String(tab.options?.entityType);
@@ -24,10 +24,10 @@ export function sampleTenantEntities(): TenantEntity[] {
24
24
  row('fma', 'focus', 'focus:marketing-agents', 'Marketing agents', '2026-09-02T00:00:00Z', { title: 'Marketing agents', status: 'on_track', category: 'product', progress: 0.7, sort_order: 2 }),
25
25
  row('fdbg', 'focus', 'focus:debug', 'Debug', '2026-09-03T00:00:00Z', { title: 'Debug', status: 'at_risk', category: 'team', progress: 0.2, sort_order: 3 }),
26
26
 
27
- commitment('c1', 'Finish exhibit list', '2026-11-03T14:40:00Z', { status: 'open', owner_name: 'Quinn', due_at: '2026-11-05T17:00:00Z', priority: 1, detail: 'Needed before the hearing.', mentions: [mention('n1', '2026-11-03T14:38:00Z', 'I still have to finish the exhibit list before the hearing.', 'Hearing prep')] }),
28
- commitment('c2', 'Call Megan about the filing receipt', '2026-11-03T14:41:00Z', { status: 'open', owner_name: 'Quinn', due_at: '2026-11-04T17:00:00Z', priority: 2 }),
27
+ commitment('c1', 'Finish exhibit list', '2026-11-03T14:40:00Z', { status: 'open', owner_name: 'Quinn', due_at: '2026-11-05T17:00:00Z', priority: 1, detail: 'Needed before the hearing.', external_id: 'iss-12', external_key: 'ENG-12', external_url: 'https://linear.app/eng/issue/ENG-12/finish-exhibit-list', state_name: 'In Progress', sync_state: 'synced', mentions: [mention('n1', '2026-11-03T14:38:00Z', 'I still have to finish the exhibit list before the hearing.', 'Hearing prep')] }),
28
+ commitment('c2', 'Call Megan about the filing receipt', '2026-11-03T14:41:00Z', { status: 'open', owner_name: 'Quinn', due_at: '2026-11-04T17:00:00Z', priority: 2, external_id: 'iss-14', external_key: 'ENG-14', external_url: 'https://linear.app/eng/issue/ENG-14/call-megan', state_name: 'Todo', sync_state: 'error', sync_error: 'Linear is rate limiting us. Retrying.' }),
29
29
  commitment('c3', 'Move weekly report to Monday', '2026-11-03T14:42:00Z', { status: 'open', owner_name: 'Quinn', source: 'granola', source_label: 'Granola', mentions: [mention('d2', '2026-11-02T15:00:00Z', 'Let us move the weekly report to Mondays.')] }),
30
- commitment('c4', 'Book the dentist', '2026-11-03T14:43:00Z', { status: 'open', owner_name: 'Quinn', due_at: '2026-11-06T09:00:00Z' }),
30
+ commitment('c4', 'Book the dentist', '2026-11-03T14:43:00Z', { status: 'open', owner_name: 'Quinn', due_at: '2026-11-06T09:00:00Z', sync_state: 'unsynced' }),
31
31
  commitment('c5', 'Send the revised proposal', '2026-10-28T10:00:00Z', { status: 'done', owner_name: 'Rae', resolved_at: '2026-10-30T10:00:00Z' }),
32
32
  commitment('c6', 'Waiting on court clerk reply', '2026-10-29T10:00:00Z', { status: 'blocked', owner_name: 'Quinn', status_reason: 'Clerk has not answered' }),
33
33
 
@@ -277,6 +277,9 @@ export function createFakeTenantHttp(options: FakeTenantOptions = {}): FakeTenan
277
277
  reads.set(key, seen);
278
278
  const first = page.results[0];
279
279
  if (seen < 2 || !first) return page;
280
+ // A change made in the tracker since the first read: linked rows come back in their next state.
281
+ const moved = page.results.map((r) => (dataOf(r).external_key ? { ...r, data: { ...dataOf(r), state_name: 'In Review' } } : r));
282
+ page = { ...page, results: moved };
280
283
  const added = { ...first, id: `${first.id}-fresh`, name: REFRESH_ROW_TITLE, data: { ...dataOf(first), title: REFRESH_ROW_TITLE } };
281
284
  return { ...page, count: page.count + 1, results: [added, ...page.results] };
282
285
  }