Skip to content

fix(pr-comments): let users mark comment authors as bots for the Humans/Bots filter - #7598

Merged
brennanb2025 merged 11 commits into
stablyai:mainfrom
dbachko:dbachko/fix-comment-author-detection
Jul 12, 2026
Merged

brennanb2025 merged 11 commits into
stablyai:mainfrom
dbachko:dbachko/fix-comment-author-detection

Conversation

@dbachko

@dbachko dbachko commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

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:

  • New persisted prBotAuthorOverrides global setting (normalized, deduped, sorted lowercase logins) with shared helpers in src/shared/pr-bot-author-overrides.ts so the desktop renderer, main-process RPC, and mobile classify comment authors identically
  • New Mark author as bot / Unmark author as bot action in the PR comment "more" menu in the checks panel; the action only appears when the author isn't already detected as a bot by the existing heuristics (or is currently overridden)
  • Overrides are threaded through isBotPRComment, getPRCommentAudienceCounts, and filterPRCommentsByAudience on desktop (checks panel, PR page, GitHub item dialog) and mobile (PR sidebar comments section), so the Humans/Bots tabs and counts stay consistent everywhere
  • Untrusted settings.update payloads for the new field are sanitized in the client-ui RPC method

Screenshots

Before — gretelflux (a regular user account posting automated CI summaries) shows under Humans 2; the new menu action is available:

Comment more menu showing the new Mark author as bot action while the bot account is still counted under Humans

After marking — the comment moves out of Humans (now 1: only the real human comment remains) and the counts update immediately:

Humans tab after the override showing only the real human comment

The overridden author now appears under Bots 3 with a BOT badge, and the menu offers Unmark author as bot to revert:

Bots tab showing the overridden author with a BOT badge and the Unmark author as bot action

Testing

  • pnpm lint — passes except one pre-existing switch-exhaustiveness-check error in src/renderer/src/components/right-sidebar/source-control-manual-review-url.ts (untouched by this PR; reproduced at the merge-base commit)
  • pnpm typecheck
  • pnpm test — 24,800 passed; 5 pre-existing failures in src/main/ipc/pty.test.ts (shell-ready marker tests) that reproduce identically on origin/main in the same environment; all tests touched or added by this PR pass
  • pnpm build
  • Added or updated high-quality tests that would catch regressions:
    • Override classification, counts, and filtering: src/renderer/src/lib/pr-comment-audience.test.ts and mobile/src/components/pr-sidebar/pr-comment-presentation.test.ts (desktop/mobile parity)
    • RPC normalization of untrusted override payloads (trimming, lowercasing, dedupe, non-string rejection): src/main/runtime/rpc/methods/client-ui.test.ts
  • Manual: marked a regular-account review bot as bot from the comment menu and verified the Humans/Bots tabs and counts update (screenshots above); the override persists in global settings across restarts

AI Review Report

Reviewed the full diff with attention to the repo's review checklist:

  • Cross-platform (macOS/Linux/Windows): No shortcuts, labels, file paths, shell invocations, or Electron platform APIs are touched. The change is pure TS/React state + settings plumbing; nothing platform-conditional.
  • SSH/remote/local: The override lives in GlobalSettings on the runtime host and flows to clients through the existing settings.get/settings.update RPC, 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.
  • Git provider neutrality: Classification operates on the provider-neutral PRComment.author/isBot fields and generic login heuristics — no GitHub-only naming or behavior added; works for GitLab comments through the same path.
  • Performance: Override sets are memoized (useMemo keyed on the settings slice) and lookups are Set.has per comment; filtering/count recomputation is unchanged in complexity. One flag: CommentRow calls usePRBotAuthorOverrides() per row — acceptable since it's a memoized store selector, but noted for very long comment lists.
  • UI quality: The menu item uses the existing shadcn DropdownMenuItem + lucide Bot icon, 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.
  • Consistency: Verified all three desktop comment surfaces (checks panel, PR page, GitHub item dialog) and mobile use the shared helpers, so counts and filters can't drift.

Security Audit

  • Input handling: prBotAuthorOverrides in settings.update is treated as untrusted: the zod schema pipes it through normalizePRBotAuthorOverrides, which drops non-arrays and non-strings, trims/lowercases, dedupes, and sorts — covered by a unit test with malformed payloads.
  • Injection surface: Overridden logins are only used as normalized Set keys for classification; they are never interpolated into commands, paths, URLs, or HTML.
  • IPC/RPC: No new RPC methods; the field rides the existing strict (.strict()) settings schema, so unknown-field smuggling is still rejected. Mobile only reads the setting.
  • Secrets/deps: No new dependencies; nothing sensitive is stored (public comment-author logins only).
  • No follow-up security work needed.

Notes

  • Overrides are global (not per-repo/provider) by design — a bot account is typically the same across repos; scoping can be added later if needed.
  • Non-English locale entries for the two new menu labels currently fall back to English strings, matching how other recent strings landed (e.g. actionRequiredHint).
  • No platform-specific or agent/integration-specific behavior added.

Generated with Devin

…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>
@coderabbitai

coderabbitai Bot commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 740745fc-4752-4fcc-bb84-64635ebe9ea2

📥 Commits

