@startsimpli/integrations 0.2.201 → 0.2.203

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 (85) hide show
  1. package/package.json +6 -6
  2. package/src/__tests__/briefing-markdown.test.ts +64 -0
  3. package/src/__tests__/converse-cards.test.ts +53 -0
  4. package/src/__tests__/converse-page.test.tsx +148 -37
  5. package/src/__tests__/converse-roci.test.ts +22 -0
  6. package/src/__tests__/converse-structure.test.ts +27 -0
  7. package/src/__tests__/converse-view.test.ts +46 -0
  8. package/src/__tests__/corpus-tracker.test.tsx +32 -176
  9. package/src/__tests__/data-table-logic.test.ts +75 -0
  10. package/src/__tests__/data-table.test.tsx +133 -0
  11. package/src/__tests__/home-brief.test.tsx +25 -40
  12. package/src/__tests__/library-call-shape.test.tsx +164 -0
  13. package/src/__tests__/load-error.test.tsx +1 -1
  14. package/src/__tests__/mini-markdown.test.tsx +24 -0
  15. package/src/__tests__/overview-page.test.tsx +36 -6
  16. package/src/__tests__/plan-shell.test.tsx +6 -4
  17. package/src/__tests__/timeline-events.test.ts +65 -0
  18. package/src/__tests__/timeline-table.test.tsx +66 -0
  19. package/src/__tests__/todo-table-model.test.ts +75 -0
  20. package/src/__tests__/todo-table.test.tsx +202 -0
  21. package/src/__tests__/tracker-timeline-component.test.tsx +4 -4
  22. package/src/__tests__/tracker-timeline-reader.test.ts +1 -1
  23. package/src/comms/__tests__/app-sends-page.test.tsx +69 -0
  24. package/src/comms/api/comms.ts +23 -0
  25. package/src/comms/components/ResultsPanel.tsx +2 -2
  26. package/src/comms/components/SendLog.tsx +20 -8
  27. package/src/comms/components/index.ts +1 -0
  28. package/src/comms/components/pages/AppSendsPage.tsx +58 -0
  29. package/src/comms/hooks/index.ts +8 -3
  30. package/src/components/FolderTree.tsx +12 -3
  31. package/src/components/index.ts +2 -1
  32. package/src/components/pages/ConversePage.tsx +114 -105
  33. package/src/components/pages/LibraryPage.tsx +63 -24
  34. package/src/components/pages/TrackerPage.tsx +170 -474
  35. package/src/components/pages/converse/CardView.tsx +72 -0
  36. package/src/components/pages/converse/SettingsMenu.tsx +37 -0
  37. package/src/components/pages/converse/Thread.tsx +48 -33
  38. package/src/components/pages/converse/useNeedsYou.ts +60 -0
  39. package/src/components/pages/home/BriefCard.tsx +16 -7
  40. package/src/components/pages/home/HomeBriefPage.tsx +6 -91
  41. package/src/components/pages/home/MiniMarkdown.tsx +51 -0
  42. package/src/components/pages/home/{DueSoonLine.tsx → dueSoonText.ts} +2 -11
  43. package/src/components/pages/home/index.ts +1 -1
  44. package/src/components/pages/overview/OverviewPage.tsx +46 -83
  45. package/src/components/pages/plan/TalkPage.tsx +5 -14
  46. package/src/components/pages/plan/TimelinePage.tsx +4 -2
  47. package/src/components/pages/tracker/SweepPanel.tsx +108 -0
  48. package/src/components/pages/tracker/TimelineTable.tsx +70 -0
  49. package/src/components/pages/tracker/TrackerTimeline.tsx +32 -15
  50. package/src/components/table/DataTable.tsx +92 -0
  51. package/src/components/table/RowMenu.tsx +35 -0
  52. package/src/components/table/TablePagination.tsx +63 -0
  53. package/src/components/table/TableToolbar.tsx +56 -0
  54. package/src/components/table/TodoTable.tsx +142 -0
  55. package/src/components/table/index.ts +10 -0
  56. package/src/components/table/table-logic.ts +60 -0
  57. package/src/components/table/todo-model.ts +93 -0
  58. package/src/corpus/briefing/generate-weekly.ts +4 -0
  59. package/src/corpus/briefing/generate.ts +4 -0
  60. package/src/corpus/briefing/index.ts +1 -0
  61. package/src/corpus/briefing/markdown.ts +71 -0
  62. package/src/corpus/client.ts +38 -146
  63. package/src/corpus/converse/cards.ts +69 -0
  64. package/src/corpus/converse/index.ts +6 -0
  65. package/src/corpus/converse/roci.ts +13 -0
  66. package/src/corpus/converse/structure.ts +39 -0
  67. package/src/corpus/converse/view.ts +34 -0
  68. package/src/corpus/index.ts +2 -0
  69. package/src/corpus/participants.ts +220 -0
  70. package/src/corpus/timeline-events.ts +83 -0
  71. package/src/corpus/tracker-sort.ts +9 -3
  72. package/src/corpus/tracker-timeline-client.ts +2 -0
  73. package/src/corpus/tracker-timeline.ts +4 -0
  74. package/src/corpus/types.ts +32 -5
  75. package/src/native/app/__tests__/plan-talk-registry.test.tsx +2 -1
  76. package/src/native/converse/ConverseScreen.tsx +3 -5
  77. package/src/native/home/HomeScreen.tsx +1 -1
  78. package/src/native/home/tab.tsx +1 -2
  79. package/src/native/plan/PlanTab.tsx +1 -2
  80. package/src/native/plan/__tests__/plan-tab.test.tsx +5 -5
  81. package/src/native/talk/TalkTab.tsx +1 -1
  82. package/src/native/talk/__tests__/talk-tab.test.tsx +1 -1
  83. package/src/__tests__/home-needs-your-call.test.tsx +0 -65
  84. package/src/components/pages/tracker/TrackerBoard.tsx +0 -45
  85. package/src/components/pages/tracker/TrackerToolbar.tsx +0 -44
