mirror of
http://nostr-git-proxy.forgejo.svc.cluster.local/git/45387ca441053e230b2126802005eb03767ab59d84555e8bac86b6e7def14e27/myadhd
synced 2026-09-23 20:23:10 +00:00
Merge branches 'feat/sprint-5-timer-anchor', 'feat/sprint-5-quick-capture', 'feat/sprint-5-soundscapes' and 'feat/sprint-6-webllm'
All checks were successful
Build and Deploy / deploy (push) Successful in 16s
All checks were successful
Build and Deploy / deploy (push) Successful in 16s
This commit is contained in:
commit
f09350d924
5 changed files with 311 additions and 13 deletions
|
|
@ -27,6 +27,7 @@
|
|||
<a href="#dopamine" data-tab="dopamine" class="tab" role="tab" id="tab-dopamine" aria-selected="false" aria-controls="dopamine">Dopamine menu</a>
|
||||
<a href="#now" data-tab="now" class="tab" role="tab" id="tab-now" aria-selected="false" aria-controls="now">One thing</a>
|
||||
<a href="#inbox" data-tab="inbox" class="tab" role="tab" id="tab-inbox" aria-selected="false" aria-controls="inbox">Brain dump</a>
|
||||
<a href="#done" data-tab="done" class="tab" role="tab" id="tab-done" aria-selected="false" aria-controls="done">Done-Wall</a>
|
||||
</nav>
|
||||
<div id="ambient-pill" class="ambient-pill" role="button" aria-expanded="false" tabindex="0">
|
||||
<span class="pill-dot">🟢</span>
|
||||
|
|
@ -40,6 +41,18 @@
|
|||
</ul>
|
||||
<div id="ambient-cheer-btn" class="ambient-cheer" role="button" tabindex="0">Send a gentle nod 🎉</div>
|
||||
</div>
|
||||
|
||||
<!-- Quick Capture Overlay -->
|
||||
<div id="quick-capture-overlay" class="completion-overlay" hidden>
|
||||
<div class="completion-card">
|
||||
<h2>Brain Dump (Parking Lot)</h2>
|
||||
<p style="margin-top:-5px; font-size:0.9rem; color:var(--dim);">Clear your mind. We'll save it to your unsorted list.</p>
|
||||
<input type="text" id="quick-capture-input" placeholder="What's distracting you?" autocomplete="off" style="width:100%;font-size:1.2rem;padding:15px;background:var(--bg-hover);border:2px solid var(--border);color:var(--text);border-radius:8px;margin-bottom:10px;margin-top:15px;" />
|
||||
<div style="text-align:right;">
|
||||
<span class="tiny dim">Press Esc to cancel, Enter to save</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
|
|
@ -278,6 +291,24 @@
|
|||
</div>
|
||||
</section>
|
||||
|
||||
<section id="done" class="tool" role="tabpanel" aria-labelledby="tab-done" hidden>
|
||||
<div class="tool-head">
|
||||
<div style="display: flex; justify-content: space-between; align-items: center; width: 100%;">
|
||||
<div>
|
||||
<h1>Done-Wall</h1>
|
||||
<p class="sub">Everything you've finished, stored securely in your browser cache.</p>
|
||||
</div>
|
||||
<button class="btn ghost" id="done-clear" style="margin-left: 1rem;">Clear History</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<ul id="done-list" class="done-items" role="list" style="list-style: none; padding: 0; margin: 0;"></ul>
|
||||
<div id="done-empty" class="tiny" style="text-align: center; padding: 2rem 0; opacity: 0.7;">
|
||||
No tasks recorded yet. Complete something in the 'One Thing' tab to see it here!
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</main>
|
||||
|
||||
<!-- Celebration canvas (confetti) -->
|
||||
|
|
@ -352,6 +383,8 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/static/store.js" defer></script>
|
||||
<script src="/static/done.js" defer></script>
|
||||
<script src="/static/app.js" defer></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -475,6 +475,46 @@
|
|||
timerPersist(); timerPaint();
|
||||
}
|
||||
|
||||
/* ---------- AI Auto-Deconstruct Contract (Tier 1 & 2) ---------- */
|
||||
window.aiBreakdownTask = async function(taskText) {
|
||||
// Shared Interface for Sibyl's Tier 3
|
||||
const prompt = `Break down this intimidating task into 3-5 tiny, actionable micro-steps: "${taskText}". Return only the list of steps.`;
|
||||
|
||||
// Tier 1: Browser Native (window.ai)
|
||||
if (window.ai && window.ai.languageModel) {
|
||||
try {
|
||||
const caps = await window.ai.languageModel.capabilities();
|
||||
if (caps.available !== 'no') {
|
||||
const session = await window.ai.languageModel.create();
|
||||
const result = await session.prompt(prompt);
|
||||
return result.split('\n').filter(s => s.trim().length > 0);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn("window.ai failed, falling back", e);
|
||||
}
|
||||
}
|
||||
|
||||
// Tier 2: BYOK (Bring Your Own Key) Fallback
|
||||
const key = store('byok_key');
|
||||
if (!key) {
|
||||
throw new Error("NO_AI_AVAILABLE"); // Let UI prompt for key or let Tier 3 try
|
||||
}
|
||||
const resp = await fetch('https://api.openai.com/v1/chat/completions', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'Bearer ' + key
|
||||
},
|
||||
body: JSON.stringify({
|
||||
model: 'gpt-4o-mini',
|
||||
messages: [{ role: 'user', content: prompt }]
|
||||
})
|
||||
});
|
||||
if (!resp.ok) throw new Error("API_ERROR");
|
||||
const data = await resp.json();
|
||||
return data.choices[0].message.content.split('\n').filter(s => s.trim().length > 0);
|
||||
};
|
||||
|
||||
$('#timer-reset').addEventListener('click', timerReset);
|
||||
|
||||
$$('.preset').forEach(function (p) {
|
||||
|
|
@ -509,6 +549,7 @@
|
|||
$('#timer-complete').hidden = true;
|
||||
// Mark the current one-thing step as done in the breaker
|
||||
var nowData = store('now');
|
||||
var taskText = $('#now-text').textContent || (nowData && nowData.text) || '';
|
||||
if (nowData && nowData.fromBreaker && typeof nowData.stepIndex === 'number') {
|
||||
var b = store(breakerKey);
|
||||
if (b && b.steps[nowData.stepIndex]) {
|
||||
|
|
@ -517,6 +558,7 @@
|
|||
breakerRender();
|
||||
}
|
||||
}
|
||||
handleNewDoneTasks(taskText);
|
||||
// Reset timer so it's fresh for the next step
|
||||
timerReset();
|
||||
// Clear one-thing and show next step prompt
|
||||
|
|
@ -719,8 +761,15 @@
|
|||
$('#now-input').focus();
|
||||
});
|
||||
|
||||
function handleNewDoneTasks(taskString) {
|
||||
if (window.dbRecordTask && taskString) {
|
||||
window.dbRecordTask(taskString).then(() => { if (window.renderDoneWall) window.renderDoneWall(); }).catch(() => {});
|
||||
}
|
||||
}
|
||||
|
||||
$('#now-done').addEventListener('click', function () {
|
||||
var nowData = store('now');
|
||||
var taskText = $('#now-text').textContent || (nowData && nowData.text) || '';
|
||||
tickSound();
|
||||
// If from breaker, mark that step done
|
||||
if (nowData && nowData.fromBreaker && typeof nowData.stepIndex === 'number') {
|
||||
|
|
@ -731,6 +780,7 @@
|
|||
breakerRender();
|
||||
}
|
||||
}
|
||||
handleNewDoneTasks(taskText);
|
||||
localStorage.removeItem('myadhd.now');
|
||||
// Check if there's a next step from breaker
|
||||
var b2 = store(breakerKey);
|
||||
|
|
@ -998,6 +1048,32 @@
|
|||
|
||||
/* ---------- keyboard shortcuts ---------- */
|
||||
document.addEventListener('keydown', function (e) {
|
||||
// Quick Capture (Alt+P) - active globally
|
||||
if (e.altKey && (e.key === 'p' || e.key === 'P')) {
|
||||
e.preventDefault();
|
||||
var overlay = document.getElementById('quick-capture-overlay');
|
||||
if (overlay.hidden) {
|
||||
overlay.hidden = false;
|
||||
document.getElementById('quick-capture-input').value = '';
|
||||
document.getElementById('quick-capture-input').focus();
|
||||
} else {
|
||||
overlay.hidden = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Quick capture handling inside input
|
||||
if (e.target.id === 'quick-capture-input') {
|
||||
if (e.key === 'Escape') {
|
||||
document.getElementById('quick-capture-overlay').hidden = true;
|
||||
} else if (e.key === 'Enter' && e.target.value.trim() !== '') {
|
||||
var unTasks = store('unsorted_tasks') || [];
|
||||
unTasks.push({ text: e.target.value.trim(), created: Date.now() });
|
||||
store('unsorted_tasks', unTasks);
|
||||
if (typeof unPaint === 'function') unPaint();
|
||||
document.getElementById('quick-capture-overlay').hidden = true;
|
||||
e.target.value = '';
|
||||
}
|
||||
}
|
||||
// Don't trigger shortcuts when typing in an input or contenteditable
|
||||
var tag = e.target.tagName;
|
||||
if (tag === 'INPUT' || tag === 'TEXTAREA' || e.target.contentEditable === 'true') return;
|
||||
|
|
|
|||
|
|
@ -7,21 +7,26 @@ let noiseNode;
|
|||
let gainNode;
|
||||
let currentNoiseType = 'off';
|
||||
|
||||
/**
|
||||
* Procedural noise generation (Brownian, Pink)
|
||||
*/
|
||||
function createNoiseBuffer(type) {
|
||||
const bufferSize = audioCtx.sampleRate * 2; // 2 seconds of noise
|
||||
const bufferSize = audioCtx.sampleRate * 2;
|
||||
const buffer = audioCtx.createBuffer(1, bufferSize, audioCtx.sampleRate);
|
||||
const output = buffer.getChannelData(0);
|
||||
|
||||
if (type === 'brown') {
|
||||
if (type === 'rain') {
|
||||
let lastOut = 0;
|
||||
for (let i = 0; i < bufferSize; i++) {
|
||||
let white = Math.random() * 2 - 1;
|
||||
output[i] = (lastOut + (0.05 * white)) / 1.05;
|
||||
lastOut = output[i];
|
||||
output[i] *= 2.0;
|
||||
}
|
||||
} else if (type === 'brown') {
|
||||
let lastOut = 0;
|
||||
for (let i = 0; i < bufferSize; i++) {
|
||||
let white = Math.random() * 2 - 1;
|
||||
output[i] = (lastOut + (0.02 * white)) / 1.02;
|
||||
lastOut = output[i];
|
||||
output[i] *= 3.5; // Compensate for gain
|
||||
output[i] *= 3.5;
|
||||
}
|
||||
} else if (type === 'pink') {
|
||||
let b0 = 0, b1 = 0, b2 = 0, b3 = 0, b4 = 0, b5 = 0, b6 = 0;
|
||||
|
|
@ -34,7 +39,7 @@ function createNoiseBuffer(type) {
|
|||
b4 = 0.55000 * b4 + white * 0.5329522;
|
||||
b5 = -0.7616 * b5 - white * 0.0168980;
|
||||
output[i] = b0 + b1 + b2 + b3 + b4 + b5 + b6 + white * 0.5362;
|
||||
output[i] *= 0.11; // Compensate for gain
|
||||
output[i] *= 0.11;
|
||||
b6 = white * 0.115926;
|
||||
}
|
||||
}
|
||||
|
|
@ -69,6 +74,40 @@ function playNoise(type) {
|
|||
|
||||
if (type === 'off') return;
|
||||
|
||||
if (type === 'gamma') {
|
||||
// 40Hz Gamma true binaural setup
|
||||
const oscLeft = audioCtx.createOscillator();
|
||||
const oscRight = audioCtx.createOscillator();
|
||||
const pannerLeft = audioCtx.createStereoPanner();
|
||||
const pannerRight = audioCtx.createStereoPanner();
|
||||
|
||||
oscLeft.frequency.value = 200; // Base carrier frequency
|
||||
oscRight.frequency.value = 240; // 40Hz beat frequency difference
|
||||
|
||||
pannerLeft.pan.value = -1; // Hard left
|
||||
pannerRight.pan.value = 1; // Hard right
|
||||
|
||||
oscLeft.connect(pannerLeft);
|
||||
oscRight.connect(pannerRight);
|
||||
|
||||
pannerLeft.connect(gainNode);
|
||||
pannerRight.connect(gainNode);
|
||||
|
||||
oscLeft.start();
|
||||
oscRight.start();
|
||||
|
||||
noiseNode = {
|
||||
stop: () => {
|
||||
oscLeft.stop(); oscRight.stop();
|
||||
},
|
||||
disconnect: () => {
|
||||
oscLeft.disconnect(); oscRight.disconnect();
|
||||
pannerLeft.disconnect(); pannerRight.disconnect();
|
||||
}
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
noiseNode = audioCtx.createBufferSource();
|
||||
noiseNode.buffer = createNoiseBuffer(type);
|
||||
noiseNode.loop = true;
|
||||
|
|
@ -83,11 +122,9 @@ function setupAudioUI() {
|
|||
|
||||
soundBtns.forEach(btn => {
|
||||
btn.addEventListener('click', () => {
|
||||
// Update UI
|
||||
soundBtns.forEach(b => b.classList.remove('active'));
|
||||
btn.classList.add('active');
|
||||
|
||||
// Update audio
|
||||
const soundType = btn.dataset.sound;
|
||||
currentNoiseType = soundType;
|
||||
playNoise(soundType);
|
||||
|
|
@ -97,7 +134,6 @@ function setupAudioUI() {
|
|||
if (volControl) {
|
||||
volControl.addEventListener('input', (e) => {
|
||||
if (gainNode) {
|
||||
// Logarithmic volume scaling for smoother feel
|
||||
const val = Number(e.target.value);
|
||||
gainNode.gain.setTargetAtTime(val * val, audioCtx.currentTime, 0.05);
|
||||
}
|
||||
|
|
@ -105,18 +141,16 @@ function setupAudioUI() {
|
|||
}
|
||||
}
|
||||
|
||||
// Wire it up on app load
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
setupAudioUI();
|
||||
});
|
||||
|
||||
|
||||
window.playGroundingPing = function() {
|
||||
if (!audioCtx) initAudio();
|
||||
var osc = audioCtx.createOscillator();
|
||||
var gain = audioCtx.createGain();
|
||||
osc.type = 'sine';
|
||||
osc.frequency.setValueAtTime(528, audioCtx.currentTime); // 528hz droplet
|
||||
osc.frequency.setValueAtTime(528, audioCtx.currentTime);
|
||||
gain.gain.setValueAtTime(0, audioCtx.currentTime);
|
||||
gain.gain.linearRampToValueAtTime(0.3, audioCtx.currentTime + 0.1);
|
||||
gain.gain.exponentialRampToValueAtTime(0.001, audioCtx.currentTime + 1.5);
|
||||
|
|
|
|||
90
site/static/done.js
Normal file
90
site/static/done.js
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
window.renderDoneWall = function() {
|
||||
if (!window.dbGetAllTasks) return;
|
||||
window.dbGetAllTasks().then(tasks => {
|
||||
var list = document.querySelector('#done-list');
|
||||
var empty = document.querySelector('#done-empty');
|
||||
if (!list || !empty) return;
|
||||
|
||||
if (tasks.length === 0) {
|
||||
list.innerHTML = '';
|
||||
empty.hidden = false;
|
||||
return;
|
||||
}
|
||||
empty.hidden = true;
|
||||
list.innerHTML = '';
|
||||
|
||||
// Group by Date string (local date)
|
||||
const groups = {};
|
||||
const todayStr = new Date().toDateString();
|
||||
|
||||
tasks.forEach(t => {
|
||||
let d = new Date(t.completedAt);
|
||||
let dStr = d.toDateString();
|
||||
if (dStr === todayStr) dStr = "Today";
|
||||
else if (dStr === new Date(Date.now() - 86400000).toDateString()) dStr = "Yesterday";
|
||||
else dStr = d.toLocaleDateString(undefined, { weekday: 'long', month: 'short', day: 'numeric' });
|
||||
|
||||
if (!groups[dStr]) groups[dStr] = [];
|
||||
groups[dStr].push(t);
|
||||
});
|
||||
|
||||
Object.keys(groups).forEach(dateLabel => {
|
||||
let head = document.createElement('h3');
|
||||
head.textContent = dateLabel;
|
||||
head.style.marginTop = '1.5rem';
|
||||
head.style.marginBottom = '0.5rem';
|
||||
head.style.color = 'var(--text-muted)';
|
||||
list.appendChild(head);
|
||||
|
||||
groups[dateLabel].forEach(task => {
|
||||
let li = document.createElement('li');
|
||||
li.style.padding = '0.5rem 0';
|
||||
li.style.borderBottom = '1px solid var(--border)';
|
||||
|
||||
let row = document.createElement('div');
|
||||
row.style.display = 'flex';
|
||||
row.style.justifyContent = 'space-between';
|
||||
|
||||
let textSpan = document.createElement('span');
|
||||
textSpan.textContent = "✓ " + task.text;
|
||||
textSpan.style.color = 'var(--primary)';
|
||||
|
||||
// Time
|
||||
let timeSpan = document.createElement('span');
|
||||
let d = new Date(task.completedAt);
|
||||
timeSpan.textContent = d.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
|
||||
timeSpan.style.color = 'var(--text-muted)';
|
||||
timeSpan.style.fontSize = '0.85em';
|
||||
|
||||
row.appendChild(textSpan);
|
||||
row.appendChild(timeSpan);
|
||||
li.appendChild(row);
|
||||
list.appendChild(li);
|
||||
});
|
||||
});
|
||||
}).catch(e => console.error(e));
|
||||
};
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
var clearBtn = document.querySelector('#done-clear');
|
||||
if (clearBtn) {
|
||||
clearBtn.addEventListener('click', () => {
|
||||
if (window.confirm("Are you sure you want to clear your entire accomplishment history?")) {
|
||||
if (window.dbClearTasks) {
|
||||
window.dbClearTasks().then(() => {
|
||||
if (window.renderDoneWall) window.renderDoneWall();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Bind to tab switch
|
||||
document.querySelectorAll('.tab').forEach(tab => {
|
||||
tab.addEventListener('click', e => {
|
||||
if (tab.dataset.tab === 'done') {
|
||||
if (window.renderDoneWall) window.renderDoneWall();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
65
site/static/store.js
Normal file
65
site/static/store.js
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
const DB_NAME = 'MyADHDSyncDB';
|
||||
const DB_VERSION = 1;
|
||||
const DONE_STORE_NAME = 'done_cache';
|
||||
|
||||
let db = null;
|
||||
|
||||
function getStoreDB() {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (db) return resolve(db);
|
||||
const request = indexedDB.open(DB_NAME, DB_VERSION);
|
||||
request.onupgradeneeded = (event) => {
|
||||
const adb = event.target.result;
|
||||
if (!adb.objectStoreNames.contains(DONE_STORE_NAME)) {
|
||||
adb.createObjectStore(DONE_STORE_NAME, { keyPath: 'id', autoIncrement: true });
|
||||
}
|
||||
};
|
||||
request.onsuccess = (event) => {
|
||||
db = event.target.result;
|
||||
resolve(db);
|
||||
};
|
||||
request.onerror = (event) => reject(event.target.error);
|
||||
});
|
||||
}
|
||||
|
||||
window.dbRecordTask = function(text) {
|
||||
return getStoreDB().then((db) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const tx = db.transaction(DONE_STORE_NAME, 'readwrite');
|
||||
const store = tx.objectStore(DONE_STORE_NAME);
|
||||
const req = store.add({
|
||||
text: text,
|
||||
completedAt: new Date().toISOString()
|
||||
});
|
||||
req.onsuccess = () => resolve();
|
||||
req.onerror = () => reject(req.error);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
window.dbGetAllTasks = function() {
|
||||
return getStoreDB().then((db) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const tx = db.transaction(DONE_STORE_NAME, 'readonly');
|
||||
const store = tx.objectStore(DONE_STORE_NAME);
|
||||
const req = store.getAll();
|
||||
req.onsuccess = () => {
|
||||
const sorted = (req.result || []).sort((a,b) => new Date(b.completedAt) - new Date(a.completedAt));
|
||||
resolve(sorted);
|
||||
};
|
||||
req.onerror = () => reject(req.error);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
window.dbClearTasks = function() {
|
||||
return getStoreDB().then((db) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const tx = db.transaction(DONE_STORE_NAME, 'readwrite');
|
||||
const store = tx.objectStore(DONE_STORE_NAME);
|
||||
const req = store.clear();
|
||||
req.onsuccess = () => resolve();
|
||||
req.onerror = () => reject(req.error);
|
||||
});
|
||||
});
|
||||
};
|
||||
Loading…
Reference in a new issue