Skip to content

feat(comment-automation): add image-only filter and AI comment moderation - #1632

Merged
sung17 merged 2 commits into
mainfrom
feat/comment-automation-image-filter
Nov 3, 2026
Merged

sung17 merged 2 commits into
mainfrom
feat/comment-automation-image-filter

Conversation

@sung17

@sung17 sung17 commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Image-only reply filter — new options.onlyCommentsWithImage switch (Facebook and Threads; ignored with a capability log elsewhere). A skipped comment records the new noImageAttachment miss reason.
  • AI comment moderation — hideComments.aiModeration (aiAgentId, categories, instruction, action: hide | delete). Each comment on a matching post goes to an AIJobAction.commentModeration job that classifies it with the agent's models (comment passed as quoted data, never as instructions). A flagged comment is hidden or deleted and is not answered. If a provider fails, the comment goes back through the reply flow unmoderated (fail open).
  • Moderation log — new CommentModerationLog table (one row per automation + comment, status pending/done/failed), a moderatedCount counter, a "Moderated comments" card, and public API commentAutomations.listModerationLogs / getModerationSummary (CLI/MCP docs updated).

Behavior kept for existing automations

Hide rules (all, phone number, link, keywords, image/video/GIF/emoji) stay where they were: they run only for comments that pass the reply filters, and the comment is hidden and still answered. Existing "DM then hide" automations behave the same. Only AI moderation runs before the reply filters and blocks the reply.

Reliability fixes from review

  • A comment already in the log but still pending (enqueue failed) gets its hide/delete enqueued again. Hide/delete jobs use a fixed jobId (moderate-comment-<automation>-<comment>), so a still-queued job does not run twice.
  • If hiding a comment or queueing the AI job fails, the error is logged on its own and no longer recorded as a failed reply.
  • Missed-comment replays carry replay: true. The AI job and the resumed job get their own jobIds and keep the replay's low priority. The resumed job uses default retries.
  • Chat handlers settle the log as failed for every failure path (missing or non-comment message, integration lookup error), so no row stays pending.

Migrations

  • 20261102072403_add_comment_automation_miss_no_image — adds the noImageAttachment miss reason
  • 20261102080247_comment_moderation_log — new table and counter

db:check-drift is clean. Migrations have not been applied anywhere.

Test plan

  • pnpm lint
  • typecheck across the repo (pre-commit)
  • worker: comment-automation, comment-moderation, comment-automation-attachment (245 tests)
  • builder: moderation logs, public API, public spec snapshot, edge instrumentation graph (54 tests)
  • Manual: Facebook automation with "hide all" + DM still DMs and hides
  • Manual: AI moderation hides/deletes an offensive comment and lets a polite one get a reply

🤖 Generated with Claude Code

…tion

- "Only comments with an image" reply filter (Facebook, Instagram, Threads),
  recorded as the `noImageAttachment` miss reason
- AI moderation: classify each comment on a matching post with a chosen AI
  agent's models, then hide or delete it; checked before the reply filters and
  a moderated comment is never answered
- CommentModerationLog table, moderatedCount counter, moderation log card and
  public API (listModerationLogs, getModerationSummary)
- Hide rules keep their original place and behavior (after the reply filters,
  hide and still answer), so existing "DM then hide" automations are unchanged
- Re-enqueue a moderation still pending in the log, dedup hide/delete jobs by
  id, and settle every failure path so no log row stays pending
- Missed-comment replays get their own AI/resume job ids and keep the replay's
  low priority

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the feature New feature or request label Nov 3, 2026
@sung17
sung17 merged commit 6ff5271 into main Nov 3, 2026
14 checks passed
hello-jackytruong referenced this pull request in hello-jackytruong/ChatWorkAI Nov 22, 2026
…tion (#1632)

* feat(comment-automation): add image-only filter and AI comment moderation

- "Only comments with an image" reply filter (Facebook, Instagram, Threads),
  recorded as the `noImageAttachment` miss reason
- AI moderation: classify each comment on a matching post with a chosen AI
  agent's models, then hide or delete it; checked before the reply filters and
  a moderated comment is never answered
- CommentModerationLog table, moderatedCount counter, moderation log card and
  public API (listModerationLogs, getModerationSummary)
- Hide rules keep their original place and behavior (after the reply filters,
  hide and still answer), so existing "DM then hide" automations are unchanged
- Re-enqueue a moderation still pending in the log, dedup hide/delete jobs by
  id, and settle every failure path so no log row stays pending
- Missed-comment replays get their own AI/resume job ids and keep the replay's
  low priority

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(worker): pass job context to orphaned-integration cleanup for comment moderation

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Deathgiver <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant