@startsimpli/integrations 0.2.65 → 0.2.67

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@startsimpli/integrations",
3
- "version": "0.2.65",
3
+ "version": "0.2.67",
4
4
  "description": "Provider-agnostic types, API clients, hooks, and UI primitives for email + calendar integrations across StartSimpli apps, plus foundry customer email (subpath ./comms).",
5
5
  "license": "MIT",
6
6
  "homepage": "https://startsimpli.com",
@@ -90,9 +90,9 @@
90
90
  "vitest": "^3.0.0",
91
91
  "react-native": "0.85.3",
92
92
  "react-native-safe-area-context": "~5.7.0",
93
+ "@startsimpli/llm": "0.4.28",
93
94
  "@startsimpli/ui": "0.4.167",
94
- "@startsimpli/ui-native": "0.1.0",
95
- "@startsimpli/llm": "0.4.28"
95
+ "@startsimpli/ui-native": "0.1.0"
96
96
  },
97
97
  "scripts": {
98
98
  "type-check": "tsc --noEmit && tsc --noEmit -p tsconfig.native.json",
@@ -4,7 +4,7 @@ import { Alert, Badge, Button, Chip, Separator, Text, useTheme } from '@startsim
4
4
  import type { VoiceFocus, VoiceNote } from '../../corpus/voice';
5
5
  import type { VoiceNotesController } from '../voice/controller';
6
6
  import { formatDuration, formatNoteDate, statusLabel, statusVariant } from '../voice/format';
7
- import { noteSections } from '../voice/sections';
7
+ import { noteSections, noteLead } from '../voice/sections';
8
8
  import { useVoiceNotes } from './useVoiceNotes';
9
9
 
10
10
  export interface NoteDetailScreenProps {
@@ -68,6 +68,7 @@ export function NoteDetailScreen({ controller, noteId, onBack }: NoteDetailScree
68
68
  ) : null}
69
69
  {note.status === 'processing' ? <Text variant="muted">Transcribing... this updates by itself.</Text> : null}
70
70
 
71
+ {noteLead(note) ? <Text>{noteLead(note)}</Text> : null}
71
72
  {sections.map((s, i) => (
72
73
  <View key={`${s.label}-${i}`} style={gap} testID={`section-${i}`}>
73
74
  {sections.length > 1 || s.label ? (
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, it } from 'vitest';
2
2
  import type { VoiceNote } from '../../../corpus/voice';
3
- import { noteSections } from '../sections';
3
+ import { noteSections, noteLead } from '../sections';
4
4
 
5
5
  const base: VoiceNote = {
6
6
  id: '1', title: 'T', summary: 'One summary', transcript: 'hi', status: 'ready',
@@ -46,4 +46,22 @@ describe('noteSections', () => {
46
46
  it('keeps plain summaries untouched', () => {
47
47
  expect(noteSections({ ...base, summary: 'Just text. No bullets.' })[0]).toMatchObject({ summary: 'Just text. No bullets.', items: [] });
48
48
  });
49
+
50
+ it('joins the stored section filings with the per-heading blocks of the summary', () => {
51
+ const summary = 'Tasks across projects.\n\n## 287A\n\n- **Finish the exhibit list**\n- **Call Megan**\n\n## Personal\n\n- **Book the dentist**\n';
52
+ const note = {
53
+ ...base, summary,
54
+ sections: [{ label: '287A', kind: 'project', focusId: 'f287' }, { label: 'Personal', kind: 'personal', focusId: null }],
55
+ };
56
+ const out = noteSections(note);
57
+ expect(out.map((s) => [s.label, s.kind, s.focusId, s.items])).toEqual([
58
+ ['287A', 'project', 'f287', ['Finish the exhibit list', 'Call Megan']],
59
+ ['Personal', 'personal', null, ['Book the dentist']],
60
+ ]);
61
+ expect(noteLead(note)).toBe('Tasks across projects.');
62
+ });
63
+
64
+ it('noteLead is empty for the single-section fallback (its lead is the section summary)', () => {
65
+ expect(noteLead({ ...base, summary: 'Lead.\n\n## Next Steps\n- **Do it**' })).toBe('');
66
+ });
49
67
  });
@@ -45,25 +45,54 @@ function fromRaw(raw: unknown): NoteSection | null {
45
45
  };
46
46
  }
47
47
 
48
- /** Older notes store one markdown summary: a lead sentence, then `## Next Steps` with `- **Title** (Owner)` bullets. */
49
- function splitLegacySummary(summary: string): { lead: string; items: string[] } {
50
- const text = summary ?? '';
51
- const bullets = [...text.matchAll(/^\s*[-*]\s+\*\*(.+?)\*\*\s*(\([^)]*\))?\s*$/gm)];
52
- if (!bullets.length) return { lead: text, items: [] };
53
- const lead = text.split(/^\s*#{1,6}\s/m)[0].trim();
54
- return { lead, items: bullets.map((m) => (m[1] + (m[2] ? ' ' + m[2] : '')).trim()) };
48
+ const BULLET = /^\s*[-*]\s+\*\*(.+?)\*\*\s*(\([^)]*\))?\s*$/;
49
+ const norm = (v: string) => v.trim().toLowerCase();
50
+
51
+ interface SummaryBlock { heading: string; text: string; items: string[] }
52
+
53
+ /**
54
+ * Notes store ONE markdown summary: a lead sentence, then `## <Label>` blocks (or a single `## Next Steps`)
55
+ * with `- **Title** (Owner)` bullets. Per-section filing lives apart, in `voice_sections` (label, kind, project).
56
+ */
57
+ function parseSummary(summary: string): { lead: string; blocks: SummaryBlock[] } {
58
+ const lead: string[] = [];
59
+ const blocks: SummaryBlock[] = [];
60
+ let cur: SummaryBlock | null = null;
61
+ for (const line of (summary ?? '').split('\n')) {
62
+ const h = line.match(/^\s*#{1,6}\s+(.+?)\s*$/);
63
+ if (h) { cur = { heading: h[1], text: '', items: [] }; blocks.push(cur); continue; }
64
+ const b = line.match(BULLET);
65
+ if (b) { (cur ?? (cur = { heading: '', text: '', items: [] }, blocks.push(cur), cur)).items.push((b[1] + (b[2] ? ' ' + b[2] : '')).trim()); continue; }
66
+ if (cur) cur.text = [cur.text, line.trim()].filter(Boolean).join(' ');
67
+ else lead.push(line);
68
+ }
69
+ return { lead: lead.join('\n').trim(), blocks };
70
+ }
71
+
72
+ /** The overall sentence above the sections ('' when the note has none or it is already the single section's summary). */
73
+ export function noteLead(note: VoiceNote): string {
74
+ const sections = noteSections(note);
75
+ if (sections.length === 1 && !sections[0].label) return '';
76
+ return parseSummary(note.summary).lead;
55
77
  }
56
78
 
57
79
  export function noteSections(note: VoiceNote): NoteSection[] {
58
80
  const raw = (note as VoiceNote & { sections?: unknown }).sections;
81
+ const parsed = parseSummary(note.summary);
59
82
  const sections = Array.isArray(raw) ? raw.map(fromRaw).filter((s): s is NoteSection => s !== null && Boolean(s.label || s.summary || s.items.length)) : [];
60
- if (sections.length) return sections;
61
- const { lead, items } = splitLegacySummary(note.summary);
83
+ if (sections.length) {
84
+ return sections.map((s) => {
85
+ if (s.summary || s.items.length) return s;
86
+ const block = parsed.blocks.find((b) => norm(b.heading) === norm(s.label));
87
+ return block ? { ...s, summary: block.text, items: block.items } : s;
88
+ });
89
+ }
90
+ const items = parsed.blocks.flatMap((b) => b.items);
62
91
  return [{
63
92
  label: '',
64
93
  kind: note.focusId ? 'project' : 'other',
65
94
  focusId: note.focusId,
66
- summary: lead,
95
+ summary: items.length ? parsed.lead : (note.summary ?? ''),
67
96
  items,
68
97
  }];
69
98
  }