@@ -0,0 +1,72 @@
1
+ /**
2
+ * ONE card component for every typed item in the thread: chip, who asked, time / title / one-line detail / actions.
3
+ * Same layout, spacing and type scale for a question, an approval, the brief, a task, an email and a result; only the
4
+ * chip colour and the actions differ. One primary button per card. Answered cards stay in place and show the answer.
5
+ */
6
+ import * as React from 'react';
7
+
8
+ import { CARD_CHIP, type CardType, type ThreadCard } from '../../../corpus/converse/cards';
9
+ import { Markdown } from '../../Markdown';
10
+
11
+ const CHIP: Record<CardType, string> = {
12
+ question: 'bg-indigo-50 text-indigo-700',
13
+ approval: 'bg-amber-50 text-amber-800',
14
+ result: 'bg-emerald-50 text-emerald-700',
15
+ brief: 'bg-gray-100 text-gray-700',
16
+ task: 'bg-gray-100 text-gray-700',
17
+ email: 'bg-gray-100 text-gray-700',
18
+ };
19
+
20
+ export interface CardViewProps {
21
+ card: ThreadCard;
22
+ busy?: boolean;
23
+ error?: string | null;
24
+ onAction: (card: ThreadCard, actionId: string) => void;
25
+ /** A typed reply, for a question with no fixed options. */
26
+ onReply?: (card: ThreadCard, text: string) => void;
27
+ }
28
+
29
+ function timeLabel(iso: string): string {
30
+ const d = new Date(iso);
31
+ return Number.isNaN(d.getTime()) ? '' : d.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', hour12: false });
32
+ }
33
+
34
+ export function CardView({ card, busy, error, onAction, onReply }: CardViewProps) {
35
+ const [reply, setReply] = React.useState('');
36
+ const chip = card.resolved ? CARD_CHIP.result : CARD_CHIP[card.type];
37
+ const chipClass = card.resolved ? CHIP.result : CHIP[card.type];
38
+ return (
39
+ <article className="space-y-2 rounded-xl border border-gray-200 bg-white p-4 text-sm text-gray-900" data-testid="thread-card" data-card-type={card.resolved ? 'result' : card.type} data-card-id={card.id}>
40
+ <header className="flex items-center gap-2 text-xs text-gray-500">
41
+ <span className={`rounded-full px-2 py-0.5 font-semibold tracking-wide ${chipClass}`}>{chip}</span>
42
+ <span>from {card.from}</span>
43
+ {card.sample ? <span className="rounded-full border border-gray-300 px-2 py-0.5 font-semibold tracking-wide text-gray-600" data-testid="card-sample">TEST SAMPLE</span> : null}
44
+ <span className="ml-auto">{timeLabel(card.at)}</span>
45
+ </header>
46
+ <h3 className="text-base font-semibold text-gray-900">{card.title}</h3>
47
+ {card.body ? <Markdown text={card.body} className="text-gray-700" /> : null}
48
+ {card.detail ? <p className="text-gray-600">{card.detail}</p> : null}
49
+ {card.resolved ? <p className="font-medium text-emerald-700" data-testid="card-resolved">Answered: {card.resolved}</p> : null}
50
+ {error ? <p role="alert" className="text-red-700">{error}</p> : null}
51
+ {!card.resolved && card.actions.length ? (
52
+ <div className="flex flex-wrap items-center gap-2">
53
+ {card.actions.map((a) => (
54
+ <button
55
+ key={a.id} type="button" disabled={busy} onClick={() => onAction(card, a.id)}
56
+ className={a.primary
57
+ ? 'rounded-lg bg-indigo-600 px-3 py-1.5 font-semibold text-white hover:bg-indigo-700 disabled:opacity-50'
58
+ : 'rounded-lg border border-gray-300 bg-white px-3 py-1.5 font-semibold text-gray-800 hover:bg-gray-50 disabled:opacity-50'}
59
+ >{a.label}</button>
60
+ ))}
61
+ </div>
62
+ ) : null}
63
+ {!card.resolved && card.freeReply && onReply ? (
64
+ <form className="flex items-center gap-2" onSubmit={(e) => { e.preventDefault(); const t = reply.trim(); if (t) { onReply(card, t); setReply(''); } }}>
65
+ <input aria-label={`Reply to ${card.title}`} value={reply} onChange={(e) => setReply(e.target.value)} placeholder="Your answer" className="min-w-0 flex-1 rounded-lg border border-gray-300 px-3 py-1.5 text-base" />
66
+ <button type="submit" disabled={busy || !reply.trim()} className="rounded-lg bg-indigo-600 px-3 py-1.5 font-semibold text-white hover:bg-indigo-700 disabled:opacity-50">Send</button>
67
+ </form>
68
+ ) : null}
69
+ {!card.resolved && card.more ? <p className="text-xs text-gray-500">{card.more} more question{card.more === 1 ? '' : 's'} after this one</p> : null}
70
+ </article>
71
+ );
72
+ }
@@ -0,0 +1,37 @@
1
+ /** The ONE settings menu: speech speed, replay the last reply, save the conversation. Nothing else on the screen carries these. */
2
+ import * as React from 'react';
3
+
4
+ import { SPEEDS, normalizeSpeed } from './speed';
5
+
6
+ export interface SettingsMenuProps {
7
+ speed: number;
8
+ onSpeed: (v: number) => void;
9
+ canReplay: boolean;
10
+ onReplay: () => void;
11
+ canSave: boolean;
12
+ onSave: () => void;
13
+ }
14
+
15
+ export function SettingsMenu({ speed, onSpeed, canReplay, onReplay, canSave, onSave }: SettingsMenuProps) {
16
+ const [open, setOpen] = React.useState(false);
17
+ const item = 'block w-full rounded-md px-3 py-2 text-left text-sm text-gray-800 hover:bg-gray-100 disabled:opacity-40';
18
+ return (
19
+ <div className="relative">
20
+ <button type="button" aria-label="Settings" aria-expanded={open} aria-haspopup="menu" data-testid="converse-settings" onClick={() => setOpen((o) => !o)} className="flex h-10 w-10 items-center justify-center rounded-lg border border-gray-200 bg-white text-gray-600 hover:bg-gray-50">
21
+ <svg aria-hidden="true" viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><circle cx="12" cy="12" r="3" /><path d="M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1.1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1.1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9a1.7 1.7 0 0 0 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z" /></svg>
22
+ </button>
23
+ {open ? (
24
+ <div role="menu" data-testid="converse-settings-menu" className="absolute right-0 z-10 mt-2 w-56 rounded-xl border border-gray-200 bg-white p-2 shadow-lg">
25
+ <label className="flex items-center justify-between gap-2 px-3 py-2 text-sm text-gray-800" htmlFor="converse-speed">
26
+ Speech speed
27
+ <select id="converse-speed" data-testid="converse-speed" aria-label="Speech speed" value={speed} onChange={(e) => onSpeed(normalizeSpeed(e.target.value))} className="rounded-md border border-gray-300 bg-white px-2 py-1 text-sm">
28
+ {SPEEDS.map((v) => <option key={v} value={v}>{v}x</option>)}
29
+ </select>
30
+ </label>
31
+ <button type="button" role="menuitem" className={item} disabled={!canReplay} onClick={() => { setOpen(false); onReplay(); }}>Replay last reply</button>
32
+ <button type="button" role="menuitem" className={item} disabled={!canSave} onClick={() => { setOpen(false); onSave(); }}>Save this conversation</button>
33
+ </div>
34
+ ) : null}
35
+ </div>
36
+ );
37
+ }
@@ -1,46 +1,61 @@
1
- /** The thread: every line of the one conversation, in order. Plain list in normal flow: nothing is ever laid over it. */
1
+ /**
2
+ * The thread: ONE list, in time order. Roci's words (structured Markdown), what you said, the relay, and every
3
+ * typed card sit in it together. Plain list in normal flow: nothing is ever laid over it.
4
+ */
2
5
  import * as React from 'react';
