@startsimpli/integrations 0.2.145 → 0.2.147
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 +3 -3
- package/src/__tests__/briefing-actions.test.ts +2 -0
- package/src/__tests__/briefing-reply.test.ts +334 -0
- package/src/__tests__/corpus-tracker.test.tsx +79 -0
- package/src/__tests__/extract-classify.test.ts +9 -4
- package/src/__tests__/owner-backfill.test.ts +114 -0
- package/src/__tests__/owner-link.test.ts +115 -0
- package/src/__tests__/owner-picker.test.tsx +70 -0
- package/src/__tests__/private-items.test.ts +63 -0
- package/src/__tests__/roster.test.ts +27 -0
- package/src/__tests__/task-detail-private.test.tsx +44 -0
- package/src/__tests__/tracker-sort.test.ts +28 -0
- package/src/components/index.ts +1 -0
- package/src/components/pages/TaskDetailPage.tsx +51 -2
- package/src/components/pages/TrackerPage.tsx +28 -6
- package/src/components/pages/task-tracker/OwnerPicker.tsx +82 -0
- package/src/components/pages/tracker/TrackerBoard.tsx +45 -0
- package/src/components/pages/tracker/TrackerToolbar.tsx +44 -0
- package/src/corpus/briefing/actions/execute.ts +5 -4
- package/src/corpus/briefing/actions/log.ts +1 -1
- package/src/corpus/briefing/actions/types.ts +21 -0
- package/src/corpus/briefing/index.ts +1 -0
- package/src/corpus/briefing/intent/model.ts +3 -0
- package/src/corpus/briefing/intent/resolve.ts +14 -6
- package/src/corpus/briefing/intent/types.ts +7 -0
- package/src/corpus/briefing/reply/handle.ts +174 -0
- package/src/corpus/briefing/reply/index.ts +6 -0
- package/src/corpus/briefing/reply/respond.ts +95 -0
- package/src/corpus/briefing/reply/types.ts +112 -0
- package/src/corpus/briefing/store.ts +14 -0
- package/src/corpus/client.ts +24 -18
- package/src/corpus/entities.ts +7 -0
- package/src/corpus/extract.ts +21 -0
- package/src/corpus/index.ts +4 -0
- package/src/corpus/owner-backfill.ts +200 -0
- package/src/corpus/owner-link.ts +160 -0
- package/src/corpus/roster.ts +53 -0
- package/src/corpus/tracker-groups.ts +8 -4
- package/src/corpus/tracker-sort.ts +51 -0
- package/src/corpus/types.ts +24 -1
- package/src/native/app/FoundryApp.tsx +25 -7
- package/src/native/app/__tests__/briefingLink.test.tsx +57 -0
- package/src/native/app/__tests__/briefingServices.test.ts +92 -0
- package/src/native/app/__tests__/launch.test.ts +2 -1
- package/src/native/app/briefingServices.ts +101 -0
- package/src/native/app/config/__tests__/briefingConfig.test.ts +49 -0
- package/src/native/app/config/links.ts +4 -1
- package/src/native/app/config/types.ts +13 -1
- package/src/native/app/config/validate.ts +20 -2
- package/src/native/app/data.ts +3 -3
- package/src/native/app/device.ts +3 -0
- package/src/native/app/launch.ts +4 -0
- package/src/native/app/registry.tsx +3 -1
- package/src/native/app/screens/RecordScreen.tsx +3 -2
- package/src/native/app/services.ts +11 -30
- package/src/native/app/strings.ts +28 -0
- package/src/native/briefing/BriefingCard.tsx +14 -2
- package/src/native/briefing/BriefingReply.tsx +68 -0
- package/src/native/briefing/__tests__/BriefingReply.test.tsx +144 -0
- package/src/native/briefing/__tests__/fakeReply.test.ts +46 -0
- package/src/native/briefing/__tests__/notify.test.ts +42 -1
- package/src/native/briefing/__tests__/replyApi.test.ts +43 -0
- package/src/native/briefing/__tests__/replyController.test.ts +230 -0
- package/src/native/briefing/__tests__/replyPosition.test.ts +116 -0
- package/src/native/briefing/audioPlayer.ts +9 -2
- package/src/native/briefing/controller.ts +50 -5
- package/src/native/briefing/fake.ts +25 -18
- package/src/native/briefing/fakeReply.ts +65 -0
- package/src/native/briefing/index.ts +8 -3
- package/src/native/briefing/notify.ts +42 -0
- package/src/native/briefing/reply.ts +261 -0
- package/src/native/briefing/replyApi.ts +82 -0
- package/src/native/recording/__tests__/deeplink.test.ts +20 -0
- package/src/native/recording/deeplink.ts +7 -0
- package/src/native/tracker/__tests__/itemsChanged.test.ts +13 -0
- package/src/native/tracker/tab.tsx +4 -1
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OWNER TEXT -> PEOPLE (bd startsim-768w.38.29).
|
|
3
|
+
*
|
|
4
|
+
* A commitment's `owner_name` is whatever the meeting said. This module decides,
|
|
5
|
+
* conservatively, which workspace member (if any) that text means. The rule is
|
|
6
|
+
* Quinn's: link only when the text UNAMBIGUOUSLY matches exactly one member by
|
|
7
|
+
* first name or full-name variant. Several possible people, or none, are never
|
|
8
|
+
* merged: the row keeps its text and the UI offers a manual pick.
|
|
9
|
+
*
|
|
10
|
+
* Deliberately NOT matched: a surname alone, an email local part, a member with
|
|
11
|
+
* no display name, and service/QA accounts. Guessing merges two humans, which is
|
|
12
|
+
* worse than leaving one fragmented.
|
|
13
|
+
*
|
|
14
|
+
* Pure and generic: no I/O, no tenant knowledge, so the backfill, the write path
|
|
15
|
+
* and the picker all share one decision.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
export interface RosterMember {
|
|
19
|
+
sub: string;
|
|
20
|
+
email: string;
|
|
21
|
+
name?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Names someone DECLARED for this member (e.g. from an alias file), for rosters
|
|
24
|
+
* that carry only sub + email. Declared, never derived from the email.
|
|
25
|
+
*/
|
|
26
|
+
aliases?: string[];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type OwnerPart =
|
|
30
|
+
| { text: string; status: 'linked'; sub: string; via: 'first-name' | 'full-name' }
|
|
31
|
+
| { text: string; status: 'ambiguous'; candidates: string[] }
|
|
32
|
+
| { text: string; status: 'unmatched' };
|
|
33
|
+
|
|
34
|
+
export type OwnerOutcome = 'none' | 'linked' | 'partial' | 'ambiguous' | 'unmatched';
|
|
35
|
+
|
|
36
|
+
export interface OwnerPlan {
|
|
37
|
+
parts: OwnerPart[];
|
|
38
|
+
/** Subs of the parts that linked, in the order written, de-duplicated. */
|
|
39
|
+
subs: string[];
|
|
40
|
+
outcome: OwnerOutcome;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const SERVICE_LOCAL = /^(qa|idf|verify|test|bot|system|noreply|no-reply|admin)([+\-_.]|$)/i;
|
|
44
|
+
const SERVICE_DOMAIN = /@(local\.test|foundry\.local)$/i;
|
|
45
|
+
|
|
46
|
+
/** Accounts that are not people: never a candidate for a name in a meeting. */
|
|
47
|
+
export function isServiceAccount(member: RosterMember): boolean {
|
|
48
|
+
const email = member.email ?? '';
|
|
49
|
+
return SERVICE_LOCAL.test(email) || SERVICE_DOMAIN.test(email) || SERVICE_LOCAL.test(member.name ?? '');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function normalize(text: string): string[] {
|
|
53
|
+
return text
|
|
54
|
+
.normalize('NFKD')
|
|
55
|
+
.replace(/[̀-ͯ]/g, '')
|
|
56
|
+
.toLowerCase()
|
|
57
|
+
.replace(/\([^)]*\)/g, ' ')
|
|
58
|
+
.replace(/[^a-z0-9\s]/g, ' ')
|
|
59
|
+
.split(/\s+/)
|
|
60
|
+
.filter(Boolean);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** "Jude, Jenny" / "A & B" / "A and B" / "A; B" / "A / B" -> separate names. */
|
|
64
|
+
export function splitOwnerNames(text: string): string[] {
|
|
65
|
+
const seen = new Set<string>();
|
|
66
|
+
const out: string[] = [];
|
|
67
|
+
for (const raw of (text ?? '').split(/\s*(?:,|;|&|\/|\+|\band\b)\s*/i)) {
|
|
68
|
+
const name = raw.trim();
|
|
69
|
+
const key = normalize(name).join(' ');
|
|
70
|
+
if (!key || seen.has(key)) continue;
|
|
71
|
+
seen.add(key);
|
|
72
|
+
out.push(name);
|
|
73
|
+
}
|
|
74
|
+
return out;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
interface Candidate { sub: string; tokens: string[] }
|
|
78
|
+
|
|
79
|
+
function candidates(roster: RosterMember[]): Candidate[] {
|
|
80
|
+
const bySub = new Map<string, Candidate>();
|
|
81
|
+
const out: Candidate[] = [];
|
|
82
|
+
for (const member of roster) {
|
|
83
|
+
if (!member.sub || isServiceAccount(member)) continue;
|
|
84
|
+
for (const raw of [member.name, ...(member.aliases ?? [])]) {
|
|
85
|
+
const tokens = raw ? normalize(raw) : [];
|
|
86
|
+
const key = `${member.sub}\u0000${tokens.join(' ')}`;
|
|
87
|
+
if (!tokens.length || bySub.has(key)) continue;
|
|
88
|
+
bySub.set(key, { sub: member.sub, tokens });
|
|
89
|
+
out.push({ sub: member.sub, tokens });
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return out;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function verdict(text: string, found: Candidate[], via: 'first-name' | 'full-name'): OwnerPart | null {
|
|
96
|
+
const subs = [...new Set(found.map((hit) => hit.sub))];
|
|
97
|
+
if (subs.length === 1) return { text, status: 'linked', sub: subs[0], via };
|
|
98
|
+
if (subs.length > 1) return { text, status: 'ambiguous', candidates: subs };
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function matchOwnerName(text: string, roster: RosterMember[]): OwnerPart {
|
|
103
|
+
const query = normalize(text);
|
|
104
|
+
const pool = candidates(roster);
|
|
105
|
+
if (!query.length) return { text, status: 'unmatched' };
|
|
106
|
+
if (query.length === 1) {
|
|
107
|
+
const hit = verdict(text, pool.filter((c) => c.tokens[0] === query[0]), 'first-name');
|
|
108
|
+
return hit ?? { text, status: 'unmatched' };
|
|
109
|
+
}
|
|
110
|
+
const joined = query.join(' ');
|
|
111
|
+
const exact = verdict(text, pool.filter((c) => c.tokens.join(' ') === joined), 'full-name');
|
|
112
|
+
if (exact) return exact;
|
|
113
|
+
const last = query[query.length - 1];
|
|
114
|
+
const variant = verdict(
|
|
115
|
+
text,
|
|
116
|
+
pool.filter((c) => c.tokens.length > 1 && c.tokens[0] === query[0] && c.tokens[c.tokens.length - 1] === last),
|
|
117
|
+
'full-name',
|
|
118
|
+
);
|
|
119
|
+
return variant ?? { text, status: 'unmatched' };
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export function planOwnerLinks(ownerText: string, roster: RosterMember[]): OwnerPlan {
|
|
123
|
+
const parts = splitOwnerNames(ownerText).map((name) => matchOwnerName(name, roster));
|
|
124
|
+
const subs: string[] = [];
|
|
125
|
+
for (const part of parts) if (part.status === 'linked' && !subs.includes(part.sub)) subs.push(part.sub);
|
|
126
|
+
let outcome: OwnerOutcome;
|
|
127
|
+
if (!parts.length) outcome = 'none';
|
|
128
|
+
else if (parts.every((p) => p.status === 'linked')) outcome = 'linked';
|
|
129
|
+
else if (subs.length) outcome = 'partial';
|
|
130
|
+
else outcome = parts.some((p) => p.status === 'ambiguous') ? 'ambiguous' : 'unmatched';
|
|
131
|
+
return { parts, subs, outcome };
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// ---- joint-owner storage --------------------------------------------------
|
|
135
|
+
//
|
|
136
|
+
// `owner_subs` is a DELIMITED TEXT attribute (`|a|b|`), not a JSON list. The
|
|
137
|
+
// tenant filters only declared attributes, and `attr.owner_subs__icontains=|a|`
|
|
138
|
+
// works identically on Postgres and the SQLite local stack, where a JSON
|
|
139
|
+
// `__contains` does not. `owner_sub` stays as the first owner so every existing
|
|
140
|
+
// reader (isTask, the single-owner picker) keeps working.
|
|
141
|
+
|
|
142
|
+
export const OWNER_SUBS_ATTRIBUTES: Array<[string, string]> = [
|
|
143
|
+
['owner_sub', 'text'], ['owner_subs', 'text'], ['owner_link', 'text'],
|
|
144
|
+
];
|
|
145
|
+
|
|
146
|
+
export function encodeOwnerSubs(subs: string[]): string {
|
|
147
|
+
const clean = [...new Set(subs.filter(Boolean))];
|
|
148
|
+
return clean.length ? `|${clean.join('|')}|` : '';
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export function decodeOwnerSubs(value: unknown): string[] {
|
|
152
|
+
if (Array.isArray(value)) return value.map(String).filter(Boolean);
|
|
153
|
+
if (typeof value !== 'string') return [];
|
|
154
|
+
return value.split('|').filter(Boolean);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** The server filter that finds a person's work, joint or sole. */
|
|
158
|
+
export function ownerSubsFilter(sub: string): Record<string, string> {
|
|
159
|
+
return { 'attr.owner_subs__icontains': `|${sub}|` };
|
|
160
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE WORKSPACE ROSTER WITH NAMES (bd startsim-768w.38.29).
|
|
3
|
+
*
|
|
4
|
+
* `/api/v1/org/members/` carries only `sub` + `email` and is admin-only, so on
|
|
5
|
+
* its own it can never tell "Quinn" from anyone. `/api/v1/org/roster/` is the
|
|
6
|
+
* narrower read any member may make: `{sub, label}`, the label being the
|
|
7
|
+
* person's name. Each is read soft (a failure yields nothing for that source)
|
|
8
|
+
* and joined by `sub`: the roster supplies the name, the members list the email.
|
|
9
|
+
*/
|
|
10
|
+
import type { RosterMember } from './owner-link';
|
|
11
|
+
|
|
12
|
+
interface Http {
|
|
13
|
+
get<T>(path: string, options?: { params?: Record<string, unknown> }): Promise<T>;
|
|
14
|
+
}
|
|
15
|
+
interface Page { results?: Array<Record<string, unknown>>; next_cursor?: string | null }
|
|
16
|
+
|
|
17
|
+
const text = (v: unknown) => (typeof v === 'string' ? v : v == null ? '' : String(v));
|
|
18
|
+
|
|
19
|
+
export async function readRoster(
|
|
20
|
+
http: Http,
|
|
21
|
+
paths: { members: string; roster: string },
|
|
22
|
+
maxPages = 20,
|
|
23
|
+
): Promise<RosterMember[]> {
|
|
24
|
+
const names = new Map<string, string>();
|
|
25
|
+
try {
|
|
26
|
+
let cursor = '';
|
|
27
|
+
for (let page = 0; page < maxPages; page += 1) {
|
|
28
|
+
const res = await http.get<Page>(paths.roster, cursor ? { params: { cursor } } : {});
|
|
29
|
+
for (const row of res.results ?? []) {
|
|
30
|
+
const sub = text(row.sub);
|
|
31
|
+
if (sub) names.set(sub, text(row.label ?? row.name));
|
|
32
|
+
}
|
|
33
|
+
cursor = text(res.next_cursor);
|
|
34
|
+
if (!cursor) break;
|
|
35
|
+
}
|
|
36
|
+
} catch { /* names unavailable: members still list, they just cannot be matched by name */ }
|
|
37
|
+
|
|
38
|
+
const out = new Map<string, RosterMember>();
|
|
39
|
+
try {
|
|
40
|
+
const res = await http.get<Page>(paths.members, {});
|
|
41
|
+
for (const row of res.results ?? []) {
|
|
42
|
+
const user = (row.user ?? {}) as Record<string, unknown>;
|
|
43
|
+
const sub = text(user.sub ?? row.sub);
|
|
44
|
+
if (!sub) continue;
|
|
45
|
+
const name = text(user.name) || names.get(sub) || '';
|
|
46
|
+
out.set(sub, { sub, email: text(user.email ?? row.email), ...(name ? { name } : {}) });
|
|
47
|
+
}
|
|
48
|
+
} catch { /* members is admin-only: fall back to the roster alone */ }
|
|
49
|
+
for (const [sub, name] of names) {
|
|
50
|
+
if (!out.has(sub)) out.set(sub, { sub, email: '', ...(name ? { name } : {}) });
|
|
51
|
+
}
|
|
52
|
+
return [...out.values()];
|
|
53
|
+
}
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { daysBetween, WEEK_DAYS } from './due-groups';
|
|
17
17
|
import { dueDay, localDate } from './today';
|
|
18
|
-
import
|
|
18
|
+
import { compareCommitments } from './tracker-sort';
|
|
19
|
+
import type { Commitment, CommitmentSort } from './types';
|
|
19
20
|
|
|
20
21
|
/** Subtypes that are things to do. The rest are what was said in the meeting. */
|
|
21
22
|
const TASK_SUBTYPES = new Set(['action', 'requirement']);
|
|
@@ -49,7 +50,7 @@ type Row = Pick<Commitment, 'status' | 'dueAt' | 'subtype' | 'ownerName' | 'owne
|
|
|
49
50
|
|
|
50
51
|
export function groupTracker<T extends Row>(
|
|
51
52
|
items: T[],
|
|
52
|
-
options: { now: number; timeZone?: string; staleDays?: number },
|
|
53
|
+
options: { now: number; timeZone?: string; staleDays?: number; sort?: CommitmentSort },
|
|
53
54
|
): TrackerGroups<T> {
|
|
54
55
|
const timeZone = options.timeZone ?? 'UTC';
|
|
55
56
|
const today = localDate(options.now, timeZone);
|
|
@@ -73,8 +74,11 @@ export function groupTracker<T extends Row>(
|
|
|
73
74
|
(idle >= staleDays ? out.stale : out.later).push(entry);
|
|
74
75
|
}
|
|
75
76
|
|
|
76
|
-
const
|
|
77
|
-
|
|
77
|
+
const byKey = compareCommitments(options.sort);
|
|
78
|
+
const dated = options.sort && options.sort !== 'due'
|
|
79
|
+
? (a: TrackerEntry<T>, b: TrackerEntry<T>) => byKey(a.item as unknown as Commitment, b.item as unknown as Commitment)
|
|
80
|
+
: (a: TrackerEntry<T>, b: TrackerEntry<T>) =>
|
|
81
|
+
(a.due ?? '9999').localeCompare(b.due ?? '9999') || (a.item.priority ?? 99) - (b.item.priority ?? 99);
|
|
78
82
|
const recent = (a: TrackerEntry<T>, b: TrackerEntry<T>) =>
|
|
79
83
|
(b.item.resolvedAt ?? b.item.lastSeenAt ?? '').localeCompare(a.item.resolvedAt ?? a.item.lastSeenAt ?? '');
|
|
80
84
|
for (const key of ['today', 'inProgress', 'upNext', 'later', 'stale', 'statements'] as const) out[key].sort(dated);
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HOW THE TRACKER ORDERS WHAT IS OWED.
|
|
3
|
+
*
|
|
4
|
+
* One table drives both halves, so they cannot disagree: `order` is the server
|
|
5
|
+
* parameter (so page one of a long list is the right page one, not whatever the
|
|
6
|
+
* first 200 rows happened to be), and `compare` orders the rows already loaded
|
|
7
|
+
* (within each group, or each board column). Every key is a declared attribute
|
|
8
|
+
* of the commitment type, which is what makes it sortable server-side at all.
|
|
9
|
+
*/
|
|
10
|
+
import type { Commitment, CommitmentSort } from './types';
|
|
11
|
+
|
|
12
|
+
type Sortable = Pick<Commitment, 'title' | 'ownerName' | 'dueAt' | 'lastSeenAt' | 'firstSeenAt'> & { priority?: number };
|
|
13
|
+
|
|
14
|
+
export const DEFAULT_TRACKER_SORT: CommitmentSort = 'due';
|
|
15
|
+
|
|
16
|
+
export const TRACKER_SORTS: ReadonlyArray<{ key: CommitmentSort; label: string; order: string }> = [
|
|
17
|
+
{ key: 'due', label: 'Due date', order: 'attr.due_at' },
|
|
18
|
+
{ key: 'updated', label: 'Recently updated', order: '-attr.last_seen_at' },
|
|
19
|
+
{ key: 'newest', label: 'Newest first', order: '-attr.first_seen_at' },
|
|
20
|
+
{ key: 'title', label: 'Title (A to Z)', order: 'attr.title' },
|
|
21
|
+
{ key: 'owner', label: 'Owner (A to Z)', order: 'attr.owner_name' },
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
/** The server `order=` value for a sort key. */
|
|
25
|
+
export function commitmentOrder(sort: CommitmentSort = DEFAULT_TRACKER_SORT): string {
|
|
26
|
+
return (TRACKER_SORTS.find((s) => s.key === sort) ?? TRACKER_SORTS[0]).order;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const text = (v: string | undefined | null) => (v ?? '').trim().toLowerCase();
|
|
30
|
+
/** Empty strings last: a missing owner or date is never "first". */
|
|
31
|
+
const blankLast = (a: string, b: string) => (a === '' ? (b === '' ? 0 : 1) : b === '' ? -1 : a.localeCompare(b));
|
|
32
|
+
const dueKey = (x: Sortable) => (x.dueAt ?? '').slice(0, 10);
|
|
33
|
+
|
|
34
|
+
/** Orders two rows the way `commitmentOrder(sort)` orders them on the server. */
|
|
35
|
+
export function compareCommitments(sort: CommitmentSort = DEFAULT_TRACKER_SORT) {
|
|
36
|
+
return (a: Sortable, b: Sortable): number => {
|
|
37
|
+
const byDue = blankLast(dueKey(a), dueKey(b)) || (a.priority ?? 99) - (b.priority ?? 99);
|
|
38
|
+
switch (sort) {
|
|
39
|
+
case 'updated':
|
|
40
|
+
return (b.lastSeenAt ?? '').localeCompare(a.lastSeenAt ?? '') || byDue;
|
|
41
|
+
case 'newest':
|
|
42
|
+
return (b.firstSeenAt ?? '').localeCompare(a.firstSeenAt ?? '') || byDue;
|
|
43
|
+
case 'title':
|
|
44
|
+
return text(a.title).localeCompare(text(b.title)) || byDue;
|
|
45
|
+
case 'owner':
|
|
46
|
+
return blankLast(text(a.ownerName), text(b.ownerName)) || byDue;
|
|
47
|
+
default:
|
|
48
|
+
return byDue;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
package/src/corpus/types.ts
CHANGED
|
@@ -715,6 +715,15 @@ export interface Commitment {
|
|
|
715
715
|
* Mutually exclusive with `focusId`.
|
|
716
716
|
*/
|
|
717
717
|
destination?: 'personal';
|
|
718
|
+
/**
|
|
719
|
+
* `private` makes the item readable by its owner ALONE, enforced by the tenant
|
|
720
|
+
* on every read path (bd startsim-768w.38.48): the tenant's `visibility` row
|
|
721
|
+
* scope reads `data.visibility`. Absent means shared with the workspace.
|
|
722
|
+
* Set on extraction for a voice note's Personal section and by the owner's
|
|
723
|
+
* manual mark; never inferred client-side, because hiding in the UI is not
|
|
724
|
+
* privacy.
|
|
725
|
+
*/
|
|
726
|
+
visibility?: 'private';
|
|
718
727
|
/**
|
|
719
728
|
* The focus the push should file the tracker issue under (a copy of `focusId`
|
|
720
729
|
* at classification time, written to the row so the central push can read it).
|
|
@@ -734,6 +743,13 @@ export interface Commitment {
|
|
|
734
743
|
* makes "assigned to me" a server filter instead of a scan over free text.
|
|
735
744
|
*/
|
|
736
745
|
ownerSub?: string;
|
|
746
|
+
/**
|
|
747
|
+
* ALL owners as members, for a joint commitment. `ownerSub` is always the
|
|
748
|
+
* first of these, so single-owner readers keep working. Empty or absent means
|
|
749
|
+
* the owner is still only text. Stored as `owner_subs` (`|a|b|`, see
|
|
750
|
+
* `./owner-link`).
|
|
751
|
+
*/
|
|
752
|
+
ownerSubs?: string[];
|
|
737
753
|
/**
|
|
738
754
|
* Where the row came from: `tenant-extraction`, `human`, `central-pipeline`.
|
|
739
755
|
*
|
|
@@ -833,7 +849,12 @@ export interface ResolutionClaim {
|
|
|
833
849
|
}
|
|
834
850
|
|
|
835
851
|
/** Server-side filters for the tracking surface (CLAUDE.md rule 8). */
|
|
852
|
+
/** How the tracker orders a page of to-dos; see `tracker-sort.ts`. */
|
|
853
|
+
export type CommitmentSort = 'due' | 'updated' | 'newest' | 'title' | 'owner';
|
|
854
|
+
|
|
836
855
|
export interface CommitmentQuery {
|
|
856
|
+
/** Server-side order. Default `due`. */
|
|
857
|
+
sort?: CommitmentSort;
|
|
837
858
|
status?: CommitmentStatus | CommitmentStatus[];
|
|
838
859
|
subtype?: CommitmentSubtype;
|
|
839
860
|
owner?: string;
|
|
@@ -892,8 +913,10 @@ export interface CommitmentApi {
|
|
|
892
913
|
* read-modify-write, which is the race the upsert exists to remove.
|
|
893
914
|
*/
|
|
894
915
|
updateCommitment?(item: Commitment, patch: Partial<Pick<Commitment,
|
|
895
|
-
'status' | 'statusReason' | 'ownerName' | 'ownerSub' | 'dueAt' | 'subtype'
|
|
916
|
+
'status' | 'statusReason' | 'ownerName' | 'ownerSub' | 'ownerSubs' | 'dueAt' | 'subtype'
|
|
896
917
|
| 'title' | 'detail' | 'resolvedAt'>> & {
|
|
918
|
+
/** `private` hides the item from everyone but its owner; `null` makes it shared again. */
|
|
919
|
+
visibility?: 'private' | null;
|
|
897
920
|
/** `null` clears it (undoing a voice-set priority). */
|
|
898
921
|
priority?: number | null;
|
|
899
922
|
}): Promise<Commitment>;
|
|
@@ -6,6 +6,9 @@ import { createTabsNavigator, type TabsNavigator } from '../shell/navigator';
|
|
|
6
6
|
import type { SessionState } from '../recording/session';
|
|
7
7
|
import { createBanners } from './banners';
|
|
8
8
|
import { createFoundryData } from './data';
|
|
9
|
+
import { fakeEntityRows } from './fakeEntities';
|
|
10
|
+
import { createFakeNativeCorpusApi, type FakeNativeCorpusApi } from '../corpus/fake';
|
|
11
|
+
import { fakeBriefingRows } from '../briefing/fakeReply';
|
|
9
12
|
import type { FoundryDevice } from './device';
|
|
10
13
|
import { readLaunch } from './launch';
|
|
11
14
|
import { buildFoundryTabs, createScreenRegistry, type ScreenFactory } from './registry';
|
|
@@ -44,10 +47,17 @@ function Themed({ mode, children }: { mode: FoundryAppConfig['theme']['mode'] |
|
|
|
44
47
|
function Root({ config, device, registry }: { config: FoundryAppConfig; device: FoundryDevice; registry: ReturnType<typeof createScreenRegistry> }) {
|
|
45
48
|
const launch = useMemo(() => readLaunch((k) => Settings.get(k), config), [config]);
|
|
46
49
|
const strings = useMemo(() => foundryStrings(config), [config]);
|
|
50
|
+
// The fake briefing's replies write to the very rows the Tracker tab reads, so both share one fake tenant.
|
|
51
|
+
const fakeCorpus = useMemo(
|
|
52
|
+
() => (launch.fakeBriefing
|
|
53
|
+
? createFakeNativeCorpusApi({ scenario: launch.scenario, extraEntities: [...fakeEntityRows(config), ...fakeBriefingRows()] })
|
|
54
|
+
: null),
|
|
55
|
+
[config, launch],
|
|
56
|
+
);
|
|
47
57
|
const { banners, services } = useMemo(() => {
|
|
48
58
|
const b = createBanners();
|
|
49
|
-
return { banners: b, services: createFoundryServices({ config, device, banners: b, strings, fakeBriefing: launch.fakeBriefing }) };
|
|
50
|
-
}, [config, device, strings, launch]);
|
|
59
|
+
return { banners: b, services: createFoundryServices({ config, device, banners: b, strings, fakeBriefing: launch.fakeBriefing ? { corpus: fakeCorpus as FakeNativeCorpusApi, script: launch.fakeReply } : null }) };
|
|
60
|
+
}, [config, device, strings, launch, fakeCorpus]);
|
|
51
61
|
// The engine is the device's; a haptic that throws (no taptic hardware, simulator) never breaks a screen.
|
|
52
62
|
// Every call is logged to the diagnostics (`haptic`, then `haptic.result`) so a device run proves the engine was invoked.
|
|
53
63
|
const haptic = useCallback((kind: HapticKind, source?: string) => {
|
|
@@ -66,8 +76,8 @@ function Root({ config, device, registry }: { config: FoundryAppConfig; device:
|
|
|
66
76
|
const [expired, setExpired] = useState(false);
|
|
67
77
|
const [showDiag, setShowDiag] = useState(false);
|
|
68
78
|
const data = useMemo(
|
|
69
|
-
() => createFoundryData({ config, authorizedFetch: services.session.authorizedFetch, fake: launch.fake, scenario: launch.scenario }),
|
|
70
|
-
[config, services, launch],
|
|
79
|
+
() => createFoundryData({ config, authorizedFetch: services.session.authorizedFetch, fake: launch.fake, scenario: launch.scenario, ...(fakeCorpus ? { fakeCorpus } : {}) }),
|
|
80
|
+
[config, services, launch, fakeCorpus],
|
|
71
81
|
);
|
|
72
82
|
|
|
73
83
|
// The tenant's declared types fill what the config left to defaults (entity types, tabs, Home cards). Read once per
|
|
@@ -105,7 +115,15 @@ function Root({ config, device, registry }: { config: FoundryAppConfig; device:
|
|
|
105
115
|
}, [launch]);
|
|
106
116
|
|
|
107
117
|
useEffect(() => {
|
|
108
|
-
if (launch.fake) {
|
|
118
|
+
if (launch.fake) {
|
|
119
|
+
setAuth('signedIn');
|
|
120
|
+
// Links and the morning notification work over the fakes too, so a simulator check can open the briefing from a link.
|
|
121
|
+
void services.deepLink.sessionReady();
|
|
122
|
+
void services.briefing?.syncNotification();
|
|
123
|
+
void Linking.getInitialURL().then((url) => url && services.deepLink.handle(url));
|
|
124
|
+
const sub = Linking.addEventListener('url', ({ url }) => services.deepLink.handle(url));
|
|
125
|
+
return () => sub.remove();
|
|
126
|
+
}
|
|
109
127
|
const off = services.session.subscribe((next) => {
|
|
110
128
|
setAuth(next);
|
|
111
129
|
if (next === 'signedIn') { setExpired(false); void services.onReady(); }
|
|
@@ -125,13 +143,13 @@ function Root({ config, device, registry }: { config: FoundryAppConfig; device:
|
|
|
125
143
|
// The GO screen reads the latest element through the ref, so it re-renders without rebuilding the tabs.
|
|
126
144
|
const record = (
|
|
127
145
|
services.recording
|
|
128
|
-
? <RecordScreen recording={services.recording} briefing={services.briefing?.controller ?? null} strings={strings} onOpenDiagnostics={() => setShowDiag(true)} onSignOut={() => { void services.session.signOut(); }} />
|
|
146
|
+
? <RecordScreen recording={services.recording} briefing={services.briefing?.controller ?? null} briefingReply={services.briefing?.reply ?? null} strings={strings} onOpenDiagnostics={() => setShowDiag(true)} onSignOut={() => { void services.session.signOut(); }} />
|
|
129
147
|
: null
|
|
130
148
|
);
|
|
131
149
|
const recordRef = useRef<ReactNode>(record);
|
|
132
150
|
recordRef.current = record;
|
|
133
151
|
const tabs = useMemo(
|
|
134
|
-
() => buildFoundryTabs({ config: appConfig, corpus: data.corpus, notes: data.notes, record: () => recordRef.current, member: data.member, openUrl: data.openUrl ?? ((url) => Linking.openURL(url)) }, registry),
|
|
152
|
+
() => buildFoundryTabs({ config: appConfig, corpus: data.corpus, notes: data.notes, record: () => recordRef.current, member: data.member, itemsChanged: services.briefing?.itemsChanged, openUrl: data.openUrl ?? ((url) => Linking.openURL(url)) }, registry),
|
|
135
153
|
[appConfig, data, registry],
|
|
136
154
|
);
|
|
137
155
|
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
+
|
|
3
|
+
const launchArgs: Record<string, string> = {};
|
|
4
|
+
const links: { handler: ((e: { url: string }) => void) | null } = { handler: null };
|
|
5
|
+
vi.mock('react-native', async () => {
|
|
6
|
+
const stub = await import('../../../../../ui-native/test/rn-stub');
|
|
7
|
+
return {
|
|
8
|
+
...stub,
|
|
9
|
+
Settings: { get: (k: string) => launchArgs[k] },
|
|
10
|
+
StatusBar: 'StatusBar',
|
|
11
|
+
AppState: { currentState: 'active', addEventListener: () => ({ remove() {} }) },
|
|
12
|
+
Linking: { openURL: async () => {}, getInitialURL: async () => null, addEventListener: (_e: string, h: (e: { url: string }) => void) => { links.handler = h; return { remove() { links.handler = null; } }; } },
|
|
13
|
+
};
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
import { act, hostById, maybeById, render } from '../../../../../ui-native/test/render';
|
|
17
|
+
import { FoundryApp } from '../FoundryApp';
|
|
18
|
+
import type { FoundryDevice } from '../device';
|
|
19
|
+
|
|
20
|
+
const tick = () => act(async () => { await new Promise((res) => setTimeout(res, 40)); });
|
|
21
|
+
const files = new Map<string, string>();
|
|
22
|
+
const session = { info: async () => ({ category: 'playback', mode: 'default', options: [], sampleRate: 48000, inputs: [] }), onInterruption: () => () => undefined, onRouteChange: () => () => undefined };
|
|
23
|
+
let played = 0;
|
|
24
|
+
const device = (): FoundryDevice => ({
|
|
25
|
+
tokenStorage: { getRefreshToken: async () => null, setRefreshToken: async () => {}, clear: async () => {} },
|
|
26
|
+
files: { exists: async (p) => files.has(p), read: async (p) => files.get(p) ?? '', write: async (p, v) => { files.set(p, v); } },
|
|
27
|
+
documentUri: (n) => `file:///docs/${n}`,
|
|
28
|
+
recording: {
|
|
29
|
+
driver: {} as never, session, background: { begin: async () => 0, end: async () => undefined } as never,
|
|
30
|
+
permissions: { get: async () => ({ status: 'granted', granted: true, canAskAgain: true }), request: async () => ({ status: 'granted', granted: true, canAskAgain: true }) },
|
|
31
|
+
openSettings: async () => undefined, fileSize: async () => 1, removeFile: async () => undefined, listRecordings: async () => [], filePart: () => ({}) as Blob,
|
|
32
|
+
},
|
|
33
|
+
briefing: {
|
|
34
|
+
driver: {
|
|
35
|
+
configureSession: async () => undefined, load: () => undefined, play: () => { played += 1; }, pause: () => undefined, release: async () => undefined,
|
|
36
|
+
status: () => ({ playing: true, loaded: true, positionMillis: 1, durationMillis: 1000, ended: false }),
|
|
37
|
+
},
|
|
38
|
+
fixture: { uri: 'fixture://briefing' },
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
const config = { app: { name: 'Acme Go', scheme: 'acmego' }, tenant: { url: 'https://acme.example.com' }, features: { briefing: true, notes: false, ask: false, planning: false, connectClaude: false }, tabs: [{ screen: 'record' }, { screen: 'tracker' }] };
|
|
42
|
+
|
|
43
|
+
describe('the briefing link over the fakes', () => {
|
|
44
|
+
it('test_scheme_briefing_lands_on_go_and_plays_the_briefing_without_tapping', async () => {
|
|
45
|
+
launchArgs.tgFakeTabs = '1';
|
|
46
|
+
launchArgs.tgFakeBriefing = '1';
|
|
47
|
+
launchArgs.tgTab = 'tracker';
|
|
48
|
+
const r = render(<FoundryApp config={config} device={device()} />);
|
|
49
|
+
await tick();
|
|
50
|
+
expect(maybeById(r, 'briefing-stop')).toHaveLength(0);
|
|
51
|
+
await act(async () => { links.handler?.({ url: 'acmego://briefing' }); await new Promise((res) => setTimeout(res, 800)); });
|
|
52
|
+
expect(played).toBeGreaterThan(0);
|
|
53
|
+
expect(hostById(r, 'briefing-stop')).toBeTruthy();
|
|
54
|
+
expect(hostById(r, 'briefing-talk')).toBeTruthy();
|
|
55
|
+
delete launchArgs.tgTab;
|
|
56
|
+
});
|
|
57
|
+
});
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
+
|
|
3
|
+
vi.mock('react-native', async () => ({
|
|
4
|
+
...(await import('../../../../../ui-native/test/rn-stub')),
|
|
5
|
+
AppState: { currentState: 'active', addEventListener: () => ({ remove() {} }) },
|
|
6
|
+
}));
|
|
7
|
+
import { createFoundryServices } from '../services';
|
|
8
|
+
import { createBanners } from '../banners';
|
|
9
|
+
import { foundryStrings } from '../strings';
|
|
10
|
+
import { resolveFoundryApp } from '../config/validate';
|
|
11
|
+
import { createFakeNativeCorpusApi } from '../../corpus/fake';
|
|
12
|
+
import { fakeBriefingRows } from '../../briefing/fakeReply';
|
|
13
|
+
|
|
14
|
+
const session = { info: async () => ({ category: 'playback', mode: 'default', options: [], sampleRate: 48000, inputs: [] }), onInterruption: () => () => undefined, onRouteChange: () => () => undefined };
|
|
15
|
+
const files = new Map<string, string>();
|
|
16
|
+
const device = (extra: object = {}) => ({
|
|
17
|
+
tokenStorage: { getRefreshToken: async () => null, setRefreshToken: async () => undefined, clear: async () => undefined },
|
|
18
|
+
files: { exists: async (p: string) => files.has(p), read: async (p: string) => files.get(p) ?? '', write: async (p: string, v: string) => { files.set(p, v); } },
|
|
19
|
+
documentUri: (n: string) => `file:///${n}`,
|
|
20
|
+
recording: {
|
|
21
|
+
driver: {}, session, background: { begin: async () => 0, end: async () => undefined }, permissions: { get: async () => ({ status: 'granted', granted: true, canAskAgain: true }), request: async () => ({ status: 'granted', granted: true, canAskAgain: true }) },
|
|
22
|
+
openSettings: async () => undefined, fileSize: async () => 1, removeFile: async () => undefined, listRecordings: async () => [], filePart: () => ({}) as Blob,
|
|
23
|
+
},
|
|
24
|
+
briefing: { driver: { configureSession: async () => undefined, load: () => undefined, play: () => undefined, pause: () => undefined, release: async () => undefined, status: () => ({ playing: true, loaded: true, positionMillis: 1, durationMillis: 1000, ended: false }) }, fixture: { uri: 'fixture://briefing' } },
|
|
25
|
+
...extra,
|
|
26
|
+
}) as never;
|
|
27
|
+
|
|
28
|
+
const make = (features: object, dev = device(), fake = false) => {
|
|
29
|
+
const config = resolveFoundryApp({ app: { name: 'Acme Go', scheme: 'acmego' }, tenant: { url: 'https://acme.example.com' }, features: { ...features } });
|
|
30
|
+
const services = createFoundryServices({
|
|
31
|
+
config, device: dev, banners: createBanners(), strings: foundryStrings(config),
|
|
32
|
+
...(fake ? { fakeBriefing: { corpus: createFakeNativeCorpusApi({ extraEntities: fakeBriefingRows() }), script: ['move this one to later'] } } : {}),
|
|
33
|
+
});
|
|
34
|
+
return { services, config };
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
describe('briefing services', () => {
|
|
38
|
+
it('test_reply_is_wired_by_default_when_the_briefing_is_on', () => {
|
|
39
|
+
const { services } = make({ briefing: true });
|
|
40
|
+
expect(services.briefing?.reply).toBeTruthy();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('test_the_reply_can_be_switched_off_in_config', () => {
|
|
44
|
+
expect(make({ briefing: { reply: false } }).services.briefing?.reply).toBeNull();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('test_a_reply_without_recording_bindings_is_a_clear_error_not_a_dead_button', () => {
|
|
48
|
+
const base = device() as any;
|
|
49
|
+
const noRec = { ...base, recording: undefined, briefing: { ...base.briefing, session } } as never;
|
|
50
|
+
expect(() => make({ briefing: true, recording: false }, noRec)).toThrow(/features\.briefing\.reply needs the recording bindings/);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('test_the_briefing_link_opens_go_and_starts_the_briefing_once_signed_in', async () => {
|
|
54
|
+
const { services } = make({ briefing: true }, device(), true);
|
|
55
|
+
const open = vi.fn();
|
|
56
|
+
services.bindOpen(open);
|
|
57
|
+
const start = vi.spyOn(services.briefing!.controller, 'start').mockResolvedValue(undefined);
|
|
58
|
+
services.deepLink.handle('acmego://briefing');
|
|
59
|
+
expect(start).not.toHaveBeenCalled();
|
|
60
|
+
await services.deepLink.sessionReady();
|
|
61
|
+
expect(open).toHaveBeenCalledWith('go');
|
|
62
|
+
expect(start).toHaveBeenCalledTimes(1);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('test_the_fake_briefing_schedules_a_notification_through_the_diagnostics_notifier', async () => {
|
|
66
|
+
const { services } = make({ briefing: true }, device(), true);
|
|
67
|
+
await services.briefing!.syncNotification();
|
|
68
|
+
const text = JSON.stringify(services.diag.entries());
|
|
69
|
+
expect(text).toContain('notification.scheduled');
|
|
70
|
+
expect(text).toContain('acmego://briefing');
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('test_the_fakes_never_reach_the_device_notifier_and_notification_can_be_turned_off', async () => {
|
|
74
|
+
const notifier = { schedule: vi.fn(async () => 'n1'), cancel: vi.fn(async () => undefined) };
|
|
75
|
+
const dev = device(); (dev as any).briefing.notifier = notifier;
|
|
76
|
+
const on = make({ briefing: true }, dev, true);
|
|
77
|
+
await on.services.briefing!.syncNotification();
|
|
78
|
+
expect(notifier.schedule).not.toHaveBeenCalled();
|
|
79
|
+
expect(JSON.stringify(on.services.diag.entries())).toContain('notification.scheduled');
|
|
80
|
+
const off = make({ briefing: { notification: false } }, device(), true);
|
|
81
|
+
await off.services.briefing!.syncNotification();
|
|
82
|
+
expect(JSON.stringify(off.services.diag.entries())).not.toContain('notification.scheduled');
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('test_a_real_sync_with_no_session_changes_nothing_and_never_throws', async () => {
|
|
86
|
+
const notifier = { schedule: vi.fn(async () => 'n1'), cancel: vi.fn(async () => undefined) };
|
|
87
|
+
const dev = device(); (dev as any).briefing.notifier = notifier;
|
|
88
|
+
const { services } = make({ briefing: true }, dev, false);
|
|
89
|
+
await expect(services.briefing!.syncNotification()).resolves.toBeUndefined();
|
|
90
|
+
expect(notifier.schedule).not.toHaveBeenCalled();
|
|
91
|
+
});
|
|
92
|
+
});
|
|
@@ -7,7 +7,7 @@ const args = (o: Record<string, string>) => (k: string) => o[k];
|
|
|
7
7
|
|
|
8
8
|
describe('readLaunch', () => {
|
|
9
9
|
it('a plain launch is real mode with nothing to open', () => {
|
|
10
|
-
expect(readLaunch(args({}), config)).toEqual({ fake: false, scenario: 'normal', target: null, autostop: null, scheme: null, hapticProbe: false, fakeBriefing: false });
|
|
10
|
+
expect(readLaunch(args({}), config)).toEqual({ fake: false, scenario: 'normal', target: null, autostop: null, scheme: null, hapticProbe: false, fakeBriefing: false, fakeReply: [] });
|
|
11
11
|
});
|
|
12
12
|
it('-tgFakeTabs with -tgTab and -tgDetail', () => {
|
|
13
13
|
expect(readLaunch(args({ tgFakeTabs: '1', tgTab: 'tracker', tgDetail: 'c1' }), config)).toMatchObject({ fake: true, target: { tab: 'tracker', id: 'c1' } });
|
|
@@ -20,6 +20,7 @@ describe('readLaunch', () => {
|
|
|
20
20
|
it('-tgHapticProbe 1', () => {
|
|
21
21
|
expect(readLaunch(args({ tgHapticProbe: '1' }), config).hapticProbe).toBe(true);
|
|
22
22
|
expect(readLaunch(args({ tgFakeBriefing: '1' }), config).fakeBriefing).toBe(true);
|
|
23
|
+
expect(readLaunch(args({ tgFakeReply: 'move this one to later | undo' }), config).fakeReply).toEqual(['move this one to later', 'undo']);
|
|
23
24
|
});
|
|
24
25
|
it('-tgFakeState and -tgAutostop', () => {
|
|
25
26
|
expect(readLaunch(args({ tgFakeTabs: '1', tgFakeState: 'empty', tgAutostop: '30' }), config)).toMatchObject({ scenario: 'empty', autostop: 30 });
|