Add max iterations

This commit is contained in:
dwrz
2026-07-05 17:55:07 +00:00
parent c4730eb8ce
commit 1e4c7f0334
6 changed files with 95 additions and 2 deletions

View File

@@ -134,4 +134,10 @@
<path d="M7 15h6"/>
<path d="M7 7h8"/>
</symbol>
<symbol id="settings-2" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M14 17H5" />
<path d="M19 7h-9" />
<circle cx="17" cy="17" r="3" />
<circle cx="7" cy="7" r="3" />
</symbol>
</svg>

Before

Width:  |  Height:  |  Size: 8.0 KiB

After

Width:  |  Height:  |  Size: 8.3 KiB

View File

@@ -661,6 +661,18 @@ body {
}
}
#compose-settings-close {
border: none;
color: var(--color-text);
}
@media (hover: hover) {
#compose-settings-close:hover {
border-color: transparent;
color: var(--color-text);
}
}
/* Tabs */
.settings-tabs {
display: flex;
@@ -715,6 +727,14 @@ body {
margin-bottom: var(--s-2);
}
.settings-label__sub {
display: block;
font-size: var(--s-2);
font-weight: 400;
color: var(--color-text-muted);
margin-top: 0.125rem;
}
.settings-select {
width: 100%;
height: var(--s2);
@@ -735,6 +755,10 @@ body {
outline-offset: 2px;
}
.settings-field {
margin-bottom: var(--s1);
}
.settings-textarea {
display: block;
width: 100%;

View File

@@ -14,6 +14,7 @@ import { WakeLock } from './wakelock.js';
const STREAM_ENDPOINT = '/v1/chat/voice/stream';
const SYSTEM_MESSAGE_KEY = 'odidere_system_message';
const MAX_TURNS_KEY = 'odidere_max_turns';
const ICONS_URL = '/static/icons.svg';
const StreamEventDelta = 'delta';
@@ -102,6 +103,13 @@ class Odidere {
this.$settingsClose = document.getElementById('settings-close');
this.$settingsTabs = document.querySelectorAll('.settings-tab');
this.$saveSystemMessage = document.getElementById('save-system-message');
this.$composeSettingsOverlay = document.getElementById(
'compose-settings-overlay',
);
this.$composeSettingsClose = document.getElementById(
'compose-settings-close',
);
this.$maxTurnsInput = document.getElementById('max-turns-input');
this.$compose = document.querySelector('.compose');
this.init();
@@ -241,6 +249,18 @@ class Odidere {
this.settings.saveSystemMessage(),
);
// --- Compose settings ---
this.$composeSettingsClose.addEventListener('click', () =>
this._closeComposeSettings(),
);
this.$composeSettingsOverlay.addEventListener('click', (e) => {
if (e.target === this.$composeSettingsOverlay)
this._closeComposeSettings();
});
this.$maxTurnsInput.addEventListener('input', () => {
this._setMaxTurns(this.$maxTurnsInput.value);
});
// --- Model/voice change persistence ---
this.settings.$model.addEventListener('change', () =>
this.settings.saveModelSelection(),
@@ -297,6 +317,9 @@ class Odidere {
case 'settings':
this.settings.open();
break;
case 'compose-settings':
this._openComposeSettings();
break;
case 'attach':
// Handled by direct listener on $attach.
break;
@@ -599,6 +622,10 @@ class Odidere {
if (systemMessage) {
payload.system_message = systemMessage;
}
const maxTurns = this._getMaxTurns();
if (maxTurns > 0) {
payload.max_iterations = maxTurns;
}
// Clear attachments and location after building payload.
this.clearAttachments();
@@ -1100,6 +1127,30 @@ class Odidere {
this.$location.classList.remove('compose__action-btn--location', 'active');
}
// ====================
// COMPOSE SETTINGS
// ====================
_openComposeSettings() {
this.$maxTurnsInput.value = this._getMaxTurns();
this.$composeSettingsOverlay.classList.add('open');
this.$composeSettingsClose.focus();
}
_closeComposeSettings() {
this.$composeSettingsOverlay.classList.remove('open');
this.$composeSettings.focus();
}
_getMaxTurns() {
const stored = localStorage.getItem(MAX_TURNS_KEY);
return stored ? Number(stored) : 0;
}
_setMaxTurns(value) {
localStorage.setItem(MAX_TURNS_KEY, String(value));
}
// ====================
// TWO-PRESS SAFETY PATTERNS
// ====================