Skip to content

Preserve class-based API configuration in React options - #215

Open
sylvesterkaczmarek wants to merge 1 commit into
openai:mainfrom
sylvesterkaczmarek:fix/preserve-class-based-api-options
Open

sylvesterkaczmarek wants to merge 1 commit into
openai:mainfrom
sylvesterkaczmarek:fix/preserve-class-based-api-options

Conversation

@sylvesterkaczmarek

Copy link
Copy Markdown

Problem

The React options wrapper recursively copies every object into a plain object, although its equality check already treats non-plain objects by identity. A structurally valid class-based HostedApiConfig consequently loses its prototype getClientSecret method and private state before it reaches the component.

Change

Traverse only plain objects and arrays when creating the latest-function wrappers. Retain other object instances by reference, consistent with the existing comparison policy. Nested functions in plain option objects continue to resolve through the latest options. Add a patch changeset; no dependencies or public types change.

Validation

  • 25 tests passed, including nine new cases. Eight of those fail on unchanged production code; the null-prototype plain-object control passes before and after.
  • The primary reproductions use a class that implements the actual HostedApiConfig interface, with a prototype method and a private field. Tests also cover replacement-instance comparison, surrounding callback updates, and non-plain leaf identity.
  • CI=1 pnpm check passed formatting, lint, type checks, documentation generation, and tests.
  • React ESM, CommonJS, and declaration builds passed. git diff --check passes.

Node 26.8.1 and Vitest 3.2.4 on macOS arm64. Tests exercise the production option-shaping helper with synthetic configurations. No live authentication, hosted ChatKit, or browser session was used. This does not expand the public options schema or change listener timing.

Reproduced against 22613848a656077a408788f028c7727e38d10449.

Signed-off-by: Sylvester Kaczmarek <16242628+sylvesterkaczmarek@users.noreply.github.com>

This branch has not been deployed

No deployments
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