Skip to content

[invite] Send the inviter's audit score to the invite email#456

Merged
NiveditJain merged 6 commits into
mainfrom
feat/update-dashboard-endpoint
Jun 24, 2026
Merged

[invite] Send the inviter's audit score to the invite email#456
NiveditJain merged 6 commits into
mainfrom
feat/update-dashboard-endpoint

Conversation

@SiddarthAA

@SiddarthAA SiddarthAA commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Summary

The invite-a-friend email now shows the inviter's audit score. This is the dashboard half of a two-repo change — it computes the score and sends it to the api-server, which renders it (companion PR below). It also bundles two /audit polish items that landed on this branch.

Changes (dashboard)

Invite score — the cross-repo feature

  • sendInvites() takes an optional score and forwards it as { to, score }.
  • POST /api/audit/invite reads the browser-supplied score and clamps it to 0–100 (rounded; non-numeric dropped) before forwarding upstream.
  • AuditDashboard → ComeBackBetterSection → InviteDialog pass the score into the POST. The prop is optional end-to-end, so it degrades to score-free copy if absent.

Also in this PR

  • Rewrote the share templates — 10 X + 10 LinkedIn, leading on the score and archetype and ending on the npx CTA + handle (@failproofai / @Failproof AI). No URLs in the copy (a bare link would render a preview card and swallow the pasted audit-card image). Deterministic seed selection + the clipboard paste hint are unchanged.
  • Enlarged the audit poster's four corner labels so they read clearly at share size — applies to both the dashboard render and the downloaded PNG.

Testing

  • tsc --noEmit and eslint clean.
  • 1889 tests pass (103 files), including new sendInvites body-shape tests and POST /api/audit/invite score-coercion/clamping tests.

Companion PR

platform (api-server) — renders the score: https://github.com/FailproofAI/platform/pull/418

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Invite emails can now include an inviter audit score (clamped to 0–100 when available), and share templates were refreshed to surface score/archetype with a clearer npx -y failproofai audit call to action (no URLs in the copy).
    • Enlarged the audit poster’s corner labels for better readability in both the dashboard and downloaded PNG.
  • Bug Fixes
    • Invite/share score handling now defensively validates, rounds, and clamps to 0–100 before forwarding (and remains emoji-free with consistent score/archetype copy).
    • Reduced noisy, benign deployment-skew log repetition when starting, without affecting other output.

SiddarthAA and others added 3 commits June 23, 2026 19:22
Thread the current audit score from the dashboard through to the api-server
so the invite email can show "my agent scored a N/100".

- sendInvites() takes an optional score and forwards it as { to, score }
- /api/audit/invite reads the browser-supplied score and clamps it to 0-100
  (rounded; non-numeric dropped) before forwarding upstream
- AuditDashboard -> ComeBackBetterSection -> InviteDialog pass the score
  down to the POST; the prop is optional end-to-end so it degrades to
  score-free copy when absent
- tests: sendInvites body shape + route score coercion/clamping

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Replace the 10 X + 10 LinkedIn templates with new copy that leads on the
score and archetype and ends on the npx CTA plus handle (npx -y failproofai
audit, @FailproofAI on X / @FailProof AI on LinkedIn).

No URLs in the copy: a bare link would render a preview card and swallow the
pasted audit-card image. The clipboard paste hint still appends via
pickTemplate, and the deterministic seed-based selection is unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Bump the header wordmark/meta and footer brand/CTA font sizes so the poster
corners read clearly at share size, with the bottom bar sized consistently
with the header. Applies to both the dashboard render and the downloaded PNG.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2fa8c352-9c91-4094-8c1a-e2ab01c50d8a

📥 Commits

Reviewing files that changed from the base of the PR and between f7b4c13 and d4b6af0.

📒 Files selected for processing (4)
  • CHANGELOG.md
  • __tests__/scripts/skew-log-filter.test.ts
  • scripts/launch.ts
  • scripts/skew-log-filter.ts
✅ Files skipped from review due to trivial changes (2)
  • scripts/skew-log-filter.ts
  • CHANGELOG.md

📝 Walkthrough

Walkthrough

This PR threads an optional audit score from the dashboard into the invite submission flow, normalizes and forwards it through the API layers, rewrites share-template copy to emphasize score/archetype with deterministic CLI CTAs and no URLs, enlarges audit poster label typography for readability, and adds server log filtering to suppress benign Next.js deployment-skew errors during startup.

Changes

Audit sharing updates

