Skip to content

feat(web): trust moat — 3-second transparency summary, milestone evidence timeline, and closing impact reports - #322

Merged
JOY (JOY) merged 1 commit into
devfrom
antigravity/give-314-transparency-moat
Nov 22, 2026
Merged

JOY (JOY) merged 1 commit into
devfrom
antigravity/give-314-transparency-moat

Conversation

@JOY

@JOY JOY (JOY) commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

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 Beta oyajkbadsykigtfrpdpg).

Summary

1. 3-Second Transparency Summary Box (/campaigns/[slug])

  • Added apps/web/src/lib/transparency.ts (getCampaignTransparencySummary, disbursedPercent, unexplainedTotal, getCampaignImpactReport, listPublishedImpactReportCampaignIds, Zod schemas, FormData highlight parser).
  • Added TransparencySummaryBox (apps/web/src/components/campaign/TransparencySummaryBox.tsx) near the top of public /campaigns/[slug] pages:
    • Statement freshness timestamp (last_statement_at, or clear empty copy when none yet).
    • Disbursed share (% or — when disbursable is 0) + disbursed total in VND.
    • Public invoice/receipt evidence count (evidence_count).
    • Unexplained transaction badge (0 chưa giải trình or count with incoming/outgoing breakdown).
    • Direct link to /campaigns/[slug]/statement and conditional #bao-cao-tong-ket anchor (only rendered when publishedImpactReport is mounted).
    • Zero PII, zero raw account numbers, fail-closed on non-public campaign previews.

2. Milestone Evidence Timeline & Owner-Only Disbursement Milestone Linking

  • Extended 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=out on public campaigns.
  • Extended /me/campaigns/[id]/disbursements (page.tsx, actions.ts, lib/statement.ts):
    • Optional same-campaign milestone picker in ExplainForm forwarding p_milestone_id to give.record_disbursement (strictly refused on refunds).
    • Added owner-only linkDisbursementMilestone action calling give.set_disbursement_milestone on explained non-refund disbursements, with milestone badge & relink/unlink control in Explanation.
    • DB (DOS.Me): give.campaign_members, single-use invite links & owner-only money boundary for #253 #264 money boundary preserved: /me/campaigns/[id]/disbursements page and actions strictly verify campaign.organizer_id === session.user.id before touching dbService(); co-organizer editors never access disbursements.

3. Closing Impact Reports (/me/campaigns/[id], /campaigns/[slug], /u/[handle])

  • Added saveImpactReport (apps/web/src/app/me/campaigns/[id]/impact-report-actions.ts) using caller JWT (dbAs(session.accessToken), never dbService()) to call give.upsert_campaign_impact_report — allowed for owning organizer or accepted co-organizer editor (#264 narrative scope) only when status is closed, succeeded, or settling.
  • Added ImpactReportSection (apps/web/src/app/me/campaigns/[id]/ImpactReportSection.tsx) inside /me/campaigns/[id]:
    • Safe Markdown preview (reusing <Markdown>, raw HTML disabled, images disallowed), up to 10 key impact highlights, draft vs. publish buttons with irreversible first-time publish confirmation (SubmitButton confirm support in components/forms.tsx), no revert-to-draft once published, and read-only view for non-editable statuses (failed, suspended, cancelled).
    • Updated co-organizer scope copy in /me/campaigns/[id]/page.tsx and TeamTab.tsx.
  • Added ClosingImpactReport (apps/web/src/components/campaign/ClosingImpactReport.tsx) on /campaigns/[slug] with #bao-cao-tong-ket anchor & tab navigation (only when published_at IS NOT NULL).
  • Added published impact report badge on /u/[handle] header (N báo cáo tổng kết) and CampaignCard (Có báo cáo tổng kết) via chunked batch lookup (listPublishedImpactReportCampaignIds).

Verification

  • pnpm format:check — PASS
  • pnpm lint — PASS
  • pnpm typecheck — PASS
  • pnpm test — PASS (191/191 files, 2,758/2,758 tests)
  • pnpm build — PASS
  • Fresh-context self-review (f35735e9) — 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

  • 🚀 New feature
  • 🐛 Bugfix
  • 🧹 Refactor
  • ⚡ Performance
  • 📚 Documentation
  • ⚙️ CI / Configuration

🔍 Changes Walkthrough

File Summary of Changes
apps/web/src/app/campaigns/[slug]/page.tsx Integrates TransparencySummaryBox and ClosingImpactReport into the public campaign view. Fetches transparency data and impact reports via Promise.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.ts Adds tests verifying that transparency summaries and impact reports render correctly on public campaigns, are hidden on drafts, and that raw HTML is sanitized from Markdown content.
apps/web/src/app/me/campaigns/[id]/ImpactReportSection.tsx New client component for the impact report editor. Handles draft/publish states, Markdown preview toggling, and dynamic highlight rows (capped at 10). Includes read-only mode for non-editable campaign statuses.
apps/web/src/app/me/campaigns/[id]/ImpactReportSection.test.ts Tests for the impact report editor UI, including Markdown preview behavior, highlight row limits, and confirmation dialogs for publishing.
apps/web/src/app/me/campaigns/[id]/impact-report-actions.ts New server action saveImpactReport. 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.ts Tests for saveImpactReport covering authorization (owner vs. editor vs. outsider), status validation, and error handling for already-published reports.
apps/web/src/app/me/campaigns/[id]/disbursements/actions.ts Adds linkDisbursementMilestone server action to associate disbursements with milestones. Updates explainDisbursement to accept and pass milestone_id. Enforces owner-only access for milestone linking.
apps/web/src/app/me/campaigns/[id]/disbursements/actions.test.ts Tests for milestone linking/unlinking, including validation that refunds cannot be linked to milestones and that non-owners are refused.
apps/web/src/app/me/campaigns/[id]/disbursements/page.tsx Updates the disbursements UI to include milestone selection dropdowns in both the "explain" form and the "already explained" view. Displays milestone badges on disbursement explanations.
apps/web/src/app/me/campaigns/[id]/TeamTab.tsx Updates the co-organizer permissions description to include "writing impact reports" in the list of allowed narrative actions.

📊 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
Loading

@JOY JOY (JOY) added line:campaigns Product line: campaigns po:agy Owned by Antigravity PO (mutual-exclusion parallel PO label) labels Nov 22, 2026

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Code review skipped — your organization has no extra usage available to pay for this review.

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.

@vercel

vercel Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
give Ready Ready Preview Nov 22, 2026 2:45pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 22, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f91e66af-ee0a-47a0-951f-703014fd1754

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

dos[bot]
dos Bot approved these changes Nov 22, 2026

@dos dos Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⏱️ 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.

@JOY

Copy link
Copy Markdown
Contributor Author

PO acceptance: merge at 41d69a5

Independent PO flagship security & correctness review (04b162e7-c7ce-417f-bc66-60471d56b8a9): APPROVE (0 P0/P1/P2 findings).

@JOY
JOY (JOY) merged commit d194a8f into dev Nov 22, 2026
6 checks passed
@JOY
JOY (JOY) deleted the antigravity/give-314-transparency-moat branch November 22, 2026 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

line:campaigns Product line: campaigns po:agy Owned by Antigravity PO (mutual-exclusion parallel PO label)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant