# Pockist Project TODO ## Active (Max 3) ### [x] Fix showError() alert-modal missing — error display is unreliable ### [ ] Add coordinate validation to weather_handler.go (invalid lat/lon cached 20min) ### [ ] Fix ShareView passing 3 args to DialogService.confirm (3rd arg ignored) ## Next Up - [ ] Investigate performant search for DBManager.searchItems() — evaluate full-text index (word→itemId map), cursor-based pagination, or Web Worker offload. Do NOT load entire DB into memory. - [ ] Fix DBManager.getDeletionToken not awaiting cleanup of expired tokens - [ ] Review PWA class usage — `pwa` class was used by old per-page click interceptors (removed 2026-06-30). Check if any dead CSS/JS/HTML references remain, or if we should standardize on it for Router delegation. ## Backlog - Bugs - [x] Fix Router not intercepting dynamically added `` tags after init - [ ] Fix DBManager.searchItems() loads entire DB into memory — v11 schema migration does NOT fix this. Needs full-text index (word→itemId map), pagination, or Web Worker offload. Investigate options. ## Backlog - Security - [ ] Fix rate limiter trusting X-Forwarded-For blindly (IP spoofing) - [ ] showActions icon property not escaped (XSS if icons from user data) - [ ] ShareHandler htmlTagRegex sanitizer is best-effort only ## Backlog - Auth Project (On Hold, finish in the next month) All auth-related work is consolidated here pending a decision to either wire up auth or remove dead code. - [ ] Decide: wire up auth routes in main.go OR remove dead auth code - [ ] Database.go missing `users` table schema (registration would fail) - [ ] Replace all token/ package log.Fatalf with graceful error returns - [ ] Fix API.js sending `Authorization: null` header for unauthenticated requests - [ ] Fix AccountHandler.Register never storing user name (dropped on insert) - [ ] Fix AccountHandler.Authenticate hardcoding empty name in JWT - [ ] JWT stored in localStorage — XSS vector if auth ever wired up - [ ] Add panic recovery middleware to Go server - [ ] Route-level protection for login-required pages (Router.needsLogin is inert) ## Backlog - Tech Debt - [ ] N+1 query in DBManager.getListItems() — **SOLVED by v11 schema migration** (compound `['parentId', 'order']` index). Will auto-close when v11 ships. - [ ] Remove redundant migration calls in ListBase._init (already run in app.js) - [ ] Unbounded SW API cache — no eviction for geocode/weather responses - [ ] Auth middleware uses bare string context keys (collision risk) - [ ] ShareHandler.startCleanupTicker goroutine has no shutdown mechanism ## Backlog - Features - [ ] ATProto integration exploration — cross-device sync, decentralized identity, social sharing via AT Protocol. See `docs/atproto-integration.md` for full design. Pending user decision on direction. - [ ] move to new list selector should be the same order as the lists.... - [ ] remove inline name ediring in list selector - [ ] copy text in action menu or outside? - [ ] note folders - [ ] add delete complete in lists instead of archive - [ ] bug, moving note to list says untitled for the selected list in the dialog dont open list after move - [ ] undo stack. - [x] new note, open straight to detail page shortcut in dialog - [ ] pin note? - [ ] merge list items within a list - [ ] share, user sets the link extension if its not already taken, shorten the expiration, user sets expirstion up to limit - [ ] list detail doesnt rerender after reorder - [ ] list selector pop up css - [ ] share button in list actions in list index - [ ] strip new lins chars when convertins lists to markdown - [ ] link views - [ ] link note to list item - [ ] new list quick button - [ ] Home screen settings should not trigger full rerender? - [ ] Second todo component for homescreen, simple stash model? - [ ] nav bar should also have a setting to be either at the top or the bottom. - [ ] settings into the nav menu, refactor nav into component - [ ] buttons for stashing a note or creating a default to do, build in part of nav buttons component refactor - [ ] home settings, widgets or straight to full page? widget componets share the page, partials full page components - [ ] nav, color theme picker for secondary, sliders for saturation? bottom border secondary hue - [x] nav menu about lines - [ ] main ui, should be more full screen, wider, slightly, need more room for list items theme picker refactor? presets? preset quick buttons? - [ ] share option in list index page action buttons on list items - [ ] pin note as widget - [ ] Notes section fills screen on active - [ ] weather, can we embed/iframe https://radar.weather.gov/?settings=v1_eyJhZ2VuZGEiOnsiaWQiOm51bGwsImNlbnRlciI6Wy05My4yMTIsNDQuOTQ0XSwibG9jYXRpb24iOm51bGwsInpvb20iOjkuMjc1NzY1NzM0ODgwODg1fSwiYW5pbWF0aW5nIjp0cnVlLCJiYXNlIjoic3RhbmRhcmQiLCJhcnRjYyI6ZmFsc2UsImNvdW50eSI6ZmFsc2UsImN3YSI6ZmFsc2UsInJmYyI6ZmFsc2UsInN0YXRlIjpmYWxzZSwibWVudSI6dHJ1ZSwic2hvcnRGdXNlZE9ubHkiOmZhbHNlLCJvcGFjaXR5Ijp7ImFsZXJ0cyI6MC44LCJsb2NhbCI6MC42LCJsb2NhbFN0YXRpb25zIjowLjgsIm5hdGlvbmFsIjowLjZ9fQ%3D%3D - [ ] item-preview, click 'full screen' dialog mode that feels like a sleak reading experience dynamically changes size if keyboard open or not remove the edit item text header have link to open in details - [ ] item preview, clicking on an item either in notes or lists should open the same dialog view that also has a button to open in item detail view the dialog should be at tall as the text or max with scroll - [ ] item preview, notes should be full screen for sure, book asthetic, optional button? because dialog prompts feel less jarring cuz 'full page reload' lose context... - [ ] list selector arrow buttons? - [ ] list note index pages, shadows css to indicate scrollable direction - [ ] default first list title is. ..? things, new list? - [ ] Open.the newly created imported list - [ ] new list button should be at top of list selector dialog in list widget - [ ] dialog needs tlc with light color scheme - [ ] schema db, groups are a separate table, one to one, from to - [ ] note widget, sort options - [ ] Weather doesn't fallback its just fails - [ ] Instead of download and whatever just say open note, then open the note, no other clicking - [ ] Tap refresh weather button, kicks new fetch without reloading whole page - [ ] Move import export event handlers out of app js - [ ] Pin enabled temp link, encrypt? - [ ] tab controls on point, rn select list button doesnt highlght, nor does the settings gear or theme toggle - [ ] should my router be in a web worker? or the service worker? - [ ] dynamic pwa theme color? web icon diff from pwq icon - [ ] input values itself saves on debounce, cant lose a thought - [ ] links in note detail view and item detail view, same view? item detail view?? - [ ] Enter to submit weather location - [ ] sun tracker in weather section?!? also year progress bar - [ ] warning to upgrade backups to new format, deprecating legacy, eventually delete - [ ] dates, all list items are this week unless otheriwse specified - [ ] fade out transitions - [ ] Streak counter /habit tracker - [ ] back button say notes/ list? - [ ] Left handed layout - [x] Workout tracker component — implemented as `type: 'workout'` items with inline `meta.entries` array. Route `/workout`. Features: inline config wizard (sets → reps → weight → create), bodyweight support (weight=0 omits weight field), custom weight input, quick-fill chips, inline editing of saved workouts, archive support. No build step, vanilla JS Web Component. - [ ] Desktop notes sizing - [ ] Same app but the free tier/ no account stays on indexed db - [ ] Water tracker component in pockist - [ ] pockist notes Export notes and todos Pkg to MD function Comps have their own logic Only generic global packages Comps encapsulate all logic Is it possible to have all html in the index? Is it even possible to avoid writing html strings in the js? Pockist cloud Once you create an account we migrate (upgrade) the db to a separate electric clientside store Same app but the free tier/ no account stays on indexed db Notes section fills screen on active After exit reset Its slightly too wide for my phone.. Also have it wait to auto fill the title - [ ] Pockist cloud --- Cloud sync paid service - [ ] everything is a note everything is an item in the db notes are view of an item you can add notes to lists notes without a list are displayed in the notes section notes added to a list are in the lists title is just the first row, \n delimited? title exists as a reson to open item in note view there are no titles, we just display the first n char full text search need undo slash delete/archive feature everything is the same data structure just applied in different views linking notes is a separate table with 2 cols? one way links clicking on a list item should open it in the note detail view. folders are just lists - is it possible to nest? folders are a list view without the buttons... links...? lists are an item with one way links... note view is markdown render? or keep it simple text area and implement 'keyboard' buttons?? objects schema item id content links meta date created date of revision undo is just copying to 'history' as new and keeping the last few?? history and trash are views of a state?? should transactions to the db be in a web worker?? ui threads open for smooth transitions? ? idk items could be food store items too fridge and pantry is a view store is a view build a view system that is resilient if field are missing this is document storage after all - [ ] This is aight This is aight Need better shortcuts Make sure this is still here after new notes db roll out Make the nav pop up a popover model dialog or whatever Make it dissapear on ESC or blur Make the weather card CSS smaller and fix the coloring all over the notes page Export notes and todos Pkg to MD function Comps have their own logic Only generic global packages Comps encapsulate all logic Is it possible to have all html in the index? Is it even possible to avoid writing html strings in the js? Pockist cloud Once you create an account we migrate (upgrade) the db to a separate electric clientside store Same app but the free tier/ no account stays on indexed db Notes section fills screen on active After exit reset - [x] docs, close chapter menu on selection on mobile - [x] docs, light dark - [x] Need to be able to move notes into to-do lists and move tasks from list to list transfer tasks. - [x] full text search, agent - [x] schema db, migration, back to basics, links and items - [x] Remove spacing at bottom of page/ components - [x] blue bg on initial user landing, starting style? - [x] spacing below sort buttons on list widget - [x] style about page, add chromium drag and drop only - [x] clear archive - [x] Auto focus text area after new note - [x] XSS prevention - [x] Welcome onboarding screen? - [x] title need to verflow.on list detail - [x] mve to bottom doesnt render properly? in list detail - [x] dont ask again for delete, call it move to trash. just always archive. trash view not archive view. or have both flags? trashed, archived. two views. two differenent mental models - [x] about section, this is just a website all data is stored locally in your browser on your device the only time data is sent to the server is when you create a public share link, upate everything to 0.1.1... - [x] weather page css - [x] BUG, move to list uses the convert method - [x] Also have it wait to auto fill the title - [x] Its slightly too wide for my phone.. - [x] Export notes and todos - [x] Pkg to MD function - [x] Comps have their own logic - [x] Only generic global packages - [x] Comps encapsulate all logic - [x] Is it possible to have all html in the index? Is it even possible to avoid writing html strings in the js? - [x] list widget, fixed height. use empy ghost items for loading and empty space - [x] zooms in on input in safari? - [ ] Once you create an account we migrate (upgrade) the db to a separate electric clientside store ## Future - Features - [ ] share feature can set a password, can share whole backup..., when importing shared backup, can we have it so the user can set the link name?? and can it all be anonymous? ## Won't Do - [ ] ~Clean up adapter layer~ — killed. Works fine, high risk, zero user value. - [ ] ~Remove migration code~ — PWA requires permanent migration chain. ## Recently Completed - [x] Fix Router intercepting blob: URLs and killing downloads — `Router.js` event delegation (2026-06-30) blocked programmatic `blob:` clicks from `ImportExportService`. Added `href.startsWith("blob:")` exclusion. Single-line fix. Also fixed markdown downloads. - [x] Fix list reordering uses DOM indices on unfiltered `listItem.items` (archived refs break ordering) — **Revised 2026-07-08:** Three iterations: 1. **Option B (root cause):** Removed child ref from `listItem.items` in `_archiveItem`, added legacy cleanup in `_loadCurrentList`. Broke restore — archived items became orphans. 2. **Option A (workaround):** Reverted to keeping refs in `listItem.items`. Added `_pruneArchivedRefs()` helper to strip dead refs before every reorder/move/sort/add/duplicate/archive operation. Fixed immediate reordering but stale `_currentListItem` caused issues after archive without refresh. 3. **Path 2 (proper fix):** Added `parentListId` tracking. `DBManager.archiveItem(id, parentListId)` stores `item.meta.parentListId`. `ArchivePage` restore reads it and re-adds the ref to the parent list. Works even if the ref was pruned from the DB by later mutations. - See `docs/parent-list-tracking.md` for full documentation. - [x] Fix API.fetch swallowing errors (calls .json() on 404/500 responses) - [x] Selective backup import (checkbox item picker) - [x] Fix `const` reassignment bug in import options dialog - [x] Fix `showError()` crash when alert-modal is missing - [x] Document database migrations and backwards compatibility - [x] Fix ArchivePage double-confirm showing literal "{count}" instead of number - [x] Fix SearchPopover highlighting corrupting HTML entities (e.g. `&` → broken) - [x] Remove dead legacy DBManager methods: `getNote()`, `getLists()`, `deleteList()`, `#itemToLegacyNote()` - [x] Fix ImportExportService revoking object URL before download starts (mobile) — **Also fixed markdown downloads.** Replaced immediate `URL.revokeObjectURL(url)` with `setTimeout(() => URL.revokeObjectURL(url), 3000)` in all 4 locations: `exportMarkdown`, `exportMarkdownFromData`, `#downloadJSON` (ImportExportService), and `#downloadJSON` (ShareView). This resolves the race where mobile browsers failed to start the download before the blob URL was destroyed. - [x] Fix `_clearCompleted` saving list before archiving items (orphaned items on failure) — Reordered `ListBase._clearCompleted` to archive all completed children first, then save the parent list with filtered refs. Already wrapped in try/catch, so partial failures leave the list untouched (no orphan risk). - [x] Fix WorkoutPage saving to `meta.exercises` but reading from `meta.entries` — Rename mismatch introduced when refactoring workout data structure. Save functions (`_saveWorkout`, `_saveWorkoutEdit`) wrote `meta.exercises`; render/edit read `meta.entries`. Workouts appeared empty after reload. Fixed by changing save keys to `entries`. - [x] Add Changelog link to nav drawer — Added `Changelog` drawer link below About. Added `id="changelog"` to the changelog section. Router updated to strip hashes from route matching and `scrollIntoView` after page render. Popstate passes `location.hash`. - [x] Fix NoteDetailPage archive immediately un-archives — `_doArchive()` called `DBManager.archiveItem()` then `Router.go('/note')`, which triggered `disconnectedCallback() → _save()`. `_save()` overwrote the DB with stale `this._note.meta` (missing `archived: true`). Fix: set `this._note.meta.archived = true` after `archiveItem` resolves so the subsequent `_save()` preserves it. --- ## v11 Schema Migration — parentId + Compound Index Breakdown ### Goal Eliminate N+1 queries and `list.items[]` by moving child relationships to a top-level `parentId` + `order` on item records, queried via a compound IndexedDB index `['parentId', 'order']`. ### Phase 1: Schema & Migration (~2 hrs) - [ ] Bump `DB_CONFIG.VERSION` to `11` - [ ] Add `idx_parent_order` compound index in `onupgradeneeded` - [ ] Write atomic backfill: read `list.items[]`, set `child.parentId` and `child.order`, delete `list.items` - [ ] Add `parentIdMigrationComplete` localStorage flag - [ ] Remove v10 inline-migration code that depends on `list.items` ### Phase 2: DBManager Core Rewrite (~4-6 hrs) - [ ] Rewrite `getListItems(listId)` to query `idx_parent_order` (returns sorted, filter archived in-memory) - [ ] Add `getListItemCount(listId)` using `index.count()` — O(1) - [ ] Add `updateItemOrder(listId, itemOrders)` — bulk update `order` fields - [ ] Update `createItem()` to accept `parentId` and `order` - [ ] Update `moveItemToList()` — update `parentId` and `order` on item, save item, no list mutation - [ ] Update `convertItemToNote()` — delete `parentId`/`order` from item, change type to `'note'` - [ ] Update `copyItemToList()` — create item with `parentId = toListId` - [ ] Update `duplicateList()` — duplicate list (no `items[]`), duplicate children with `parentId = newListId` - [ ] Update `mergeLists()` — new items get `parentId = targetId` and `order` - [ ] Update `deleteList()` — query `idx_parent` for listId, archive children, archive list - [ ] Update `hardDeleteItem()` — no list reference cleanup needed (`items[]` is gone) - [ ] Update `searchItems()` — build parentMap by scanning items for `parentId` - [ ] Update `archiveItem()` — keep `parentId`, `getListItems` filters archived - [ ] Kill or simplify legacy adapter methods: `saveList()`, `getList()`, `getLists()`, `saveLists()`, `createList()`, `#itemToLegacyList()` ### Phase 3: Component Updates (~4-6 hrs) - [ ] `ListBase.js`: `_handleAdd` — create item with `parentId`, reorder existing via `updateItemOrder` - [ ] `ListBase.js`: `_moveItem` — swap `order` values, save both items - [ ] `ListBase.js`: `_clearCompleted` — archive items, no list mutation - [ ] `ListBase.js`: `_sortItems` — update each item's `order`, call `updateItemOrder` - [ ] `ListBase.js`: `_reorderItem` / `_moveItemToTop` / `_moveItemToBottom` — update `order` on affected items - [ ] `ListBase.js`: `_doDuplicateItem` — create with `parentId`, update `order` of following items - [ ] `ListBase.js`: `_initDraggable` — `onReorder` calls `updateItemOrder` - [ ] `ArchivePage.js`: `_getParentListName` — check `item.parentId`, `getItem(parentId)` for name - [ ] `ArchivePage.js`: restore — just `archived = false`, no list reference fixup - [ ] `ArchivePage.js`: `_deleteAll` — hard-delete children via `idx_parent` query - [ ] `ListIndexPage.js`, `ListDetailPage.js`, `NoteBase.js`, `NoteDetailPage.js`, `NoteIndexPage.js` — replace all `l.items?.length || 0` with `getListItemCount()` ### Phase 4: Import, Export & Sharing (~3-4 hrs) - [ ] `ImportExportService.js` export — compute `items[]` on the fly from `getListItems()` for v2.0 backwards compat - [ ] `ImportExportService.js` import — backfill `parentId`/`order` from `list.items[]` if missing (old exports) - [ ] `ImportExportService.js` append/smart-merge — set `parentId = targetListId`, compute `order`, do not mutate `target.items[]` - [ ] `ShareButton.js` — share payload already includes full child records with `parentId`, verify intact - [ ] `ShareView.js` — import logic handles `parentId` same as file import ### Phase 5: Cleanup & Docs (~2 hrs) - [ ] Remove dead legacy adapter methods from DBManager - [ ] Update `docs/db-and-components.md` schema section - [ ] Update `docs/migrations-and-compat.md` with v11 migration - [ ] Update `TODO.md` — mark N+1 and adapter cleanup as done - [ ] Full test pass: migration, CRUD, export/import, share, search, archive, drag-and-drop