From 8d148d31ddc8cccc7af0a2e941f20ddfcaf7d248 Mon Sep 17 00:00:00 2001 From: Codex Date: Tue, 13 Oct 2026 14:26:43 +1100 Subject: [PATCH] feat(tasks): add daily and weekly recurring occurrences --- CHANGELOG.md | 8 ++++++++ README.md | 4 ++-- package.json | 5 +++-- public/addons.js | 2 +- public/backup.js | 2 +- public/data-actions.js | 23 +++++++++++++++++----- public/index.html | 2 +- public/locales/ar.json | 5 +++++ public/locales/en.json | 5 +++++ public/locales/es.json | 5 +++++ public/locales/fr.json | 5 +++++ public/locales/ja.json | 5 +++++ public/locales/ru.json | 5 +++++ public/locales/zh-CN.json | 5 +++++ public/locales/zh-HK.json | 5 +++++ public/locales/zh-MO.json | 5 +++++ public/locales/zh-TW.json | 5 +++++ public/service-worker.js | 2 +- public/system-navigation.js | 2 +- public/tasks.js | 13 ++++++++----- public/terminal-app.js | 4 ++-- scripts/build.mjs | 2 +- scripts/test-cloud.mjs | 5 +++++ scripts/test-recurring.mjs | 38 +++++++++++++++++++++++++++++++++++++ scripts/validate.mjs | 2 +- 25 files changed, 141 insertions(+), 23 deletions(-) create mode 100644 scripts/test-recurring.mjs diff --git a/CHANGELOG.md b/CHANGELOG.md index a033cd4..34a6933 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ 本项目按 `v主版本.次版本.修订版本` 标记应用版本;按需创建 Git tag。下列内容以对应提交和已发布功能为准。 +## v1.26.0 — 2026-10-13 + +- 待办创建与编辑新增不重复、每天、每周选项,列表展示重复周期。 +- 完成重复待办后,按原日期周期生成今天之后的下一次;跳过错过日期,保留已完成实例及关联目标、优先级。 +- 下一次待办 ID 由系列与次数决定;重复完成、重新打开旧实例或重载页面不会重复生成。关闭重复只影响该实例之后的生成,已生成实例保留。 +- 重复元数据沿用现有 SQLite、云同步、备份与回收站结构,普通任务保持兼容。 +- 增加每日/每周日期计算、闰年、过期跳过、停止重复、跨客户端 ID 与重复完成测试。 + ## v1.25.0 — 2026-10-13 - 任务与目标接入统一回收站,可恢复原 ID、完成状态、日期、优先级和关联;移入回收站时不删除关联记录。 diff --git a/README.md b/README.md index ef41894..b4fc763 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ 以桌面操作系统为交互方式的个人记录网站。用 App 记录日常、管理目标与待办,并沿时间线回看已经留下的内容。 -在线站点:[Life OS](https://life-os-personal-desktop.biss0.chatgpt.site) · 当前应用版本:**v1.25.0** · [更新日志](CHANGELOG.md) +在线站点:[Life OS](https://life-os-personal-desktop.biss0.chatgpt.site) · 当前应用版本:**v1.26.0** · [更新日志](CHANGELOG.md) ## 功能 @@ -11,7 +11,7 @@ | 今日 | 为选定日期写每日总结,并查看当日瞬间;快速记录支持一天多条文字、标题和标签,独立于每日总结。总结可记录天气、1–5 能量、地点和关联任务;每日电影是写作提示。 | | 时间线 | 按日期浏览记忆,使用关键词或标签筛选,编辑、删除和收藏。 | | 博物馆 | 回看收藏的记忆。 | -| 目标与待办 | 创建和编辑目标、待办,调整日期、优先级、关联目标与完成状态;目标倒计时可选择显示在桌面。 | +| 目标与待办 | 创建和编辑目标、待办,调整日期、优先级、关联目标与完成状态;每天/每周重复待办完成后自动生成下一次,已完成记录保留;目标倒计时可选择显示在桌面。 | | 日历 | 在月视图与日视图中查看记忆、任务、目标、节日和公共假期;按界面语言地区自动选择日历国家,也可手动切换,为选定日期新增记忆。 | | 数据库管理器 | 在再次登录并确认风险后,按表查看、创建、编辑和删除当前账号的云端记录。 | | 洞察 | 周报和月报展示记录频率、完成任务数、常见天气、能量记录及收藏或标记高光的记忆;仅依据已保存的数据统计。 | diff --git a/package.json b/package.json index 38ea011..587ead0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "life-os", - "version": "1.25.0", + "version": "1.26.0", "private": true, "type": "module", "scripts": { @@ -9,7 +9,8 @@ "test:cloud": "node scripts/test-cloud.mjs", "test:reliability": "node scripts/test-reliability.mjs", "test:moments": "node scripts/test-moments.mjs", - "test:task-trash": "node scripts/test-task-trash.mjs" + "test:task-trash": "node scripts/test-task-trash.mjs", + "test:recurring": "node scripts/test-recurring.mjs" }, "dependencies": { "@sqlite.org/sqlite-wasm": "3.53.4-build1" diff --git a/public/addons.js b/public/addons.js index aa3bdf1..c0b0949 100644 --- a/public/addons.js +++ b/public/addons.js @@ -3,7 +3,7 @@ const DRAFT_KEY = 'lifeos_today_draft_v1'; const localDay = () => { const d = new Date(); return `${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,'0')}-${String(d.getDate()).padStart(2,'0')}`; }; const escapeHtml = value => String(value || '').replace(/[&<>"']/g, char => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[char])); - const APP_VERSION = '1.25.0'; + const APP_VERSION = '1.26.0'; window.LifeOSVersion = APP_VERSION; const appIds = ['today', 'timeline', 'museum', 'insights', 'profile', 'tasks', 'calendar', 'system', 'browser', 'terminal', 'database']; const t = (key, values) => LifeI18n.t(key, values); diff --git a/public/backup.js b/public/backup.js index ebaa48b..a89f3e0 100644 --- a/public/backup.js +++ b/public/backup.js @@ -22,7 +22,7 @@ const stored = records(); return { app: 'Life OS', - version: window.LifeOSVersion || '1.25.0', + version: window.LifeOSVersion || '1.26.0', schemaVersion: BACKUP_SCHEMA, exportedAt: new Date().toISOString(), profile: json('lifeos_profile', {}), diff --git a/public/data-actions.js b/public/data-actions.js index e22b12f..aa8925b 100644 --- a/public/data-actions.js +++ b/public/data-actions.js @@ -34,28 +34,41 @@ Object.assign(goal, { title, description: String(description).trim().slice(0, 240), targetDate, showOnDesktop: Boolean(targetDate && showOnDesktop), updatedAt: new Date().toISOString() }); persistBoard(data); return goal; }, - createTask({ title, dueDate = '', goalId = '', priority = 'normal' }) { + createTask({ title, dueDate = '', goalId = '', priority = 'normal', repeat = 'none' }) { title = required(title, 140); if (!validDate(dueDate)) throw new Error('invalidDate'); if (!['normal', 'high', 'low'].includes(priority)) throw new Error('invalidPriority'); + if (!['none','daily','weekly'].includes(repeat) || (repeat !== 'none' && !dueDate)) throw new Error('invalidDate'); const data = board(); if (goalId && !data.goals.some(goal => goal.id === goalId)) throw new Error('notFound'); - const task = { id: `task_${crypto.randomUUID()}`, title, dueDate, goalId, priority, done: false, createdAt: new Date().toISOString() }; + const task = { id: `task_${crypto.randomUUID()}`, title, dueDate, goalId, priority, repeat, done: false, createdAt: new Date().toISOString() }; data.tasks.push(task); persistBoard(data); return task; }, - updateTask(id, { title, dueDate = '', goalId = '', priority = 'normal' }) { + updateTask(id, { title, dueDate = '', goalId = '', priority = 'normal', repeat }) { title = required(title, 140); if (!validDate(dueDate)) throw new Error('invalidDate'); if (!['normal', 'high', 'low'].includes(priority)) throw new Error('invalidPriority'); const data = board(), task = data.tasks.find(item => item.id === id); if (!task || (goalId && !data.goals.some(goal => goal.id === goalId))) throw new Error('notFound'); - Object.assign(task, { title, dueDate, goalId, priority, updatedAt: new Date().toISOString() }); + repeat = repeat ?? task.repeat ?? 'none'; + if (!['none','daily','weekly'].includes(repeat) || (repeat !== 'none' && !dueDate)) throw new Error('invalidDate'); + Object.assign(task, { title, dueDate, goalId, priority, repeat, updatedAt: new Date().toISOString() }); persistBoard(data); return task; }, setTaskDone(id, done) { const data = board(), task = data.tasks.find(item => item.id === id); - if (!task) throw new Error('notFound'); + if (!task || task.trashedAt) throw new Error('notFound'); task.done = done; task.completedAt = done ? new Date().toISOString() : null; + if (done && ['daily','weekly'].includes(task.repeat) && !task.nextOccurrenceId) { + const step=task.repeat==='daily'?1:7, base=Date.parse(`${task.dueDate}T00:00:00Z`), today=Date.parse(`${day()}T00:00:00Z`); + if (!Number.isFinite(base)) throw new Error('invalidDate'); + const advances=Math.max(1,Math.floor((today-base)/(864e5*step))+1); + const dueDate=new Date(base+advances*step*864e5).toISOString().slice(0,10); + const series=task.repeatSeriesId || task.id, occurrence=(task.occurrence || 0)+1; + const nextId=`${series}_occ_${occurrence}`; + task.repeatSeriesId=series; task.nextOccurrenceId=nextId; + if (!data.tasks.some(item=>item.id===nextId)) data.tasks.push({id:nextId,title:task.title,dueDate,goalId:task.goalId,priority:task.priority,repeat:task.repeat,repeatSeriesId:series,occurrence,previousOccurrenceId:task.id,done:false,createdAt:task.completedAt}); + } persistBoard(data); return task; }, setGoalDone(id, done) { diff --git a/public/index.html b/public/index.html index 32651b9..43895da 100644 --- a/public/index.html +++ b/public/index.html @@ -25,4 +25,4 @@ function profileApp(c){let p=profile(),a=mems(),common=Object.entries(a.reduce(( function today(c){let m=mems().find(x=>x.date===day());if(todayDraft===null){selectedMood=m?.mood||'cloudy';selectedEnergy=m?.energy||3}let f=m||filmFor(selectedMood,selectedEnergy),text=todayDraft===null?(m?.text||''):todayDraft,cWeek=new Date().toLocaleDateString(LifeI18n.locale(),{weekday:'long'}).toUpperCase();c.innerHTML=`
${cWeek}

