Skip to content

fix(flags): align board flag rendering#1142

Merged
tomcasaburi merged 2 commits into
masterfrom
codex/test-community-flags
May 27, 2026
Merged

fix(flags): align board flag rendering#1142
tomcasaburi merged 2 commits into
masterfrom
codex/test-community-flags

Conversation

@tomcasaburi
Copy link
Copy Markdown
Member

@tomcasaburi tomcasaburi commented May 27, 2026

Summary

  • remove the temporary test-community flag fallback so flags depend on directory metadata
  • share the hasFlags check between flag publishing and post rendering
  • align /pol/ board flag selector order and sprite coordinates with 4chan sources

Verification

  • corepack yarn test
  • corepack yarn type-check
  • corepack yarn lint
  • corepack yarn build
  • corepack yarn doctor
  • focused post-rebase: corepack yarn test --run src/lib/tests/board-flags.test.ts src/lib/tests/comment-flag-selection.test.ts src/lib/tests/comment-flags.test.ts src/components/post-form/tests/post-form.test.tsx src/components/reply-modal/tests/reply-modal.test.tsx
  • browser checks in Chrome, Firefox, and WebKit confirmed the temporary test address no longer gets flags while /pol/, /mlp/, and /bant/ behavior remains correct

Note

Low Risk
UI and flag-metadata alignment with expanded tests; no auth or data-path changes. CI behavior for React Doctor on PRs is narrower in scope.

Overview
Board flags now use a shared hasCommentFlagsForDirectory check so post rendering and flag publish/selector logic agree on when flags apply. Desktop and mobile posts use that helper for author flag display instead of duplicating features.hasFlags.

/pol/ political flags match 4chan selector order and sprite positions via explicit coordinates (not index-based grid math), with tests covering key codes and /pol/ option ordering.

CI runs full yarn doctor only on non-PR builds; on PRs with React UI changes it runs yarn doctor --diff with annotations on the changed files.

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

Summary by CodeRabbit

  • New Features / Improvements

    • Author flags display now consistently respects directory flag capability (hidden for deleted/removed/purged posts).
    • Political flags use updated sprite positions for improved visual alignment.
  • Tests

    • Expanded tests for political flag definitions and comment-flag directory detection/selection.

Review Change Stack

@vercel
Copy link
Copy Markdown

vercel Bot commented May 27, 2026

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

Project Deployment Actions Updated (UTC)
5chan Ready Ready Preview, Comment May 27, 2026 8:55am

Request Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 27, 2026

📝 Walkthrough

Walkthrough

Exports a CommentFlagDirectory type and hasCommentFlagsForDirectory; post-desktop and post-mobile now use that helper. Adds POLITICAL_FLAG_COORDINATES and an optional coordinates override to buildFlagDefinitions with updated tests. CI workflow splits the React Doctor step for PR vs non-PR runs.

Changes

Comment Flag Detection and Political Flag Coordinates

Layer / File(s) Summary
Flag-detection helper and type consolidation
src/lib/comment-flag-selection.ts, src/lib/__tests__/comment-flag-selection.test.ts
CommentFlagDirectory type alias and exported hasCommentFlagsForDirectory added; related functions updated to use the alias; unit test added for the helper.
Post component flag-display integration
src/components/post-desktop/post-desktop.tsx, src/components/post-mobile/post-mobile.tsx
Both components import and use hasCommentFlagsForDirectory to determine PostAuthorFlags visibility, replacing direct directoryEntry?.features?.hasFlags checks while preserving deleted/removed/purged exclusions.
Political flag sprite-coordinate system
src/lib/board-flags.ts, src/lib/__tests__/board-flags.test.ts, src/lib/__tests__/comment-flag-selection.test.ts
Adds POLITICAL_FLAG_COORDINATES mapping and extends buildFlagDefinitions with an optional coordinatesByCode override; wires overrides into the pol kind and updates tests to verify new flag codes, coordinates, and ordering.

CI Workflow

Layer / File(s) Summary
Split React Doctor step
.github/workflows/ci.yml
Replace single conditional "Run React Doctor" step with two steps: run yarn doctor for non-PR events, and run yarn doctor --diff <base> --annotations --pr-comment for PRs when React UI files changed.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • bitsocialnet/5chan#1140: Aligns with the core comment-flag implementation, expanding refactored flag-detection helpers into post component rendering.

Poem

🐰 I hopped through types to find the flag,

mapped little sprites to tidy tags,
posts now ask the helper true,
CI split to check what's new,
tiny hops, big tidy flags.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title directly reflects the core objective: aligning board flag rendering through sprite-coordinate alignment and hasFlags check centralization for /pol/ and other boards.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ 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/test-community-flags

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
Copy link
Copy Markdown
Member Author

Addressed the CI blocker by keeping full React Doctor on push builds and running React Doctor in diff mode for pull requests that touch React UI files. The flag change itself did not introduce React Doctor errors; the full-scan failure reproduces on current master after react-doctor 0.2.6, while the PR diff scan passes with warnings only.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/ci.yml:
- Around line 95-97: The workflow step "Run React Doctor on changed React files"
runs `yarn doctor --pr-comment` but the workflow only grants `permissions:
contents: read`, so the doctor can't write PR comments; update the workflow
permissions to include write access for PR comments (e.g., add `permissions:
pull-requests: write` at the job or workflow level) so the `--pr-comment` flag
can create/update pull request comments, leaving the rest of the job and the
`yarn doctor --diff ... --annotations --pr-comment` invocation unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6d8fc5cb-b8b8-4c40-aa2c-242c567016fc

📥 Commits

Reviewing files that changed from the base of the PR and between abd6e26 and 1f0c30c.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml

Comment thread .github/workflows/ci.yml Outdated
@tomcasaburi tomcasaburi force-pushed the codex/test-community-flags branch from 1f0c30c to f8b5baf Compare May 27, 2026 08:55
@tomcasaburi
Copy link
Copy Markdown
Member Author

Addressed the CodeRabbit workflow comment by removing the unnecessary React Doctor --pr-comment flag instead of broadening GitHub token permissions. The PR diff still uses --annotations and the local diff-mode doctor check passes.

@tomcasaburi tomcasaburi merged commit 0299390 into master May 27, 2026
11 checks passed
@tomcasaburi tomcasaburi deleted the codex/test-community-flags branch May 27, 2026 09:06
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