Skip to content

Add --all mode to serve-instrument package#1363

Merged
joshunrau merged 1 commit into
v2from
serve-instruments-all
Jun 5, 2026
Merged

Add --all mode to serve-instrument package#1363
joshunrau merged 1 commit into
v2from
serve-instruments-all

Conversation

@gdevenyi
Copy link
Copy Markdown
Contributor

@gdevenyi gdevenyi commented Jun 1, 2026

Summary

Merges the multi-instrument serving capability directly into serve-instrument via a new --all CLI flag.

Usage

Single instrument (default, unchanged):

serve-instrument ./my-instrument

All instruments (new --all mode):

serve-instrument --all ./instruments-dir

With --all, the target directory must contain forms/ and/or interactive/ subdirectories. The server provides:

  • An index page linking to all discovered instruments
  • Per-instrument pages with hot-rebuild on file change (fs.watch)
  • An en/fr language switcher wired to the libui i18n translator
  • Verbose request logging (with -v)

Changes

  • src/cli.ts: Added --all / -a flag; validates that target has forms//interactive/ subdirs in all mode
  • src/root.tsx: Merged UI — RootProps is now a discriminated union (single | index | instrument pages); added LanguageSwitcher and IndexPage components
  • src/server.tsx: Added InstrumentLoaderMap class and AllModeHandler alongside existing SingleModeHandler; Server.create branches on mode
  • package.json: Bumped version to 0.0.13

Copilot AI review requested due to automatic review settings June 1, 2026 18:18
@gdevenyi gdevenyi requested a review from joshunrau as a code owner June 1, 2026 18:18
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 1, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 7242d97d-22ea-414e-8ffa-c657d603d7cb

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch serve-instruments-all

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
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 new workspace package, @opendatacapture/serve-instrument-all, providing a dev server that discovers and serves all instruments under forms/ and interactive/, with an index page and per-instrument rendering/bundling.

Changes:

  • Introduces the serve-instrument-all CLI + HTTP server to enumerate instruments and serve an index plus per-instrument pages.
  • Adds a small React client/root app including an en/fr language switcher and instrument rendering via ScalarInstrumentRenderer.
  • Adds build tooling (esbuild + Tailwind CSS extraction) and wires the new package into the pnpm workspace lockfile.

Reviewed changes

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

Show a summary per file
File Description
pnpm-lock.yaml Adds the new workspace importer for packages/serve-instrument-all.
packages/serve-instrument-all/package.json Defines the new package, bin entry, and dependencies for the CLI/dev server.
packages/serve-instrument-all/tsconfig.json TypeScript config matching existing dev-server conventions (DOM libs, runtime path mapping).
packages/serve-instrument-all/scripts/build.js Builds the Node CLI and browser client bundles (plus inlined Tailwind styles).
packages/serve-instrument-all/src/cli.ts CLI argument parsing/validation and server startup (--port, --verbose).
packages/serve-instrument-all/src/server.tsx HTTP server, instrument discovery, bundling/watch logic, and runtime asset serving.
packages/serve-instrument-all/src/root.tsx React UI: index page + instrument page with language switcher.
packages/serve-instrument-all/src/client.tsx Client hydration entrypoint for the server-rendered HTML.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

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

Comment on lines +161 to +163
const [, type, name] = instrumentMatch;
const decodedName = decodeURIComponent(name!);
const encodedBundle = await this.loaderMap.getEncodedBundle(type!, decodedName);
Comment on lines +197 to +200
const clientBundle = await fs.promises
.readFile(path.resolve(import.meta.dirname, 'client.js'), 'utf-8')
.then((text) => `const __ROOT_PROPS__ = ${JSON.stringify(props)}; ${text}`);

Comment on lines +44 to +47
fs.watch(target, { recursive: false }, () => {
log(chalk.yellow('↺') + chalk.dim(` [${this.label}] File changed, rebuilding...`));
void this.updateEncodedBundle();
});
Comment on lines +161 to +163
const [, type, name] = instrumentMatch;
const decodedName = decodeURIComponent(name!);
const encodedBundle = await this.loaderMap.getEncodedBundle(type!, decodedName);
Comment on lines +197 to +200
const clientBundle = await fs.promises
.readFile(path.resolve(import.meta.dirname, 'client.js'), 'utf-8')
.then((text) => `const __ROOT_PROPS__ = ${JSON.stringify(props)}; ${text}`);

Comment on lines +44 to +47
fs.watch(target, { recursive: false }, () => {
log(chalk.yellow('↺') + chalk.dim(` [${this.label}] File changed, rebuilding...`));
void this.updateEncodedBundle();
});
Comment on lines +161 to +163
const [, type, name] = instrumentMatch;
const decodedName = decodeURIComponent(name!);
const encodedBundle = await this.loaderMap.getEncodedBundle(type!, decodedName);
Comment on lines +197 to +200
const clientBundle = await fs.promises
.readFile(path.resolve(import.meta.dirname, 'client.js'), 'utf-8')
.then((text) => `const __ROOT_PROPS__ = ${JSON.stringify(props)}; ${text}`);

Comment on lines +44 to +47
fs.watch(target, { recursive: false }, () => {
log(chalk.yellow('↺') + chalk.dim(` [${this.label}] File changed, rebuilding...`));
void this.updateEncodedBundle();
});
Copy link
Copy Markdown
Collaborator

@joshunrau joshunrau left a comment

Choose a reason for hiding this comment

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

We should not be implementing a completely new package for this, with all of the code from serve-instrument copied near verbatim. You should use a subcommand instead so we can reuse the code and it can be maintainable in a single package.

Merges the multi-instrument serving capability directly into
serve-instrument via a new --all CLI flag, instead of a separate
serve-instrument-all package.

With --all, the target directory must contain forms/ and/or interactive/
subdirectories. The server provides:
- An index page linking to all discovered instruments
- Per-instrument pages with hot-rebuild on file change
- An en/fr language switcher
- Verbose request logging

Without --all, the existing single-instrument behavior is preserved.
@gdevenyi gdevenyi force-pushed the serve-instruments-all branch from ab02f81 to d2b92e5 Compare June 2, 2026 15:17
@gdevenyi gdevenyi changed the title Add serve-instrument-all package Add --all mode to serve-instrument package Jun 2, 2026
@gdevenyi
Copy link
Copy Markdown
Contributor Author

gdevenyi commented Jun 2, 2026

We should not be implementing a completely new package for this, with all of the code from serve-instrument copied near verbatim. You should use a subcommand instead so we can reuse the code and it can be maintainable in a single package.

Merged into serve-instrument package instead.

@joshunrau joshunrau merged commit 9c05917 into v2 Jun 5, 2026
1 check 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