Layer / File(s) Summary
Thread score through UI and API layers
app/audit/_components/audit-dashboard.tsx, app/audit/_components/come-back-better-section.tsx, app/audit/_components/invite-dialog.tsx, app/api/audit/invite/route.ts, lib/auth/api-server-client.ts
The dashboard score is passed through component props into InviteDialog and included in the API request body. The invite route accepts, validates, clamps to 0–100, and rounds the score before forwarding it through sendInvites, which conditionally includes it in the /v0/invite POST body.
Test score validation and forwarding
__tests__/api/audit-invite-route.test.ts, __tests__/lib/api-server-client.test.ts
Tests verify that in-range scores pass through unchanged, out-of-range values are clamped and fractional values rounded, invalid/missing scores become undefined, and sendInvites conditionally includes the score in request bodies.
Rewrite share templates for deterministic structure
app/audit/_components/share-templates.ts, __tests__/audit/share-templates.test.ts
Share templates now lead with score/archetype and end with channel-specific CLI CTAs, with no bare URLs or emojis. Tests enforce per-template CTA endings, URL absence, archetype-or-score presence, and emoji-free copy across all channels.
Enlarge poster typography and document updates
app/audit/audit-styles.css, CHANGELOG.md
Audit poster header and footer font sizes are increased for readability in both dashboard renders and exported PNGs, with mobile responsive adjustments. Changelog documents the score forwarding feature, template rewrites, and poster label enlargements.

Server launch log filtering

Layer / File(s) Summary
Implement and integrate deployment-skew error filter
scripts/skew-log-filter.ts, __tests__/scripts/skew-log-filter.test.ts, scripts/launch.ts, CHANGELOG.md
A new stateful makeSkewLogFilter utility suppresses the multi-line "Failed to find Server Action" Next.js error block via readline handlers during start mode, while preserving all other output and leaving dev mode unchanged. Tests verify correct block suppression, passthrough of unrelated lines, and proper handling of multiple block occurrences.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~28 minutes

Possibly related PRs

  • FailproofAI/failproofai#435: Prior audit-poster restructure PR that shares the same /api/audit/invite proxy and share-templates code path extended here with clamped inviter score forwarding and updated template/test expectations.

Poem

🐇 I tucked a score inside the note,
Then sent it down the invite route so bright.
No links, no emojis—clean and tight,
Just archetypes and CLI delight.
Big poster corners now proudly sing,
As logs stay quiet, clean, and well-scrubbed thing!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly describes the main feature: sending the inviter's audit score to the invite email, which is the primary cross-repo change highlighted in the PR description.
Description check ✅ Passed The description provides a clear summary, details the dashboard changes, explains the score clamping logic, documents the share template rewrites and poster label enlargements, reports comprehensive testing results, and references the companion PR.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

__tests__/scripts/skew-log-filter.test.ts

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

scripts/launch.ts

ESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.

scripts/skew-log-filter.ts

ESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.


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

Comment @coderabbitai help to get the list of available commands.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@__tests__/audit/share-templates.test.ts`:
- Around line 19-23: The assertion in the test for template output uses
toContain to check for the "npx -y failproofai audit" CTA string, but this only
verifies the string exists somewhere in the output, not that it appears at the
end as the test title implies. Replace the toContain assertion with toMatch
using a regex pattern that anchors to the end of the string (using the $
anchor), or use toEndWith if available in your testing framework, to ensure the
CTA truly terminates the template output and prevent regressions where the CTA
might appear mid-body instead of at the end.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 71870348-5971-45a0-9ad5-6d11cc8b2369

📥 Commits

Reviewing files that changed from the base of the PR and between 2349fbe and 01bc277.

📒 Files selected for processing (11)
  • CHANGELOG.md
  • __tests__/api/audit-invite-route.test.ts
  • __tests__/audit/share-templates.test.ts
  • __tests__/lib/api-server-client.test.ts
  • app/api/audit/invite/route.ts
  • app/audit/_components/audit-dashboard.tsx
  • app/audit/_components/come-back-better-section.tsx
  • app/audit/_components/invite-dialog.tsx
  • app/audit/_components/share-templates.ts
  • app/audit/audit-styles.css
  • lib/auth/api-server-client.ts

Comment thread __tests__/audit/share-templates.test.ts
SiddarthAA and others added 2 commits June 24, 2026 01:23
Addresses CodeRabbit review on #456: the 'ends on the npx CTA' test used
toContain (presence only); switch to an end-anchored regex so a CTA that
drifts mid-body is caught.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…n the server log

A browser tab left open across a dashboard rebuild/upgrade keeps POSTing a
stale Server Action ID (IDs are hashed per build). Next handles it gracefully
on the client — a 404 with `x-nextjs-action-not-found: 1`, which the client
recovers from — but the standalone server still throws + logs a 3-line
"Failed to find Server Action <hash>" block to stderr per stale request, which
floods the failproofai terminal.

The earlier attempt to fix this client-side was the wrong layer (a browser
handler can't suppress a server-process log). This filters at the only place
failproofai controls that output: the launcher. In `start` mode it now pipes
the spawned Next server's stdout/stderr through a stateful per-stream filter
that drops exactly the skew block and passes everything else through verbatim
(color preserved via FORCE_COLOR). `dev` keeps `stdio: "inherit"` so Next's
interactive compile output is untouched.

Verified against the real standalone build: 3 stale-action POSTs produced 0
leaked error lines while the banner/startup logs (and color) came through.
Unit-tested incl. the case where a genuine error following a skew block is NOT
swallowed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@NiveditJain

Copy link
Copy Markdown
Member

lgtm

@NiveditJain NiveditJain merged commit 4bd01a2 into main Jun 24, 2026
12 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants