@startsimpli/integrations 0.2.144 → 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 +102 -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 +47 -9
  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
@@ -28,15 +28,20 @@ import * as React from 'react';
28
28
 
29
29
  import { isStalled, runCoverage, runProgress } from '../../corpus/runs';
30
30
  import { stripMarkdown } from '../Markdown';
31
+ import { isOverdue } from '../../corpus/work-item-logic';
31
32
  import { useTrackerName } from '../../task-tracker/useTrackerName';
32
33
  import type { MemberConnectionsApi } from './types';
33
34
  import { failureMessage, unfilteredMessage } from './work-items';
34
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';
35
39
  import { STALE_DAYS, groupTracker } from '../../corpus/tracker-groups';
36
40
  import type { TrackerEntry } from '../../corpus/tracker-groups';
37
41
  import type {
38
42
  Commitment,
39
43
  CommitmentQuery,
44
+ CommitmentSort,
40
45
  CommitmentStatus,
41
46
  CommitmentTrackerApi,
42
47
  CorpusScope,
@@ -174,8 +179,12 @@ export function TrackerPage({
174
179
  const [doneOpen, setDoneOpen] = React.useState(false);
175
180
  const [workspaceHasAny, setWorkspaceHasAny] = React.useState<boolean | null>(null);
176
181
 
182
+ const [sort, setSort] = React.useState<CommitmentSort>(DEFAULT_TRACKER_SORT);
183
+ const [view, setView] = React.useState<TrackerView>('list');
184
+
177
185
  const query = React.useMemo<CommitmentQuery>(
178
186
  () => ({
187
+ sort,
179
188
  // Everything still owed, one server page, with each item's project. The
180
189
  // groups below are computed over this set; the count says when it is only
181
190
  // the first page.
@@ -183,7 +192,7 @@ export function TrackerPage({
183
192
  withFocus: true,
184
193
  pageSize: 200,
185
194
  }),
186
- [],
195
+ [sort],
187
196
  );
188
197
 
189
198
  const load = React.useCallback(async () => {
@@ -337,17 +346,22 @@ export function TrackerPage({
337
346
  }, [canQueue, pollMs, maxAutoResumes, scope.orgId, sweepEpoch]);
338
347
 
339
348
  const [filterText, setFilterText] = React.useState('');
349
+ type QuickKey = 'all' | 'overdue' | 'blocked' | 'in_progress';
350
+ const [quick, setQuick] = React.useState<QuickKey>('all');
340
351
  /** Client-side narrowing over the loaded page: title, owner, subject or project name. */
341
352
  const matches = React.useCallback((r: Commitment) => {
353
+ if (quick === 'overdue' && !isOverdue(r, clock)) return false;
354
+ if (quick === 'blocked' && r.status !== 'blocked') return false;
355
+ if (quick === 'in_progress' && r.status !== 'in_progress') return false;
342
356
  const q = filterText.trim().toLowerCase();
343
357
  if (!q) return true;
344
358
  const project = r.focusId ? projectNames[r.focusId] ?? '' : '';
345
359
  return [r.title, r.ownerName, r.subject, project, r.detail].some((v) => (v ?? '').toLowerCase().includes(q));
346
- }, [filterText, projectNames]);
347
- const filtering = filterText.trim().length > 0;
360
+ }, [filterText, quick, clock, projectNames]);
361
+ const filtering = filterText.trim().length > 0 || quick !== 'all';
348
362
  const groups = React.useMemo(
349
- () => groupTracker(rows.filter(matches), { now: clock, timeZone }),
350
- [rows, matches, clock, timeZone],
363
+ () => groupTracker(rows.filter(matches), { now: clock, timeZone, sort }),
364
+ [rows, matches, clock, timeZone, sort],
351
365
  );
352
366
  const doneGroups = React.useMemo(
353
367
  () => (doneRows ? groupTracker(doneRows.filter(matches), { now: clock, timeZone }).done : []),
@@ -439,7 +453,20 @@ export function TrackerPage({
439
453
  placeholder="Filter to-dos by title, owner or project…" aria-label="Filter to-dos"
440
454
  />
441
455
  ) : null}
442
- {filtering && owed === 0 && rows.length > 0 ? <p className={cn.muted}>No to-dos match “{filterText.trim()}”.</p> : null}
456
+ {rows.length > 0 ? (
457
+ <div className="flex flex-wrap gap-2" role="group" aria-label="Quick filters">
458
+ {([['all', 'All'], ['overdue', 'Overdue'], ['blocked', 'Blocked'], ['in_progress', 'In progress']] as Array<[QuickKey, string]>).map(([key, label]) => (
459
+ <button
460
+ key={key} type="button" aria-pressed={quick === key} onClick={() => setQuick(key)}
461
+ className={`rounded-full border px-3 py-1 text-xs ${quick === key ? 'border-gray-900 bg-gray-900 text-white' : 'border-gray-300 text-gray-700'}`}
462
+ >{label}</button>
463
+ ))}
464
+ </div>
465
+ ) : null}
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}
443
470
  <div className="flex flex-wrap items-center gap-3">
444
471
  <p className={cn.muted} data-testid="tracker-summary">
445
472
  {loading ? 'Loading…' : `${owed} owed · ${c.today} today · ${c.inProgress} in progress`}
@@ -515,7 +542,18 @@ export function TrackerPage({
515
542
  </p>
516
543
  ) : null}
517
544
 
518
- {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 ? (
519
557
  <section key={key} aria-label={label} className="space-y-1">
520
558
  <h2 className={`flex items-baseline gap-2 ${cn.heading}`}>
521
559
  {label} <span className="text-sm font-normal text-gray-500">{c[key]}</span>
@@ -526,7 +564,7 @@ export function TrackerPage({
526
564
  } : undefined))}
527
565
  </ul>
528
566
  </section>
529
- ) : null))}
567
+ ) : null)) : null}
530
568
 
531
569
  {total > rows.length ? (
532
570
  <p className={cn.muted}>
@@ -537,7 +575,7 @@ export function TrackerPage({
537
575
  </p>
538
576
  ) : null}
539
577
 
540
- {c.stale ? (
578
+ {c.stale && view === 'list' ? (
541
579
  <details className={fold}>
542
580
  <summary className={foldSummary}>Stale ({c.stale})
543
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