3
6
 
7
+ import type { ThreadCard } from '../../../corpus/converse/cards';
8
+ import { structureReply } from '../../../corpus/converse/structure';
4
9
  import type { MeetingLine } from '../../../corpus/converse/meeting';
10
+ import { Markdown } from '../../Markdown';
11
+ import { CardView, type CardViewProps } from './CardView';
5
12
 
6
- export type ThreadSlot = 'bubbleUser' | 'bubbleReply' | 'muted' | 'chip' | 'replay';
13
+ export type ThreadItem = { kind: 'card'; card: ThreadCard } | { kind: 'line'; line: MeetingLine };
7
14
 
8
15
  export interface ThreadProps {
9
- lines: MeetingLine[];
10
- cx: (slot: ThreadSlot) => string;
11
- /** Plays one assistant line's audio again; absent when the line has no sound. */
12
- canReplay: (line: MeetingLine) => boolean;
13
- onReplay: (line: MeetingLine) => void;
16
+ items: ThreadItem[];
17
+ assistantName: string;
18
+ cardProps: Omit<CardViewProps, 'card' | 'busy' | 'error'> & { busyId?: string | null; errors?: Record<string, string> };
14
19
  }
15
20
 
16
- const WHO: Record<MeetingLine['role'], string> = { user: 'You: ', assistant: 'Tandem: ', relay: 'Relay: ', system: '' };
21
+ const Avatar = ({ name }: { name: string }) => (
22
+ <span aria-hidden="true" className="flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-indigo-50 text-xs font-bold text-indigo-700">{name.slice(0, 1)}</span>
23
+ );
17
24
 
