Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions config/sync/ai_content_preparation_wizard.settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ _core:
default_config_hash: CnMDjnwForHi_GT3i_XaQPEufjjthpNa6Wd_HO7_Wws
pandoc_path: /usr/bin/pandoc
max_file_size: 10485760
allowed_extensions:
- txt
- md
- docx
- pdf
default_ai_provider: ''
allowed_extensions: 'txt,md,docx,pdf'
default_ai_provider: amazeeio
default_ai_model: ''
session_timeout: 3600
enable_refinement: true
max_refinement_iterations: 5
document_processors: "pdf|/usr/bin/pdftotext\r\ntxt,md,docx|/usr/bin/pandoc"
enable_logging: false
webpage_processor_mode: basic
webpage_processor_binary: ''
webpage_processor_arguments: '{url}'
webpage_processor_timeout: 30
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,10 @@ ai_content_preparation_wizard.settings:
title: 'Settings'
route_name: ai_content_preparation_wizard.settings
base_route: ai_content_preparation_wizard.settings

# Tab on /admin/content page.
ai_content_preparation_wizard.content_tab:
title: 'Content Preparation Wizard'
route_name: ai_content_preparation_wizard.wizard
base_route: system.admin_content
weight: 10
18 changes: 11 additions & 7 deletions web/modules/custom/ai_content_preparation_wizard/js/async-plan.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,17 @@
}.bind(this));
}

// Enable refinement controls.
var refinementSection = document.getElementById('refinement-section');
if (refinementSection) {
var textarea = refinementSection.querySelector('textarea');
var button = refinementSection.querySelector('input[type="submit"]');
if (textarea) textarea.disabled = false;
if (button) button.disabled = false;
// Enable refinement controls using explicit IDs.
var refinementTextarea = document.getElementById('edit-refinement-textarea');
var regenerateButton = document.getElementById('edit-regenerate-plan');
if (refinementTextarea) {
refinementTextarea.disabled = false;
refinementTextarea.removeAttribute('disabled');
}
if (regenerateButton) {
regenerateButton.disabled = false;
regenerateButton.removeAttribute('disabled');
regenerateButton.classList.remove('is-disabled');
}

// Show and enable navigation buttons.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,16 @@ protected function buildStep1(array &$form, FormStateInterface $form_state): voi
'#attributes' => ['class' => ['wizard-step-content']],
];

$extensions = str_replace(',',' ', $extensions);
$form['step1']['documents'] = [
'#type' => 'managed_file',
'#title' => $this->t('Upload Documents'),
'#description' => $this->t('Drag and drop files here or click to browse. Supported formats: @formats', [
'@formats' => implode(', ', $extensions),
'@formats' => str_replace(',', ' ', $extensions),
]),
'#upload_location' => 'private://ai_content_preparation_wizard',
'#upload_validators' => [
'FileExtension' => ['extensions' => implode(' ', $extensions)],
'FileExtension' => ['extensions' => $extensions],
'FileSizeLimit' => ['fileLimit' => $maxSize],
],
'#multiple' => TRUE,
Expand Down Expand Up @@ -612,6 +613,9 @@ protected function buildStep2(array &$form, FormStateInterface $form_state): voi
'#placeholder' => $this->t('Type instructions to adjust the plan...'),
'#rows' => 3,
'#disabled' => $needsAsyncGeneration,
'#attributes' => [
'id' => 'edit-refinement-textarea',
],
];

$form['step2']['split_layout']['plan_panel']['refinement_section']['regenerate'] = [
Expand All @@ -629,6 +633,9 @@ protected function buildStep2(array &$form, FormStateInterface $form_state): voi
],
'#limit_validation_errors' => [['refinement']],
'#disabled' => $needsAsyncGeneration,
'#attributes' => [
'id' => 'edit-regenerate-plan',
],
];
}
else {
Expand Down Expand Up @@ -1142,6 +1149,9 @@ public function submitStep2(array &$form, FormStateInterface $form_state): void
* Submit handler to regenerate plan.
*/
public function regeneratePlan(array &$form, FormStateInterface $form_state): void {
// Always stay on step 2 when regenerating.
$form_state->set('step', 2);

$refinement = $form_state->getValue('refinement');
if (!$refinement || !$this->planGenerator) {
$this->messenger()->addWarning($this->t('Please enter refinement instructions.'));
Expand Down Expand Up @@ -1177,6 +1187,8 @@ public function regeneratePlan(array &$form, FormStateInterface $form_state): vo
]));
}

// Ensure we stay on step 2 after regeneration.
$form_state->set('step', 2);
$form_state->setRebuild();
}

Expand Down