fix(hermes): remove duplicate action buttons

This commit is contained in:
Russell Ballestrini 2025-07-02 07:20:16 -04:00
parent f7241e0d0d
commit 2a8e020f9c

142
src/ui.js
View file

@ -650,16 +650,41 @@ async function openHermesModalNew() {
// Load models
const loadModels = async () => {
try {
const models = await window.fetchModelsFromEndpoints();
console.log("Loading models for Hermes modal...");
const models = await fetchModelsFromEndpoints();
console.log("Models loaded:", models);
modelSelect.innerHTML = '';
models.forEach(model => {
if (models && models.length > 0) {
models.forEach(model => {
const option = document.createElement("option");
option.value = model.uniqueId;
option.textContent = `${model.endpointId} | ${model.modelName}`;
modelSelect.appendChild(option);
});
// Set current selected model if available
const currentModel = getSelectedModel();
if (currentModel) {
const currentOption = Array.from(modelSelect.options).find(opt =>
opt.textContent.includes(currentModel)
);
if (currentOption) {
modelSelect.value = currentOption.value;
}
}
} else {
const option = document.createElement("option");
option.value = model.uniqueId;
option.textContent = `${model.endpointId} | ${model.modelName}`;
option.textContent = "No models available";
option.disabled = true;
modelSelect.appendChild(option);
});
}
} catch (error) {
console.error("Failed to load models:", error);
const option = document.createElement("option");
option.textContent = "Error loading models";
option.disabled = true;
modelSelect.appendChild(option);
}
};
@ -685,12 +710,14 @@ async function openHermesModalNew() {
`;
const voices = ["alloy", "echo", "fable", "onyx", "nova", "shimmer"];
voices.forEach(voice => {
voices.forEach((voice, index) => {
const option = document.createElement("option");
option.value = voice;
option.textContent = voice.charAt(0).toUpperCase() + voice.slice(1);
if (index === 0) option.selected = true; // Set alloy as default
voiceSelect.appendChild(option);
});
console.log("Voices loaded:", voices.length, "voices");
voiceSection.appendChild(voiceLabel);
voiceSection.appendChild(voiceSelect);
@ -711,9 +738,6 @@ async function openHermesModalNew() {
`;
const actions = [
{ text: "📖 Read Page", action: () => window.readPageWithHermes() },
{ text: "🔊 TTS Modal", action: () => window.openTTSModal() },
{ text: "🌐 Translate", action: () => window.openTranslateModal() },
{ text: "📁 Upload File", action: () => document.querySelector('[data-uncloseai-file-input]')?.click() },
{ text: "🔄 Refresh Models", action: loadModels },
{ text: "🗑️ Clear Chat", action: () => {
@ -721,7 +745,7 @@ async function openHermesModalNew() {
chatBox.innerHTML = '';
clearConversationHistory();
// Re-add intro message
chatBox.appendChild(introMsg.cloneNode(true));
addIntroMessage();
}
}}
];
@ -774,60 +798,56 @@ async function openHermesModalNew() {
menuBtn.style.background = settingsOpen ? 'rgba(255,255,255,0.3)' : 'rgba(255,255,255,0.2)';
};
// Quick action buttons (minimal on mobile)
if (!isMobile) {
const controls = document.createElement("div");
controls.style.cssText = `
flex-shrink: 0;
// Quick action buttons
const controls = document.createElement("div");
controls.style.cssText = `
flex-shrink: 0;
padding: 8px 16px;
background: white;
border-top: 1px solid #e9ecef;
border-bottom: 1px solid #e9ecef;
display: flex;
gap: 8px;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
`;
const actions = [
{ text: "📖 Read", action: () => window.readPageWithHermes() },
{ text: "🔊 TTS", action: () => window.openTTSModal() },
{ text: "🌐 Translate", action: () => window.openTranslateModal() }
];
actions.forEach(({ text, action }) => {
const btn = document.createElement("button");
btn.textContent = text;
btn.style.cssText = `
padding: 8px 16px;
background: white;
border-top: 1px solid #e9ecef;
border-bottom: 1px solid #e9ecef;
display: flex;
gap: 8px;
overflow-x: auto;
background: #f8f9fa;
border: 1px solid #dee2e6;
border-radius: 20px;
cursor: pointer;
white-space: nowrap;
font-size: 14px;
transition: all 0.2s;
`;
btn.onmouseover = () => {
btn.style.background = '#e9ecef';
btn.style.borderColor = '#adb5bd';
};
btn.onmouseout = () => {
btn.style.background = '#f8f9fa';
btn.style.borderColor = '#dee2e6';
};
btn.onclick = action;
controls.appendChild(btn);
});
const actions = [
{ text: "📖 Read", action: () => window.readPageWithHermes() },
{ text: "🔊 TTS", action: () => window.openTTSModal() },
{ text: "🌐 Translate", action: () => window.openTranslateModal() }
];
actions.forEach(({ text, action }) => {
const btn = document.createElement("button");
btn.textContent = text;
btn.style.cssText = `
padding: 8px 16px;
background: #f8f9fa;
border: 1px solid #dee2e6;
border-radius: 20px;
cursor: pointer;
white-space: nowrap;
font-size: 14px;
transition: all 0.2s;
`;
btn.onmouseover = () => {
btn.style.background = '#e9ecef';
btn.style.borderColor = '#adb5bd';
};
btn.onmouseout = () => {
btn.style.background = '#f8f9fa';
btn.style.borderColor = '#dee2e6';
};
btn.onclick = action;
controls.appendChild(btn);
});
container.appendChild(header);
container.appendChild(settingsPanel);
container.appendChild(chatArea);
container.appendChild(controls);
} else {
container.appendChild(header);
container.appendChild(settingsPanel);
container.appendChild(chatArea);
}
// Assemble modal structure
container.appendChild(header);
container.appendChild(settingsPanel);
container.appendChild(chatArea);
container.appendChild(controls);
// Input area
const inputArea = document.createElement("div");