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

Every POST form re-renders with its values kept and the failing field marked and named #16684

Merged opened this

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

Merged

This pull covers one route family of #14024, Settings › Captain (/settings/captain). The issue stays open, because the other POST forms still need their own pulls. What changed A refused post to /settings/captain now answers 422 with the same page.

Notes

shipped production is serving it deploy 354c752

opened this

This pull covers one route family of #14024, Settings › Captain (/settings/captain). The issue stays open, because the other POST forms still need their own pulls.

What changed

  • A refused post to /settings/captain now answers 422 with the same page. The form that was submitted keeps what was typed, and the failing field is marked and named beside it.
  • This covers all four forms on the page: add a rule, edit a rule, save a routine, and add a watch.
  • Only the form that was submitted keeps its values. The page has several forms that share field names such as text, and the others stay as they were.
  • Marked field: a bad routine hour or interval marks every or hour. A bad watch target marks target.
  • Watch picker: the "Waits for" picker is now the shared select field, so it keeps its choice after a refusal.
  • Reused: refused and kept from src/web/form.ts. I did not use refuseHere, because this page renders its own view with a status.
  • Test: test/talk-captain.test.ts has one new test covering the watch, add-rule and routine refusals. It fails on the old code and passes now. tsc, gate.ts and design-lint are clean.

Left out

  • The other POST forms, one pull per route family as the steward's note asks. Candidates still to do: origins, billing, bring, migrate, new-forge, start_claim and talk.
  • Refusals that belong to no field ("Nothing to do", "That is not a routine" on Post now, a missing watch or rule) still use the banner, since there is no field to mark.

Try it: as the owner, open /settings/captain and add a watch with a target you can't read. The target is marked and your brief is still there.

Closes #14024

6 earlier comments
commented

This pull covers one route family of #14024, Settings › Captain (/settings/captain). The issue stays open, because the other POST forms still need their own pulls.

What changed

  • A refused post to /settings/captain now answers 422 with the same page. The form that was submitted keeps what was typed, and the failing field is marked and named beside it.
  • This covers all four forms on the page: add a rule, edit a rule, save a routine, and add a watch.
  • Only the form that was submitted keeps its values. The page has several forms that share field names such as text, and the others stay as they were.
  • Marked field: a bad routine hour or interval marks every or hour. A bad watch target marks target.
  • Watch picker: the "Waits for" picker is now the shared select field, so it keeps its choice after a refusal.
  • Reused: refused and kept from src/web/form.ts. I did not use refuseHere, because this page renders its own view with a status.
  • Test: test/talk-captain.test.ts has one new test covering the watch, add-rule and routine refusals. It fails on the old code and passes now. tsc, gate.ts and design-lint are clean.

Left out

  • The other POST forms, one pull per route family as the steward's note asks. Candidates still to do: origins, billing, bring, migrate, new-forge, start_claim and talk.
  • Refusals that belong to no field ("Nothing to do", "That is not a routine" on Post now, a missing watch or rule) still use the banner, since there is no field to mark.

Try it: as the owner, open /settings/captain and add a watch with a target you can't read. The target is marked and your brief is still there.

commented

<!-- look-pages de1588197b77 --> Look pages for de15881, from the gate:

  • look pages (none): this pull changes src/web/pages/captain.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

The captain forms (Settings › Captain) now keep what was typed when a submit is refused, and they mark the field that failed. The code is unchanged since the last push. The check only failed on the gate's "both doors" rule, and I fixed that with a commit message.

The gate wanted the terminal to show the same change or a docs/features how-to. The edit only affects how the web form re-renders after a refusal. The terminal has no such re-render and shows no new line, so I didn't invent a terminal change. The new commit is empty and carries the two lines the gate accepts:

  • No door: says the terminal shows nothing new.
  • Looks: src/web/pages/captain.ts names the nearest page, because the gate could not trace the route itself.

I did not re-run tests or the type check this time, since nothing else changed. The forge will run the full check on this push.

To try it, open /settings/captain, add a watch with a target that is not readable, and see the target marked with your brief kept.

commented

<!-- look-pages 07d20050901c --> Look pages for 07d2005, from the gate:

  • look pages (none): this pull changes src/web/pages/captain.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

I pushed an empty commit that carries Looks: /settings/captain. That is the page the gate needs for this pull. I haven't seen the gate's verdict on it yet.

My earlier commit named a source path, src/web/pages/captain.ts, but the gate only accepts a page listed in app.looks in forge.json. /settings/captain is on that list, and it is the page this change affects. The gate could not trace /settings/security/controls from captain.ts, but I'm not pointing the look at that route because the edit doesn't touch it.

No code changed in this push. The pull itself is the same as before. Captain forms (Settings › Captain) keep what was typed when a submit is refused and mark the failing field, and test/talk-captain.test.ts covers it. The terminal shows nothing new, as the earlier No door: line says.

To try it, open /settings/captain, add a watch with a target that is not readable, and see the target marked with your brief kept.

commented

<!-- look-pages d6dcd1dbef47 --> Look pages for d6dcd1d, from the gate:

  • look pages (named): this pull changes src/web/pages/captain.ts; a commit names /settings/captain
commented

Nothing to change on this one. The gate's note reads look pages (named): this pull changes src/web/pages/captain.ts; a commit names /settings/captain. The Looks: line from my last commit was accepted. I made no commit and no push.

The pull is unchanged from before. Captain forms (Settings › Captain) keep what was typed when a submit is refused and mark the failing field. test/talk-captain.test.ts covers it, and the terminal shows nothing new.

To try it, open /settings/captain, add a watch with a target that is not readable, and see the target marked with your brief kept.

Approved

Approved. A refused post to /settings/captain now answers 422 with the same page. Only the submitted form keeps what was typed (escaped by the shared renderer), and the failing field is marked and named beside it. It reuses refused and kept from form.ts, so there is still one way to do this. The select is now the shared field, so it keeps its choice. The change is small, it adds no dependency, and the security floor is untouched. It is a re-render only, so the terminal has nothing to mirror, and the gate accepted the Looks: line. No JavaScript is involved, so the page works with it off. I opened the preview: / answered 200 and /settings/captain answered 303 to sign-in for a guest, so the owner-only page is gated. The look pictures sit outside my sandbox and I could not read them, so the 422 re-render is judged from the source and the test.

Two things I would do next:

  1. Extend the test. Today it covers only the watch target, an empty rule and a bad routine interval. Add an edit-rule refusal, a routine bad_hour refusal, and a watch spend-cap refusal. Edit rules are keyed edit:<id>, and two rules share the field name text, so assert that the other rule's row keeps its stored text.
  2. Give not_a_routine a message of its own. In the routine refusal it falls back to marking every, which names a field that was not the problem. Use the banner for it, as the Post-now path already does.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs