Skip to content

fix(mod queue): stop resurfacing stale pending history#1130

Merged
tomcasaburi merged 1 commit into
masterfrom
codex/fix/stale-mod-queue-history
May 15, 2026
Merged

fix(mod queue): stop resurfacing stale pending history#1130
tomcasaburi merged 1 commit into
masterfrom
codex/fix/stale-mod-queue-history

Conversation

@tomcasaburi
Copy link
Copy Markdown
Member

@tomcasaburi tomcasaburi commented May 15, 2026

Summary

  • Stop storing live pending mod queue snapshots as persistent queue history.
  • Only resurface historical queue items when they represent terminal local moderation state: approved, rejected, or removed.
  • Add regression coverage for stale pending history that has disappeared from the live queue feed.

Root cause

The mod queue persisted every queued item in mod-queue-storage and later merged that history back into the visible queue when the live feed no longer returned the item. On 5chan.app, old pending snapshots from localStorage could therefore survive hard refreshes and reappear even after another moderator approved the posts.

Verification

  • corepack yarn test src/lib/utils/__tests__/mod-queue-utils.test.ts
  • corepack yarn lint
  • corepack yarn type-check
  • corepack yarn test
  • corepack yarn doctor
  • corepack yarn knip
  • corepack yarn build
  • git diff --check

Note

Medium Risk
Changes how the moderation queue persists and rehydrates items, which can affect what moderators see and act on, but is limited to client-side filtering/presentation logic.

Overview
Prevents the mod queue UI from re-adding stale pending items from persisted queuedCommentHistory once they’ve disappeared from the live feed.

This introduces shouldKeepQueuedCommentHistory/getVisibleQueuedCommentHistory to only persist and resurface terminal local moderation outcomes (approved/rejected/removed), and updates ModQueueView to use these helpers when snapshotting feed items and merging history back into the visible feed. Adds unit tests covering the terminal-state rule and the stale-pending regression.

Reviewed by Cursor Bugbot for commit 58b20e7. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced moderation queue history filtering to prevent stale pending items from reappearing once removed from the live feed
    • Updated queued comment history retention to only preserve terminal moderation states (approved, rejected, removed), automatically filtering out pending states

Review Change Stack

@vercel
Copy link
Copy Markdown

vercel Bot commented May 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
5chan Ready Ready Preview, Comment May 15, 2026 11:26am

Request Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 15, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9f445f2a-d4e0-4319-a5a5-5e781a42fbac

📥 Commits

Reviewing files that changed from the base of the PR and between 8486401 and 58b20e7.

📒 Files selected for processing (3)
  • src/lib/utils/__tests__/mod-queue-utils.test.ts
  • src/lib/utils/mod-queue-utils.ts
  • src/views/mod-queue/mod-queue.tsx

📝 Walkthrough

Walkthrough

This PR adds two utility functions to filter and manage queued comment history visibility based on moderation terminal states, live feed presence, and board address matching, then integrates them into ModQueueView to replace prior manual filtering logic in snapshot collection and feedWithHistory construction.

Changes

Queued Comment History Visibility Filtering

Layer / File(s) Summary
New queued history filtering utilities
src/lib/utils/mod-queue-utils.ts
Add imports for pending-approval rejection and board-address equality helpers. Export shouldKeepQueuedCommentHistory() to retain only approved or pending-approval-rejected comments, and getVisibleQueuedCommentHistory<T>() to filter typed queued history by CID presence in live feed, keep-history predicate, and board address matching.
Integration in ModQueueView
src/views/mod-queue/mod-queue.tsx
Update utilities import to multi-line format. Filter queuedCommentSnapshots through shouldKeepQueuedCommentHistory before storing in remembered history. Rebuild feedWithHistory by appending getVisibleQueuedCommentHistory(feed, queuedCommentHistory, communityAddresses) to the live feed instead of using manual CID comparison and board filtering.
Test cases for history utilities
src/lib/utils/__tests__/mod-queue-utils.test.ts
Add multi-line import for the new utility functions. Add test case verifying shouldKeepQueuedCommentHistory returns false for non-terminal states (pending, published) and true for terminal states (approved, rejected, removed). Add test case verifying getVisibleQueuedCommentHistory returns only terminal history items matching the live feed and selected board, excluding stale pending entries no longer in the live feed.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A rabbit's ode to history's keep,
Terminal states, no pending sleep,
CIDs match, addresses align,
Filtered views make queues shine,
Stale ghosts fade, fresh ones stay,
Mod queue history, the filtered way!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main objective: preventing stale pending history items from being resurfaced in the mod queue, which is the core fix addressed across all three modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix/stale-mod-queue-history

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@tomcasaburi tomcasaburi merged commit a6f6e42 into master May 15, 2026
11 checks passed
@tomcasaburi tomcasaburi deleted the codex/fix/stale-mod-queue-history branch May 15, 2026 11:35
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.

1 participant