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

/new-forge fits 360 px with the keyboard up: the name field and the button stay in view #13019

Merged opened this

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

Merged

scout/forge:scout/13005-new-forge-fits-360-px-with-the-keyboard → main 10 commits fork 2 threads · 2 unresolved

  • Merged. scout/13005-new-forge-fits-360-px-with-the-keyboard was merged into main as 55304bd.

Review

Sign in to review this change.
6 files changed +122 −29
docs/design/areas/forms.md +1
@@ -4,6 +4,7 @@ A form's fields and its buttons sit in two rows, one for what you fill in and on
44
55 - `.field-row` — a row of `.field`s side by side that wraps on a narrow screen, each at least 160px wide and aligned to the bottom so a labelled input and the button beside it share a baseline. Styled in `style/components.ts`; written by `createForm` in `pages/branches.ts` (the new-branch form), the graph filter in `pages/fleet-graph.ts` and the freeze form in `pages/frozen.ts`. The new-pull form stacks Base and Compare as plain `.field`s, one column at any width.
66 - `.form-actions` — the row of a form's buttons under its fields: 16px above, 8px apart, wrapping. Styled in `style/components.ts`, and in `style/content.ts` for a thread's close reason and "close into" input and for `.comment-form` on a narrow screen; written by nearly every form in `src/web/pages/` (`account.ts`, `settings.ts`, `crew.ts`, `edit.ts`, `issues.ts`, `pulls.ts`, `oauth.ts`, `teams.ts`, `chain.ts`, `everyday.ts`) and by the review comment form in `diff-view.ts`; `client.ts` finds its `.muted` note to report a save.
7 - `.form-actions[data-stick]` — on a screen up to 640px the row sticks to the bottom edge (opaque `--bg`, 8px padding) so a long form's submit stays in view with the keyboard up; `/forges/new` sets it (#13005).
78
89 - The gate break-glass (#7790) on the pull's Files step is a plain `field()` with a hint and a `.form-actions` row holding one `btn` in the `danger` variant; no new class. It sits under the disabled primary Merge button, so the page keeps one accent.
910
docs/design/size-budget.json +11 −11
@@ -1,31 +1,31 @@
11 {
22 "/": {
33 "js": 21504,
4 "css": 43520
4 "css": 44544
55 },
66 "/explore": {
77 "js": 21248,
8 "css": 43520
8 "css": 44544
99 },
1010 "/map": {
1111 "js": 28160,
12 "css": 45056
12 "css": 46080
1313 },
1414 "/:owner/:name": {
1515 "js": 35072,
16 "css": 43520
16 "css": 44544
1717 },
1818 "/changelog": {
1919 "js": 26112,
20 "css": 43520
20 "css": 44544
2121 },
2222 "/:owner/:name/next": {
2323 "js": 23040,
24 "css": 44032
24 "css": 44800
2525 },
2626 "/:owner/:name/space": {
27 "js": 28928,
28 "css": 44800
27 "js": 29440,
28 "css": 45568
2929 },
3030 "/:owner/:name/space.json": {
3131 "js": 0,
@@ -33,14 +33,14 @@
3333 },
3434 "/pricing": {
3535 "js": 21248,
36 "css": 43520
36 "css": 44544
3737 },
3838 "/forges/new": {
3939 "js": 21248,
40 "css": 43520
40 "css": 44544
4141 },
4242 "/claim": {
4343 "js": 23808,
44 "css": 43520
44 "css": 44544
4545 }
4646 }
src/web/layout.ts +23 −7
@@ -101,6 +101,8 @@ export interface PageOptions {
101101 */
102102 flash?: Flash;
103103 title: string;
104 /** A form with a sticky submit row: the layout shrinks with the on-screen keyboard (#13005). */
105 keyboardResizes?: boolean;
104106 /**
105107 * One sentence for the places that show a page before it is opened: a
106108 * search result, a link unfurled in a chat. A repository's description,
@@ -222,7 +224,10 @@ export interface PageOptions {
222224
223225 // ---- topbar pieces ----
224226
225 /** The theme a mode button sends: the viewer's own named theme while it is of that mode, else the default of the pair. */
227 /**
228 * The theme a mode button sends: the viewer's own named theme while it is of that mode, else the
229 * default of the pair.
230 */
226231 const modeTheme = (mode: "light" | "dark", active: ThemeName | undefined): ThemeName =>
227232 active !== undefined && THEMES[active].appearance === mode ? active : mode;
228233
@@ -413,10 +418,15 @@ const STATIC_PALETTE: PaletteItem[] = [
413418 { t: "Your shells", h: "/settings/shells", c: "Settings" },
414419 ];
415420
416 /** What a signed-out visitor can reach: places to go, not Create and Settings rows that end at a sign-in wall. */
421 /**
422 * What a signed-out visitor can reach: places to go, not Create and Settings rows that end at a
423 * sign-in wall.
424 */
417425 const VISITOR_PALETTE = new Set(goPaletteRows().filter((r) => r.visitor).map((r) => r.t));
418426
419 /** First path segments that are the forge's own pages, never an owner: no repository read for them. */
427 /**
428 * First path segments that are the forge's own pages, never an owner: no repository read for them.
429 */
420430 const NOT_AN_OWNER = new Set([
421431 ...STATIC_PALETTE.map((p) => p.h.split("/")[1] ?? ""),
422432 "api", "releases", "audit", "admin", "tell", "login", "logout", "signup", "feed", "boards", "organizations", "static", "assets",
@@ -529,7 +539,8 @@ function paletteIndex(ctx: Ctx, extra: PaletteItem[]): Html {
529539 }),
530540 };
531541 }),
532 // A "Go to" row is the viewer's own: an admin's page is not listed to anyone else (it would end at a 403 or a 404).
542 // A "Go to" row is the viewer's own: an admin's page is not listed to anyone else (it would end
543 // at a 403 or a 404).
533544 ...(ctx.auth.user
534545 ? STATIC_PALETTE.filter((p) => {
535546 const row = GO_ROWS.find((r) => r.t === p.t && r.h === p.h);
@@ -631,7 +642,9 @@ function flashToast(flash: Flash): Html {
631642
632643 // ---- the chrome ----
633644
634 /** Where a signed-out visitor's way in leads: the topbar button and the palette's Sign in share it. */
645 /**
646 * Where a signed-out visitor's way in leads: the topbar button and the palette's Sign in share it.
647 */
635648 export function signInHref(ctx: Ctx): string {
636649 const token = activeEdgeToken(ctx.app);
637650 if (edgeStrangerLogin(ctx.request, token, ctx.auth.user) !== undefined) return "/signup";
@@ -653,7 +666,10 @@ export function signUpHref(ctx: Ctx): string | undefined {
653666 return mode === "open" || mode === "request" ? withReturn("/signup", returnTo(ctx)) : "/";
654667 }
655668
656 /** The Talk button; the count of confirms waiting on the viewer's yes is asked only here, where the button renders. */
669 /**
670 * The Talk button; the count of confirms waiting on the viewer's yes is asked only here, where the
671 * button renders.
672 */
657673 function talkButton(ctx: Ctx, user: User, about?: string): Html {
658674 const waiting = waitingCount(ctx, user);
659675 const label = waiting > 0 ? `Talk to the forge, ${waiting} waiting` : "Talk to the forge";
@@ -808,7 +824,7 @@ export function page(options: PageOptions, status = 200): Response {
808824 <meta charset="utf-8" />
809825 <meta
810826 name="viewport"
811 content="width=device-width, initial-scale=1"
827 content="width=device-width, initial-scale=1${options.keyboardResizes ? ", interactive-widget=resizes-content" : ""}"
812828 />
813829 <title>${tabTitle(options.title)}</title>
814830 <meta name="description" content="${pageDescription(options)}" />
src/web/pages/new-forge.ts +31 −11
@@ -1,7 +1,7 @@
11 /**
22 * `/forges/new`: "+ New forge" (#426), the page a signed-in person spawns a
3 * child from (they claim it and become its admin). It is the same door as `POST /api/v1/forges` and the MCP
4 * `spawn` (`spawn/door.ts`), as one form that works without JavaScript.
3 * child from (they claim it and become its admin). It is the same door as `POST /api/v1/forges` and
4 * the MCP `spawn` (`spawn/door.ts`), as one form that works without JavaScript.
55 *
66 * The path: the owner wants to send someone a forge; from the "+" menu he
77 * fills in a name and ticks the apps, presses **See the plan** (nothing is
@@ -94,7 +94,10 @@ function errorsOf(door: Door): Errors {
9494 return { form: plainError(message) };
9595 }
9696
97 /** What the form reads before it draws: room, then (when there is room) the repositories and the crew. */
97 /**
98 * What the form reads before it draws: room, then (when there is room) the repositories and the
99 * crew.
100 */
98101 interface Reads {
99102 readonly full: string | undefined;
100103 /** Why even a small forge would pass the host's child quota; the form still draws. */
@@ -138,7 +141,9 @@ function sizeOptions(chosen: string): { value: string; label: string; selected?:
138141 }));
139142 }
140143
141 /** The templates in order, Blank first; the one asked for chosen (Blank when it is not one of them). */
144 /**
145 * The templates in order, Blank first; the one asked for chosen (Blank when it is not one of them).
146 */
142147 function templateOptions(chosen: string, repos: readonly string[]): { value: string; label: string; selected?: boolean }[] {
143148 const known = TEMPLATES.some((t) => t.id === chosen) || repos.includes(chosen);
144149 const at = known ? chosen : DEFAULT_TEMPLATE;
@@ -181,7 +186,10 @@ function freshError(errors: Errors, repoCount: number): string | undefined {
181186 return errors["fresh"] ?? (repoCount === 0 ? errors["apps"] : undefined);
182187 }
183188
184 /** The line under the heading: the crew starts on the included credit when there is one, else on the person's AI account. */
189 /**
190 * The line under the heading: the crew starts on the included credit when there is one, else on the
191 * person's AI account.
192 */
185193 function hostingTerms(includedUsd: number): string {
186194 const crew =
187195 includedUsd > 0
@@ -220,7 +228,6 @@ function formView(
220228 // /forges answers only an admin; to anyone else the link would lead to a 404.
221229 actions: ctx.auth.user?.isAdmin ? sentLink() : undefined,
222230 })}
223 <p class="muted small" id="hosting-terms">${hostingTerms(includedUsd)}</p>
224231 ${quota ? html`<p role="status" id="quota-full">This forge has no room for another forge: ${quota}.</p>` : null}
225232 ${errors["form"]
226233 ? html`<p class="error mb" role="alert">${errors["form"]}</p>`
@@ -383,7 +390,7 @@ function formView(
383390 </p>
384391 </details>
385392 ${codeField(values.code, errors["code"])}
386 <div class="form-actions">
393 <div class="form-actions" data-stick>
387394 <button class="btn" type="submit" name="do" value="plan">
388395 See the plan
389396 </button>
@@ -391,6 +398,7 @@ function formView(
391398 </div>
392399 </form>
393400 </section>
401 <p class="muted small" id="hosting-terms">${hostingTerms(includedUsd)}</p>
394402 </div>`;
395403 }
396404
@@ -449,12 +457,17 @@ function giftLine(g: unknown): Html | null {
449457 return typeof gift?.plan === "string" ? html`<li><b>${giftWords({ plan: gift.plan })}</b></li>` : null;
450458 }
451459
452 /** The way to the list of forges sent; /forges answers only an admin, so only an admin is shown it. */
460 /**
461 * The way to the list of forges sent; /forges answers only an admin, so only an admin is shown it.
462 */
453463 function sentLink(): Html {
454464 return btn("Forges you sent", { href: "/forges", size: "sm" });
455465 }
456466
457 /** A link on its own (made again, or paid for): what to do with it, the link, and for an admin the way back to the list. */
467 /**
468 * A link on its own (made again, or paid for): what to do with it, the link, and for an admin the
469 * way back to the list.
470 */
458471 export function claimLinkBody(link: string, isAdmin: boolean): Html {
459472 return linkToSend(link, isAdmin ? html`<p>${sentLink()}</p>` : null);
460473 }
@@ -493,7 +506,8 @@ export function newForgePage(ctx: Ctx): Response {
493506 notePhase(ctx.request, "session", takeSessionTime(ctx.request));
494507 const reads = readsFor(ctx, user);
495508 const rendering = performance.now();
496 // A code in the address moves to a cookie and out of the address (the log and history never hold it).
509 // A code in the address moves to a cookie and out of the address (the log and history never hold
510 // it).
497511 const inUrl = ctx.url.searchParams.get("code");
498512 if (inUrl !== null && inUrl !== "") return keepGift(inUrl.slice(0, 64), "/forges/new", ctx.url, ctx.app.config.url);
499513 // A link with a code arrives filled in, and says it is a gift, or plainly why not.
@@ -504,6 +518,7 @@ export function newForgePage(ctx: Ctx): Response {
504518 const response = page({
505519 ctx,
506520 title: "New forge",
521 keyboardResizes: true,
507522 body: formView(ctx, user, { ...EMPTY, code, name: (ctx.url.searchParams.get("name") ?? "").slice(0, 38), ...fromPack(ctx, user) }, errors, gift, reads),
508523 });
509524 notePhase(ctx.request, "render", performance.now() - rendering);
@@ -558,6 +573,7 @@ export async function newForgeSubmit(ctx: Ctx): Promise<Response> {
558573 {
559574 ctx,
560575 title: "New forge",
576 keyboardResizes: true,
561577 body: formView(ctx, user, values, errorsOf(door), null, readsFor(ctx, user)),
562578 },
563579 door.status === 422 ? 422 : door.status,
@@ -566,6 +582,7 @@ export async function newForgeSubmit(ctx: Ctx): Promise<Response> {
566582 return page({
567583 ctx,
568584 title: "New forge",
585 keyboardResizes: true,
569586 body: formView(ctx, user, values, {}, planView(ctx, user, values, door.body), readsFor(ctx, user)),
570587 });
571588 noteForgeMade(ctx);
@@ -591,7 +608,10 @@ export async function newForgeSubmit(ctx: Ctx): Promise<Response> {
591608 return response;
592609 }
593610
594 /** The code is asked for only when one is in play: filled in from a link, or behind a quiet disclosure that needs no script. */
611 /**
612 * The code is asked for only when one is in play: filled in from a link, or behind a quiet
613 * disclosure that needs no script.
614 */
595615 function codeField(value: string, error: string | undefined): Html {
596616 const input = formField({ label: "Gift code", name: "code", value, autocomplete: "off", ...(error ? { error } : {}) });
597617 if (value !== "" || error) return input;
src/web/style/components.ts +5
@@ -165,6 +165,11 @@ fieldset.field > .check + .check { margin-top: 8px; }
165165 .field-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
166166 .field-row .field { flex: 1; min-width: 160px; margin-bottom: 0; }
167167 .form-actions { margin-top: 16px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
168 /* A long form's buttons stay in reach on a phone, with the keyboard up (#13005). */
outdated

Sticky bottom:0 follows the layout viewport, so with an iOS keyboard open the row may still sit under it. Pair with interactive-widget=resizes-content in the viewport meta or verify at 360x640 and say how.

169 @media (max-width: 640px) {
170 .form-actions[data-stick] { position: sticky; bottom: 0; padding: 8px 0; margin-bottom: 0; background: var(--bg); }
171 form:has(.form-actions[data-stick]) .input { min-width: 0; max-width: 100%; }
172 }
168173
169174 /* ---- stat tile ---- fixed heights: a changing value shifts nothing */
170175 .stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
test/new-forge-phone.test.ts added +51
@@ -0,0 +1,51 @@
1 /**
2 * /forges/new on a 360px phone with the keyboard up (#13005): the submit row sticks,
3 * and the name field leads the form.
4 */
5 import { afterAll, beforeAll, expect, test } from "bun:test";
6 import { mkdtemp, rm } from "node:fs/promises";
7 import { tmpdir } from "node:os";
8 import { join } from "node:path";
9 import { createApp, type App } from "../src/app.ts";
10 import { serve, type Servers } from "../src/http/server.ts";
11 import { css } from "../src/web/style.ts";
12
13 let dir = "";
14 let app: App;
15 let servers: Servers;
16
17 beforeAll(async () => {
18 dir = await mkdtemp(join(tmpdir(), "forge-new-forge-phone-"));
19 app = createApp({ dataDir: dir, url: "https://forge.test", port: 0 });
20 servers = await serve(app);
21 });
22 afterAll(async () => {
23 servers.stop();
24 app.close();
25 await rm(dir, { recursive: true, force: true });
26 });
27
28 test("the buttons row is marked to stick and the name field comes first", async () => {
29 const page = await (await fetch(`${servers.url}/forges/new`)).text();
30 const form = /<form[^>]*id="new-forge"[\s\S]*?<\/form>/.exec(page)?.[0] ?? "";
31 expect(form).toMatch(/<div class="form-actions" data-stick>/);
32 expect(form.indexOf('name="name"')).toBeGreaterThan(-1);
33 expect(form.indexOf('name="name"')).toBeLessThan(form.indexOf('name="direction"'));

This checks the name precedes direction, but the issue asks for the name in view: the lead line and hosting-terms paragraph sit above it. Assert the name is the first field after the heading and move the terms below the form.

34 expect(form).toContain("autofocus");
35 // The name is the first field after the heading, and the hosting terms sit below the form.
36 const body = page.slice(page.indexOf("<h1"));
37 expect(/<(?:input|textarea|select)\b[^>]*\bname="([^"]*)"/.exec(body)?.[1]).toBe("name");
38 expect(body.indexOf('name="name"')).toBeLessThan(body.indexOf('id="hosting-terms"'));
39 expect(page.indexOf("</form>")).toBeLessThan(page.indexOf('id="hosting-terms"'));
40 });
41
42 test("the viewport resizes with the keyboard, so the bottom edge moves up with it", async () => {
43 const page = await (await fetch(`${servers.url}/forges/new`)).text();
44 expect(page).toMatch(/<meta\s+name="viewport"\s+content="[^"]*interactive-widget=resizes-content/);
45 });
46
47 test("a narrow screen pins the marked row to the bottom, opaque, and keeps inputs inside", () => {
48 const sheet = typeof css === "string" ? css : [...css].join("\n");
49 expect(sheet).toMatch(/max-width: 640px\)\s*\{\s*\.form-actions\[data-stick\]\s*\{[^}]*position: sticky;[^}]*bottom: 0;[^}]*background: var\(--bg\)/);
50 expect(sheet).toContain("max-width: 100%");
51 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs