diff --git a/src/web/public/app.js b/src/web/public/app.js index 0ece7ac8..1145660b 100644 --- a/src/web/public/app.js +++ b/src/web/public/app.js @@ -1302,20 +1302,60 @@ class ClaudemanApp { respawnSection.style.display = 'none'; } + // Reset duration presets to default (unlimited) + this.selectDurationPreset(''); + document.getElementById('sessionOptionsModal').classList.add('active'); // Focus the name input setTimeout(() => document.getElementById('sessionNameInput').focus(), 100); } + // Handle duration preset selection + selectDurationPreset(value) { + // Remove active from all buttons + document.querySelectorAll('.duration-preset-btn').forEach(btn => btn.classList.remove('active')); + + // Find and activate the clicked button + const btn = document.querySelector(`.duration-preset-btn[data-minutes="${value}"]`); + if (btn) btn.classList.add('active'); + + // Show/hide custom input + const customInput = document.querySelector('.duration-custom-input'); + const durationInput = document.getElementById('modalRespawnDuration'); + + if (value === 'custom') { + customInput.classList.add('visible'); + durationInput.focus(); + } else { + customInput.classList.remove('visible'); + durationInput.value = ''; // Clear custom value when using preset + } + } + + // Get selected duration from preset buttons or custom input + getSelectedDuration() { + const customInput = document.querySelector('.duration-custom-input'); + const durationInput = document.getElementById('modalRespawnDuration'); + + if (customInput.classList.contains('visible')) { + // Custom mode - use input value + return durationInput.value ? parseInt(durationInput.value) : null; + } else { + // Preset mode - get from active button + const activeBtn = document.querySelector('.duration-preset-btn.active'); + const minutes = activeBtn?.dataset.minutes; + return minutes ? parseInt(minutes) : null; + } + } + // Get respawn config from modal inputs getModalRespawnConfig() { const updatePrompt = document.getElementById('modalRespawnPrompt').value; const sendClear = document.getElementById('modalRespawnSendClear').checked; const sendInit = document.getElementById('modalRespawnSendInit').checked; const kickstartPrompt = document.getElementById('modalRespawnKickstart').value.trim() || undefined; - const durationStr = document.getElementById('modalRespawnDuration').value; - const durationMinutes = durationStr ? parseInt(durationStr) : null; + const durationMinutes = this.getSelectedDuration(); // Auto-compact settings const autoCompactEnabled = document.getElementById('modalAutoCompactEnabled').checked; diff --git a/src/web/public/index.html b/src/web/public/index.html index 18339582..3fea64c4 100644 --- a/src/web/public/index.html +++ b/src/web/public/index.html @@ -209,17 +209,28 @@