Skip to content

Settings UI for the long-form composition strategy#42

Merged
pfefferle merged 2 commits intoadd/long-form-teaser-threadfrom
add/long-form-composition-setting
Apr 29, 2026
Merged

Settings UI for the long-form composition strategy#42
pfefferle merged 2 commits intoadd/long-form-teaser-threadfrom
add/long-form-composition-setting

Conversation

@pfefferle
Copy link
Copy Markdown
Member

Builds on top of #34. Targeting that branch so the setting is testable end-to-end alongside the strategies. Re-target to trunk once #34 lands.

Proposed changes

  • New Long-form posts field in Settings → ATmosphere, Publishing section. Radio group with three options matching the strategies Long-form teaser-thread strategy + atmosphere_long_form_composition filter #34 introduces:
    • Link card (default) — unchanged from today.
    • Truncated post with link — body text + inline permalink, no card.
    • Teaser thread — two-post hook + CTA-with-link.
  • Stored as atmosphere_long_form_composition. REST schema enumerates the three valid values; sanitize callback falls back to the default for unknown / non-string input.
  • Atmosphere::init() registers a low-priority (priority 1) filter that seeds atmosphere_long_form_composition from the option, leaving the default-priority filter slot open for downstream per-post overrides (FOSSE, custom plugins, etc.).

Other information

  • Have you written new tests for your changes, if applicable?

Testing instructions

  1. After Long-form teaser-thread strategy + atmosphere_long_form_composition filter #34 is merged into this branch, visit Settings → ATmosphere. The new Long-form posts field shows three radio options. Link card is selected by default.
  2. Switch to Teaser thread, save, and publish a long-form post (500+ words, has a title). Confirm two app.bsky.feed.post records land with reply refs.
  3. Add add_filter( 'atmosphere_long_form_composition', fn() => 'truncate-link' ); in a small test plugin while the setting is Teaser thread. Confirm the filter wins.
  4. Manually corrupt the option (update_option( 'atmosphere_long_form_composition', 'bogus' )). Confirm publishing falls back to link-card.
  5. composer lint and npm run env-test pass (5 new tests, 143 total).

Exposes the `atmosphere_long_form_composition` filter as a radio-group
setting in the Publishing section: link-card (default), truncate-link,
or teaser-thread. The setting seeds the filter at priority 1 so any
downstream filter at the default priority can still override it per
post. Sanitize callback rejects unknown values, falling back to the
default.
@pfefferle pfefferle self-assigned this Apr 28, 2026
@github-actions github-actions Bot added [Feature] WP Admin Admin UI and settings [Status] In Progress [Tests] Includes Tests PR includes test changes labels Apr 28, 2026
@pfefferle pfefferle requested a review from kraftbj April 28, 2026 16:26
@pfefferle pfefferle marked this pull request as ready for review April 28, 2026 16:26
Copy link
Copy Markdown
Contributor

@kraftbj kraftbj left a comment

Choose a reason for hiding this comment

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

Reviewed. None of these strike me as blockers — leaving them as suggestions for a follow-up.

Comment thread tests/phpunit/tests/class-test-long-form-composition-setting.php
Comment thread includes/class-atmosphere.php Outdated
Comment thread includes/wp-admin/class-admin.php Outdated
- Extract the strategy slug list to `Atmosphere::LONG_FORM_STRATEGIES`
  and reference it from the REST enum, sanitize allowlist, and the
  render iteration. Translatable labels live in a small private helper
  keyed off the same constant.
- Move the seed callback to a named static method, `Atmosphere::seed_long_form_composition()`,
  so production wiring and tests can register the same callable.
- Log invalid stored values via `error_log()` (rate-limited to once
  per hour with a transient) so operators can spot config drift —
  matches the `error_log` convention in `Transformer\Post` for silent
  strategy downgrades.
- Test class now re-registers the seed in `set_up()` and clears it in
  `tear_down()` so isolation no longer depends on alphabetical ordering
  of test classes that call `remove_all_filters()`.
@kraftbj
Copy link
Copy Markdown
Contributor

kraftbj commented Apr 29, 2026

Thanks! Looks good from here.

@pfefferle pfefferle merged commit 6bd6a32 into add/long-form-teaser-thread Apr 29, 2026
8 checks passed
@pfefferle pfefferle deleted the add/long-form-composition-setting branch April 29, 2026 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] WP Admin Admin UI and settings [Tests] Includes Tests PR includes test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants