opencode-extended-sidebar 0.2.90 → 0.2.91
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/.oesignore +17 -17
- package/CHANGELOG.md +96 -95
- package/LICENSE +21 -21
- package/README.md +150 -235
- package/oes.json +13 -11
- package/package.json +100 -100
- package/scripts/install-git-hooks.mjs +29 -29
- package/src/pware.oc.core/constants/index.ts +18 -18
- package/src/pware.oc.core/constants/pware.oc.core.constants.eventKind.ts +29 -29
- package/src/pware.oc.core/constants/pware.oc.core.constants.eventName.ts +15 -13
- package/src/pware.oc.core/constants/pware.oc.core.constants.eventType.ts +241 -241
- package/src/pware.oc.core/constants/pware.oc.core.constants.myWork.ts +55 -55
- package/src/pware.oc.core/constants/pware.oc.core.constants.partType.ts +65 -65
- package/src/pware.oc.core/constants/pware.oc.core.constants.phase.ts +58 -58
- package/src/pware.oc.core/constants/pware.oc.core.constants.pulse.ts +63 -63
- package/src/pware.oc.core/constants/pware.oc.core.constants.rowKind.ts +34 -34
- package/src/pware.oc.core/constants/pware.oc.core.constants.status.ts +74 -74
- package/src/pware.oc.core/constants/pware.oc.core.constants.toolName.ts +69 -69
- package/src/pware.oc.core/git/index.ts +7 -7
- package/src/pware.oc.core/git/pware.oc.core.git.ts +237 -237
- package/src/pware.oc.core/git/pware.oc.core.gitignore.ts +87 -87
- package/src/pware.oc.core/index.ts +19 -18
- package/src/pware.oc.core/pware.oc.core.bus.ts +42 -42
- package/src/pware.oc.core/pware.oc.core.cache.ts +48 -48
- package/src/pware.oc.core/pware.oc.core.clipboard.ts +97 -97
- package/src/pware.oc.core/pware.oc.core.debug.ts +280 -280
- package/src/pware.oc.core/pware.oc.core.events.ts +79 -79
- package/src/pware.oc.core/pware.oc.core.glyph.ts +135 -135
- package/src/pware.oc.core/pware.oc.core.layout.ts +234 -234
- package/src/pware.oc.core/pware.oc.core.oes.ts +99 -89
- package/src/pware.oc.core/pware.oc.core.paths.ts +240 -240
- package/src/pware.oc.core/pware.oc.core.preview.ts +74 -74
- package/src/pware.oc.core/pware.oc.core.pulse.ts +726 -726
- package/src/pware.oc.core/pware.oc.core.runtimeConfig.ts +41 -0
- package/src/pware.oc.core/pware.oc.core.sqlite.ts +164 -175
- package/src/pware.oc.core/pware.oc.core.sqliteGateway.ts +89 -0
- package/src/pware.oc.core/pware.oc.core.status.ts +214 -214
- package/src/pware.oc.core/pware.oc.core.timing.ts +63 -63
- package/src/pware.oc.core/pware.oc.core.width.ts +215 -215
- package/src/pware.oc.omo/constants/index.ts +15 -15
- package/src/pware.oc.omo/constants/pware.oc.omo.constants.backgroundTask.ts +18 -18
- package/src/pware.oc.omo/constants/pware.oc.omo.constants.boulderStatus.ts +49 -49
- package/src/pware.oc.omo/constants/pware.oc.omo.constants.docKind.ts +29 -29
- package/src/pware.oc.omo/constants/pware.oc.omo.constants.eventName.ts +11 -11
- package/src/pware.oc.omo/constants/pware.oc.omo.constants.planStatus.ts +60 -60
- package/src/pware.oc.omo/constants/pware.oc.omo.constants.reviewStatus.ts +49 -49
- package/src/pware.oc.omo/constants/pware.oc.omo.constants.startWork.ts +25 -25
- package/src/pware.oc.omo/constants/pware.oc.omo.constants.verdict.ts +38 -38
- package/src/pware.oc.omo/index.ts +7 -7
- package/src/pware.oc.omo/resolver/index.ts +19 -19
- package/src/pware.oc.omo/resolver/pware.oc.omo.resolver.approval.ts +179 -179
- package/src/pware.oc.omo/resolver/pware.oc.omo.resolver.approvalGroup.ts +116 -116
- package/src/pware.oc.omo/resolver/pware.oc.omo.resolver.approvalState.ts +34 -34
- package/src/pware.oc.omo/resolver/pware.oc.omo.resolver.boulder.ts +503 -503
- package/src/pware.oc.omo/resolver/pware.oc.omo.resolver.config.ts +40 -40
- package/src/pware.oc.omo/resolver/pware.oc.omo.resolver.doc.ts +269 -269
- package/src/pware.oc.omo/resolver/pware.oc.omo.resolver.draftFile.ts +18 -18
- package/src/pware.oc.omo/resolver/pware.oc.omo.resolver.notepadsFile.ts +18 -18
- package/src/pware.oc.omo/resolver/pware.oc.omo.resolver.plan.ts +155 -155
- package/src/pware.oc.omo/resolver/pware.oc.omo.resolver.planFile.ts +363 -361
- package/src/pware.oc.omo/resolver/pware.oc.omo.resolver.proofFile.ts +18 -18
- package/src/pware.oc.omo/resolver/pware.oc.omo.resolver.rulesFile.ts +11 -11
- package/src/pware.oc.omo/resolver/pware.oc.omo.resolver.runContinuationFile.ts +14 -14
- package/src/pware.oc.opencode/constants/index.ts +10 -10
- package/src/pware.oc.opencode/constants/pware.oc.opencode.constants.eventName.ts +15 -15
- package/src/pware.oc.opencode/constants/pware.oc.opencode.constants.fileTouch.ts +18 -18
- package/src/pware.oc.opencode/constants/pware.oc.opencode.constants.questionKind.ts +45 -45
- package/src/pware.oc.opencode/constants/pware.oc.opencode.constants.sessionStatus.ts +58 -58
- package/src/pware.oc.opencode/index.ts +8 -8
- package/src/pware.oc.opencode/pware.oc.opencode.events.ts +182 -182
- package/src/pware.oc.opencode/pware.oc.opencode.files.ts +399 -399
- package/src/pware.oc.opencode/resolver/index.ts +223 -170
- package/src/pware.oc.opencode/resolver/pware.oc.opencode.resolver.file.ts +150 -162
- package/src/pware.oc.opencode/resolver/pware.oc.opencode.resolver.question.ts +149 -185
- package/src/pware.oc.opencode/resolver/pware.oc.opencode.resolver.session.ts +248 -211
- package/src/pware.oc.opencode/resolver/pware.oc.opencode.resolver.todo.ts +22 -26
- package/src/pware.oc.opencode/resolver/pware.oc.opencode.resolver.tool.ts +224 -236
- package/src/pware.oc.perf/index.ts +14 -14
- package/src/pware.oc.perf/pware.oc.perf.asciichart.d.ts +15 -15
- package/src/pware.oc.perf/pware.oc.perf.charts.ts +284 -284
- package/src/pware.oc.perf/pware.oc.perf.reader.ts +962 -927
- package/src/pware.oc.perf/pware.oc.perf.realtime.ts +88 -88
- package/src/pware.oc.perf/pware.oc.perf.realtimeBlock.ts +118 -118
- package/src/pware.oc.perf/pware.oc.perf.realtimeCpuRam.ts +79 -79
- package/src/pware.oc.perf/pware.oc.perf.realtimeSampler.ts +71 -71
- package/src/pware.oc.perf/pware.oc.perf.realtimeTimeline.ts +214 -214
- package/src/pware.oc.perf/pware.oc.perf.self.ts +179 -179
- package/src/pware.oc.perf/pware.oc.perf.view.tsx +463 -462
- package/src/pware.oc.runtime/index.ts +13 -13
- package/src/pware.oc.runtime/pware.oc.runtime.monitor.ts +142 -142
- package/src/pware.oc.runtime/pware.oc.runtime.mywork-enrich.ts +87 -79
- package/src/pware.oc.runtime/pware.oc.runtime.mywork.ts +282 -253
- package/src/pware.oc.runtime/pware.oc.runtime.omoRead.ts +37 -0
- package/src/pware.oc.runtime/pware.oc.runtime.questions.ts +83 -95
- package/src/pware.oc.runtime/pware.oc.runtime.snapshotClient.ts +130 -129
- package/src/pware.oc.runtime/pware.oc.runtime.source.ts +105 -105
- package/src/pware.oc.runtime/pware.oc.runtime.worker.ts +44 -43
- package/src/pware.oc.runtime/resolver/index.ts +268 -224
- package/src/pware.oc.runtime/resolver/pware.oc.runtime.resolver.delegate.ts +146 -146
- package/src/pware.oc.ui/index.ts +12 -12
- package/src/pware.oc.ui/pware.oc.ui.chrome.tsx +381 -339
- package/src/pware.oc.ui/pware.oc.ui.glyphs.tsx +144 -144
- package/src/pware.oc.ui/pware.oc.ui.host.tsx +111 -111
- package/src/pware.oc.ui/pware.oc.ui.live.tsx +82 -82
- package/src/pware.oc.ui/pware.oc.ui.menudialogs.tsx +843 -843
- package/src/pware.oc.ui/pware.oc.ui.sections.tsx +552 -526
- package/src/pware.oc.ui/pware.oc.ui.sidebar.tsx +1718 -1629
- package/src/pware.oc.ui.tsx +98 -98
|
@@ -1,170 +1,223 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* pware.oc.core.opencode.resolver
|
|
3
|
-
*
|
|
4
|
-
* Aggregate of the opencode SQLite resolvers: readDbSnapshot composes the
|
|
5
|
-
* session graph + tools + files for the panel; readProjectFeed rolls the
|
|
6
|
-
* Sessions-tab feed across a set of sessions. Re-exports the entity resolvers.
|
|
7
|
-
*/
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
getSessionById,
|
|
15
|
-
getSessionsByIds,
|
|
16
|
-
listChildSessions,
|
|
17
|
-
listRecentMainSessions,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
import
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
export * from "./pware.oc.opencode.resolver.
|
|
28
|
-
export * from "./pware.oc.opencode.resolver.
|
|
29
|
-
export * from "./pware.oc.opencode.resolver.
|
|
30
|
-
|
|
31
|
-
export
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
current
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
/** Current session tool parts — name + status only, no args/outputs. */
|
|
48
|
-
tools: ToolView[]
|
|
49
|
-
/** Basenames + optional +/- from edit/write parts. No paths, no bodies. */
|
|
50
|
-
files: FileView[]
|
|
51
|
-
error: string | null
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export function emptyDb(dbPath: string, error: string | null = null): DbSnapshot {
|
|
55
|
-
return {
|
|
56
|
-
present: false,
|
|
57
|
-
dbPath,
|
|
58
|
-
projectId: null,
|
|
59
|
-
current: null,
|
|
60
|
-
main: null,
|
|
61
|
-
parent: null,
|
|
62
|
-
children: [],
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
const
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
)
|
|
170
|
-
|
|
1
|
+
/**
|
|
2
|
+
* pware.oc.core.opencode.resolver
|
|
3
|
+
*
|
|
4
|
+
* Aggregate of the opencode SQLite resolvers: readDbSnapshot composes the
|
|
5
|
+
* session graph + tools + files for the panel; readProjectFeed rolls the
|
|
6
|
+
* Sessions-tab feed across a set of sessions. Re-exports the entity resolvers.
|
|
7
|
+
*/
|
|
8
|
+
import type { FileFilter, FileView } from "../pware.oc.opencode.files.js"
|
|
9
|
+
import { getOes } from "../../pware.oc.core/pware.oc.core.oes.js"
|
|
10
|
+
import { profileAsync } from "../../pware.oc.core/pware.oc.core.debug.js"
|
|
11
|
+
import { readonlyReadGateway } from "../../pware.oc.core/pware.oc.core.sqliteGateway.js"
|
|
12
|
+
import type { SqlDb } from "../../pware.oc.core/pware.oc.core.sqlite.js"
|
|
13
|
+
import {
|
|
14
|
+
getSessionById,
|
|
15
|
+
getSessionsByIds,
|
|
16
|
+
listChildSessions,
|
|
17
|
+
listRecentMainSessions,
|
|
18
|
+
HOUR_MS,
|
|
19
|
+
sessionAgeTier,
|
|
20
|
+
toSessionView,
|
|
21
|
+
type SessionView,
|
|
22
|
+
} from "./pware.oc.opencode.resolver.session.js"
|
|
23
|
+
import { SESSION_STATUS_RUNNING } from "../constants/pware.oc.opencode.constants.sessionStatus.js"
|
|
24
|
+
import { listRecentToolEvents, listToolEvents, type ToolView } from "./pware.oc.opencode.resolver.tool.js"
|
|
25
|
+
import { listSessionFiles, listRecentSessionFiles } from "./pware.oc.opencode.resolver.file.js"
|
|
26
|
+
|
|
27
|
+
export * from "./pware.oc.opencode.resolver.session.js"
|
|
28
|
+
export * from "./pware.oc.opencode.resolver.todo.js"
|
|
29
|
+
export * from "./pware.oc.opencode.resolver.tool.js"
|
|
30
|
+
export * from "./pware.oc.opencode.resolver.file.js"
|
|
31
|
+
export * from "./pware.oc.opencode.resolver.question.js"
|
|
32
|
+
|
|
33
|
+
export type DbSnapshot = {
|
|
34
|
+
present: boolean
|
|
35
|
+
dbPath: string
|
|
36
|
+
/** Project of the current session — scopes project-wide reads (questions). */
|
|
37
|
+
projectId: string | null
|
|
38
|
+
current: SessionView | null
|
|
39
|
+
/** Orchestrator: parent if current is a child, otherwise current. */
|
|
40
|
+
main: SessionView | null
|
|
41
|
+
parent: SessionView | null
|
|
42
|
+
children: SessionView[]
|
|
43
|
+
/** Sessions keyed by id — current, main, and any looked-up delegates. */
|
|
44
|
+
byId: Record<string, SessionView>
|
|
45
|
+
/** Recent main (parent_id null) sessions in this project — the `sessionFetch` window. */
|
|
46
|
+
recent: SessionView[]
|
|
47
|
+
/** Current session tool parts — name + status only, no args/outputs. */
|
|
48
|
+
tools: ToolView[]
|
|
49
|
+
/** Basenames + optional +/- from edit/write parts. No paths, no bodies. */
|
|
50
|
+
files: FileView[]
|
|
51
|
+
error: string | null
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function emptyDb(dbPath: string, error: string | null = null): DbSnapshot {
|
|
55
|
+
return {
|
|
56
|
+
present: false,
|
|
57
|
+
dbPath,
|
|
58
|
+
projectId: null,
|
|
59
|
+
current: null,
|
|
60
|
+
main: null,
|
|
61
|
+
parent: null,
|
|
62
|
+
children: [],
|
|
63
|
+
byId: {},
|
|
64
|
+
recent: [],
|
|
65
|
+
tools: [],
|
|
66
|
+
files: [],
|
|
67
|
+
error,
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export type DbSnapshotReadOptions = {
|
|
72
|
+
readonly dbPath: string
|
|
73
|
+
readonly sessionId: string
|
|
74
|
+
readonly extraIds?: readonly string[]
|
|
75
|
+
readonly projectRoot?: string | null
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export type DbReadPlan<T> = {
|
|
79
|
+
readonly initial: () => T
|
|
80
|
+
readonly stages: readonly ((db: SqlDb, state: T) => T)[]
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function createDbSnapshotRead(opts: DbSnapshotReadOptions): DbReadPlan<DbSnapshot> {
|
|
84
|
+
const now = Date.now()
|
|
85
|
+
const oes = getOes(opts.projectRoot)
|
|
86
|
+
const loadCurrent = (db: SqlDb, state: DbSnapshot): DbSnapshot => {
|
|
87
|
+
const row = getSessionById(db, opts.sessionId)
|
|
88
|
+
if (!row) {
|
|
89
|
+
return { ...emptyDb(opts.dbPath, "session not in db yet"), present: true }
|
|
90
|
+
}
|
|
91
|
+
const current = toSessionView(row, now)
|
|
92
|
+
return {
|
|
93
|
+
...state,
|
|
94
|
+
present: true,
|
|
95
|
+
projectId: row.project_id,
|
|
96
|
+
current,
|
|
97
|
+
main: current,
|
|
98
|
+
byId: { [current.id]: current },
|
|
99
|
+
error: null,
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const loadGraph = (db: SqlDb, state: DbSnapshot): DbSnapshot => {
|
|
104
|
+
const current = state.current
|
|
105
|
+
const projectId = state.projectId
|
|
106
|
+
if (!current || !projectId) return state
|
|
107
|
+
let parent: SessionView | null = null
|
|
108
|
+
const children = listChildSessions(db, current.id).map((r) => toSessionView(r, now))
|
|
109
|
+
if (current.parentId) {
|
|
110
|
+
const p = getSessionById(db, current.parentId)
|
|
111
|
+
if (p) parent = toSessionView(p, now)
|
|
112
|
+
}
|
|
113
|
+
const main = parent ?? current
|
|
114
|
+
const extra = getSessionsByIds(db, [...(opts.extraIds ?? [])]).map((r) =>
|
|
115
|
+
toSessionView(r, now),
|
|
116
|
+
)
|
|
117
|
+
const visibleMs = oes.sessionVisibleHours * HOUR_MS
|
|
118
|
+
const dimMs = oes.sessionDimHours * HOUR_MS
|
|
119
|
+
const recent = listRecentMainSessions(db, {
|
|
120
|
+
projectId,
|
|
121
|
+
limit: oes.sessionFetch,
|
|
122
|
+
})
|
|
123
|
+
.map((r) => toSessionView(r, now))
|
|
124
|
+
.filter((v) => {
|
|
125
|
+
const keep =
|
|
126
|
+
v.id === current.id || v.id === main.id || v.status === SESSION_STATUS_RUNNING
|
|
127
|
+
return sessionAgeTier(v.ageMs, dimMs, visibleMs, keep) !== "hidden"
|
|
128
|
+
})
|
|
129
|
+
const byId: Record<string, SessionView> = {}
|
|
130
|
+
for (const v of [current, parent, main, ...children, ...extra, ...recent]) {
|
|
131
|
+
if (v) byId[v.id] = v
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
...state,
|
|
135
|
+
main,
|
|
136
|
+
parent,
|
|
137
|
+
children,
|
|
138
|
+
byId,
|
|
139
|
+
recent,
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const loadTools = (db: SqlDb, state: DbSnapshot): DbSnapshot => {
|
|
144
|
+
if (!state.current) return state
|
|
145
|
+
return {
|
|
146
|
+
...state,
|
|
147
|
+
tools: listToolEvents(db, state.current.id, oes.toolFetch),
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const loadFiles = (db: SqlDb, state: DbSnapshot): DbSnapshot => {
|
|
152
|
+
if (!state.current) return state
|
|
153
|
+
return {
|
|
154
|
+
...state,
|
|
155
|
+
files: listSessionFiles(db, state.current.id, {
|
|
156
|
+
skipGitignore: oes.skipGitignore,
|
|
157
|
+
projectRoot: opts.projectRoot,
|
|
158
|
+
}),
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return {
|
|
163
|
+
initial: () => emptyDb(opts.dbPath),
|
|
164
|
+
stages: [loadCurrent, loadGraph, loadTools, loadFiles],
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export function readDbSnapshot(db: SqlDb, opts: DbSnapshotReadOptions): DbSnapshot {
|
|
169
|
+
const plan = createDbSnapshotRead(opts)
|
|
170
|
+
return plan.stages.reduce((state, stage) => stage(db, state), plan.initial())
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export type ProjectFeed = {
|
|
174
|
+
tools: ToolView[]
|
|
175
|
+
files: FileView[]
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export function emptyProjectFeed(): ProjectFeed {
|
|
179
|
+
return { tools: [], files: [] }
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** Lazy read — callers gate on the Sessions tab so the queries never run elsewhere. */
|
|
183
|
+
export type ProjectFeedReadOptions = {
|
|
184
|
+
readonly dbPath: string
|
|
185
|
+
readonly sessionIds: readonly string[]
|
|
186
|
+
readonly toolLimit: number
|
|
187
|
+
readonly filter?: FileFilter
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export function createProjectFeedRead(opts: ProjectFeedReadOptions): DbReadPlan<ProjectFeed> {
|
|
191
|
+
return {
|
|
192
|
+
initial: emptyProjectFeed,
|
|
193
|
+
stages: [
|
|
194
|
+
(db, state) => ({
|
|
195
|
+
...state,
|
|
196
|
+
tools: listRecentToolEvents(db, [...opts.sessionIds], opts.toolLimit),
|
|
197
|
+
}),
|
|
198
|
+
(db, state) => ({
|
|
199
|
+
...state,
|
|
200
|
+
files: listRecentSessionFiles(db, [...opts.sessionIds], opts.filter),
|
|
201
|
+
}),
|
|
202
|
+
],
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export function readProjectFeed(db: SqlDb, opts: ProjectFeedReadOptions): ProjectFeed {
|
|
207
|
+
if (opts.sessionIds.length === 0) return emptyProjectFeed()
|
|
208
|
+
const plan = createProjectFeedRead(opts)
|
|
209
|
+
return plan.stages.reduce((state, stage) => stage(db, state), plan.initial())
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export function readProjectFeedAsync(opts: ProjectFeedReadOptions): Promise<ProjectFeed> {
|
|
213
|
+
if (!opts.dbPath || opts.sessionIds.length === 0) return Promise.resolve(emptyProjectFeed())
|
|
214
|
+
const plan = createProjectFeedRead(opts)
|
|
215
|
+
return profileAsync("db.feed", () =>
|
|
216
|
+
readonlyReadGateway.run({
|
|
217
|
+
dbPath: opts.dbPath,
|
|
218
|
+
initial: plan.initial,
|
|
219
|
+
stages: plan.stages,
|
|
220
|
+
fallback: emptyProjectFeed,
|
|
221
|
+
}),
|
|
222
|
+
)
|
|
223
|
+
}
|