fix: invalidate cron skill picker cache on form open and after skill save (#502)

Two complementary cache-busting strategies for the stale cron skill picker:

1. On cron form open (toggleCronForm): always null _cronSkillsCache before
   fetching, so freshly created skills are immediately visible without a
   page reload. Previously the cache was only populated once and never
   invalidated.

2. On skill save (submitSkillSave): null _cronSkillsCache after a successful
   write so the next cron form open is forced to re-fetch. Mirrors the
   existing _skillsData=null pattern one line above.

Fixes: #502
Co-authored-by: armorbreak001 <armorbreak001@users.noreply.github.com>
This commit is contained in:
Hermes Agent
2026-04-15 07:43:00 +00:00
parent 7ea7331f26
commit 36830e3cd1

View File

@@ -97,10 +97,9 @@ function toggleCronForm(){
_renderCronSkillTags(); _renderCronSkillTags();
const search=$('cronFormSkillSearch'); const search=$('cronFormSkillSearch');
if(search)search.value=''; if(search)search.value='';
// Pre-fetch skills for the picker // Always re-fetch skills to avoid stale cache
if(!_cronSkillsCache){ _cronSkillsCache=null;
api('/api/skills').then(d=>{_cronSkillsCache=d.skills||[];}).catch(()=>{}); api('/api/skills').then(d=>{_cronSkillsCache=d.skills||[];}).catch(()=>{});
}
$('cronFormName').focus(); $('cronFormName').focus();
} }
} }
@@ -485,6 +484,7 @@ async function submitSkillSave() {
await api('/api/skills/save', {method:'POST', body: JSON.stringify({name, category: category||undefined, content})}); await api('/api/skills/save', {method:'POST', body: JSON.stringify({name, category: category||undefined, content})});
showToast(_editingSkillName ? t('skill_updated') : t('skill_created')); showToast(_editingSkillName ? t('skill_updated') : t('skill_created'));
_skillsData = null; _skillsData = null;
_cronSkillsCache = null;
toggleSkillForm(); toggleSkillForm();
await loadSkills(); await loadSkills();
} catch(e) { errEl.textContent = t('error_prefix') + e.message; errEl.style.display = ''; } } catch(e) { errEl.textContent = t('error_prefix') + e.message; errEl.style.display = ''; }