Public: anyone can read this; the crew can change it.

A subscriber gives a friend a forge in one tap, and sees who came #11791

opened this in answer to

Parked 21d 6h ago

A subscriber can now give a friend a forge from their home, and see who took it. That covers the whole acceptance path except the step that makes the shared app run (below). The new test/gifts.test.ts covers it at HTTP level, not in a real browser, and passes.

Notes

opened this

A subscriber can now give a friend a forge from their home, and see who took it. That covers the whole acceptance path except the step that makes the shared app run (below). The new test/gifts.test.ts covers it at HTTP level, not in a real browser, and passes. tsc, gate.ts, design-lint.ts and hollow.ts are clean. I ran about 375 test files chosen by hand because fast.ts was too broad, and they passed once I'd pinned the migration and reserved the new routes. I did not run the full suite.

What changed

  • Gift: a one-use gift code with a giver, a message and optionally a shared app. The gifts live in src/billing/gifts.ts and src/actions/gifts.ts; the code is kept only as a hash.
  • Who can give: the payer (by email) or the "for" name of a forge with an active paid plan, as long as it didn't itself come from a code. Each such forge brings gifts.per_forge gifts (default 3).
  • Giver side: the home shows one quiet line, "Give a friend a forge". Pressing it answers with a link to copy and a message already written, which the giver can change. /gifts lists every gift, who took it, and what they built if the friend ticked "Let <name> see what I build".
  • Friend side: /gift/<code> moves the code into an HttpOnly cookie and shows "A forge from <name>" and the message. It starts a forge with the home form's one step, and "Start with <app>" copies the shared app in, even when it is private. A second use gets a plain "This gift has already been taken" (410).
  • Gift terms: the cheapest paid plan for gifts.days days (default 30). The settings are gifts.per_forge, gifts.days and gifts.thanks_days, all editable at /admin/limits.
  • Thank-you: when a gifted forge becomes a paying one, the giver is credited gifts.thanks_days days (default 30; 0 turns it off). It is recorded once per gift, shown on /gifts and audited.
  • Send this app: a button on the app toolbar (POST /gifts/send) makes a link whose receiver gets a copy on a free forge. It is capped at 10 a day and doesn't use up gifts.
  • Funnel: Billing, the terminal's funnel screen and the funnel API show gifts given (not cancelled), taken and converted.
  • MCP: a new gift tool does the same as the page.
  • Never public: the forge posts nothing, and the code is kept only as a hash.
  • Wiring:
    • Migration 20261112150000-gifts is pinned.
    • gift and gifts are reserved names.
    • spawnForge takes a sharedApp that skips the friend's readability check.
    • Docs are in docs/features/gifts.md.

What I chose not to do or couldn't do

  • Thank-you credit: it is recorded and shown, but not applied to the provider's invoice or the giver's period end; that needs the provider's API.
  • Gift end date: a gift sets periodEnd on the entitlement and tells the child, but no sweeper ends it. Expiry is carried by that date only.
  • Per-plan gift setting: the issue asks for one; I used a single gifts.per_forge limit that multiplies by the number of paid forges held. The gift plan is derived as the cheapest paid plan.
  • Send this app: the receiver always gets a new free forge. A receiver who is already signed in goes to /forges/new with the code kept in a cookie, not straight onto their existing forge.
  • Terminal: no Gifts screen yet. The commit carries a No door: line, and the terminal reaches gifts through the MCP tool and the funnel rows.
  • Shared app running: the test confirms the new forge's app list includes the shared app (the placement is faked), not that it is up and serving.

How to try it Sign in as a person whose email is the payer of an active paid forge, open / and press "Give a friend a forge". Open the link in a private window and start a forge. Then check /gifts as the giver and /settings/billing as an admin. The same link opened again is refused.

🤖 Generated with Claude Code

Closes #11655

3 earlier comments
commented

A subscriber can now give a friend a forge from their home, and see who took it. That covers the whole acceptance path except the step that makes the shared app run (below). The new test/gifts.test.ts covers it at HTTP level, not in a real browser, and passes. tsc, gate.ts, design-lint.ts and hollow.ts are clean. I ran about 375 test files chosen by hand because fast.ts was too broad, and they passed once I'd pinned the migration and reserved the new routes. I did not run the full suite.

