feat(extension): save useful posts (Phase 1)#9
Merged
Conversation
Adds the "save comments" Phase 1 feature: a per-post Save toggle in the side panel that keeps an on-device snapshot of useful posts. - src/savedPosts.ts (new): SavedPosts store over a @forumforge/storage Collection. A saved post is a frozen snapshot plus provenance (thread key, page URL, title, savedAt), keyed per thread so the same post id in two threads can't collide. toggle/save/remove/isSaved/savedIdsFor/all. - src/render.ts: each post gets a "Save"/"Saved" toggle (aria-pressed + label, not color alone) reflecting savedPostIds; render stays a pure view. setSaveButtonState is shared by render and the panel update. - src/sidepanel.ts: loads saved ids for the thread, passes them to render, and a delegated click handler persists toggles against the frozen post snapshot. Honest UI — the button reflects what storage actually reached. - public/sidepanel.html: Save toggle styles. Everything stays on-device (local-first, docs/PRIVACY.md); no new permissions. Docs synced: ROADMAP.md, Initial Plan.md checklist, and the extension README. Verification: pnpm -r typecheck passes; pnpm test 102 pass (+12: saved post store, key namespacing, Save rendering); extension build bundles. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ujybr1sbfakZamZJsZxUfz
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
First, merged the one outstanding unmerged PR (#8, "new posts since last visit") — its lone review comment was already resolved and CI was green, so it merged cleanly into
main. Then continued Phase 1 with the next roadmap item: save comments.ForumForge now lets the reader save any useful post from a thread. Each post gets a Save / Saved toggle in the side panel; saving keeps an on-device snapshot (the post content frozen at save time) plus where it came from, so the saved item stays stable even if the page later changes — and can be revisited and exported to Markdown later (the next Phase 1 item).
Everything stays on-device (local-first, see
docs/PRIVACY.md): nothing about what you keep leaves the browser, and no new permissions are needed — saved posts reuse the existingstoragepermission.What changed
src/savedPosts.ts(new) — aSavedPostsstore over a@forumforge/storageCollection. ASavedPostis a frozen snapshot plus provenance (thread key, page URL, title,savedAt). Keys are namespaced per thread (<threadKey> <postId>), so the same post id in two different threads can't collide; the thread key reusesreadHistory's fragment-normalization so a post anchor in the URL doesn't fork the key. API:save/remove/isSaved/toggle/savedIdsFor/all.src/render.ts— each post gets aSave/Savedtoggle reflectingoptions.savedPostIds. The state is carried by the label andaria-pressed(not color alone).renderThreadstays a pure view;setSaveButtonStateis exported and shared by initial render and the panel's click update so the two never drift.src/sidepanel.ts— loads the thread's saved ids, passes them to render, and a single delegated click handler (on the persistent output container) toggles save state against the frozen post snapshot. The button reflects what storage actually reached — a failed write leaves the label honest.public/sidepanel.html— Save toggle styles (pill button, pressed state).Docs synced in the same change:
ROADMAP.md, the canonicalInitial Plan.mdchecklist, and the extensionREADME.md.Roadmap (Phase 1)
Verification
pnpm -r typecheck— passes (core + parser + storage + extension)pnpm test— 102 tests pass (+12: saved-post store, per-thread key namespacing, Save rendering & state toggling)pnpm --filter @forumforge/extension build— bundlesdist/Intentionally not done
SavedPosts.all()already returns saved posts most-recent-first to feed it, but the UI and export are the next Phase 1 items, out of scope here.🤖 Generated with Claude Code
Generated by Claude Code