Skip to content

worker: Add indexing dashboard in development#4189

Merged
backspace merged 21 commits intomainfrom
server/indexing-dashboard-cs-10443
Mar 16, 2026
Merged

worker: Add indexing dashboard in development#4189
backspace merged 21 commits intomainfrom
server/indexing-dashboard-cs-10443

Conversation

@backspace
Copy link
Contributor

@backspace backspace commented Mar 13, 2026

I’m often wondering when developing how much is left to index:

image

This adds an event sink for index runners to report on their progress and a worker manager dashboard to report that.

@github-actions
Copy link

github-actions bot commented Mar 13, 2026

Host Test Results

    1 files  ±0      1 suites  ±0   2h 31m 22s ⏱️ + 1m 36s
2 022 tests ±0  2 007 ✅ ±0  15 💤 ±0  0 ❌ ±0 
2 037 runs  ±0  2 022 ✅ ±0  15 💤 ±0  0 ❌ ±0 

Results for commit 58ada6f. ± Comparison against base commit 0db3b27.

♻️ This comment has been updated with latest results.

@backspace backspace marked this pull request as ready for review March 13, 2026 23:33
@backspace backspace requested a review from a team March 13, 2026 23:33
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fc9fd377b9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@habdelra habdelra requested a review from Copilot March 14, 2026 13:17
@habdelra
Copy link
Contributor

wow! 🤩

@habdelra
Copy link
Contributor

you can actually have multiple workers in development using env vars (i think it’s ALL_PRIORITY_WORKER_COUNT and HIGH_PRIORITY_WORKER_COUNT), can this handle showing multiple workers indexing simultaneously?

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a development-time “indexing dashboard” by emitting indexing progress events from IndexRunner through the worker/task stack, collecting them in the realm-server worker manager, and rendering a simple HTML dashboard (plus JSON endpoint).

Changes:

  • Introduces an IndexingProgressEvent flow from IndexRunner → tasks → Worker → realm-server worker process IPC → worker-manager.
  • Adds an in-memory IndexingEventSink with tests and exposes /_indexing-dashboard + /_indexing-status (non-ECS).
  • Updates CI to include the new realm-server test module.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
packages/runtime-common/worker.ts Adds IndexingProgressEvent type and reportProgress plumbing into task args.
packages/runtime-common/tasks/index.ts Extends TaskArgs with optional reportProgress callback.
packages/runtime-common/tasks/indexer.ts Passes reportProgress through to IndexRunner as onProgress.
packages/runtime-common/index-runner.ts Emits indexing progress events (start, per-file, finish).
packages/realm-server/worker.ts Sends progress events over IPC to worker-manager.
packages/realm-server/worker-manager.ts Adds event sink, dev-only routes, and parses `progress
packages/realm-server/indexing-event-sink.ts New: stores active indexing + limited history snapshots.
packages/realm-server/handlers/handle-indexing-dashboard.ts New: renders HTML dashboard from the sink snapshot.
packages/realm-server/tests/indexing-event-sink-test.ts New: validates event sink behavior for start/visit/finish and concurrency across realms.
packages/realm-server/tests/index.ts Registers the new test module.
.github/workflows/ci.yaml Adds indexing-event-sink-test.ts to the realm-server test matrix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +125 to +129
function reportProgress(event: IndexingProgressEvent) {
if (process.send) {
process.send(`progress|${JSON.stringify(event)}`);
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 281eefc

Comment on lines +20 to +44
/** Active indexing state per realm */
#active = new Map<string, RealmIndexingState>();

/** Recently completed indexing runs (most recent first) */
#history: RealmIndexingState[] = [];

/** Max history entries to keep */
#maxHistory = 50;

handleEvent(event: IndexingProgressEvent): void {
switch (event.type) {
case 'indexing-started': {
this.#active.set(event.realmURL, {
realmURL: event.realmURL,
jobId: event.jobId,
jobType: event.jobType ?? 'unknown',
status: 'indexing',
totalFiles: event.totalFiles ?? 0,
filesCompleted: 0,
files: event.files ?? [],
completedFiles: [],
startedAt: Date.now(),
lastUpdatedAt: Date.now(),
});
break;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in aeb0ff9

@backspace
Copy link
Contributor Author

you can actually have multiple workers in development using env vars (i think it’s ALL_PRIORITY_WORKER_COUNT and HIGH_PRIORITY_WORKER_COUNT), can this handle showing multiple workers indexing simultaneously?

When I ran the realm server for this I had WORKER_HIGH_PRIORITY_COUNT=4 WORKER_ALL_PRIORITY_COUNT=4 so maybe it’s not being reflected, or something else is missing, I’ll look into it.

@backspace
Copy link
Contributor Author

The reason you only see one active job despite having 8 workers is that realms are started sequentially in packages/realm-server/server.ts:279-284:
  // ideally we'd like to use a Promise.all to start these and the ordering
  // will just fall out naturally from cross realm invalidation. Until we have
  // that we should start the realms in order.
  for (let realm of this.realms) {
    await realm.start();
  }

Each realm.start() is awaited before the next one begins, so only one from-scratch-index job exists in the queue at a time
during startup. Your 8 workers are available, but only one has work at any given moment. Once that realm finishes indexing,
the next realm starts, and so on.

The comment in the code even acknowledges this — they'd like to use Promise.all but haven't implemented cross-realm
invalidation ordering yet. If/when that changes to parallel startup, you'd see multiple active jobs on the dashboard.

Seems true?

backspace and others added 5 commits March 16, 2026 09:42
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@habdelra
Copy link
Contributor

habdelra commented Mar 16, 2026

The reason you only see one active job despite having 8 workers is that
realms are started sequentially in packages/realm-server/server.ts:279-284:

  // ideally we'd like to use a Promise.all to start these and the ordering
  // will just fall out naturally from cross realm invalidation. Until we have
  // that we should start the realms in order.
  for (let realm of this.realms) {
    await realm.start();
  }

Each realm.start() is awaited before the next one begins, so only one from-scratch-index job exists in the queue at a time
during startup. Your 8 workers are available, but only one has work at any given moment. Once that realm finishes indexing,
the next realm starts, and so on.
The comment in the code even acknowledges this — they'd like to use Promise.all but haven't implemented cross-realm
invalidation ordering yet. If/when that changes to parallel startup, you'd see multiple active jobs on the dashboard.

Seems true?

that's true--but that's just at startup. there are other scenarios after startup that could use multiple workers. like you run 2 different realm full reindex jobs, and then maybe do a incremental index because of an auto save. if you had it configured as such, that could be 3 concurrent jobs right there.

@backspace
Copy link
Contributor Author

that's true--but that's just at startup. there are other scenarios after startup that could use multiple workers. like you run 2 different realm full reindex jobs, and then maybe do a incremental index because of an auto save. if you had it configured as such, that could be 3 concurrent jobs right there.

👍🏻 it does show concurrent jobs:

image

@habdelra
Copy link
Contributor

could we include an update to the README.md to describe how to access this?

@habdelra
Copy link
Contributor

habdelra commented Mar 16, 2026

I'm not sure if it's useful, but you might also want to show pending jobs in the queue too (just like you show completed jobs)

@backspace
Copy link
Contributor Author

👍🏻 I added a mention in README and the dashboard now shows pending jobs:

image

@backspace backspace merged commit dc8558c into main Mar 16, 2026
109 of 110 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants