Merge subcircuit codegen into the main Circuit processor#2785
Open
stagg wants to merge 2 commits into
Open
Conversation
`@SubCircuitInject` is now handled by the same `circuit-codegen` KSP processor as `@CircuitInject` instead of a separate near-identical processor. The real differences (screen type, factory interfaces, create() signature, function-presenter support, factory naming, UI wrapper) live in a small `CodegenTarget` abstraction; everything else (DI modes, provider hoisting, qualifier/origin propagation, the when(screen) skeleton) is shared. - `CodegenTarget` is a sealed interface with `Circuit`/`SubCircuit` objects capturing the divergences. Pairs with `CodegenMode` (which picks the DI framework). - `CircuitSymbols` loads every runtime type optionally so a subcircuit-only classpath (no circuit-runtime) works. - `CircuitOptions` reads the legacy `subcircuit.codegen.*` keys as fallbacks. - `circuitx-subcircuit-codegen` becomes a Maven relocation pointer to `circuit-codegen` (Gradle module metadata disabled so consumers follow the POM relocation). Old dependencies keep resolving. - SubCircuit processor tests moved into circuit-codegen, plus a test guarding the legacy option-key fallback. circuitCi is green. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
- Guard the @AssistedFactory abstract-function lookup: singleOrNull() + a null-checked return type now emit clean diagnostics instead of an uncaught NoSuchElementException/NPE that failed the KSP round with a raw stacktrace. - Replace the misleading CircuitSymbols.create() try/catch (which only ever caught the eager Modifier load) with an explicit Modifier-presence check, so absent runtime types fail loudly rather than being swallowed. - Add presenterAssistedFactory_metro to cover the Metro @AssistedFactory path, and subCircuitOnly_withoutCircuitRuntimeOnClasspath to pin the lazy single-runtime classpath invariant. - Reword the CHANGELOG "generated output is unchanged" claim; the output is behaviorally equivalent but not textually identical. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
ZacSweers
approved these changes
Jul 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change
@SubCircuitInjectwas handled by a separate, clone of the Circuit KSP processor. This folds it intocircuit-codegenso there's one processor for both annotations.The differences (screen type, factory interfaces,
create()signature, function-presenter support, factory naming, UI wrapper) now live in a smallCodegenTargetsealed interface withCircuit/SubCircuitobjects.Notable bits
CircuitSymbolsloads every runtime type lazily. Circuit and SubCircuit runtimes are independent, so a subcircuit-only consumer won't have circuit-runtime on the classpath. OnlyModifieris required (always present via compose-ui); circuit types are only touched byCodegenTarget.Circuit.circuitx-subcircuit-codegenbecomes a Maven relocation pointer tocircuit-codegen.CircuitOptionsreads the legacysubcircuit.codegen.*keys as fallbacks so existing KSP args don't silently drop to the default mode.🤖 Generated with Claude Code