Skip to content

Conversation

@kzamanbd
Copy link
Contributor

@kzamanbd kzamanbd commented Dec 29, 2025

…s API

All Submissions:

  • My code follow the WordPress' coding standards
  • My code satisfies feature requirements
  • My code is tested
  • My code passes the PHPCS tests
  • My code has proper inline documentation
  • I've included related pull request(s) (optional)
  • I've included developer documentation (optional)
  • I've added proper labels to this pull request

Changes proposed in this Pull Request:

Related Pull Request(s)

  • Full PR Link

Closes

How to test the changes in this Pull Request:

  • Steps or issue link

Changelog entry

Title

Detailed Description of the pull request. What was previous behaviour
and what will be changed in this PR.

Before Changes

Describe the issue before changes with screenshots(s).

After Changes

Describe the issue after changes with screenshot(s).

Feature Video (optional)

Link of detailed video if this PR is for a feature.

PR Self Review Checklist:

  • Code is not following code style guidelines
  • Bad naming: make sure you would understand your code if you read it a few months from now.
  • KISS: Keep it simple, Sweetie (not stupid!).
  • DRY: Don't Repeat Yourself.
  • Code that is not readable: too many nested 'if's are a bad sign.
  • Performance issues
  • Complicated constructions that need refactoring or comments: code should almost always be self-explanatory.
  • Grammar errors.

FOR PR REVIEWER ONLY:

As a reviewer, your feedback should be focused on the idea, not the person. Seek to understand, be respectful, and focus on constructive dialog.

As a contributor, your responsibility is to learn from suggestions and iterate your pull request should it be needed based on feedback. Seek to collaborate and produce the best possible contribution to the greater whole.

  • Correct — Does the change do what it’s supposed to? ie: code 100% fulfilling the requirements?
  • Secure — Would a nefarious party find some way to exploit this change? ie: everything is sanitized/escaped appropriately for any SQL or XSS injection possibilities?
  • Readable — Will your future self be able to understand this change months down the road?
  • Elegant — Does the change fit aesthetically within the overall style and architecture?

Summary by CodeRabbit

  • New Features
    • Vendor preferences endpoint now exposes two read-only boolean fields — ai_text_enable and ai_image_enable — indicating whether text-based and image-based AI features are currently enabled for the vendor. These values provide visibility into which AI capabilities are active in the account configuration.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 29, 2025

📝 Walkthrough

Walkthrough

The vendor preferences REST endpoint now includes two boolean flags, ai_text_enable and ai_image_enable, computed at runtime via the Intelligence Manager/Model and returned in the /vendor-dashboard/preferences response and schema.

Changes

Cohort / File(s) Summary
AI Preference Exposure
includes/REST/VendorDashboardController.php
Added imports WeDevs\Dokan\Intelligence\Manager and WeDevs\Dokan\Intelligence\Services\Model. get_preferences() now queries Manager/Model to set ai_text_enable and ai_image_enable and returns them. get_preferences_schema() now declares these two read-only boolean properties.

Sequence Diagram(s)

sequenceDiagram
  participant Client as Mobile/Web Client
  participant REST as VendorDashboardController (REST)
  participant Manager as Intelligence Manager
  participant Model as Intelligence Model
  Note over REST,Manager: New runtime checks for AI enablement

  Client->>REST: GET /dokan/v1/vendor-dashboard/preferences
  REST->>Manager: request AI config state
  Manager->>Model: query text/image enable flags
  Model-->>Manager: { text: bool, image: bool }
  Manager-->>REST: { ai_text: bool, ai_image: bool }
  REST-->>Client: preferences + ai_text_enable, ai_image_enable
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

Dependency With Pro, Needs: Testing

Suggested reviewers

  • mrabbani

Poem

