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

A lapsed forge's pay-again link opens checkout with its plan already chosen and says how many days of grace remain #16076

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

The lapsed-forge page now names the plan checkout opens with, says how many grace days are left, and says when the link has expired. The new test file and the existing pay-again and lapse tests pass (19 tests). tsc, gate and design-lint are clean too.

Notes

shipped production is serving it deploy 3fede26

opened this

The lapsed-forge page now names the plan checkout opens with, says how many grace days are left, and says when the link has expired. The new test file and the existing pay-again and lapse tests pass (19 tests). tsc, gate and design-lint are clean too. I didn't run the full suite, and I haven't loaded the page in a running app.

  • Plan: it was already chosen. payAgainPlan and startPayAgain pick the forge's own paid plan, or the last paid one, so I left them alone and added no new test for them. The page now also says "Paying again opens checkout for Medium, $49 a month."
  • Grace days: this is new. graceDaysLeft and payAgainWords in src/billing/lapse_words.ts build the sentences. The days come from lapseRule(...).graceDays and the forge's lapse state, shown as "2 days of your 7-day grace remain." Once the forge sleeps, the page says "Your grace period has ended."
  • Expired link: once the data's keep-until date has passed, the page says "This link has expired" and tells the payer to ask the operator. It still shows the Pay again button. I did not block payment, because that would change behaviour.
  • Page: src/web/pages/lapsed.ts renders those lines above the export sentence. Webhook handling is untouched.
  • Files: the issue named src/billing/pay_again.ts, which I didn't change. The new tests are in test/billing-pay-again-plan.test.ts.

To try it, open a lapsed forge's address in a browser.

The pre-push hook wanted a "Try:" commit, so the second commit is empty and carries that line.

[{"go":"a lapsed forge's address in a browser","look":"the lines above the export sentence","expect":"the plan and price, and either days of grace left or 'Your grace period has ended.'"}]

🤖 Generated with Claude Code

Closes #16047

7 earlier comments · 2 events
commented

The lapsed-forge page now names the plan checkout opens with, says how many grace days are left, and says when the link has expired. The new test file and the existing pay-again and lapse tests pass (19 tests). tsc, gate and design-lint are clean too. I didn't run the full suite, and I haven't loaded the page in a running app.

  • Plan: it was already chosen. payAgainPlan and startPayAgain pick the forge's own paid plan, or the last paid one, so I left them alone and added no new test for them. The page now also says "Paying again opens checkout for Medium, $49 a month."
  • Grace days: this is new. graceDaysLeft and payAgainWords in src/billing/lapse_words.ts build the sentences. The days come from lapseRule(...).graceDays and the forge's lapse state, shown as "2 days of your 7-day grace remain." Once the forge sleeps, the page says "Your grace period has ended."
  • Expired link: once the data's keep-until date has passed, the page says "This link has expired" and tells the payer to ask the operator. It still shows the Pay again button. I did not block payment, because that would change behaviour.
  • Page: src/web/pages/lapsed.ts renders those lines above the export sentence. Webhook handling is untouched.
  • Files: the issue named src/billing/pay_again.ts, which I didn't change. The new tests are in test/billing-pay-again-plan.test.ts.

To try it, open a lapsed forge's address in a browser.

The pre-push hook wanted a "Try:" commit, so the second commit is empty and carries that line.

[{"go":"a lapsed forge's address in a browser","look":"the lines above the export sentence","expect":"the plan and price, and either days of grace left or 'Your grace period has ended.'"}]

🤖 Generated with Claude Code

commented

The gate's "both doors" rule failed because the pull edited the lapsed page but not the terminal. The terminal's lapsed screen, src/tui/screens/lapsed.ts, now shows the same lines as the page, so that rule should pass on the new push.

  • Lines shown: each lapsed forge there gets the plan and price line, the grace-days line, and the expired-link line, from the same payAgainWords.
  • Order: they come after the existing sentence and the "Your data is kept until…" line. My first version put them in between, which broke test/billing-lapsed-sleep.test.ts, and I had already pushed it. I fixed the order and pushed again.
  • Tests: test/billing-lapsed-sleep.test.ts and test/billing-pay-again-plan.test.ts pass (6 tests), and tsc is clean. I did not run the full fast tier, because fast.ts expanded the diff to 2,308 files (an estimated 195 minutes) and I ran the covering tests directly. That background run may still be going in this session. I couldn't stop it, and its output doesn't matter.
  • Commit messages: the first push carries a Looks: src/web/pages/lapsed.ts line, which answers the gate's look-pages note. The latest carries a No door: line for the reordering.

I haven't seen the forge's check result on the new push yet.

🤖 Generated with Claude Code

commented

<!-- look-pages 02b944092804 --> Look pages for 02b9440, from the gate:

  • look pages (none): this pull changes src/web/pages/lapsed.ts but the forge could not trace the route of /settings/security/controls (an inline or wrapped handler), so it could not infer a page; the reviewer decides. A "Looks: <path>" line naming the nearest page, or a "No look: <why>" line (10+ characters), says it
commented

A lapsed forge's pay-again link now opens checkout with its plan already chosen, and the page says how many days of grace remain. An expired link is named as expired. This push adds no code. It only answers the gate's look-pages note.

The gate could not infer a page for src/web/pages/lapsed.ts, so I added an empty commit with a No look: line. That is the form AGENTS.md asks for. It says the lapsed page is reached only from a lapsed forge's address, and no page in app.looks shows it. The nearest entry, /settings/security/controls, is a different page, so I did not name it with Looks:.

I ran bun scripts/gate.ts after the commit. Its only note is that src/billing/lapse_words.ts and src/web/pages/lapsed.ts have comment lines over 100 columns. The gate says the nightly rewrap fixes those on main, so I left them.

If you would rather have a real look picture of the lapsed page, someone would need to add a lapsed sample route to app.looks. I did not add one, because that is a new feature.

🤖 Generated with Claude Code

Changes requested — before the latest push

The grace-days line can never show on this page. lapsedResponse takes only Lapse state none (src/spawn/host.ts:646), so graceDaysLeft is always 0 and the page always says 'Your grace period has ended.' The issue asked for days left on the pay-again link of a lapsed forge, but the one live caller never reaches the grace branch. Fix first: decide where a forge in grace meets the pay-again link, show the days there, and test it through the page. Other changes: (1) the tests only call the word helpers. Add one test of lapsedResponse and one of the lapsed TUI screen that fail without the change (plan line, expired line, grace line). (2) Box 1 is met only by pre-existing code and no test pins it; the new test should show the checkout started by startPayAgain uses that plan. (3) Add the how-to to docs/features/lapsed-forge.md (not README). (4) Design: three muted lines under the empty-state say the same thing twice (the title already says asleep, and 'grace has ended' repeats it). Fold the plan into the action note and drop the 'grace has ended' sentence, and keep one sentence per fact (principle 1). (5) The expired-link line says 'may be gone' yet still offers Pay again; at least do not offer the button when the data is past keepUntil, or word it so a person is not charged blind. (6) payAgainWords takes four positional args and builds the sentences in lapse_words.ts, though they are page copy. The 100-column comments should be rewrapped. (7) Make the text-only (non-HTML) 402 carry the same lines for the same reason.

commented

The grace-days line now shows where a forge in grace is seen, which is the billing page and screen. It no longer sits on the wake page, where it could never show. The four test files that cover this change pass, as do tsc, gate.ts --fix and design-lint. I did not run the whole suite, and I did not load the page in a running app.

Grace days. A forge in grace is awake, so it never reaches the pay-again page. That page only ever sees billing none. I removed the dead line there and put the days into lapseNotice, which the billing page and the terminal billing screen already use. It now reads "6 days of grace remain, ending on 2026-03-08 UTC, and then your forge sleeps; …", and "1 day of grace remains" on the last day. test/lapse-words.test.ts pinned the old sentence, so I changed it and pass now explicitly. The old wording was wrong for the new feature, not the test.

Wake page (src/web/pages/lapsed.ts):

  • The plan sentence now sits inside the empty-state note, next to the "asleep" sentence. The three stacked muted lines are gone, and so is "Your grace period has ended."
  • Once keepUntil has passed, the page shows the expired sentence in place of the Pay again button, so nobody is charged blind. The text still tells the payer to ask the operator.
  • The plain-text 402 carries the same plan line, or the expired line.

Terminal (src/tui/screens/lapsed.ts):

  • Each row shows the plan line, or the expired line.
  • p on an expired row starts no checkout.

Tests (test/billing-pay-again-plan.test.ts):

  • lapsedResponse is tested in three cases: the plan line, the expired line without a button, and the plain-text answer.
  • The checkout started by startPayAgain is shown to use the plan named on the page.
  • lapsedForges is tested on the lapsed screen.
  • The grace-days line is tested through lapseNotice.

Docs. The how-to is in docs/features/lapsed-forge.md, with a new "Grace days" section.

