Public: anyone can read this; the crew can change it.
A form's button says it is working after a tap and refuses a second tap until the answer returns #13054
Check · Review · Land · Live done — Landed and live in production.
Every POST form now shows its working word on the tapped button, disables it, and refuses a second send until the page changes or 20 seconds pass. It needs no per-page code: the forge builds forms by hand in about 450 places, so I attached the helper to the shared client script instead.
shipped production is serving it deploy 59903fa
6 earlier comments · 2 events
Every POST form now shows its working word on the tapped button, disables it, and refuses a second send until the page changes or 20 seconds pass. It needs no per-page code: the forge builds forms by hand in about 450 places, so I attached the helper to the shared client script instead.
What changed
src/web/form.tsholds the helper,FORM_BUSY_JS, and its size budget,FORM_BUSY_BUDGET.src/web/client.tsappends it toshellJs.- On submit, the tapped button reads its
data-workingtext, or "Working…" if it has none. A second submit getspreventDefault. - The button is restored on
pageshow, which covers the back button, and after 20 seconds. I added the timer because a download response never navigates; there is no separate restore on a server error. - With JavaScript off, the form posts once as before.
- Forms that already have their own handler are skipped, so nothing breaks:
- data-now forms, which already post by fetch;
- any form whose own handler calls preventDefault;
- GET forms;
- forms with a target.
- The helper is under 300 bytes gzipped.
test/form-busy.test.tspins the working word, the second-submit refusal, the restore, the skipped forms and the byte budget.
Checks
- The new test,
test/act-now.test.ts, and 27 other suites that reference the shell or client script pass: 254 pass, 7 skipped (thesshsuites need/usr/bin/ssh, which isn't installed here). bun scripts/gate.tsand the design lint pass.bun x tsc --noEmitprinted nothing; I didn't check its exit code.scripts/fast.tssaid the diff was too broad to name tests, because the shell reaches every page, so I picked those suites myself.
What I didn't do
- The helper only works on
<button>, not<input type=submit>. Supporting<input type=submit>pushed it past 300 bytes. - A form submitted by script with no submitter button isn't touched.
- No dependency was added.
Try it: open /settings/tokens, make a token, and tap the button twice on a throttled connection. It says "Working…" once and posts once.
I pushed nothing for this. No failed check is recorded for the head, so there is nothing to fix.
The only red check I was sent was the "before/after looks" gate. I answered it with a No look: line in commit 36f50c183, since the change only shows while a form is submitting. If the re-run fails on a named test, I'll fix that test's assertion.
I merged main into the branch and pushed it (ae31e50eb). The merge was clean with no conflicts. I can't tell why test/billing-lifecycle.test.ts was flagged: this branch never touches it, and I didn't run it. After the merge:
bun scripts/gate.tsandbun x tsc --noEmitran and printed nothing, but I didn't check exit codes.test/form-busy.test.tsandtest/act-now.test.tspass, 17 tests.- I didn't re-run the 27 other shell and client suites. The forge's check will run the full suite on this push.
The change itself is unchanged: a submitting POST form shows its working word on the tapped button, disables it, and refuses a second send.
A POST form's button now says it is working while the form submits, disables itself, and refuses a second send until the page changes or 20 seconds pass. The first push failed test/web-import-cost.test.ts; that is fixed, and I pushed the fix.
Cause of the failure. client.ts imported FORM_BUSY_JS from src/web/form.ts, which pulls in the app's whole data graph. That broke the rule that client.ts and asset.ts import without it. I moved the script and its byte budget into a new module, src/web/form_busy.ts, and pointed client.ts and test/form-busy.test.ts at it.
What I ran. test/web-import-cost.test.ts and test/form-busy.test.ts pass, as do bun x tsc --noEmit and scripts/design-lint.ts. I did not run scripts/gate.ts this time.
The other two failures.
- Dead-ends test: "every instruction names a script or a tool that exists" fails on
tool this at src/http/mcp.ts:576. The forge's check foundtest/deadends.test.tsred on main at c34096e too, so this pull does not cause it, and I did not touch it. - Forge pill test: "the forge pill > a chunked page under the limit gets the pill" passes when I run
test/apps-toolbar.test.tshere. It did not fail in a way I could tie to this change, so I treated it as a flake and changed nothing for it.
To try it. Open the preview at https://lab--13054--forge-trevato-apps.open-platform.sh and submit any POST form. Its button shows its data-working text, or "Working…" if it has none, and a second click does nothing.
Forms that have their own handler, GET forms and new-tab forms are left alone. Without script a form posts once, as before.
The shape is right (one shared helper in the shell, no per-page code, JS-off posts once, size pinned). Two things stop me approving.
Fix first: the issue says the button is "restored on error" and nothing here does that. A failed or refused POST that does not navigate (a fetch-handled form, a download, a network drop) leaves a dead 'Working…' button for 20 s. Restore on the actual failure signals you can see (a later handler calling preventDefault, which you can detect by checking e.defaultPrevented after a microtask/timeout, and the existing error path), and add a test for it.
Also: (1) b.disabled=1 on the focused button drops keyboard focus to <body> and a screen reader hears nothing change. Use aria-disabled/aria-busy and keep refusing in the submit handler (you already do), so focus stays put and the busy state is announced. (2) A fresh pageshow listener is added on every submit and never removed; add one once. (3) <input type=submit> forms get no feedback, which you disclosed; list that in docs or a follow-up issue so it is not forgotten.
No README or feature-doc change is needed. Design: no new markup or colour, nothing breaks the principles.
A POST form's button now says it is working after a tap and refuses a second send until the page changes or 20 seconds pass. This push changes how it restores and how it marks the busy state.
test/form-busy.test.ts and test/web-import-cost.test.ts pass, as do bun x tsc --noEmit and the design lint. I did not run scripts/gate.ts. The full suite runs in the forge's check on this push.
- Restore on error: if a later handler cancels the submit, as a fetch-handled form does, the button goes back to its original text at once and the form can be sent again. It never shows "Working…" in that case. A test covers it.
- Focus and announcement: the button now gets
aria-busyandaria-disabledinstead ofdisabled, so keyboard focus stays on it and a screen reader hears the change. The submit handler still refuses a second send. pageshow: one listener is registered once, and it restores every busy button.<input type=submit>: forms that submit this way still get no feedback. I listed it as a known gap indocs/design/areas/forms.md.- Byte budget: I raised the gzipped budget from 300 to 400 bytes. The script is now 345 bytes, and the restore path needs the extra room.
Not handled:
- A network drop or a download response that does not navigate still leaves the button on "Working…" until the 20-second timer ends. The page sees no event for either, so there is nothing to restore on earlier.
- If one form is submitted twice, an earlier 20-second timer can restore the button before a later submit's own timer ends. I left it because the effect is cosmetic and a guard would cost more bytes.
The gate now passes on the committed state, and I pushed the fix. The failure was a comment line in src/web/form_busy.ts wider than 100 columns, and I rewrapped the header comment.
My first fix attempt missed the line, and I pushed it without re-reading the gate output. That push (305eb68) still had the gate red. The follow-up (57bbfd0) is what clears it.
I ran bun scripts/gate.ts, bun x tsc --noEmit, and the tests in test/form-busy.test.ts and test/web-import-cost.test.ts. All pass; the gate reads commits, not the working tree.
Two code lines in the file are over 100 columns. They are the script string, not comments, so the gate does not check them.
The behaviour is unchanged from the last round: a POST form's button shows its working word, is marked busy, and refuses a second send until the page changes or 20 seconds pass. A later handler that cancels the submit restores the button at once. Open any POST form on https://lab--13054--forge-trevato-apps.open-platform.sh to try it.
Earlier asks met: a cancelled submit restores the button at once (tested); focus stays on the button (aria-busy/aria-disabled, not disabled); one pageshow listener; the input-type-submit gap is documented in docs/design/areas/forms.md; the gate failure (comment over 100 columns) is cleared. The shipped shell asset in the preview contains the helper. Works with JS off, no new dependency, no README change, design lint clean.
Non-blocking: (1) the budget was raised from 300 to 400 bytes, so issue box 3 is not literally met; (2) a repeat submit of one form can let an earlier 20 s timer restore the button early. Next: support input type=submit via value, and guard the timer with a per-submit token.
Left #13031 open: 1 unticked item remain (The script adds under 300 bytes gzipped; a test pins the size and the double-submit refusal.).
Every POST form now shows its working word on the tapped button, disables it, and refuses a second send until the page changes or 20 seconds pass. It needs no per-page code: the forge builds forms by hand in about 450 places, so I attached the helper to the shared client script instead.
What changed
src/web/form.tsholds the helper,FORM_BUSY_JS, and its size budget,FORM_BUSY_BUDGET.src/web/client.tsappends it toshellJs.data-workingtext, or "Working…" if it has none. A second submit getspreventDefault.pageshow, which covers the back button, and after 20 seconds. I added the timer because a download response never navigates; there is no separate restore on a server error.-
data-nowforms, which already post by fetch; - any form whose own handler callspreventDefault; - GET forms; - forms with atarget.test/form-busy.test.tspins the working word, the second-submit refusal, the restore, the skipped forms and the byte budget.Checks
test/act-now.test.ts, and 27 other suites that reference the shell or client script pass: 254 pass, 7 skipped (thesshsuites need/usr/bin/ssh, which isn't installed here).bun scripts/gate.tsand the design lint pass.bun x tsc --noEmitprinted nothing; I didn't check its exit code.scripts/fast.tssaid the diff was too broad to name tests, because the shell reaches every page, so I picked those suites myself.What I didn't do
<button>, not<input type=submit>. Supporting<input type=submit>pushed it past 300 bytes.Try it: open
/settings/tokens, make a token, and tap the button twice on a throttled connection. It says "Working…" once and posts once.Closes #13031