Reviewing files that changed from the base of the PR and between 5160b2d and 5bda560.

📒 Files selected for processing (3)
  • mobile/src/components/MobilePRSidebar.tsx
  • mobile/src/components/pr-sidebar/PRCommentsSection.tsx
  • mobile/src/session/use-pr-bot-author-overrides.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • mobile/src/components/pr-sidebar/PRCommentsSection.tsx
  • mobile/src/components/MobilePRSidebar.tsx

📝 Walkthrough

Walkthrough

This PR adds manual PR bot-author overrides across shared settings, runtime persistence, renderer UI, and mobile UI. It introduces normalization helpers and the prBotAuthorOverrides settings field, updates RPC validation and defaults, and makes comment audience classification override-aware. Desktop checks UI can mark or unmark authors as bots, while renderer and mobile comment lists apply the resulting overrides. New localized labels and tests cover normalization, limits, classification, filtering, and mobile propagation.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: manual bot author overrides for PR comment Humans/Bots filtering.
Description check ✅ Passed The description includes all required sections and provides summary, screenshots, testing, review, security, and notes.
Linked Issues check ✅ Passed The PR implements manual bot-author overrides and threads them through counts and filtering across desktop and mobile as requested.
Out of Scope Changes check ✅ Passed The changes stay focused on PR comment bot overrides, settings plumbing, UI actions, localization, and tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (3)
src/shared/pr-bot-author-overrides.ts (1)

25-30: 🔒 Security & Privacy | 🔵 Trivial | 💤 Low value

Consider 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 GlobalSettings and slow down later createBotAuthorOverrideSet lookups 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 win

Reuse the shared normalizer instead of duplicating it.

normalized = author.toLowerCase() re-implements what the already-imported normalizePRCommentAuthorLogin does. 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 win

Redundant usePRBotAuthorOverrides() calls across nested components.

CommentRow calls const botAuthorOverrides = usePRBotAuthorOverrides()
const automated = isBotPRComment(comment, botAuthorOverrides) and renders CommentMoreMenu, which independently calls const botAuthorOverrides = usePRBotAuthorOverrides()
const authorLogin = normalizePRCommentAuthorLogin(comment.author) again. Each call re-subscribes to the store and rebuilds a new Set via useMemo per 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 in PRCommentsList (already done for commentCounts/visibleComments) and passing it down as a prop to CommentRow/CommentMoreMenu instead 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

📥 Commits

Reviewing files that changed from the base of the PR and between 99ae2dc and 2103b5b.

📒 Files selected for processing (24)
  • mobile/src/components/MobilePRSidebar.tsx
  • mobile/src/components/pr-sidebar/PRCommentsSection.tsx
  • mobile/src/components/pr-sidebar/pr-comment-audience.ts
  • mobile/src/components/pr-sidebar/pr-comment-presentation.test.ts
  • mobile/src/session/use-pr-bot-author-overrides.ts
  • src/main/codex-accounts/runtime-home-service.test.ts
  • src/main/codex-accounts/service.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/methods/client-ui.test.ts
  • src/main/runtime/rpc/methods/client-ui.ts
  • src/renderer/src/components/GitHubItemDialog.tsx
  • src/renderer/src/components/PullRequestPage.tsx
  • src/renderer/src/components/right-sidebar/checks-panel-content.tsx
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/lib/pr-bot-author-overrides.ts
  • src/renderer/src/lib/pr-comment-audience.test.ts
  • src/renderer/src/lib/pr-comment-audience.ts
  • src/shared/constants.ts
  • src/shared/pr-bot-author-overrides.ts
  • src/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>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
mobile/src/session/use-pr-bot-author-overrides.ts (1)

9-16: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Consider a stable derived key instead of the raw PR data object as refreshKey.

The hook takes refreshKey: unknown and compares it by reference in the effect deps (Line 44). The caller passes state.data (the full PR payload) as this key. Objects are compared by reference in dependency arrays, so if state.data gets a new reference on every poll/re-render (even without a substantive change), this effect — and its settings.get call — will re-fire far more often than the intended "refresh alongside every PR refetch."

Worth verifying whether state.data reference 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

📥 Commits

Reviewing files that changed from the base of the PR and between 2103b5b and 5160b2d.

📒 Files selected for processing (7)
  • mobile/src/components/MobilePRSidebar.tsx
  • mobile/src/components/pr-sidebar/pr-comment-audience.ts
  • mobile/src/session/use-pr-bot-author-overrides.ts
  • src/main/runtime/rpc/methods/client-ui.test.ts
  • src/renderer/src/components/right-sidebar/checks-panel-content.tsx
  • src/renderer/src/lib/pr-comment-audience.ts
  • src/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

@brennanb2025 brennanb2025 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 brennanb2025 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@brennanb2025
brennanb2025 merged commit 7fe6742 into stablyai:main Jul 12, 2026
4 checks passed
@brennanb2025

Copy link
Copy Markdown
Contributor

Thanks for the PR!!

brennanb2025 added a commit that referenced this pull request Jul 13, 2026
#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 <>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…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]>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
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 <>
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.

[Bug]: PR comment Humans/Bots filter misclassifies review bots that use regular user accounts

2 participants