Skip to content

Commit 1acded2

Browse files
committed
Add queue delay configuration options for seconds and units
- Introduced `queueDelaySeconds` and `queueDelayUnit` to profile configurations. - Updated queue processing logic to handle delays in both seconds and minutes. - Enhanced UI to allow users to toggle between seconds and minutes for delay input.
1 parent ac70a97 commit 1acded2

File tree

6 files changed

+94
-9
lines changed

6 files changed

+94
-9
lines changed

config.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,14 @@ async function getCurrentProfileConfig() {
234234
profile.queueDelayMinutes = 5; // Default delay in minutes
235235
logConfigurationRelatedStuff(`Initialized missing 'queueDelayMinutes' for profile: ${profileName}`);
236236
}
237+
if (typeof profile.queueDelaySeconds === 'undefined') {
238+
profile.queueDelaySeconds = 300; // Default delay in seconds
239+
logConfigurationRelatedStuff(`Initialized missing 'queueDelaySeconds' for profile: ${profileName}`);
240+
}
241+
if (typeof profile.queueDelayUnit === 'undefined') {
242+
profile.queueDelayUnit = 'min'; // Default unit is minutes
243+
logConfigurationRelatedStuff(`Initialized missing 'queueDelayUnit' for profile: ${profileName}`);
244+
}
237245
if (typeof profile.enableQueueMode === 'undefined') {
238246
profile.enableQueueMode = false;
239247
logConfigurationRelatedStuff(`Initialized missing 'enableQueueMode' for profile: ${profileName}`);
@@ -253,6 +261,14 @@ async function getCurrentProfileConfig() {
253261
defaultProfile.queueDelayMinutes = 5;
254262
logConfigurationRelatedStuff("Initialized missing 'queueDelayMinutes' for default profile");
255263
}
264+
if (typeof defaultProfile.queueDelaySeconds === 'undefined') {
265+
defaultProfile.queueDelaySeconds = 300;
266+
logConfigurationRelatedStuff("Initialized missing 'queueDelaySeconds' for default profile");
267+
}
268+
if (typeof defaultProfile.queueDelayUnit === 'undefined') {
269+
defaultProfile.queueDelayUnit = 'min';
270+
logConfigurationRelatedStuff("Initialized missing 'queueDelayUnit' for default profile");
271+
}
256272
if (typeof defaultProfile.enableQueueMode === 'undefined') {
257273
defaultProfile.enableQueueMode = false;
258274
logConfigurationRelatedStuff("Initialized missing 'enableQueueMode' for default profile");

default-config.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
"firstModificationDone": false,
77
"enableQueueMode": false,
88
"queueDelayMinutes": 5,
9+
"queueDelaySeconds": 300,
10+
"queueDelayUnit": "min",
911
"customButtons": [
1012
{
1113
"icon": "🧠",

floating-panel-ui-engine.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,19 @@ window.MaxExtensionFloatingPanel.processNextQueueItem = function () {
125125

126126
// If there are more items, set a timeout for the next one
127127
if (this.promptQueue.length > 0) {
128-
const delayMs = (globalMaxExtensionConfig.queueDelayMinutes || 5) * 60 * 1000;
129-
logConCgp(`[queue-engine] Waiting for ${delayMs / 1000 / 60} minutes before next item.`);
128+
const unit = globalMaxExtensionConfig.queueDelayUnit || 'min';
129+
let delayMs;
130+
131+
if (unit === 'sec') {
132+
const delaySec = globalMaxExtensionConfig.queueDelaySeconds || 300;
133+
delayMs = delaySec * 1000;
134+
logConCgp(`[queue-engine] Waiting for ${delaySec} seconds before next item.`);
135+
} else { // 'min'
136+
const delayMin = globalMaxExtensionConfig.queueDelayMinutes || 5;
137+
delayMs = delayMin * 60 * 1000;
138+
logConCgp(`[queue-engine] Waiting for ${delayMin} minutes before next item.`);
139+
}
140+
130141
this.queueTimerId = setTimeout(() => this.processNextQueueItem(), delayMs);
131142
} else {
132143
logConCgp('[queue-engine] All items have been sent.');

floating-panel-ui-queue.js

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ window.MaxExtensionFloatingPanel.initializeQueueSection = function () {
2828
const togglePlaceholder = document.getElementById('max-extension-queue-toggle-placeholder');
2929
const expandableSection = this.queueSectionElement.querySelector('.expandable-queue-controls');
3030
this.delayInputElement = document.getElementById('max-extension-queue-delay-input');
31+
this.delayUnitToggle = document.getElementById('max-extension-delay-unit-toggle');
3132
this.playQueueButton = document.getElementById('max-extension-play-queue-btn');
3233
this.resetQueueButton = document.getElementById('max-extension-reset-queue-btn');
3334
this.queueDisplayArea = document.getElementById('max-extension-queue-display');
@@ -42,19 +43,51 @@ window.MaxExtensionFloatingPanel.initializeQueueSection = function () {
4243
event.stopPropagation();
4344
});
4445

45-
// Set initial values and event listeners for controls
46-
this.delayInputElement.value = globalMaxExtensionConfig.queueDelayMinutes || 5;
46+
// --- DELAY INPUT AND UNIT TOGGLE LOGIC ---
47+
48+
const updateDelayUI = () => {
49+
const unit = globalMaxExtensionConfig.queueDelayUnit || 'min';
50+
if (unit === 'sec') {
51+
this.delayUnitToggle.textContent = 'sec';
52+
this.delayInputElement.value = globalMaxExtensionConfig.queueDelaySeconds;
53+
this.delayInputElement.title = "Delay in seconds between sending each queued prompt. Minimum 2 seconds.";
54+
} else {
55+
this.delayUnitToggle.textContent = 'min';
56+
this.delayInputElement.value = globalMaxExtensionConfig.queueDelayMinutes;
57+
this.delayInputElement.title = "Delay in minutes between sending each queued prompt. Minimum 2 minutes.";
58+
}
59+
};
60+
61+
// Set initial state from config
62+
updateDelayUI();
63+
64+
// Add listener for unit toggle
65+
this.delayUnitToggle.addEventListener('click', (event) => {
66+
event.preventDefault();
67+
globalMaxExtensionConfig.queueDelayUnit = (globalMaxExtensionConfig.queueDelayUnit === 'min') ? 'sec' : 'min';
68+
updateDelayUI();
69+
// The config is saved when profile settings are saved.
70+
});
71+
72+
// Add listener for input value changes
4773
this.delayInputElement.addEventListener('change', (event) => {
4874
let delay = parseInt(event.target.value, 10);
4975
if (isNaN(delay) || delay < 2) {
50-
delay = 2; // Enforce minimum delay
76+
delay = 2;
5177
event.target.value = delay;
5278
}
53-
globalMaxExtensionConfig.queueDelayMinutes = delay;
54-
logConCgp(`[floating-panel-queue] Queue delay set to ${delay} minutes.`);
55-
// Note: The config is saved with the profile, or upon panel settings save.
79+
80+
if (globalMaxExtensionConfig.queueDelayUnit === 'sec') {
81+
globalMaxExtensionConfig.queueDelaySeconds = delay;
82+
logConCgp(`[floating-panel-queue] Queue delay set to ${delay} seconds.`);
83+
} else {
84+
globalMaxExtensionConfig.queueDelayMinutes = delay;
85+
logConCgp(`[floating-panel-queue] Queue delay set to ${delay} minutes.`);
86+
}
5687
});
5788

89+
// --- END DELAY LOGIC ---
90+
5891
// Create and insert the Queue Mode toggle
5992
const isQueueEnabled = globalMaxExtensionConfig.enableQueueMode || false;
6093
this.queueModeToggle = MaxExtensionInterface.createToggle(

floating-panel.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,22 @@
8383
font-size: 12px;
8484
}
8585

86+
#max-extension-delay-unit-toggle {
87+
background: transparent;
88+
border: none;
89+
padding: 0;
90+
margin: 0;
91+
font: inherit;
92+
color: inherit;
93+
cursor: pointer;
94+
text-decoration: underline;
95+
display: inline;
96+
}
97+
98+
#max-extension-delay-unit-toggle:hover {
99+
opacity: 0.8;
100+
}
101+
86102
#max-extension-queue-delay-input {
87103
width: 50px;
88104
background-color: rgba(80, 80, 80, 1);

floating-panel.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,14 @@
2323

2424
<div class="expandable-queue-controls">
2525
<div class="delay-container">
26-
<label for="max-extension-queue-delay-input">Delay (min):</label>
26+
<label for="max-extension-queue-delay-input"
27+
>Delay (<button
28+
id="max-extension-delay-unit-toggle"
29+
title="Click to switch between minutes and seconds"
30+
>
31+
min</button
32+
>):</label
33+
>
2734
<input
2835
id="max-extension-queue-delay-input"
2936
type="number"

0 commit comments

Comments
 (0)