@startsimpli/integrations 0.2.145 → 0.2.146

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 (72) hide show
  1. package/package.json +4 -4
  2. package/src/__tests__/briefing-actions.test.ts +2 -0
  3. package/src/__tests__/briefing-reply.test.ts +334 -0
  4. package/src/__tests__/corpus-tracker.test.tsx +79 -0
  5. package/src/__tests__/owner-backfill.test.ts +114 -0
  6. package/src/__tests__/owner-link.test.ts +115 -0
  7. package/src/__tests__/owner-picker.test.tsx +70 -0
  8. package/src/__tests__/roster.test.ts +27 -0
  9. package/src/__tests__/tracker-sort.test.ts +28 -0
  10. package/src/components/index.ts +1 -0
  11. package/src/components/pages/TaskDetailPage.tsx +33 -2
  12. package/src/components/pages/TrackerPage.tsx +28 -6
  13. package/src/components/pages/task-tracker/OwnerPicker.tsx +82 -0
  14. package/src/components/pages/tracker/TrackerBoard.tsx +45 -0
  15. package/src/components/pages/tracker/TrackerToolbar.tsx +44 -0
  16. package/src/corpus/briefing/actions/execute.ts +5 -4
  17. package/src/corpus/briefing/actions/log.ts +1 -1
  18. package/src/corpus/briefing/actions/types.ts +21 -0
  19. package/src/corpus/briefing/index.ts +1 -0
  20. package/src/corpus/briefing/intent/model.ts +3 -0
  21. package/src/corpus/briefing/intent/resolve.ts +14 -6
  22. package/src/corpus/briefing/intent/types.ts +7 -0
  23. package/src/corpus/briefing/reply/handle.ts +174 -0
  24. package/src/corpus/briefing/reply/index.ts +6 -0
  25. package/src/corpus/briefing/reply/respond.ts +95 -0
  26. package/src/corpus/briefing/reply/types.ts +112 -0
  27. package/src/corpus/briefing/store.ts +14 -0
  28. package/src/corpus/client.ts +16 -18
  29. package/src/corpus/entities.ts +4 -0
  30. package/src/corpus/index.ts +4 -0
  31. package/src/corpus/owner-backfill.ts +200 -0
  32. package/src/corpus/owner-link.ts +160 -0
  33. package/src/corpus/roster.ts +53 -0
  34. package/src/corpus/tracker-groups.ts +8 -4
  35. package/src/corpus/tracker-sort.ts +51 -0
  36. package/src/corpus/types.ts +13 -1
  37. package/src/native/app/FoundryApp.tsx +25 -7
  38. package/src/native/app/__tests__/briefingLink.test.tsx +57 -0
  39. package/src/native/app/__tests__/briefingServices.test.ts +92 -0
  40. package/src/native/app/__tests__/launch.test.ts +2 -1
  41. package/src/native/app/briefingServices.ts +101 -0
  42. package/src/native/app/config/__tests__/briefingConfig.test.ts +49 -0
  43. package/src/native/app/config/links.ts +4 -1
  44. package/src/native/app/config/types.ts +13 -1
  45. package/src/native/app/config/validate.ts +20 -2
  46. package/src/native/app/data.ts +3 -3
  47. package/src/native/app/device.ts +3 -0
  48. package/src/native/app/launch.ts +4 -0
  49. package/src/native/app/registry.tsx +3 -1
  50. package/src/native/app/screens/RecordScreen.tsx +3 -2
  51. package/src/native/app/services.ts +11 -30
  52. package/src/native/app/strings.ts +28 -0
  53. package/src/native/briefing/BriefingCard.tsx +14 -2
  54. package/src/native/briefing/BriefingReply.tsx +68 -0
  55. package/src/native/briefing/__tests__/BriefingReply.test.tsx +144 -0
  56. package/src/native/briefing/__tests__/fakeReply.test.ts +46 -0
  57. package/src/native/briefing/__tests__/notify.test.ts +42 -1
  58. package/src/native/briefing/__tests__/replyApi.test.ts +43 -0
  59. package/src/native/briefing/__tests__/replyController.test.ts +230 -0
  60. package/src/native/briefing/__tests__/replyPosition.test.ts +116 -0
  61. package/src/native/briefing/audioPlayer.ts +9 -2
  62. package/src/native/briefing/controller.ts +50 -5
  63. package/src/native/briefing/fake.ts +25 -18
  64. package/src/native/briefing/fakeReply.ts +65 -0
  65. package/src/native/briefing/index.ts +8 -3
  66. package/src/native/briefing/notify.ts +42 -0
  67. package/src/native/briefing/reply.ts +261 -0
  68. package/src/native/briefing/replyApi.ts +82 -0
  69. package/src/native/recording/__tests__/deeplink.test.ts +20 -0
  70. package/src/native/recording/deeplink.ts +7 -0
  71. package/src/native/tracker/__tests__/itemsChanged.test.ts +13 -0
  72. package/src/native/tracker/tab.tsx +4 -1
@@ -0,0 +1,115 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import {
3
+ decodeOwnerSubs, encodeOwnerSubs, matchOwnerName, planOwnerLinks, splitOwnerNames,
4
+ } from '../corpus/owner-link';
5
+
6
+ const roster = [
7
+ { sub: 'u-quinn', email: 'quinn@x.com', name: 'Quinn Osha' },
8
+ { sub: 'u-jon', email: 'jonathan@x.com', name: 'Jonathan Osha' },
9
+ { sub: 'u-kate', email: 'kate@x.com', name: 'Kate Reyes' },
10
+ { sub: 'u-st1', email: 'st1@x.com', name: 'Stephanie Lee' },
11
+ { sub: 'u-st2', email: 'st2@x.com', name: 'Stephanie Lopez' },
12
+ { sub: 'u-noname', email: 'qosha@debugg.ai' },
13
+ { sub: 'u-qa', email: 'qa-tandem@startsimpli.com', name: 'Tandem QA' },
14
+ { sub: 'u-qa2', email: 'idf+tandem@foundry.local', name: 'Jude Test' },
15
+ ];
16
+
17
+ describe('splitOwnerNames', () => {
18
+ it('splits joint owners on comma, ampersand, "and", semicolon, slash', () => {
19
+ expect(splitOwnerNames('Jude, Jenny')).toEqual(['Jude', 'Jenny']);
20
+ expect(splitOwnerNames('Jonathan & Kevin')).toEqual(['Jonathan', 'Kevin']);
21
+ expect(splitOwnerNames('Kate and Quinn')).toEqual(['Kate', 'Quinn']);
22
+ expect(splitOwnerNames('Kate; Quinn / Megan')).toEqual(['Kate', 'Quinn', 'Megan']);
23
+ });
24
+ it('keeps a single name whole and drops blanks and duplicates', () => {
25
+ expect(splitOwnerNames('Jonathan Osha')).toEqual(['Jonathan Osha']);
26
+ expect(splitOwnerNames(' , Kate,kate ')).toEqual(['Kate']);
27
+ expect(splitOwnerNames('')).toEqual([]);
28
+ });
29
+ });
30
+
31
+ describe('matchOwnerName', () => {
32
+ it('links a unique first name and the full-name variants to one person', () => {
33
+ for (const text of ['Quinn', 'quinn', 'Quinn Osha', 'QUINN OSHA']) {
34
+ expect(matchOwnerName(text, roster)).toMatchObject({ status: 'linked', sub: 'u-quinn' });
35
+ }
36
+ });
37
+ it('links first+last across a middle name', () => {
38
+ const r = [{ sub: 'm', email: 'm@x.com', name: 'Megan Q. Fox' }];
39
+ expect(matchOwnerName('Megan Fox', r)).toMatchObject({ status: 'linked', sub: 'm' });
40
+ });
41
+ it('never merges an ambiguous first name', () => {
42
+ const m = matchOwnerName('Stephanie', roster);
43
+ expect(m.status).toBe('ambiguous');
44
+ expect(m.status === 'ambiguous' && m.candidates.sort()).toEqual(['u-st1', 'u-st2']);
45
+ });
46
+ it('an exact full name beats an ambiguous first name', () => {
47
+ expect(matchOwnerName('Stephanie Lee', roster)).toMatchObject({ status: 'linked', sub: 'u-st1' });
48
+ });
49
+ it('a surname alone never matches', () => {
50
+ expect(matchOwnerName('Osha', roster).status).toBe('unmatched');
51
+ });
52
+ it('same first name, different surname is not the same person', () => {
53
+ expect(matchOwnerName('Jonathan Smith', roster).status).toBe('unmatched');
54
+ });
55
+ it('a member with no name is never matched through their email', () => {
56
+ expect(matchOwnerName('qosha', roster).status).toBe('unmatched');
57
+ });
58
+ it('service and QA accounts are never candidates', () => {
59
+ expect(matchOwnerName('Jude', roster).status).toBe('unmatched');
60
+ expect(matchOwnerName('Tandem', roster).status).toBe('unmatched');
61
+ });
62
+ it('unknown names are unmatched', () => {
63
+ expect(matchOwnerName('Najima', roster).status).toBe('unmatched');
64
+ });
65
+ it('two roster rows for one sub are one person', () => {
66
+ const r = [...roster, { sub: 'u-quinn', email: 'q2@x.com', name: 'Quinn Osha' }];
67
+ expect(matchOwnerName('Quinn', r)).toMatchObject({ status: 'linked', sub: 'u-quinn' });
68
+ });
69
+ });
70
+
71
+ describe('declared aliases', () => {
72
+ const bare = [
73
+ { sub: 'a', email: 'qosha@debugg.ai', aliases: ['Quinn Osha'] },
74
+ { sub: 'b', email: 'jpo@ogmc.ai', aliases: ['Jonathan Osha'] },
75
+ { sub: 'c', email: 'sam@x.com' },
76
+ ];
77
+ it('match through declared aliases only', () => {
78
+ expect(matchOwnerName('Quinn', bare)).toMatchObject({ status: 'linked', sub: 'a' });
79
+ expect(matchOwnerName('Jonathan Osha', bare)).toMatchObject({ status: 'linked', sub: 'b' });
80
+ expect(matchOwnerName('Sam', bare).status).toBe('unmatched');
81
+ expect(matchOwnerName('Osha', bare).status).toBe('unmatched');
82
+ });
83
+ it('a roster with no names links nothing', () => {
84
+ expect(planOwnerLinks('Quinn, Jonathan', bare.map(({ aliases, ...m }) => m)).outcome).toBe('unmatched');
85
+ });
86
+ });
87
+
88
+ describe('planOwnerLinks', () => {
89
+ it('links the resolvable parts of a joint owner and reports the rest', () => {
90
+ const plan = planOwnerLinks('Jonathan Osha, Kevin', roster);
91
+ expect(plan.subs).toEqual(['u-jon']);
92
+ expect(plan.parts.map((p) => p.status)).toEqual(['linked', 'unmatched']);
93
+ expect(plan.outcome).toBe('partial');
94
+ });
95
+ it('classifies whole rows', () => {
96
+ expect(planOwnerLinks('Quinn', roster).outcome).toBe('linked');
97
+ expect(planOwnerLinks('Kate, Quinn', roster).subs).toEqual(['u-kate', 'u-quinn']);
98
+ expect(planOwnerLinks('Stephanie', roster).outcome).toBe('ambiguous');
99
+ expect(planOwnerLinks('Najima', roster).outcome).toBe('unmatched');
100
+ expect(planOwnerLinks('', roster).outcome).toBe('none');
101
+ });
102
+ it('two spellings of one person do not double-count', () => {
103
+ expect(planOwnerLinks('Jonathan, Jonathan Osha', roster).subs).toEqual(['u-jon']);
104
+ });
105
+ });
106
+
107
+ describe('owner_subs encoding', () => {
108
+ it('round-trips and is delimiter-safe for icontains filtering', () => {
109
+ expect(encodeOwnerSubs(['a', 'b'])).toBe('|a|b|');
110
+ expect(decodeOwnerSubs('|a|b|')).toEqual(['a', 'b']);
111
+ expect(decodeOwnerSubs(['a', 'b'])).toEqual(['a', 'b']);
112
+ expect(decodeOwnerSubs(undefined)).toEqual([]);
113
+ expect(encodeOwnerSubs([])).toBe('');
114
+ });
115
+ });
@@ -0,0 +1,70 @@
1
+ import { describe, expect, it, vi } from 'vitest';
2
+ import { render, screen, waitFor, fireEvent } from '@testing-library/react';
3
+
4
+ import { TaskDetailPage } from '../components/pages/TaskDetailPage';
5
+ import { toCommitment, commitmentToEntity, type TenantEntity } from '../corpus/entities';
6
+ import type { Commitment } from '../corpus/types';
7
+
8
+ const members = [
9
+ { sub: 'u-q', email: 'q@x.com', name: 'Quinn Osha' },
10
+ { sub: 'u-s1', email: 's1@x.com', name: 'Stephanie Lee' },
11
+ { sub: 'u-s2', email: 's2@x.com', name: 'Stephanie Lopez' },
12
+ ];
13
+
14
+ const make = (data: Record<string, unknown>): Commitment =>
15
+ toCommitment({
16
+ id: 'a', external_id: 'commit:a', name: 'a', entity_type: 'commitment', version: 1,
17
+ data: { title: 'Task a', status: 'open', subtype: 'action', mentions: [], ...data },
18
+ } as unknown as TenantEntity, { orgId: 'o' });
19
+
20
+ function setup(item: Commitment) {
21
+ const api = {
22
+ listCommitments: vi.fn(async (q: { page?: number } = {}) => ({ results: (q.page ?? 1) === 1 ? [item] : [], count: 1 })) as never,
23
+ updateCommitment: vi.fn(async (i: Commitment, patch: object) => ({ ...i, ...patch })) as never,
24
+ listMembers: vi.fn(async () => members),
25
+ };
26
+ render(<TaskDetailPage api={api} scope={{ orgId: 'o' } as never} itemId="commit:a" />);
27
+ return api;
28
+ }
29
+
30
+ describe('commitment joint owners round trip', () => {
31
+ it('reads owner_subs and writes it back', () => {
32
+ const c = make({ owner_name: 'Quinn, Kate', owner_sub: 'u-q', owner_subs: '|u-q|u-k|' });
33
+ expect(c.ownerSubs).toEqual(['u-q', 'u-k']);
34
+ expect((commitmentToEntity(c) as { data: Record<string, unknown> }).data.owner_subs).toBe('|u-q|u-k|');
35
+ });
36
+ });
37
+
38
+ describe('OwnerPicker in the task detail', () => {
39
+ it('offers a one-tap link for an unambiguous name and saves joint owners', async () => {
40
+ const api = setup(make({ owner_name: 'Quinn' }));
41
+ fireEvent.click(await screen.findByRole('button', { name: /link “quinn” to quinn osha/i }));
42
+ await waitFor(() => expect(api.updateCommitment).toHaveBeenCalledWith(
43
+ expect.anything(), { ownerSubs: ['u-q'], ownerSub: 'u-q' }));
44
+ fireEvent.change(await screen.findByLabelText('Add owner'), { target: { value: 'u-s1' } });
45
+ await waitFor(() => expect(api.updateCommitment).toHaveBeenLastCalledWith(
46
+ expect.anything(), { ownerSubs: ['u-q', 'u-s1'], ownerSub: 'u-q' }));
47
+ });
48
+
49
+ it('never picks for an ambiguous name: shows the candidates', async () => {
50
+ const api = setup(make({ owner_name: 'Stephanie' }));
51
+ expect(await screen.findByText(/which “stephanie”/i)).toBeInTheDocument();
52
+ expect(api.updateCommitment).not.toHaveBeenCalled();
53
+ fireEvent.click(screen.getByRole('button', { name: 'Stephanie Lopez' }));
54
+ await waitFor(() => expect(api.updateCommitment).toHaveBeenCalledWith(
55
+ expect.anything(), { ownerSubs: ['u-s2'], ownerSub: 'u-s2' }));
56
+ });
57
+
58
+ it('says plainly when the name is not a member, and keeps the text', async () => {
59
+ setup(make({ owner_name: 'Najima' }));
60
+ expect(await screen.findByText(/“najima” is not a workspace member/i)).toBeInTheDocument();
61
+ expect(screen.getByText('Najima')).toBeInTheDocument();
62
+ });
63
+
64
+ it('removing a linked owner leaves the original text', async () => {
65
+ const api = setup(make({ owner_name: 'Quinn', owner_sub: 'u-q', owner_subs: '|u-q|' }));
66
+ fireEvent.click(await screen.findByRole('button', { name: /remove quinn osha/i }));
67
+ await waitFor(() => expect(api.updateCommitment).toHaveBeenCalledWith(
68
+ expect.anything(), { ownerSubs: [], ownerSub: '' }));
69
+ });
70
+ });
@@ -0,0 +1,27 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { readRoster } from '../corpus/roster';
3
+
4
+ const paths = { members: 'm', roster: 'r' };
5
+
6
+ describe('readRoster', () => {
7
+ it('joins names from the member roster to emails from the admin list', async () => {
8
+ const http = { async get(path: string, o?: { params?: Record<string, unknown> }) {
9
+ if (path === 'r') return o?.params?.cursor
10
+ ? { results: [{ sub: 'b', label: 'Kate' }], next_cursor: null }
11
+ : { results: [{ sub: 'a', label: 'Quinn' }], next_cursor: 'c2' };
12
+ return { results: [{ user: { sub: 'a', email: 'q@x.com' } }, { user: { sub: 'b', email: 'k@x.com' } }] };
13
+ } } as never;
14
+ expect(await readRoster(http, paths)).toEqual([
15
+ { sub: 'a', email: 'q@x.com', name: 'Quinn' }, { sub: 'b', email: 'k@x.com', name: 'Kate' }]);
16
+ });
17
+ it('still serves names when the admin-only members list is refused', async () => {
18
+ const http = { async get(path: string) {
19
+ if (path === 'm') throw new Error('403');
20
+ return { results: [{ sub: 'a', label: 'Quinn' }] };
21
+ } } as never;
22
+ expect(await readRoster(http, paths)).toEqual([{ sub: 'a', email: '', name: 'Quinn' }]);
23
+ });
24
+ it('is empty, not an error, when neither is available', async () => {
25
+ expect(await readRoster({ get: async () => { throw new Error('x'); } } as never, paths)).toEqual([]);
26
+ });
27
+ });
@@ -0,0 +1,28 @@
1
+ import { describe, expect, it } from 'vitest';
2
+
3
+ import { commitmentOrder, compareCommitments } from '../corpus/tracker-sort';
4
+ import { groupTracker } from '../corpus/tracker-groups';
5
+
6
+ const row = (o: Record<string, unknown>) => ({ title: '', ...o }) as never;
7
+
8
+ describe('tracker sort', () => {
9
+ it('maps each key to a declared-attribute server order, due by default', () => {
10
+ expect(commitmentOrder()).toBe('attr.due_at');
11
+ expect(commitmentOrder('updated')).toBe('-attr.last_seen_at');
12
+ expect(commitmentOrder('title')).toBe('attr.title');
13
+ expect(commitmentOrder('owner')).toBe('attr.owner_name');
14
+ });
15
+
16
+ it('puts a missing owner or date last, never first', () => {
17
+ const rows = [row({ title: 'x', ownerName: undefined }), row({ title: 'y', ownerName: 'Amy' })];
18
+ expect(rows.sort(compareCommitments('owner')).map((r: { title: string }) => r.title)).toEqual(['y', 'x']);
19
+ const dated = [row({ title: 'none' }), row({ title: 'soon', dueAt: '2026-08-01T00:00:00Z' })];
20
+ expect(dated.sort(compareCommitments('due')).map((r: { title: string }) => r.title)).toEqual(['soon', 'none']);
21
+ });
22
+
23
+ it('groupTracker orders within groups by the sort', () => {
24
+ const mk = (title: string) => ({ title, status: 'open', subtype: 'action', dueAt: '2026-09-01T00:00:00Z', lastSeenAt: '2026-08-01T00:00:00Z', firstSeenAt: '2026-08-01T00:00:00Z' }) as never;
25
+ const g = groupTracker([mk('b'), mk('a')], { now: Date.parse('2026-08-10T00:00:00Z'), sort: 'title' });
26
+ expect(g.upNext.concat(g.later).map((e) => (e.item as { title: string }).title)).toEqual(['a', 'b']);
27
+ });
28
+ });
@@ -70,3 +70,4 @@ export * from './pages/VoiceNotesPage';
70
70
  export { VoiceRecordButton, VOICE_MIME_CANDIDATES } from './pages/VoiceRecordButton';