Not done:

  • payAgainWords is gone, replaced by four one-argument sentence helpers in lapse_words.ts. I left them there instead of moving them into the page, because the page and the terminal screen share them, as they already share lapsedSentence and exportSentence.
  • POST /pay-again still accepts a press past keepUntil. Only the offer is removed, since refusing the POST changes behaviour.
  • The 100-column comments were rewrapped by gate.ts --fix, but the gate still prints a note naming lapse_words.ts and lapsed.ts, which the nightly rewrap handles.

The earlier No look: line stands: no page in app.looks shows the lapsed page.

[{"go":"a lapsed forge's address in a browser","look":"the note under 'This forge is asleep'","expect":"one sentence on why it sleeps plus 'Paying again opens checkout for <plan>, $<price> a month.', then the Pay again button"},{"go":"/settings/billing as an admin, for a forge in grace","look":"the muted lapse notice under the forge's row","expect":"'N days of grace remain, ending on <date> UTC' and the keep-until date"}]

🤖 Generated with Claude Code

commented

The lapse notice for a forge in grace now says how many days of grace remain, and the two billing tests that expected the old wording have been updated to match. That is the whole fix, and it's pushed.

  • Cause: the notice in the code now reads "Your payment lapsed: 7 days of grace remain, ending on 2026-11-30 UTC, and then your forge sleeps; its data is kept until 2026-12-30 UTC." The tests still expected "the grace period ends on …".
  • Tests changed: the test was wrong, not the code. The two regexes now match "N day(s) of grace remain, ending on <date> UTC". They are in test/billing-tui.test.ts (the terminal row) and test/billing.test.ts (the Billing page).
  • Run here: both billing files pass (25 tests) and bun x tsc --noEmit is clean.
  • HEAD sweep: I didn't change anything for the "HEAD on every GET route" failure. That test file passes when I run it alone here. In the check it ran in a shard of its own that also failed on billing. Because the billing files are the only red, I'm treating it as a knock-on of the Billing page assertion. If the check shows it red again, it needs its own look.
Changes requested — before the latest push

Changes needed, one round:

  1. (High, fix first) The expiry is only cosmetic. POST /pay-again still makes a checkout after keepUntil, so anyone who posts to it directly (or has the page open) pays for data that may be gone. Refuse it server-side with the same expired sentence, and test the POST. The terminal path (p) is guarded but the web mutation is not.
  2. Box 2: the days are not computed by lapse_rule (graceDaysLeft reads lapse.graceUntil) and are not shown on the pay-again page. The builder moved them to the billing notice because a forge in grace never meets that page. Compute them from lapseRule and say in the pull that the box is met there, or leave the box.
  3. Tests: the TUI expired row and the p-blocked-on-expired note are untested; the screen test only covers the non-expired row. Add them.
  4. Principle 1: the expired sentence repeats the keep-until day that the export line directly below already says.
  5. Direction: the owner put pipeline work before any feature; this is a feature pull, so say why it goes ahead of #6534 and the rest. Design: no hand-rolled markup, button stays a post form, works without JS. README untouched, how-to is in docs/features/lapsed-forge.md.
commented

A lapsed forge's pay-again link now opens checkout with the forge's plan already chosen. Once the data's keep-until day has passed, the link says it has expired and refuses to open checkout, both on the page and when posted to directly. The page and the terminal screen both say which plan checkout opens with ("Paying again opens checkout for Medium, $49 a month."). That plan is the forge's own paid plan, or else the last paid plan it had.

Review round (@sentinel):

  1. Expiry is enforced on the server. POST /pay-again now checks linkExpired (the same test that hides the button). Past the keep-until day it answers 410 with the expired sentence and makes no checkout. payAgainGate passes the lapse it already looked up into payAgainRoute (src/web/pages/lapsed.ts, src/spawn/host.ts).
  2. Grace days come from the lapse rule. graceDaysLeft and the day grace ends (graceEnds) moved to src/billing/lapse_rule.ts. They read lapseRule(db).graceDays, the billing.grace_days setting that /pricing states, instead of lapse.graceUntil. lapseNotice now takes the rule, and the billing page and screen pass it.
    • The box "The page shows grace days left, computed by lapse_rule" is met on the billing page and screen, not the pay-again page. A forge in grace is still awake, so it never shows the pay-again page; by the time it does, no grace is left to count.
  3. Tests added in test/billing-pay-again-plan.test.ts:
    • a post through payAgainGate gets 303 while the data is kept, and 410 with no checkout made once it has expired;
    • the terminal's expired row shows the expired line and no plan;
    • pressing p on an expired row shows the expired note and starts no checkout;
    • graceDaysLeft follows the rule's setting.
  4. The expired sentence no longer repeats the day. It now reads "This link has expired. Ask this forge's operator at … before paying." The export line below it already names the keep-until day.
  5. Why this goes ahead of #6534: I haven't been given a reason to put it ahead of the pipeline work. The pull already existed when the review came in, and I only addressed the review. It touches only the billing read path and the pay-again post, with no webhook handling and no pipeline code, so it doesn't compete with #6534 for the same files. If that ordering rule means this should wait, park it; nothing depends on it.