🐰 I nibble code beneath the moon,
Two tiny flags will sing real soon,
Text and image, true or false they say,
Mobile vendors will know the way. ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Description check ❓ Inconclusive The PR description contains a filled-out template with a linked issue reference (#1375), but critical sections like 'Changes proposed,' 'How to test,' and 'Changelog entry' lack substantive details. Expand 'Changes proposed' to describe the implementation details, provide concrete test steps, and complete the changelog entry with before/after behavior description.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding AI text and image enhancer settings to vendor preferences API.
Linked Issues check ✅ Passed The changes add ai_text_enable and ai_image_enable boolean fields to the /preferences endpoint response, directly fulfilling the requirement to expose AI Assist enable/disable settings [#1375].
Out of Scope Changes check ✅ Passed All code changes are scoped to the vendor preferences API endpoint to expose public, non-sensitive AI configuration flags, with no extraneous modifications detected.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fdafa4a and 506e9b2.

📒 Files selected for processing (1)
  • includes/REST/VendorDashboardController.php
🚧 Files skipped from review as they are similar to previous changes (1)
  • includes/REST/VendorDashboardController.php
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: api tests (1, 1)
  • GitHub Check: e2e tests (1, 3)
  • GitHub Check: e2e tests (3, 3)
  • GitHub Check: e2e tests (2, 3)

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@kzamanbd kzamanbd self-assigned this Dec 29, 2025
@kzamanbd kzamanbd requested a review from mrabbani December 29, 2025 10:11
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
includes/REST/VendorDashboardController.php (1)

598-609: Consider clarifying schema descriptions.

The descriptions use imperative phrasing ("Enable product ai text enhancer") which could be misinterpreted as an action rather than a state indicator. Consider rephrasing to be more descriptive:

  • "Whether AI-powered text generation is enabled and configured for products"
  • "Whether AI-powered image enhancement is enabled and configured for products"
🔎 Proposed refinement
                'ai_text_enable'    => [
-                   'description' => esc_html__( 'Enable product ai text enhancer.', 'dokan-lite' ),
+                   'description' => esc_html__( 'Whether AI text generation is enabled and configured.', 'dokan-lite' ),
                    'type'        => 'boolean',
                    'context'     => [ 'view' ],
                    'readonly'    => true,
                ],
                'ai_image_enable'    => [
-                   'description' => esc_html__( 'Enable product ai image enhancer.', 'dokan-lite' ),
+                   'description' => esc_html__( 'Whether AI image enhancement is enabled and configured.', 'dokan-lite' ),
                    'type'        => 'boolean',
                    'context'     => [ 'view' ],
                    'readonly'    => true,
                ],
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9a44aa3 and fdafa4a.

📒 Files selected for processing (1)
  • includes/REST/VendorDashboardController.php
🧰 Additional context used
🧬 Code graph analysis (1)
includes/REST/VendorDashboardController.php (2)
includes/Intelligence/Services/Model.php (1)
  • Model (9-205)
includes/Intelligence/Manager.php (1)
  • is_configured (49-67)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: e2e tests (2, 3)
  • GitHub Check: e2e tests (1, 3)
  • GitHub Check: e2e tests (3, 3)
  • GitHub Check: api tests (1, 1)
🔇 Additional comments (2)
includes/REST/VendorDashboardController.php (2)

419-420: Response fields correctly structured.

The new fields expose boolean flags without leaking sensitive information (API keys, secrets), which aligns with the security requirements stated in the PR objectives.


10-11: The imports on lines 10-11 are correct and necessary. The Intelligence module is registered unconditionally in the core ServiceProvider, so Manager and Model classes are always available via the DI container. No defensive checks or error handling are needed—the current implementation is safe.

Likely an incorrect or invalid review comment.

Comment on lines +385 to +388
$is_enabled = dokan_get_option( 'dokan_ai_image_gen_availability', 'dokan_ai', 'off' ) === 'on';
$manager = dokan()->get_container()->get( Manager::class );
$is_text_configured = $manager->is_configured();
$is_image_configured = $is_enabled && $manager->is_configured( Model::SUPPORTS_IMAGE );
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for text generation availability options in codebase

echo "=== Searching for text-related availability options ==="
rg -n "dokan_ai.*text.*availability" -i

echo ""
echo "=== Searching for all dokan_ai availability options ==="
rg -n "dokan_ai_.*_availability" -A 1 -B 1

echo ""
echo "=== Searching for image/text gen availability definitions ==="
rg -n "dokan_ai.*gen_availability" -A 3 -B 3

Repository: getdokan/dokan

Length of output: 1346


🏁 Script executed:

#!/bin/bash
# Find the Manager class implementation
echo "=== Finding Manager class location ==="
fd -n "Manager.php" | head -20

echo ""
echo "=== Search for is_configured method implementation ==="
rg -n "is_configured" -A 5 -B 2 | head -100

echo ""
echo "=== Search for how text AI is controlled ==="
rg -n "text.*configured\|text.*availability\|text_gen" -i -B 2 -A 2 | head -80

echo ""
echo "=== Search admin settings for AI features ==="
rg -n "dokan_ai" -l | head -20

Repository: getdokan/dokan

Length of output: 3157


🏁 Script executed:

#!/bin/bash
# Read Manager class is_configured method
echo "=== Manager::is_configured() implementation ==="
sed -n '49,80p' includes/Intelligence/Manager.php

echo ""
echo "=== Check for availability option definitions in Settings.php ==="
cat includes/Intelligence/Admin/Settings.php | head -150

Repository: getdokan/dokan

Length of output: 6251


🏁 Script executed:

#!/bin/bash
# Search for where image availability option is defined and used
echo "=== Where is dokan_ai_image_gen_availability defined/set? ==="
rg -n "dokan_ai_image_gen_availability" -B 5 -A 5

echo ""
echo "=== Check if there's any documentation or comments about this asymmetry ==="
rg -n "image.*availability\|availability.*image" -i -B 2 -A 2

echo ""
echo "=== Check git history or comments around line 385-388 ==="
sed -n '375,395p' includes/REST/VendorDashboardController.php

Repository: getdokan/dokan

Length of output: 2420


🏁 Script executed:

#!/bin/bash
# Check if the image availability option is ever SET anywhere
echo "=== Is dokan_ai_image_gen_availability ever SET in the codebase? ==="
rg -n "dokan_ai_image_gen_availability" 

echo ""
echo "=== Search for any migrations, setup, or initialization of this option ==="
rg -n "image_gen_availability\|option.*image\|set.*option.*image" -i | head -30

echo ""
echo "=== Check if there are any settings definitions for image availability ==="
cat includes/Intelligence/Admin/Settings.php | grep -n "image\|availability" -i

Repository: getdokan/dokan

Length of output: 518


🏁 Script executed:

#!/bin/bash
# Check if there are any image-related AI settings that might be defined elsewhere
echo "=== Search for image generation in entire codebase ==="
rg -n "image.*gen\|SUPPORTS_IMAGE" -B 2 -A 2 | head -100

echo ""
echo "=== Check REST API request controller to see how image is handled ==="
sed -n '1,50p' includes/Intelligence/REST/AIRequestController.php

Repository: getdokan/dokan

Length of output: 1394


🏁 Script executed:

#!/bin/bash
# Check what the default value means and search for any feature flags
echo "=== Check if there are any comments about image feature being disabled ==="
rg -n "image\|SUPPORTS_IMAGE" includes/Intelligence/ -B 3 -A 3

echo ""
echo "=== Check Model class to see what SUPPORTS_IMAGE is ==="
grep -n "SUPPORTS_IMAGE\|SUPPORTS_TEXT" includes/Intelligence/Services/Model.php | head -20

echo ""
echo "=== Search entire codebase for references to the availability option being set ==="
git log -p --all -S "dokan_ai_image_gen_availability" -- | head -50

Repository: getdokan/dokan

Length of output: 670


🏁 Script executed:

#!/bin/bash
# Check if the option might be set via filters or hooks
echo "=== Search for apply_filters or do_action related to AI settings ==="
rg -n "apply_filters.*dokan_ai\|do_action.*dokan_ai" -B 2 -A 2

echo ""
echo "=== Check if there's a dedicated settings panel or filter for image availability ==="
rg -n "image.*availability\|availability.*image" -i

echo ""
echo "=== Verify what happens when image_gen_availability is 'off' (default) ==="
sed -n '383,410p' includes/REST/VendorDashboardController.php

Repository: getdokan/dokan

Length of output: 2269


🏁 Script executed:

#!/bin/bash
# Final check: look for any filter that might set this option
echo "=== Search for any update_option or settings saving related to image ==="
rg -n "update_option.*dokan_ai\|dokan_get_option.*dokan_ai" -B 2 -A 2 | grep -i image

echo ""
echo "=== Check if there's a settings form or admin page that handles image ==="
fd "settings\|admin" -e php | xargs grep -l "dokan_ai_image" 2>/dev/null

echo ""
echo "=== Final check: Is there any conditional logic that sets this option ==="
rg -n "dokan_ai_image_gen_availability" --context 10

Repository: getdokan/dokan

Length of output: 2347


Image AI feature gating is incomplete and disabled by default, creating inconsistent behavior.

The asymmetry between text and image AI features is real and more problematic than initially apparent:

  • Text AI: Enabled if API key is configured (no availability toggle exists)
  • Image AI: Has a dokan_ai_image_gen_availability option that defaults to 'off', but this option is never set anywhere in the codebase and has no admin UI to enable it

The image availability option is hardcoded to default to 'off' with no mechanism to change it, effectively disabling image generation entirely. Either:

  1. Add a corresponding text availability option for consistency, or
  2. Remove the image availability check and rely solely on configuration (like text), or
  3. Complete the image availability feature by adding admin settings to control it
🤖 Prompt for AI Agents
In includes/REST/VendorDashboardController.php around lines 385 to 388, the
image AI availability is hardcoded to an unused option defaulting to 'off',
which disables image generation; remove the dokan_get_option gating and instead
determine image capability directly from the manager configuration so image
support mirrors text behavior—set $is_image_configured by calling
$manager->is_configured(Model::SUPPORTS_IMAGE) (or, if you prefer parity the
other way, introduce a corresponding text availability option and admin
setting), update any related logic to rely only on manager.is_configured for
feature availability, and remove dead code referencing
dokan_ai_image_gen_availability.

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