Repository navigation
feat(web): trust moat — 3-second transparency summary, milestone evidence timeline, and closing impact reports - #322
Conversation
…line, and closing impact reports (Refs #314)
There was a problem hiding this comment.
If your organization's extra usage balance is empty, an organization admin can add extra usage credits at claude.ai/admin-settings/usage. If its monthly spend limit was reached, an admin can raise it on the same page. If neither applies, contact Anthropic support.
Once extra usage is available, someone with write access to this repository can comment @claude review on this pull request to trigger a review.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
There was a problem hiding this comment.
⏱️ Code Review completed (26 eligible files · 115,849 chars · 4 model call(s) · 4 PR unit(s))
Whole diff with bounded context at base 4c1b736 / head 41d69a5.
✅ No verified defects
2 possible issue(s) could not be grounded in or verified against the snapshot source, so they are not published.
Context investigation was bounded to the explicitly requested snapshot paths.
|
PO acceptance: merge at 41d69a5 Independent PO flagship security & correctness review (04b162e7-c7ce-417f-bc66-60471d56b8a9): APPROVE (0 P0/P1/P2 findings).
|
Refs #314
Phase 2 (App) implementation for #314 — Trust moat: 3-second transparency summary, milestone-linked disbursement evidence, and closing impact report, built on top of Phase 1 DB (
DOS/DOS.Me#1881, live on Betaoyajkbadsykigtfrpdpg).Summary
1. 3-Second Transparency Summary Box (
/campaigns/[slug])apps/web/src/lib/transparency.ts(getCampaignTransparencySummary,disbursedPercent,unexplainedTotal,getCampaignImpactReport,listPublishedImpactReportCampaignIds, Zod schemas, FormData highlight parser).TransparencySummaryBox(apps/web/src/components/campaign/TransparencySummaryBox.tsx) near the top of public/campaigns/[slug]pages:last_statement_at, or clear empty copy when none yet).%or—when disbursable is0) + disbursed total in VND.evidence_count).0 chưa giải trìnhor count with incoming/outgoing breakdown)./campaigns/[slug]/statementand conditional#bao-cao-tong-ketanchor (only rendered whenpublishedImpactReportis mounted).2. Milestone Evidence Timeline & Owner-Only Disbursement Milestone Linking
MilestoneList(apps/web/src/components/campaign/MilestoneList.tsx) to render per-milestone linked disbursement totals, disbursement counts, and public evidence counts with a direct jump to/campaigns/[slug]/statement?type=outon public campaigns./me/campaigns/[id]/disbursements(page.tsx,actions.ts,lib/statement.ts):ExplainFormforwardingp_milestone_idtogive.record_disbursement(strictly refused on refunds).linkDisbursementMilestoneaction callinggive.set_disbursement_milestoneon explained non-refund disbursements, with milestone badge & relink/unlink control inExplanation./me/campaigns/[id]/disbursementspage and actions strictly verifycampaign.organizer_id === session.user.idbefore touchingdbService(); co-organizer editors never access disbursements.3. Closing Impact Reports (
/me/campaigns/[id],/campaigns/[slug],/u/[handle])saveImpactReport(apps/web/src/app/me/campaigns/[id]/impact-report-actions.ts) using caller JWT (dbAs(session.accessToken), neverdbService()) to callgive.upsert_campaign_impact_report— allowed for owning organizer or accepted co-organizer editor (#264narrative scope) only when status isclosed,succeeded, orsettling.ImpactReportSection(apps/web/src/app/me/campaigns/[id]/ImpactReportSection.tsx) inside/me/campaigns/[id]:<Markdown>, raw HTML disabled, images disallowed), up to 10 key impact highlights, draft vs. publish buttons with irreversible first-time publish confirmation (SubmitButtonconfirmsupport incomponents/forms.tsx), no revert-to-draft once published, and read-only view for non-editable statuses (failed,suspended,cancelled)./me/campaigns/[id]/page.tsxandTeamTab.tsx.ClosingImpactReport(apps/web/src/components/campaign/ClosingImpactReport.tsx) on/campaigns/[slug]with#bao-cao-tong-ketanchor & tab navigation (only whenpublished_at IS NOT NULL)./u/[handle]header (N báo cáo tổng kết) andCampaignCard(Có báo cáo tổng kết) via chunked batch lookup (listPublishedImpactReportCampaignIds).Verification
pnpm format:check— PASSpnpm lint— PASSpnpm typecheck— PASSpnpm test— PASS (191/191 files, 2,758/2,758 tests)pnpm build— PASSf35735e9) — PASS (0 P0, 0 P1, 0 P2 remaining after resolving all initial review findings).📌 TL;DR
This PR implements the "Trust Moat" feature (#314), introducing a public transparency dashboard with milestone-linked disbursement rollups and a new Closing Impact Report system. It allows organizers to draft, publish, and manage post-campaign impact reports while strictly enforcing role-based access controls and data sanitization.
🎯 Type of Change
🔍 Changes Walkthrough
apps/web/src/app/campaigns/[slug]/page.tsxTransparencySummaryBoxandClosingImpactReportinto the public campaign view. Fetches transparency data and impact reports viaPromise.all, ensuring they are hidden for draft/preview modes. Adds a "Báo cáo tổng kết" tab when a published report exists.apps/web/src/app/campaigns/[slug]/page.test.tsapps/web/src/app/me/campaigns/[id]/ImpactReportSection.tsxapps/web/src/app/me/campaigns/[id]/ImpactReportSection.test.tsapps/web/src/app/me/campaigns/[id]/impact-report-actions.tssaveImpactReport. Validates user role (owner or editor) and campaign status (closed/succeeded/settling) before upserting the report via RPC.apps/web/src/app/me/campaigns/[id]/impact-report-actions.test.tssaveImpactReportcovering authorization (owner vs. editor vs. outsider), status validation, and error handling for already-published reports.apps/web/src/app/me/campaigns/[id]/disbursements/actions.tslinkDisbursementMilestoneserver action to associate disbursements with milestones. UpdatesexplainDisbursementto accept and passmilestone_id. Enforces owner-only access for milestone linking.apps/web/src/app/me/campaigns/[id]/disbursements/actions.test.tsapps/web/src/app/me/campaigns/[id]/disbursements/page.tsxapps/web/src/app/me/campaigns/[id]/TeamTab.tsx📊 Architectural Flow
sequenceDiagram participant Organizer as Organizer/Editor participant UI as ImpactReportSection participant Action as saveImpactReport (Server) participant DB as Supabase (RPC) participant Public as Public Campaign Page Organizer->>UI: Edit Summary & Highlights UI->>UI: Toggle Markdown Preview Organizer->>UI: Click "Publish" UI->>Action: Submit FormData (intent: publish) Action->>Action: Validate Session & UUID Action->>DB: Check managed_campaigns (Status & Role) alt Status is not closed/succeeded/settling Action-->>UI: Error: Status not allowed else User is not Owner/Editor Action-->>UI: Error: Not found (404) else Valid Action->>DB: upsert_campaign_impact_report DB-->>Action: Success Action->>Action: revalidatePath (Public & Me) Action-->>UI: Success Message end Note over Public: On Next Page Load Public->>DB: Fetch Transparency Summary & Impact Report DB-->>Public: Data (Sanitized Markdown) Public->>Public: Render TransparencySummaryBox & ClosingImpactReport