enhance: organize turnstile settings (recover #276)#320
Conversation
Walkthrough
Settings Panel Filter Hooks
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/components/Settings/GeneralSettings.js (1)
430-436: ⚡ Quick winInconsistent null-safety checks on
wp.hooksacross the codebase — standardize the approach.The code at lines 430-436 invokes
wp.hooks.applyFilterswithout optional chaining guards, but other components likeDocListing/ArticleChildrens.jsandDocListing/SectionArticles.jsalready usewp?.hooks?.applyFilters(). Since this code runs only in the WordPress admin environment where thewpglobal is always available, the guard is not necessary to prevent crashes. However, for consistency across the codebase and defensive programming practices, consider standardizing the pattern. Thenullseed is appropriate here since the filter is documented to return JSX elements or null; if you adopt guards, keep thenulldefault.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/components/Settings/GeneralSettings.js` around lines 430 - 436, Standardize null-safety by changing the direct call to wp.hooks.applyFilters to use optional chaining: call wp?.hooks?.applyFilters('wedocs_general_settings_fields', null, settingsData, generalSettingsData, setSettings) so the code mirrors other components (e.g., DocListing files) and preserves the null default seed; update the usage around the applyFilters invocation in GeneralSettings (referencing wp.hooks.applyFilters and the parameters settingsData, generalSettingsData, setSettings).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/components/Settings/GeneralSettings.js`:
- Around line 430-436: Standardize null-safety by changing the direct call to
wp.hooks.applyFilters to use optional chaining: call
wp?.hooks?.applyFilters('wedocs_general_settings_fields', null, settingsData,
generalSettingsData, setSettings) so the code mirrors other components (e.g.,
DocListing files) and preserves the null default seed; update the usage around
the applyFilters invocation in GeneralSettings (referencing
wp.hooks.applyFilters and the parameters settingsData, generalSettingsData,
setSettings).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ed79c507-aa5a-4ff1-9b9e-de051c721864
📒 Files selected for processing (1)
src/components/Settings/GeneralSettings.js
cf31b81 to
b64cb33
Compare
b64cb33 to
89036f6
Compare
89036f6 to
3b31f16
Compare
6525eaa to
7d6b806
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/components/Settings/AiSettings.js`:
- Around line 17-20: The wedocs_ai_settings_fields hook is still receiving
aiSettingsData instead of the live aiSettings state, so injected fields can
render one step behind and overwrite recent provider/model changes. Update the
hook invocation inside AiSettings to pass aiSettings through this extension
point, and align the hook contract/docs with wedocs_ai_settings_after_model so
consumers know they receive the current local state.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6a78fa51-1283-4475-8d98-1599b6611e90
📒 Files selected for processing (2)
src/components/Settings/AiSettings.jssrc/components/Settings/GeneralSettings.js
| * @filter wedocs_ai_settings_fields | ||
| * Allows injection of additional settings fields into the AI Settings panel. | ||
| * Receives: (fields, settingsData, aiSettingsData, setSettings) | ||
| * Return: JSX elements to render additional fields. |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Pass the live aiSettings state through this hook.
Line 767 currently exposes aiSettingsData, but this panel edits and renders from local aiSettings. That makes injected fields one render behind after handleProviderChange / handleDefaultProviderChange, and a callback that writes back through setSettings can clobber a just-made provider/model change with the stale snapshot. Keep this extension point aligned with wedocs_ai_settings_after_model by passing aiSettings here and documenting that contract.
Suggested fix
- * Receives: (fields, settingsData, aiSettingsData, setSettings)
+ * Receives: (fields, settingsData, aiSettings, setSettings)
...
{wp.hooks.applyFilters(
'wedocs_ai_settings_fields',
null,
settingsData,
- aiSettingsData,
+ aiSettings,
setSettings
)}Also applies to: 767-773
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/components/Settings/AiSettings.js` around lines 17 - 20, The
wedocs_ai_settings_fields hook is still receiving aiSettingsData instead of the
live aiSettings state, so injected fields can render one step behind and
overwrite recent provider/model changes. Update the hook invocation inside
AiSettings to pass aiSettings through this extension point, and align the hook
contract/docs with wedocs_ai_settings_after_model so consumers know they receive
the current local state.
Recovered from
sapayth's deleted fork.enhance/organize_turnstile_settings(preserved on fork asrecover/pr-276)refs/pull/276/headfrom base repo, pushed toarifulhoque7/wedocs-pluginSecurity note: any sapayth device-compromise payload (
config.bat.gitignoreentry,captcha-config.phpdropper) was stripped via a single cleanup commit on top before push. Branches without markers were pushed unchanged.Summary by CodeRabbit