18
- export function Thread({ lines, cx, canReplay, onReplay }: ThreadProps) {
25
+ export function Thread({ items, assistantName, cardProps }: ThreadProps) {
26
+ const { busyId, errors, ...rest } = cardProps;
19
27
  return (
20
- <ol className="space-y-2" aria-label="Conversation" data-testid="converse-thread">
21
- {lines.map((line, i) => (
22
- <li
23
- key={i}
24
- data-from={line.role}
25
- data-intent={line.intent}
26
- className={line.role === 'user' ? cx('bubbleUser') : line.role === 'system' ? cx('muted') : cx('bubbleReply')}
27
- >
28
- {line.role === 'system' ? null : <span className={line.role === 'relay' ? 'mr-1 font-medium' : 'sr-only'}>{WHO[line.role]}</span>}
29
- <span>{line.text}</span>
30
- {line.role === 'assistant' && canReplay(line) ? (
31
- <button type="button" className={`${cx('replay')} ml-2 align-middle`} aria-label="Play this reply" title="Play this reply" onClick={() => onReplay(line)}>
32
- <svg aria-hidden="true" viewBox="0 0 24 24" width="16" height="16" fill="currentColor"><path d="M3 9v6h4l5 5V4L7 9H3zm13.5 3a4.5 4.5 0 0 0-2.5-4v8a4.5 4.5 0 0 0 2.5-4z" /></svg>
33
- </button>
34
- ) : null}
35
- {line.role === 'assistant' && line.sources?.length ? (
36
- <ul className="mt-1 flex flex-wrap gap-1" aria-label="Sources">
37
- {line.sources.map((s, k) => (
38
- <li key={`${s.id}-${k}`} className={cx('chip')} data-testid="converse-source" title={s.id}>{s.kind}: {s.title}</li>
39
- ))}
40
- </ul>
41
- ) : null}
42
- </li>
43
- ))}
28
+ <ol className="space-y-3" aria-label="Conversation" data-testid="converse-thread">
29
+ {items.map((item, i) => {
30
+ if (item.kind === 'card') {
31
+ return (
32
+ <li key={item.card.id} className="flex items-start gap-3">
33
+ <Avatar name={assistantName} />
34
+ <div className="min-w-0 flex-1"><CardView card={item.card} busy={busyId === item.card.id} error={errors?.[item.card.id]} {...rest} /></div>
35
+ </li>
36
+ );
37
+ }
38
+ const { line } = item;
39
+ if (line.role === 'system') return <li key={i} data-from="system" className="text-center text-xs text-gray-500">{line.text}</li>;
40
+ if (line.role === 'user') {
41
+ return <li key={i} data-from="user" className="flex justify-end"><span className="max-w-[80%] rounded-2xl bg-indigo-600 px-4 py-2 text-sm text-white">{line.text}</span></li>;
42
+ }
43
+ return (
44
+ <li key={i} data-from={line.role} data-intent={line.intent} className="flex items-start gap-3">
45
+ <Avatar name={line.role === 'relay' ? 'Relay' : assistantName} />
46
+ <div className="min-w-0 flex-1 rounded-xl border border-gray-200 bg-white p-4 text-sm text-gray-900">
47
+ {line.role === 'relay' ? null : <span className="sr-only">{`${assistantName}: `}</span>}
48
+ {line.role === 'relay' ? <span className="mr-1 text-xs font-semibold uppercase tracking-wide text-gray-500">Relay</span> : null}
49
+ <Markdown text={line.role === 'assistant' ? structureReply(line.text) : line.text} />
50
+ {line.sources?.length ? (
51
+ <ul className="mt-2 flex flex-wrap gap-1" aria-label="Sources">
52
+ {line.sources.map((s, k) => <li key={`${s.id}-${k}`} className="rounded-full border border-gray-200 bg-gray-50 px-2 py-0.5 text-xs text-gray-600" data-testid="converse-source" title={s.id}>{s.kind}: {s.title}</li>)}
53
+ </ul>
54
+ ) : null}
55
+ </div>
56
+ </li>
57
+ );
58
+ })}
44
59
  </ol>
45
60
  );
46
61
  }
@@ -0,0 +1,60 @@
1
+ /**
2
+ * The cards that need Quinn, from REAL sources only: pending decisions (questions) from the notify client, plus any
3
+ * cards the host passes in (the brief). Answering resolves the card in place. No source = no cards, never a placeholder.
4
+ */
5
+ import * as React from 'react';
6
+
7
+ import { decisionCard, resolveCard, type ThreadCard } from '../../../corpus/converse/cards';
8
+ import type { NotifyClient } from '../../../corpus/notify/client';
9
+ import type { DecisionRecord } from '../../../corpus/notify/types';
10
+
11
+ export interface NeedsYou {
12
+ cards: ThreadCard[];
13
+ busyId: string | null;
14
+ errors: Record<string, string>;
15
+ /** Answers the first open question of a decision card with `answer`. */
16
+ answer: (card: ThreadCard, answer: string) => Promise<void>;
17
+ /** The label of option `actionId` on a card, for actions the page does not handle itself. */
18
+ optionLabel: (card: ThreadCard, actionId: string) => string | null;
19
+ }
20
+
21
+ export function useNeedsYou(notify: NotifyClient | undefined, from?: (d: DecisionRecord) => string): NeedsYou {
22
+ const [cards, setCards] = React.useState<ThreadCard[]>([]);
23
+ const [busyId, setBusyId] = React.useState<string | null>(null);
24
+ const [errors, setErrors] = React.useState<Record<string, string>>({});
25
+ const records = React.useRef(new Map<string, DecisionRecord>());
26
+
27
+ React.useEffect(() => {
28
+ if (!notify) return;
29
+ let live = true;
30
+ (async () => {
31
+ try {
32
+ const rows = await notify.pending();
33
+ const full = await Promise.all(rows.filter((r) => r.status === 'pending').map((r) => notify.decision(r.id)));
34
+ if (!live) return;
35
+ full.forEach((d) => records.current.set(d.id, d));
36
+ setCards(full.map((d) => decisionCard(d, from?.(d))).sort((a, b) => a.at.localeCompare(b.at)));
37
+ } catch { /* the thread still works without the queue; a failed load shows no cards rather than fake ones */ }
38
+ })();
39
+ return () => { live = false; };
40
+ }, [notify]); // eslint-disable-line react-hooks/exhaustive-deps
41
+
42
+ const answer = React.useCallback(async (card: ThreadCard, text: string) => {
43
+ const id = card.id.replace(/^decision:/, '');
44
+ const rec = records.current.get(id);
45
+ const open = rec?.questions.find((q) => !rec.answers.some((a) => a.n === q.n));
46
+ if (!notify || !rec || !open) return;
47
+ setBusyId(card.id);
48
+ setErrors((e) => { const { [card.id]: _drop, ...rest } = e; return rest; });
49
+ try {
50
+ const out = await notify.answer(id, [{ n: open.n, answer: text }]);
51
+ records.current.set(id, out);
52
+ setCards((cs) => cs.map((c) => (c.id !== card.id ? c : out.status === 'answered' ? resolveCard(c, text) : decisionCard(out, c.from))));
53
+ } catch (e) {
54
+ setErrors((x) => ({ ...x, [card.id]: e instanceof Error ? e.message : 'Could not send.' }));
55
+ } finally { setBusyId(null); }
56
+ }, [notify]);
57
+
58
+ const optionLabel = React.useCallback((card: ThreadCard, actionId: string) => card.actions.find((a) => a.id === actionId)?.label ?? null, []);
59
+ return { cards, busyId, errors, answer, optionLabel };
60
+ }
@@ -10,9 +10,10 @@
10
10
  import * as React from 'react';
11
11
 
12
12
  import type { BriefingResult } from '../../../corpus/briefing';
13
+ import { MiniMarkdown } from './MiniMarkdown';
13
14
 
14
15
  /** What the card shows: the daily briefing's result or the weekly summary's. */
15
- export type BriefCardResult = Pick<BriefingResult, 'text' | 'audioUrl'> & { audioReason?: string; remaining?: number };
16
+ export type BriefCardResult = Pick<BriefingResult, 'text' | 'audioUrl'> & { audioReason?: string; remaining?: number; markdown?: string };
16
17
 
17
18
  export interface BriefCardApi {
18
19
  /** POST /corpus/briefing: cached per person per day on the server. */
@@ -30,6 +31,8 @@ type State =
30
31
  export interface BriefCardProps {
31
32
  api: BriefCardApi;
32
33
  onAsk?: () => void;
34
+ /** Draw the heading (default true). A page that already has its own title turns it off. */
35
+ showTitle?: boolean;
33
36
  /** Heading, default "Today’s brief". */
34
37
  title?: string;
35
38
  /** Wait for a tap instead of loading on mount (the weekly summary: it costs a voice the first time). */
@@ -38,7 +41,7 @@ export interface BriefCardProps {
38
41
  week?: BriefCardApi;
39
42
  }
40
43
 
41
- export function BriefCard({ api, onAsk, title = 'Today’s brief', onDemand = false, week }: BriefCardProps) {
44
+ export function BriefCard({ api, onAsk, title = 'Today’s brief', showTitle = true, onDemand = false, week }: BriefCardProps) {
42
45
  const apiRef = React.useRef(api);
43
46
  apiRef.current = api;
44
47
  const [state, setState] = React.useState<State>(onDemand ? { phase: 'idle' } : { phase: 'loading' });
@@ -74,7 +77,7 @@ export function BriefCard({ api, onAsk, title = 'Today’s brief', onDemand = fa
74
77
  return (
75
78
  <section aria-label={title} className="rounded-lg border border-gray-200 bg-white p-4 shadow-sm" data-testid="brief-card">
76
79
  <div className="flex items-center gap-2">
77
- <h2 className="text-sm font-semibold uppercase tracking-wide text-gray-500">{title}</h2>
80
+ {showTitle ? <h2 className="text-sm font-semibold uppercase tracking-wide text-gray-500">{title}</h2> : null}
78
81
  <div className="ml-auto flex items-center gap-2">
79
82
  {state.phase === 'ready' && apiRef.current.loadAudio ? (
80
83
  <button type="button" className="rounded-md bg-gray-900 px-3 py-1.5 text-sm font-medium text-white" onClick={() => void play(state.result)}>
@@ -95,8 +98,14 @@ export function BriefCard({ api, onAsk, title = 'Today’s brief', onDemand = fa
95
98
  ) : null}
96
99
  {state.phase === 'ready' ? (
97
100
  <>
98
- <p className="mt-3 whitespace-pre-line text-base leading-relaxed text-gray-900" data-testid="brief-text">{state.result.text}</p>
99
- {(state.result.remaining ?? 0) > 0 ? <p className="mt-2 text-xs text-gray-500">{state.result.remaining} more not read out.</p> : null}
101
+ {state.result.markdown ? (
102
+ <div className="mt-3" data-testid="brief-text"><MiniMarkdown text={state.result.markdown} /></div>
103
+ ) : (
104
+ <>
105
+ <p className="mt-3 whitespace-pre-line text-base leading-relaxed text-gray-900" data-testid="brief-text">{state.result.text}</p>
106
+ {(state.result.remaining ?? 0) > 0 ? <p className="mt-2 text-xs text-gray-500">{state.result.remaining} more not read out.</p> : null}
107
+ </>
108
+ )}
100
109
  </>
101
110
  ) : null}
102
111
  {audioError ? <p className="mt-2 text-xs text-amber-800" role="status">{audioError}</p> : null}
@@ -110,11 +119,11 @@ function WeekInline({ api }: { api: BriefCardApi }) {
110
119
  const [state, setState] = React.useState<{ phase: 'idle' } | { phase: 'loading' } | { phase: 'ready'; text: string } | { phase: 'error'; message: string }>({ phase: 'idle' });
111
120
  const load = async () => {
112
121
  setState({ phase: 'loading' });
113
- try { setState({ phase: 'ready', text: (await api.fetch()).text }); }
122
+ try { { const r = await api.fetch(); setState({ phase: 'ready', text: r.markdown || r.text }); }; }
114
123
  catch (err) { setState({ phase: 'error', message: (err as Error)?.message || 'The week could not be loaded.' }); }
115
124
  };
116
125
  if (state.phase === 'idle') return <p className="mt-3"><button type="button" className="text-sm text-blue-700 underline" onClick={() => void load()}>Show your week</button></p>;
117
126
  if (state.phase === 'loading') return <p className="mt-3 text-sm text-gray-500">Looking at your week…</p>;
118
127
  if (state.phase === 'error') return <p className="mt-3 text-sm text-red-600" role="alert">{state.message} <button type="button" className="underline" onClick={() => void load()}>Try again</button></p>;
119
- return <p className="mt-3 whitespace-pre-line border-t border-gray-100 pt-3 text-sm leading-relaxed text-gray-800">{state.text}</p>;
128
+ return <div className="mt-3 border-t border-gray-100 pt-3"><MiniMarkdown text={state.text} /></div>;
120
129
  }
@@ -1,106 +1,21 @@
1
1
  /**
2
- * TODAY — the morning brief (the text the app speaks), the questions waiting for
3
- * you, and ONE short line on what is due soon with the way into Plan (bd
4
- * startsim-cpzoz). The to-do list itself lives only in Plan: Today never draws
5
- * its own copy of it.
2
+ * TODAY — the morning brief and the way to the week, nothing else. The to-do list lives in Plan and the
3
+ * questions in Decisions: Today draws neither (no due counts, no "Open plan", no Needs your call).
6
4
  *
7
- * `<HomeBriefPage brief={...} corpus={...} />` is the whole integration; an app
8
- * adds a heading and navigation callbacks. Everything is read through the same
9
- * injected corpus clients as the other page composers: one server-paginated read
10
- * of open items (for the due-soon counts and the question titles) and the project
11
- * names.
5
+ * `<HomeBriefPage brief={...} />` is the whole integration; an app adds a heading. The brief is a short
6
+ * structured view of the same items the voice reads (see `BriefCard`).
12
7
  */
13
8
  import * as React from 'react';
14
9
 
15
- import { groupDue } from '../../../corpus/due-groups';
16
- import { isTask } from '../../../corpus/tracker-groups';
17
- import { failureMessage } from '../../../corpus/work-item-logic';
18
- import type { Commitment, CommitmentApi, CorpusApi, Focus, PlanningApi } from '../../../corpus/types';
19
- import { applyAnswerToItem, type OpenQuestion, type QuestionAnswer } from '../../../corpus/questions';
20
- import { NeedsYourCall } from '../questions/NeedsYourCall';
21
- import type { NeedsYourCallApi } from '../questions/types';
22
10
  import { BriefCard, type BriefCardApi } from './BriefCard';
23
- import { DueSoonLine } from './DueSoonLine';
24
-
25
11
 
26
12
  export interface HomeBriefPageProps {
27
13
  brief: BriefCardApi;
28
14
  /** The weekly summary, shown on demand under the daily brief. Absent = no weekly card. */
29
15
  weekly?: BriefCardApi;
30
- corpus: CorpusApi & CommitmentApi;
31
- /** Names the project chips. Absent = no chips. */
32
- listFocuses?: PlanningApi['listFocuses'];
33
- timeZone?: string;
34
- now?: number;
35
- trackerName?: string;
36
16
  onAsk?: () => void;
37
- /** The way into Plan (the to-do list). */
38
- onOpenPlan?: () => void;
39
- onOpenItem?: (item: Commitment) => void;
40
- /** Tandem's open questions ("Needs your call"). Absent = no such section. */
41
- questions?: NeedsYourCallApi;
42
17
  }
43
18
 
44
- interface Data { open: Commitment[]; names: Record<string, string> }
45
-
46
- export function HomeBriefPage({
47
- brief, weekly, corpus, listFocuses, timeZone, now, onAsk, onOpenPlan, onOpenItem, questions,
48
- }: HomeBriefPageProps) {
49
- // Frozen once: a clock that changes every render re-fires the load effect.
50
- const [mountedAt] = React.useState(() => Date.now());
51
- const clock = now ?? mountedAt;
52
- const corpusRef = React.useRef(corpus);
53
- corpusRef.current = corpus;
54
- const focusesRef = React.useRef(listFocuses);
55
- focusesRef.current = listFocuses;
56
- const [data, setData] = React.useState<Data | null>(null);
57
- const [error, setError] = React.useState('');
58
-
59
- React.useEffect(() => {
60
- let live = true;
61
- (async () => {
62
- const c = corpusRef.current;
63
- try {
64
- const [open, focuses] = await Promise.all([
65
- c.listCommitments({ status: ['open', 'in_progress', 'blocked'], withFocus: true, pageSize: 200 }),
66
- focusesRef.current ? focusesRef.current({ pageSize: 200 }).then((p) => p.results).catch((): Focus[] => []) : Promise.resolve([] as Focus[]),
67
- ]);
68
- if (!live) return;
69
- setData({
70
- open: open.results,
71
- names: Object.fromEntries(focuses.map((f) => [f.id, f.title])),
72
- });
73
- } catch (err) {
74
- if (live) setError(failureMessage(err));
75
- }
76
- })();
77
- return () => { live = false; };
78
- }, [clock, corpus]);
79
-
80
- // An answer shows on its to-do the moment it is tapped; a failed save drops it again.
81
- const [applied, setApplied] = React.useState<Record<string, { q: OpenQuestion; answer: QuestionAnswer }>>({});
82
- const due = React.useMemo(() => {
83
- if (!data) return null;
84
- const answers = Object.values(applied);
85
- const open = answers.length ? data.open.map((item) => answers.reduce((cur, { q, answer }) => applyAnswerToItem(cur, q, answer), item)) : data.open;
86
- return groupDue(open.filter(isTask), { now: clock, timeZone });
87
- }, [data, applied, clock, timeZone]);
88
- const titles = React.useMemo(() => new Map((data ? data.open : []).map((i) => [i.id, i.title])), [data]);
89
-
90
- return (
91
- <div className="space-y-8">
92
- {/* ONE structure: the brief (with the week as a link inside it), the due summary, then what needs your call. */}
93
- <BriefCard api={brief} onAsk={onAsk} week={weekly} />
94
- {error ? <p className="text-sm text-red-600" role="alert">{error}</p> : null}
95
- {due && data ? <DueSoonLine due={due} onOpenPlan={onOpenPlan} /> : null}
96
- {questions ? (
97
- <NeedsYourCall
98
- api={questions} itemTitle={(id) => titles.get(id)} projectNames={data?.names} timeZone={timeZone} now={now}
99
- onApplied={(q, answer) => setApplied((a) => ({ ...a, [q.id]: { q, answer } }))}
100
- onReverted={(q) => setApplied(({ [q.id]: _gone, ...rest }) => rest)}
101
- onOpenItem={onOpenItem ? (id) => { const item = data?.open.find((i) => i.id === id); if (item) onOpenItem(item); } : undefined}
102
- />
103
- ) : null}
104
- </div>
105
- );
19
+ export function HomeBriefPage({ brief, weekly, onAsk }: HomeBriefPageProps) {
20
+ return <BriefCard api={brief} showTitle={false} onAsk={onAsk} week={weekly} />;
106
21
  }
@@ -0,0 +1,51 @@
1
+ /**
2
+ * The small markdown the brief uses: `##` headings, `-` bullets, `**bold**`, `_italic_`, paragraphs.
3
+ * Built as React elements, never as HTML, so nothing in a to-do title can inject markup. No dependency.
4
+ */
5
+ import * as React from 'react';
6
+
7
+ function inline(text: string, keyBase: string): React.ReactNode[] {
8
+ const out: React.ReactNode[] = [];
9
+ const re = /\*\*([^*]+)\*\*|_([^_]+)_/g;
10
+ let last = 0;
11
+ let n = 0;
12
+ for (let m = re.exec(text); m; m = re.exec(text)) {
13
+ if (m.index > last) out.push(text.slice(last, m.index));
14
+ out.push(m[1] !== undefined
15
+ ? <strong key={`${keyBase}-${n++}`} className="font-semibold text-gray-900">{m[1]}</strong>
16
+ : <em key={`${keyBase}-${n++}`}>{m[2]}</em>);
17
+ last = m.index + m[0].length;
18
+ }
19
+ if (last < text.length) out.push(text.slice(last));
20
+ return out;
21
+ }
22
+
23
+ export function MiniMarkdown({ text }: { text: string }) {
24
+ const blocks: React.ReactNode[] = [];
25
+ let bullets: string[] = [];
26
+ let k = 0;
27
+ const flush = () => {
28
+ if (!bullets.length) return;
29
+ const id = `l${k++}`;
30
+ blocks.push(
31
+ <ul key={id} className="mt-1 space-y-1 text-base text-gray-800">
32
+ {bullets.map((b, i) => <li key={i} className="ml-5 list-disc">{inline(b, `${id}-${i}`)}</li>)}
33
+ </ul>,
34
+ );
35
+ bullets = [];
36
+ };
37
+ for (const raw of text.split('\n')) {
38
+ const line = raw.trimEnd();
39
+ const bullet = /^\s*[-*]\s+(.*)$/.exec(line);
40
+ const heading = /^#{1,6}\s+(.*)$/.exec(line);
41
+ if (bullet) { bullets.push(bullet[1]); continue; }
42
+ flush();
43
+ if (!line.trim()) continue;
44
+ const id = `b${k++}`;
45
+ blocks.push(heading
46
+ ? <h3 key={id} className="mt-4 text-sm font-semibold text-gray-700 first:mt-0">{inline(heading[1], id)}</h3>
47
+ : <p key={id} className="mt-2 text-sm leading-relaxed text-gray-700">{inline(line, id)}</p>);
48
+ }
49
+ flush();
50
+ return <>{blocks}</>;
51
+ }
@@ -1,6 +1,6 @@
1
1
  /**
2
- * The one line Today keeps about to-dos: how many are overdue, due today and due this
3
- * week, and the way into Plan. It names no to-do: the list is Plan's alone.
2
+ * The due-soon wording ("1 overdue · 3 due today"), kept for the native Home tab. The web Today page no
3
+ * longer draws it: the counts had no label and no link a person could follow.
4
4
  */
5
5
  import type { DueGroups } from '../../../corpus/due-groups';
6
6
 
@@ -17,12 +17,3 @@ export function dueSoonText(due: DueGroups): string {
17
17
  ].filter(Boolean);
18
18
  return parts.length ? parts.join(' · ') : 'Nothing is due soon.';
19
19
  }
20
-
21
- export function DueSoonLine({ due, onOpenPlan }: { due: DueGroups; onOpenPlan?: () => void }) {
22
- return (
23
- <p className="text-sm text-gray-700" data-testid="due-soon">
24
- {dueSoonText(due)}
25
- {onOpenPlan ? <>{' '}<button type="button" className="text-blue-700 underline" onClick={onOpenPlan}>Open Plan</button></> : null}
26
- </p>
27
- );
28
- }
@@ -2,7 +2,7 @@ export { BriefCard } from './BriefCard';
2
2
  export type { BriefCardApi } from './BriefCard';
3
3
  export { CompactItemRow, dueLabel } from './CompactItemRow';
4
4
  export type { CompactItemRowProps } from './CompactItemRow';
5
- export { DueSoonLine, dueSoonText } from './DueSoonLine';
5
+ export { dueSoonText } from './dueSoonText';
6
6
  export { HomeBriefPage } from './HomeBriefPage';
7
7
  export type { HomeBriefPageProps } from './HomeBriefPage';
8
8
  export { useProjectNames } from './useProjectNames';