@startsimpli/integrations 0.2.149 → 0.2.151

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 (46) hide show
  1. package/package.json +3 -3
  2. package/src/__tests__/connection-check-reason.test.tsx +85 -0
  3. package/src/__tests__/focus-history.test.ts +90 -0
  4. package/src/__tests__/goal-rows.test.ts +51 -0
  5. package/src/__tests__/goals-page.test.tsx +124 -0
  6. package/src/__tests__/helpers/question-tenant.ts +45 -0
  7. package/src/__tests__/question-checkin.test.ts +139 -0
  8. package/src/__tests__/question-voice-parse.test.ts +110 -0
  9. package/src/__tests__/question-voice.test.ts +208 -0
  10. package/src/__tests__/stated-date-extract.test.ts +119 -0
  11. package/src/__tests__/stated-date.test.ts +107 -0
  12. package/src/__tests__/tracker-done-stamp.test.ts +42 -0
  13. package/src/__tests__/tracker-timeline-component.test.tsx +81 -0
  14. package/src/__tests__/tracker-timeline-reader.test.ts +94 -0
  15. package/src/__tests__/tracker-timeline.test.ts +209 -0
  16. package/src/components/index.ts +1 -0
  17. package/src/components/pages/PlanningPage.tsx +16 -2
  18. package/src/components/pages/TrackerPage.tsx +8 -0
  19. package/src/components/pages/connections/ConnectionCard.tsx +12 -0
  20. package/src/components/pages/connections/bound-api.ts +1 -1
  21. package/src/components/pages/goals/FocusProgressHistory.tsx +77 -0
  22. package/src/components/pages/goals/GoalsPage.tsx +186 -0
  23. package/src/components/pages/goals/index.ts +4 -0
  24. package/src/components/pages/tracker/TrackerTimeline.tsx +123 -0
  25. package/src/components/pages/types.ts +2 -2
  26. package/src/corpus/client.ts +27 -1
  27. package/src/corpus/commitments.ts +3 -1
  28. package/src/corpus/extract.ts +8 -6
  29. package/src/corpus/focus-history.ts +104 -0
  30. package/src/corpus/goal-rows.ts +29 -0
  31. package/src/corpus/index.ts +6 -0
  32. package/src/corpus/questions/checkin-handle.ts +67 -0
  33. package/src/corpus/questions/checkin.ts +103 -0
  34. package/src/corpus/questions/index.ts +9 -0
  35. package/src/corpus/questions/respond.ts +76 -0
  36. package/src/corpus/questions/store.ts +5 -1
  37. package/src/corpus/questions/sync.ts +1 -0
  38. package/src/corpus/questions/types.ts +10 -2
  39. package/src/corpus/questions/voice-parse.ts +98 -0
  40. package/src/corpus/questions/voice.ts +225 -0
  41. package/src/corpus/spoken-time.ts +4 -4
  42. package/src/corpus/stated-date.ts +187 -0
  43. package/src/corpus/tracker-timeline-client.ts +117 -0
  44. package/src/corpus/tracker-timeline.ts +228 -0
  45. package/src/corpus/types.ts +25 -1
  46. package/src/corpus/work-item-logic.ts +1 -1
@@ -0,0 +1,81 @@
1
+ /**
2
+ * The strip on the Tracker: it reads once per real input, one range picker
3
+ * state drives chart and table, and an empty window says so.
4
+ */
5
+ import * as React from 'react';
6
+ import { act, render, screen, waitFor } from '@testing-library/react';
7
+ import userEvent from '@testing-library/user-event';
8
+ import { describe, expect, it, vi } from 'vitest';
9
+
10
+ import { TrackerTimeline } from '../components/pages/tracker/TrackerTimeline';
11
+ import type { TimelineRead } from '../corpus/tracker-timeline-client';
12
+
13
+ // Recharts measures a real layout box; jsdom has none.
14
+ vi.mock('recharts', async () => {
15
+ const actual = await vi.importActual<Record<string, unknown>>('recharts');
16
+ return { ...actual, ResponsiveContainer: ({ children }: { children: React.ReactNode }) => <div data-testid="chart">{children}</div> };
17
+ });
18
+
19
+ const NOW = Date.parse('2026-11-07T15:00:00Z');
20
+ const read = (over: Partial<TimelineRead> = {}): TimelineRead => ({
21
+ anchor: '2026-11-07', created: [], done: [], overdue: [], items: [], truncated: false, ...over,
22
+ });
23
+
24
+ describe('TrackerTimeline', () => {
25
+ it('reads once, not once per render', async () => {
26
+ const timeline = vi.fn().mockResolvedValue(read());
27
+ const { rerender } = render(<TrackerTimeline api={{ timeline }} orgId="o" now={NOW} filter={{}} />);
28
+ await screen.findByText('No to-dos in this window.');
29
+ for (let i = 0; i < 5; i += 1) rerender(<TrackerTimeline api={{ timeline }} orgId="o" now={NOW} filter={{}} />);
30
+ expect(timeline).toHaveBeenCalledTimes(1);
31
+ });
32
+
33
+ it('re-reads when a filter really changes, and debounces typing', async () => {
34
+ vi.useFakeTimers({ shouldAdvanceTime: true });
35
+ const timeline = vi.fn().mockResolvedValue(read());
36
+ const { rerender } = render(<TrackerTimeline api={{ timeline }} orgId="o" now={NOW} filter={{}} debounceMs={300} />);
37
+ await vi.waitFor(() => expect(timeline).toHaveBeenCalledTimes(1));
38
+ for (const s of ['i', 'in', 'inv']) rerender(<TrackerTimeline api={{ timeline }} orgId="o" now={NOW} filter={{ search: s }} debounceMs={300} />);
39
+ expect(timeline).toHaveBeenCalledTimes(1);
40
+ await act(async () => { await vi.advanceTimersByTimeAsync(400); });
41
+ expect(timeline).toHaveBeenCalledTimes(2);
42
+ expect(timeline.mock.calls[1][0]).toMatchObject({ search: 'inv' });
43
+ vi.useRealTimers();
44
+ });
45
+
46
+ it('lists the to-dos behind the numbers and flags estimated completions', async () => {
47
+ const timeline = vi.fn().mockResolvedValue(read({
48
+ items: [
49
+ { id: 'a', title: 'Send the proposal', status: 'open', dueAt: '2026-11-04', firstSeenAt: '2026-11-01', resolvedAt: null, updatedAt: null },
50
+ { id: 'b', title: 'Book the venue', status: 'done', dueAt: null, firstSeenAt: null, resolvedAt: null, updatedAt: '2026-11-06T09:00:00Z' },
51
+ ],
52
+ }));
53
+ render(<TrackerTimeline api={{ timeline }} orgId="o" now={NOW} filter={{}} />);
54
+ // created on the 1st and overdue since the 4th: two rows for one to-do
55
+ expect(await screen.findAllByText('Send the proposal')).toHaveLength(2);
56
+ expect(screen.getAllByText('Overdue').length).toBeGreaterThan(0);
57
+ expect(screen.getByText('Book the venue')).toBeInTheDocument();
58
+ expect(screen.getByTestId('timeline-estimated')).toHaveTextContent('1 done to-do has no completion date');
59
+ });
60
+
61
+ it('one range choice drives the table too', async () => {
62
+ const timeline = vi.fn().mockResolvedValue(read({
63
+ items: [
64
+ { id: 'old', title: 'Old thing', status: 'open', dueAt: null, firstSeenAt: '2026-09-20', resolvedAt: null, updatedAt: null },
65
+ { id: 'new', title: 'New thing', status: 'open', dueAt: null, firstSeenAt: '2026-11-05', resolvedAt: null, updatedAt: null },
66
+ ],
67
+ }));
68
+ render(<TrackerTimeline api={{ timeline }} orgId="o" now={NOW} filter={{}} />);
69
+ expect(await screen.findByText('New thing')).toBeInTheDocument();
70
+ expect(screen.queryByText('Old thing')).not.toBeInTheDocument(); // default 30D
71
+ await userEvent.click(screen.getByRole('tab', { name: '90 days' }));
72
+ await waitFor(() => expect(screen.getByText('Old thing')).toBeInTheDocument());
73
+ expect(timeline).toHaveBeenCalledTimes(1); // the range is a view, not a read
74
+ });
75
+
76
+ it('says plainly when the read fails', async () => {
77
+ const timeline = vi.fn().mockRejectedValue(Object.assign(new Error('x'), { status: 403 }));
78
+ render(<TrackerTimeline api={{ timeline }} orgId="o" now={NOW} filter={{}} />);
79
+ expect(await screen.findByRole('alert')).toHaveTextContent('do not have access');
80
+ });
81
+ });
@@ -0,0 +1,94 @@
1
+ /**
2
+ * The timeline's server reads. The point of every case: the browser asks the
3
+ * tenant for GROUPED COUNTS and one capped page of rows per series, and never
4
+ * walks the whole list.
5
+ */
6
+ import { describe, expect, it, vi } from 'vitest';
7
+
8
+ import { createTimelineReader } from '../corpus/tracker-timeline-client';
9
+
10
+ const NOW = Date.parse('2026-11-07T15:00:00Z');
11
+ const clock = { now: NOW, timeZone: 'UTC' };
12
+
13
+ type Call = { path: string; params: Record<string, unknown> };
14
+
15
+ function fakeHttp(counts: Record<string, Array<[string | null, number]>> = {}, rows: Array<Record<string, unknown>> = []) {
16
+ const calls: Call[] = [];
17
+ const get = vi.fn(async (path: string, opts?: { params?: Record<string, unknown> }) => {
18
+ const params = opts?.params ?? {};
19
+ calls.push({ path, params });
20
+ if (path.endsWith('/counts')) {
21
+ const all = counts[String(params.group_by)] ?? [];
22
+ const page = Number(params.page ?? 1);
23
+ const slice = all.slice((page - 1) * 2, page * 2);
24
+ return { results: slice.map(([v, c]) => ({ values: [v], count: c })), next: page * 2 < all.length ? 'more' : null, groupBy: [params.group_by] };
25
+ }
26
+ return { count: rows.length, results: rows, next: null };
27
+ });
28
+ return { http: { get } as never, calls };
29
+ }
30
+
31
+ const read = (http: never, filter = {}) =>
32
+ createTimelineReader({ http, type: 'commitment' })(filter, clock);
33
+
34
+ describe('createTimelineReader', () => {
35
+ it('asks for a grouped count per series on the counts endpoint', async () => {
36
+ const { http, calls } = fakeHttp({ 'attr.first_seen_at': [['2026-11-05T10:00:00Z', 3]] });
37
+ const out = await read(http);
38
+ const counted = calls.filter((c) => c.path === 'api/v1/entities/counts').map((c) => c.params.group_by).sort();
39
+ expect(counted).toEqual(['attr.due_at', 'attr.first_seen_at', 'attr.resolved_at']);
40
+ expect(calls.every((c) => c.params.type === 'commitment')).toBe(true);
41
+ expect(out.created).toEqual([{ value: '2026-11-05T10:00:00Z', count: 3 }]);
42
+ expect(out.anchor).toBe('2026-11-07');
43
+ });
44
+
45
+ it('follows the counts pages, not just the first', async () => {
46
+ const many: Array<[string, number]> = ['2026-11-01', '2026-11-02', '2026-11-03', '2026-11-04', '2026-11-05'].map((d) => [d, 1]);
47
+ const { http, calls } = fakeHttp({ 'attr.due_at': many });
48
+ const out = await read(http);
49
+ expect(out.overdue).toHaveLength(5);
50
+ expect(calls.filter((c) => c.params.group_by === 'attr.due_at')).toHaveLength(3);
51
+ });
52
+
53
+ it('reads at most one capped page of rows per series, never everything', async () => {
54
+ const { http, calls } = fakeHttp();
55
+ await read(http);
56
+ const lists = calls.filter((c) => c.path === 'api/v1/entities');
57
+ expect(lists.length).toBe(4); // created, done, estimated done, overdue
58
+ expect(lists.every((c) => Number(c.params.page_size) <= 200 && c.params.page === undefined)).toBe(true);
59
+ });
60
+
61
+ it('looks for already-done rows with no resolved_at, windowed by their last update', async () => {
62
+ const { http, calls } = fakeHttp();
63
+ await read(http);
64
+ const est = calls.find((c) => c.params['attr.resolved_at__isnull'] === 'true')!;
65
+ expect(est.params).toMatchObject({ 'attr.status': 'done' });
66
+ expect(est.params.updated_after).toBeDefined();
67
+ expect(est.params.group_by).toBeUndefined();
68
+ });
69
+
70
+ it('maps rows to timeline items, with updated_at for the estimate', async () => {
71
+ const { http } = fakeHttp({}, [
72
+ { id: 'c1', name: 'Send proposal', updated_at: '2026-11-06T09:00:00Z', data: { title: 'Send proposal', status: 'done', first_seen_at: '2026-11-01', due_at: null } },
73
+ ]);
74
+ const out = await read(http);
75
+ expect(out.items).toEqual([
76
+ { id: 'c1', title: 'Send proposal', status: 'done', dueAt: null, firstSeenAt: '2026-11-01', resolvedAt: null, updatedAt: '2026-11-06T09:00:00Z' },
77
+ ]);
78
+ });
79
+
80
+ it('makes no request for a series the filter empties, and carries the filter to the rest', async () => {
81
+ const { http, calls } = fakeHttp();
82
+ await read(http, { status: 'blocked', search: 'invoice' });
83
+ expect(calls.some((c) => c.params.group_by === 'attr.resolved_at')).toBe(false);
84
+ expect(calls.some((c) => c.params['attr.resolved_at__isnull'] === 'true')).toBe(false);
85
+ expect(calls.every((c) => c.params.search === 'invoice')).toBe(true);
86
+ });
87
+
88
+ it('says when a series had more rows than the page it read', async () => {
89
+ const http = { get: vi.fn(async (path: string) => (path.endsWith('/counts')
90
+ ? { results: [], next: null }
91
+ : { count: 450, results: [], next: 'x' })) } as never;
92
+ expect((await read(http)).truncated).toBe(true);
93
+ });
94
+ });
@@ -0,0 +1,209 @@
1
+ /**
2
+ * The Tracker timeline's arithmetic: which day a thing lands on, what counts as
3
+ * overdue, and what an empty window looks like. Pure, so every case here is a
4
+ * way the strip could draw a wrong number while the data underneath is fine.
5
+ */
6
+ import { describe, expect, it } from 'vitest';
7
+
8
+ import {
9
+ TIMELINE_DAYS,
10
+ bucketCounts,
11
+ buildTimeline,
12
+ completionOf,
13
+ dayOf,
14
+ timelineParams,
15
+ windowDayList,
16
+ type TimelineItem,
17
+ } from '../corpus/tracker-timeline';
18
+
19
+ const NOW = Date.parse('2026-11-07T15:00:00Z');
20
+
21
+ describe('dayOf', () => {
22
+ it('keeps a date-only value as it is', () => {
23
+ expect(dayOf('2026-11-03', 'America/Los_Angeles')).toBe('2026-11-03');
24
+ });
25
+ it('puts an instant on the reader’s local day, not UTC', () => {
26
+ // 02:00Z on the 4th is still the evening of the 3rd in Los Angeles.
27
+ expect(dayOf('2026-11-04T02:00:00Z', 'America/Los_Angeles')).toBe('2026-11-03');
28
+ expect(dayOf('2026-11-04T02:00:00Z', 'UTC')).toBe('2026-11-04');
29
+ });
30
+ it('is null for nothing or nonsense', () => {
31
+ expect(dayOf(null)).toBeNull();
32
+ expect(dayOf('not a date')).toBeNull();
33
+ });
34
+ });
35
+
36
+ describe('windowDayList', () => {
37
+ it('is the anchor day and the days before it, oldest first', () => {
38
+ expect(windowDayList('2026-11-07', 3)).toEqual(['2026-11-05', '2026-11-06', '2026-11-07']);
39
+ });
40
+ it('crosses a month boundary', () => {
41
+ expect(windowDayList('2026-03-01', 2)).toEqual(['2026-02-28', '2026-03-01']);
42
+ });
43
+ });
44
+
45
+ describe('bucketCounts', () => {
46
+ it('merges distinct timestamps that fall on one local day', () => {
47
+ const out = bucketCounts(
48
+ [
49
+ { value: '2026-11-04T02:00:00Z', count: 2 },
50
+ { value: '2026-11-03T20:00:00Z', count: 3 },
51
+ { value: '2026-11-04T09:00:00Z', count: 1 },
52
+ { value: null, count: 9 },
53
+ ],
54
+ 'America/Los_Angeles',
55
+ );
56
+ expect(out.get('2026-11-03')).toBe(5);
57
+ expect(out.get('2026-11-04')).toBe(1);
58
+ expect(out.size).toBe(2);
59
+ });
60
+ });
61
+
62
+ const item = (over: Partial<TimelineItem> & { id: string }): TimelineItem => ({
63
+ title: `Item ${over.id}`,
64
+ status: 'open',
65
+ dueAt: null,
66
+ firstSeenAt: null,
67
+ resolvedAt: null,
68
+ updatedAt: null,
69
+ ...over,
70
+ });
71
+
72
+ describe('completionOf', () => {
73
+ it('uses resolved_at when the item has one', () => {
74
+ expect(completionOf(item({ id: 'a', status: 'done', resolvedAt: '2026-11-05T10:00:00Z', updatedAt: '2026-11-06T10:00:00Z' }), 'UTC'))
75
+ .toEqual({ day: '2026-11-05', estimated: false });
76
+ });
77
+ it('falls back to updated_at and says it is an estimate', () => {
78
+ expect(completionOf(item({ id: 'a', status: 'done', updatedAt: '2026-11-06T10:00:00Z' }), 'UTC'))
79
+ .toEqual({ day: '2026-11-06', estimated: true });
80
+ });
81
+ it('is null for an item that is not done', () => {
82
+ expect(completionOf(item({ id: 'a', status: 'open', resolvedAt: '2026-11-05T10:00:00Z' }), 'UTC')).toBeNull();
83
+ });
84
+ });
85
+
86
+ describe('buildTimeline', () => {
87
+ const empty = { created: [], done: [], overdue: [], items: [] };
88
+
89
+ it('is a zero-filled series for every day of the window when nothing happened', () => {
90
+ const t = buildTimeline({ ...empty, anchor: '2026-11-07' }, NOW, 'UTC');
91
+ expect(t.series.map((s) => s.id)).toEqual(['created', 'done', 'overdue']);
92
+ for (const s of t.series) {
93
+ expect(s.points).toHaveLength(TIMELINE_DAYS);
94
+ expect(s.points.every((p) => p.value === 0)).toBe(true);
95
+ expect(s.points[TIMELINE_DAYS - 1].date).toBe('2026-11-07');
96
+ }
97
+ expect(t.points).toEqual([]);
98
+ expect(t.estimatedDone).toBe(0);
99
+ });
100
+
101
+ it('puts counts on their day', () => {
102
+ const t = buildTimeline(
103
+ {
104
+ ...empty, anchor: '2026-11-07',
105
+ created: [{ value: '2026-11-05T10:00:00Z', count: 4 }],
106
+ done: [{ value: '2026-11-06', count: 2 }],
107
+ overdue: [{ value: '2026-11-01', count: 1 }],
108
+ },
109
+ NOW, 'UTC',
110
+ );
111
+ const at = (id: string, d: string) => t.series.find((s) => s.id === id)!.points.find((p) => p.date === d)!.value;
112
+ expect(at('created', '2026-11-05')).toBe(4);
113
+ expect(at('done', '2026-11-06')).toBe(2);
114
+ expect(at('overdue', '2026-11-01')).toBe(1);
115
+ expect(at('overdue', '2026-11-05')).toBe(0);
116
+ });
117
+
118
+ it('ignores counts older than the longest window', () => {
119
+ const t = buildTimeline({ ...empty, anchor: '2026-11-07', created: [{ value: '2026-01-01', count: 7 }] }, NOW, 'UTC');
120
+ expect(t.series[0].points.reduce((s, p) => s + p.value, 0)).toBe(0);
121
+ });
122
+
123
+ it('adds estimated completions to the done series and reports how many', () => {
124
+ const t = buildTimeline(
125
+ {
126
+ ...empty, anchor: '2026-11-07',
127
+ done: [{ value: '2026-11-06', count: 1 }],
128
+ items: [item({ id: 'old', status: 'done', updatedAt: '2026-11-06T09:00:00Z' })],
129
+ },
130
+ NOW, 'UTC',
131
+ );
132
+ const done = t.series.find((s) => s.id === 'done')!;
133
+ expect(done.points.find((p) => p.date === '2026-11-06')!.value).toBe(2);
134
+ expect(t.estimatedDone).toBe(1);
135
+ });
136
+
137
+ describe('overdue rule', () => {
138
+ const events = (items: TimelineItem[]) =>
139
+ buildTimeline({ ...empty, anchor: '2026-11-07', items }, NOW, 'UTC').points.flatMap((p) => p.events ?? []);
140
+
141
+ it('lists an open item past its date as overdue on its due day', () => {
142
+ const ev = events([item({ id: 'a', dueAt: '2026-11-02' })]);
143
+ expect(ev).toHaveLength(1);
144
+ expect(ev[0]).toMatchObject({ id: 'overdue:a', category: 'overdue', status: 'Overdue', delta: 0, tone: 'down' });
145
+ });
146
+ it('never lists a done or dropped item as overdue', () => {
147
+ expect(events([item({ id: 'a', status: 'done', dueAt: '2026-11-02' })]).filter((e) => e.category === 'overdue')).toEqual([]);
148
+ expect(events([item({ id: 'b', status: 'dropped', dueAt: '2026-11-02' })]).filter((e) => e.category === 'overdue')).toEqual([]);
149
+ });
150
+ it('does not list an item due in the future', () => {
151
+ expect(events([item({ id: 'a', dueAt: '2026-11-20' })]).filter((e) => e.category === 'overdue')).toEqual([]);
152
+ });
153
+ });
154
+
155
+ it('lists the to-dos as events and groups them under their day', () => {
156
+ const t = buildTimeline(
157
+ {
158
+ ...empty, anchor: '2026-11-07',
159
+ items: [
160
+ item({ id: 'a', firstSeenAt: '2026-11-05T10:00:00Z' }),
161
+ item({ id: 'b', firstSeenAt: '2026-11-05T12:00:00Z', status: 'done', resolvedAt: '2026-11-06T08:00:00Z' }),
162
+ ],
163
+ },
164
+ NOW, 'UTC',
165
+ );
166
+ const day5 = t.points.find((p) => p.date === '2026-11-05')!;
167
+ expect(day5.events!.map((e) => e.id).sort()).toEqual(['created:a', 'created:b']);
168
+ expect(day5.value).toBe(2);
169
+ expect(t.points.find((p) => p.date === '2026-11-06')!.events![0]).toMatchObject({ id: 'done:b', status: 'Done', tone: 'up' });
170
+ });
171
+ });
172
+
173
+ describe('timelineParams', () => {
174
+ const base = { now: NOW, timeZone: 'UTC' };
175
+
176
+ it('asks the server for each series, windowed and grouped by the date attribute', () => {
177
+ const p = timelineParams('created', {}, base);
178
+ expect(p).toMatchObject({ group_by: 'attr.first_seen_at' });
179
+ expect(p['attr.first_seen_at__gte']).toBe('2026-08-09');
180
+ });
181
+
182
+ it('counts only done items for the done series', () => {
183
+ expect(timelineParams('done', {}, base)).toMatchObject({ group_by: 'attr.resolved_at', 'attr.status': 'done' });
184
+ });
185
+
186
+ it('counts only owed items past their date for the overdue series', () => {
187
+ const p = timelineParams('overdue', {}, base);
188
+ expect(p).toMatchObject({ group_by: 'attr.due_at', 'attr.status__in': 'open,in_progress,blocked' });
189
+ expect(p['attr.due_at__lt']).toBe('2026-11-07T15:00:00.000Z');
190
+ });
191
+
192
+ it('carries the page’s filters to every series', () => {
193
+ const p = timelineParams('created', { search: 'proposal', owner: 'Rae' }, base);
194
+ expect(p).toMatchObject({ search: 'proposal', 'attr.owner_name__icontains': 'Rae' });
195
+ });
196
+
197
+ it('narrows to the chosen status, and a done-only series has nothing under a blocked chip', () => {
198
+ expect(timelineParams('created', { status: 'blocked' }, base)).toMatchObject({ 'attr.status': 'blocked' });
199
+ expect(timelineParams('done', { status: 'blocked' }, base)).toBeNull();
200
+ expect(timelineParams('overdue', { status: 'blocked' }, base)).toMatchObject({ 'attr.status': 'blocked' });
201
+ });
202
+
203
+ it('the overdue chip narrows every series to owed items past their date', () => {
204
+ const c = timelineParams('created', { overdueOnly: true }, base);
205
+ expect(c).toMatchObject({ 'attr.status__in': 'open,in_progress,blocked' });
206
+ expect(c!['attr.due_at__lt']).toBe('2026-11-07T15:00:00.000Z');
207
+ expect(timelineParams('done', { overdueOnly: true }, base)).toBeNull();
208
+ });
209
+ });
@@ -53,6 +53,7 @@ export { ExternalLinkChip } from './pages/task-tracker/ExternalLinkChip';
53
53
  // row, the honesty banner, the overdue/changed predicates — so two views over
