feat(extension): new posts since last visit (Phase 1)#8
Merged
Conversation
Track per-thread read history on-device and flag posts the reader hasn't seen since their last visit. The first visit marks nothing new; later visits show a "New" badge (text + color) and an edge accent. - src/readHistory.ts: stable thread key (fragment dropped), pure id-diff (selectNewIds/mergeSeenIds), and a ReadHistory store over StorageBackend. - src/storage.ts: ChromeStorageBackend implementing @forumforge/storage's StorageBackend over chrome.storage.local (StorageArea injected for tests). - src/render.ts: renderThread takes newPostIds; new posts get data-new and a readable "New" badge. - src/sidepanel.ts: record the visit, pass new ids to render, show "N new". - manifest: add narrow "storage" permission for on-device read history. Docs (ROADMAP, Initial Plan, extension + storage READMEs, memory lesson) synced. Verified: pnpm -r typecheck, pnpm test (90 pass, +14), extension build. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011yrk3ZtMZMpTSnTTjB2YE9
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e49257cd08
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
threadKey dropped the URL fragment unconditionally, which collapsed every SPA-style thread under one path (e.g. #/thread/42, #/thread/7) into a single readHistory key — so a first visit to one such thread looked like a revisit. Strip only plain post-anchor fragments (#post-12, #p9); keep route fragments (those containing "/"). Adds a test covering hash-routed thread identity. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011yrk3ZtMZMpTSnTTjB2YE9
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
Continues Phase 1 with the next roadmap item after OP highlighting (#7):
new posts since last visit.
ForumForge now remembers which posts you've already read in a thread and flags
the ones that are new when you come back — so you can pick up where you left
off instead of re-scanning the whole thread. The first visit marks nothing
("new since last time" is meaningless before there's a last time); later visits
show a "New" badge (text and color) plus an edge accent.
Everything stays on-device (local-first, see
docs/PRIVACY.md): nothingabout what you read leaves the browser.
What changed
src/readHistory.ts(new) — a stable thread key (the#fragmentisdropped, the query kept), pure id-diffing (
selectNewIds/mergeSeenIds),and a
ReadHistorystore layered over aStorageBackend. Post ids are thestable content-derived ids from
@forumforge/core(the factory already names"new-post detection" as a reason they're stable), so the diff survives reloads.
src/storage.ts(new) —ChromeStorageBackend, the@forumforge/storageStorageBackendimplemented overchrome.storage.local. The backingStorageAreais injectable, so it'sunit-tested against a fake area without a real browser. This is the persistent
backend the storage seam was designed for; keeping it in the extension keeps
@forumforge/storagebrowser-agnostic.src/render.ts—renderThreadtakesnewPostIds; new posts get adata-newattribute and a readable "New" badge. Role-edged posts keep theirrole edge (the badge alone signals "new" there) so the two cues don't fight.
src/sidepanel.ts— records the visit, passes new ids to render, and showsN posts · M new. Read history is a convenience layer: if persistence fails,the thread still renders.
manifest.json— adds the narrowstoragepermission, tied to thisfeature. No host permissions; nothing synced off-device.
webext.d.ts— minimalchrome.storagetypings (no@types/chrome).Docs synced in the same change:
ROADMAP.md, the canonicalInitial Plan.mdchecklist, the extension and storage
README.mds, and the storage memory lesson.Roadmap (Phase 1)
Verification
pnpm -r typecheck— passes (core + parser + storage + extension)pnpm test— 90 tests pass (+14: read-history diffing & persistence,chrome.storage backend adapter, "New" badge rendering)
pnpm --filter @forumforge/extension build— bundlesdist/Intentionally not done
logic, storage adapter, and render are unit-tested.
page is its own key). Refining that to one logical thread needs site-adapter
knowledge (Phase 2).
settings UI; out of scope here.
🤖 Generated with Claude Code
https://claude.ai/code/session_011yrk3ZtMZMpTSnTTjB2YE9
Generated by Claude Code