From 3d3e798c3418ad705324a00f785ffb1f79e214e3 Mon Sep 17 00:00:00 2001 From: djg Date: Wed, 23 Sep 2026 17:07:09 +0000 Subject: [PATCH 1/6] feat(shortcuts): add Alt+P quick capture overlay --- site/index.html | 13 +++++++++++++ site/static/app.js | 26 ++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/site/index.html b/site/index.html index b522b07..d855dcf 100644 --- a/site/index.html +++ b/site/index.html @@ -27,6 +27,7 @@ Dopamine menu One thing Brain dump + Done-Wall + + +
diff --git a/site/static/app.js b/site/static/app.js index 4d15e13..5faa732 100644 --- a/site/static/app.js +++ b/site/static/app.js @@ -955,6 +955,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; From b9bd6ae5e64599573996a6bb4384559eec1c88f1 Mon Sep 17 00:00:00 2001 From: djg Date: Wed, 23 Sep 2026 17:07:42 +0000 Subject: [PATCH 2/6] feat(ai): add Tier 1 & 2 Auto-Deconstruct contract API logic --- site/static/app.js | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/site/static/app.js b/site/static/app.js index 4d15e13..cc03a40 100644 --- a/site/static/app.js +++ b/site/static/app.js @@ -432,6 +432,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) { From 2db8a05a5e6323545c261e6f3c27d37fecdb49ee Mon Sep 17 00:00:00 2001 From: djg Date: Wed, 23 Sep 2026 17:09:19 +0000 Subject: [PATCH 3/6] feat: implement Accomplishments Done-Wall and IndexedDB datastore for task completion tracing --- site/index.html | 20 ++++++++++ site/static/app.js | 8 ++++ site/static/done.js | 90 ++++++++++++++++++++++++++++++++++++++++++++ site/static/store.js | 65 ++++++++++++++++++++++++++++++++ 4 files changed, 183 insertions(+) create mode 100644 site/static/done.js create mode 100644 site/static/store.js diff --git a/site/index.html b/site/index.html index b522b07..4ff0d9b 100644 --- a/site/index.html +++ b/site/index.html @@ -278,6 +278,24 @@ + +
@@ -352,6 +370,8 @@ + + diff --git a/site/static/app.js b/site/static/app.js index 4d15e13..67a625e 100644 --- a/site/static/app.js +++ b/site/static/app.js @@ -676,8 +676,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') { @@ -688,6 +695,7 @@ breakerRender(); } } + handleNewDoneTasks(taskText); localStorage.removeItem('myadhd.now'); // Check if there's a next step from breaker var b2 = store(breakerKey); diff --git a/site/static/done.js b/site/static/done.js new file mode 100644 index 0000000..32e57a0 --- /dev/null +++ b/site/static/done.js @@ -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(); + } + }); + }); +}); diff --git a/site/static/store.js b/site/static/store.js new file mode 100644 index 0000000..24de0ba --- /dev/null +++ b/site/static/store.js @@ -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); + }); + }); +}; From 8e69e24869ab620461a53ce95ba90ef516589257 Mon Sep 17 00:00:00 2001 From: djg Date: Wed, 23 Sep 2026 17:12:04 +0000 Subject: [PATCH 4/6] fix(done-wall): intercept timer modal completion path to correctly hydrate the IndexedDB history records upon resolving the action natively --- site/static/app.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/site/static/app.js b/site/static/app.js index 67a625e..0288e48 100644 --- a/site/static/app.js +++ b/site/static/app.js @@ -466,6 +466,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]) { @@ -474,6 +475,7 @@ breakerRender(); } } + handleNewDoneTasks(taskText); // Reset timer so it's fresh for the next step timerReset(); // Clear one-thing and show next step prompt From 0e7d1e796d5a6f5636ea3f6f47462bf0916a9012 Mon Sep 17 00:00:00 2001 From: djg Date: Wed, 23 Sep 2026 19:01:19 +0000 Subject: [PATCH 5/6] feat(audio): implement rain and 40hz gamma procedural generation --- site/static/audio.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/site/static/audio.js b/site/static/audio.js index fd26e24..ab70ed9 100644 --- a/site/static/audio.js +++ b/site/static/audio.js @@ -15,7 +15,21 @@ function createNoiseBuffer(type) { const buffer = audioCtx.createBuffer(1, bufferSize, audioCtx.sampleRate); const output = buffer.getChannelData(0); - if (type === 'brown') { + if (type === 'rain') { + // Procedural rain using a low-pass filter over white noise + 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 === 'gamma') { + // 40Hz Gamma binaural - just placeholder noise here, handled in real oscillators playing + for (let i = 0; i < bufferSize; i++) { + output[i] = (Math.random() * 2 - 1) * 0.1; + } + } else if (type === 'brown') { let lastOut = 0; for (let i = 0; i < bufferSize; i++) { let white = Math.random() * 2 - 1; From ad413165eeb99d2e9e212cfc816382079e7b1740 Mon Sep 17 00:00:00 2001 From: djg Date: Wed, 23 Sep 2026 19:06:24 +0000 Subject: [PATCH 6/6] fix(audio): implement true 40hz binaural stereo oscillators --- site/static/audio.js | 56 ++++++++++++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/site/static/audio.js b/site/static/audio.js index ab70ed9..3a24983 100644 --- a/site/static/audio.js +++ b/site/static/audio.js @@ -7,16 +7,12 @@ 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 === 'rain') { - // Procedural rain using a low-pass filter over white noise let lastOut = 0; for (let i = 0; i < bufferSize; i++) { let white = Math.random() * 2 - 1; @@ -24,18 +20,13 @@ function createNoiseBuffer(type) { lastOut = output[i]; output[i] *= 2.0; } - } else if (type === 'gamma') { - // 40Hz Gamma binaural - just placeholder noise here, handled in real oscillators playing - for (let i = 0; i < bufferSize; i++) { - output[i] = (Math.random() * 2 - 1) * 0.1; - } } 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; @@ -48,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; } } @@ -83,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; @@ -97,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); @@ -111,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); } @@ -119,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);