71
71
  export type { VoiceRecordButtonProps, VoiceRecordClassNames } from './pages/VoiceRecordButton';
72
72
  export * from './pages/home';
73
+ export * from './pages/task-tracker/OwnerPicker';
@@ -18,12 +18,17 @@ import type { Commitment, CommitmentApi, CommitmentStatus, CorpusScope } from '.
18
18
  import { isOverdue, priorityLabel } from '../../corpus/work-item-logic';
19
19
  import { isAuthored } from '../../corpus/planning';
20
20
  import { useTrackerName } from '../../task-tracker/useTrackerName';
21
+ import { OwnerPicker } from './task-tracker/OwnerPicker';
22
+ import type { RosterMember } from '../../corpus/owner-link';
21
23
  import { ExternalLinkChip } from './task-tracker/ExternalLinkChip';
22
24
  import { failureMessage } from './work-items';
23
25
  import type { MemberConnectionsApi } from './types';
24
26
 
25
27
  export interface TaskDetailPageProps {
26
- api: Pick<CommitmentApi, 'listCommitments' | 'updateCommitment'>;
28
+ api: Pick<CommitmentApi, 'listCommitments' | 'updateCommitment'> & {
29
+ /** The workspace roster; absent means the owner stays text, as before. */
30
+ listMembers?: () => Promise<RosterMember[]>;
31
+ };
27
32
  scope: CorpusScope;
28
33
  /** The item's `externalId` (`commit:<dedupeKey>`), as it appears in the route. */
29
34
  itemId: string;
@@ -79,6 +84,26 @@ export function TaskDetailPage({
79
84
  const [error, setError] = React.useState('');
80
85
  const [busy, setBusy] = React.useState(false);
81
86
  const [editing, setEditing] = React.useState(false);
87
+ const [members, setMembers] = React.useState<RosterMember[]>([]);
88
+ React.useEffect(() => {
89
+ let live = true;
90
+ void apiRef.current.listMembers?.().then((rows) => { if (live) setMembers(rows); }).catch(() => undefined);
91
+ return () => { live = false; };
92
+ }, []);
93
+
94
+ const setOwners = async (subs: string[]) => {
95
+ if (!item || !apiRef.current.updateCommitment) return;
96
+ setBusy(true);
97
+ setError('');
98
+ try {
99
+ const updated = await apiRef.current.updateCommitment(item, { ownerSubs: subs, ownerSub: subs[0] ?? '' });
100
+ setItem({ ...item, ...updated, ownerSubs: subs, ownerSub: subs[0] });
101
+ } catch (err) {
102
+ setError(failureMessage(err));
103
+ } finally {
104
+ setBusy(false);
105
+ }
106
+ };
82
107
  const [form, setForm] = React.useState({ title: '', detail: '', owner: '', due: '' });
83
108
 
84
109
  React.useEffect(() => {
@@ -198,7 +223,13 @@ export function TaskDetailPage({
198
223
 
199
224
  <dl className="mt-3 grid grid-cols-[7rem_1fr] gap-y-1 text-sm">
200
225
  <dt className={cn.muted}>Owner</dt>
201
- <dd>{item.ownerName ? item.ownerName : <span className={cn.muted}>No owner named</span>}</dd>
226
+ <dd>
227
+ {members.length ? (
228
+ <OwnerPicker members={members} ownerName={item.ownerName}
229
+ value={item.ownerSubs?.length ? item.ownerSubs : item.ownerSub ? [item.ownerSub] : []}
230
+ onChange={(subs) => void setOwners(subs)} disabled={busy || !canWrite} mutedClassName={cn.muted} />
231
+ ) : item.ownerName ? item.ownerName : <span className={cn.muted}>No owner named</span>}
232
+ </dd>
202
233
  <dt className={cn.muted}>Due</dt>
203
234
  <dd>
204
235
  {item.dueAt
@@ -33,11 +33,15 @@ import { useTrackerName } from '../../task-tracker/useTrackerName';
33
33
  import type { MemberConnectionsApi } from './types';
34
34
  import { failureMessage, unfilteredMessage } from './work-items';
35
35
  import { CompactItemRow } from './home/CompactItemRow';
36
+ import { TrackerBoard } from './tracker/TrackerBoard';
37
+ import { TrackerToolbar, type TrackerView } from './tracker/TrackerToolbar';
38
+ import { DEFAULT_TRACKER_SORT } from '../../corpus/tracker-sort';
36
39
  import { STALE_DAYS, groupTracker } from '../../corpus/tracker-groups';
37
40
  import type { TrackerEntry } from '../../corpus/tracker-groups';
38
41
  import type {
39
42
  Commitment,
40
43
  CommitmentQuery,
44
+ CommitmentSort,
41
45
  CommitmentStatus,
42
46
  CommitmentTrackerApi,
43
47
  CorpusScope,
@@ -175,8 +179,12 @@ export function TrackerPage({
175
179
  const [doneOpen, setDoneOpen] = React.useState(false);
176
180
  const [workspaceHasAny, setWorkspaceHasAny] = React.useState<boolean | null>(null);
177
181
 
182
+ const [sort, setSort] = React.useState<CommitmentSort>(DEFAULT_TRACKER_SORT);
183
+ const [view, setView] = React.useState<TrackerView>('list');
184
+
178
185
  const query = React.useMemo<CommitmentQuery>(
179
186
  () => ({
187
+ sort,
180
188
  // Everything still owed, one server page, with each item's project. The
181
189
  // groups below are computed over this set; the count says when it is only
182
190
  // the first page.
@@ -184,7 +192,7 @@ export function TrackerPage({
184
192
  withFocus: true,
185
193
  pageSize: 200,
186
194
  }),
187
- [],
195
+ [sort],
188
196
  );
189
197
 
190
198
  const load = React.useCallback(async () => {
@@ -352,8 +360,8 @@ export function TrackerPage({
352
360
  }, [filterText, quick, clock, projectNames]);
353
361
  const filtering = filterText.trim().length > 0 || quick !== 'all';
354
362
  const groups = React.useMemo(
355
- () => groupTracker(rows.filter(matches), { now: clock, timeZone }),
356
- [rows, matches, clock, timeZone],
363
+ () => groupTracker(rows.filter(matches), { now: clock, timeZone, sort }),
364
+ [rows, matches, clock, timeZone, sort],
357
365
  );
358
366
  const doneGroups = React.useMemo(
359
367
  () => (doneRows ? groupTracker(doneRows.filter(matches), { now: clock, timeZone }).done : []),
@@ -456,6 +464,9 @@ export function TrackerPage({
456
464
  </div>
457
465
  ) : null}
458
466
  {filtering && owed === 0 && rows.length > 0 ? <p className={cn.muted}>No to-dos match{filterText.trim() ? ` “${filterText.trim()}”` : ' this filter'}.</p> : null}
467
+ {rows.length > 0 ? (
468
+ <TrackerToolbar sort={sort} onSort={setSort} view={view} onView={setView} inputClassName={cn.input} />
469
+ ) : null}
459
470
  <div className="flex flex-wrap items-center gap-3">
460
471
  <p className={cn.muted} data-testid="tracker-summary">
461
472
  {loading ? 'Loading…' : `${owed} owed · ${c.today} today · ${c.inProgress} in progress`}
@@ -531,7 +542,18 @@ export function TrackerPage({
531
542
  </p>
532
543
  ) : null}
533
544
 
534
- {sections.map(({ key, label }) => (groups[key].length ? (
545
+ {view === 'board' ? (
546
+ <TrackerBoard
547
+ entries={[...groups.today, ...groups.inProgress, ...groups.upNext, ...groups.later, ...groups.stale]}
548
+ sort={sort}
549
+ headingClassName={cn.heading} mutedClassName={cn.muted}
550
+ renderRow={(entry) => rowFor(entry, canWrite ? {
551
+ actions: <button type="button" className={btn} onClick={() => void act(entry.item, { status: 'done' })}>Mark done</button>,
552
+ } : undefined)}
553
+ />
554
+ ) : null}
555
+
556
+ {view === 'list' ? sections.map(({ key, label }) => (groups[key].length ? (
535
557
  <section key={key} aria-label={label} className="space-y-1">
536
558
  <h2 className={`flex items-baseline gap-2 ${cn.heading}`}>
537
559
  {label} <span className="text-sm font-normal text-gray-500">{c[key]}</span>
@@ -542,7 +564,7 @@ export function TrackerPage({
542
564
  } : undefined))}
543
565
  </ul>
544
566
  </section>
545
- ) : null))}
567
+ ) : null)) : null}
546
568
 
547
569
  {total > rows.length ? (
548
570
  <p className={cn.muted}>
@@ -553,7 +575,7 @@ export function TrackerPage({
553
575
  </p>
554
576
  ) : null}
555
577
 
556
- {c.stale ? (
578
+ {c.stale && view === 'list' ? (
557
579
  <details className={fold}>
558
580
  <summary className={foldSummary}>Stale ({c.stale})
559
581
  <span className="ml-2 text-xs font-normal text-gray-500">no date, not touched in {STALE_DAYS}+ days</span>
@@ -0,0 +1,82 @@
1
+ /**
2
+ * WHO OWES THIS (bd startsim-768w.38.29): a multi-person owner field.
3
+ *
4
+ * The meeting's owner text stays visible. Beside it, the people it is linked to
5
+ * as workspace members, an add control, and, while nothing is linked, a
6
+ * suggestion per name: one tap to link when exactly one member matches, a choice
7
+ * between the candidates when several could be meant, and a plain note when the
8
+ * name is not a member at all. Nothing is ever auto-merged here.
9
+ */
10
+ import * as React from 'react';
11
+ import { planOwnerLinks } from '../../../corpus/owner-link';
12
+ import type { RosterMember } from '../../../corpus/owner-link';
13
+
14
+ export interface OwnerPickerProps {
15
+ members: RosterMember[];
16
+ /** What the meeting said, preserved verbatim. */
17
+ ownerName?: string;
18
+ /** The members currently linked. */
19
+ value: string[];
20
+ onChange: (subs: string[]) => void;
21
+ disabled?: boolean;
22
+ mutedClassName?: string;
23
+ buttonClassName?: string;
24
+ }
25
+
26
+ const labelOf = (members: RosterMember[], sub: string) => {
27
+ const m = members.find((x) => x.sub === sub);
28
+ return m?.name || m?.aliases?.[0] || m?.email || sub;
29
+ };
30
+
31
+ export function OwnerPicker({
32
+ members, ownerName, value, onChange, disabled, mutedClassName = 'text-sm text-gray-500',
33
+ buttonClassName = 'rounded-md border border-gray-300 px-2 py-0.5 text-xs text-gray-800 disabled:opacity-50',
34
+ }: OwnerPickerProps) {
35
+ const remaining = members.filter((m) => !value.includes(m.sub));
36
+ const suggestions = !value.length && ownerName ? planOwnerLinks(ownerName, members).parts : [];
37
+ const add = (sub: string) => { if (sub && !value.includes(sub)) onChange([...value, sub]); };
38
+
39
+ return (
40
+ <div data-testid="owner-picker" className="space-y-1">
41
+ {ownerName ? <div>{ownerName}</div> : <div className={mutedClassName}>No owner named</div>}
42
+ {value.length ? (
43
+ <ul className="flex flex-wrap gap-1" aria-label="Linked owners">
44
+ {value.map((sub) => (
45
+ <li key={sub} className="inline-flex items-center gap-1 rounded-full border border-gray-300 px-2 py-0.5 text-xs">
46
+ {labelOf(members, sub)}
47
+ <button type="button" aria-label={`Remove ${labelOf(members, sub)}`} disabled={disabled}
48
+ onClick={() => onChange(value.filter((s) => s !== sub))}>×</button>
49
+ </li>
50
+ ))}
51
+ </ul>
52
+ ) : null}
53
+ {suggestions.map((part) => (
54
+ <div key={part.text} className="flex flex-wrap items-center gap-1 text-xs">
55
+ {part.status === 'linked' ? (
56
+ <button type="button" className={buttonClassName} disabled={disabled} onClick={() => add(part.sub)}>
57
+ Link “{part.text}” to {labelOf(members, part.sub)}
58
+ </button>
59
+ ) : part.status === 'ambiguous' ? (
60
+ <>
61
+ <span className={mutedClassName}>Which “{part.text}”?</span>
62
+ {part.candidates.map((sub) => (
63
+ <button key={sub} type="button" className={buttonClassName} disabled={disabled} onClick={() => add(sub)}>
64
+ {labelOf(members, sub)}
65
+ </button>
66
+ ))}
67
+ </>
68
+ ) : (
69
+ <span className={mutedClassName}>“{part.text}” is not a workspace member</span>
70
+ )}
71
+ </div>
72
+ ))}
73
+ {members.length && remaining.length ? (
74
+ <select aria-label="Add owner" className="rounded-md border border-gray-300 px-2 py-1 text-xs" disabled={disabled}
75
+ value="" onChange={(e) => add(e.target.value)}>
76
+ <option value="">Add owner…</option>
77
+ {remaining.map((m) => <option key={m.sub} value={m.sub}>{labelOf(members, m.sub)}</option>)}
78
+ </select>
79
+ ) : null}
80
+ </div>
81
+ );
82
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * THE BOARD VIEW: what is owed, one column per status (Open, In progress,
3
+ * Blocked). The same rows, filters and sort as the list; only the layout
4
+ * differs. Each card is the shared `CompactItemRow`, so the two views cannot
5
+ * disagree about what a row says.
6
+ */
7
+ import * as React from 'react';
8
+
9
+ import { compareCommitments } from '../../../corpus/tracker-sort';
10
+ import type { TrackerEntry } from '../../../corpus/tracker-groups';
11
+ import type { CommitmentSort } from '../../../corpus/types';
12
+
13
+ export const BOARD_COLUMNS = [
14
+ { status: 'open', label: 'Open' },
15
+ { status: 'in_progress', label: 'In progress' },
16
+ { status: 'blocked', label: 'Blocked' },
17
+ ] as const;
18
+
19
+ export function TrackerBoard({
20
+ entries, sort, renderRow, headingClassName, mutedClassName,
21
+ }: {
22
+ entries: TrackerEntry[];
23
+ sort: CommitmentSort;
24
+ renderRow: (entry: TrackerEntry) => React.ReactNode;
25
+ headingClassName: string;
26
+ mutedClassName: string;
27
+ }) {
28
+ const compare = React.useMemo(() => compareCommitments(sort), [sort]);
29
+ const columns = BOARD_COLUMNS.map((col) => ({
30
+ ...col,
31
+ entries: entries.filter((e) => e.item.status === col.status).sort((a, b) => compare(a.item, b.item)),
32
+ }));
33
+ return (
34
+ <div className="grid gap-4 md:grid-cols-3" data-testid="tracker-board">
35
+ {columns.map((col) => (
36
+ <section key={col.status} aria-label={`${col.label} column`} className="min-w-0 space-y-1 rounded-lg bg-gray-50 p-3">
37
+ <h2 className={`flex items-baseline gap-2 ${headingClassName}`}>
38
+ {col.label} <span className="text-sm font-normal text-gray-500">{col.entries.length}</span>
39
+ </h2>
40
+ {col.entries.length ? <ul>{col.entries.map(renderRow)}</ul> : <p className={mutedClassName}>Nothing here.</p>}
41
+ </section>
42
+ ))}
43
+ </div>
44
+ );
45
+ }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Sort and view controls for the tracker. Presentational: the page owns both
3
+ * values, and the sort is a SERVER parameter (so it re-reads page one).
4
+ */
5
+ import * as React from 'react';
6
+
7
+ import { TRACKER_SORTS } from '../../../corpus/tracker-sort';
8
+ import type { CommitmentSort } from '../../../corpus/types';
9
+
10
+ export type TrackerView = 'list' | 'board';
11
+
12
+ const VIEWS: Array<[TrackerView, string]> = [['list', 'List'], ['board', 'Board']];
13
+
14
+ export function TrackerToolbar({
15
+ sort, onSort, view, onView, inputClassName,
16
+ }: {
17
+ sort: CommitmentSort;
18
+ onSort: (sort: CommitmentSort) => void;
19
+ view: TrackerView;
20
+ onView: (view: TrackerView) => void;
21
+ inputClassName: string;
22
+ }) {
23
+ return (
24
+ <div className="flex flex-wrap items-center gap-3">
25
+ <label className="flex items-center gap-2 text-xs text-gray-600">
26
+ Sort
27
+ <select
28
+ className={inputClassName} value={sort} aria-label="Sort to-dos"
29
+ onChange={(e) => onSort(e.target.value as CommitmentSort)}
30
+ >
31
+ {TRACKER_SORTS.map((s) => <option key={s.key} value={s.key}>{s.label}</option>)}
32
+ </select>
33
+ </label>
34
+ <div className="ml-auto flex overflow-hidden rounded-md border border-gray-300" role="group" aria-label="View">
35
+ {VIEWS.map(([key, label]) => (
36
+ <button
37
+ key={key} type="button" aria-pressed={view === key} onClick={() => onView(key)}
38
+ className={`px-3 py-1 text-xs ${view === key ? 'bg-gray-900 text-white' : 'text-gray-700'}`}
39
+ >{label}</button>
40
+ ))}
41
+ </div>
42
+ </div>
43
+ );
44
+ }
@@ -29,6 +29,7 @@ export interface ExecuteInput {
29
29
  timeZone: string;
30
30
  }
31
31
 
32
+ const reasonOf = (error: unknown) => (error instanceof Error ? error.message : String(error)).slice(0, 200);
32
33
  const sameDay = (a: unknown, b: unknown) => (a ? String(a).slice(0, 10) : null) === (b ? String(b).slice(0, 10) : null);
33
34
 
34
35
  /** The fields a patch changes, read off an item, so a reversal can put them back. */
@@ -93,7 +94,7 @@ async function undoOne(log: ActionLog, input: ExecuteInput, now: number): Promis
93
94
  return { status: 'applied', spoken: undoText(entry, now, input.timeZone), itemId: entry.itemId };
94
95
  } catch (error) {
95
96
  log.stack.push(entry); // nothing changed: it can be tried again
96
- return { status: 'failed', spoken: `I could not undo that: ${error instanceof Error ? error.message : 'the change did not go through'}.`, itemId: entry.itemId };
97
+ return { status: 'failed', spoken: `I could not undo that: ${error instanceof Error ? error.message : 'the change did not go through'}.`, itemId: entry.itemId, reason: reasonOf(error) };
97
98
  }
98
99
  }
99
100
 
@@ -121,7 +122,7 @@ export async function executeVoiceActions(input: ExecuteInput): Promise<ExecuteO
121
122
  pushUndo(log, { actionId: key, kind: 'create', itemId: created.id, title: action.title, before: {}, after: {}, at: nowIso });
122
123
  result = { status: 'applied', spoken: confirmText(action, action.title, now, input.timeZone), itemId: created.id };
123
124
  } catch (error) {
124
- result = { status: 'failed', spoken: `I could not add ${shortTitle(action.title)}.`, ...(error instanceof Error ? {} : {}) };
125
+ result = { status: 'failed', spoken: `I could not add ${shortTitle(action.title)}.`, reason: reasonOf(error) };
125
126
  }
126
127
  } else {
127
128
  const patch = patchFor(action, today, nowIso) as ItemPatch;
@@ -136,8 +137,8 @@ export async function executeVoiceActions(input: ExecuteInput): Promise<ExecuteO
136
137
  pushUndo(log, { actionId: key, kind: 'edit', itemId: item.id, title: item.title, before, after: patch, at: nowIso });
137
138
  result = { status: 'applied', spoken: confirmText(action, item.title, now, input.timeZone), itemId: item.id };
138
139
  }
139
- } catch {
140
- result = { status: 'failed', spoken: `I could not update ${shortTitle(title)}.`, itemId: action.itemId };
140
+ } catch (error) {
141
+ result = { status: 'failed', spoken: `I could not update ${shortTitle(title)}.`, itemId: action.itemId, reason: reasonOf(error) };
141
142
  }
142
143
  }
143
144
 
@@ -42,7 +42,7 @@ export function createEntityActionLog(http: LogHttp, ownerSub: string): ActionLo
42
42
  });
43
43
  const hit = (page.results ?? []).find((r) => (r.external_id ?? (r as { externalId?: string }).externalId) === externalId && mine(r));
44
44
  const stored = ((hit?.data ?? {}) as Record<string, unknown>).action_log as Partial<ActionLog> | undefined;
45
- return stored ? { applied: stored.applied ?? {}, order: stored.order ?? [], stack: stored.stack ?? [] } : emptyLog();
45
+ return stored ? { applied: stored.applied ?? {}, order: stored.order ?? [], stack: stored.stack ?? [], pending: stored.pending ?? [] } : emptyLog();
46
46
  },
47
47
  async save(log) {
48
48
  await http.post('api/v1/entities/upsert', {