Repository navigation
fix(pr-comments): let users mark comment authors as bots for the Humans/Bots filter - #7598
Conversation
…ns/Bots filter Some review bots post from regular user accounts that defeat both provider bot metadata and login heuristics, so their comments were misclassified as human. Adds a persisted prBotAuthorOverrides setting with a "Mark author as bot" comment action, applied consistently across desktop and mobile. Fixes stablyai#7597 Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThis PR adds manual PR bot-author overrides across shared settings, runtime persistence, renderer UI, and mobile UI. It introduces normalization helpers and the 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (3)
src/shared/pr-bot-author-overrides.ts (1)
25-30: 🔒 Security & Privacy | 🔵 Trivial | 💤 Low valueConsider bounding the sanitized override list size.
The function is documented as sanitizing "an untrusted settings update value" but does not cap the number of entries or individual string length before persisting. A malformed/oversized payload could bloat
GlobalSettingsand slow down latercreateBotAuthorOverrideSetlookups in the comment-classification hot path.🛡️ Optional defensive cap
+const MAX_PR_BOT_AUTHOR_OVERRIDES = 500 + export function normalizePRBotAuthorOverrides(value: unknown): string[] { if (!Array.isArray(value)) { return [] } - return [...createBotAuthorOverrideSet(value.filter((login) => typeof login === 'string'))].sort() + return [...createBotAuthorOverrideSet(value.filter((login) => typeof login === 'string'))] + .sort() + .slice(0, MAX_PR_BOT_AUTHOR_OVERRIDES) }src/renderer/src/lib/pr-comment-audience.ts (1)
53-64: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReuse the shared normalizer instead of duplicating it.
normalized = author.toLowerCase()re-implements what the already-importednormalizePRCommentAuthorLogindoes. If that shared helper's normalization rules ever change, this inline copy will silently drift and override matching could break.♻️ Proposed fix to reuse the shared normalizer
export function isBotPRComment( comment: PRComment, botAuthorOverrides?: ReadonlySet<string> ): boolean { const author = comment.author.trim() - const normalized = author.toLowerCase() + const normalized = normalizePRCommentAuthorLogin(comment.author) if (botAuthorOverrides?.has(normalized)) { return true }src/renderer/src/components/right-sidebar/checks-panel-content.tsx (1)
1493-1503: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winRedundant
usePRBotAuthorOverrides()calls across nested components.
CommentRowcalls const botAuthorOverrides = usePRBotAuthorOverrides()
const automated = isBotPRComment(comment, botAuthorOverrides) and rendersCommentMoreMenu, which independently calls const botAuthorOverrides = usePRBotAuthorOverrides()
const authorLogin = normalizePRCommentAuthorLogin(comment.author) again. Each call re-subscribes to the store and rebuilds a newSetviauseMemoper component instance, so every visible comment row constructs the override set twice (up to ~200 times for the 100-comment cap). Consider computing the set once inPRCommentsList(already done forcommentCounts/visibleComments) and passing it down as a prop toCommentRow/CommentMoreMenuinstead of each subscribing independently.♻️ Proposed refactor sketch
function CommentMoreMenu({ comment, onStartEdit, onDelete, - onQueueForAgent + onQueueForAgent, + botAuthorOverrides }: { comment: PRComment onStartEdit?: () => void onDelete?: () => void | Promise<void> onQueueForAgent?: () => void + botAuthorOverrides: ReadonlySet<string> }): React.JSX.Element | null { - const botAuthorOverrides = usePRBotAuthorOverrides() const authorLogin = normalizePRCommentAuthorLogin(comment.author)}): React.JSX.Element { - const botAuthorOverrides = usePRBotAuthorOverrides() + const botAuthorOverrides = usePRBotAuthorOverrides() // still needed here for `automated` const automated = isBotPRComment(comment, botAuthorOverrides) ... - <CommentMoreMenu comment={comment} ... /> + <CommentMoreMenu comment={comment} botAuthorOverrides={botAuthorOverrides} ... />Also applies to: 1687-1688
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 4718e00d-7333-409c-a1a7-f2d0a368edc4
📒 Files selected for processing (24)
mobile/src/components/MobilePRSidebar.tsxmobile/src/components/pr-sidebar/PRCommentsSection.tsxmobile/src/components/pr-sidebar/pr-comment-audience.tsmobile/src/components/pr-sidebar/pr-comment-presentation.test.tsmobile/src/session/use-pr-bot-author-overrides.tssrc/main/codex-accounts/runtime-home-service.test.tssrc/main/codex-accounts/service.test.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/rpc/methods/client-ui.test.tssrc/main/runtime/rpc/methods/client-ui.tssrc/renderer/src/components/GitHubItemDialog.tsxsrc/renderer/src/components/PullRequestPage.tsxsrc/renderer/src/components/right-sidebar/checks-panel-content.tsxsrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/lib/pr-bot-author-overrides.tssrc/renderer/src/lib/pr-comment-audience.test.tssrc/renderer/src/lib/pr-comment-audience.tssrc/shared/constants.tssrc/shared/pr-bot-author-overrides.tssrc/shared/types.ts
- Cap sanitized prBotAuthorOverrides at 500 entries so malformed payloads can't bloat GlobalSettings or slow comment classification - Reuse the shared normalizePRCommentAuthorLogin in isBotPRComment on desktop and mobile instead of duplicating the normalization inline - Pass botAuthorOverrides from CommentRow to CommentMoreMenu instead of re-subscribing per menu instance - Re-fetch mobile bot-author overrides alongside each PR refetch so they don't stay a stale one-shot snapshot for the whole session Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
mobile/src/session/use-pr-bot-author-overrides.ts (1)
9-16: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winConsider a stable derived key instead of the raw PR data object as
refreshKey.The hook takes
refreshKey: unknownand compares it by reference in the effect deps (Line 44). The caller passesstate.data(the full PR payload) as this key. Objects are compared by reference in dependency arrays, so ifstate.datagets a new reference on every poll/re-render (even without a substantive change), this effect — and itssettings.getcall — will re-fire far more often than the intended "refresh alongside every PR refetch."Worth verifying whether
state.datareference is stable except on genuine refetches; if not, deriving a primitive key (e.g., PR id +updatedAt) would be more robust.Also applies to: 44-44
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: e8c2099c-5124-434f-b56b-49f77da5d6f5
📒 Files selected for processing (7)
mobile/src/components/MobilePRSidebar.tsxmobile/src/components/pr-sidebar/pr-comment-audience.tsmobile/src/session/use-pr-bot-author-overrides.tssrc/main/runtime/rpc/methods/client-ui.test.tssrc/renderer/src/components/right-sidebar/checks-panel-content.tsxsrc/renderer/src/lib/pr-comment-audience.tssrc/shared/pr-bot-author-overrides.ts
🚧 Files skipped from review as they are similar to previous changes (5)
- src/shared/pr-bot-author-overrides.ts
- mobile/src/components/MobilePRSidebar.tsx
- mobile/src/components/pr-sidebar/pr-comment-audience.ts
- src/renderer/src/lib/pr-comment-audience.ts
- src/renderer/src/components/right-sidebar/checks-panel-content.tsx
# Conflicts: # mobile/src/components/MobilePRSidebar.tsx
brennanb2025
left a comment
There was a problem hiding this comment.
Thanks for the focused contribution. I hardened persistence and cross-client behavior, moved mark and unmark into an atomic runtime-owned update, added mobile and paired-web coverage, translated the UI, and verified the real Comments filters end to end.
brennanb2025
left a comment
There was a problem hiding this comment.
Reviewed against latest main. Verified atomic persisted bot-author overrides across desktop, paired web, and mobile; focused tests, typechecks, lint, delegated perf/review, and Electron mark/unmark evidence are clean.
|
Thanks for the PR!! |
#7598 pushed client-ui.ts to 301 lines, one over the max-lines limit, which breaks repo lint for every PR that merges current main (verify does not run on main pushes). Follow the existing browser-schemas.ts/computer-schemas.ts pattern: zod schemas move to a sibling module, the method registry stays. Co-authored-by: Brennan Benson <>
…ns/Bots filter (stablyai#7598) * fix(pr-comments): let users mark comment authors as bots for the Humans/Bots filter Some review bots post from regular user accounts that defeat both provider bot metadata and login heuristics, so their comments were misclassified as human. Adds a persisted prBotAuthorOverrides setting with a "Mark author as bot" comment action, applied consistently across desktop and mobile. Fixes stablyai#7597 Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(pr-comments): address review feedback on bot-author overrides - Cap sanitized prBotAuthorOverrides at 500 entries so malformed payloads can't bloat GlobalSettings or slow comment classification - Reuse the shared normalizePRCommentAuthorLogin in isBotPRComment on desktop and mobile instead of duplicating the normalization inline - Pass botAuthorOverrides from CommentRow to CommentMoreMenu instead of re-subscribing per menu instance - Re-fetch mobile bot-author overrides alongside each PR refetch so they don't stay a stale one-shot snapshot for the whole session Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(pr-comments): harden bot author override sync * fix(pr-comments): bound and recover override updates * fix(pr-comments): merge overrides from canonical settings * fix(pr-comments): make bot override updates atomic * fix(pr-comments): surface rejected bot overrides * fix(i18n): translate bot override warning * fix(i18n): translate bot author actions --------- Co-authored-by: Dzmitry Bachko <[email protected]> Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Brennan Benson <[email protected]>
stablyai#7598 pushed client-ui.ts to 301 lines, one over the max-lines limit, which breaks repo lint for every PR that merges current main (verify does not run on main pushes). Follow the existing browser-schemas.ts/computer-schemas.ts pattern: zod schemas move to a sibling module, the method registry stays. Co-authored-by: Brennan Benson <>
Summary
Fixes #7597
Some review bots (e.g.
gretelflux) post from regular user accounts, so neither provider metadata (isBot) nor login heuristics ([bot]suffix, automation substrings) classify them as bots — their comments pollute the Humans tab of the PR comment filter. This PR adds a user-controlled escape hatch:prBotAuthorOverridesglobal setting (normalized, deduped, sorted lowercase logins) with shared helpers insrc/shared/pr-bot-author-overrides.tsso the desktop renderer, main-process RPC, and mobile classify comment authors identicallyisBotPRComment,getPRCommentAudienceCounts, andfilterPRCommentsByAudienceon desktop (checks panel, PR page, GitHub item dialog) and mobile (PR sidebar comments section), so the Humans/Bots tabs and counts stay consistent everywheresettings.updatepayloads for the new field are sanitized in the client-ui RPC methodScreenshots
Before —
gretelflux(a regular user account posting automated CI summaries) shows under Humans 2; the new menu action is available:After marking — the comment moves out of Humans (now 1: only the real human comment remains) and the counts update immediately:
The overridden author now appears under Bots 3 with a
BOTbadge, and the menu offers Unmark author as bot to revert:Testing
pnpm lint— passes except one pre-existingswitch-exhaustiveness-checkerror insrc/renderer/src/components/right-sidebar/source-control-manual-review-url.ts(untouched by this PR; reproduced at the merge-base commit)pnpm typecheckpnpm test— 24,800 passed; 5 pre-existing failures insrc/main/ipc/pty.test.ts(shell-ready marker tests) that reproduce identically onorigin/mainin the same environment; all tests touched or added by this PR passpnpm buildsrc/renderer/src/lib/pr-comment-audience.test.tsandmobile/src/components/pr-sidebar/pr-comment-presentation.test.ts(desktop/mobile parity)src/main/runtime/rpc/methods/client-ui.test.tsAI Review Report
Reviewed the full diff with attention to the repo's review checklist:
GlobalSettingson the runtime host and flows to clients through the existingsettings.get/settings.updateRPC, so remote/SSH clients and mobile see the same classification as local. The mobile hook fetch is best-effort — if the RPC fails, heuristics still apply and nothing breaks.PRComment.author/isBotfields and generic login heuristics — no GitHub-only naming or behavior added; works for GitLab comments through the same path.useMemokeyed on the settings slice) and lookups areSet.hasper comment; filtering/count recomputation is unchanged in complexity. One flag:CommentRowcallsusePRBotAuthorOverrides()per row — acceptable since it's a memoized store selector, but noted for very long comment lists.DropdownMenuItem+ lucideBoticon, separator rules match the surrounding menu, and labels are localized (en/es/ja/ko/zh entries added; non-en fall back to English pending translation). The action is hidden when heuristics already classify the author as a bot, so it can't produce a no-op state.Security Audit
prBotAuthorOverridesinsettings.updateis treated as untrusted: the zod schema pipes it throughnormalizePRBotAuthorOverrides, which drops non-arrays and non-strings, trims/lowercases, dedupes, and sorts — covered by a unit test with malformed payloads.Setkeys for classification; they are never interpolated into commands, paths, URLs, or HTML..strict()) settings schema, so unknown-field smuggling is still rejected. Mobile only reads the setting.Notes
actionRequiredHint).Generated with Devin