Skip to content

Fix - incremental setup dependency - #2

Merged
AkshayChordiya merged 1 commit into
AkshayChordiya:mainfrom
jordond:fix/incremental-setup-dependency
Aug 14, 2026
Merged

AkshayChordiya merged 1 commit into
AkshayChordiya:mainfrom
jordond:fix/incremental-setup-dependency

Conversation

@jordond

@jordond jordond commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Editing any composable makes Pose regenerate every preview in the module without its theme, warning PG024, until the next clean build.

getSymbolsWithAnnotation only returns symbols from KSP's dirty file set. Nothing in user source connects a composable to the config object. That edge only exists in the code Pose emits, as AppPose.Theme { ... }. So on any round that didn't touch the config file, the processor couldn't see it and took the no-config path.

Generated previews now declare the setup object's file as a Dependencies source alongside their own, which keeps it in the dirty set:

val sources = listOfNotNull(containingFile, setupFile).distinct()
Dependencies(aggregating = false, *sources.toTypedArray())

I tried aggregating = true first. It doesn't work: only declared sources land in the dirty set, so you regenerate more files and still lose the theme. Previews stay isolating and incremental cost is unchanged.

Parameter types, sealed subtypes and PreviewParameterProvider classes don't need the same treatment. They're all named in user source, so Kotlin already dirties the composable when they change. I reproduced both to check.

To reproduce: put @PoseSetup in its own file, build, add a comment to any @Pose composable, build again.

Note

I was going to add tests, but wanted to keep the diff only related to the fix.

Repro and tests needs two compilations and CompileHarness is one-shot, so covering it means a TestKit source set. I have that working on a branch if you want it as a follow-up.

Edit any composable, rebuild, and every preview in the module comes back unthemed
with a `PG024`, even though the `@PoseSetup` object is right there and untouched.
Clean build fixes it until the next edit.

`getSymbolsWithAnnotation` only returns symbols from KSP's dirty file set. Nothing
in user source connects a composable to the config object. That edge only exists
in the code Pose emits, as `AppPose.Theme { ... }`. So on any round that didn't
touch the config file, the processor couldn't see it and took the no-config path.

Generated previews now declare the setup object's file as a `Dependencies` source
alongside their own, which keeps it in the dirty set:

```kotlin
val sources = listOfNotNull(containingFile, setupFile).distinct()
Dependencies(aggregating = false, *sources.toTypedArray())
```

I tried `aggregating = true` first. It doesn't work: only declared sources land in
the dirty set, so you regenerate more files and still lose the theme. Previews stay
isolating and incremental cost is unchanged.

Parameter types, sealed subtypes and `PreviewParameterProvider` classes don't need
the same treatment. They're all named in user source, so Kotlin already dirties the
composable when they change. I reproduced both to check.

To reproduce: put `@PoseSetup` in its own file, build, add a comment to any `@Pose`
composable, build again.

No tests in this PR, to keep the diff to the fix. Repro needs two compilations and
`CompileHarness` is one-shot, so covering it means a TestKit source set. I have that
working on a branch if you want it as a follow-up.
@AkshayChordiya
AkshayChordiya self-requested a review August 14, 2026 15:44
@AkshayChordiya

Copy link
Copy Markdown
Owner

Great find and thank you so much for the fix, will merge it in!

@AkshayChordiya
AkshayChordiya merged commit 73c66fb into AkshayChordiya:main Aug 14, 2026
1 check passed
@jordond
jordond deleted the fix/incremental-setup-dependency branch August 14, 2026 19:45
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