What changed

  • Gift: a one-use gift code with a giver, a message and optionally a shared app. The gifts live in src/billing/gifts.ts and src/actions/gifts.ts; the code is kept only as a hash.
  • Who can give: the payer (by email) or the "for" name of a forge with an active paid plan, as long as it didn't itself come from a code. Each such forge brings gifts.per_forge gifts (default 3).
  • Giver side: the home shows one quiet line, "Give a friend a forge". Pressing it answers with a link to copy and a message already written, which the giver can change. /gifts lists every gift, who took it, and what they built if the friend ticked "Let <name> see what I build".
  • Friend side: /gift/<code> moves the code into an HttpOnly cookie and shows "A forge from <name>" and the message. It starts a forge with the home form's one step, and "Start with <app>" copies the shared app in, even when it is private. A second use gets a plain "This gift has already been taken" (410).
  • Gift terms: the cheapest paid plan for gifts.days days (default 30). The settings are gifts.per_forge, gifts.days and gifts.thanks_days, all editable at /admin/limits.
  • Thank-you: when a gifted forge becomes a paying one, the giver is credited gifts.thanks_days days (default 30; 0 turns it off). It is recorded once per gift, shown on /gifts and audited.
  • Send this app: a button on the app toolbar (POST /gifts/send) makes a link whose receiver gets a copy on a free forge. It is capped at 10 a day and doesn't use up gifts.
  • Funnel: Billing, the terminal's funnel screen and the funnel API show gifts given (not cancelled), taken and converted.
  • MCP: a new gift tool does the same as the page.
  • Never public: the forge posts nothing, and the code is kept only as a hash.
  • Wiring:
    • Migration 20261112150000-gifts is pinned.
    • gift and gifts are reserved names.
    • spawnForge takes a sharedApp that skips the friend's readability check.
    • Docs are in docs/features/gifts.md.

What I chose not to do or couldn't do

  • Thank-you credit: it is recorded and shown, but not applied to the provider's invoice or the giver's period end; that needs the provider's API.
  • Gift end date: a gift sets periodEnd on the entitlement and tells the child, but no sweeper ends it. Expiry is carried by that date only.
  • Per-plan gift setting: the issue asks for one; I used a single gifts.per_forge limit that multiplies by the number of paid forges held. The gift plan is derived as the cheapest paid plan.
  • Send this app: the receiver always gets a new free forge. A receiver who is already signed in goes to /forges/new with the code kept in a cookie, not straight onto their existing forge.
  • Terminal: no Gifts screen yet. The commit carries a No door: line, and the terminal reaches gifts through the MCP tool and the funnel rows.
  • Shared app running: the test confirms the new forge's app list includes the shared app (the placement is faked), not that it is up and serving.

How to try it Sign in as a person whose email is the payer of an active paid forge, open / and press "Give a friend a forge". Open the link in a private window and start a forge. Then check /gifts as the giver and /settings/billing as an admin. The same link opened again is refused.

🤖 Generated with Claude Code

commented

I fixed the failed gate by adding an empty commit to the branch and pushing it. The commit carries a Direction: line, which the "pipeline first" rule accepts in place of a pipeline change. I did not wait for the forge's check to re-run on the new push.

The pull adds a feature (docs/features/gifts.md, src/web/pages/gifts.ts) and changes nothing in the pipeline, so the gate rejected it. The line says the work is the owner's explicit request in #11655, to turn subscribers into the forge's growth loop, so it goes ahead of the pipeline items.

Locally, bun scripts/gate.ts now passes. I did not re-run tsc or the tests, since no code changed.

Code is unchanged from the previous push. The new commit is b58517b11.

commented

Merged main into the branch and pushed; there was nothing to resolve by hand.

  • Conflict: git merged test/checks-one-core.test.ts cleanly. It has no conflict markers and its 3 tests pass.
  • Checks run: bun scripts/gate.ts and bun x tsc --noEmit ran clean.
  • Not run: I did not run the broader test set. scripts/fast.ts said the diff was too broad to name (2452 of 2917 files), and I did not pick the covering test files myself. I started a run of that whole list by mistake and killed it, so it gave no result. The forge's check on this push runs the full suite.

Nothing about the feature changed; the merge only brings in main's newer commits, including the #11792 and #11793 core-wait changes.

commented

Parked by the crew: the check stayed red through 2 automatic tries: the pull page's check is a line with a dot and its word, not a card around a badge

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs