A Signal with no key links to typesafe.ai and to the key's field in Settings (#266)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-16 19:32:57 +00:00
parent f34423735a
commit f1a156c974
3 changed files with 30 additions and 3 deletions

View File

@@ -109,7 +109,7 @@ function signalHead(sg: Signal){
<div class="meta">
<h2>${esc(sg.name)}</h2>
<div class="sub">Picked out of the noise of your ${plural(S.feeds.length,'feed')}: ${esc(sg.description||sg.keywords.join(', '))} · ${sg.unread} unread</div>
${nokey?'<div class="sub" style="color:var(--warn)">No TypeSafe key yet, so nothing is being picked out. Add one in Settings.</div>':''}
${nokey?`<div class="sub" style="color:var(--warn)">No TypeSafe key yet, so nothing is being picked out. ${KEY_LINKS}</div>`:''}
</div>
<div class="acts">
<button class="btn ico" data-a="settings" title="Edit this signal" aria-label="Edit this signal">${ICON.settings}</button>
@@ -151,7 +151,7 @@ function signalModal(sg?: Signal){
and each new one, and the ones about this subject are pulled out: its name, these words and
your sentence together. The rest stays noise, in its own feed. Each item is one call on your
TypeSafe key.${sg?' A change here reads everything again.':''}</span></div>
${nokey?'<p class="hint" style="color:var(--warn)">Add your TypeSafe key in Settings first: without one, nothing is picked out.</p>':''}
${nokey?`<p class="hint" style="color:var(--warn)">Without a TypeSafe key, nothing is picked out. ${KEY_LINKS}</p>`:''}
<div class="cardacts"><button class="btn ico" onclick="closeModal()" title="Cancel" aria-label="Cancel">${ICON.close}</button>
<button class="btn ico primary" id="sgsave" title="${sg?'Save':'Make signal'}" aria-label="${sg?'Save':'Make signal'}">${sg?ICON.check:ICON.plus}</button></div>`);
wireChips($('#sgkw'));
@@ -272,3 +272,18 @@ async function jevIcon(name: string, keywords: string[], description: string|nul
const r=await api('/api/signals/icon',{method:'POST',body:JSON.stringify({name,keywords,description,candidates})});
return r.icon;
}
/// Where to get a TypeSafe key and where it goes, wherever a Signal says it has none: one click to
/// each, rather than "in Settings" left to be found.
const KEY_LINKS=`<a href="https://typesafe.ai" target="_blank" rel="noopener">Get one at typesafe.ai</a>, then
<button type="button" class="dlink" data-keylink>add it in Settings</button>.`;
/// Settings, open at the key's field.
async function keySetting(){
closeModal();
await prefsModal();
const k=$<HTMLInputElement>('#stskey'); k.scrollIntoView({block:'center'}); k.focus();
}
document.addEventListener('click',(e: MouseEvent)=>{
if(!(e.target as Element).closest?.('[data-keylink]')) return;
e.preventDefault(); keySetting().catch(err=>toast(why(err),true));
});