54
54
  // one list cannot drift into disagreeing about what they mean.
55
55
  export * from './pages/PlanningPage';
56
+ export * from './pages/goals';
56
57
  export * from './pages/LiabilityPlanPage';
57
58
  export {
58
59
  PRIORITY_LABELS,
@@ -33,6 +33,7 @@ import * as React from 'react';
33
33
 
34
34
  import { displayProgress, focusStatusLabel, standingLabel } from '../../corpus/planning';
35
35
  import { FocusDocuments } from '../FocusDocuments';
36
+ import { FocusProgressHistory } from './goals/FocusProgressHistory';
36
37
  import {
37
38
  WorkItemRow,
38
39
  compareForScreen,
@@ -121,11 +122,18 @@ export interface PlanningPageProps {
121
122
  now?: number;
122
123
  /** The reader's IANA zone, for "overdue" and "next due". Default UTC. */
123
124
  timeZone?: string;
125
+ /**
126
+ * Optional CONTROLLED selection: the id of the focus whose detail is open.
127
+ * Lets a host route straight to one (`/planning?focus=<id>`), e.g. from the
128
+ * Goals table. Omit both and the page keeps its own selection.
129
+ */
130
+ focusId?: string | null;
131
+ onFocusChange?: (focusId: string | null) => void;
124
132
  classNames?: Partial<Record<PlanningSlot, string>>;
125
133
  }
126
134
 
127
135
  export function PlanningPage({
128
- api, scope, onOpenDocument, now, timeZone, classNames = {},
136
+ api, scope, onOpenDocument, now, timeZone, focusId, onFocusChange, classNames = {},
129
137
  }: PlanningPageProps) {
130
138
  const cn = { ...DEFAULTS, ...classNames };
131
139
 
@@ -140,7 +148,12 @@ export function PlanningPage({
140
148
 
141
149
  const [focuses, setFocuses] = React.useState<Focus[]>([]);
142
150
  const [standings, setStandings] = React.useState<Record<string, FocusStanding>>({});
143
- const [selected, setSelected] = React.useState<string | null>(null);
151
+ const [innerSelected, setInnerSelected] = React.useState<string | null>(null);
152
+ const selected = focusId !== undefined ? focusId : innerSelected;
153
+ const setSelected = React.useCallback((id: string | null) => {
154
+ setInnerSelected(id);
155
+ onFocusChange?.(id);
156
+ }, [onFocusChange]);
144
157
  const [items, setItems] = React.useState<Commitment[]>([]);
145
158
  const [applied, setApplied] = React.useState<string[]>([]);
146
159
  const [members, setMembers] = React.useState<Array<{ sub: string; email: string; name?: string }>>([]);
@@ -372,6 +385,7 @@ export function PlanningPage({
372
385
  classNames={cn}
373
386
  onSelect={() => setSelected(null)}
374
387
  />
388
+ <FocusProgressHistory focus={selectedFocus} api={api} />
375
389
  {error ? <p className={cn.error} role="alert">{error}</p> : null}
376
390
  </section>
377
391
 
@@ -34,6 +34,8 @@ import type { MemberConnectionsApi } from './types';
34
34
  import { failureMessage, unfilteredMessage } from './work-items';
35
35
  import { CompactItemRow } from './home/CompactItemRow';
36
36
  import { TrackerBoard } from './tracker/TrackerBoard';
37
+ import { TrackerTimeline } from './tracker/TrackerTimeline';
38
+ import { filterFromChip } from '../../corpus/tracker-timeline';
37
39
  import { TrackerToolbar, type TrackerView } from './tracker/TrackerToolbar';
38
40
  import { DEFAULT_TRACKER_SORT } from '../../corpus/tracker-sort';
39
41
  import { STALE_DAYS, groupTracker } from '../../corpus/tracker-groups';
@@ -463,6 +465,12 @@ export function TrackerPage({
463
465
  ))}
464
466
  </div>
465
467
  ) : null}
468
+ {api.timeline ? (
469
+ <TrackerTimeline
470
+ api={api} orgId={scope.orgId} now={clock} timeZone={timeZone}
471
+ filter={filterFromChip(quick, { search: filterText })}
472
+ />
473
+ ) : null}
466
474
  {filtering && owed === 0 && rows.length > 0 ? <p className={cn.muted}>No to-dos match{filterText.trim() ? ` “${filterText.trim()}”` : ' this filter'}.</p> : null}
467
475
  {rows.length > 0 ? (
468
476
  <TrackerToolbar sort={sort} onSort={setSort} view={view} onView={setView} inputClassName={cn.input} />
@@ -30,6 +30,7 @@ export function ConnectionCard({
30
30
  const [busy, setBusy] = React.useState('');
31
31
  const [error, setError] = React.useState('');
32
32
  const [notice, setNotice] = React.useState('');
33
+ const [checkWhy, setCheckWhy] = React.useState<{ reason: string; next_step: string } | null>(null);
33
34
  /** Sentences the SERVER wrote about the last settings save. Never composed here. */
34
35
  const [notices, setNotices] = React.useState<string[]>([]);
35
36
  const [replacing, setReplacing] = React.useState(false);
@@ -133,8 +134,10 @@ export function ConnectionCard({
133
134
  className={cn.button}
134
135
  disabled={Boolean(busy)}
135
136
  onClick={() => void guard('check', async () => {
137
+ setCheckWhy(null);
136
138
  const res = await api.checkConnection(connection.id);
137
139
  setNotice(res.detail || (res.ok ? 'Connection is healthy.' : ''));
140
+ setCheckWhy(res.reason ? { reason: res.reason, next_step: res.next_step ?? '' } : null);
138
141
  onChanged();
139
142
  })}
140
143
  >
@@ -394,6 +397,15 @@ export function ConnectionCard({
394
397
  </CapabilityPicker>
395
398
 
396
399
  {notice ? <p className={cn.muted}>{notice}</p> : null}
400
+ {/* A key that authenticated but sees nothing: the connector's own words for
401
+ why and what to do (bd startsim-768w.38.16). Generic, so no vendor is named
402
+ here, and `detail` above is never replaced by it. */}
403
+ {checkWhy ? (
404
+ <div className={cn.card} data-check-reason>
405
+ <p className="text-sm text-gray-900">{checkWhy.reason}</p>
406
+ {checkWhy.next_step ? <p className={cn.muted}>{checkWhy.next_step}</p> : null}
407
+ </div>
408
+ ) : null}
397
409
  {/* WHAT THE CHANGE COSTS, in the server's words. Rendered verbatim: this
398
410
  file names no vendor and cannot know which settings restart a walk. */}
399
411
  {notices.map((said) => (
@@ -51,7 +51,7 @@ export interface BoundApi {
51
51
  config?: Record<string, unknown>;
52
52
  capabilities_enabled?: string[];
53
53
  }): Promise<Connection>;
54
- checkConnection(id: string): Promise<{ ok: boolean; account_label: string; detail: string }>;
54
+ checkConnection(id: string): Promise<{ ok: boolean; account_label: string; detail: string; reason?: string; next_step?: string }>;
55
55
  rotateCredential(id: string, credentials: Record<string, unknown>): Promise<Connection>;
56
56
  disconnect(id: string): Promise<void>;
57
57
  updateConnection?(id: string, input: {
@@ -0,0 +1,77 @@
1
+ 'use client';
2
+
3
+ /**
4
+ * A focus's progress over time, drawn by the shared `RangeTimelineChart`
5
+ * (`@startsimpli/ui/insights`) from the tenant's revision trail. See
6
+ * `corpus/focus-history.ts` for what the data is and what it is not.
7
+ *
8
+ * Shown only for a MEASURABLE focus (a target above zero): a qualitative focus has
9
+ * no progress number to chart. `today` is injected and the clock is read once at
10
+ * mount; this never calls `Date.now()` in render.
11
+ */
12
+ import * as React from 'react';
13
+ import { RangeTimelineChart } from '@startsimpli/ui/insights';
14
+
15
+ import { currentValueSeries, loadCurrentValueRevisions, type FocusRevision } from '../../../corpus/focus-history';
16
+ import type { Focus, PlanningApi } from '../../../corpus/types';
17
+
18
+ export interface FocusProgressHistoryProps {
19
+ focus: Focus;
20
+ api: Pick<PlanningApi, 'listFocusRevisions'>;
21
+ /** ISO date the window ends on. Defaults to the day this mounted. */
22
+ today?: string;
23
+ className?: string;
24
+ }
25
+
26
+ type State = { kind: 'loading' } | { kind: 'ready'; revisions: FocusRevision[] } | { kind: 'unavailable' };
27
+
28
+ export function FocusProgressHistory({ focus, api, today, className }: FocusProgressHistoryProps) {
29
+ const [mounted] = React.useState(() => new Date().toISOString().slice(0, 10));
30
+ const anchor = today ?? mounted;
31
+ const [state, setState] = React.useState<State>({ kind: 'loading' });
32
+ const apiRef = React.useRef(api);
33
+ apiRef.current = api;
34
+ const measurable = typeof focus.targetValue === 'number' && focus.targetValue > 0;
35
+ const read = api.listFocusRevisions;
36
+
37
+ React.useEffect(() => {
38
+ if (!read || !measurable) return undefined;
39
+ let live = true;
40
+ setState({ kind: 'loading' });
41
+ loadCurrentValueRevisions((page) => apiRef.current.listFocusRevisions!(focus.id, { page, pageSize: 100 }), anchor)
42
+ .then((revisions) => { if (live) setState({ kind: 'ready', revisions }); })
43
+ .catch(() => { if (live) setState({ kind: 'unavailable' }); });
44
+ return () => { live = false; };
45
+ }, [read, measurable, focus.id, anchor]);
46
+
47
+ const { points, since } = React.useMemo(
48
+ () => (state.kind === 'ready' ? currentValueSeries(state.revisions, anchor) : { points: [] as never[], since: undefined }),
49
+ [state, anchor],
50
+ );
51
+
52
+ if (!read || !measurable) return null;
53
+ return (
54
+ <section className={className ?? 'space-y-2'} aria-label="Progress over time" data-testid="focus-progress-history">
55
+ {state.kind === 'loading' ? <p className="text-sm text-gray-500">Loading progress history…</p> : null}
56
+ {state.kind === 'unavailable' ? (
57
+ <p className="text-sm text-gray-500">Progress history is not available for this workspace yet.</p>
58
+ ) : null}
59
+ {state.kind === 'ready' && points.length === 0 ? (
60
+ <p className="text-sm text-gray-500">No progress changes recorded yet. The chart fills in as the current value is updated.</p>
61
+ ) : null}
62
+ {state.kind === 'ready' && points.length > 0 ? (
63
+ <>
64
+ <RangeTimelineChart
65
+ title="Progress over time"
66
+ points={points}
67
+ anchor={anchor}
68
+ direction="back"
69
+ defaultRange="90d"
70
+ height={240}
71
+ />
72
+ <p className="text-xs text-gray-500">Recorded since {since}. Earlier values were not tracked.</p>
73
+ </>
74
+ ) : null}
75
+ </section>
76
+ );
77
+ }