refactor: refactor client-bridge to support multiple instances and namespaces#1235
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5362d8f729
ℹ️ 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".
| ): Promise<ClientBridge<T>> { | ||
| const needsCompatLib = opts?.needsCompatLib ?? false; | ||
| const scriptFileName = needsCompatLib ? "bundle.compat.js" : "bundle.native.js"; | ||
| const scriptFilePath = path.join(__dirname, "..", "client-scripts", namespace, "build", scriptFileName); |
There was a problem hiding this comment.
Read bundles from the actual build output path
ClientBridge.create now resolves bundles via client-scripts/<namespace>/build/<bundle>, but the build pipeline in this commit still writes bundles directly to build/src/browser/client-scripts/<bundle> (src/browser/client-scripts/build.js:53-64). Because no namespaced bundle directories are produced, fs.promises.readFile(scriptFilePath) will hit ENOENT for any namespace and prevent client bridge initialization.
Useful? React with 👍 / 👎.
|
|
||
| private _clientMethodCommand<K extends keyof T>(name: K, args: Parameters<T[K]>): string { | ||
| const params = args.map(arg => (arg !== undefined ? JSON.stringify(arg) : "undefined")).join(", "); | ||
| const call = `__geminiCore['${this._namespace}'].${String(name)}(${params})`; |
There was a problem hiding this comment.
Call the same __geminiCore shape that injected scripts expose
Bridge calls are now emitted as __geminiCore['<namespace>'].method(...), but the injected client script in this commit still exports to flat window.__geminiCore (src/browser/client-scripts/index.js:10-14) and does not create per-namespace objects. That makes the guard treat every call as “not injected”, retry once, and then throw, so browser-side commands fail even after successful script injection.
Useful? React with 👍 / 👎.
What's done?
Refactored client-bridge to support the following:
Client scripts refactor comes in the PRs that follow.