Skip to content

refactor: refactor client-bridge to support multiple instances and namespaces#1235

Open
shadowusr wants to merge 1 commit intousers/shadowusr/TESTPLANE-672.update-composite-image-rendererfrom
users/shadowusr/TESTPLANE-886
Open

refactor: refactor client-bridge to support multiple instances and namespaces#1235
shadowusr wants to merge 1 commit intousers/shadowusr/TESTPLANE-672.update-composite-image-rendererfrom
users/shadowusr/TESTPLANE-886

Conversation

@shadowusr
Copy link
Copy Markdown
Member

What's done?

Refactored client-bridge to support the following:

  • Multiple instances of client-bridge can now operate independently
  • Multiple client-bridges correspond to namespace'd client-scripts

Client scripts refactor comes in the PRs that follow.

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: 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);
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 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})`;
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 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 👍 / 👎.

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.

2 participants