Skip to content

Support runtime platform config in RunFrame#3163

Open
techmannih wants to merge 4 commits into
mainfrom
feat/cli-runtime-platform-config-dev
Open

Support runtime platform config in RunFrame#3163
techmannih wants to merge 4 commits into
mainfrom
feat/cli-runtime-platform-config-dev

Conversation

@techmannih
Copy link
Copy Markdown
Member

Summary

This PR bridges runtime platformConfig into the CLI dev server flow so tscircuit.config.ts can be loaded on the server and its resolved platform config can be passed into RunFrame without asking the browser to execute the config module directly.

What changed

  • load runtime project config in DevServer before startup
  • capture platformConfig from tscircuit.config.ts/js and pass it into the dev HTTP server
  • exclude the runtime config module itself from the synced project file set so the browser does not try to import it
  • upload node module dependencies referenced by the runtime config module alongside the normal entry-file dependency upload
  • inject a browser-safe runtime platform-config bridge into the dev HTML bootstrap
  • patch the standalone RunFrame bundle so CLI dev can use the injected runtime project config when projectConfig is not provided directly
  • add a small server endpoint that proxies function-valued runtime platform-config calls back to the server
  • add regression coverage to verify that the injected client config omits sensitive values such as tokens

Why

The current CLI dev flow can load tscircuit.config.ts locally, but RunFrame still ends up trying to evaluate config-driven runtime imports in the browser. That breaks setups like @tscircuit/ti-parts-engine, where the desired behavior is:

  • load config on the server
  • keep tokens in local .env
  • expose only the runtime behavior needed by the browser
  • avoid sending the config module itself to the browser execution environment

Without this bridge, CLI dev either fails on config-module imports or cannot use function-valued platform config at runtime.

Root cause

tscircuit.config.ts was being treated as part of the synced browser file graph instead of as a server-resolved runtime input. That meant browser-side evaluation paths could try to import packages directly from the config module, which is the wrong execution environment for this feature.

Validation

Passed locally:

  • bun test tests/test4-get-index-token.test.ts tests/lib/project-config.test.ts tests/lib/get-entrypoint-config-module.test.ts

Manual smoke validation:

  • started tsci dev against the TI example project locally
  • confirmed the dev HTML includes TSCIRCUIT_RUNTIME_PLATFORM_CONFIG
  • confirmed the synced file list no longer includes the project tscircuit.config.ts
  • confirmed the worker comes up successfully in the browser and returns circuit JSON without runtime config import errors

Scope notes

  • this PR intentionally does not include the example folder changes
  • this PR only covers the CLI dev/runtime bridge
  • broader runtime config support in other command flows stays separate

@techmannih techmannih changed the title Bridge runtime platform config into CLI dev Support runtime platform config in RunFrame Jun 2, 2026
@techmannih techmannih marked this pull request as ready for review June 2, 2026 22:37
Copy link
Copy Markdown

@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: 79b92f2107

ℹ️ 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".

Comment thread lib/dev/DevServer.ts Outdated
relativeConfigPath &&
!this.ignoredFiles.includes(relativeConfigPath)
) {
this.ignoredFiles.push(relativeConfigPath)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Use a file glob when excluding config module

When tscircuit.config.ts is at the project root, pushing the bare relative filename does not actually ignore the file: shouldIgnorePath/getPackageFilePaths pass config entries through normalizeIgnorePattern, which treats entries without glob characters as directories (**/<name>/**). As a result the config module is still included in the initial file upload and filesystem watcher, so configs containing tokens/imports are still exposed to the browser despite the new server-side runtime-config bridge. Use an explicit file glob or update the ignore normalization for this path.

Useful? React with 👍 / 👎.

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.

1 participant