Skip to content

Merge subcircuit codegen into the main Circuit processor#2785

Open
stagg wants to merge 2 commits into
mainfrom
j-merge-subcircuit-codegen
Open

Merge subcircuit codegen into the main Circuit processor#2785
stagg wants to merge 2 commits into
mainfrom
j-merge-subcircuit-codegen

Conversation

@stagg

@stagg stagg commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Change

@SubCircuitInject was handled by a separate, clone of the Circuit KSP processor. This folds it into circuit-codegen so 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 small CodegenTarget sealed interface with Circuit/SubCircuit objects.

Notable bits

  • Most of the PR size is from deleting the existing subcircuit codegen, and a very big test that mirrors the Circuit processor test
  • CircuitSymbols loads every runtime type lazily. Circuit and SubCircuit runtimes are independent, so a subcircuit-only consumer won't have circuit-runtime on the classpath. Only Modifier is required (always present via compose-ui); circuit types are only touched by CodegenTarget.Circuit.
  • circuitx-subcircuit-codegen becomes a Maven relocation pointer to circuit-codegen.
  • CircuitOptions reads the legacy subcircuit.codegen.* keys as fallbacks so existing KSP args don't silently drop to the default mode.

🤖 Generated with Claude Code

stagg and others added 2 commits July 8, 2026 16:21
`@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>
@stagg stagg marked this pull request as ready for review July 9, 2026 16:55
@stagg stagg requested a review from ZacSweers July 9, 2026 16:55
@stagg stagg enabled auto-merge July 10, 2026 17:21
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