@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.
- package/LICENSE +202 -0
- package/README.md +324 -2
- package/_dist/app.d.ts +8 -0
- package/_dist/app.d.ts.map +1 -0
- package/_dist/cli.d.ts +16 -0
- package/_dist/cli.d.ts.map +1 -0
- package/_dist/hosting.d.ts +24 -0
- package/_dist/hosting.d.ts.map +1 -0
- package/_dist/mod.d.ts +7 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/types.d.ts +5 -0
- package/_dist/types.d.ts.map +1 -0
- package/_dist/url.d.ts +2 -0
- package/_dist/url.d.ts.map +1 -0
- package/app.js +10 -0
- package/app.js.map +1 -0
- package/app.ts +10 -0
- package/browser-links.js +22 -0
- package/browser-links.js.map +1 -0
- package/browser-links.ts +28 -0
- package/cli.js +172 -0
- package/cli.js.map +1 -0
- package/cli.ts +168 -0
- package/client.js +748 -0
- package/client.js.map +1 -0
- package/client.ts +734 -0
- package/clipboard.js +18 -0
- package/clipboard.js.map +1 -0
- package/clipboard.ts +17 -0
- package/commands.js +1157 -0
- package/commands.js.map +1 -0
- package/commands.ts +1108 -0
- package/components/Ansi.tsx +160 -0
- package/components/App.tsx +446 -0
- package/components/Canvas.tsx +625 -0
- package/components/Card.tsx +276 -0
- package/components/Chat.tsx +205 -0
- package/components/Configuration.tsx +218 -0
- package/components/Decision.tsx +49 -0
- package/components/Dot.tsx +52 -0
- package/components/Entity.tsx +609 -0
- package/components/Fault.tsx +43 -0
- package/components/Filter.tsx +103 -0
- package/components/Keybindings.tsx +100 -0
- package/components/Keys.tsx +67 -0
- package/components/Markdown.tsx +90 -0
- package/components/Navigation.tsx +161 -0
- package/components/New.tsx +490 -0
- package/components/Peek.tsx +168 -0
- package/components/Prio.tsx +20 -0
- package/components/Run.tsx +263 -0
- package/components/Search.tsx +280 -0
- package/components/Stamp.tsx +44 -0
- package/components/Status.tsx +514 -0
- package/components/Sync.tsx +173 -0
- package/components/Tile.tsx +50 -0
- package/components/answered.js +23 -0
- package/components/answered.js.map +1 -0
- package/components/answered.ts +25 -0
- package/components/comp.js +11 -0
- package/components/comp.js.map +1 -0
- package/components/comp.ts +10 -0
- package/components/drag.js +173 -0
- package/components/drag.js.map +1 -0
- package/components/drag.ts +198 -0
- package/components/fields.tsx +90 -0
- package/components/fixtures/README.md +10 -0
- package/components/fixtures/archetypes.json +3646 -0
- package/components/hits.js +63 -0
- package/components/hits.js.map +1 -0
- package/components/hits.ts +84 -0
- package/components/icons.tsx +177 -0
- package/components/inspect.tsx +331 -0
- package/components/mount.ts +79 -0
- package/components/nav.tsx +479 -0
- package/components/offers.js +26 -0
- package/components/offers.js.map +1 -0
- package/components/offers.ts +54 -0
- package/components/page.js +21 -0
- package/components/page.js.map +1 -0
- package/components/page.ts +18 -0
- package/components/read.js +5 -0
- package/components/read.js.map +1 -0
- package/components/read.ts +7 -0
- package/components/registry.js +285 -0
- package/components/registry.js.map +1 -0
- package/components/registry.ts +317 -0
- package/components/session_status.tsx +115 -0
- package/components/subscriptions.js +149 -0
- package/components/subscriptions.js.map +1 -0
- package/components/subscriptions.ts +161 -0
- package/components/title.tsx +21 -0
- package/components/useQuery.js +166 -0
- package/components/useQuery.js.map +1 -0
- package/components/useQuery.ts +211 -0
- package/components/views/Board.tsx +450 -0
- package/components/views/BoardTile.tsx +65 -0
- package/components/views/Dashboard.tsx +148 -0
- package/components/views/Debug.tsx +445 -0
- package/components/views/Dependency.tsx +51 -0
- package/components/views/Entry.tsx +500 -0
- package/components/views/Gist.tsx +28 -0
- package/components/views/Inline.tsx +54 -0
- package/components/views/Json.tsx +19 -0
- package/components/views/Layout.tsx +211 -0
- package/components/views/List.tsx +238 -0
- package/components/views/Md.tsx +43 -0
- package/components/views/Media.tsx +48 -0
- package/components/views/Memory.tsx +32 -0
- package/components/views/Relate.tsx +205 -0
- package/components/views/Search.tsx +42 -0
- package/components/views/Session.tsx +850 -0
- package/components/views/SessionManage.tsx +127 -0
- package/components/views/Show.tsx +758 -0
- package/components/views/Shown.tsx +72 -0
- package/components/views/Split.tsx +58 -0
- package/components/views/TaskTile.tsx +37 -0
- package/components/views/Title.tsx +105 -0
- package/components/views/Wake.tsx +77 -0
- package/components/views/Web.tsx +49 -0
- package/components/wells.js +30 -0
- package/components/wells.js.map +1 -0
- package/components/wells.ts +33 -0
- package/configuration.js +38 -0
- package/configuration.js.map +1 -0
- package/configuration.ts +41 -0
- package/decision_sync.js +88 -0
- package/decision_sync.js.map +1 -0
- package/decision_sync.ts +93 -0
- package/deno.json +1 -0
- package/domain-host.tsx +108 -0
- package/edge.js +193 -0
- package/edge.js.map +1 -0
- package/edge.ts +196 -0
- package/entry_log.js +241 -0
- package/entry_log.js.map +1 -0
- package/entry_log.ts +214 -0
- package/failure.js +22 -0
- package/failure.js.map +1 -0
- package/failure.ts +34 -0
- package/front.json +61 -0
- package/highlight.js +143 -0
- package/highlight.js.map +1 -0
- package/highlight.ts +149 -0
- package/history.js +68 -0
- package/history.js.map +1 -0
- package/history.ts +72 -0
- package/host_commands.js +107 -0
- package/host_commands.js.map +1 -0
- package/host_commands.ts +38 -0
- package/hosting.js +53 -0
- package/hosting.js.map +1 -0
- package/hosting.ts +72 -0
- package/idb.js +14 -0
- package/idb.js.map +1 -0
- package/idb.ts +15 -0
- package/index.js +232 -0
- package/index.js.map +1 -0
- package/index.ts +252 -0
- package/keybindings.js +136 -0
- package/keybindings.js.map +1 -0
- package/keybindings.ts +37 -0
- package/kit.js +103 -0
- package/kit.js.map +1 -0
- package/kit.ts +119 -0
- package/layout.js +254 -0
- package/layout.js.map +1 -0
- package/layout.ts +210 -0
- package/legacy_outbox.js +53 -0
- package/legacy_outbox.js.map +1 -0
- package/legacy_outbox.ts +63 -0
- package/live.js +2883 -0
- package/live.js.map +1 -0
- package/live.ts +3334 -0
- package/live_archetypes.js +92 -0
- package/live_archetypes.js.map +1 -0
- package/live_archetypes.ts +113 -0
- package/live_client.js +145 -0
- package/live_client.js.map +1 -0
- package/live_client.ts +120 -0
- package/main.tsx +5 -0
- package/mod.js +7 -0
- package/mod.js.map +1 -0
- package/mod.ts +7 -0
- package/mount.tsx +50 -0
- package/navigation.js +120 -0
- package/navigation.js.map +1 -0
- package/navigation.ts +152 -0
- package/near.js +83 -0
- package/near.js.map +1 -0
- package/near.ts +83 -0
- package/new.js +295 -0
- package/new.js.map +1 -0
- package/new.ts +361 -0
- package/outbox.js +112 -0
- package/outbox.js.map +1 -0
- package/outbox.ts +129 -0
- package/owner.js +39 -0
- package/owner.js.map +1 -0
- package/owner.ts +37 -0
- package/package.json +81 -4
- package/paste.js +157 -0
- package/paste.js.map +1 -0
- package/paste.ts +122 -0
- package/props.js +303 -0
- package/props.js.map +1 -0
- package/props.ts +358 -0
- package/providers.js +136 -0
- package/providers.js.map +1 -0
- package/providers.ts +194 -0
- package/query.js +987 -0
- package/query.js.map +1 -0
- package/query.ts +1113 -0
- package/remote.js +37 -0
- package/remote.js.map +1 -0
- package/remote.ts +46 -0
- package/resolver.js +149 -0
- package/resolver.js.map +1 -0
- package/resolver.ts +213 -0
- package/rfc2047.js +37 -0
- package/rfc2047.js.map +1 -0
- package/rfc2047.ts +40 -0
- package/row_holds.js +107 -0
- package/row_holds.js.map +1 -0
- package/row_holds.ts +93 -0
- package/served.ts +42 -0
- package/session_worktree.js +7 -0
- package/session_worktree.js.map +1 -0
- package/session_worktree.ts +16 -0
- package/sessions.js +57 -0
- package/sessions.js.map +1 -0
- package/sessions.ts +53 -0
- package/sha.js +161 -0
- package/sha.js.map +1 -0
- package/sha.ts +164 -0
- package/styles.css +2823 -0
- package/subs.js +36 -0
- package/subs.js.map +1 -0
- package/subs.ts +40 -0
- package/terminal-route.js +13 -0
- package/terminal-route.js.map +1 -0
- package/terminal-route.ts +17 -0
- package/terminal.js +251 -0
- package/terminal.js.map +1 -0
- package/terminal.ts +186 -0
- package/time.js +142 -0
- package/time.js.map +1 -0
- package/time.ts +133 -0
- package/title.js +25 -0
- package/title.js.map +1 -0
- package/title.ts +50 -0
- package/tui/doc.ts +6 -0
- package/tui/testing.ts +19 -0
- package/twin.js +11 -0
- package/twin.js.map +1 -0
- package/twin.ts +13 -0
- package/types.js +456 -0
- package/types.js.map +1 -0
- package/types.ts +1370 -0
- package/url.js +77 -0
- package/url.js.map +1 -0
- package/url.ts +85 -0
- package/verb.js +82 -0
- package/verb.js.map +1 -0
- package/verb.ts +137 -0
- package/warmth.js +41 -0
- package/warmth.js.map +1 -0
- package/warmth.ts +54 -0
- package/wire.js +86 -0
- package/wire.js.map +1 -0
- package/wire.ts +63 -0
|
@@ -0,0 +1,850 @@
|
|
|
1
|
+
/** @jsxRuntime automatic *//** @jsxImportSource npm:react@19.3.0 *//** @jsxImportSourceTypes npm:react@19.3.0 *//* @ts-types="npm:@types/react@19.3.0" */ import {
|
|
2
|
+
type ReactNode,
|
|
3
|
+
useEffect,
|
|
4
|
+
useLayoutEffect,
|
|
5
|
+
useMemo,
|
|
6
|
+
useRef,
|
|
7
|
+
useState,
|
|
8
|
+
} from 'npm:react@19.3.0'
|
|
9
|
+
import { Time } from 'jsr:@yaks/ui@0.2.36'
|
|
10
|
+
/** @jsxImportSource react */
|
|
11
|
+
import { domainBundle } from '../../domain-host.tsx'
|
|
12
|
+
import { useJob, useModel, useReference, useRepoUrl } from '../subscriptions.ts'
|
|
13
|
+
import { awake, EID, type Ent, idOf, kilo, type LogRow } from '../../types.ts'
|
|
14
|
+
import { ent, findEid, mutate, retrySubscription, uuid } from '../../live.ts'
|
|
15
|
+
import { graphLog } from '../../entry_log.ts'
|
|
16
|
+
import { doing as running } from 'jsr:@yaks/tools@0.2.36/title'
|
|
17
|
+
import { slot, tileLink, type TileProps, tileTitle } from '../Tile.tsx'
|
|
18
|
+
import { linkProps, screenTarget } from '../nav.tsx'
|
|
19
|
+
import { Id } from './Inline.tsx'
|
|
20
|
+
import { block } from 'jsr:@yaks/ui@0.2.36'
|
|
21
|
+
import { ago, Stamp } from '../Stamp.tsx'
|
|
22
|
+
import { Dot } from '../Dot.tsx'
|
|
23
|
+
import { Twig } from 'jsr:@yaks/kernel@0.2.36/Comments'
|
|
24
|
+
import { branches } from 'jsr:@yaks/kernel@0.2.36/comments'
|
|
25
|
+
import { Entity, resolve } from '../Entity.tsx'
|
|
26
|
+
import { type Mention, mentions, parse } from 'jsr:@yaks/markdown@0.2.36'
|
|
27
|
+
import { commitUrl } from '../Markdown.tsx'
|
|
28
|
+
import { useCitedComments, useCommentsOn, useQueryResult } from '../useQuery.ts'
|
|
29
|
+
import { UrlVal } from 'jsr:@yaks/ux@0.2.36'
|
|
30
|
+
import { Ansi } from '../Ansi.tsx'
|
|
31
|
+
import { SessionDot, useSessionStanding } from '../session_status.tsx'
|
|
32
|
+
import { SessionInput, SessionRelated } from './SessionManage.tsx'
|
|
33
|
+
import {
|
|
34
|
+
EntryBody,
|
|
35
|
+
EntryLens,
|
|
36
|
+
type EntryLine,
|
|
37
|
+
EntrySummary,
|
|
38
|
+
entryVisible,
|
|
39
|
+
mergeTools,
|
|
40
|
+
} from './Entry.tsx'
|
|
41
|
+
import { entityUrl } from '../../url.ts'
|
|
42
|
+
|
|
43
|
+
// An agent session, watched — the console (W-3676 #5): a sticky slim bar
|
|
44
|
+
// (task, lifecycle summary, stop — server-owned columns riding
|
|
45
|
+
// the snapshot like any component, so the bar re-renders itself as the
|
|
46
|
+
// run moves), the log with the session's comments woven in by time, then
|
|
47
|
+
// the pinned composer (Comments.tsx), which is the way to talk TO the
|
|
48
|
+
// agent. The session never scrolls on its own: it takes its content's height,
|
|
49
|
+
// the frame a page boxes it in (its own page, a card, a chat's box) or the
|
|
50
|
+
// page around it scrolls, and the bar and composer stick to that scroller's
|
|
51
|
+
// edges while the session is in view.
|
|
52
|
+
//
|
|
53
|
+
// Every substrate normalizes to one renderer row: process-backed and
|
|
54
|
+
// graph-native Sessions alike subscribe to their ordered entry partition (a
|
|
55
|
+
// process run's JSONL is ingested into the same entries). The browser never
|
|
56
|
+
// learns a provider dialect, and there is no /logs file-poll (T-16798).
|
|
57
|
+
|
|
58
|
+
let Frame = block('div', 'Session', {
|
|
59
|
+
Head: 'div',
|
|
60
|
+
Summary: 'div',
|
|
61
|
+
Context: 'span',
|
|
62
|
+
Stop: 'button',
|
|
63
|
+
Body: 'div',
|
|
64
|
+
References: 'details',
|
|
65
|
+
ReferencesGist: 'summary',
|
|
66
|
+
ReferencesList: 'div',
|
|
67
|
+
Reference: 'div',
|
|
68
|
+
Facts: 'details',
|
|
69
|
+
Diagnostics: 'details',
|
|
70
|
+
Gist: 'summary',
|
|
71
|
+
Kv: 'div',
|
|
72
|
+
Key: 'span',
|
|
73
|
+
Val: 'span',
|
|
74
|
+
Think: 'div',
|
|
75
|
+
Fault: 'p',
|
|
76
|
+
EntryState: 'p',
|
|
77
|
+
Retry: 'button',
|
|
78
|
+
Log: 'div',
|
|
79
|
+
Earlier: 'button',
|
|
80
|
+
Line: 'div',
|
|
81
|
+
Content: 'div',
|
|
82
|
+
Seq: 'button',
|
|
83
|
+
When: 'time',
|
|
84
|
+
Err: 'pre',
|
|
85
|
+
Json: 'pre',
|
|
86
|
+
Unsent: 'div',
|
|
87
|
+
Foot: 'div',
|
|
88
|
+
})
|
|
89
|
+
let {
|
|
90
|
+
Head,
|
|
91
|
+
Summary,
|
|
92
|
+
Context,
|
|
93
|
+
Stop,
|
|
94
|
+
Body: Panel,
|
|
95
|
+
References,
|
|
96
|
+
ReferencesGist,
|
|
97
|
+
ReferencesList,
|
|
98
|
+
Reference,
|
|
99
|
+
Facts,
|
|
100
|
+
Diagnostics,
|
|
101
|
+
Gist,
|
|
102
|
+
Kv,
|
|
103
|
+
Key,
|
|
104
|
+
Val,
|
|
105
|
+
Think,
|
|
106
|
+
Fault,
|
|
107
|
+
EntryState,
|
|
108
|
+
Retry,
|
|
109
|
+
Log,
|
|
110
|
+
Earlier,
|
|
111
|
+
Line,
|
|
112
|
+
Content,
|
|
113
|
+
Seq,
|
|
114
|
+
When,
|
|
115
|
+
Err,
|
|
116
|
+
Json,
|
|
117
|
+
Unsent,
|
|
118
|
+
Foot,
|
|
119
|
+
} = Frame
|
|
120
|
+
|
|
121
|
+
type Entry = EntryLine
|
|
122
|
+
type Mentioned =
|
|
123
|
+
| { kind: 'entity'; id: string; eid?: string }
|
|
124
|
+
| { kind: 'link'; href: string }
|
|
125
|
+
|
|
126
|
+
// A run of same-tag sys frames is one fact told many times (the
|
|
127
|
+
// thinking-token stream grows an estimate frame by frame): keep the
|
|
128
|
+
// LAST of the run — its text is the current count, carried forward when
|
|
129
|
+
// the newest frame has none — and remember how many frames it speaks
|
|
130
|
+
// for. Distinct texts (a hook start, a task notification) never
|
|
131
|
+
// squeeze: each is its own news.
|
|
132
|
+
let squeeze = (entries: Entry[]) => {
|
|
133
|
+
let out: Entry[] = []
|
|
134
|
+
for (let x of entries) {
|
|
135
|
+
let p = out.at(-1)
|
|
136
|
+
if (
|
|
137
|
+
x.row?.kind == 'sys' && p?.row?.kind == 'sys' &&
|
|
138
|
+
x.row.tag == p.row.tag &&
|
|
139
|
+
(x.row.tag == 'thinking' || x.row.text == p.row.text)
|
|
140
|
+
) {
|
|
141
|
+
out[out.length - 1] = {
|
|
142
|
+
...x,
|
|
143
|
+
row: x.row.text ? x.row : p.row,
|
|
144
|
+
n: (p.n ?? 1) + 1,
|
|
145
|
+
}
|
|
146
|
+
} else out.push(x)
|
|
147
|
+
}
|
|
148
|
+
return out
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// ISO in the db; a local clock is what a human reads.
|
|
152
|
+
let when = (at?: string | null) => <Time at={at} />
|
|
153
|
+
|
|
154
|
+
let lineLabel = (text: string) => {
|
|
155
|
+
let n = text.replace(/\n$/, '').split('\n').length
|
|
156
|
+
return `${n} ${n == 1 ? 'line' : 'lines'}`
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Weave the heard comments into the log by time: only says wear a
|
|
160
|
+
// clock, so each line carries the last one seen forward, and a comment
|
|
161
|
+
// slots in after everything said before it. Comments the log can't
|
|
162
|
+
// place yet (no timestamped line reached) flush before the first one
|
|
163
|
+
// that can; leftovers land at the end.
|
|
164
|
+
let weave = (rows: Entry[], cs: Ent[]) => {
|
|
165
|
+
let out: (Entry | Ent)[] = []
|
|
166
|
+
let i = 0, t = ''
|
|
167
|
+
for (let x of rows) {
|
|
168
|
+
if (x.row?.kind == 'say' && x.row.at) t = x.row.at
|
|
169
|
+
while (i < cs.length && t && String(cs[i].created?.at ?? '') <= t) {
|
|
170
|
+
out.push(cs[i++])
|
|
171
|
+
}
|
|
172
|
+
out.push(x)
|
|
173
|
+
}
|
|
174
|
+
return [...out, ...cs.slice(i)]
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
type MentionLine = Partial<Entry>
|
|
178
|
+
let mentionLine = (x: MentionLine | Ent): x is MentionLine => 'row' in x
|
|
179
|
+
|
|
180
|
+
// Ent carries an open index signature now (types.ts, D-18663 seam 2), so a bare
|
|
181
|
+
// `'seq' in x` no longer narrows a woven comment (an Ent) away from a log line.
|
|
182
|
+
// An explicit predicate keeps the transcript's two row kinds apart.
|
|
183
|
+
let logLine = (x: Entry | Ent): x is Entry => 'seq' in x
|
|
184
|
+
|
|
185
|
+
let mentionText = (x: MentionLine | Ent) => {
|
|
186
|
+
if (mentionLine(x)) return x.row?.kind == 'say' ? [x.row.text] : []
|
|
187
|
+
return [x.doc?.body ?? '']
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// A hex word quoted in code is a commit: a link to it in its project's
|
|
191
|
+
// repository, or nothing where the project names none. A whole SHA is the
|
|
192
|
+
// commit's own entity.
|
|
193
|
+
let commit = (m: Mention, repo?: string): Mention[] => {
|
|
194
|
+
if (m.kind != 'entity' || !/^[0-9a-f]+$/i.test(m.id) || EID.test(m.id)) {
|
|
195
|
+
return [m]
|
|
196
|
+
}
|
|
197
|
+
let href = commitUrl(repo, m.id)
|
|
198
|
+
return href ? [{ kind: 'link', href }] : []
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// The SCAN — the expensive half: mentions parses every text in the thread.
|
|
202
|
+
// On a large log this is milliseconds, so the render path memoizes it (keyed on
|
|
203
|
+
// mentionSig) and never runs it per render.
|
|
204
|
+
export let threadMentions = (
|
|
205
|
+
thread: (MentionLine | Ent)[],
|
|
206
|
+
repo?: string,
|
|
207
|
+
): Mention[] =>
|
|
208
|
+
thread.flatMap(mentionText).flatMap((text) =>
|
|
209
|
+
mentions(parse(text)).flatMap((m) => commit(m, repo))
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
// Resolve entity ids to eids and dedupe — the CHEAP half over the already-parsed
|
|
213
|
+
// mentions, so it stays per render and an eid that loads in late still links.
|
|
214
|
+
// The first mention wins its place; entity spellings dedupe by the entity they
|
|
215
|
+
// resolve to, so a labeled link and a later bare id still make one row.
|
|
216
|
+
export let resolveMentions = (raw: Mention[]): Mentioned[] => {
|
|
217
|
+
let out: Mentioned[] = []
|
|
218
|
+
let seen = new Set<string>()
|
|
219
|
+
for (let mention of raw) {
|
|
220
|
+
let item: Mentioned
|
|
221
|
+
if (mention.kind == 'entity') {
|
|
222
|
+
let eid = findEid(mention.id)
|
|
223
|
+
item = { kind: 'entity', id: mention.id, ...(eid ? { eid } : {}) }
|
|
224
|
+
} else item = mention
|
|
225
|
+
let key = item.kind == 'entity'
|
|
226
|
+
? `entity:${item.eid ?? item.id}`
|
|
227
|
+
: `link:${item.href}`
|
|
228
|
+
if (!seen.has(key)) {
|
|
229
|
+
seen.add(key)
|
|
230
|
+
out.push(item)
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return out
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Parse then resolve. Non-render callers use this directly; the render path
|
|
237
|
+
// splits the two so it can memoize the scan (threadMentions) alone.
|
|
238
|
+
export let sessionMentions = (
|
|
239
|
+
thread: (MentionLine | Ent)[],
|
|
240
|
+
repo?: string,
|
|
241
|
+
): Mentioned[] => resolveMentions(threadMentions(thread, repo))
|
|
242
|
+
|
|
243
|
+
// A cheap content signature for the mention scan: everything that changes the
|
|
244
|
+
// parsed mentions, read as ids/seqs/stamps — no markdown parse, no walk of the
|
|
245
|
+
// thread text — so useMemo reruns the scan once per content change, never per
|
|
246
|
+
// render. Log rows are append-only (seq + count cover growth);
|
|
247
|
+
// a heard comment set is keyed by its size and newest edit (add/remove/edit/
|
|
248
|
+
// heard-flip all move one of the two).
|
|
249
|
+
export let mentionSig = (a: {
|
|
250
|
+
count: number
|
|
251
|
+
seq: number
|
|
252
|
+
heard: Ent[]
|
|
253
|
+
repo?: string
|
|
254
|
+
}): string =>
|
|
255
|
+
[
|
|
256
|
+
a.count,
|
|
257
|
+
a.seq,
|
|
258
|
+
a.heard.length,
|
|
259
|
+
a.heard.reduce((m, c) => {
|
|
260
|
+
let t = String(c.updated?.at ?? c.created?.at ?? '')
|
|
261
|
+
return t > m ? t : m
|
|
262
|
+
}, ''),
|
|
263
|
+
a.repo ?? '',
|
|
264
|
+
].join('|')
|
|
265
|
+
|
|
266
|
+
export let SessionReferences = ({ items }: { items: Mentioned[] }) => {
|
|
267
|
+
let [open, setOpen] = useState(
|
|
268
|
+
() => !globalThis.matchMedia?.('(max-width: 700px)').matches,
|
|
269
|
+
)
|
|
270
|
+
if (!items.length) return null
|
|
271
|
+
return (
|
|
272
|
+
<References
|
|
273
|
+
open={open}
|
|
274
|
+
onToggle={(ev: Event) =>
|
|
275
|
+
setOpen((ev.currentTarget as HTMLDetailsElement).open)}
|
|
276
|
+
>
|
|
277
|
+
<ReferencesGist>references · {items.length}</ReferencesGist>
|
|
278
|
+
<ReferencesList>
|
|
279
|
+
{items.map((item) => (
|
|
280
|
+
<Reference
|
|
281
|
+
key={item.kind == 'entity' ? item.eid ?? item.id : item.href}
|
|
282
|
+
>
|
|
283
|
+
{item.kind == 'entity'
|
|
284
|
+
? item.eid
|
|
285
|
+
? <Entity eid={item.eid} view='Inline' />
|
|
286
|
+
: (
|
|
287
|
+
<a href={entityUrl(item.id)} data-ref={item.id}>
|
|
288
|
+
{item.id}
|
|
289
|
+
</a>
|
|
290
|
+
)
|
|
291
|
+
: UrlVal(item.href)}
|
|
292
|
+
</Reference>
|
|
293
|
+
))}
|
|
294
|
+
</ReferencesList>
|
|
295
|
+
</References>
|
|
296
|
+
)
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// The tail thinks out loud: provider progress and unresolved graph work win;
|
|
300
|
+
// the newest durable row remains the fallback for process-backed sessions.
|
|
301
|
+
export let doing = (r?: LogRow, turn?: string | null, starting = false) =>
|
|
302
|
+
r?.kind == 'reason'
|
|
303
|
+
? 'thinking…'
|
|
304
|
+
: r?.kind == 'sys' && r.tag == 'thinking'
|
|
305
|
+
? (r.text ? `thinking · ${r.text}` : 'thinking…')
|
|
306
|
+
: r?.kind == 'sys' && r.tag == 'generation'
|
|
307
|
+
? 'waiting for model…'
|
|
308
|
+
: r?.kind == 'exec' && r.exit == null && !r.status
|
|
309
|
+
? 'running command…'
|
|
310
|
+
: r?.kind == 'tool' && r.ok == null
|
|
311
|
+
? running(r.name)
|
|
312
|
+
: turn == 'idle' || r?.kind == 'turn' ||
|
|
313
|
+
(r?.kind == 'say' && r.role == 'agent')
|
|
314
|
+
? 'waiting for request…'
|
|
315
|
+
: r?.kind == 'say' && r.role == 'user'
|
|
316
|
+
? 'waiting for response…'
|
|
317
|
+
: starting
|
|
318
|
+
? 'starting…'
|
|
319
|
+
: 'working…'
|
|
320
|
+
|
|
321
|
+
// A named fact, present only when there IS one — absence says enough.
|
|
322
|
+
let Fact = ({ k, v }: { k: string; v?: ReactNode }) =>
|
|
323
|
+
v
|
|
324
|
+
? (
|
|
325
|
+
<>
|
|
326
|
+
<Key>{k}</Key>
|
|
327
|
+
<Val>{v}</Val>
|
|
328
|
+
</>
|
|
329
|
+
)
|
|
330
|
+
: null
|
|
331
|
+
|
|
332
|
+
// Task, role and lifecycle are one summary lane. The timestamp sits below
|
|
333
|
+
// what the session serves instead of reserving a header column of its own.
|
|
334
|
+
export let SessionSummary = ({ e, gist }: { e: Ent; gist: string }) => {
|
|
335
|
+
let s = e.session!
|
|
336
|
+
let job = useJob(e)
|
|
337
|
+
return (
|
|
338
|
+
<Summary>
|
|
339
|
+
{job && <Entity eid={job} view='Inline' />}
|
|
340
|
+
<Facts>
|
|
341
|
+
<Gist>{gist}</Gist>
|
|
342
|
+
<Kv>
|
|
343
|
+
<Fact k='id' v={s.id} />
|
|
344
|
+
<Fact k='cwd' v={e.process?.cwd} />
|
|
345
|
+
<Fact k='pid' v={e.process?.pid ? `${e.process.pid}` : null} />
|
|
346
|
+
<Fact k='started' v={when(e.created?.at)} />
|
|
347
|
+
</Kv>
|
|
348
|
+
<Stamp e={e} />
|
|
349
|
+
</Facts>
|
|
350
|
+
</Summary>
|
|
351
|
+
)
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
export let SessionContext = ({ tokens }: { tokens?: number }) =>
|
|
355
|
+
tokens ? <Context>{kilo(tokens)} context</Context> : null
|
|
356
|
+
|
|
357
|
+
export let SessionDiagnostics = ({
|
|
358
|
+
stderr,
|
|
359
|
+
exit,
|
|
360
|
+
open,
|
|
361
|
+
}: {
|
|
362
|
+
stderr?: string
|
|
363
|
+
exit?: number | null
|
|
364
|
+
open?: boolean
|
|
365
|
+
}) =>
|
|
366
|
+
stderr
|
|
367
|
+
? (
|
|
368
|
+
<Diagnostics open={open}>
|
|
369
|
+
<Gist>diagnostics · {lineLabel(stderr)}</Gist>
|
|
370
|
+
<Err mod={exit != null && exit != 0 && 'fail'}>
|
|
371
|
+
<Ansi text={stderr} />
|
|
372
|
+
</Err>
|
|
373
|
+
</Diagnostics>
|
|
374
|
+
)
|
|
375
|
+
: null
|
|
376
|
+
|
|
377
|
+
// The raw event, pretty when it parses — the whole line, nothing elided.
|
|
378
|
+
// (ui's `pretty` is the locale timestamp; the suffix keeps them apart.)
|
|
379
|
+
let prettyJson = (line: string) => {
|
|
380
|
+
try {
|
|
381
|
+
return JSON.stringify(JSON.parse(line), null, 2)
|
|
382
|
+
} catch {
|
|
383
|
+
return line
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
// Process logs have only bytes, while graph-native entries have an eid and
|
|
388
|
+
// therefore take every face through the renderer registry.
|
|
389
|
+
export let SessionEntry = (
|
|
390
|
+
{ x, repo, open, onOpen }: {
|
|
391
|
+
x: Entry
|
|
392
|
+
repo?: string
|
|
393
|
+
open?: boolean
|
|
394
|
+
onOpen?: () => void
|
|
395
|
+
},
|
|
396
|
+
) => {
|
|
397
|
+
if (!x.eid) return <EntryBody x={x} repo={repo} />
|
|
398
|
+
let e = ent(x.eid)
|
|
399
|
+
let face = resolve(e, 'Entry.Summary')
|
|
400
|
+
return x.row && (face.Render == EntrySummary || face.view == 'JSON')
|
|
401
|
+
? <EntryBody x={x} repo={repo} />
|
|
402
|
+
: <face.Render e={e} open={open} onOpen={onOpen} />
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
export let SessionTime = ({ x }: { x: Entry }) => {
|
|
406
|
+
let at = x.row?.at
|
|
407
|
+
if (!at) return null
|
|
408
|
+
return (
|
|
409
|
+
<When {...(x.eid ? linkProps(ent(x.eid)) : {})}>
|
|
410
|
+
<Time at={at} />
|
|
411
|
+
</When>
|
|
412
|
+
)
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
// Two independent reveals, both in place: the `…` control grows the entry's
|
|
416
|
+
// own content where it sits (full command, full output) so nothing above it
|
|
417
|
+
// moves; the seq gutter opens the raw event beneath it for inspection. A row is
|
|
418
|
+
// "open" (its seq pinned visible) while either is showing.
|
|
419
|
+
let Row = ({ x, repo }: { x: Entry; repo?: string }) => {
|
|
420
|
+
let [full, setFull] = useState(false)
|
|
421
|
+
let [raw, setRaw] = useState(false)
|
|
422
|
+
return (
|
|
423
|
+
<Line mod={(full || raw) && 'open'}>
|
|
424
|
+
<Seq
|
|
425
|
+
type='button'
|
|
426
|
+
aria-label={`${raw ? 'hide' : 'show'} event ${x.seq} details`}
|
|
427
|
+
data-tip={raw ? undefined : 'the raw event'}
|
|
428
|
+
onClick={() => setRaw(!raw)}
|
|
429
|
+
>
|
|
430
|
+
{x.seq}
|
|
431
|
+
</Seq>
|
|
432
|
+
<Content>
|
|
433
|
+
<SessionTime x={x} />
|
|
434
|
+
<SessionEntry
|
|
435
|
+
x={x}
|
|
436
|
+
repo={repo}
|
|
437
|
+
open={full}
|
|
438
|
+
onOpen={() => setFull(!full)}
|
|
439
|
+
/>
|
|
440
|
+
</Content>
|
|
441
|
+
{raw &&
|
|
442
|
+
(x.eid ? <EntryLens eid={x.eid} /> : <Json>{prettyJson(x.line)}</Json>)}
|
|
443
|
+
</Line>
|
|
444
|
+
)
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
// What scrolls the session: never the session itself, but the frame a page
|
|
448
|
+
// boxes it in or the page around it. Null in the TUI's fake DOM (no
|
|
449
|
+
// parentElement), which switches the feature off there.
|
|
450
|
+
let scrollerOf = (n: HTMLElement | null) => {
|
|
451
|
+
// No getComputedStyle off the browser (TUI fake DOM, linkedom mounts): there
|
|
452
|
+
// is no scroller to find, so tail-pin/auto-grow simply switch off.
|
|
453
|
+
if (typeof getComputedStyle != 'function') return null
|
|
454
|
+
for (let s = n; s; s = s.parentElement) {
|
|
455
|
+
if (/auto|scroll/.test(getComputedStyle(s).overflowY)) return s
|
|
456
|
+
}
|
|
457
|
+
return null
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
// How far the session's end (its composer, or its last row) sits below what
|
|
461
|
+
// its scroller shows: at most 0 while the reader can see it, and null once it
|
|
462
|
+
// has scrolled away above.
|
|
463
|
+
let below = (s: HTMLElement, session: HTMLElement) => {
|
|
464
|
+
let end = session.getBoundingClientRect().bottom
|
|
465
|
+
let top = s.getBoundingClientRect().top + s.clientTop
|
|
466
|
+
return end > top ? end - (top + s.clientHeight) : null
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
// The transcript loads from its tail in pages. This window caps rendering
|
|
470
|
+
// while a page is held, and grows as the reader asks for older entries.
|
|
471
|
+
// Distance from the bottom anchors the view across a prepend.
|
|
472
|
+
//
|
|
473
|
+
// Follow the tail: while the reader can see the session's end, each new log
|
|
474
|
+
// row brings it back into view and the window slides (bounded); scroll up and
|
|
475
|
+
// it stays put — and a new tail row then widens the window instead of letting
|
|
476
|
+
// the start advance and unmount the row being read. Stickiness is sampled on
|
|
477
|
+
// scroll events (before new rows land — right after a render the end has
|
|
478
|
+
// already moved and measuring would always say "not at end"). The
|
|
479
|
+
// programmatic pin fires a scroll event too, re-arming itself.
|
|
480
|
+
//
|
|
481
|
+
// A session framed alone (its own page, a card, a chat's box) opens at its
|
|
482
|
+
// tail and loads older rows as the reader nears its top. One drawn among a
|
|
483
|
+
// page's other parts leaves the page where the reader put it: it follows its
|
|
484
|
+
// tail only once the reader has scrolled its end into view, and older rows
|
|
485
|
+
// come on a press.
|
|
486
|
+
//
|
|
487
|
+
// `enabled` is false in the TUI (no real scroller / getComputedStyle): there
|
|
488
|
+
// the whole log renders as before, since the terminal owns its own scrollback.
|
|
489
|
+
let WINDOW = 200
|
|
490
|
+
let useTranscript = (
|
|
491
|
+
total: number,
|
|
492
|
+
tail: string | number,
|
|
493
|
+
enabled: boolean,
|
|
494
|
+
session: string,
|
|
495
|
+
more: boolean,
|
|
496
|
+
pending: boolean,
|
|
497
|
+
loaded: number,
|
|
498
|
+
load: () => void,
|
|
499
|
+
) => {
|
|
500
|
+
let root = useRef<HTMLDivElement>(null)
|
|
501
|
+
// Find the host's scroll container while the transcript is still empty.
|
|
502
|
+
// Re-reading computed style after every appended tail forces the browser
|
|
503
|
+
// to lay out the whole transcript just to rediscover the same ancestor.
|
|
504
|
+
let scroller = useRef<HTMLElement | null | undefined>(undefined)
|
|
505
|
+
// Whether the scroller holds the session alone, and whether the reader can
|
|
506
|
+
// see its end: a session framed alone starts there.
|
|
507
|
+
let alone = useRef(false)
|
|
508
|
+
let stuck = useRef(false)
|
|
509
|
+
let scroll = () => {
|
|
510
|
+
if (scroller.current === undefined) {
|
|
511
|
+
let parent = root.current?.parentElement ?? null
|
|
512
|
+
scroller.current = scrollerOf(parent)
|
|
513
|
+
alone.current = stuck.current = !!parent && scroller.current == parent
|
|
514
|
+
}
|
|
515
|
+
return scroller.current
|
|
516
|
+
}
|
|
517
|
+
let [shown, setShown] = useState(WINDOW)
|
|
518
|
+
let anchor = useRef<number | null>(null)
|
|
519
|
+
let start = enabled ? Math.max(0, total - shown) : 0
|
|
520
|
+
let page = useRef({ start, more, pending, load })
|
|
521
|
+
page.current = { start, more, pending, load }
|
|
522
|
+
// A new session starts back at its own tail.
|
|
523
|
+
useEffect(() => setShown(WINDOW), [session])
|
|
524
|
+
|
|
525
|
+
// Reveal older rows, holding the reader's place: distance from the bottom is
|
|
526
|
+
// invariant across a prepend, so restoring it after the grow keeps the view.
|
|
527
|
+
let older = () => {
|
|
528
|
+
let { start, more, pending, load } = page.current
|
|
529
|
+
if (anchor.current != null || pending) return
|
|
530
|
+
if (!start && !more) return
|
|
531
|
+
let s = scroll()
|
|
532
|
+
anchor.current = s ? s.scrollHeight - s.scrollTop : 0
|
|
533
|
+
setShown((n) => n + WINDOW)
|
|
534
|
+
if (!start) load()
|
|
535
|
+
}
|
|
536
|
+
useLayoutEffect(() => {
|
|
537
|
+
if (anchor.current == null || pending) return
|
|
538
|
+
let s = scroll()
|
|
539
|
+
if (s) s.scrollTop = s.scrollHeight - anchor.current
|
|
540
|
+
anchor.current = null
|
|
541
|
+
}, [shown, loaded, pending])
|
|
542
|
+
|
|
543
|
+
// One scroll listener samples stickiness and auto-grows near the top.
|
|
544
|
+
let startRef = useRef(start)
|
|
545
|
+
startRef.current = start
|
|
546
|
+
useEffect(() => {
|
|
547
|
+
let s = scroll()
|
|
548
|
+
if (!s) return
|
|
549
|
+
let sample = () => {
|
|
550
|
+
let gap = below(s, root.current!)
|
|
551
|
+
// within a scrollbar-rounding of the end still counts as AT it
|
|
552
|
+
stuck.current = gap != null && gap <= 4
|
|
553
|
+
if (
|
|
554
|
+
alone.current && (startRef.current > 0 || page.current.more) &&
|
|
555
|
+
s.scrollTop < 400
|
|
556
|
+
) older()
|
|
557
|
+
}
|
|
558
|
+
s.addEventListener('scroll', sample)
|
|
559
|
+
return () => s.removeEventListener('scroll', sample)
|
|
560
|
+
}, [])
|
|
561
|
+
|
|
562
|
+
// A new tail row: when the reader has scrolled up, widen the window by the
|
|
563
|
+
// delta so `start` holds and no top row unmounts (in a layout effect, so the
|
|
564
|
+
// corrected window is committed before paint — no flash). While stuck, let it
|
|
565
|
+
// slide; the pin below keeps the bottom in view.
|
|
566
|
+
let seen = useRef({ total, tail })
|
|
567
|
+
useLayoutEffect(() => {
|
|
568
|
+
let d = total - seen.current.total
|
|
569
|
+
let newTail = tail != seen.current.tail
|
|
570
|
+
seen.current = { total, tail }
|
|
571
|
+
if (d > 0 && newTail && !stuck.current) setShown((n) => n + d)
|
|
572
|
+
}, [total, tail])
|
|
573
|
+
|
|
574
|
+
// Bring the end back into view while stuck (the tail moved).
|
|
575
|
+
useLayoutEffect(() => {
|
|
576
|
+
let s = scroll()
|
|
577
|
+
if (!s || !stuck.current) return
|
|
578
|
+
let gap = below(s, root.current!)
|
|
579
|
+
if (gap != null && gap > 0) s.scrollTop += gap
|
|
580
|
+
}, [tail])
|
|
581
|
+
|
|
582
|
+
return { root, start, older }
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
/** Whether a session is drawn inside another page (a document's chat, a
|
|
586
|
+
* persona's): there it names itself by its id, a link to its own page; on its
|
|
587
|
+
* own page the titlebar names it. */
|
|
588
|
+
export let embedded = (e: Ent): boolean => screenTarget()?.eid != e.eid
|
|
589
|
+
|
|
590
|
+
export let Session = (
|
|
591
|
+
{ e, talkback = true }: { e: Ent; talkback?: boolean },
|
|
592
|
+
) => {
|
|
593
|
+
let s = e.session!
|
|
594
|
+
let repo = useRepoUrl(e)
|
|
595
|
+
// Its replies are said by the persona it wears (Entry.tsx), by name.
|
|
596
|
+
useReference(s.persona)
|
|
597
|
+
let web = typeof document != 'undefined' &&
|
|
598
|
+
typeof document.querySelector == 'function'
|
|
599
|
+
let [take, setTake] = useState(WINDOW)
|
|
600
|
+
useEffect(() => setTake(WINDOW), [e.eid])
|
|
601
|
+
// One predicate for every surface (types.ts): a session we spawned says
|
|
602
|
+
// it's going in its status, one that only announced itself is going while
|
|
603
|
+
// its door is open. `standing` is that answer as a word, so an external
|
|
604
|
+
// run's pip and label read `running` instead of a blank lifecycle.
|
|
605
|
+
let state = useSessionStanding(e, web ? take : undefined)
|
|
606
|
+
let entries = state.entries
|
|
607
|
+
let ready = entries.status == 'ready' ? entries.log : undefined
|
|
608
|
+
let [retried, setRetried] = useState(false)
|
|
609
|
+
useEffect(() => {
|
|
610
|
+
if (entries.status == 'ready') setRetried(false)
|
|
611
|
+
}, [entries.status])
|
|
612
|
+
let live = awake(e)
|
|
613
|
+
let status = state.status
|
|
614
|
+
let fault = e.exception?.value ?? e.failed?.reason
|
|
615
|
+
// Every substrate reads graph entries. The web asks for a bounded tail;
|
|
616
|
+
// the TUI keeps its own scrollback. The fallback log is only for internal
|
|
617
|
+
// derivations while the explicit read state paints below.
|
|
618
|
+
let log = ready ?? graphLog([])
|
|
619
|
+
// Context: derived from the transcript's usage entries.
|
|
620
|
+
let context = log.context ??
|
|
621
|
+
log.entries.findLast((x) => x.row?.context)?.row?.context
|
|
622
|
+
let rows = squeeze(mergeTools(log.entries.filter(entryVisible)))
|
|
623
|
+
// The facts fold behind the one lifecycle fact worth keeping in the bar.
|
|
624
|
+
let started = e.created?.at
|
|
625
|
+
let gist = started ? `started ${ago(started)}` : 'not started'
|
|
626
|
+
// A comment, on the session or on anything else, joins the thread once the
|
|
627
|
+
// transcript cites it. A managed resume
|
|
628
|
+
// prints `C-id: words` as its own user row, so that copy hides; graph-native
|
|
629
|
+
// context/tool delivery has a reference without a duplicate say row.
|
|
630
|
+
let inputs = new Set(
|
|
631
|
+
log.entries.flatMap((x) =>
|
|
632
|
+
x.row?.kind == 'say' && x.row.role == 'user' ? [x.row.text] : []
|
|
633
|
+
),
|
|
634
|
+
)
|
|
635
|
+
let citing = useCitedComments(e.eid)
|
|
636
|
+
let cited = new Set(citing.map((c) => c.eid))
|
|
637
|
+
let all = [...useCommentsOn(e.eid), ...citing]
|
|
638
|
+
let cs = [...new Map(all.map((c) => [c.eid, c])).values()]
|
|
639
|
+
.sort((a, b) => a.num - b.num)
|
|
640
|
+
.filter((c) => {
|
|
641
|
+
let body = c.doc?.body ?? ''
|
|
642
|
+
return !inputs.has(body) && !inputs.has(`${idOf(c)}: ${body}`)
|
|
643
|
+
})
|
|
644
|
+
let heard = (c: Ent) => c.created?.via == e.eid || cited.has(c.eid)
|
|
645
|
+
let heardCs = cs.filter(heard)
|
|
646
|
+
let trees = branches(cs.map(domainBundle))
|
|
647
|
+
let nodes = new Map(trees.map((node) => [node.row.entity.eid, node]))
|
|
648
|
+
let thread = weave(
|
|
649
|
+
rows,
|
|
650
|
+
trees.map((node) => ent(node.row.entity.eid)).filter(heard),
|
|
651
|
+
)
|
|
652
|
+
// Windowed from the tail on the web; the whole thread in the TUI.
|
|
653
|
+
let { root, start, older } = useTranscript(
|
|
654
|
+
thread.length,
|
|
655
|
+
`${log.entries.at(-1)?.seq ?? 0}`,
|
|
656
|
+
web,
|
|
657
|
+
e.eid,
|
|
658
|
+
entries.status == 'ready' && entries.more,
|
|
659
|
+
entries.status == 'ready' && entries.pending,
|
|
660
|
+
log.entries.length,
|
|
661
|
+
() => setTake((n) => n + WINDOW),
|
|
662
|
+
)
|
|
663
|
+
let windowed = start > 0 ? thread.slice(start) : thread
|
|
664
|
+
let unsent = trees.filter((node) => !heard(ent(node.row.entity.eid)))
|
|
665
|
+
// The mention scan (mentions over the whole thread) is a per-render scan we
|
|
666
|
+
// can't pay — a 14M-log session stalled first paint on it. Parse once,
|
|
667
|
+
// memoized on the cheap content signature; resolve+dedup stays per render so a
|
|
668
|
+
// late-loading eid still links.
|
|
669
|
+
let sig = mentionSig({
|
|
670
|
+
count: log.entries.length,
|
|
671
|
+
seq: log.entries.at(-1)?.seq ?? 0,
|
|
672
|
+
heard: heardCs,
|
|
673
|
+
repo,
|
|
674
|
+
})
|
|
675
|
+
let raw = useMemo(
|
|
676
|
+
() => threadMentions(thread, repo),
|
|
677
|
+
[sig],
|
|
678
|
+
)
|
|
679
|
+
let mentions = resolveMentions(raw)
|
|
680
|
+
let graphActivity = ready?.activity
|
|
681
|
+
let activity = graphActivity?.kind == 'tool'
|
|
682
|
+
? graphActivity.label
|
|
683
|
+
: graphActivity?.label ??
|
|
684
|
+
doing(
|
|
685
|
+
rows.at(-1)?.row,
|
|
686
|
+
s.standing == 'idle' || status == 'idle' ? 'idle' : undefined,
|
|
687
|
+
!started,
|
|
688
|
+
)
|
|
689
|
+
let showActivity = live || status == 'idle'
|
|
690
|
+
return (
|
|
691
|
+
<Frame elRef={root}>
|
|
692
|
+
<Head>
|
|
693
|
+
<Dot status={status} />
|
|
694
|
+
{embedded(e) && <Id e={e} />}
|
|
695
|
+
<SessionSummary e={e} gist={gist} />
|
|
696
|
+
<SessionContext tokens={context} />
|
|
697
|
+
{live && (
|
|
698
|
+
<Stop
|
|
699
|
+
type='button'
|
|
700
|
+
onClick={() => {
|
|
701
|
+
// The brake is data: a `stop` entry appended to the transcript,
|
|
702
|
+
// after which the host runs nothing more in it.
|
|
703
|
+
let stop = uuid()
|
|
704
|
+
mutate(
|
|
705
|
+
{ eid: stop, name: 'entry', comp: { session: e.eid } },
|
|
706
|
+
{ eid: stop, name: 'stop', comp: {} },
|
|
707
|
+
)
|
|
708
|
+
}}
|
|
709
|
+
>
|
|
710
|
+
■ stop
|
|
711
|
+
</Stop>
|
|
712
|
+
)}
|
|
713
|
+
</Head>
|
|
714
|
+
<SessionRelated eid={e.eid} />
|
|
715
|
+
<Panel>
|
|
716
|
+
{/* markdown, its markup kept as words by @yaks/markdown — as with a task body */}
|
|
717
|
+
{fault && <Fault mod='error'>{fault}</Fault>}
|
|
718
|
+
<Log>
|
|
719
|
+
{entries.status == 'loading' && (
|
|
720
|
+
<EntryState>Loading entries for {idOf(e)}…</EntryState>
|
|
721
|
+
)}
|
|
722
|
+
{(entries.status == 'failed' ||
|
|
723
|
+
entries.status == 'ready' && entries.fault) && (
|
|
724
|
+
<EntryState>
|
|
725
|
+
Entries could not be loaded: {entries.status == 'failed'
|
|
726
|
+
? entries.reason
|
|
727
|
+
: entries.fault!.reason} [{entries.status == 'failed'
|
|
728
|
+
? entries.reference
|
|
729
|
+
: entries.fault!.reference}]{' '}
|
|
730
|
+
<Retry
|
|
731
|
+
type='button'
|
|
732
|
+
onClick={() => {
|
|
733
|
+
setRetried(true)
|
|
734
|
+
retrySubscription(
|
|
735
|
+
entries.status == 'failed'
|
|
736
|
+
? entries.sub
|
|
737
|
+
: entries.fault!.sub,
|
|
738
|
+
)
|
|
739
|
+
}}
|
|
740
|
+
>
|
|
741
|
+
{retried ? 'retry again' : 'retry'}
|
|
742
|
+
</Retry>
|
|
743
|
+
{retried && ' Retry requested.'}
|
|
744
|
+
</EntryState>
|
|
745
|
+
)}
|
|
746
|
+
{entries.status == 'ready' && !log.entries.length && (
|
|
747
|
+
<EntryState>
|
|
748
|
+
{live ? 'No entries yet' : 'No entries recorded'}
|
|
749
|
+
</EntryState>
|
|
750
|
+
)}
|
|
751
|
+
{(start > 0 || entries.status == 'ready' && entries.more) && (
|
|
752
|
+
<Earlier type='button' onClick={older}>
|
|
753
|
+
{entries.status == 'ready' && entries.pending
|
|
754
|
+
? 'Loading earlier entries…'
|
|
755
|
+
: start > 0
|
|
756
|
+
? `↑ ${start} earlier ${start == 1 ? 'line' : 'lines'}`
|
|
757
|
+
: '↑ Earlier entries'}
|
|
758
|
+
</Earlier>
|
|
759
|
+
)}
|
|
760
|
+
{windowed.map((x) =>
|
|
761
|
+
logLine(x)
|
|
762
|
+
? <Row key={x.seq} x={x} repo={repo} />
|
|
763
|
+
: <Twig key={x.eid} node={nodes.get(x.eid)!} />
|
|
764
|
+
)}
|
|
765
|
+
{showActivity && <Think>✳ {activity}</Think>}
|
|
766
|
+
</Log>
|
|
767
|
+
<SessionDiagnostics exit={e.exit?.code} open={status == 'failed'} />
|
|
768
|
+
{unsent.length > 0 && (
|
|
769
|
+
<Unsent>
|
|
770
|
+
{unsent.map((node) => (
|
|
771
|
+
<Twig key={node.row.entity.eid} node={node} />
|
|
772
|
+
))}
|
|
773
|
+
</Unsent>
|
|
774
|
+
)}
|
|
775
|
+
</Panel>
|
|
776
|
+
<SessionReferences items={mentions} />
|
|
777
|
+
{
|
|
778
|
+
/* the one composer, pinned like the bar: comment about it, or say
|
|
779
|
+
TO it (Comments.tsx knows which sessions can take words) */
|
|
780
|
+
}
|
|
781
|
+
{talkback && (
|
|
782
|
+
<Foot>
|
|
783
|
+
<SessionInput e={e} />
|
|
784
|
+
</Foot>
|
|
785
|
+
)}
|
|
786
|
+
</Frame>
|
|
787
|
+
)
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
// A session row names the work behind it. The first human input is a small
|
|
791
|
+
// held query, so a list never loads every session's transcript.
|
|
792
|
+
let RowLine = block('div', 'SessionRow', {
|
|
793
|
+
Head: 'div',
|
|
794
|
+
Title: 'span',
|
|
795
|
+
Meta: 'span',
|
|
796
|
+
Brief: 'span',
|
|
797
|
+
})
|
|
798
|
+
|
|
799
|
+
let excerpt = (text?: string | null) => text?.trim().replace(/\s+/g, ' ')
|
|
800
|
+
|
|
801
|
+
export let SessionRow = ({ e, slots, onOpen }: TileProps) => {
|
|
802
|
+
let task = e.refs.find((r) => r.type == 'worked')?.child
|
|
803
|
+
let face = useReference(task)
|
|
804
|
+
let first = useQueryResult(
|
|
805
|
+
`.entry.session=${e.eid}&.content&!output&!notice&!prompt&` +
|
|
806
|
+
'.order=entry.seq&.limit=1&.fields=content.body',
|
|
807
|
+
true,
|
|
808
|
+
true,
|
|
809
|
+
).eids[0]
|
|
810
|
+
let ask = excerpt(first && ent(first).content?.body)
|
|
811
|
+
let brief = excerpt(e.brief?.text)
|
|
812
|
+
let latest = useQueryResult(
|
|
813
|
+
`.entry.session=${e.eid}&.order=-entry.seq&.limit=1&.fields=entry.seq,created.at`,
|
|
814
|
+
true,
|
|
815
|
+
true,
|
|
816
|
+
).eids[0]
|
|
817
|
+
let last = latest ? ent(latest) : undefined
|
|
818
|
+
let model = useModel(e).name
|
|
819
|
+
let title = excerpt(e.doc?.title) || ask ||
|
|
820
|
+
brief || 'Session'
|
|
821
|
+
let detail = face.value ? brief || ask : ask && brief
|
|
822
|
+
return (
|
|
823
|
+
<RowLine>
|
|
824
|
+
<RowLine.Head {...tileLink(e, onOpen)}>
|
|
825
|
+
{slot(slots, 'before')}
|
|
826
|
+
<SessionDot e={e} />
|
|
827
|
+
<RowLine.Title>
|
|
828
|
+
{slots?.title ?? (face.value
|
|
829
|
+
? <Entity eid={face.value.eid} view='Session.Work.Inline' />
|
|
830
|
+
: <span {...tileTitle(undefined, title)} />)}
|
|
831
|
+
</RowLine.Title>
|
|
832
|
+
{slot(slots, 'after')}
|
|
833
|
+
{(last?.entry?.seq != null || model || last?.created?.at) && (
|
|
834
|
+
<RowLine.Meta>
|
|
835
|
+
{last?.entry?.seq != null && <>#{last.entry.seq}</>}
|
|
836
|
+
{model && <>{last?.entry?.seq != null && ' · '}{model}</>}
|
|
837
|
+
{last?.created?.at && (
|
|
838
|
+
<>
|
|
839
|
+
{(last?.entry?.seq != null || model) && ' · '}
|
|
840
|
+
<Stamp at={last.created.at} label='active' />
|
|
841
|
+
</>
|
|
842
|
+
)}
|
|
843
|
+
</RowLine.Meta>
|
|
844
|
+
)}
|
|
845
|
+
</RowLine.Head>
|
|
846
|
+
{slot(slots, 'body')}
|
|
847
|
+
{detail && <RowLine.Brief>{detail}</RowLine.Brief>}
|
|
848
|
+
</RowLine>
|
|
849
|
+
)
|
|
850
|
+
}
|