-
Notifications
You must be signed in to change notification settings - Fork 215
enhance: Add AI text and image enhancer settings to vendor preferences #3051
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughThe vendor preferences REST endpoint now includes two boolean flags, Changes
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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✨ Finishing touches
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ 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)
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.
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
📒 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.
| $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 ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 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 3Repository: 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 -20Repository: 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 -150Repository: 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.phpRepository: 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" -iRepository: 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.phpRepository: 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 -50Repository: 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.phpRepository: 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 10Repository: 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_availabilityoption 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:
- Add a corresponding text availability option for consistency, or
- Remove the image availability check and rely solely on configuration (like text), or
- 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.
…s API
All Submissions:
Changes proposed in this Pull Request:
Related Pull Request(s)
Closes
How to test the changes in this Pull Request:
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:
FOR PR REVIEWER ONLY:
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.