diff --git a/src/jazz/store.ts b/src/jazz/store.ts index 17a7ba0..854c3e4 100644 --- a/src/jazz/store.ts +++ b/src/jazz/store.ts @@ -834,6 +834,22 @@ export class JazzThoughtStore { ); } + subscribeInspectorActivity(onChange: () => void): () => void { + const unsubscribers = [ + this.db.subscribeAll( + thoughtstreamApp.events.where({}).orderBy("observedAt", "desc").limit(1), + () => onChange(), + ), + this.db.subscribeAll( + thoughtstreamApp.sources.where({}), + () => onChange(), + ), + ]; + return () => { + for (const unsubscribe of unsubscribers) unsubscribe(); + }; + } + async queryConsumerEvents(query: ConsumerEventQuery): Promise { if (query.eventTypes.length === 0 || query.acceptedPrivacy.length === 0) return []; const rows = await this.db.all(thoughtstreamApp.events.where({ diff --git a/src/web/inspector.ts b/src/web/inspector.ts index 4ef4655..159a614 100644 --- a/src/web/inspector.ts +++ b/src/web/inspector.ts @@ -194,6 +194,10 @@ async function handleRequest( }); return; } + if (url.pathname === "/api/live") { + streamInspectorActivity(store, request, response); + return; + } if (url.pathname === "/api/proposals") { sendJson(response, 200, await projectProposalQueue(store)); return; @@ -572,7 +576,7 @@ export function renderInspectorHtml(): string {

thought stream

loading
root activity…
Loading root activity…
Select an observation to see what processed it and what, if anything, happened.