Skip to content

feat(angular): add provideA2Ui helper for idiomatic renderer configuration#2061

Open
josemontespg wants to merge 6 commits into
a2ui-project:mainfrom
josemontespg:agent/wt_d95e3868
Open

feat(angular): add provideA2Ui helper for idiomatic renderer configuration#2061
josemontespg wants to merge 6 commits into
a2ui-project:mainfrom
josemontespg:agent/wt_d95e3868

Conversation

@josemontespg

Copy link
Copy Markdown
Collaborator

What

Introduces the provideA2Ui helper function to configure the root A2UI settings using Angular's standalone APIs (EnvironmentProviders, makeEnvironmentProviders).
It also updates the A2uiRendererService unit tests to use this new helper.

Why

Improves developer experience by replacing verbose provider configurations with a single, clean function call, aligning with modern, idiomatic Angular 14+ patterns.
Resolves: #2003

Effect

Allows configuring A2UI in bootstrapApplication like this:

bootstrapApplication(AppComponent, {
  providers: [
    provideA2Ui({
      catalogs: [BasicCatalog],
    }),
  ]
});

It is 100% backwards compatible as the manual token provision continues to function.

@josemontespg josemontespg left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Adversarial Reviewer Objections:

  1. Missing Documentation Update: The setup guide docs/public/guides/client-setup.md still shows the verbose setup using A2UI_RENDERER_CONFIG directly. It should be updated to use the new provideA2Ui helper.

  2. Inflexible API (Suggestion): The provideA2Ui helper in renderers/angular/src/v0_9/core/a2ui-renderer.service.ts only supports static configuration values (useValue). In many real-world scenarios (like in the restaurant sample), the configuration requires injecting other services (e.g., to handle actions).

To make provideA2Ui more versatile, please consider supporting factory functions:

export function provideA2Ui(
  configOrFactory: RendererConfiguration | (() => RendererConfiguration)
): EnvironmentProviders {
  return makeEnvironmentProviders([
    {
      provide: A2UI_RENDERER_CONFIG,
      ...(typeof configOrFactory === 'function'
        ? { useFactory: configOrFactory }
        : { useValue: configOrFactory }),
    },
  ]);
}

This will allow us to clean up the samples as well.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the provideA2Ui helper function to configure the A2UI renderer using Angular's environment providers, along with corresponding unit tests. The feedback suggests enhancing the unit tests to verify that A2uiRendererService can be successfully resolved and instantiated when using this provider helper, ensuring a more robust integration test.

Comment thread renderers/angular/src/v0_9/core/a2ui-renderer.service.spec.ts Outdated

@josemontespg josemontespg left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Adversarial review passed. The implementation matches the approved design and successfully simplifies the configuration API while maintaining backward compatibility. Tests passed. (Note: Unable to approve via API as it is detected as own PR)

Comment thread .prettierignore
@josemontespg
josemontespg requested a review from ditman July 21, 2026 23:30

@ditman ditman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I like this very much, thanks for tackling it so quickly!

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.

Angular Renderer: Idiomatic Framework Use

2 participants