Fix caller name mismatch after mid-session theme change
Setting a show theme after the caller lineup was loaded caused every caller button to keep its pre-theme label while the LLM dialog used the post-theme bg names — host says "Hi Phil", caller replies "it's Cody, actually". Three underlying bugs, all fixed here: - _regenerate_backgrounds_for_keys ignored its keys parameter and replaced the entire caller_backgrounds dict, clobbering used slots along with unused ones. Now only the listed slots are touched. - set_show_theme's used_keys detection compared record.caller_name (the slim bg name) against CALLER_BASES[k]["name"] (the randomized fallback name) — two different namespaces that never match, so every slot was flagged unused. Now it matches against session.caller_backgrounds[k]["name"]. - set_show_theme fired the regeneration as a detached asyncio task, so the POST returned before bg was consistent. Even if the frontend did reload /api/callers, it would race the regen. Now awaited. Frontend setShowTheme/clearShowTheme now call loadCallers() after the theme POST resolves so the button list actually refreshes, with a "Regenerating..." button state during the ~30-60s wait. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
+16
-1
@@ -1356,8 +1356,14 @@ async function loadShowTheme() {
|
||||
|
||||
async function setShowTheme() {
|
||||
const input = document.getElementById('show-theme-input');
|
||||
const setBtn = document.getElementById('set-theme-btn');
|
||||
const theme = input.value.trim();
|
||||
if (!theme) return;
|
||||
const originalText = setBtn?.textContent;
|
||||
if (setBtn) {
|
||||
setBtn.disabled = true;
|
||||
setBtn.textContent = 'Regenerating...';
|
||||
}
|
||||
try {
|
||||
const res = await fetch('/api/show-theme', {
|
||||
method: 'POST',
|
||||
@@ -1367,11 +1373,19 @@ async function setShowTheme() {
|
||||
const data = await res.json();
|
||||
if (data.theme) {
|
||||
input.classList.add('active');
|
||||
document.getElementById('set-theme-btn').classList.add('hidden');
|
||||
setBtn?.classList.add('hidden');
|
||||
document.getElementById('clear-theme-btn').classList.remove('hidden');
|
||||
}
|
||||
// Backend regenerated backgrounds for unused callers — refresh the
|
||||
// button list so we show the new names, not the pre-theme cache.
|
||||
await loadCallers();
|
||||
} catch (e) {
|
||||
console.error('Failed to set show theme:', e);
|
||||
} finally {
|
||||
if (setBtn) {
|
||||
setBtn.disabled = false;
|
||||
setBtn.textContent = originalText || 'Set';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1387,6 +1401,7 @@ async function clearShowTheme() {
|
||||
input.classList.remove('active');
|
||||
document.getElementById('set-theme-btn').classList.remove('hidden');
|
||||
document.getElementById('clear-theme-btn').classList.add('hidden');
|
||||
await loadCallers();
|
||||
} catch (e) {
|
||||
console.error('Failed to clear show theme:', e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user