Changed tests: in test/lapse-words.test.ts the calls to lapseNotice now pass a rule (graceDays: 7, the value they already used). Their assertions are unchanged.

Checks: gate, tsc --noEmit and design-lint pass. The billing, pay-again, lapse-words, lapsed-sleep and lifecycle test files pass: 52 tests across 7 files. The gate also flagged that the new test's press helper looks like the one in test/pay-again.test.ts. I kept a local copy so this test file stays self-contained.

[{"go":"/settings/billing","look":"the lapse notice on a forge in grace","expect":"it says how many days of grace remain and the day they end, counted from the grace-days setting /pricing states"},{"go":"a lapsed forge's address past its keep-until day","look":"the button area","expect":"'This link has expired. Ask this forge's operator at … before paying.' with no button; the export line below names the day; a POST to /pay-again answers 410 with the same sentence"}]

🤖 Generated with Claude Code

commented

When a forge's payment has lapsed, its pay-again page and terminal screen now name the plan checkout will open with, for example "Paying again opens checkout for Medium, $49 a month." Once the keep-until day has passed they say the link has expired and offer no button (#16047).

What changed

  • Lapsed page (src/web/pages/lapsed.ts): the page and its plain-text answer show the plan line while the data is still kept. After the keep-until day they show "This link has expired" and no pay-again form.
  • Pay-again post (src/spawn/host.ts payAgainGate): a POST after the keep-until day is refused with status 410 and the same sentence, and no checkout is made. Before, an old link could still open a checkout for data that might already be gone.
  • Terminal lapsed screen (src/tui/screens/lapsed.ts): each row keeps the lapse sentence and export line first, then either the plan line or the expired line. Pressing p on an expired forge says so and starts no checkout.
  • Grace days (src/billing/lapse_rule.ts graceDaysLeft, src/billing/lapse_words.ts): the lapse notice says how many grace days remain and the day grace ends. The count comes from the lapse rule's setting, not a stored date. The keep-until day was printed twice and now appears once.

test/billing-pay-again-plan.test.ts covers all of the above. The lapsed-screen test now presses typed KeyEvents and draws into a real Surface with the real theme, as test/feed-filters.test.ts does, instead of using as never casts.

Not done: the gate notes that this test's press helper looks like the one in test/pay-again.test.ts. That is a note, not a failure, and the two build different requests (this one posts to a forge's own address), so I kept them separate.

To try it: visit a lapsed forge's address on the preview while its data is still kept, and you should see the plan line and a "Pay again" button. For a forge lapsed past its keep-until day, the page says the link has expired, and a POST to /pay-again returns 410. Run bun test test/billing-pay-again-plan.test.ts for the tests.

bun scripts/gate.ts, bun x tsc --noEmit and that test file pass locally.

🤖 Generated with Claude Code

Approved

Earlier asks, all met at this head: (1) POST /pay-again now answers 410 with the expired sentence and makes no checkout past keepUntil. It uses the same linkExpired check that hides the button, and a test goes through payAgainGate. (2) The grace days are counted by lapseRule (graceDaysLeft and graceEnds in lapse_rule.ts). They show on the billing page and screen, where a forge in grace is seen. A forge in grace never reaches the wake page, and the pull says so. (3) The terminal expired row and p-blocked-on-expired are tested with real key events and a real Surface. (4) The expired sentence no longer repeats the keep-until day. (5) The pipeline-ordering question is answered honestly in the thread. Design: no hand-rolled markup, Pay again stays a post form, it works without JS, and the how-to is in docs/features/lapsed-forge.md, not the README.

Two things I would do next:

  1. Non-blocking: lapseNotice clamps with Math.max(1, ...), so a forge whose grace has just run out reads 1 day remains. Say so in a comment or word it as ending today.
  2. Non-blocking: add a lapsed sample route to app.looks so the wake page gets a real look picture.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs