← Back to Pull requests

Add comments with visibility to submitted leads #4607

Closed
unknown closed this pull request without merging on Oct 03, 2026 04:28 UTC
View on GitHub
unknown unknown commented on Oct 02, 2026 19:11 UTC
Author

Summary

Adds comments to submitted leads, with a visibility setting per comment. This follows the Figma design.

  • Workspace: the lead sheet has "Lead Details" and "Comments" tabs. A comment is "Workspace only" (the default) or "Workspace and partner". Comments the partner can see have an orange card and a "Partner visible" badge. Comments from the partner have a "Partner" badge. Users can edit or delete only their own comments.

  • Partner: the partner lead sheet has the same tabs. The partner sees only the comments that are visible to them, and can post comments. Workspace comments show the program badge.

  • Emails: a partner-visible workspace comment emails the partner users. A partner comment emails the workspace users. Each comment queues a QStash job with a 3 minute delay, as messages do. Comments posted less than 3 minutes apart go out in one email.
  • Screenshots

  • Workspace comments. Comments the partner can see are orange. Comments from the partner have a "Partner" badge.
  • <img width="800" alt="workspace-comments" src="https://github.com/user-attachments/assets/246df85d-5870-4603-bf9c-c0a49f90be69" />

  • Visibility selector. "Workspace and partner" makes the input orange and changes the placeholder.
  • <img width="800" alt="workspace-visibility" src="https://github.com/user-attachments/assets/dbb006e8-587e-4bdd-acce-5b01ff3d305d" />

  • Partner view. The partner sees the same lead without the "Workspace only" comment.
  • <img width="800" alt="partner-comments" src="https://github.com/user-attachments/assets/5eb8662b-b0d4-4d43-ad31-e4c276385a98" />

  • Email to the partner. Two comments posted less than 3 minutes apart go out in one email.
  • <img width="400" alt="email-partner" src="https://github.com/user-attachments/assets/aa0dc258-b538-41b8-96d1-39e1b5e2368b" />

  • Email to the workspace. The workspace gets this email when the partner posts a comment.
  • <img width="400" alt="email-workspace" src="https://github.com/user-attachments/assets/70415477-dbe6-4aa2-b63f-e1707530a1c9" />

    Schema

    New SubmittedLeadComment model. partnerVisible holds the visibility. partnerId is set only when the partner wrote the comment, like Message.senderPartnerId. notifiedAt records which comments the notification jobs have handled, so a job sends every comment that is not sent yet. This needs a prisma db push.

    Decisions to review

  • The emails use the existing newMessageFromProgram and newMessageFromPartner notification settings. There are no new settings. Like message emails, the workspace email goes to every role with the setting on, including viewers and billing users.

  • Partners see the name of the workspace user who wrote a comment, in the sheet and in the email, as the design shows. The activity log in the same sheet shows only the program name.

  • Partners cannot edit or delete comments. The partner frames show no menu.
  • How to test

    1. In apps/web, start the local services with docker compose up -d. Then run pnpm prisma:push to add the new table.
    2. From the repo root, run pnpm dev. This also rebuilds @dub/ui, which has a change for the input placeholder.
    3. Create a lead. Sign in to http://partners.localhost:8888 as a partner of the Acme program. Go to Submitted Leads and click Submit lead.
    4. Test the workspace side. Sign in to http://localhost:8888 as a member of the acme workspace. Open Submitted Leads, open the lead, and click the Comments tab.
    - Post one comment with Workspace only and one with Workspace and partner. The second one is orange.
    - Edit and delete your own comment from the ⋯ menu.
    5. Test the partner side. In the partner portal, open the same lead and click Comments.
    - You see only the Workspace and partner comment.
    - Post a reply. In the workspace, it shows with a Partner badge.
    6. Test the emails. Without ngrok, QStash cannot reach your local app, so call the cron route yourself. In local dev, the route does not check the QStash signature.
    - In the browser Network tab, open the request to /submitted-leads/<lead id>/comments. Copy the id and createdAt of the newest comment.
    - Run the command below. Use notify-partner for a Workspace and partner comment, and notify-program for a partner comment.
    - Open MailHog at http://localhost:8025 to see the email.

       curl -X POST http://localhost:8888/api/cron/submitted-leads/comments/notify-partner \
         -H "content-type: application/json" \
         -d '{"leadId":"<lead id>","lastCommentId":"<comment id>","lastCommentCreatedAt":"<comment createdAt>"}'
       

    7. To see the email templates with sample data, run pnpm dev in packages/email and open http://localhost:3333.

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    Summary by CodeRabbit

    New Features
    Added a Comments tab to submitted-lead details in workspace and partner views, with a comment-count badge and comment history.
    Workspace users can post comments, choose whether partners can see them, and edit or delete their own comments. Partners can post comments visible to the workspace.
    Added email notifications for new comments, with comment details and links back to the submitted lead, sent to eligible recipients.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: Joker666 Review duration: 557m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #4607"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.5% · Safe to merge
    20.5%
    Repository