From 47bded8af736be8c312d06a2097cf6f01d2b3402 Mon Sep 17 00:00:00 2001 From: Codex Date: Tue, 13 Oct 2026 14:06:39 +1100 Subject: [PATCH] feat(tasks): add recoverable task and goal deletion --- CHANGELOG.md | 7 +++++++ README.md | 4 ++-- package.json | 5 +++-- public/addons.js | 7 ++++--- public/backup.js | 2 +- public/calendar.js | 2 +- public/data-actions.js | 25 ++++++++++++++++++++++++- public/desktop-widgets.js | 2 +- public/i18n-renderers.js | 20 ++++++++++---------- public/index.html | 2 +- public/local-db-worker.js | 4 ++-- public/locales/ar.json | 14 +++++++------- public/locales/en.json | 14 +++++++------- public/locales/es.json | 14 +++++++------- public/locales/fr.json | 14 +++++++------- public/locales/ja.json | 14 +++++++------- public/locales/ru.json | 10 +++++----- public/locales/zh-CN.json | 14 +++++++------- public/locales/zh-HK.json | 14 +++++++------- public/locales/zh-MO.json | 14 +++++++------- public/locales/zh-TW.json | 14 +++++++------- public/notifications.js | 2 +- public/service-worker.js | 2 +- public/system-navigation.js | 2 +- public/tasks.js | 4 ++-- public/terminal-app.js | 4 ++-- scripts/build.mjs | 2 +- scripts/test-task-trash.mjs | 35 +++++++++++++++++++++++++++++++++++ scripts/validate.mjs | 10 +++++----- 29 files changed, 172 insertions(+), 105 deletions(-) create mode 100644 scripts/test-task-trash.mjs diff --git a/CHANGELOG.md b/CHANGELOG.md index eb43d73..a033cd4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ 本项目按 `v主版本.次版本.修订版本` 标记应用版本;按需创建 Git tag。下列内容以对应提交和已发布功能为准。 +## v1.25.0 — 2026-10-13 + +- 任务与目标接入统一回收站,可恢复原 ID、完成状态、日期、优先级和关联;移入回收站时不删除关联记录。 +- 永久删除目标才解除任务关联,永久删除任务才解除记忆关联;回收站记录不参与搜索、日历、通知、洞察与桌面倒计时。 +- 创建任务、编辑目标偏好等写入操作保留既有回收站记录;本地 SQLite、云同步和备份继续兼容。 +- 增加任务和目标软删除、恢复、写入保护及永久关联清理测试。 + ## v1.24.0 — 2026-10-13 - 每日总结和瞬间删除后先移入回收站,可在系统设置的数据与备份页面查看、恢复或二次确认永久删除。 diff --git a/README.md b/README.md index 24ab987..ef41894 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ 以桌面操作系统为交互方式的个人记录网站。用 App 记录日常、管理目标与待办,并沿时间线回看已经留下的内容。 -在线站点:[Life OS](https://life-os-personal-desktop.biss0.chatgpt.site) · 当前应用版本:**v1.24.0** · [更新日志](CHANGELOG.md) +在线站点:[Life OS](https://life-os-personal-desktop.biss0.chatgpt.site) · 当前应用版本:**v1.25.0** · [更新日志](CHANGELOG.md) ## 功能 @@ -32,7 +32,7 @@ ## 数据与备份 -记忆和瞬间的删除操作会先移入回收站。系统设置 → 数据与备份 → 回收站可预览、恢复或确认永久删除;不会自动清理。恢复保留原记录 ID、标签与收藏关系。如果该日期已有新的每日总结,会阻止恢复并提示处理,避免覆盖。回收站状态参与云同步和 JSON 备份;永久删除后不能通过回收站恢复,已有独立备份仍保留当时的内容。任务和目标暂不进入回收站。 +记忆、瞬间、任务和目标的删除操作会先移入回收站。系统设置 → 数据与备份 → 回收站可预览、恢复或确认永久删除;不会自动清理。恢复保留原记录 ID、属性与关联。如果该日期已有新的每日总结,会阻止恢复并提示处理,避免覆盖。回收站状态参与云同步和 JSON 备份;永久删除后不能通过回收站恢复,已有独立备份仍保留当时的内容。永久删除目标会解除任务关联,永久删除任务会解除记忆关联,关联记录本身不会被删除。 首次使用可选择“仅本地使用”或“登录并云同步”。仅本地模式无需登录,也不会请求云同步接口;数据写入当前设备、当前浏览器、本站专属的 OPFS 私有存储区,逻辑数据库位置为 `OPFS:/lifeos.sqlite`。SQLite 是本地持久层,`localStorage` 作为同步界面缓存和兼容旧版本的数据迁移来源。SQLite Schema v2 会将记忆、目标、待办和收藏投影为独立关系表,用于索引和全局检索;升级时自动从已有状态重建,不需要手动迁移。系统设置会显示当前模式、数据库状态、近似大小和持久存储状态。 diff --git a/package.json b/package.json index 48abd45..38ea011 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "life-os", - "version": "1.24.0", + "version": "1.25.0", "private": true, "type": "module", "scripts": { @@ -8,7 +8,8 @@ "validate": "node scripts/validate.mjs", "test:cloud": "node scripts/test-cloud.mjs", "test:reliability": "node scripts/test-reliability.mjs", - "test:moments": "node scripts/test-moments.mjs" + "test:moments": "node scripts/test-moments.mjs", + "test:task-trash": "node scripts/test-task-trash.mjs" }, "dependencies": { "@sqlite.org/sqlite-wasm": "3.53.4-build1" diff --git a/public/addons.js b/public/addons.js index ae7a81a..aa3bdf1 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.24.0'; + const APP_VERSION = '1.25.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); @@ -51,7 +51,7 @@ const results = box.querySelector('.lifeos-search-results'); let searchSequence = 0; const localResults = query => { - const board = sys().tasksBoard || { goals: [], tasks: [] }; + const board = window.LifeOSActions.board(); const rows = [ ...mems().map(item => ({ kind:'memory', id:item.id, title:item.title || item.text?.trim().split('\n')[0].slice(0,64) || t('timeline.untitled'), meta:item.date, snippet:[item.text, ...(item.tags || []), item.location, item.mood].filter(Boolean).join(' · '), updated_at:item.updatedAt || item.date })), ...(board.tasks || []).map(item => ({ kind:'task', id:item.id, title:item.title, meta:item.dueDate || '', snippet:item.priority || '', updated_at:item.updatedAt || item.createdAt || '' })), @@ -67,7 +67,8 @@ const indexed = await window.LifeOSLocalDB.search(query, 12); const current = new Map(found.map(item => [`${item.kind}:${item.id}`, item])); const activeIds = new Set(mems().map(item => item.id)); - indexed.forEach(item => { if (item.kind === 'memory' && !activeIds.has(item.id)) return; const key = `${item.kind}:${item.id}`; if (!current.has(key)) current.set(key, item); }); + const activeBoard=window.LifeOSActions.board(), activeTasks=new Set(activeBoard.tasks.map(item=>item.id)), activeGoals=new Set(activeBoard.goals.map(item=>item.id)); + indexed.forEach(item => { if ((item.kind === 'memory' && !activeIds.has(item.id)) || (item.kind==='task' && !activeTasks.has(item.id)) || (item.kind==='goal' && !activeGoals.has(item.id))) return; const key = `${item.kind}:${item.id}`; if (!current.has(key)) current.set(key, item); }); found = [...current.values()].slice(0, 12); } catch {} } diff --git a/public/backup.js b/public/backup.js index 03ffee8..ebaa48b 100644 --- a/public/backup.js +++ b/public/backup.js @@ -22,7 +22,7 @@ const stored = records(); return { app: 'Life OS', - version: window.LifeOSVersion || '1.24.0', + version: window.LifeOSVersion || '1.25.0', schemaVersion: BACKUP_SCHEMA, exportedAt: new Date().toISOString(), profile: json('lifeos_profile', {}), diff --git a/public/calendar.js b/public/calendar.js index 85bd39c..a8f0717 100644 --- a/public/calendar.js +++ b/public/calendar.js @@ -66,7 +66,7 @@ function eventsFor(key) { const events = []; for (const memory of mems()) if (memory.date === key) events.push({ kind: 'memory', rank: 0, title: memory.title || memory.text?.trim().split('\n')[0].slice(0, 64) || t('timeline.untitled'), detail: memory.text || LifeI18n.t('timeline.noNote'), time: '', id: memory.id, mood: memory.contextRecorded === false ? '' : memory.mood, energy: memory.contextRecorded === false ? null : memory.energy }); - const board = system().tasksBoard || { goals: [], tasks: [] }; + const raw = system().tasksBoard || { goals: [], tasks: [] }, board={goals:(raw.goals||[]).filter(item=>!item.trashedAt),tasks:(raw.tasks||[]).filter(item=>!item.trashedAt)}; for (const task of board.tasks || []) { const due = task.dueDate === key, completed = localDatePart(task.completedAt) === key; if (due) events.push({ kind: 'task', rank: completed ? 1 : 2, title: task.title, detail: task.goalId ? board.goals.find(goal => goal.id === task.goalId)?.title || '' : '', time: completed ? t('taskDone') : t('taskDue'), done: Boolean(task.done), id: task.id }); diff --git a/public/data-actions.js b/public/data-actions.js index 37f5662..e22b12f 100644 --- a/public/data-actions.js +++ b/public/data-actions.js @@ -9,6 +9,7 @@ const current = sys().tasksBoard; return current && Array.isArray(current.goals) && Array.isArray(current.tasks) ? current : { goals: [], tasks: [] }; }; + const activeBoard = () => { const data=board(); return {goals:data.goals.filter(item=>!item.trashedAt),tasks:data.tasks.filter(item=>!item.trashedAt)}; }; const validDate = value => !value || (/^\d{4}-\d{2}-\d{2}$/.test(value) && !Number.isNaN(Date.parse(`${value}T12:00:00`)) && new Date(`${value}T12:00:00`).getFullYear() === Number(value.slice(0, 4)) && new Date(`${value}T12:00:00`).getMonth() + 1 === Number(value.slice(5, 7)) && new Date(`${value}T12:00:00`).getDate() === Number(value.slice(8))); const required = (value, max) => { const result = String(value || '').trim(); @@ -17,7 +18,7 @@ }; const persistBoard = data => { const state = sys(); state.tasksBoard = data; save('lifeos_system', state); renderAll(); }; window.LifeOSActions = { - board, + board: activeBoard, allBoard: board, allMemories, allFavorites, createGoal({ title, description = '', targetDate = '', showOnDesktop = false }) { title = required(title, 100); @@ -66,6 +67,17 @@ deleteTask(id) { const data = board(), task = data.tasks.find(item => item.id === id); if (!task) throw new Error('notFound'); + task.trashedAt = new Date().toISOString(); task.updatedAt=task.trashedAt; + persistBoard(data); return task; + }, + restoreTask(id) { + const data=board(), task=data.tasks.find(item=>item.id===id && item.trashedAt); + if(!task) throw new Error('notFound'); + delete task.trashedAt; task.updatedAt=new Date().toISOString(); persistBoard(data); return task; + }, + purgeTask(id) { + const data=board(), task=data.tasks.find(item=>item.id===id && item.trashedAt); + if(!task) throw new Error('notFound'); data.tasks = data.tasks.filter(item => item.id !== id); const all = allMemories(); if (all.some(item => item.taskId === id)) save('lifeos_memories', all.map(item => item.taskId === id ? { ...item, taskId: '', updatedAt: new Date().toISOString() } : item)); @@ -74,6 +86,17 @@ deleteGoal(id) { const data = board(), goal = data.goals.find(item => item.id === id); if (!goal) throw new Error('notFound'); + goal.trashedAt=new Date().toISOString(); goal.updatedAt=goal.trashedAt; + persistBoard(data); return goal; + }, + restoreGoal(id) { + const data=board(), goal=data.goals.find(item=>item.id===id && item.trashedAt); + if(!goal) throw new Error('notFound'); + delete goal.trashedAt; goal.updatedAt=new Date().toISOString(); persistBoard(data); return goal; + }, + purgeGoal(id) { + const data=board(), goal=data.goals.find(item=>item.id===id && item.trashedAt); + if(!goal) throw new Error('notFound'); data.goals = data.goals.filter(item => item.id !== id); data.tasks.forEach(task => { if (task.goalId === id) task.goalId = ''; }); persistBoard(data); return goal; diff --git a/public/desktop-widgets.js b/public/desktop-widgets.js index 52b1bc0..d6f9703 100644 --- a/public/desktop-widgets.js +++ b/public/desktop-widgets.js @@ -107,7 +107,7 @@ const now = new Date(); clock.querySelector('.widget-body').innerHTML = `
${new Intl.DateTimeFormat(LifeI18n.locale(), { hour: '2-digit', minute: '2-digit' }).format(now)}
${LifeI18n.date(now, { weekday: 'long', month: 'long', day: 'numeric' })}
`; const current = day(), memories = mems().filter(item => item.date === current).length; - const tasks = sys().tasksBoard?.tasks || [], due = tasks.filter(item => !item.done && item.dueDate && item.dueDate <= current).length; + const tasks = (sys().tasksBoard?.tasks || []).filter(item=>!item.trashedAt), due = tasks.filter(item => !item.done && item.dueDate && item.dueDate <= current).length; today.querySelector('.widget-body').innerHTML = `
${LifeI18n.number(memories)}${label('memoriesToday')}
${LifeI18n.number(due)}${label('tasksDue')}
`; actions.querySelector('.widget-body').innerHTML = `
${[['today','newMemory'],['tasks','openTasks'],['calendar','openCalendar']].map(([id, text]) => ``).join('')}
`; } diff --git a/public/i18n-renderers.js b/public/i18n-renderers.js index 8c67190..c84ed41 100644 --- a/public/i18n-renderers.js +++ b/public/i18n-renderers.js @@ -7,7 +7,7 @@ const short = value => new Intl.DateTimeFormat(locale(), { month: 'short', day: 'numeric' }).format(new Date(value + 'T12:00:00')).toUpperCase(); const weather = mood => t(`weather.${mood}`); const rootModal = () => document.getElementById('modal'); - const linkedTasks = () => sys().tasksBoard?.tasks || []; + const linkedTasks = () => (sys().tasksBoard?.tasks || []).filter(item=>!item.trashedAt); const escAttr = value => esc(value).replace(/\"/g, '"'); const titleOf = memory => memory.title?.trim() || memory.text?.trim().split('\n')[0].slice(0, 64) || t('timeline.untitled'); const localizedFilmField = (memory, field) => { const index = LifeI18n.supported.reduce((found, code) => found >= 0 ? found : LifeI18n.dictionaries[code]?.prompt.films.findIndex(film => film.title === memory.filmTitle), -1); return index < 0 ? (memory[field] || '') : (LifeI18n.dictionaries[lang()]?.prompt.films[index]?.[field === 'filmTitle' ? 'title' : 'subtitle'] || memory[field] || ''); }; @@ -124,7 +124,7 @@ const period = reportPeriod(), inPeriod = key => key && key >= period.start && key < period.end && key <= period.today; const records = mems().filter(item => inPeriod(item.date)).sort((a, b) => a.date.localeCompare(b.date)); const daysRecorded = new Set(records.map(item => item.date)).size; - const board = sys().tasksBoard || {}, tasks = Array.isArray(board.tasks) ? board.tasks : [], goals = Array.isArray(board.goals) ? board.goals : []; + const board = sys().tasksBoard || {}, tasks = Array.isArray(board.tasks) ? board.tasks.filter(item=>!item.trashedAt) : [], goals = Array.isArray(board.goals) ? board.goals.filter(item=>!item.trashedAt) : []; const tasksCreated = tasks.filter(item => inPeriod(reportEventDate(item.createdAt))).length; const tasksCompleted = tasks.filter(item => item.done && inPeriod(reportEventDate(item.completedAt))).length; const goalsCompleted = goals.filter(item => item.done && inPeriod(reportEventDate(item.completedAt))).length; @@ -156,7 +156,7 @@ container.innerHTML = `
${t('system.eyebrow')}

