Now let me update the `runDeepAnalysis()` function to use the selected playbook. I need to change all references from `DEEP_ANALYSIS_PASSES` to the playbook's passes.


TodoWrite

Replace DEEP_ANALYSIS_PASSES with DEEP_ANALYSIS_PLAYBOOKS constant (4 playbooks, full prompts)

Replacing DEEP_ANALYSIS_PASSES with DEEP_ANALYSIS_PLAYBOOKS constant

Add playbook dropdown UI + update Deep Analysis button

Update runDeepAnalysis() to use selected playbook

Updating runDeepAnalysis() to use selected playbook

Add initPlaybookDropdown() and call on page load

Update api.php: save_ai_response to persist deep_analysis_playbook field

Update api.php: load_deep_analysis to return playbook info

Updating load_deep_analysis API endpoint

Verify with php -l syntax check


Todos have been modified successfully. Ensure that you continue to use the todo list to track your progress. Please proceed with the current tasks if applicable

Replace DEEP_ANALYSIS_PASSES with DEEP_ANALYSIS_PLAYBOOKS constant (4 playbooks, full prompts)

Replacing DEEP_ANALYSIS_PASSES with DEEP_ANALYSIS_PLAYBOOKS constant

Add playbook dropdown UI + update Deep Analysis button

Update runDeepAnalysis() to use selected playbook

Updating runDeepAnalysis() to use selected playbook

Add initPlaybookDropdown() and call on page load

Update api.php: save_ai_response to persist deep_analysis_playbook field

Update api.php: load_deep_analysis to return playbook info

Updating load_deep_analysis API endpoint

Verify with php -l syntax check

Verify with php -l syntax check


Now I need to update `runDeepAnalysis()`. Let me re-read the current state of the function to get exact line numbers after the edit.


3199:        async function runDeepAnalysis() {


  3199→        async function runDeepAnalysis() {
  3200→            // Validate providers selected
  3201→            var selectedProvidersList = getSelectedProviders();
  3202→            if (selectedProvidersList.length === 0) {
  3203→                alert('Please select at least one AI provider.');
  3204→                return;
  3205→            }
  3206→
  3207→            // Build models map
  3208→            var modelsMap = {};

        async function runDeepAnalysis() {
            // Validate providers selected
            var selectedProvidersList = getSelectedProviders();
            if (selectedProvidersList.length === 0) {
                alert('Please select at least one AI provider.');
                return;
            }

            // Build models map
            var modelsMap = {};


Now I'll update the function. I need to change:
1. Beginning — read selected playbook from dropdown
2. The confirm dialog to show playbook name and pass count
3. The loop to use `passes` variable instead of `DEEP_ANALYSIS_PASSES`
4. The saveAIResponse call to include `deep_analysis_playbook`
5. The progress/completion messages


Edit

        async function runDeepAnalysis() {
            // Validate providers selected
            var selectedProvidersList = getSelectedProviders();
            if (selectedProvidersList.length === 0) {
                alert('Please select at least one AI provider.');
                return;
            }

            // Build models map
            var modelsMap = {};
            selectedProvidersList.forEach(function(provider) {
                var modelSelect = document.getElementById('model_' + provider);
                modelsMap[provider] = modelSelect ? modelSelect.value : '';
            });

            // Confirm with user
            var passNames = DEEP_ANALYSIS_PASSES.map(function(p, i) { return (i+1) + '. ' + p.name; }).join('\n');
            if (!confirm('Run Deep Analysis with ' + selectedProvidersList.length + ' AI provider(s)?\n\n' + passNames + '\n\nThis will run 5 sequential passes. Each pass builds on the previous conversation history.\n\nEstimated time: 3-10 minutes depending on content size and providers.')) {
                return;
            }

        async function runDeepAnalysis() {
            // Get selected playbook
            var playbookKey = document.getElementById('deep-analysis-playbook').value;
            var playbook = DEEP_ANALYSIS_PLAYBOOKS[playbookKey];
            if (!playbook) {
                alert('Please select a playbook from the dropdown.');
                return;
            }
            var passes = playbook.passes;

            // Validate providers selected
            var selectedProvidersList = getSelectedProviders();
            if (selectedProvidersList.length === 0) {
                alert('Please select at least one AI provider.');
                return;
            }

            // Build models map
            var modelsMap = {};
            selectedProvidersList.forEach(function(provider) {
                var modelSelect = document.getElementById('model_' + provider);
                modelsMap[provider] = modelSelect ? modelSelect.value : '';
            });

            // Confirm with user
            var passNames = passes.map(function(p, i) { return (i+1) + '. ' + p.name; }).join('\n');
            if (!confirm('Run "' + playbook.name + '" with ' + selectedProvidersList.length + ' AI provider(s)?\n\n' + passNames + '\n\nThis will run ' + passes.length + ' sequential passes. Each pass builds on the previous conversation history.\n\nEstimated time: 3-10 minutes depending on content size and providers.')) {
                return;
            }