@yaks/browse 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 (271) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +324 -2
  3. package/_dist/app.d.ts +8 -0
  4. package/_dist/app.d.ts.map +1 -0
  5. package/_dist/cli.d.ts +16 -0
  6. package/_dist/cli.d.ts.map +1 -0
  7. package/_dist/hosting.d.ts +24 -0
  8. package/_dist/hosting.d.ts.map +1 -0
  9. package/_dist/mod.d.ts +7 -0
  10. package/_dist/mod.d.ts.map +1 -0
  11. package/_dist/types.d.ts +5 -0
  12. package/_dist/types.d.ts.map +1 -0
  13. package/_dist/url.d.ts +2 -0
  14. package/_dist/url.d.ts.map +1 -0
  15. package/app.js +10 -0
  16. package/app.js.map +1 -0
  17. package/app.ts +10 -0
  18. package/browser-links.js +22 -0
  19. package/browser-links.js.map +1 -0
  20. package/browser-links.ts +28 -0
  21. package/cli.js +172 -0
  22. package/cli.js.map +1 -0
  23. package/cli.ts +168 -0
  24. package/client.js +748 -0
  25. package/client.js.map +1 -0
  26. package/client.ts +734 -0
  27. package/clipboard.js +18 -0
  28. package/clipboard.js.map +1 -0
  29. package/clipboard.ts +17 -0
  30. package/commands.js +1157 -0
  31. package/commands.js.map +1 -0
  32. package/commands.ts +1108 -0
  33. package/components/Ansi.tsx +160 -0
  34. package/components/App.tsx +446 -0
  35. package/components/Canvas.tsx +625 -0
  36. package/components/Card.tsx +276 -0
  37. package/components/Chat.tsx +205 -0
  38. package/components/Configuration.tsx +218 -0
  39. package/components/Decision.tsx +49 -0
  40. package/components/Dot.tsx +52 -0
  41. package/components/Entity.tsx +609 -0
  42. package/components/Fault.tsx +43 -0
  43. package/components/Filter.tsx +103 -0
  44. package/components/Keybindings.tsx +100 -0
  45. package/components/Keys.tsx +67 -0
  46. package/components/Markdown.tsx +90 -0
  47. package/components/Navigation.tsx +161 -0
  48. package/components/New.tsx +490 -0
  49. package/components/Peek.tsx +168 -0
  50. package/components/Prio.tsx +20 -0
  51. package/components/Run.tsx +263 -0
  52. package/components/Search.tsx +280 -0
  53. package/components/Stamp.tsx +44 -0
  54. package/components/Status.tsx +514 -0
  55. package/components/Sync.tsx +173 -0
  56. package/components/Tile.tsx +50 -0
  57. package/components/answered.js +23 -0
  58. package/components/answered.js.map +1 -0
  59. package/components/answered.ts +25 -0
  60. package/components/comp.js +11 -0
  61. package/components/comp.js.map +1 -0
  62. package/components/comp.ts +10 -0
  63. package/components/drag.js +173 -0
  64. package/components/drag.js.map +1 -0
  65. package/components/drag.ts +198 -0
  66. package/components/fields.tsx +90 -0
  67. package/components/fixtures/README.md +10 -0
  68. package/components/fixtures/archetypes.json +3646 -0
  69. package/components/hits.js +63 -0
  70. package/components/hits.js.map +1 -0
  71. package/components/hits.ts +84 -0
  72. package/components/icons.tsx +177 -0
  73. package/components/inspect.tsx +331 -0
  74. package/components/mount.ts +79 -0
  75. package/components/nav.tsx +479 -0
  76. package/components/offers.js +26 -0
  77. package/components/offers.js.map +1 -0
  78. package/components/offers.ts +54 -0
  79. package/components/page.js +21 -0
  80. package/components/page.js.map +1 -0
  81. package/components/page.ts +18 -0
  82. package/components/read.js +5 -0
  83. package/components/read.js.map +1 -0
  84. package/components/read.ts +7 -0
  85. package/components/registry.js +285 -0
  86. package/components/registry.js.map +1 -0
  87. package/components/registry.ts +317 -0
  88. package/components/session_status.tsx +115 -0
  89. package/components/subscriptions.js +149 -0
  90. package/components/subscriptions.js.map +1 -0
  91. package/components/subscriptions.ts +161 -0
  92. package/components/title.tsx +21 -0
  93. package/components/useQuery.js +166 -0
  94. package/components/useQuery.js.map +1 -0
  95. package/components/useQuery.ts +211 -0
  96. package/components/views/Board.tsx +450 -0
  97. package/components/views/BoardTile.tsx +65 -0
  98. package/components/views/Dashboard.tsx +148 -0
  99. package/components/views/Debug.tsx +445 -0
  100. package/components/views/Dependency.tsx +51 -0
  101. package/components/views/Entry.tsx +500 -0
  102. package/components/views/Gist.tsx +28 -0
  103. package/components/views/Inline.tsx +54 -0
  104. package/components/views/Json.tsx +19 -0
  105. package/components/views/Layout.tsx +211 -0
  106. package/components/views/List.tsx +238 -0
  107. package/components/views/Md.tsx +43 -0
  108. package/components/views/Media.tsx +48 -0
  109. package/components/views/Memory.tsx +32 -0
  110. package/components/views/Relate.tsx +205 -0
  111. package/components/views/Search.tsx +42 -0
  112. package/components/views/Session.tsx +850 -0
  113. package/components/views/SessionManage.tsx +127 -0
  114. package/components/views/Show.tsx +758 -0
  115. package/components/views/Shown.tsx +72 -0
  116. package/components/views/Split.tsx +58 -0
  117. package/components/views/TaskTile.tsx +37 -0
  118. package/components/views/Title.tsx +105 -0
  119. package/components/views/Wake.tsx +77 -0
  120. package/components/views/Web.tsx +49 -0
  121. package/components/wells.js +30 -0
  122. package/components/wells.js.map +1 -0
  123. package/components/wells.ts +33 -0
  124. package/configuration.js +38 -0
  125. package/configuration.js.map +1 -0
  126. package/configuration.ts +41 -0
  127. package/decision_sync.js +88 -0
  128. package/decision_sync.js.map +1 -0
  129. package/decision_sync.ts +93 -0
  130. package/deno.json +1 -0
  131. package/domain-host.tsx +108 -0
  132. package/edge.js +193 -0
  133. package/edge.js.map +1 -0
  134. package/edge.ts +196 -0
  135. package/entry_log.js +241 -0
  136. package/entry_log.js.map +1 -0
  137. package/entry_log.ts +214 -0
  138. package/failure.js +22 -0
  139. package/failure.js.map +1 -0
  140. package/failure.ts +34 -0
  141. package/front.json +61 -0
  142. package/highlight.js +143 -0
  143. package/highlight.js.map +1 -0
  144. package/highlight.ts +149 -0
  145. package/history.js +68 -0
  146. package/history.js.map +1 -0
  147. package/history.ts +72 -0
  148. package/host_commands.js +107 -0
  149. package/host_commands.js.map +1 -0
  150. package/host_commands.ts +38 -0
  151. package/hosting.js +53 -0
  152. package/hosting.js.map +1 -0
  153. package/hosting.ts +72 -0
  154. package/idb.js +14 -0
  155. package/idb.js.map +1 -0
  156. package/idb.ts +15 -0
  157. package/index.js +232 -0
  158. package/index.js.map +1 -0
  159. package/index.ts +252 -0
  160. package/keybindings.js +136 -0
  161. package/keybindings.js.map +1 -0
  162. package/keybindings.ts +37 -0
  163. package/kit.js +103 -0
  164. package/kit.js.map +1 -0
  165. package/kit.ts +119 -0
  166. package/layout.js +254 -0
  167. package/layout.js.map +1 -0
  168. package/layout.ts +210 -0
  169. package/legacy_outbox.js +53 -0
  170. package/legacy_outbox.js.map +1 -0
  171. package/legacy_outbox.ts +63 -0
  172. package/live.js +2883 -0
  173. package/live.js.map +1 -0
  174. package/live.ts +3334 -0
  175. package/live_archetypes.js +92 -0
  176. package/live_archetypes.js.map +1 -0
  177. package/live_archetypes.ts +113 -0
  178. package/live_client.js +145 -0
  179. package/live_client.js.map +1 -0
  180. package/live_client.ts +120 -0
  181. package/main.tsx +5 -0
  182. package/mod.js +7 -0
  183. package/mod.js.map +1 -0
  184. package/mod.ts +7 -0
  185. package/mount.tsx +50 -0
  186. package/navigation.js +120 -0
  187. package/navigation.js.map +1 -0
  188. package/navigation.ts +152 -0
  189. package/near.js +83 -0
  190. package/near.js.map +1 -0
  191. package/near.ts +83 -0
  192. package/new.js +295 -0
  193. package/new.js.map +1 -0
  194. package/new.ts +361 -0
  195. package/outbox.js +112 -0
  196. package/outbox.js.map +1 -0
  197. package/outbox.ts +129 -0
  198. package/owner.js +39 -0
  199. package/owner.js.map +1 -0
  200. package/owner.ts +37 -0
  201. package/package.json +81 -4
  202. package/paste.js +157 -0
  203. package/paste.js.map +1 -0
  204. package/paste.ts +122 -0
  205. package/props.js +303 -0
  206. package/props.js.map +1 -0
  207. package/props.ts +358 -0
  208. package/providers.js +136 -0
  209. package/providers.js.map +1 -0
  210. package/providers.ts +194 -0
  211. package/query.js +987 -0
  212. package/query.js.map +1 -0
  213. package/query.ts +1113 -0
  214. package/remote.js +37 -0
  215. package/remote.js.map +1 -0
  216. package/remote.ts +46 -0
  217. package/resolver.js +149 -0
  218. package/resolver.js.map +1 -0
  219. package/resolver.ts +213 -0
  220. package/rfc2047.js +37 -0
  221. package/rfc2047.js.map +1 -0
  222. package/rfc2047.ts +40 -0
  223. package/row_holds.js +107 -0
  224. package/row_holds.js.map +1 -0
  225. package/row_holds.ts +93 -0
  226. package/served.ts +42 -0
  227. package/session_worktree.js +7 -0
  228. package/session_worktree.js.map +1 -0
  229. package/session_worktree.ts +16 -0
  230. package/sessions.js +57 -0
  231. package/sessions.js.map +1 -0
  232. package/sessions.ts +53 -0
  233. package/sha.js +161 -0
  234. package/sha.js.map +1 -0
  235. package/sha.ts +164 -0
  236. package/styles.css +2823 -0
  237. package/subs.js +36 -0
  238. package/subs.js.map +1 -0
  239. package/subs.ts +40 -0
  240. package/terminal-route.js +13 -0
  241. package/terminal-route.js.map +1 -0
  242. package/terminal-route.ts +17 -0
  243. package/terminal.js +251 -0
  244. package/terminal.js.map +1 -0
  245. package/terminal.ts +186 -0
  246. package/time.js +142 -0
  247. package/time.js.map +1 -0
  248. package/time.ts +133 -0
  249. package/title.js +25 -0
  250. package/title.js.map +1 -0
  251. package/title.ts +50 -0
  252. package/tui/doc.ts +6 -0
  253. package/tui/testing.ts +19 -0
  254. package/twin.js +11 -0
  255. package/twin.js.map +1 -0
  256. package/twin.ts +13 -0
  257. package/types.js +456 -0
  258. package/types.js.map +1 -0
  259. package/types.ts +1370 -0
  260. package/url.js +77 -0
  261. package/url.js.map +1 -0
  262. package/url.ts +85 -0
  263. package/verb.js +82 -0
  264. package/verb.js.map +1 -0
  265. package/verb.ts +137 -0
  266. package/warmth.js +41 -0
  267. package/warmth.js.map +1 -0
  268. package/warmth.ts +54 -0
  269. package/wire.js +86 -0
  270. package/wire.js.map +1 -0
  271. package/wire.ts +63 -0
@@ -0,0 +1,758 @@
1
+ /** @jsxRuntime automatic *//** @jsxImportSourceTypes npm:react@19.3.0 *//** @jsxImportSource npm:react@19.3.0 */
2
+ import { Decision } from '../Decision.tsx'
3
+ import { Keys } from '../Keys.tsx'
4
+ import { useReference, useRepoUrl, useRows } from '../subscriptions.ts'
5
+ /* @ts-types="npm:@types/react@19.3.0" */ import { type ReactNode, useEffect, useRef, useState } from 'npm:react@19.3.0'
6
+ import type { Bundle } from 'jsr:@yaks/graph@0.2.36'
7
+ import { type Ent, statusOf, vocab } from '../../types.ts'
8
+ import { statusChanges } from '../../client.ts'
9
+ import { FLOOR, textOf } from '../../twin.ts'
10
+ import {
11
+ base,
12
+ commentCount,
13
+ crewed,
14
+ edgeTotal,
15
+ ent,
16
+ gated,
17
+ mutate,
18
+ parents,
19
+ pending,
20
+ settled,
21
+ statuses,
22
+ useHold,
23
+ } from '../../live.ts'
24
+ import { actionsAt } from '../nav.tsx'
25
+ import { useBoardsOver, useQueryEids } from '../useQuery.ts'
26
+ import { block, Loading } from 'jsr:@yaks/ui@0.2.36'
27
+ import { Stamp } from '../Stamp.tsx'
28
+ import { Comments } from 'jsr:@yaks/kernel@0.2.36/Comments'
29
+ import { Dot } from '../Dot.tsx'
30
+ import { Prio } from '../Prio.tsx'
31
+ import { Markdown } from '../Markdown.tsx'
32
+ import { TitleEdit } from '../title.tsx'
33
+ import { Edit, useEdit } from 'jsr:@yaks/ux@0.2.36'
34
+ import { bundle } from '../registry.ts'
35
+ import { Relate } from './Relate.tsx'
36
+ import { up } from './Dependency.tsx'
37
+ import { Id } from './Inline.tsx'
38
+ import { decisionActions, Entity } from '../Entity.tsx'
39
+ import { Icon } from '../icons.tsx'
40
+ import { Chat } from '../Chat.tsx'
41
+
42
+ // The lego box. A SECTION is an internal view ('Full.Title', 'Meta',
43
+ // 'Full.Body', 'Dependencies', 'Runs', 'Comments' — registered in Entity.tsx
44
+ // like 'Id' and 'Dependency'): matched per entity through the registry door,
45
+ // and each renders NOTHING when its data is absent. Show serves the Full
46
+ // role for every entity — the one generic whole-entity view, just stacking
47
+ // the sections — so there is no Task-vs-Doc split to keep in sync: a bare
48
+ // doc simply has fewer sections with something to say, and a tool its name
49
+ // for a title and its description for a body. Specializing a section for an
50
+ // entity shape is a higher-scoring registry entry (a kind's own `Title`,
51
+ // `Body` or `Full.Body`), not an edit here.
52
+
53
+ let Frame = block('div', 'Show', {
54
+ Main: 'div',
55
+ Heading: 'h1',
56
+ Title: 'span',
57
+ Body: 'div',
58
+ Acceptance: 'section',
59
+ AcceptanceTitle: 'h2',
60
+ AcceptanceBody: 'div',
61
+ Claim: 'span',
62
+ Domain: 'span',
63
+ Meta: 'div',
64
+ More: 'div',
65
+ Proposal: 'span',
66
+ Deps: 'span',
67
+ Done: 's',
68
+ Blocked: 'span',
69
+ Superseded: 'span',
70
+ Mail: 'div',
71
+ MailKey: 'span',
72
+ MailVal: 'span',
73
+ MailFault: 'span',
74
+ Comments: 'span',
75
+ Runs: 'div',
76
+ Boards: 'div',
77
+ Tasks: 'div',
78
+ Similar: 'div',
79
+ Score: 'span',
80
+ })
81
+ let {
82
+ Main,
83
+ Heading,
84
+ Title,
85
+ Body: BodyEl,
86
+ Acceptance: AcceptanceEl,
87
+ AcceptanceTitle,
88
+ AcceptanceBody,
89
+ Claim,
90
+ Domain,
91
+ Meta: MetaEl,
92
+ Proposal,
93
+ Deps,
94
+ Done,
95
+ Blocked,
96
+ Superseded,
97
+ Mail: MailEl,
98
+ MailKey,
99
+ MailVal,
100
+ MailFault,
101
+ Comments: Talk,
102
+ Runs: RunsEl,
103
+ Boards: BoardsEl,
104
+ Tasks: TasksEl,
105
+ Similar: SimilarEl,
106
+ Score,
107
+ } = Frame
108
+
109
+ // The status pip IS the status control: a click anchors the vocabulary's
110
+ // enum editor on the dot — every status one press away, and a slip is a
111
+ // closed menu, not a written status (the old cycle wrote on every click).
112
+ // The registry supplies the picker exactly as an Edit would — its popout
113
+ // wrapper owns the anchor dance; only the face differs — a bare Dot
114
+ // (kept out of the editor's hands), so the heading and titlebar flex
115
+ // rows keep their dot untouched by Edit's value chrome.
116
+ export let Pip = ({ e }: { e: Ent }) => {
117
+ let anchor = useRef<HTMLElement>(null)
118
+ let edit = useEdit(e.eid, 'task', 'status')
119
+ let status = statusOf(e)
120
+ // The vocabulary declares task.status as derived; its shared enum picker
121
+ // translates a choice into completed/cancelled marks.
122
+ return (
123
+ <>
124
+ <Dot
125
+ elRef={anchor}
126
+ status={status}
127
+ gated={gated(e)}
128
+ live={crewed(e)}
129
+ className='Show_Pip'
130
+ onClick={() => edit.open ? edit.end() : edit.begin()}
131
+ />
132
+ <Edit.Control
133
+ e={{ entity: { eid: e.eid }, task: { status } }}
134
+ comp='task'
135
+ prop='status'
136
+ onChange={(b) =>
137
+ mutate(
138
+ ...statusChanges(e.eid, String((b.task as Ent['task'])?.status))
139
+ .filter((c) => vocab.comp(c.name)),
140
+ )}
141
+ anchor={anchor}
142
+ side='below'
143
+ />
144
+ </>
145
+ )
146
+ }
147
+
148
+ // The task fields, all through the registry door (@yaks/ux Edit):
149
+ // the faces stay the board grammar's chips — Prio badge, domain chip,
150
+ // project link — while the registry supplies each type's editor from the
151
+ // vocabulary (number box, domain well, project search).
152
+ let rank = (e: Bundle) => (
153
+ <Edit
154
+ e={e}
155
+ comp='filed'
156
+ prop='priority'
157
+ editable
158
+ name='priority'
159
+ show={(_, v) => <Prio p={v} className='Show_Chip' />}
160
+ />
161
+ )
162
+
163
+ let facet = (e: Bundle) => (
164
+ <Edit
165
+ e={e}
166
+ comp='filed'
167
+ prop='domain'
168
+ editable
169
+ name='domain'
170
+ show={(face) => (face ? <Domain>{face}</Domain> : null)}
171
+ />
172
+ )
173
+
174
+ // Who authored or edited this — the stamp supplies the sentence, while
175
+ // the prop registry supplies each actor's linked face.
176
+ let By = (
177
+ { e, comp }: { e: Ent; comp: 'created' | 'updated' },
178
+ ) =>
179
+ e[comp]?.by
180
+ ? (
181
+ <Edit
182
+ e={bundle(e)}
183
+ comp={comp}
184
+ prop='by'
185
+ show={(face, v) => {
186
+ if (!face || !v) return null
187
+ let a = ent(String(v))
188
+ return <Entity eid={a.eid} view='Meta.Author.Inline' />
189
+ }}
190
+ />
191
+ )
192
+ : null
193
+
194
+ // Whose plate: the assignee face is a LINK to the person (or the project
195
+ // standing in for its operator) — same grammar as the project. Claim (⚑, who's
196
+ // on it NOW) renders separately.
197
+ let plate = (e: Bundle) => (
198
+ <Edit
199
+ e={e}
200
+ comp='filed'
201
+ prop='assignee'
202
+ editable
203
+ handle
204
+ name='assignee'
205
+ show={(face, v) => {
206
+ if (!face || !v) return null
207
+ let a = ent(String(v))
208
+ return <Entity eid={a.eid} view='Meta.Assignee.Inline' />
209
+ }}
210
+ />
211
+ )
212
+
213
+ let home = (e: Bundle) => (
214
+ <Edit
215
+ e={e}
216
+ comp='filed'
217
+ prop='project'
218
+ editable
219
+ handle
220
+ name='project'
221
+ show={(face, v) => {
222
+ if (!face || !v) return null
223
+ let p = ent(String(v))
224
+ return <Entity eid={p.eid} view='Meta.Project.Inline' />
225
+ }}
226
+ />
227
+ )
228
+
229
+ let MailField = (
230
+ { name, children }: { name: string; children: ReactNode },
231
+ ) => (
232
+ <>
233
+ <MailKey>{name}</MailKey>
234
+ <MailVal>{children}</MailVal>
235
+ </>
236
+ )
237
+
238
+ // A letter says its envelope and receipt before its prose. Transport ids
239
+ // remain in the inspector; Full carries the fields used to read and trust it.
240
+ export let Mail = ({ e }: { e: Ent }) => {
241
+ let m = e.mail
242
+ if (!m) return null
243
+ let inbound = !!m.message_id
244
+ // The send outcome is the shared delivered/failed facet (D-14945), not a
245
+ // mail column: delivered = sent, failed = attempted-and-failed, neither =
246
+ // pending. `at` stays on the row as the arrival DATA.
247
+ let sent = e.delivered?.at
248
+ let fault = e.failed?.reason
249
+ return (
250
+ <MailEl>
251
+ <MailField name='from'>{m.from || '?'}</MailField>
252
+ {!inbound && e.deliver?.to && e.deliver.to != m.to &&
253
+ <MailField name='requested'>{e.deliver.to}</MailField>}
254
+ <MailField name='to'>{m.to || e.deliver?.to || ''}</MailField>
255
+ {inbound
256
+ ? (
257
+ <>
258
+ <MailField name='received'>
259
+ <Stamp at={m.at} />
260
+ </MailField>
261
+ <MailKey>verified</MailKey>
262
+ <MailVal mod={m.verified ? 'verified' : 'unverified'}>
263
+ {m.verified ? 'yes' : 'no'}
264
+ </MailVal>
265
+ </>
266
+ )
267
+ : sent
268
+ ? (
269
+ <MailField name='sent'>
270
+ <Stamp at={sent} />
271
+ </MailField>
272
+ )
273
+ : e.failed
274
+ ? (
275
+ <MailField name='attempted'>
276
+ <Stamp at={e.failed.at} />
277
+ </MailField>
278
+ )
279
+ : <MailField name='status'>pending</MailField>}
280
+ {fault && <MailFault>{fault}</MailFault>}
281
+ </MailEl>
282
+ )
283
+ }
284
+
285
+ // ---- the sections ----
286
+
287
+ // The body is markdown, drawn by @yaks/markdown, where markup a body wrote
288
+ // stays words (a body can come from anyone who mails the fleet); double-click opens its Edit, which swaps in the raw
289
+ // source, and the Edit closing on the blur that commits swaps the
290
+ // rendered view back. An empty body keeps a line of height to give the
291
+ // double-click somewhere to land.
292
+ export let Body = ({ e, mod }: { e: Ent; mod?: string }) => {
293
+ let repo = useRepoUrl(e)
294
+ let edit = useEdit(e.eid, 'doc', 'body', { value: e.doc?.body })
295
+ if (!e.doc) return null
296
+ // A body this client was never shipped is not an empty one: paint the
297
+ // wait and offer no editor until it lands (pending() is the ask).
298
+ if (pending(e)) return <BodyEl mod={mod}>…</BodyEl>
299
+ return edit.open
300
+ ? (
301
+ <BodyEl mod={mod}>
302
+ <Edit.Text e={bundle(e)} comp='doc' prop='body' multi />
303
+ </BodyEl>
304
+ )
305
+ : (
306
+ <Markdown
307
+ as={BodyEl}
308
+ mod={mod}
309
+ onDoubleClick={edit.begin}
310
+ text={e.doc?.body ?? ''}
311
+ repo={repo}
312
+ />
313
+ )
314
+ }
315
+
316
+ // Acceptance criteria are a second document-shaped facet, not part of the
317
+ // task narrative. Whole-entity views carry bodies, so the same Markdown/source
318
+ // editing seam as doc.body keeps the criteria legible and editable.
319
+ export let Acceptance = ({ e }: { e: Ent }) => {
320
+ let repo = useRepoUrl(e)
321
+ let edit = useEdit(e.eid, 'accept', 'body', { value: e.accept?.body })
322
+ if (!e.accept) return null
323
+ return (
324
+ <AcceptanceEl>
325
+ <AcceptanceTitle>Acceptance</AcceptanceTitle>
326
+ {pending(e, 'accept', 'body')
327
+ ? <AcceptanceBody>…</AcceptanceBody>
328
+ : edit.open
329
+ ? (
330
+ <AcceptanceBody>
331
+ <Edit.Text e={bundle(e)} comp='accept' prop='body' multi />
332
+ </AcceptanceBody>
333
+ )
334
+ : (
335
+ <Markdown
336
+ as={AcceptanceBody}
337
+ onDoubleClick={edit.begin}
338
+ text={e.accept.body ?? ''}
339
+ repo={repo}
340
+ />
341
+ )}
342
+ </AcceptanceEl>
343
+ )
344
+ }
345
+
346
+ // Every edge sentence an entity speaks, top-down: what holds it (reversed
347
+ // — 'contained by X', 'required by Y'), then what it holds — its contains
348
+ // children (ent() splits those out of refs into kids, so they'd
349
+ // otherwise only show as board tallies) and its requires/reads.
350
+ export let Dependencies = ({ e }: { e: Ent }) => {
351
+ // A hub's edges arrive BOUNDED (live.ts routeSub): the newest hundred at
352
+ // each end. Say what is missing rather than letting a page read as the whole
353
+ // neighbourhood — the same statement a windowed list owes (M-16612).
354
+ let total = edgeTotal(e.eid)
355
+ let shown = parents(e.eid).length + e.kids.length + e.refs.length
356
+ // The far end of each sentence is its own row: held here, beside the list.
357
+ useRows([
358
+ ...parents(e.eid).map((d) => d.parent),
359
+ ...e.kids.map((k) => k.eid),
360
+ ...e.refs.map((r) => r.child),
361
+ ])
362
+ let more = total == null ? 0 : total - shown
363
+ return (
364
+ <>
365
+ {parents(e.eid).map((d) => (
366
+ <Entity
367
+ key={d.parent + d.type}
368
+ eid={d.parent}
369
+ view='Dependency'
370
+ type={d.type}
371
+ label={up(d.type)}
372
+ />
373
+ ))}
374
+ {e.kids.map((k) => (
375
+ <Entity key={k.eid} eid={k.eid} view='Dependency' type='contains' />
376
+ ))}
377
+ {e.refs.map((r) => (
378
+ <Entity key={r.child} eid={r.child} view='Dependency' type={r.type} />
379
+ ))}
380
+ {more > 0 && <Frame.More>and {more} more</Frame.More>}
381
+ </>
382
+ )
383
+ }
384
+
385
+ // A comment's target is its first relationship sentence. Compose the
386
+ // ordinary edge rows too: comments remain entities and may carry edges of
387
+ // their own.
388
+ export let CommentDependencies = ({ e }: { e: Ent }) => (
389
+ <>
390
+ <Entity
391
+ eid={e.comment!.target}
392
+ view='Dependency'
393
+ type='comment'
394
+ label='on'
395
+ />
396
+ <Dependencies e={e} />
397
+ </>
398
+ )
399
+
400
+ // The entity's session: the claim's holder, so a task is the door to the
401
+ // agent working it.
402
+ export let Runs = ({ e }: { e: Ent }) =>
403
+ e.claim
404
+ ? (
405
+ <RunsEl>
406
+ <Entity eid={e.claim.session} view='List.Tile' />
407
+ </RunsEl>
408
+ )
409
+ : null
410
+
411
+ // The saved boards that watch this entity — a project's boards, found by
412
+ // boardsOver's query scan, since a query string is where a board names
413
+ // its subject.
414
+ export let Boards = ({ e }: { e: Ent }) => {
415
+ let ids = useBoardsOver(e.eid)
416
+ if (!ids.length) return null
417
+ return (
418
+ <BoardsEl>
419
+ {ids.map((b) => <Entity key={b} eid={b} view='List.Tile' />)}
420
+ </BoardsEl>
421
+ )
422
+ }
423
+
424
+ // The tasks homed here — every task filed under this project or one of its
425
+ // sub-projects. Open work only, board-ordered (status column, then rank): the
426
+ // project page is a working view; the full history lives on its boards.
427
+ export let Tasks = ({ e }: { e: Ent }) => {
428
+ let ids = useQueryEids(
429
+ vocab.prop('filed', 'project') && vocab.prop('task', 'status')
430
+ ? `.filed.project->${e.eid}&.task&.task.status=open,wip`
431
+ : '',
432
+ )
433
+ .map(ent)
434
+ .sort((a, b) =>
435
+ statuses.findIndex((s) => s == statusOf(a)) -
436
+ statuses.findIndex((s) => s == statusOf(b)) ||
437
+ (a.filed?.priority ?? 0) - (b.filed?.priority ?? 0)
438
+ )
439
+ if (!ids.length) return null
440
+ return (
441
+ <TasksEl>
442
+ {ids.map((t) => <Entity key={t.eid} eid={t.eid} view='List.Tile' />)}
443
+ </TasksEl>
444
+ )
445
+ }
446
+
447
+ // Semantic kin — vector-neighbor rank through the generic /query door:
448
+ // what the graph already says like this doc, above the twin floor,
449
+ // score-stamped. Vectors are derived data the server holds, so this
450
+ // section asks over HTTP per doc text; a box without the embedder
451
+ // (503), a dead server, or a bare doc all render nothing — never an
452
+ // error. Each row is the Dependency sentence — similarity read as a
453
+ // derived edge — with the cosine riding as a quiet stamp.
454
+ export let Similar = ({ e }: { e: Ent }) => {
455
+ let [kin, setKin] = useState<{ eid: string; score: number }[]>([])
456
+ let seq = useRef(0)
457
+ let text = textOf(e.doc?.title, e.doc?.body)
458
+ useEffect(() => {
459
+ let mine = ++seq.current // a newer text owns the list
460
+ let abort = new AbortController()
461
+ let got = (hits: { eid: string; score: number }[]) => {
462
+ if (!abort.signal.aborted && mine == seq.current) {
463
+ setKin(hits.filter((h) => h.eid != e.eid))
464
+ }
465
+ }
466
+ if (!text) return got([])
467
+ let q = encodeURIComponent(`.near=${e.eid}&.order=similar&.limit=5`)
468
+ fetch(`${base()}/query?q=${q}`, { signal: abort.signal })
469
+ .then((r) => (r.ok ? r.json() : []))
470
+ .then((rows) =>
471
+ got(
472
+ (rows as Record<string, unknown>[]).map((row) => {
473
+ let entity = row.entity as { eid?: string } | undefined
474
+ let rank = row.rank as { score?: number } | undefined
475
+ return {
476
+ eid: String(entity?.eid ?? ''),
477
+ score: Number(rank?.score ?? 0),
478
+ }
479
+ }).filter((h) => h.eid && h.score >= FLOOR),
480
+ ), () => got([]))
481
+ return () => abort.abort()
482
+ }, [text, e.eid])
483
+ // A neighbor can die between sweeps — the cache, not the vector
484
+ // table, says who still exists.
485
+ let live = kin.filter((h) => ent(h.eid).num)
486
+ if (!live.length) return null
487
+ return (
488
+ <SimilarEl>
489
+ {live.map((h) => (
490
+ <Entity
491
+ key={h.eid}
492
+ eid={h.eid}
493
+ view='Dependency'
494
+ type='similar'
495
+ note={<Score>{h.score.toFixed(2)}</Score>}
496
+ />
497
+ ))}
498
+ </SimilarEl>
499
+ )
500
+ }
501
+
502
+ // Each tally reads as a sentence, verb first — "requires ~2~ 1": two
503
+ // blockers already settled (struck — done or cancelled), one still open. A
504
+ // child that isn't a task can't be settled, so it counts as open. This is
505
+ // the CALM deps affordance (D-17094): open deps live here, never on the Dot
506
+ // — only the `blocked` facet reddens it (gated()).
507
+ let split = (kids: Ent[]): [number, number] => {
508
+ let done = kids.filter((k) => k.task && settled(statusOf(k))).length
509
+ return [kids.length - done, done]
510
+ }
511
+
512
+ let tallies = (e: Ent): [string, number, number][] => [
513
+ [
514
+ 'requires',
515
+ ...split(
516
+ e.refs.filter((r) => r.type == 'requires').map((r) => ent(r.child)),
517
+ ),
518
+ ],
519
+ ['contains', ...split(e.kids)],
520
+ [
521
+ 'reads',
522
+ ...split(
523
+ e.refs.filter((r) => r.type == 'reads').map((r) => ent(r.child)),
524
+ ),
525
+ ],
526
+ ]
527
+
528
+ let depIcons: Record<string, string> = {
529
+ requires: 'workflow',
530
+ contains: 'box',
531
+ reads: 'book-open',
532
+ }
533
+
534
+ let tally = (type: string, open: number, done: number) =>
535
+ `${type} ${
536
+ [
537
+ done && `${done} done`,
538
+ open && `${open}${done ? ' open' : ''}`,
539
+ ].filter(Boolean).join(' · ')
540
+ }`
541
+
542
+ let ProposalState = ({ e }: { e: Ent }) => {
543
+ if (!e.proposed) return null
544
+ let declined = e.decided?.verdict == 'declined'
545
+ let approved = !!e.decided && !declined
546
+ let cancelled = !e.decided && statusOf(e) == 'cancelled'
547
+ let state = approved
548
+ ? 'approved'
549
+ : declined
550
+ ? 'declined'
551
+ : cancelled
552
+ ? 'cancelled'
553
+ : 'proposed'
554
+ // Undecided, the icon IS the control: a click opens approve / decline.
555
+ let acts = decisionActions(e)
556
+ let open = acts.length ? actionsAt(acts) : undefined
557
+ return (
558
+ <Proposal
559
+ mod={state}
560
+ aria-label={state}
561
+ data-tip={open ? 'proposed — approve or decline' : state}
562
+ role={open && 'button'}
563
+ tabIndex={open && 0}
564
+ onClick={open}
565
+ >
566
+ <Icon
567
+ name={approved
568
+ ? 'stamp'
569
+ : declined || cancelled
570
+ ? 'circle-x'
571
+ : 'lightbulb'}
572
+ />
573
+ </Proposal>
574
+ )
575
+ }
576
+
577
+ let ClaimLine = ({ session }: { session: string }) => {
578
+ let claimant = useReference(session)
579
+ return (
580
+ <Claim>
581
+ ⚑ {claimant.value
582
+ ? <Entity eid={session} view='Meta.Claim.Inline' />
583
+ : claimant.state?.status == 'failed'
584
+ ? 'could not load'
585
+ : claimant.ready
586
+ ? 'unavailable'
587
+ : <Loading as='span' state='claim' />}
588
+ </Claim>
589
+ )
590
+ }
591
+
592
+ // The meta line — the union of the board row and Full's facts: prio · project
593
+ // · domain · edge tallies · comments · assignee · claim · age. Every field
594
+ // uses the same face everywhere and renders nothing when absent. In a card
595
+ // frame the titlebar carries title, pip, and id, so an empty line renders
596
+ // nothing; the document face and dense tile pass `id` to keep its chip here.
597
+ export let Meta = (
598
+ { e, id, before, children }: {
599
+ e: Ent
600
+ id?: boolean
601
+ before?: ReactNode
602
+ children?: ReactNode
603
+ },
604
+ ) => {
605
+ useHold(!!vocab.prop('comment', 'target') && { comments: e.eid })
606
+ let talk = commentCount(e.eid).value
607
+ let edges = tallies(e)
608
+ let hasEdges = edges.some(([, open, done]) => open > 0 || done > 0)
609
+ // What replaced this — the incoming supersedes edges. A superseded entity
610
+ // is marked on its own face (never hidden), pointing to the current one.
611
+ let replacedBy = parents(e.eid).filter((d) => d.type == 'supersedes')
612
+ if (
613
+ !id && !before && !children && !e.task && !e.proposed && !talk &&
614
+ !e.claim &&
615
+ !e.created?.at &&
616
+ !hasEdges && !replacedBy.length
617
+ ) {
618
+ return null
619
+ }
620
+ let task = e.task && bundle(e)
621
+ return (
622
+ <MetaEl>
623
+ {before}
624
+ <ProposalState e={e} />
625
+ {task && (
626
+ <>
627
+ {rank(task)}
628
+ {home(task)}
629
+ {facet(task)}
630
+ </>
631
+ )}
632
+ {edges.map(([t, open, done]) =>
633
+ (open > 0 || done > 0) && (
634
+ <Deps
635
+ key={t}
636
+ mod={t}
637
+ aria-label={tally(t, open, done)}
638
+ data-tip={tally(t, open, done)}
639
+ >
640
+ <Icon name={depIcons[t]} size={12} />
641
+ {done > 0 && <Done>{done}</Done>}
642
+ {open > 0 && <span>{open}</span>}
643
+ </Deps>
644
+ )
645
+ )}
646
+ {e.blocked && (
647
+ <Blocked data-tip='blocked on an external reason'>
648
+ <Icon name='circle-alert' />{' '}
649
+ <Edit
650
+ e={bundle(e)}
651
+ comp='blocked'
652
+ prop='on'
653
+ editable
654
+ name='blocked'
655
+ show={(face) => <>blocked{face ? ` — ${face}` : ''}</>}
656
+ />
657
+ </Blocked>
658
+ )}
659
+ {replacedBy.map((d) => (
660
+ <Superseded
661
+ key={d.parent}
662
+ data-tip='superseded — a newer entity replaced this'
663
+ >
664
+ <Icon name='history' /> superseded by{' '}
665
+ <Entity eid={d.parent} view='Inline' />
666
+ </Superseded>
667
+ ))}
668
+ {talk > 0 && (
669
+ <Talk
670
+ aria-label={`${talk} ${talk == 1 ? 'comment' : 'comments'}`}
671
+ data-tip={`${talk} ${talk == 1 ? 'comment' : 'comments'}`}
672
+ >
673
+ <Icon name='message-circle' size={12} />
674
+ {talk}
675
+ </Talk>
676
+ )}
677
+ {task && plate(task)}
678
+ {e.claim && <ClaimLine session={e.claim.session} />}
679
+ <Stamp e={e} by={(comp) => <By e={e} comp={comp} />} />
680
+ {id && <Id e={e} />}
681
+ {children}
682
+ </MetaEl>
683
+ )
684
+ }
685
+
686
+ // Comments already speaks eid — a thin adapter gives it the section
687
+ // signature so it registers like the rest.
688
+ export let Talkback = ({ e }: { e: Ent }) => <Comments eid={e.eid} />
689
+
690
+ // ---- the one generic Full view: stack the sections ----
691
+
692
+ // The section stack, walked by both faces — change the order here,
693
+ // every doc-carrying entity follows.
694
+ let stack = [
695
+ 'Acceptance',
696
+ 'Dependencies',
697
+ 'Relate',
698
+ 'Boards',
699
+ 'Tasks',
700
+ 'Runs',
701
+ 'Similar',
702
+ 'Comments',
703
+ ]
704
+
705
+ // A document's title on its Full page (`Full.Title`): its inline markdown,
706
+ // typed over in place on a double-click.
707
+ export let FullTitle = ({ e }: { e: Ent }) => <TitleEdit eid={e.eid} />
708
+
709
+ // The root Full face is the DOCUMENT: a real h1 owns the title at the
710
+ // column's measure — it wraps, never truncates — with the pip riding its
711
+ // first line and the meta chips in a quiet row beneath (id included; the
712
+ // App bar's compact title stays hidden until this h1 scrolls away — the
713
+ // view-timeline in styles.css). Its title and its body are the entity's own
714
+ // `Full.Title` and `Full.Body`: a document's typed over where they stand, and
715
+ // a kind's own wherever it registers one (a persona's body, its documents). A
716
+ // page that draws its own chat beside Full asks for none (`chat`).
717
+ export let Show = (
718
+ { e, talkback = true, chat = talkback }: {
719
+ e: Ent
720
+ talkback?: boolean
721
+ chat?: boolean
722
+ },
723
+ ) => (
724
+ <Frame>
725
+ <Main>
726
+ <Heading>
727
+ {e.task && <Pip e={e} />}
728
+ <Title>
729
+ <Entity eid={e.eid} view='Full.Title' />
730
+ </Title>
731
+ </Heading>
732
+ <Entity eid={e.eid} view='Meta' id />
733
+ <Entity eid={e.eid} view='Mail' />
734
+ <Decision e={e} />
735
+ <Keys e={e} />
736
+ <Entity eid={e.eid} view='Full.Body' />
737
+ {stack.filter((v) => talkback || v != 'Comments').map((v) => (
738
+ <Entity key={v} eid={e.eid} view={v} />
739
+ ))}
740
+ </Main>
741
+ {chat && <Chat e={e} />}
742
+ </Frame>
743
+ )
744
+
745
+ // The card face (Card.Full): the titlebar is the head — the meta line
746
+ // stands in.
747
+ export let CardFull = ({ e }: { e: Ent }) => (
748
+ <>
749
+ <Entity eid={e.eid} view='Meta' />
750
+ <Entity eid={e.eid} view='Mail' />
751
+ <Decision e={e} />
752
+ <Keys e={e} />
753
+ <Entity eid={e.eid} view='Full.Body' mod='bare' />
754
+ {stack.map((v) => <Entity key={v} eid={e.eid} view={v} />)}
755
+ </>
756
+ )
757
+
758
+ export { Relate }