From 63f5097a6dbabeffdf42f0e82d1da7c81522c7b9 Mon Sep 17 00:00:00 2001 From: Laan Tungir Date: Tue, 28 Apr 2026 10:44:22 -0400 Subject: [PATCH] This is a meaningful git commit message --- www/document.html | 66 +++++++++++++++++++++++++++++++++++---------- www/js/version.json | 6 ++--- 2 files changed, 55 insertions(+), 17 deletions(-) diff --git a/www/document.html b/www/document.html index db2e3e0..7a110a0 100644 --- a/www/document.html +++ b/www/document.html @@ -1803,13 +1803,21 @@ user: } function enforceDefaultSkillSelection() { - const convo = getCurrentConversation(); - if (!convo) return; const defaultKey = getDefaultDocumentSkillKey(); if (!defaultKey) return; const hasDefaultSkill = skills.some((s) => s.key === defaultKey); if (!hasDefaultSkill) return; + const convo = getCurrentConversation(); + if (!convo) { + if (!selectedSkillKeys.includes(defaultKey)) { + selectedSkillKeys = [...selectedSkillKeys, defaultKey]; + renderSkillsList(); + renderSkillsEditor(); + } + return; + } + const removed = new Set(getConversationRemovedSkillKeys(convo)); const selected = new Set(getConversationSkillKeys(convo)); if (!removed.has(defaultKey) && !selected.has(defaultKey)) { @@ -4061,15 +4069,40 @@ user: }); } + function upsertDefaultDocumentSkillDraft() { + if (!currentPubkey) return; + const key = getDefaultDocumentSkillKey(); + if (!key) return; + if (skills.some((s) => s.key === key)) return; + + const llm = String(aiConfig.model || 'default').trim() || 'default'; + const temperature = Number(aiConfig.temperature ?? 0); + const maxTokens = Math.max(1, Math.floor(Number(aiConfig.max_tokens ?? 10000))); + const evt = { + kind: 31123, + created_at: Math.floor(Date.now() / 1000), + pubkey: currentPubkey, + id: uid(), + tags: [ + ['d', DEFAULT_DOCUMENT_SKILL_SLUG], + ['description', DEFAULT_DOCUMENT_SKILL_DESCRIPTION], + ['llm', llm], + ['temperature', String(temperature)], + ['max_tokens', String(maxTokens)] + ], + content: DEFAULT_DOCUMENT_SKILL_TEMPLATE + }; + upsertSkillFromEvent(evt); + } + async function ensureDefaultDocumentSkillExists() { if (!currentPubkey) return; const slug = DEFAULT_DOCUMENT_SKILL_SLUG; const key = getDefaultDocumentSkillKey(); - const existingInMemory = skills.find((s) => s.key === key); - if (existingInMemory) { - enforceDefaultSkillSelection(); - return; - } + + // Ensure visibility/editability immediately, even before network round-trips. + upsertDefaultDocumentSkillDraft(); + enforceDefaultSkillSelection(); const filter = { kinds: [31123], @@ -4128,13 +4161,18 @@ user: }; const skillEvent = buildSkillEventFromEditor(draftSkill); - await publishEvent(skillEvent); - upsertSkillFromEvent({ - ...skillEvent, - pubkey: currentPubkey, - id: uid() - }); - setStatus('Created default-document-skill.'); + try { + await publishEvent(skillEvent); + upsertSkillFromEvent({ + ...skillEvent, + pubkey: currentPubkey, + id: uid() + }); + setStatus('Created default-document-skill.'); + } catch (error) { + console.warn('[document.html] failed to publish default-document-skill, keeping local draft:', error); + setStatus('Default document skill loaded locally (publish pending).'); + } enforceDefaultSkillSelection(); } diff --git a/www/js/version.json b/www/js/version.json index cd9d397..04439bd 100644 --- a/www/js/version.json +++ b/www/js/version.json @@ -1,5 +1,5 @@ { - "VERSION": "v0.7.8", - "VERSION_NUMBER": "0.7.8", - "BUILD_DATE": "2026-04-28T14:39:51.733Z" + "VERSION": "v0.7.9", + "VERSION_NUMBER": "0.7.9", + "BUILD_DATE": "2026-04-28T14:44:22.682Z" }