feat(social): add a channel to many posts at once, and send many drafts for review (#1178) #1184
All Vouch review confidence checks passed
Residual risk 0.42 = Change Risk (0.52) × (1 − Review Confidence (0.19)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 25% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #1184"
general
weight: 0.35
claude[bot]
What changed
Add a channel to many posts (
social.post.bulk_add_channel, R1, members and above)bulk-edit.tspattern ofsocial.post.bulk_replace(#1144). The posts are locked in id order, each with its variants. Each post then goes throughsocial.post.add_channelsas a nested command (ctx.tryRunwith a LEFT_OUT map), which writes its own audit row.social.post.add_channelsnow appends a post version (withVersion), so each post gets a version for the new channel. Single adds get one too.403 CHANNEL_NOT_ALLOWED, and a channel that is not live in the org isCHANNEL_NOT_FOUND.-
not_found-
not_allowed: on none of the caller's channels. This check runs first, so a limited member learns nothing about the post.-
published: no channel is still open-
already_on: the channel is live on the post (a cancelled one can be added again)-
too_many_channels: the post already has 20-
in_flight: a channel is going out or needs attentionadded: [{ postId, variantId, issues }], so it says which added channels already fit their rules and which need edits (for example Instagram without media).Send many drafts for review
social.post.submitonce per post, the way bulk approve callssocial.variant.decide(runBulk).submitResultsorts each post into one of these: submitted, nothing to submit (NOTHING_TO_SUBMIT), invalid (VARIANT_INVALID, listing each channel's issues), blocked word (BANNED_WORDS, with the words), or another refusal.Bulk bar
runAddChannel), and shows the skip reasons and the drafts that need edits with their issues.Folded in from #1062
- The nested
social.post.assigngets a server-onlybulk: true. The RPC contract's strict input does not carry it, and no agent may run the command.- Its event carries
bulk: trueand notifies nobody.- The bulk command emits
social.post.bulk_assigned. The dispatcher sends oneassignednotification covering the posts the assignee can see (postsVisibleTo, #1081). One post reads as a single assignment. Several posts givepostId: null,detail.count, and the item opens the assignee's own posts (?mine=true).Folded in from #1099 (bulk label point only)
bulk_labelsandbulk_assignreport a post outside a limited member's channels asnot_allowedbeforepublished,unchangedortoo_many_labels.No migration.
MAX_CHANNELS_PER_POSTmoved tovariants.ts(re-exported fromposts.ts) sobulk-edit.tscan use it without a circular import.How it was tested
- new
apps/kernel/test/social-bulk-add-channel.db.test.ts:- 30 posts each get a draft with the base content and planned time, an audit row and a version
- Instagram needs edits
- mixed outcomes, one per skip reason
- channel scope: a limited member, a channel outside the scope, a hidden published post reported as
not_allowed- viewer refused, a revoked or foreign channel refused, bounds
- lock order while another transaction holds a post
-
social-bulk-edit.db.test.tsextended:- one notification per bulk assignment, with a count
- a limited assignee is told only of the posts they can see
- due dates kept for a departed assignee, refused for a new assignment (#1062)
-
not_allowedfor hidden posts in bulk labels and bulk assign (#1099)- every
apps/kernel/test/social-.db.test.tsfile andnotifications.db.test.ts: 65 files, 424 tests pass.-
apps/app/test/social-bulk.test.ts: submit requests,submitResultcategories,runAddChannelbatches-
social-bulk-bar.test.tsx: Gửi duyệt and Thêm kênh are offered; Thêm kênh* is hidden when there is no channel to add-
social-notifications.test.ts: the bulk assignment target- every skip reason has vi/en copy
pnpm typecheck,pnpm lint,pnpm docs:checkpass.Closes #1178
🤖 Generated with Claude Code
---
<!-- dos-pr-summary -->
📌 TL;DR
This PR introduces two new bulk actions to the Social module: "Submit for review" (sending drafts to review) and "Add a channel" (bulk-adding a channel to multiple posts). It also refines the notification system to handle bulk assignment notifications and updates the UI to support these new workflows with detailed result reporting.
🎯 Type of Change
🔍 Changes Walkthrough
| File | Summary of Changes |
| :--- | :--- |
|
apps/app/src/components/social-bulk.tsx| Adds UI logic for the newsubmitandaddChannelactions. Includes new form states, result rendering cards, and integration with the new API endpoints. ||
apps/app/src/i18n/messages/en.ts| Adds English translations for the new bulk actions, result messages, and the newassigned_manynotification text. ||
apps/app/src/i18n/messages/vi.ts| Adds Vietnamese translations for the new bulk actions, result messages, and the newassigned_manynotification text. ||
apps/app/src/lib/social-bulk.ts| Extends theBulkActiontype to includesubmitandaddChannel. ImplementssubmitResultto categorize submission errors (invalid, blocked, skipped) andrunAddChannelto handle batched channel additions with issue tracking. ||
apps/app/src/lib/social-notifications.ts| UpdatesNotificationTargetto support a'mine'target, allowing navigation to the user's assigned posts when a bulk assignment notification is clicked. ||
apps/app/src/routes/social-notifications.tsx| Handles the newassignednotification kind, displaying a count of assigned posts and navigating to the "My Posts" view. ||
apps/app/src/routes/social.tsx| Updates theBulkBarcomponent usage to passchannelOptionsand enables thesubmitandaddChannelactions based on user roles and list tabs. ||
apps/app/test/social-bulk-bar.test.tsx| Adds tests to verify that thesubmitandaddChannelactions are correctly displayed in the UI for members and that the channel form behaves as expected. ||
apps/app/test/social-bulk.test.ts| Adds unit tests for the newsubmitResultlogic (categorizing errors) andrunAddChannel(batching and issue tracking). ||
apps/app/test/social-notifications.test.ts| Adds tests for the newassignednotification target resolution. ||
apps/kernel/src/rpc.ts| Registers the newbulkAddChannelRPC handler, mapping it to thesocial.post.bulk_add_channelcommand. ||
apps/kernel/test/social-bulk-add-channel.db.test.ts| New integration test file verifying thebulk_add_channelcommand against a real PostgreSQL database, covering permissions, edge cases (published posts, channel limits), and audit logging. |📊 Architectural Flow
<!-- /dos-pr-summary -->