@yaks/inbox 0.0.0-stage → 0.2.36

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 (88) hide show
  1. package/LICENSE +202 -0
  2. package/Person.tsx +275 -0
  3. package/Project.tsx +83 -0
  4. package/README.md +311 -2
  5. package/_dist/actions-browser.d.ts +8 -0
  6. package/_dist/actions-browser.d.ts.map +1 -0
  7. package/_dist/actions.d.ts +22 -0
  8. package/_dist/actions.d.ts.map +1 -0
  9. package/_dist/asks.d.ts +15 -0
  10. package/_dist/asks.d.ts.map +1 -0
  11. package/_dist/graph.d.ts +12 -0
  12. package/_dist/graph.d.ts.map +1 -0
  13. package/_dist/letters.d.ts +24 -0
  14. package/_dist/letters.d.ts.map +1 -0
  15. package/_dist/mail.d.ts +4 -0
  16. package/_dist/mail.d.ts.map +1 -0
  17. package/_dist/mod.d.ts +7 -0
  18. package/_dist/mod.d.ts.map +1 -0
  19. package/_dist/options.d.ts +18 -0
  20. package/_dist/options.d.ts.map +1 -0
  21. package/_dist/queries.d.ts +23 -0
  22. package/_dist/queries.d.ts.map +1 -0
  23. package/_dist/read.d.ts +18 -0
  24. package/_dist/read.d.ts.map +1 -0
  25. package/_dist/reader.d.ts +25 -0
  26. package/_dist/reader.d.ts.map +1 -0
  27. package/_dist/service.d.ts +8 -0
  28. package/_dist/service.d.ts.map +1 -0
  29. package/_dist/threads.d.ts +33 -0
  30. package/_dist/threads.d.ts.map +1 -0
  31. package/_dist/tools.d.ts +12 -0
  32. package/_dist/tools.d.ts.map +1 -0
  33. package/_dist/vocab.d.ts +5 -0
  34. package/_dist/vocab.d.ts.map +1 -0
  35. package/actions-browser.js +165 -0
  36. package/actions-browser.js.map +1 -0
  37. package/actions-browser.ts +158 -0
  38. package/actions.js +34 -0
  39. package/actions.js.map +1 -0
  40. package/actions.ts +53 -0
  41. package/asks.js +76 -0
  42. package/asks.js.map +1 -0
  43. package/asks.ts +94 -0
  44. package/deno.json +1 -0
  45. package/front.js +41 -0
  46. package/front.js.map +1 -0
  47. package/front.json +68 -0
  48. package/front.ts +38 -0
  49. package/graph.js +176 -0
  50. package/graph.js.map +1 -0
  51. package/graph.ts +182 -0
  52. package/inspect.tsx +22 -0
  53. package/letters.js +233 -0
  54. package/letters.js.map +1 -0
  55. package/letters.ts +325 -0
  56. package/mail.js +122 -0
  57. package/mail.js.map +1 -0
  58. package/mail.ts +148 -0
  59. package/mod.js +11 -0
  60. package/mod.js.map +1 -0
  61. package/mod.ts +24 -0
  62. package/options.js +15 -0
  63. package/options.js.map +1 -0
  64. package/options.ts +42 -0
  65. package/package.json +76 -4
  66. package/queries.js +240 -0
  67. package/queries.js.map +1 -0
  68. package/queries.ts +302 -0
  69. package/read.js +453 -0
  70. package/read.js.map +1 -0
  71. package/read.ts +476 -0
  72. package/reader.js +105 -0
  73. package/reader.js.map +1 -0
  74. package/reader.ts +147 -0
  75. package/service.js +29 -0
  76. package/service.js.map +1 -0
  77. package/service.ts +45 -0
  78. package/threads.js +182 -0
  79. package/threads.js.map +1 -0
  80. package/threads.ts +276 -0
  81. package/tools.js +101 -0
  82. package/tools.js.map +1 -0
  83. package/tools.ts +103 -0
  84. package/views.tsx +30 -0
  85. package/vocab.js +12 -0
  86. package/vocab.js.map +1 -0
  87. package/vocab.json +242 -0
  88. package/vocab.ts +11 -0
