Skip to content

fix(swift): make a2uiCatalogs and a2uiDefaultCatalogID publicly read-only - #4273

Closed
pinieb wants to merge 1 commit into
a2ui-project:release-2026-11-16from
pinieb:remediation/issue-4195
Closed

pinieb wants to merge 1 commit into
a2ui-project:release-2026-11-16from
pinieb:remediation/issue-4195

Conversation

@pinieb

@pinieb pinieb commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Note

Stacked on release-2026-11-16 (#4258). This PR will not be submitted until after #4258 merges into main.

Fixes #4195 by making EnvironmentValues.a2uiCatalogs and EnvironmentValues.a2uiDefaultCatalogID read-only (public internal(set)) on the public A2UISwiftUI API surface and removing the deprecated A2UICatalogsKey and A2UIDefaultCatalogIDKey structs, so catalogs are written into the SwiftUI environment only by Surface.

Changes

  1. Mark EnvironmentValues.a2uiCatalogs and EnvironmentValues.a2uiDefaultCatalogID as public internal(set) and remove A2UICatalogsKey and A2UIDefaultCatalogIDKey in A2UICatalogsKey.swift.
  2. Replace direct external EnvironmentValues writes in CatalogImplementationTests.swift, A2UIDividerTests.swift, ModalHost.swift, and RenderedChildrenTests.swift with Surface-hosted views that exercise the public API without @testable import.
  3. Document the breaking public API change in swift/CHANGELOG.md.

Impact & risks

  1. Breaking public API change in A2UISwiftUI (for the upcoming 0.12.0 minor bump): EnvironmentValues.a2uiCatalogs and EnvironmentValues.a2uiDefaultCatalogID are no longer writable outside A2UISwiftUI, and A2UICatalogsKey and A2UIDefaultCatalogIDKey are removed.
  2. Catalog container views (such as A2UIRow, A2UIColumn, and custom catalog implementations across v0.9, v0.9.1, and v1.0 surfaces) continue to read @Environment(\.a2uiCatalogs) and @Environment(\.a2uiDefaultCatalogID). Callers configure catalogs through Surface.init(viewModel:catalogs:defaultCatalogID:) or Surface.makeWithBasicCatalogs(viewModel:).

Testing

  1. swift test --filter A2UISwiftUITests --no-parallel (188 tests in 33 suites passed).
  2. ./scripts/fix_format.sh --check --only-swift and npx prettier@3.8.4 --config .prettierrc --check swift/CHANGELOG.md.

How to inspect or modify this branch locally

To check out and make additional changes to this PR branch:

# Check out the PR branch locally using GitHub CLI
gh pr checkout 4273

# Make your edits, then commit and push back
git commit -am "fix(swift): additional adjustments for #4195"
git push

@pinieb
pinieb force-pushed the remediation/issue-4195 branch from 9f53dcc to b265469 Compare November 17, 2026 16:33

@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 a breaking change by making EnvironmentValues.a2uiCatalogs and EnvironmentValues.a2uiDefaultCatalogID read-only (public internal(set)) and removing the deprecated A2UICatalogsKey and A2UIDefaultCatalogIDKey structs. Consequently, catalogs are now injected exclusively via Surface, and the test suite has been updated to reflect this new pattern. The review feedback suggests improving code readability in several test files by using Swift's raw string literals (#"..."#) instead of escaped double quotes for JSON string instances.

@pinieb
pinieb force-pushed the remediation/issue-4195 branch from 1dad6ae to 84f84ca Compare November 17, 2026 16:58
@pinieb
pinieb marked this pull request as ready for review November 17, 2026 17:04
@josemontespg
josemontespg deleted the branch a2ui-project:release-2026-11-16 November 17, 2026 18:30
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.

[BUG]: SwiftUI EnvironmentValues (a2uiCatalogs and a2uiDefaultCatalogID) should not be publicly writeable

2 participants