Skip to content

fix: onelog connection - #198

Draft
Kallyan01 wants to merge 6 commits into
mainfrom
fix/onelog-connection
Draft

Kallyan01 wants to merge 6 commits into
mainfrom
fix/onelog-connection

Conversation

@Kallyan01

@Kallyan01 Kallyan01 commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

What

Why

Related Issue(s):

How

AI Disclosure

Testing Instructions

Screenshots

Additional Info

Checklist

  • I have read the Contribution Guidelines.
  • I have read the Development Guidelines.
  • I have added necessary tests to cover my changes.
  • I have updated the project documentation as needed.
  • My code has detailed inline documentation.
  • My code is tested to the best of my abilities.
  • My code passes all lints, tests, and checks.
Open WordPress Playground Preview

Copilot AI balanced review requested due to automatic review settings November 11, 2026 08:13
@Kallyan01
Kallyan01 added this pull request to stack #200 November 11, 2026 08:15
@codecov-commenter

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Critical issues exclude the plugin from fresh development environments, accept HTTP 200 without validating connection acknowledgement, and leave orphaned remote connections after URL changes or failed batches.

4 open issues
What changed in this PR

This PR reworks OneLogs connections between governing and brand sites, moving cross-site requests to the server and updating the settings and logs interfaces.

Changes:

  • Introduces dedicated connection controllers and a shared remote client, keeping stored brand-site keys out of browser responses.
  • Updates settings and logs screens to use WordPress apiFetch, normalized URLs, and clearer failure messages.
  • Expands PHP and JavaScript coverage and adjusts plugin startup and development configuration.
File Description
webpack.config.js Uses the TypeScript settings entry point.
tests/​phpunit/​TestCase.php Adds REST server and HTTP mocking helpers.
tests/​phpunit/​Integration/​UtilsTest.php Tests URL normalization and site identity.
tests/​phpunit/​Integration/​Modules/​Settings/​SettingsTest.php Tests key privacy and shared-site management.
tests/​phpunit/​Integration/​Modules/​Rest/​Shared_Sites_ControllerTest.php Covers brand-site validation, saving, and deletion.
tests/​phpunit/​Integration/​Modules/​Rest/​Logs_REST_ControllerTest.php Covers log permissions and remote retrieval.
tests/​phpunit/​Integration/​Modules/​Rest/​Governing_Site_ControllerTest.php Covers connection, disconnection, and key regeneration.
tests/​phpunit/​Integration/​Modules/​Core/​RestTest.php Removes tests for the deleted CORS module.
tests/​phpunit/​Integration/​Modules/​Core/​AssetsTest.php Verifies localized data excludes stored brand keys.
tests/​js/​utils.test.ts Tests URL helpers, errors, and localized constants.
tests/​js/​tsconfig.json Removes the test-specific base URL override.
tests/​js/​SiteTable.test.tsx Tests masked keys and blank-key editing.
tests/​js/​SiteSettings.test.tsx Updates API mocks and connection feedback coverage.
tests/​js/​SiteModal.test.tsx Covers validation and server-managed saves.
tests/​js/​setup.ts Updates localized fixtures and console types.
tests/​js/​SettingsPage.test.tsx Adds settings save, deletion, and notice coverage.
tests/​js/​OnboardingScreen.test.tsx Updates the typed settings fixture.
tests/​js/​LogsDashboard.test.tsx Tests remote logs and error recovery.
tests/​js/​apiService.test.ts Tests request parameters and response handling.
onelogs.php Defers initialization until plugins have loaded.
inc/​Utils.php Adds URL normalization, site identity, and debug logging.
inc/​Modules/​Settings/​Settings.php Hides keys from REST settings and adds site helpers.
inc/​Modules/​Rest/​Shared_Sites_Controller.php Adds server-side brand-site saving and deletion.
inc/​Modules/​Rest/​Secret_Key_Controller.php Adds a dedicated key-regeneration route.
inc/​Modules/​Rest/​Remote_Client.php Centralizes authenticated cross-site requests.
inc/​Modules/​Rest/​Logs_REST_Controller.php Updates permissions, remote retrieval, and data handling.
inc/​Modules/​Rest/​Governing_Site_Controller.php Adds governing-site connection and disconnection routes.
inc/​Modules/​Rest/​Brand_Site_Controller.php Lets brand sites deregister themselves.
inc/​Modules/​Rest/​Basic_Options_Controller.php Removes the combined settings controller.
inc/​Modules/​Rest/​Abstract_REST_Controller.php Adds shared authentication and remote-error helpers.
inc/​Modules/​Core/​Rest.php Removes custom browser CORS header handling.
inc/​Modules/​Core/​Assets.php Updates localized data and asset metadata loading.
inc/​Main.php Registers the dedicated REST controllers.
assets/​src/​types/​global.d.ts Defines shared localized-data types.
assets/​src/​js/​utils.ts Adds URL normalization and error extraction.
assets/​src/​js/​constants.ts Reads the revised localized configuration.
assets/​src/​components/​SiteTable.tsx Masks keys and initializes blank-key edits.
assets/​src/​components/​SiteSettings.tsx Uses apiFetch and improves connection feedback.
assets/​src/​components/​SiteModal.tsx Validates edits and delegates connection checks to the server.
assets/​src/​admin/​settings/​page.tsx Adds typed settings state and server-backed operations.
assets/​src/​admin/​settings/​index.tsx Mounts the extracted settings component.
assets/​src/​admin/​settings/​index.js Removes the previous JavaScript settings implementation.
assets/​src/​admin/​onboarding/​page.tsx Uses WordPress-provided API middleware.
assets/​src/​admin/​onboarding/​index.tsx Removes duplicate global type declarations.
assets/​src/​admin/​logs/​types.ts Reuses shared site types without API keys.
assets/​src/​admin/​logs/​components/​LogsDashboard.tsx Clears stale results and displays server errors.
assets/​src/​admin/​logs/​components/​FiltersPanel.tsx Reads the localized site type.
assets/​src/​admin/​logs/​apiService.ts Simplifies local API requests and remote-site parameters.
.wp-env.json Removes the repository from the environment’s plugin list.

Review effort: Balanced

Comment thread .wp-env.json Resolved
Comment on lines +143 to +144
if ( 200 === $code ) {
return true;
Comment on lines +140 to +141
if ( is_wp_error( $checked ) ) {
return $this->remote_error_response( $checked );
}
}

Settings::set_shared_sites( $sites );
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 11, 2026 08:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Critical validation and connection-lifecycle flaws can erase configured sites, falsely report successful connections, and leave remote sites connected without corresponding local records.

4 open issues
1 previously missed issue

In code that hasn't changed since last review

Medium severity Ignore stale log request completions

assets/​src/​admin/​logs/​components/​LogsDashboard.tsx:76

Please ignore stale request completions before clearing the logs. If a slow brand-site request is pending, the user switches back to the governing site, and that site's logs load successfully, a later failure from the old brand-site request executes this block and erases the current logs while showing the old site's error. Track a request generation or cancel superseded requests, and guard both success and failure state updates.

1 resolved since last review

Review effort: Balanced

*/
public function set_shared_sites( WP_REST_Request $request ): WP_REST_Response|\WP_Error {
$sites_data = $request->get_param( 'sites_data' );
$sites_data = is_array( $sites_data ) ? array_values( array_filter( $sites_data, 'is_array' ) ) : [];
@Kallyan01
Kallyan01 marked this pull request as draft November 11, 2026 16:59
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.

3 participants