package/reader.ts ADDED
@@ -0,0 +1,147 @@
1
+ /** Pure attention policy shared by every inbox door. No I/O or sends. */
2
+ export type Row = {
3
+ eid: string
4
+ comps: Record<string, Record<string, unknown>>
5
+ }
6
+
7
+ // Who an inbox reads FOR: the session S acting for actor A, standing in
8
+ // project P, holding the eids it CLAIMS. Every "addressed to me" test
9
+ // below is a pure fact about the graph, so membership can't drift.
10
+ export type Reader = {
11
+ session?: string
12
+ actor?: string
13
+ scope?: string
14
+ // Whether this reader is the project's operator loop. Non-operators get no
15
+ // project-wide mail or actor knocks, only direct address and claimed work.
16
+ operator?: boolean
17
+ claims?: Set<string>
18
+ // The addresses this reader answers to (its actor's, plus the actor's own
19
+ // eid, which is how a letter names a recipient before delivery resolves
20
+ // it). A letter reaches a PERSON this way — they stand in no project, so
21
+ // the scope arm below says nothing about them.
22
+ addrs?: Set<string>
23
+ // The entities this actor has a standing instruction about: watch them
24
+ // though nothing is aimed at me, mute them though something is. Absent
25
+ // from both is the default, which is whatever addressed() says.
26
+ watching?: Set<string>
27
+ muting?: Set<string>
28
+ // Personal archived/opened marks live on the actor/target subscription.
29
+ attention?: Map<string, Row>
30
+ }
31
+
32
+ // What an inbox item is ABOUT — a subscription is aimed at the task or
33
+ // the venture, never at the individual letter, so this is the eid the
34
+ // watch/mute sets are asked about.
35
+ export let aboutOf = (r: Row): string =>
36
+ String(
37
+ r.comps.comment?.target ?? r.comps.notification?.about ??
38
+ r.comps.mail?.target ?? r.comps.knock?.target ?? '',
39
+ )
40
+
41
+ // Every entity this actor has said something about, split by mode.
42
+ export let subsOf = (all: Row[], actor?: string): {
43
+ watching: Set<string>
44
+ muting: Set<string>
45
+ attention: Map<string, Row>
46
+ } => {
47
+ let watching = new Set<string>(), muting = new Set<string>()
48
+ let attention = new Map<string, Row>()
49
+ if (actor) {
50
+ for (let r of all) {
51
+ let sub = r.comps.subscription
52
+ if (!sub || String(sub.actor) != actor) continue
53
+ let target = String(sub.target)
54
+ if (sub.mode == 'mute') muting.add(target)
55
+ if (sub.mode == 'watch') watching.add(target)
56
+ attention.set(target, r)
57
+ }
58
+ }
59
+ return { watching, muting, attention }
60
+ }
61
+
62
+ // Addressed to this reader — the four doors an item reaches attention
63
+ // through: a comment on work it claims or on the session itself, a knock aimed
64
+ // at the session or its actor, or mail that ARRIVED
65
+ // (message_id is the inbound mark; sent mail carries none). One predicate,
66
+ // so the digest, the TUI, and the web read the SAME inbox.
67
+ export let addressed = (who: Reader) => (r: Row): boolean => {
68
+ let c = r.comps.comment
69
+ if (c) {
70
+ let t = String(c.target ?? '')
71
+ // Said TO the actor, not just to one of its sessions: an operator loop
72
+ // outlives the session that happened to be running when someone spoke
73
+ // to the venture, so a comment on P-19 must reach whoever runs P-19 —
74
+ // it was unheard by anyone otherwise. Gated on `operator` exactly like
75
+ // the actor knock below, so a specialist still hears only direct
76
+ // address and its own claimed work.
77
+ return t == who.session || !!who.claims?.has(t) ||
78
+ (who.operator == true && !!who.actor && t == who.actor)
79
+ }
80
+ // A notification was emitted, not said: it reaches whoever its `to`
81
+ // names, the session or the actor, and for an operator loop the project it
82
+ // stands in, which is everyone there.
83
+ if (r.comps.notification) {
84
+ let t = String(r.comps.notification.to ?? '')
85
+ return !!t && (t == who.session || t == who.actor ||
86
+ (who.operator == true && t == who.scope))
87
+ }
88
+ let k = r.comps.knock
89
+ if (k) {
90
+ // WHO the knock is for rides the shared `deliver {to}` facet now.
91
+ let t = String(r.comps.deliver?.to ?? '')
92
+ return !!t &&
93
+ (t == who.session || (who.operator == true && t == who.actor))
94
+ }
95
+ let m = r.comps.mail
96
+ if (m) {
97
+ // An arrival, never a letter still going out — message_id is the
98
+ // inbound mark, and it screens both arms below.
99
+ if (!m.message_id) return false
100
+ // A letter to your SESSION is direct address, so it lands whatever loop
101
+ // you run — the same rule the comment and knock arms above already
102
+ // follow. Sessions are addressable by id (`S-31@<fleet domain>`), and
103
+ // gating that on `operator` would resolve the
104
+ // address perfectly and then tell nobody.
105
+ if (who.session && String(m.target) == who.session) return true
106
+ // Project mail reaches only the operator loop, never a specialist.
107
+ if (who.operator != true) return false
108
+ // Two ways a letter is yours, and the FIRST is what a person has: it
109
+ // was sent to an address you answer to. A person stands in no project,
110
+ // so the scope arm says nothing about them — and a reader with neither
111
+ // arm matches NOTHING rather than the fleet's whole correspondence
112
+ // (1338 arrived letters in a week: the wrong default is a firehose,
113
+ // not an inconvenience).
114
+ return (!!who.addrs?.size && who.addrs.has(String(m.to ?? ''))) ||
115
+ (!!who.scope && String(m.target) == who.scope)
116
+ }
117
+ return false
118
+ }
119
+
120
+ // The reader an inbox reads for, resolved from the graph in one place:
121
+ // the session named, the actor it acts for, the project it stands in, and
122
+ // the eids it claims — everything addressed() needs.
123
+ // Every address an actor answers to: the address book entry it carries,
124
+ // and its own eid — a letter names its recipient by reference and only
125
+ // resolves to an address at delivery (M-4063), so both forms appear in the
126
+ // stored row depending on when you look.
127
+ export let addrsOf = (all: Row[], actor?: string): Set<string> => {
128
+ let out = new Set<string>()
129
+ if (!actor) return out
130
+ out.add(actor)
131
+ let a = all.find((r) => r.eid == actor)?.comps.email?.address
132
+ if (a) out.add(String(a))
133
+ return out
134
+ }
135
+
136
+ // A person or project reading through any door. A browser has no session — its
137
+ // identity is the actor its client entity names — and a person browsing
138
+ // their own graph IS the loop, which is all `operator` has ever meant.
139
+ // No claims: leases belong to sessions, and a person holds none.
140
+ export let readerAt = (all: Row[], actor?: string): Reader => ({
141
+ actor,
142
+ operator: true,
143
+ claims: new Set(),
144
+ addrs: addrsOf(all, actor),
145
+ scope: all.find((r) => r.eid == actor)?.comps.project ? actor : undefined,
146
+ ...subsOf(all, actor),
147
+ })
package/service.js ADDED
@@ -0,0 +1,29 @@
1
+ // The inbox's letters, as a duty: the module a server imports at
2
+ // `@yaks/inbox/service`. Every pass reads the person's inbox and queues a
3
+ // letter for each newly blocking decision, and after `hour` (UTC) at most one
4
+ // digest a day of the rest (./letters.ts). The queued letters are the record:
5
+ // their eids are derived from what they render, so a pass that finds them
6
+ // written queues nothing, and a missed day is not replayed. @yaks/mail sends
7
+ // them.
8
+ //
9
+ // It is a loop because nothing is committed when a day turns or a thread waits;
10
+ // it is a duty so that one process over the graph queues at a time. A config
11
+ // that opens no door (./options.ts) has nothing to queue, and the duty ends at
12
+ // once.
13
+ import { sleep } from "@yaks/fp";
14
+ import { queue } from "./letters.js";
15
+ import { door } from "./options.js";
16
+ /** How long a pass waits for the next one, unless the config says. */ export let EVERY = 10_000;
17
+ /** Queue what is owed, then again every `every`, until the signal aborts. An
18
+ * already-aborted signal is one pass. */ export let service = async (host, options = {}, signal = AbortSignal.abort())=>{
19
+ let open = door(options);
20
+ if (!open) return;
21
+ for(;;){
22
+ let now = new Date().toISOString();
23
+ await queue(host.graph, host.graph.vocab, open, (b)=>host.graph.apply(b), now, new Date(now).getUTCHours() >= (open.hour ?? 9));
24
+ if (signal.aborted) return;
25
+ await sleep(open.every ?? EVERY, signal);
26
+ if (signal.aborted) return;
27
+ }
28
+ };
29
+ //# sourceMappingURL=service.js.map
package/service.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sources":["./service.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,0EAA0E;AAC1E,8EAA8E;AAC9E,8EAA8E;AAC9E,0EAA0E;AAC1E,6EAA6E;AAC7E,QAAQ;AACR,EAAE;AACF,gFAAgF;AAChF,6EAA6E;AAC7E,+EAA+E;AAC/E,QAAQ;AAGR,SAAS,KAAK,wBAA6B;AAC3C,SAAS,KAAK,uBAAsB;AACpC,SAAS,IAAI,uBAAoC;AAEjD,oEAAoE,GACpE,OAAO,IAAI,QAAQ,OAAM;AAEzB;uCACuC,GACvC,OAAO,IAAI,UAAU,OACnB,MACA,UAAmB,CAAC,CAAC,EACrB,SAAsB,YAAY,KAAK,EAAE;EAEzC,IAAI,OAAO,KAAK;EAChB,IAAI,CAAC,MAAM;EACX,OAAS;IACP,IAAI,MAAM,IAAI,OAAO,WAAW;IAChC,MAAM,MACJ,KAAK,KAAK,EACV,KAAK,KAAK,CAAC,KAAK,EAChB,MACA,CAAC,IAAM,KAAK,KAAK,CAAC,KAAK,CAAC,IACxB,KACA,IAAI,KAAK,KAAK,WAAW,MAAM,CAAC,KAAK,IAAI,IAAI,CAAC;IAEhD,IAAI,OAAO,OAAO,EAAE;IACpB,MAAM,MAAM,KAAK,KAAK,IAAI,OAAO;IACjC,IAAI,OAAO,OAAO,EAAE;EACtB;AACF,EAAC"}
package/service.ts ADDED
@@ -0,0 +1,45 @@
1
+ // The inbox's letters, as a duty: the module a server imports at
2
+ // `@yaks/inbox/service`. Every pass reads the person's inbox and queues a
3
+ // letter for each newly blocking decision, and after `hour` (UTC) at most one
4
+ // digest a day of the rest (./letters.ts). The queued letters are the record:
5
+ // their eids are derived from what they render, so a pass that finds them
6
+ // written queues nothing, and a missed day is not replayed. @yaks/mail sends
7
+ // them.
8
+ //
9
+ // It is a loop because nothing is committed when a day turns or a thread waits;
10
+ // it is a duty so that one process over the graph queues at a time. A config
11
+ // that opens no door (./options.ts) has nothing to queue, and the duty ends at
12
+ // once.
13
+
14
+ import type { Graph } from 'jsr:@yaks/graph@0.2.36'
15
+ import { sleep } from '@yaks/fp'
16
+ import { queue } from './letters.js'
17
+ import { door, type Options } from './options.js'
18
+
19
+ /** How long a pass waits for the next one, unless the config says. */
20
+ export let EVERY = 10_000
21
+
22
+ /** Queue what is owed, then again every `every`, until the signal aborts. An
23
+ * already-aborted signal is one pass. */
24
+ export let service = async (
25
+ host: { graph: Graph },
26
+ options: Options = {},
27
+ signal: AbortSignal = AbortSignal.abort(),
28
+ ): Promise<void> => {
29
+ let open = door(options)
30
+ if (!open) return
31
+ for (;;) {
32
+ let now = new Date().toISOString()
33
+ await queue(
34
+ host.graph,
35
+ host.graph.vocab,
36
+ open,
37
+ (b) => host.graph.apply(b),
38
+ now,
39
+ new Date(now).getUTCHours() >= (open.hour ?? 9),
40
+ )
41
+ if (signal.aborted) return
42
+ await sleep(open.every ?? EVERY, signal)
43
+ if (signal.aborted) return
44
+ }
45
+ }
package/threads.js ADDED
@@ -0,0 +1,182 @@
1
+ import { addressed } from "./reader.js";
2
+ import { threadOf } from "@yaks/notify";
3
+ export const lanes = [
4
+ 'Needs you',
5
+ 'Replies',
6
+ 'Updates',
7
+ 'Recent'
8
+ ];
9
+ let str = (v)=>String(v ?? '');
10
+ let newest = (...times)=>{
11
+ let latest = '';
12
+ for (let time of times){
13
+ let value = str(time);
14
+ if (value > latest) latest = value;
15
+ }
16
+ return latest;
17
+ };
18
+ let closed = (r)=>!!(r.comps.completed || r.comps.cancelled);
19
+ let states = [
20
+ 'completed',
21
+ 'cancelled',
22
+ 'failed',
23
+ 'blocked',
24
+ 'broken',
25
+ 'resolved',
26
+ 'regressed',
27
+ 'decided',
28
+ 'exit'
29
+ ];
30
+ export let stateAt = (r)=>newest(r.comps.blocked?.since, ...states.map((s)=>r.comps[s]?.at));
31
+ export let messageAt = (r)=>newest(r.comps.created?.at, r.comps.mail?.at, r.comps.commit?.at);
32
+ /** Reading, archiving, delivery and arbitrary edits are not new activity. */ export let activityAt = (r)=>newest(messageAt(r), stateAt(r), r.comps.bug?.last, r.comps.bug?.first);
33
+ export { threadOf } from "@yaks/notify";
34
+ export let saidBy = (who, r, byId)=>{
35
+ if (r.comps.mail) return !!who.addrs?.has(str(r.comps.mail.from));
36
+ if (r.comps.entry) {
37
+ return !!who.actor && (r.comps.created?.by == who.actor || byId?.get(str(r.comps.entry.session))?.comps.session?.actor == who.actor) && !!r.comps.content && ![
38
+ 'output',
39
+ 'prompt',
40
+ 'notice',
41
+ 'reasoning',
42
+ 'result',
43
+ 'exception',
44
+ 'refusal',
45
+ 'ask',
46
+ 'call'
47
+ ].some((c)=>!!r.comps[c]);
48
+ }
49
+ return !!who.actor && r.comps.created?.by == who.actor;
50
+ };
51
+ let words = (r)=>[
52
+ r.comps.doc?.title,
53
+ r.comps.doc?.body,
54
+ r.comps.content?.body,
55
+ r.comps.bug?.title,
56
+ r.comps.decision?.question
57
+ ].map(str).join('\n').toLocaleLowerCase();
58
+ /** Follow reply ancestry, not every branch on an entity the person spoke on. */ let answers = (who, r, byId)=>{
59
+ let seen = new Set([
60
+ r.eid
61
+ ]);
62
+ let ref = str(r.comps.comment?.reply_to ?? r.comps.mail?.reply_to);
63
+ while(ref && !seen.has(ref)){
64
+ seen.add(ref);
65
+ let parent = byId.get(ref);
66
+ if (!parent || threadOf(parent, who, byId) != threadOf(r, who, byId)) {
67
+ return false;
68
+ }
69
+ if (saidBy(who, parent, byId)) return true;
70
+ ref = str(parent.comps.comment?.reply_to ?? parent.comps.mail?.reply_to);
71
+ }
72
+ return false;
73
+ };
74
+ /** One row per thread, with lane precedence and blocking work first. */ export let threads = (all, who, search = {})=>{
75
+ let records = new Map(all.filter((r)=>!r.comps.mail_notice).map((r)=>[
76
+ r.eid,
77
+ r
78
+ ]));
79
+ let byId = new Map(records);
80
+ for (let r of records.values()){
81
+ for (let id of [
82
+ r.comps.mail?.message_id,
83
+ r.comps.notified?.message_id
84
+ ]){
85
+ if (id) byId.set(str(id), r);
86
+ }
87
+ }
88
+ let groups = new Map();
89
+ for (let r of records.values()){
90
+ if (r.comps.edge || r.comps.subscription) continue;
91
+ let eid = threadOf(r, who, byId);
92
+ let group = groups.get(eid) ?? [];
93
+ group.push(r);
94
+ groups.set(eid, group);
95
+ }
96
+ let to = addressed(who);
97
+ let text = (search.text ?? '').trim().toLocaleLowerCase();
98
+ let out = [];
99
+ for (let [eid, group] of groups){
100
+ if (who.muting?.has(eid)) continue;
101
+ let root = byId.get(eid) ?? group[0];
102
+ let messages = group.filter((r)=>r.comps.comment || r.comps.mail && !r.comps.notification || r.comps.entry && (saidBy(who, r, byId) || r.comps.output && !r.comps.reasoning))// A thread opens with its root: a reply said in the same millisecond
103
+ // as what it answers still follows it.
104
+ .sort((a, b)=>messageAt(a).localeCompare(messageAt(b)) || +(a.eid != eid) - +(b.eid != eid) || a.eid.localeCompare(b.eid));
105
+ let own = messages.filter((r)=>saidBy(who, r, byId));
106
+ let started = saidBy(who, root) || !!who.actor && root.comps.session?.actor == who.actor;
107
+ let watched = !!who.watching?.has(eid) || !!who.claims?.has(eid);
108
+ let received = messages.filter((r)=>!saidBy(who, r, byId));
109
+ let reply = received.filter((r)=>answers(who, r, byId) || to(r) || !!root.comps.conversation && started && r.comps.comment?.target == eid || !!r.comps.entry?.session && started && !!r.comps.output);
110
+ // A notification tells its reader what happened, unless they did it.
111
+ let told = !!root.comps.notification && to(root) && !started;
112
+ let direct = group.some((r)=>!r.comps.notification && to(r)) || !root.comps.notification && root.comps.mail && root.comps.deliver?.to == who.actor;
113
+ let assigned = !!who.actor && root.comps.filed?.assignee == who.actor;
114
+ let alert = !!root.comps.bug && !root.comps.resolved && who.operator == true && (!who.scope || !root.comps.bug.app || root.comps.bug.app == who.scope || watched || assigned);
115
+ let decision = !!root.comps.decision && !!who.actor && who.operator == true && (assigned || !root.comps.filed?.assignee && (!who.scope || root.comps.filed?.project == who.scope || watched));
116
+ let need = !!(!root.comps.archived && !closed(root) && !root.comps.decided && (assigned && !!root.comps.task || decision || alert || direct && group.some((r)=>!!r.comps.knock)));
117
+ let changes = group.filter((r)=>r.comps.commit || r.comps.entry && (r.comps.exception || r.comps.refusal || r.comps.stop));
118
+ let update = told || (started || watched) && (!!stateAt(root) || !!changes.length);
119
+ let visible = [
120
+ 'doc',
121
+ 'task',
122
+ 'session',
123
+ 'design',
124
+ 'bug',
125
+ 'project',
126
+ 'mail',
127
+ 'decision'
128
+ ].some((name)=>!!root.comps[name]);
129
+ let recent = started && visible || !!own.length || !!who.actor && (!!who.attention?.get(eid)?.comps.opened || root.comps.decided?.by == who.actor);
130
+ if (!need && !reply.length && !update && !recent && !direct) continue;
131
+ let activity = need ? group : [
132
+ root,
133
+ ...own,
134
+ ...reply,
135
+ ...started || watched ? changes : []
136
+ ];
137
+ let at = newest(...activity.map(activityAt));
138
+ let personal = who.attention?.get(eid)?.comps ?? {};
139
+ let away = str(personal.archived?.at);
140
+ let archived = !!(root.comps.notification && root.comps.archived) || !!personal.archived && (!away || at <= away);
141
+ if (!search.all && archived) continue;
142
+ // A decision's question and answer can have different authors. Treat the
143
+ // answer as its own words rather than attributing the whole root to them.
144
+ if (search.direction || text) {
145
+ let searchable = group.flatMap((r)=>{
146
+ let mine = r == root ? started : saidBy(who, r, byId);
147
+ let includes = (said)=>!search.direction || said == (search.direction == 'said');
148
+ return [
149
+ ...includes(mine) ? [
150
+ words(r)
151
+ ] : [],
152
+ ...r.comps.decided && includes(r.comps.decided.by == who.actor) ? [
153
+ str(r.comps.decided.choice).toLocaleLowerCase()
154
+ ] : []
155
+ ];
156
+ });
157
+ if (!searchable.some((words)=>!text || words.includes(text))) continue;
158
+ }
159
+ let blocking = need && all.some((edge)=>edge.comps.requires && edge.comps.edge?.to == eid && !!byId.get(str(edge.comps.edge.from))?.comps.task && !closed(byId.get(str(edge.comps.edge.from))));
160
+ let lane = need ? 'Needs you' : reply.length || direct ? 'Replies' : update ? 'Updates' : 'Recent';
161
+ let latest = changes.concat(messages).sort((a, b)=>activityAt(a).localeCompare(activityAt(b))).at(-1) ?? root;
162
+ let attention = newest(personal.opened?.at, root.comps.decided?.at, started ? messageAt(root) : '', ...own.map(messageAt));
163
+ if (search.lane && lane != search.lane) {
164
+ continue;
165
+ }
166
+ out.push({
167
+ eid,
168
+ row: root,
169
+ latest,
170
+ messages,
171
+ lane,
172
+ reason: need ? alert ? 'alert' : root.comps.decision ? 'decision' : 'assigned to you' : lane == 'Replies' ? 'reply to your words' : told ? 'told you what happened' : lane == 'Updates' ? 'work changed state' : 'had your attention',
173
+ blocking,
174
+ at,
175
+ unread: at > attention,
176
+ archived
177
+ });
178
+ }
179
+ return out.sort((a, b)=>Number(b.blocking) - Number(a.blocking) || b.at.localeCompare(a.at) || a.eid.localeCompare(b.eid));
180
+ };
181
+ export { attention } from "@yaks/notify";
182
+ //# sourceMappingURL=threads.js.map
package/threads.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"threads.js","sources":["./threads.ts"],"names":[],"mappings":"AAAA,SAAS,SAAS,sBAA4C;AAC9D,SAAS,QAAQ,4BAAiC;AAElD,OAAO,MAAM,QAAQ;EAAC;EAAa;EAAW;EAAW;CAAS,CAAS;AA2B3E,IAAI,MAAM,CAAC,IAAuB,OAAO,KAAK;AAC9C,IAAI,SAAS,CAAC,GAAG;EACf,IAAI,SAAS;EACb,KAAK,IAAI,QAAQ,MAAO;IACtB,IAAI,QAAQ,IAAI;IAChB,IAAI,QAAQ,QAAQ,SAAS;EAC/B;EACA,OAAO;AACT;AACA,IAAI,SAAS,CAAC,IAAW,CAAC,C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