${fmtDate(day()).replace(/^[^,]+, /,'')}

${i18n('How was your day?')}

`}function rerenderToday(){let old=document.querySelector('#entry');todayDraft=old?old.value:todayDraft||'';window.today(document.querySelector('#content-today'));let entry=document.querySelector('#entry');entry?.focus();entry?.setSelectionRange(entry.value.length,entry.value.length)} function systemApp(c){let s=settings(),bytes=new Blob([JSON.stringify({mems:mems(),museum:museum(),profile:profile()})]).size;let rec=s.lastBackup&&(Date.now()-new Date(s.lastBackup)>12096e5);c.innerHTML=`
SYSTEM SETTINGS

System, local and yours.

APPEARANCE
${['dark','light','auto'].map(x=>``).join('')}
LANGUAGE
DATA
STORAGE

Local Storage
${mems().length} memories · ${museum().length} museum items · Approx. ${Math.ceil(bytes/1024)} KB

DATA STORAGE

Your data is stored locally in this browser.
Create regular backups to prevent data loss.

${s.lastBackup?'LAST BACKUP · '+fmtDate(s.lastBackup.slice(0,10)):'LAST BACKUP · NEVER'} ${rec?'
BACKUP RECOMMENDED':''}

VERSION

Life OS
Version ${window.LifeOSVersion||'1.18.1'} · Schema v2

`}function theme(x){let s=settings();s.theme=x;save('lifeos_settings',s);init();renderAll()}function exportData(){let data={app:'Life OS',version:window.LifeOSVersion||'1.18.1',schemaVersion:1,exportedAt:new Date().toISOString(),profile:profile(),memories:mems(),museum:museum(),settings:settings()};let a=document.createElement('a');a.href=URL.createObjectURL(new Blob([JSON.stringify(data,null,2)],{type:'application/json'}));a.download='life-os-backup-'+day()+'.json';a.click();let s=settings();s.lastBackup=new Date().toISOString();save('lifeos_settings',s);renderAll();toast('BACKUP CREATED')}function readImport(el){let f=el.files[0];if(!f)return;let r=new FileReader;r.onload=()=>{try{let d=JSON.parse(r.result);if(d.app!=='Life OS'||![1,2,3].includes(d.schemaVersion)||!Array.isArray(d.memories)||!Array.isArray(d.museum))throw 0;importData=d;importPreview()}catch{toast('INVALID BACKUP FILE')}};r.readAsText(f)}function importPreview(){let d=importData;modal.innerHTML=``}function replaceConfirm(){modal.innerHTML=``}function applyImport(mode){let d=importData;if(mode==='replace'){save('lifeos_memories',d.memories);save('lifeos_museum',d.museum);save('lifeos_profile',d.profile||{});save('lifeos_settings',d.settings||{})}else{let a=mems(), ids=new Set(a.map(x=>x.id)),dates=new Set(a.map(x=>x.date));save('lifeos_memories',[...a,...d.memories.filter(x=>!ids.has(x.id)&&!dates.has(x.date))]);let mu=museum(),mi=new Set(mu.map(x=>x.id));save('lifeos_museum',[...mu,...d.museum.filter(x=>!mi.has(x.id))])}modal.innerHTML='';toast('RESTORING SYSTEM...');setTimeout(()=>{renderAll();toast('SYSTEM RESTORED')},500)}function resetConfirm(){modal.innerHTML=``}function toast(t){let x=document.createElement('div');x.className='toast';x.textContent=t;document.body.append(x);setTimeout(()=>x.remove(),2000)} window.renderIcons=renderIcons;window.renderAll=renderAll;window.toast=toast; - + diff --git a/public/locales/ar.json b/public/locales/ar.json index 987425b..381bf1e 100644 --- a/public/locales/ar.json +++ b/public/locales/ar.json @@ -438,6 +438,11 @@ "holidayCaveat": "قد تتغير المواعيد؛ راجع الإعلانات الرسمية المحلية." }, "tasks": { + "repeatLabel": "التكرار", + "repeatNone": "بدون تكرار", + "repeatDaily": "كل يوم", + "repeatWeekly": "كل أسبوع", + "repeatHint": "عند الإكمال يُنشأ الموعد التالي بعد اليوم وفق الدورة الأصلية مع تخطي المواعيد الماضية. عدّل المهمة الحالية لتغيير التكرار المستقبلي.", "eyebrow": "الأهداف والمهام", "title": "امنح المهم ما يستحقه.", "subtitle": "خطة بسيطة لليوم والأيام المقبلة.", diff --git a/public/locales/en.json b/public/locales/en.json index 57fac5e..373c36a 100644 --- a/public/locales/en.json +++ b/public/locales/en.json @@ -438,6 +438,11 @@ "holidayCaveat": "Dates may change; check local official announcements." }, "tasks": { + "repeatLabel": "Repeat", + "repeatNone": "No repeat", + "repeatDaily": "Every day", + "repeatWeekly": "Every week", + "repeatHint": "Completion creates the next occurrence after today, preserving the schedule and skipping missed dates. Edit the current occurrence to change future repeats.", "eyebrow": "GOALS & TASKS", "title": "Make room for what matters.", "subtitle": "A small, steady plan for today and the days ahead.", diff --git a/public/locales/es.json b/public/locales/es.json index 9c3955c..c146f97 100644 --- a/public/locales/es.json +++ b/public/locales/es.json @@ -438,6 +438,11 @@ "holidayCaveat": "Las fechas pueden cambiar; consulte los anuncios oficiales locales." }, "tasks": { + "repeatLabel": "Repetir", + "repeatNone": "Sin repetición", + "repeatDaily": "Cada día", + "repeatWeekly": "Cada semana", + "repeatHint": "Al completar se crea la siguiente fecha futura según el ciclo original, omitiendo fechas pasadas. Edita la tarea actual para cambiar las futuras.", "eyebrow": "OBJETIVOS Y TAREAS", "title": "Haz espacio para lo importante.", "subtitle": "Un plan sencillo para hoy y los próximos días.", diff --git a/public/locales/fr.json b/public/locales/fr.json index b00ea3d..2d614b0 100644 --- a/public/locales/fr.json +++ b/public/locales/fr.json @@ -438,6 +438,11 @@ "holidayCaveat": "Les dates peuvent changer ; consultez les annonces officielles locales." }, "tasks": { + "repeatLabel": "Répétition", + "repeatNone": "Aucune", + "repeatDaily": "Chaque jour", + "repeatWeekly": "Chaque semaine", + "repeatHint": "La réalisation crée la prochaine occurrence après aujourd’hui, en conservant le rythme et en sautant les dates passées. Modifiez l’occurrence actuelle pour changer les suivantes.", "eyebrow": "OBJECTIFS ET TÂCHES", "title": "Avancez vers l’essentiel.", "subtitle": "Un plan simple pour aujourd’hui et les jours à venir.", diff --git a/public/locales/ja.json b/public/locales/ja.json index 2de135c..7e760ba 100644 --- a/public/locales/ja.json +++ b/public/locales/ja.json @@ -438,6 +438,11 @@ "holidayCaveat": "日付は変更される場合があります。現地の公式発表をご確認ください。" }, "tasks": { + "repeatLabel": "繰り返し", + "repeatNone": "繰り返さない", + "repeatDaily": "毎日", + "repeatWeekly": "毎週", + "repeatHint": "完了すると予定の周期に沿って今日より後の次回を作成し、過ぎた日をスキップします。現在のタスクの編集は以後の繰り返しに適用されます。", "eyebrow": "目標とタスク", "title": "大切なことに時間を使おう。", "subtitle": "今日とこれからのための小さな計画。", diff --git a/public/locales/ru.json b/public/locales/ru.json index 89148cc..5b7fcfb 100644 --- a/public/locales/ru.json +++ b/public/locales/ru.json @@ -438,6 +438,11 @@ "holidayCaveat": "Даты могут измениться; сверяйтесь с официальными объявлениями." }, "tasks": { + "repeatLabel": "Повторение", + "repeatNone": "Без повтора", + "repeatDaily": "Ежедневно", + "repeatWeekly": "Еженедельно", + "repeatHint": "Выполнение создаёт следующую дату после сегодня по исходному циклу, пропуская прошлые даты. Изменяйте текущую задачу для будущих повторов.", "eyebrow": "ЦЕЛИ И ЗАДАЧИ", "title": "Освободите место для важного.", "subtitle": "Небольшой план на сегодня и ближайшие дни.", diff --git a/public/locales/zh-CN.json b/public/locales/zh-CN.json index 1ea8f05..b2a81f8 100644 --- a/public/locales/zh-CN.json +++ b/public/locales/zh-CN.json @@ -438,6 +438,11 @@ "holidayCaveat": "日期可能调整,请以当地官方公告为准。" }, "tasks": { + "repeatLabel": "重复", + "repeatNone": "不重复", + "repeatDaily": "每天", + "repeatWeekly": "每周", + "repeatHint": "完成后按原周期生成今天之后的下一次,跳过已错过的日期。修改当前待办可调整后续重复。", "eyebrow": "目标与待办", "title": "把心力留给重要的事。", "subtitle": "为今天和接下来的日子,排一个轻量、踏实的计划。", diff --git a/public/locales/zh-HK.json b/public/locales/zh-HK.json index 53ffdf8..472decf 100644 --- a/public/locales/zh-HK.json +++ b/public/locales/zh-HK.json @@ -438,6 +438,11 @@ "holidayCaveat": "日期或有調整,請以當地官方公告為準。" }, "tasks": { + "repeatLabel": "重複", + "repeatNone": "不重複", + "repeatDaily": "每天", + "repeatWeekly": "每週", + "repeatHint": "完成後按原週期生成今天之後的下一次,跳過已錯過的日期。修改目前待辦可調整後續重複。", "eyebrow": "目標與待辦", "title": "把心力留給重要的事。", "subtitle": "為今天和接下來的日子,排一個輕量、踏實的計劃。", diff --git a/public/locales/zh-MO.json b/public/locales/zh-MO.json index d23b3a5..16babbb 100644 --- a/public/locales/zh-MO.json +++ b/public/locales/zh-MO.json @@ -438,6 +438,11 @@ "holidayCaveat": "日期或有調整,請以當地官方公告為準。" }, "tasks": { + "repeatLabel": "重複", + "repeatNone": "不重複", + "repeatDaily": "每天", + "repeatWeekly": "每週", + "repeatHint": "完成後按原週期生成今天之後的下一次,跳過已錯過的日期。修改目前待辦可調整後續重複。", "eyebrow": "目標與待辦", "title": "把心力留給重要的事。", "subtitle": "爲今天和接下來的日子,排一個輕量、踏實的計劃。", diff --git a/public/locales/zh-TW.json b/public/locales/zh-TW.json index a85a82b..c2b17cd 100644 --- a/public/locales/zh-TW.json +++ b/public/locales/zh-TW.json @@ -438,6 +438,11 @@ "holidayCaveat": "日期可能調整,請以當地官方公告為準。" }, "tasks": { + "repeatLabel": "重複", + "repeatNone": "不重複", + "repeatDaily": "每天", + "repeatWeekly": "每週", + "repeatHint": "完成後按原週期產生今天之後的下一次,跳過已錯過的日期。修改目前待辦可調整後續重複。", "eyebrow": "目標與待辦", "title": "把心力留給重要的事。", "subtitle": "為今天和接下來的日子,排一個輕量、踏實的計劃。", diff --git a/public/service-worker.js b/public/service-worker.js index 8ab24cf..9013280 100644 --- a/public/service-worker.js +++ b/public/service-worker.js @@ -1,4 +1,4 @@ -const CACHE = 'life-os-shell-v1.25.0'; +const CACHE = 'life-os-shell-v1.26.0'; const SHELL = [ '/', '/index.html', '/manifest.webmanifest', '/life-os-icon.svg', '/local-db-worker.js', '/sqlite3.mjs', '/sqlite3.wasm' diff --git a/public/system-navigation.js b/public/system-navigation.js index fe60e9b..02fbd4c 100644 --- a/public/system-navigation.js +++ b/public/system-navigation.js @@ -27,7 +27,7 @@ shell.innerHTML = `
${t('settings')}

${t(active)}

${active === 'home' ? `

${t('homeHint')}

` : ''}
`; const view = shell.querySelector('.system-settings-view'); if (active === 'home') { - view.innerHTML = `
${t('device')}

${t('deviceHint')}

${t('version', { version: window.LifeOSVersion || '1.25.0' })}
${t('quickSettings')}
${['appearance', 'notifications', 'language', 'data'].map(id => `
${navigationButton(id, true)}

${t(`${id}Hint`)}

`).join('')}
`; + view.innerHTML = `
${t('device')}

${t('deviceHint')}

${t('version', { version: window.LifeOSVersion || '1.26.0' })}
${t('quickSettings')}
${['appearance', 'notifications', 'language', 'data'].map(id => `
${navigationButton(id, true)}

${t(`${id}Hint`)}

`).join('')}
`; } else { const group = document.createElement('div'); group.className = 'settings system-settings-group'; diff --git a/public/tasks.js b/public/tasks.js index bc9cf5a..f09bec2 100644 --- a/public/tasks.js +++ b/public/tasks.js @@ -2,6 +2,7 @@ (() => { const t = (key, values) => LifeI18n.t(`tasks.${key}`, values); let filter = 'all'; + const repeatOptions = (value='none') => ['none','daily','weekly'].map(item=>``).join(''); const esc = value => String(value || '').replace(/[&<>"']/g, char => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[char])); const board = () => { const state = sys(); @@ -25,11 +26,11 @@ const goalOptions = data.goals.filter(goal => !goal.done).map(goal => ``).join(''); container.innerHTML = `
${t('eyebrow')}

${t('title')}

${t('subtitle')}

${t('todayHeading')}
${todayTasks}${t('openCount', { count: open })}
${todayTasks ? '↗' : '✓'}
-
+

${t('repeatHint')}

${visible.length ? visible.map(task => { const goal = data.goals.find(item => item.id === task.goalId); - return `
${esc(task.title)}
${t(`priority.${task.priority}`)}${goal ? `${esc(goal.title)}` : ''}${isOverdue(task) ? `${t('overdue')} · ` : ''}${task.dueDate ? t('due', { date: dateLabel(task.dueDate) }) : t('noDate')}
`; + return `
${esc(task.title)}
${t(`priority.${task.priority}`)}${task.repeat && task.repeat !== 'none' ? `${t(task.repeat==='daily'?'repeatDaily':'repeatWeekly')}` : ''}${goal ? `${esc(goal.title)}` : ''}${isOverdue(task) ? `${t('overdue')} · ` : ''}${task.dueDate ? t('due', { date: dateLabel(task.dueDate) }) : t('noDate')}
`; }).join('') : `
○

${t('noTasks')}

`}
${t('activeGoals')}
${activeGoals.length}
${activeGoals.length ? `
${activeGoals.map(goal => { const linked = data.tasks.filter(task => task.goalId === goal.id), completed = linked.filter(task => task.done).length, progress = linked.length ? Math.round(completed / linked.length * 100) : 0; @@ -43,19 +44,20 @@ event.preventDefault(); const form = event.currentTarget, input = form.querySelector('#task-new-title'), title = input.value.trim(); if (!title) return; - window.LifeOSActions.createTask({ title, dueDate: form.querySelector('#task-new-date').value || '', goalId: form.querySelector('#task-new-goal').value || '', priority: form.querySelector('#task-new-priority').value || 'normal' }); toast('tasks.taskAdded'); + const repeat = form.querySelector('#task-new-repeat')?.value || 'none'; + window.LifeOSActions.createTask({ title, dueDate: form.querySelector('#task-new-date').value || (repeat !== 'none' ? day() : ''), goalId: form.querySelector('#task-new-goal').value || '', priority: form.querySelector('#task-new-priority').value || 'normal', repeat }); toast('tasks.taskAdded'); }; window.toggleTask = id => { const task = board().tasks.find(item => item.id === id); if (task) window.LifeOSActions.setTaskDone(id, !task.done); }; window.deleteTask = id => { window.LifeOSActions.deleteTask(id); toast('tasks.taskRemoved'); }; window.openTaskEdit = id => { const task = board().tasks.find(item => item.id === id); if (!task) return; const goals = board().goals.map(goal => ``).join(''); - document.querySelector('#modal').innerHTML = ``; + document.querySelector('#modal').innerHTML = ``; setTimeout(() => document.querySelector('#task-edit-title-input')?.focus(), 0); }; window.saveTaskEdit = event => { event.preventDefault(); const form = event.currentTarget, id = form.dataset.id; - window.LifeOSActions.updateTask(id, { title: form.querySelector('#task-edit-title-input').value, dueDate: form.querySelector('#task-edit-date').value, goalId: form.querySelector('#task-edit-goal').value, priority: form.querySelector('#task-edit-priority').value }); + window.LifeOSActions.updateTask(id, { title: form.querySelector('#task-edit-title-input').value, dueDate: form.querySelector('#task-edit-date').value, goalId: form.querySelector('#task-edit-goal').value, priority: form.querySelector('#task-edit-priority').value, repeat: form.querySelector('#task-edit-repeat')?.value }); closeModal(); toast('tasks.taskUpdated'); }; window.openGoalForm = (id = '') => { @@ -81,4 +83,5 @@ const style = document.createElement('style'); style.textContent = `.task-head{display:flex;align-items:flex-start;justify-content:space-between;gap:14px}.task-head h1{max-width:430px}.task-head .secondary{white-space:nowrap}.task-focus{display:flex;align-items:center;justify-content:space-between;margin:18px 0;padding:18px 20px;background:linear-gradient(115deg,color-mix(in srgb,var(--accent) 15%,var(--panel2)),var(--panel2));border:1px solid var(--line);border-radius:13px}.task-focus .eyebrow{margin-bottom:5px}.task-focus strong{font-size:30px;letter-spacing:-.06em}.task-focus span{margin-left:10px;color:var(--muted);font-size:12px}.task-focus-mark{font-size:26px;color:var(--accent)}.task-quick{display:grid;grid-template-columns:minmax(130px,1fr) 145px 120px 95px auto;gap:7px}.task-quick input,.task-quick select,.goal-form input,.goal-form textarea,.goal-form select{min-width:0;border:1px solid var(--line);background:var(--panel2);border-radius:8px;padding:10px 11px;outline:none}.task-quick input:focus,.task-quick select:focus,.goal-form input:focus,.goal-form textarea:focus,.goal-form select:focus{border-color:var(--accent)}.task-quick select{font-size:12px}.task-quick .primary{padding:10px 11px;white-space:nowrap}.task-filters{display:flex;gap:7px;flex-wrap:wrap;margin:19px 0 8px}.task-filters .chip{padding:7px 12px}.task-list{display:grid;gap:7px}.task-row{display:flex;align-items:center;gap:12px;padding:12px;background:color-mix(in srgb,var(--panel2) 55%,transparent);border:1px solid var(--line);border-radius:10px}.task-check{flex:none;width:21px;height:21px;border:1px solid var(--muted);border-radius:7px;background:transparent;color:var(--accent);font-weight:700}.task-check[aria-pressed=true]{background:var(--accent);border-color:var(--accent);color:var(--bg)}.task-copy{min-width:0;flex:1}.task-copy>strong{display:block;font-size:13px;font-weight:550;overflow-wrap:anywhere}.task-meta{display:flex;align-items:center;gap:9px;flex-wrap:wrap;margin-top:5px;color:var(--muted);font-size:10px}.task-meta span{display:inline-flex;align-items:center;gap:4px}.task-meta b,.is-overdue .task-meta{color:#df8a70}.task-priority{font:9px 'DM Mono';letter-spacing:.05em}.task-priority.high{color:#df8a70}.task-priority.low{color:var(--muted)}.is-done .task-copy>strong{text-decoration:line-through;color:var(--muted)}.task-edit{border:1px solid var(--line);border-radius:7px;background:transparent;color:var(--muted);font:10px 'DM Mono';padding:6px 8px;white-space:nowrap}.task-edit:hover,.task-edit:focus-visible{color:var(--accent);border-color:var(--accent)}.task-delete{width:28px;height:28px;border:0;border-radius:7px;background:transparent;color:var(--muted);font-size:19px;line-height:1}.task-delete:hover{background:var(--panel2);color:var(--ink)}.task-empty,.goal-empty{padding:21px;text-align:center;color:var(--muted);font-size:13px}.task-empty span{font-size:23px;color:var(--accent)}.goal-section{margin-top:24px;padding-top:16px;border-top:1px solid var(--line)}.goal-section-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:10px}.goal-section-head .eyebrow{margin:0}.goal-count{font:11px 'DM Mono';color:var(--muted)}.goal-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:9px}.goal-card{min-width:0;padding:14px;border:1px solid var(--line);border-radius:11px;background:color-mix(in srgb,var(--panel2) 55%,transparent)}.goal-card-top{display:flex;justify-content:space-between;align-items:center}.goal-actions{display:flex;align-items:center;gap:4px;flex-wrap:wrap;justify-content:flex-end}.goal-desktop-toggle{border:1px solid var(--line);border-radius:7px;background:transparent;color:var(--muted);font:9px 'DM Mono';padding:6px 8px;white-space:nowrap}.goal-desktop-toggle.selected{color:var(--accent);border-color:var(--accent)}.goal-form label.goal-pin-option{display:flex!important;grid-template-columns:18px 1fr;align-items:center;gap:8px!important}.goal-form label.goal-pin-option input{width:16px;height:16px;min-width:16px;padding:0;accent-color:var(--accent)}.goal-finish{border:0;background:transparent;color:var(--muted);font:9px 'DM Mono';letter-spacing:.04em;padding:5px}.goal-finish:hover{color:var(--accent)}.finished-goals{margin-top:14px}.finished-goals summary{cursor:pointer;color:var(--muted);font:10px 'DM Mono';letter-spacing:.08em;margin-bottom:9px}.is-goal-done{opacity:.72}.goal-mark{font-size:20px;color:var(--accent)}.goal-card h3{margin:8px 0 4px;font-size:15px;letter-spacing:-.025em;overflow-wrap:anywhere}.goal-card p{margin:0 0 12px;color:var(--muted);font-size:11px;line-height:1.5}.goal-progress-line{display:flex;justify-content:space-between;gap:8px;margin-top:11px;font:9px 'DM Mono';color:var(--muted)}.goal-progress{height:4px;background:var(--line);border-radius:5px;margin-top:5px;overflow:hidden}.goal-progress i{display:block;height:100%;background:var(--accent);border-radius:5px}.goal-date{margin-top:10px;color:var(--muted);font-size:10px}.goal-form{display:grid;gap:13px}.goal-form h2{font-size:21px;margin-bottom:0}.goal-form label{display:grid;gap:6px;color:var(--muted);font-size:12px}.goal-form textarea{resize:vertical}.goal-form .actions{margin:0}.desktop-goal-countdowns{position:absolute;z-index:1;top:24px;right:28px;width:min(310px,30vw);max-height:72vh;overflow:auto;display:grid;gap:8px}.desktop-goal-countdowns.hidden{display:none}.desktop-goal-heading{color:var(--muted);font:10px 'DM Mono';letter-spacing:.15em;text-align:right}.desktop-goal-card{display:grid;gap:5px;width:100%;padding:13px 15px;text-align:left;background:color-mix(in srgb,var(--panel) 88%,transparent);border:1px solid var(--line);border-radius:12px;box-shadow:var(--shadow);backdrop-filter:blur(12px)}.desktop-goal-card span{font-size:13px;font-weight:600;overflow-wrap:anywhere}.desktop-goal-card strong{color:var(--accent);font:500 13px 'DM Mono'}.desktop-goal-card small{color:var(--muted);font-size:11px}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}@media(max-width:650px){.desktop-goal-countdowns{position:relative;top:auto;right:auto;width:auto;max-width:none;max-height:30vh;margin:12px 16px 92px;overflow:auto;grid-template-columns:repeat(2,minmax(0,1fr));align-items:start}.desktop-goal-heading{grid-column:1/-1;text-align:left}.desktop-icons{padding:76px 14px 18px;display:flex;flex-wrap:wrap;justify-content:flex-start;gap:16px 4px}.app-icon{flex:0 0 calc(25% - 4px);min-width:0;justify-items:center;font-size:10px;letter-spacing:.04em}.desktop-goal-card{padding:11px 12px}.desktop-goal-card span{font-size:12px}}@media(min-width:651px){.desktop-icons{padding:72px 32px;display:grid;grid-template-columns:96px;justify-items:start;align-content:start;gap:14px}.app-icon{width:96px;justify-items:center;font-size:11px}.desktop-goal-countdowns{top:26px;right:30px;width:min(330px,28vw);max-height:calc(100vh - 110px)}}@media(max-width:700px){.task-quick{grid-template-columns:1fr 1fr}.task-quick input:first-of-type{grid-column:1/-1}.task-quick .primary{grid-column:1/-1}.task-head{align-items:flex-start}.task-head .secondary{font-size:9px;padding:9px 10px}.goal-grid{grid-template-columns:1fr}.task-meta{gap:6px}.task-focus{padding:14px}.task-focus span{display:block;margin:3px 0 0}}`; document.head.append(style); + const repeatStyle=document.createElement('style'); repeatStyle.textContent=`.task-quick{grid-template-columns:repeat(3,minmax(0,1fr))}.task-quick>input:first-of-type,.task-quick>.primary,.task-repeat-hint{grid-column:1/-1}.task-repeat-hint{margin:2px 0;font-size:13px;color:var(--muted);line-height:1.5}@media(max-width:700px){.task-quick{grid-template-columns:repeat(2,minmax(0,1fr))}}`; document.head.append(repeatStyle); })(); diff --git a/public/terminal-app.js b/public/terminal-app.js index 8ebe73b..861e6ae 100644 --- a/public/terminal-app.js +++ b/public/terminal-app.js @@ -150,7 +150,7 @@ return { message: new Intl.DateTimeFormat(LifeI18n.locale(), options).format(new Date()) }; } if (kind === 'uptime') { if (verb) throw new Error('usage'); const seconds = Math.floor((Date.now() - startedAt) / 1000); return { message: t('uptime', { minutes: Math.floor(seconds / 60), seconds: seconds % 60 }) }; } - if (kind === 'version') { if (verb) throw new Error('usage'); return { message: `Life OS v${window.LifeOSVersion || '1.25.0'}` }; } + if (kind === 'version') { if (verb) throw new Error('usage'); return { message: `Life OS v${window.LifeOSVersion || '1.26.0'}` }; } if (kind === 'status') { if (verb) throw new Error('usage'); const data = board(); return { message: t('status', { memories: mems().length, goals: data.goals.length, tasks: data.tasks.length }) }; } if (kind === 'apps') { if (verb) throw new Error('usage'); return { message: Object.keys(APPS).map(id => `${id} — ${LifeI18n.t(`app.${id}`)}`).join('\n') }; } if (kind === 'history') { if (verb) throw new Error('usage'); return { message: history.slice(-20).map((entry,index) => `${index + 1}. ${entry}`).join('\n') || t('empty') }; } @@ -235,7 +235,7 @@ }; window.terminalApp = node => { if (node.querySelector('.terminal-shell') && node.dataset.terminalLocale === lang()) { output(node); return; } - if (!welcomed) { lines.unshift({ value: t('welcome', { version: window.LifeOSVersion || '1.25.0' }), kind: 'system' }); welcomed = true; } + if (!welcomed) { lines.unshift({ value: t('welcome', { version: window.LifeOSVersion || '1.26.0' }), kind: 'system' }); welcomed = true; } node.dataset.terminalLocale = lang(); node.innerHTML = `
Life OS / ${t('title')}${t('hint')}
`; output(node); composer(node, Boolean(compose)); diff --git a/scripts/build.mjs b/scripts/build.mjs index 5762cf4..c819785 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -13,7 +13,7 @@ const [rawIndexHtml, addonsJs, backupJs, bootGuardJs, localDbJs, localDbWorkerJs readFile(new URL("../node_modules/@sqlite.org/sqlite-wasm/dist/sqlite3.wasm", import.meta.url)), text("i18n.js"), text("tasks.js"), text("calendar.js"), text("notifications.js"), text("i18n-renderers.js"), text("desktop-personalization.js"), text("desktop-widgets.js"), text("system-navigation.js"), text("browser-app.js"), text("data-actions.js"), text("terminal-app.js"), text("db-admin.js"), text("manifest.webmanifest"), text("service-worker.js"), text("life-os-icon.svg"), readFile(new URL("../public/locales/en.json", import.meta.url), "utf8"), readFile(new URL("../public/locales/zh-CN.json", import.meta.url), "utf8") ]); -const release = "1.25.0"; +const release = "1.26.0"; const localeEnJs = `window.LifeOSLocales=window.LifeOSLocales||{};window.LifeOSLocales.en=${localeEn};`; const localeZhJs = `window.LifeOSLocales=window.LifeOSLocales||{};window.LifeOSLocales['zh-CN']=${localeZh};`; const extraLocaleCodes = ['zh-HK', 'zh-MO', 'zh-TW', 'ar', 'fr', 'ru', 'es', 'ja']; diff --git a/scripts/test-cloud.mjs b/scripts/test-cloud.mjs index 0803f5c..2da1eec 100644 --- a/scripts/test-cloud.mjs +++ b/scripts/test-cloud.mjs @@ -158,3 +158,8 @@ assert.ok((await call('/api/lifeos-state')).body.state.memories.find(item=>item. delete trashed.trashedAt; assert.equal((await call('/api/lifeos-sync','POST',{kind:'memories',id:trashed.id,baseVersion:2,value:trashed})).status,200,'restoring uses the same cloud record ID'); console.log("Life OS record migration, sync conflict, tags, same-day moments and user isolation valid"); +const recurringCloud={id:'recurring-cloud',title:'Daily review',dueDate:'2026-10-14',repeat:'daily',repeatSeriesId:'series-one',occurrence:1,done:false}; +assert.equal((await call('/api/lifeos-sync','POST',{kind:'tasks',id:recurringCloud.id,baseVersion:0,value:recurringCloud})).status,200); +const loadedRecurring=(await call('/api/lifeos-state')).body.state.system.tasksBoard.tasks.find(item=>item.id===recurringCloud.id); +assert.equal(loadedRecurring.repeat,'daily');assert.equal(loadedRecurring.repeatSeriesId,'series-one');assert.equal(loadedRecurring.occurrence,1); +assert.equal((await call('/api/lifeos-sync','POST',{kind:'tasks',id:recurringCloud.id,baseVersion:0,value:recurringCloud})).status,409,'the same occurrence ID cannot create a duplicate cloud record'); diff --git a/scripts/test-recurring.mjs b/scripts/test-recurring.mjs new file mode 100644 index 0000000..deece85 --- /dev/null +++ b/scripts/test-recurring.mjs @@ -0,0 +1,38 @@ +import assert from 'node:assert/strict'; +import {readFileSync} from 'node:fs'; +import vm from 'node:vm'; +const source=readFileSync(new URL('../public/data-actions.js',import.meta.url),'utf8'); +function client(date,initial={tasksBoard:{goals:[],tasks:[]}}) { + let state=structuredClone(initial); + const ctx=vm.createContext({sys:()=>structuredClone(state),mems:()=>[],museum:()=>[],save:(key,value)=>{if(key==='lifeos_system')state=structuredClone(value);},renderAll(){},day:()=>date,crypto:globalThis.crypto}); + ctx.window=ctx;vm.runInContext(source,ctx); + return {action:ctx.LifeOSActions,state:()=>structuredClone(state)}; +} +const a=client('2026-10-13'); +const first=a.action.createTask({title:'Daily review',dueDate:'2026-10-13',repeat:'daily',priority:'high'}); +const before=a.state(); +a.action.setTaskDone(first.id,true); +let tasks=a.action.board().tasks; +assert.equal(tasks.length,2); +assert.equal(tasks[0].done,true); +assert.equal(tasks[1].dueDate,'2026-10-14'); +assert.equal(tasks[1].priority,'high'); +assert.equal(tasks[1].repeat,'daily'); +a.action.setTaskDone(first.id,false);a.action.setTaskDone(first.id,true); +assert.equal(a.action.board().tasks.length,2,'recompleting does not create duplicates'); +const other=client('2026-10-13',before);other.action.setTaskDone(first.id,true); +assert.equal(other.action.board().tasks[1].id,tasks[1].id,'two clients derive the same occurrence ID'); +const reloaded=client('2026-10-13',a.state());reloaded.action.setTaskDone(first.id,true); +assert.equal(reloaded.action.board().tasks.length,2,'idempotence survives reload'); +const second=tasks[1];a.action.updateTask(second.id,{title:second.title,dueDate:second.dueDate,priority:second.priority,repeat:'none'}); +a.action.setTaskDone(second.id,true); +assert.equal(a.action.board().tasks.length,2,'turning repetition off stops generation'); +const w=client('2026-10-13');const weekly=w.action.createTask({title:'Weekly review',dueDate:'2026-09-21',repeat:'weekly'}); +w.action.setTaskDone(weekly.id,true); +assert.equal(w.action.board().tasks[1].dueDate,'2026-10-19','overdue weekly task preserves weekday and skips missed dates'); +const leap=client('2028-02-28');const leapTask=leap.action.createTask({title:'Leap test',dueDate:'2028-02-28',repeat:'daily'}); +leap.action.setTaskDone(leapTask.id,true); +assert.equal(leap.action.board().tasks[1].dueDate,'2028-02-29'); +assert.throws(()=>a.action.createTask({title:'No date',repeat:'daily'}),/invalidDate/); +assert.throws(()=>a.action.createTask({title:'Unsupported repeat',dueDate:'2026-10-13',repeat:'monthly'}),/invalidDate/); +console.log('Life OS recurring task schedule, stop, cross-client IDs and replay protection valid'); diff --git a/scripts/validate.mjs b/scripts/validate.mjs index 226a803..f0943ab 100644 --- a/scripts/validate.mjs +++ b/scripts/validate.mjs @@ -285,7 +285,7 @@ assert.ok(command('date').message.length > 8); assert.ok(command('time').message.includes(':')); assert.ok(command('datetime').message.length > 12); assert.equal(command('uptime').message, 'terminal.uptime'); -assert.equal(command('version').message, 'Life OS v1.25.0'); +assert.equal(command('version').message, 'Life OS v1.26.0'); assert.equal(command('status').message, 'terminal.status'); assert.match(command('apps').message, /calendar/); assert.equal(command('echo "hello Life OS"').message, 'hello Life OS');