Skip to content

feat(extension): new posts since last visit (Phase 1)#8

Merged
erichuang1425 merged 2 commits into
mainfrom
claude/unmerged-prs-review-merge-4c6q4o
Jun 23, 2026
Merged

feat(extension): new posts since last visit (Phase 1)#8
erichuang1425 merged 2 commits into
mainfrom
claude/unmerged-prs-review-merge-4c6q4o

Conversation

@erichuang1425

Copy link
Copy Markdown
Owner

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): nothing
about what you read leaves the browser.

read thread ─▶ thread key from URL ─▶ diff post ids vs seen ─▶ mark new ─▶ persist

What changed

  • src/readHistory.ts (new) — a stable thread key (the #fragment is
    dropped, the query kept), pure id-diffing (selectNewIds / mergeSeenIds),
    and a ReadHistory store layered over a StorageBackend. Post ids are the
    stable 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/storage StorageBackend implemented over
    chrome.storage.local. The backing StorageArea is injectable, so it's
    unit-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/storage browser-agnostic.
  • src/render.tsrenderThread takes newPostIds; new posts get a
    data-new attribute and a readable "New" badge. Role-edged posts keep their
    role 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 shows
    N posts · M new. Read history is a convenience layer: if persistence fails,
    the thread still renders.
  • manifest.json — adds the narrow storage permission, tied to this
    feature. No host permissions; nothing synced off-device.
  • webext.d.ts — minimal chrome.storage typings (no @types/chrome).

Docs synced in the same change: ROADMAP.md, the canonical Initial Plan.md
checklist, the extension and storage README.mds, and the storage memory lesson.

Roadmap (Phase 1)

  • Clean reading mode
  • OP highlighting
  • New posts since last visit ← this PR
  • Save comments
  • Local user notes
  • Markdown export
  • Discourse adapter
  • Hacker News adapter

Verification

  • pnpm -r typecheck — passes (core + parser + storage + extension)
  • pnpm test90 tests pass (+14: read-history diffing & persistence,
    chrome.storage backend adapter, "New" badge rendering)
  • pnpm --filter @forumforge/extension build — bundles dist/

Intentionally not done

  • Clicking through in a real browser is a manual step (needs a browser); the
    logic, storage adapter, and render are unit-tested.
  • Pagination: a paginated thread's pages are tracked per-URL for now (each
    page is its own key). Refining that to one logical thread needs site-adapter
    knowledge (Phase 2).
  • "Mark all read" / clearing history — a natural follow-up once there's
    settings UI; out of scope here.

🤖 Generated with Claude Code

https://claude.ai/code/session_011yrk3ZtMZMpTSnTTjB2YE9


Generated by Claude Code

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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread apps/extension/src/readHistory.ts Outdated
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
@erichuang1425 erichuang1425 merged commit ac441c2 into main Jun 23, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants