Skip to content

Add configurable distribution modes for federation delivery#3044

Draft
pfefferle wants to merge 2 commits intotrunkfrom
add/distribution-mode-setting
Draft

Add configurable distribution modes for federation delivery#3044
pfefferle wants to merge 2 commits intotrunkfrom
add/distribution-mode-setting

Conversation

@pfefferle
Copy link
Member

Fixes #2672

Proposed changes:

  • Add a "Distribution Mode" setting to the Advanced Settings page with four presets: Default (100/batch, 30s pause), Balanced (50/batch, 60s pause), Eco (20/batch, 5min pause), and Custom (manual configuration).
  • Wire the presets into the existing activitypub_dispatcher_batch_size and activitypub_scheduler_async_batch_pause filters so admins can tune federation delivery speed without code.
  • Add ACTIVITYPUB_DISTRIBUTION_MODE constant for wp-config.php override (hides the UI when set).

Other information:

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

Testing instructions:

  • Go to Settings > ActivityPub > Advanced.
  • Verify the "Distribution Mode" setting appears as the first field.
  • Select each mode (Default, Balanced, Eco, Custom) and save — verify the page reloads with the correct selection preserved.
  • Select "Custom", enter custom values for batch size and pause, save — verify the values are preserved.
  • Verify the Custom fields toggle visibility when switching between Custom and other modes.
  • Define ACTIVITYPUB_DISTRIBUTION_MODE as 'eco' in wp-config.php — verify the UI field is hidden and Eco mode values are used.

Changelog entry

  • Automatically create a changelog entry from the details below.
Changelog Entry Details

Significance

  • Patch

Type

  • Added - for new features

Message

Add a Distribution Mode setting to control how quickly posts are delivered to followers.

Adds a "Distribution Mode" setting to the Advanced Settings page with
four presets (Default, Balanced, Eco, Custom) that control batch size
and pause between batches for federation delivery. Includes a constant
override via ACTIVITYPUB_DISTRIBUTION_MODE in wp-config.php.

Fixes #2672
Copilot AI review requested due to automatic review settings March 17, 2026 09:56
@pfefferle pfefferle added the Enhancement New feature or request label Mar 17, 2026
@pfefferle pfefferle self-assigned this Mar 17, 2026
@pfefferle pfefferle requested a review from a team March 17, 2026 09:56
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an admin-configurable “Distribution Mode” that controls federation delivery pacing via existing dispatcher/scheduler filters, with an optional wp-config.php constant override to enforce a mode and hide the UI.

Changes:

  • Adds an Advanced Settings “Distribution Mode” radio field with presets and custom batch/pause inputs.
  • Registers new options and wires delivery pacing into activitypub_dispatcher_batch_size and activitypub_scheduler_async_batch_pause.
  • Adds ACTIVITYPUB_DISTRIBUTION_MODE constant override and a changelog entry.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Description
includes/wp-admin/class-advanced-settings-fields.php Adds the Distribution Mode settings UI, including custom input toggling.
includes/constants.php Defines ACTIVITYPUB_DISTRIBUTION_MODE for wp-config.php overrides.
includes/class-options.php Registers new settings and applies distribution mode to existing delivery pacing filters.
.github/changelog/3044-from-description Records the feature in the changelog.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +33 to +41
if ( ! ACTIVITYPUB_DISTRIBUTION_MODE ) {
\add_settings_field(
'activitypub_distribution_mode',
\__( 'Distribution Mode', 'activitypub' ),
array( self::class, 'render_distribution_mode_field' ),
'activitypub_advanced_settings',
'activitypub_advanced_settings'
);
}
Comment on lines +692 to +698
public static function pre_option_activitypub_distribution_mode( $pre ) {
if ( false !== ACTIVITYPUB_DISTRIBUTION_MODE ) {
return ACTIVITYPUB_DISTRIBUTION_MODE;
}

return $pre;
}
Comment on lines +707 to +723
public static function get_distribution_params() {
$mode = \get_option( 'activitypub_distribution_mode', 'default' );

$modes = array(
'default' => array(
'batch_size' => 100,
'pause' => 30,
),
'balanced' => array(
'batch_size' => 50,
'pause' => 60,
),
'eco' => array(
'batch_size' => 20,
'pause' => 300,
),
);
Comment on lines +745 to +748
public static function filter_dispatcher_batch_size( $batch_size ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found, VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
$params = self::get_distribution_params();
return $params['batch_size'];
}
Comment on lines +759 to +762
public static function filter_scheduler_batch_pause( $pause ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found, VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
$params = self::get_distribution_params();
return $params['pause'];
}
Comment on lines +370 to +380
<script>
( function() {
var radios = document.querySelectorAll( 'input[name="activitypub_distribution_mode"]' );
var fields = document.getElementById( 'activitypub-custom-distribution-fields' );
radios.forEach( function( radio ) {
radio.addEventListener( 'change', function() {
fields.style.display = this.value === 'custom' ? '' : 'none';
} );
} );
} )();
</script>
@pfefferle pfefferle marked this pull request as draft March 17, 2026 10:21
@pfefferle pfefferle marked this pull request as draft March 17, 2026 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement New feature or request [Feature] WP Admin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add configurable distribution modes for federation delivery

3 participants