${t('system.title')}

${t('system.appearance')}
${['dark','light','auto'].map(item => ``).join('')}
${t('system.language')}

${detected}

${LifeI18n.supported.map(code => ``).join('')}
${window.LifeOSNotifications?.markup() || ''}
${t('system.data')}
${t('system.storage')}

${t('system.local')}
${t('system.storageSummary',{memories:LifeI18n.number(mems().length),museum:LifeI18n.number(museum().length),tasks:LifeI18n.number(sys().tasksBoard?.tasks?.length||0),size:LifeI18n.number(Math.ceil(bytes/1024))})}

${t('system.dataStorage')}

${t('system.stored')}
${t('system.backups')}

${t('system.lastBackup',{value:state.lastBackup ? short(state.lastBackup.slice(0,10)) : t('common.never')})}${oldBackup ? `
${t('system.recommended')}` : ''}

${t('system.version')}

${t('system.release',{version:window.LifeOSVersion||'1.18.1'})}

`; }; window.importPreview = () => { const data = importData, board = data.system?.tasksBoard || {}; rootModal().innerHTML = ``; }; - const trashItems = () => window.LifeOSActions.allMemories().filter(item => item.trashedAt).sort((a,b) => b.trashedAt.localeCompare(a.trashedAt)); + const trashItems = () => { const board=window.LifeOSActions.allBoard(); return [...window.LifeOSActions.allMemories().map(item=>({...item,_trashType:'Memory'})),...board.tasks.map(item=>({...item,_trashType:'Task'})),...board.goals.map(item=>({...item,_trashType:'Goal'}))].filter(item=>item.trashedAt).sort((a,b)=>b.trashedAt.localeCompare(a.trashedAt)); }; const baseSystem = window.systemApp; window.systemApp = container => { baseSystem(container); @@ -164,17 +164,17 @@ }; window.openRecycleBin = () => { const items = trashItems(); - rootModal().innerHTML = ``; + rootModal().innerHTML = ``; }; - window.restoreTrashedMemory = id => { - try { window.LifeOSActions.restoreMemory(id); window.openRecycleBin(); toast(t('trash.restored')); } + window.restoreTrashedMemory = (id,type='Memory') => { + try { window.LifeOSActions[`restore${type}`](id); window.openRecycleBin(); toast(t('trash.restored')); } catch(error) { const node=document.querySelector('#trash-error'); if(node) node.textContent=t(error.message === 'memoryExists' ? 'trash.dateConflict' : 'trash.unavailable'); } }; - window.confirmPurgeMemory = id => { - const item=trashItems().find(memory=>memory.id===id); if(!item) return; - rootModal().innerHTML = ``; + window.confirmPurgeMemory = (id,type='Memory') => { + const item=trashItems().find(memory=>memory.id===id && memory._trashType===type); if(!item) return; + rootModal().innerHTML = ``; }; - window.purgeTrashedMemory = id => { try { window.LifeOSActions.purgeMemory(id); window.openRecycleBin(); toast(t('trash.purged')); } catch { window.openRecycleBin(); } }; + window.purgeTrashedMemory = (id,type='Memory') => { try { window.LifeOSActions[`purge${type}`](id); window.openRecycleBin(); toast(t('trash.purged')); } catch { window.openRecycleBin(); } }; const trashStyle = document.createElement('style'); trashStyle.textContent = `.trash-panel{width:min(650px,calc(100vw - 28px));max-height:calc(100dvh - 28px);overflow:auto}.trash-panel h2{font-size:24px;letter-spacing:0}.trash-list{display:grid;gap:12px}.trash-item{border:1px solid var(--line);background:var(--panel2);border-radius:10px;padding:14px;min-width:0}.trash-item>strong{display:block;font-size:16px;overflow-wrap:anywhere}.trash-item>small{display:block;font-size:12px;color:var(--muted);margin:7px 0}.trash-item details{font-size:14px}.trash-item details p{white-space:pre-wrap;overflow-wrap:anywhere;max-height:180px;overflow:auto;line-height:1.6}.trash-item .actions{flex-wrap:wrap}#trash-error{color:#eea27d;font-size:14px}`; document.head.append(trashStyle); diff --git a/public/index.html b/public/index.html index b1e2723..32651b9 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/local-db-worker.js b/public/local-db-worker.js index 6ca5f03..14a8117 100644 --- a/public/local-db-worker.js +++ b/public/local-db-worker.js @@ -95,8 +95,8 @@ function projectKey(key, value) { } if (key === 'lifeos_system') { const board = json(value, {})?.tasksBoard || {}; - replaceRows('goals', list(board.goals).filter(row => row?.id), 'INSERT INTO goals(id,title,description,target_date,done,updated_at,payload) VALUES(?,?,?,?,?,?,?)', row => [String(row.id || ''), String(row.title || ''), String(row.description || ''), String(row.targetDate || ''), row.done ? 1 : 0, String(row.updatedAt || row.createdAt || ''), JSON.stringify(row)]); - replaceRows('tasks', list(board.tasks).filter(row => row?.id), 'INSERT INTO tasks(id,title,due_date,goal_id,priority,done,updated_at,payload) VALUES(?,?,?,?,?,?,?,?)', row => [String(row.id || ''), String(row.title || ''), String(row.dueDate || ''), String(row.goalId || ''), String(row.priority || 'normal'), row.done ? 1 : 0, String(row.updatedAt || row.createdAt || ''), JSON.stringify(row)]); + replaceRows('goals', list(board.goals).filter(row => row?.id && !row.trashedAt), 'INSERT INTO goals(id,title,description,target_date,done,updated_at,payload) VALUES(?,?,?,?,?,?,?)', row => [String(row.id || ''), String(row.title || ''), String(row.description || ''), String(row.targetDate || ''), row.done ? 1 : 0, String(row.updatedAt || row.createdAt || ''), JSON.stringify(row)]); + replaceRows('tasks', list(board.tasks).filter(row => row?.id && !row.trashedAt), 'INSERT INTO tasks(id,title,due_date,goal_id,priority,done,updated_at,payload) VALUES(?,?,?,?,?,?,?,?)', row => [String(row.id || ''), String(row.title || ''), String(row.dueDate || ''), String(row.goalId || ''), String(row.priority || 'normal'), row.done ? 1 : 0, String(row.updatedAt || row.createdAt || ''), JSON.stringify(row)]); } if (key === 'lifeos_museum') { const rows = list(json(value, [])).filter(row => row?.id && row?.memoryId); diff --git a/public/locales/ar.json b/public/locales/ar.json index cb9b280..987425b 100644 --- a/public/locales/ar.json +++ b/public/locales/ar.json @@ -1,19 +1,19 @@ { "trash": { "title": "سلة المحذوفات", - "hint": "تبقى الملخصات واللحظات هنا حتى استعادتها أو حذفها نهائياً.", + "hint": "تبقى الذكريات واللحظات والمهام والأهداف حتى استعادتها أو حذفها.", "open": "فتح السلة ({count})", - "moveHint": "ستُنقل هذه الذكرى إلى السلة ويمكنك استعادتها لاحقاً.", + "moveHint": "يُنقل السجل إلى السلة مع الاحتفاظ بروابطه.", "moved": "تم النقل إلى السلة", "restore": "استعادة", - "restored": "تمت استعادة الذكرى", + "restored": "تمت استعادة السجل", "empty": "السلة فارغة.", "purge": "حذف نهائي", - "purgeQuestion": "حذف هذه الذكرى نهائياً؟", - "purgeHint": "سيُحذف النص والمفضلة المرتبطة به ولن يمكن استعادتهما من السلة.", + "purgeQuestion": "حذف هذا السجل نهائياً؟", + "purgeHint": "لا يمكن الاستعادة. حذف هدف يفصل مهامه، ومهمة تفصل ذكرياتها، وذكرى تزيل المفضلة.", "purged": "تم الحذف نهائياً", "dateConflict": "يوجد ملخص لهذا التاريخ. انقله إلى السلة قبل استعادة هذه الذكرى.", - "unavailable": "هذه الذكرى لم تعد متاحة." + "unavailable": "هذا السجل لم يعد متاحاً." }, "moments": { "label": "لحظات", @@ -477,7 +477,7 @@ "taskRemoved": "حُذفت المهمة", "goalRemoved": "حُذف الهدف", "confirmGoalDelete": "حذف هذا الهدف؟", - "confirmGoalDeleteBody": "ستبقى المهام المرتبطة دون هدف.", + "confirmGoalDeleteBody": "يُنقل السجل إلى السلة مع الاحتفاظ بروابطه.", "target": "التاريخ المستهدف", "completed": "مكتمل", "progress": "أُنجز {done} من {total}", diff --git a/public/locales/en.json b/public/locales/en.json index 956b2a1..57fac5e 100644 --- a/public/locales/en.json +++ b/public/locales/en.json @@ -1,19 +1,19 @@ { "trash": { "title": "RECYCLE BIN", - "hint": "Daily summaries and moments stay here until you restore or permanently delete them.", + "hint": "Memories, moments, tasks and goals stay here until restored or permanently deleted.", "open": "OPEN RECYCLE BIN ({count})", - "moveHint": "This memory will move to the recycle bin. You can restore it later.", + "moveHint": "This record moves to the recycle bin with its links preserved.", "moved": "Moved to recycle bin", "restore": "RESTORE", - "restored": "Memory restored", + "restored": "Record restored", "empty": "The recycle bin is empty.", "purge": "DELETE PERMANENTLY", - "purgeQuestion": "Permanently delete this memory?", - "purgeHint": "This removes the memory and its favorite entry. You cannot restore it from the recycle bin afterward.", + "purgeQuestion": "Permanently delete this record?", + "purgeHint": "This cannot be restored from the recycle bin. Deleting a goal unlinks its tasks; deleting a task unlinks its memories; deleting a memory removes its favorite.", "purged": "Permanently deleted", "dateConflict": "A daily summary already exists on this date. Move that summary to the recycle bin before restoring this one.", - "unavailable": "This memory is no longer available." + "unavailable": "This record is no longer available." }, "moments": { "label": "MOMENTS", @@ -477,7 +477,7 @@ "taskRemoved": "TASK REMOVED", "goalRemoved": "GOAL REMOVED", "confirmGoalDelete": "Delete this goal?", - "confirmGoalDeleteBody": "Tasks linked to it will be kept without a goal.", + "confirmGoalDeleteBody": "This record moves to the recycle bin with its links preserved.", "target": "TARGET DATE", "completed": "COMPLETED", "progress": "{done} OF {total} DONE", diff --git a/public/locales/es.json b/public/locales/es.json index 81123ea..9c3955c 100644 --- a/public/locales/es.json +++ b/public/locales/es.json @@ -1,19 +1,19 @@ { "trash": { "title": "PAPELERA", - "hint": "Los resúmenes y momentos permanecen aquí hasta restaurarlos o eliminarlos definitivamente.", + "hint": "Recuerdos, momentos, tareas y objetivos permanecen aquí hasta restaurarlos o eliminarlos.", "open": "ABRIR PAPELERA ({count})", - "moveHint": "Este recuerdo se moverá a la papelera. Podrás restaurarlo.", + "moveHint": "Se moverá a la papelera conservando sus relaciones.", "moved": "Movido a la papelera", "restore": "RESTAURAR", - "restored": "Recuerdo restaurado", + "restored": "Registro restaurado", "empty": "La papelera está vacía.", "purge": "ELIMINAR DEFINITIVAMENTE", - "purgeQuestion": "¿Eliminar definitivamente este recuerdo?", - "purgeHint": "Se eliminarán el texto y su favorito. No podrás restaurarlo desde la papelera.", + "purgeQuestion": "¿Eliminar definitivamente este registro?", + "purgeHint": "No podrás restaurarlo. El objetivo desvincula tareas, la tarea desvincula recuerdos y el recuerdo elimina su favorito.", "purged": "Eliminado definitivamente", "dateConflict": "Ya hay un resumen en esta fecha. Muévelo a la papelera antes de restaurar este.", - "unavailable": "Este recuerdo ya no está disponible." + "unavailable": "Este registro ya no está disponible." }, "moments": { "label": "MOMENTOS", @@ -477,7 +477,7 @@ "taskRemoved": "TAREA ELIMINADA", "goalRemoved": "OBJETIVO ELIMINADO", "confirmGoalDelete": "¿Eliminar este objetivo?", - "confirmGoalDeleteBody": "Las tareas asociadas se conservarán sin objetivo.", + "confirmGoalDeleteBody": "Se moverá a la papelera conservando sus relaciones.", "target": "FECHA OBJETIVO", "completed": "COMPLETADO", "progress": "{done} DE {total} COMPLETADAS", diff --git a/public/locales/fr.json b/public/locales/fr.json index aa5142e..b00ea3d 100644 --- a/public/locales/fr.json +++ b/public/locales/fr.json @@ -1,19 +1,19 @@ { "trash": { "title": "CORBEILLE", - "hint": "Les résumés et instants restent ici jusqu’à leur restauration ou suppression définitive.", + "hint": "Souvenirs, instants, tâches et objectifs restent ici jusqu’à restauration ou suppression.", "open": "OUVRIR LA CORBEILLE ({count})", - "moveHint": "Ce souvenir sera déplacé dans la corbeille. Vous pourrez le restaurer.", + "moveHint": "Cet élément sera déplacé dans la corbeille avec ses liens.", "moved": "Déplacé dans la corbeille", "restore": "RESTAURER", - "restored": "Souvenir restauré", + "restored": "Élément restauré", "empty": "La corbeille est vide.", "purge": "SUPPRIMER DÉFINITIVEMENT", - "purgeQuestion": "Supprimer définitivement ce souvenir ?", - "purgeHint": "Le texte et son favori seront supprimés. La restauration sera impossible depuis la corbeille.", + "purgeQuestion": "Supprimer définitivement cet élément ?", + "purgeHint": "Restauration impossible. L’objectif délie ses tâches, la tâche délie ses souvenirs, le souvenir perd son favori.", "purged": "Supprimé définitivement", "dateConflict": "Un résumé existe à cette date. Déplacez-le dans la corbeille avant cette restauration.", - "unavailable": "Ce souvenir n’est plus disponible." + "unavailable": "Cet élément n’est plus disponible." }, "moments": { "label": "INSTANTS", @@ -477,7 +477,7 @@ "taskRemoved": "TÂCHE SUPPRIMÉE", "goalRemoved": "OBJECTIF SUPPRIMÉ", "confirmGoalDelete": "Supprimer cet objectif ?", - "confirmGoalDeleteBody": "Les tâches associées seront conservées sans objectif.", + "confirmGoalDeleteBody": "Cet élément sera déplacé dans la corbeille avec ses liens.", "target": "DATE CIBLE", "completed": "TERMINÉ", "progress": "{done} SUR {total} TERMINÉES", diff --git a/public/locales/ja.json b/public/locales/ja.json index 8103fe8..2de135c 100644 --- a/public/locales/ja.json +++ b/public/locales/ja.json @@ -1,19 +1,19 @@ { "trash": { "title": "ごみ箱", - "hint": "日々のまとめと瞬間は、復元または完全削除するまで残ります。", + "hint": "記憶、瞬間、タスク、目標は復元または完全削除するまで残ります。", "open": "ごみ箱を開く({count})", - "moveHint": "この記憶をごみ箱に移します。後で復元できます。", + "moveHint": "関連付けを保持してごみ箱に移します。", "moved": "ごみ箱へ移動しました", "restore": "復元", - "restored": "復元しました", + "restored": "記録を復元しました", "empty": "ごみ箱は空です。", "purge": "完全に削除", - "purgeQuestion": "この記憶を完全に削除しますか?", - "purgeHint": "本文とお気に入りを削除します。ごみ箱から復元できなくなります。", + "purgeQuestion": "この記録を完全に削除しますか?", + "purgeHint": "復元できません。目標はタスク、タスクは記憶との関連を解除し、記憶のお気に入りを削除します。", "purged": "完全に削除しました", "dateConflict": "この日にはまとめがあります。先にそのまとめをごみ箱へ移してください。", - "unavailable": "この記憶は利用できません。" + "unavailable": "この記録は利用できません。" }, "moments": { "label": "瞬間の記録", @@ -477,7 +477,7 @@ "taskRemoved": "タスクを削除しました", "goalRemoved": "目標を削除しました", "confirmGoalDelete": "この目標を削除しますか?", - "confirmGoalDeleteBody": "関連タスクは目標なしで残ります。", + "confirmGoalDeleteBody": "関連付けを保持してごみ箱に移します。", "target": "目標日", "completed": "完了", "progress": "{total} 件中 {done} 件完了", diff --git a/public/locales/ru.json b/public/locales/ru.json index ffff69a..89148cc 100644 --- a/public/locales/ru.json +++ b/public/locales/ru.json @@ -1,19 +1,19 @@ { "trash": { "title": "КОРЗИНА", - "hint": "Итоги дня и моменты остаются здесь до восстановления или окончательного удаления.", + "hint": "Записи, моменты, задачи и цели остаются до восстановления или удаления.", "open": "ОТКРЫТЬ КОРЗИНУ ({count})", - "moveHint": "Запись попадёт в корзину. Её можно восстановить позже.", + "moveHint": "Запись перемещается в корзину с сохранением связей.", "moved": "Перемещено в корзину", "restore": "ВОССТАНОВИТЬ", "restored": "Запись восстановлена", "empty": "Корзина пуста.", "purge": "УДАЛИТЬ НАВСЕГДА", "purgeQuestion": "Удалить эту запись навсегда?", - "purgeHint": "Текст и избранное будут удалены. Восстановить из корзины будет невозможно.", + "purgeHint": "Восстановление невозможно. Цель отсоединяет задачи, задача отсоединяет записи, запись удаляет избранное.", "purged": "Удалено навсегда", "dateConflict": "На эту дату уже есть итог дня. Сначала переместите его в корзину.", - "unavailable": "Эта запись больше недоступна." + "unavailable": "Эта запись недоступна." }, "moments": { "label": "МОМЕНТЫ", @@ -477,7 +477,7 @@ "taskRemoved": "ЗАДАЧА УДАЛЕНА", "goalRemoved": "ЦЕЛЬ УДАЛЕНА", "confirmGoalDelete": "Удалить эту цель?", - "confirmGoalDeleteBody": "Связанные задачи останутся без цели.", + "confirmGoalDeleteBody": "Запись перемещается в корзину с сохранением связей.", "target": "ЦЕЛЕВАЯ ДАТА", "completed": "ЗАВЕРШЕНО", "progress": "ГОТОВО {done} ИЗ {total}", diff --git a/public/locales/zh-CN.json b/public/locales/zh-CN.json index 5f6649e..1ea8f05 100644 --- a/public/locales/zh-CN.json +++ b/public/locales/zh-CN.json @@ -1,19 +1,19 @@ { "trash": { "title": "回收站", - "hint": "每日总结和瞬间保留在这里,直到你恢复或永久删除。", + "hint": "记忆、瞬间、任务和目标保留在这里,直到恢复或永久删除。", "open": "打开回收站({count})", - "moveHint": "这条记忆将移入回收站,之后可以恢复。", + "moveHint": "这条记录将移入回收站,关联保留,之后可以恢复。", "moved": "已移入回收站", "restore": "恢复", - "restored": "记忆已恢复", + "restored": "记录已恢复", "empty": "回收站为空。", "purge": "永久删除", - "purgeQuestion": "永久删除这条记忆?", - "purgeHint": "正文和收藏关系将被删除,之后无法从回收站恢复。", + "purgeQuestion": "永久删除这条记录?", + "purgeHint": "无法从回收站恢复。删除目标会解除任务关联;删除任务会解除记忆关联;删除记忆会移除收藏。", "purged": "已永久删除", "dateConflict": "该日期已有每日总结,请先将现有总结移入回收站,再恢复这条记忆。", - "unavailable": "这条记忆已不可用。" + "unavailable": "这条记录已不可用。" }, "moments": { "label": "瞬间记录", @@ -474,7 +474,7 @@ "taskRemoved": "待办已删除", "goalRemoved": "目标已删除", "confirmGoalDelete": "删除这个目标?", - "confirmGoalDeleteBody": "关联的待办会保留,但不再关联此目标。", + "confirmGoalDeleteBody": "这条记录将移入回收站,关联保留,之后可以恢复。", "target": "目标日期", "completed": "已完成", "complete": "标记完成", diff --git a/public/locales/zh-HK.json b/public/locales/zh-HK.json index 4a2f96b..53ffdf8 100644 --- a/public/locales/zh-HK.json +++ b/public/locales/zh-HK.json @@ -1,19 +1,19 @@ { "trash": { "title": "回收站", - "hint": "每日總結和瞬間保留在這裡,直到你恢復或永久刪除。", + "hint": "記憶、瞬間、任務和目標保留在這裡,直到恢復或永久刪除。", "open": "開啟回收站({count})", - "moveHint": "這條記憶將移入回收站,之後可以恢復。", + "moveHint": "這條記錄將移入回收站,保留關聯,之後可以恢復。", "moved": "已移入回收站", "restore": "恢復", - "restored": "記憶已恢復", + "restored": "記錄已恢復", "empty": "回收站為空。", "purge": "永久刪除", - "purgeQuestion": "永久刪除這條記憶?", - "purgeHint": "正文和收藏關係將被刪除,之後無法從回收站恢復。", + "purgeQuestion": "永久刪除這條記錄?", + "purgeHint": "無法恢復。刪除目標解除任務關聯;刪除任務解除記憶關聯;刪除記憶移除收藏。", "purged": "已永久刪除", "dateConflict": "該日期已有每日總結,請先將現有總結移入回收站,再恢復這條記憶。", - "unavailable": "這條記憶已不可用。" + "unavailable": "這條記錄已不可用。" }, "moments": { "label": "瞬間記錄", @@ -474,7 +474,7 @@ "taskRemoved": "待辦已刪除", "goalRemoved": "目標已刪除", "confirmGoalDelete": "刪除這個目標?", - "confirmGoalDeleteBody": "關聯的待辦會保留,但不再關聯此目標。", + "confirmGoalDeleteBody": "這條記錄將移入回收站,保留關聯,之後可以恢復。", "target": "目標日期", "completed": "已完成", "complete": "標記完成", diff --git a/public/locales/zh-MO.json b/public/locales/zh-MO.json index 5c5b522..d23b3a5 100644 --- a/public/locales/zh-MO.json +++ b/public/locales/zh-MO.json @@ -1,19 +1,19 @@ { "trash": { "title": "回收站", - "hint": "每日總結和瞬間保留在這裡,直到你恢復或永久刪除。", + "hint": "記憶、瞬間、任務和目標保留在這裡,直到恢復或永久刪除。", "open": "開啟回收站({count})", - "moveHint": "這條記憶將移入回收站,之後可以恢復。", + "moveHint": "這條記錄將移入回收站,保留關聯,之後可以恢復。", "moved": "已移入回收站", "restore": "恢復", - "restored": "記憶已恢復", + "restored": "記錄已恢復", "empty": "回收站為空。", "purge": "永久刪除", - "purgeQuestion": "永久刪除這條記憶?", - "purgeHint": "正文和收藏關係將被刪除,之後無法從回收站恢復。", + "purgeQuestion": "永久刪除這條記錄?", + "purgeHint": "無法恢復。刪除目標解除任務關聯;刪除任務解除記憶關聯;刪除記憶移除收藏。", "purged": "已永久刪除", "dateConflict": "該日期已有每日總結,請先將現有總結移入回收站,再恢復這條記憶。", - "unavailable": "這條記憶已不可用。" + "unavailable": "這條記錄已不可用。" }, "moments": { "label": "瞬間記錄", @@ -474,7 +474,7 @@ "taskRemoved": "待辦已刪除", "goalRemoved": "目標已刪除", "confirmGoalDelete": "刪除這個目標?", - "confirmGoalDeleteBody": "關聯的待辦會保留,但不再關聯此目標。", + "confirmGoalDeleteBody": "這條記錄將移入回收站,保留關聯,之後可以恢復。", "target": "目標日期", "completed": "已完成", "complete": "標記完成", diff --git a/public/locales/zh-TW.json b/public/locales/zh-TW.json index 77baf92..a85a82b 100644 --- a/public/locales/zh-TW.json +++ b/public/locales/zh-TW.json @@ -1,19 +1,19 @@ { "trash": { "title": "回收站", - "hint": "每日總結和瞬間保留在這裡,直到你還原或永久刪除。", + "hint": "記憶、瞬間、任務和目標保留在這裡,直到還原或永久刪除。", "open": "開啟回收站({count})", - "moveHint": "這條記憶將移入回收站,之後可以還原。", + "moveHint": "這條記錄將移入回收站,保留關聯,之後可以還原。", "moved": "已移入回收站", "restore": "還原", - "restored": "記憶已還原", + "restored": "記錄已還原", "empty": "回收站為空。", "purge": "永久刪除", - "purgeQuestion": "永久刪除這條記憶?", - "purgeHint": "正文和收藏關係將被刪除,之後無法從回收站還原。", + "purgeQuestion": "永久刪除這條記錄?", + "purgeHint": "無法還原。刪除目標解除任務關聯;刪除任務解除記憶關聯;刪除記憶移除收藏。", "purged": "已永久刪除", "dateConflict": "該日期已有每日總結,請先將現有總結移入回收站,再還原這條記憶。", - "unavailable": "這條記憶已無法使用。" + "unavailable": "這條記錄已無法使用。" }, "moments": { "label": "瞬間記錄", @@ -474,7 +474,7 @@ "taskRemoved": "待辦已刪除", "goalRemoved": "目標已刪除", "confirmGoalDelete": "刪除這個目標?", - "confirmGoalDeleteBody": "關聯的待辦會保留,但不再關聯此目標。", + "confirmGoalDeleteBody": "這條記錄將移入回收站,保留關聯,之後可以還原。", "target": "目標日期", "completed": "已完成", "complete": "標記完成", diff --git a/public/notifications.js b/public/notifications.js index d878fbf..3b8e17e 100644 --- a/public/notifications.js +++ b/public/notifications.js @@ -46,7 +46,7 @@ if (mems().some(memory => memory.date === date && memory.kind !== 'moment')) return null; return { title: t('memory.title'), body: t('memory.body'), app: 'today' }; } - const board = sys().tasksBoard || {}; + const raw = sys().tasksBoard || {}, board={goals:(raw.goals||[]).filter(item=>!item.trashedAt),tasks:(raw.tasks||[]).filter(item=>!item.trashedAt)}; if (kind === 'tasks') { const pending = (board.tasks || []).filter(task => !task.done && task.dueDate && task.dueDate <= date); if (!pending.length) return null; diff --git a/public/service-worker.js b/public/service-worker.js index 250149e..8ab24cf 100644 --- a/public/service-worker.js +++ b/public/service-worker.js @@ -1,4 +1,4 @@ -const CACHE = 'life-os-shell-v1.24.0'; +const CACHE = 'life-os-shell-v1.25.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 297f463..fe60e9b 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.24.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.25.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 2ce78b6..bc9cf5a 100644 --- a/public/tasks.js +++ b/public/tasks.js @@ -6,9 +6,9 @@ const board = () => { const state = sys(); if (!state.tasksBoard || !Array.isArray(state.tasksBoard.goals) || !Array.isArray(state.tasksBoard.tasks)) state.tasksBoard = { goals: [], tasks: [] }; - return state.tasksBoard; + return {goals:state.tasksBoard.goals.filter(item=>!item.trashedAt),tasks:state.tasksBoard.tasks.filter(item=>!item.trashedAt)}; }; - const persist = data => { const state = sys(); state.tasksBoard = data; save('lifeos_system', state); renderAll(); }; + const persist = data => { const state = sys(), previous=window.LifeOSActions.allBoard(); state.tasksBoard={goals:[...data.goals,...previous.goals.filter(item=>item.trashedAt)],tasks:[...data.tasks,...previous.tasks.filter(item=>item.trashedAt)]}; save('lifeos_system', state); renderAll(); }; const dateLabel = value => value ? new Intl.DateTimeFormat(LifeI18n.locale(), { month: 'short', day: 'numeric', year: 'numeric' }).format(new Date(`${value}T12:00:00`)) : t('noDate'); const isOverdue = task => !task.done && task.dueDate && task.dueDate < day(); diff --git a/public/terminal-app.js b/public/terminal-app.js index dc182c9..8ebe73b 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.24.0'}` }; } + if (kind === 'version') { if (verb) throw new Error('usage'); return { message: `Life OS v${window.LifeOSVersion || '1.25.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.24.0' }), kind: 'system' }); welcomed = true; } + if (!welcomed) { lines.unshift({ value: t('welcome', { version: window.LifeOSVersion || '1.25.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 1fe63e8..5762cf4 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.24.0"; +const release = "1.25.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-task-trash.mjs b/scripts/test-task-trash.mjs new file mode 100644 index 0000000..a491f1e --- /dev/null +++ b/scripts/test-task-trash.mjs @@ -0,0 +1,35 @@ +import assert from 'node:assert/strict'; +import {readFileSync} from 'node:fs'; +import vm from 'node:vm'; +let state={tasksBoard:{goals:[{id:'g',title:'Goal',done:false,targetDate:'2026-12-01'}],tasks:[{id:'t',title:'Task',goalId:'g',done:true,createdAt:'2026-10-13T00:00:00Z'}]}}; +let memories=[{id:'m',date:'2026-10-13',text:'Linked memory',taskId:'t'}]; +const ctx=vm.createContext({sys:()=>structuredClone(state),mems:()=>structuredClone(memories),museum:()=>[],save:(key,value)=>{if(key==='lifeos_system') state=structuredClone(value);if(key==='lifeos_memories') memories=structuredClone(value);},renderAll(){},day:()=> '2026-10-13',crypto:globalThis.crypto,filmFor:()=>({}), + document:{createElement:()=>({}),head:{append(){}},querySelector:()=>null},LifeI18n:{t:key=>key,locale:()=> 'en-US'},setInterval(){},setTimeout(){}}); +ctx.window=ctx; +vm.runInContext(readFileSync(new URL('../public/data-actions.js',import.meta.url),'utf8'),ctx); +vm.runInContext(readFileSync(new URL('../public/tasks.js',import.meta.url),'utf8'),ctx); +const actions=ctx.LifeOSActions; +actions.deleteTask('t'); +assert.equal(actions.board().tasks.length,0); +assert.equal(actions.allBoard().tasks.length,1); +assert.equal(memories[0].taskId,'t'); +actions.restoreTask('t'); +assert.equal(actions.board().tasks[0].id,'t'); +assert.equal(actions.board().tasks[0].done,true); +actions.deleteGoal('g'); +assert.equal(actions.board().goals.length,0); +assert.equal(actions.board().tasks[0].goalId,'g'); +actions.restoreGoal('g'); +assert.equal(actions.board().goals[0].id,'g'); +actions.deleteTask('t'); +ctx.toggleGoalDesktop('g'); +assert.ok(actions.allBoard().tasks.find(item=>item.id==='t').trashedAt,'desktop preference edits preserve trash'); +actions.createTask({title:'New task',goalId:'g'}); +assert.equal(actions.allBoard().tasks.length,2,'new writes preserve trash'); +actions.purgeTask('t'); +assert.equal(memories[0].taskId,'','permanent task deletion unlinks memories'); +actions.deleteGoal('g'); +actions.purgeGoal('g'); +assert.equal(actions.allBoard().tasks[0].goalId,'','permanent goal deletion unlinks tasks'); +assert.throws(()=>actions.purgeTask(actions.allBoard().tasks[0].id),/notFound/,'active items cannot be permanently deleted'); +console.log('Life OS task/goal trash, restoration and permanent association cleanup valid'); diff --git a/scripts/validate.mjs b/scripts/validate.mjs index e57df4a..226a803 100644 --- a/scripts/validate.mjs +++ b/scripts/validate.mjs @@ -247,7 +247,7 @@ submitTerminal('yes'); assert.equal(terminalStorage.get('lifeos_system').tasksBoard.goals[0].title, 'UI goal'); submitTerminal('goal delete "UI goal"'); submitTerminal('yes'); -assert.equal(terminalStorage.get('lifeos_system').tasksBoard.goals.some(item => item.title === 'UI goal'), false); +assert.equal(terminalContext.LifeOSActions.board().goals.some(item => item.title === 'UI goal'), false); assert.match(command('goal add').message, /terminal\.flow\.title/); assert.match(command('A guided goal').message, /terminal\.flow\.description/); assert.match(command('').message, /terminal\.flow\.targetDate/); @@ -268,7 +268,7 @@ assert.equal(command('no').cancel, true); assert.equal(terminalStorage.get('lifeos_system').tasksBoard.tasks.length, 2); assert.match(command('task delete 2').message, /terminal\.flow\.confirmDelete/); assert.match(command('yes').message, /terminal\.flow\.deleted/); -assert.equal(terminalStorage.get('lifeos_system').tasksBoard.tasks.length, 1); +assert.equal(terminalContext.LifeOSActions.board().tasks.length, 1); assert.match(command('memory delete 2026-09-30').message, /terminal\.flow\.confirmDelete/); assert.equal(command('yes').message.includes('terminal.flow.deleted'), true); assert.equal(terminalContext.mems().some(item => item.date === '2026-09-30'), false); @@ -276,16 +276,16 @@ assert.ok(terminalStorage.get('lifeos_memories').find(item => item.date === '202 terminalContext.LifeOSActions.createTask({ title: 'Linked task', goalId: terminalStorage.get('lifeos_system').tasksBoard.goals[0].id }); assert.match(command('goal delete 1').message, /terminal\.flow\.confirmDelete/); assert.match(command('yes').message, /terminal\.flow\.deleted/); -assert.equal(terminalStorage.get('lifeos_system').tasksBoard.tasks[1].goalId, ''); +assert.ok(terminalContext.LifeOSActions.board().tasks[1].goalId, 'trashing a goal preserves task associations'); terminalContext.LifeOSActions.createMemory({ date: '2026-10-02', title: 'Linked memory', taskId: terminalStorage.get('lifeos_system').tasksBoard.tasks[0].id }); assert.match(command('task delete 1').message, /terminal\.flow\.confirmDelete/); assert.match(command('yes').message, /terminal\.flow\.deleted/); -assert.equal(terminalStorage.get('lifeos_memories').find(item => item.date === '2026-10-02').taskId, ''); +assert.ok(terminalStorage.get('lifeos_memories').find(item => item.date === '2026-10-02').taskId, 'trashing a task preserves memory associations'); 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.24.0'); +assert.equal(command('version').message, 'Life OS v1.25.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');