fix(skills): wait for source before enabling the editor

This commit is contained in:
red person
2026-10-28 07:06:39 +03:00
parent a646b59110
commit 2c5d5005ba
6 changed files with 113 additions and 6 deletions
+1 -1
View File
@@ -2671,7 +2671,7 @@
<script type="module" src="/static/js/dragSort.js"></script>
<script type="module" src="/static/js/sessions.js"></script>
<script type="module" src="/static/js/memory.js"></script>
<script type="module" src="/static/js/skills.js?v=20260909kebabconsistency1"></script>
<script type="module" src="/static/js/skills.js?v=20261028skillsourceready1"></script>
<script type="module" src="/static/js/tourHints.js"></script>
<script type="module" src="/static/js/tourAutoplay.js"></script>
<script type="module" src="/static/js/fileHandler.js?v=20260909mobileattachmentedit1"></script>
+1 -1
View File
@@ -1941,7 +1941,7 @@ function _activateEntityAnchor(e, forcedAnchor = null) {
else { const b = document.getElementById('tasks-btn'); if (b) b.click(); }
}).catch(() => { const b = document.getElementById('tasks-btn'); if (b) b.click(); });
} else if (kind === 'skill') {
import('./skills.js?v=20260909kebabconsistency1').then(mod => {
import('./skills.js?v=20261028skillsourceready1').then(mod => {
const open = mod.openSkill || (mod.default && mod.default.openSkill);
if (open) open(id);
}).catch(() => {});
+2 -2
View File
@@ -272,7 +272,7 @@ export function openMemoryModal(tabName = 'browse') {
if (tab) {
tab.click();
} else if (target === 'skills') {
import('./skills.js?v=20260909kebabconsistency1').then(m => {
import('./skills.js?v=20261028skillsourceready1').then(m => {
if (m.loadSkills) m.loadSkills(true);
else if (m.default?.loadSkills) m.default.loadSkills(true);
});
@@ -1613,7 +1613,7 @@ document.addEventListener('DOMContentLoaded', () => {
});
// Lazy-load skills tab (cascade=true → play the domino-in entrance)
if (target === 'skills') {
import('./skills.js?v=20260909kebabconsistency1').then(m => { if (m.loadSkills) m.loadSkills(true); else if (m.default?.loadSkills) m.default.loadSkills(true); });
import('./skills.js?v=20261028skillsourceready1').then(m => { if (m.loadSkills) m.loadSkills(true); else if (m.default?.loadSkills) m.default.loadSkills(true); });
}
});
});
+8
View File
@@ -1260,6 +1260,9 @@ async function _expandSkillCard(card, name) {
card._md = md || '';
} else {
pre.textContent = 'Loading…';
const editBtn = [...card.querySelectorAll('.skill-card-preview button')]
.find(button => button.textContent.trim() === 'Edit');
if (editBtn) editBtn.disabled = true;
try {
const md = await _fetchSkillMarkdown(name);
pre.textContent = md || '(empty)';
@@ -1267,6 +1270,8 @@ async function _expandSkillCard(card, name) {
card._md = md;
} catch (e) {
pre.textContent = `Failed to load SKILL.md: ${e.message || 'Unknown error'}`;
} finally {
if (editBtn) editBtn.disabled = !card._mdLoaded;
}
}
}
@@ -1275,6 +1280,9 @@ async function _expandSkillCard(card, name) {
// Swap the read-only <pre> for an editable <textarea> (and back). The
// Edit button toggles; a Save button commits via the markdown endpoint.
function _toggleSkillEdit(card, name) {
// A loading/error preview is not source text. Menu entry points must obey
// the same readiness gate as the disabled footer control.
if (!card._mdLoaded) return;
const preview = card.querySelector('.skill-card-preview');
if (!preview) return;
const existing = preview.querySelector('.skill-md-editor');
+2 -2
View File
@@ -7,7 +7,7 @@
// - Other static assets (images/fonts/libs): cache-first with bg refresh.
// - API / non-GET: never cached.
// Bump CACHE_NAME whenever the precache list or SW logic changes.
const CACHE_NAME = 'odysseus-v659-notes-reference';
const CACHE_NAME = 'odysseus-v660-skill-source-ready';
// KaTeX resolves these from its own stylesheet, so caching the CSS without them
// gives offline math fallback glyphs instead of proper typesetting.
@@ -68,7 +68,7 @@ const PRECACHE = [
'/static/js/dragSort.js',
'/static/js/sessions.js',
'/static/js/memory.js',
'/static/js/skills.js?v=20260909kebabconsistency1',
'/static/js/skills.js?v=20261028skillsourceready1',
'/static/js/skillsMetrics.js?v=20260908autonomousskills1',
'/static/js/tourHints.js',
'/static/js/fileHandler.js?v=20260909mobileattachmentedit1',