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

Config files open as a form in the terminal too: JSON, YAML and TOML values edited field by field #16679

Merged opened this

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

Merged

The terminal now has a form screen for JSON, YAML and TOML files, opened with Z in the workspace. bun x tsc --noEmit, gate.ts, design-lint.ts and the config, TUI-workspace and doorless tests pass. I did not run the full suite or the CI-only socket suites; the forge's check does that.

Notes

shipped production is serving it deploy 354c752

opened this

The terminal now has a form screen for JSON, YAML and TOML files, opened with Z in the workspace. bun x tsc --noEmit, gate.ts, design-lint.ts and the config, TUI-workspace and doorless tests pass. I did not run the full suite or the CI-only socket suites; the forge's check does that.

What changed

  • Entry: Z in the workspace on a file isFormConfig accepts. It is listed in the key help. f and F were already taken. It refuses, with a toast, while that file has unsaved edits, and on a mirror of an origin, which edits as text.
  • Fields: src/tui/screens/config_rows.ts turns the document into rows with the web form's pointers, using findSchema, schemaAt and validate.
  • Keys:
    • enter or e edits a value (an enum opens a picker).
    • space toggles a boolean.
    • a adds a card to the array the cursor is in.
    • x removes the card.
    • n adds a key.
    • s saves.
  • Cards: adding, removing and new keys go through the web's applyOp, so a new card starts as the schema says.
  • Saving: src/web/render/config-save.ts (settleConfig) holds the "nothing changed", write and read-back steps. The web page now calls it too, so both doors say the same words. A writer gets the commit dialog (editFiles, with the blob the form read as was). Anyone else gets "Propose a change" (proposeEdit). A schema breach is refused in the web's words and nothing is written.
  • Live to web viewers: I did not add or test anything for this. I assumed editFiles and proposeEdit already publish live updates, since the web uses the same calls.
  • Tests:
    • test/tui-config-form.test.ts edits a JSON number, a YAML boolean and a TOML string, each changing exactly one line with comments kept. It also covers adding and removing a card and a no-change save.
    • test/tui-propose-edit.test.ts adds a schema refusal in the form, and a reader proposing from it. I changed that file's openBeacon helper to search alice/beacon, because the existing reader test leaves a kim/beacon fork that the shorter query matched first.
  • Docs and lists: docs/features/config-form.md has a terminal section and no longer says the terminal has no form. The config page gained a door, so I pruned it from scripts/doorless-allow.json.

Reused: configFields's document model, findSchema, schemaAt, validate, applyOp, writeConfig through settleConfig, editFiles, proposeEdit, the existing commit dialog, promptScreen and pickerScreen. I did not run scripts/similar.ts.

Left out

  • Reordering cards (up and down) is not in the terminal form.
  • A null value is edited as a string.
  • The form is not in the palette.
  • A writer on a protected branch gets the commit dialog's new-branch default, not a separate proposal path.

Try it: open a repository in the terminal workspace, open app.json, app.yml or app.toml, press Z, change a value with enter, press s, then ctrl+s.

Closes #8934

7 earlier comments · 1 event
commented

The terminal now has a form screen for JSON, YAML and TOML files, opened with Z in the workspace. bun x tsc --noEmit, gate.ts, design-lint.ts and the config, TUI-workspace and doorless tests pass. I did not run the full suite or the CI-only socket suites; the forge's check does that.

What changed

  • Entry: Z in the workspace on a file isFormConfig accepts. It is listed in the key help. f and F were already taken. It refuses, with a toast, while that file has unsaved edits, and on a mirror of an origin, which edits as text.
  • Fields: src/tui/screens/config_rows.ts turns the document into rows with the web form's pointers, using findSchema, schemaAt and validate.
  • Keys:
    • enter or e edits a value (an enum opens a picker).
    • space toggles a boolean.
    • a adds a card to the array the cursor is in.
    • x removes the card.
    • n adds a key.
    • s saves.
  • Cards: adding, removing and new keys go through the web's applyOp, so a new card starts as the schema says.
  • Saving: src/web/render/config-save.ts (settleConfig) holds the "nothing changed", write and read-back steps. The web page now calls it too, so both doors say the same words. A writer gets the commit dialog (editFiles, with the blob the form read as was). Anyone else gets "Propose a change" (proposeEdit). A schema breach is refused in the web's words and nothing is written.
  • Live to web viewers: I did not add or test anything for this. I assumed editFiles and proposeEdit already publish live updates, since the web uses the same calls.
  • Tests:
    • test/tui-config-form.test.ts edits a JSON number, a YAML boolean and a TOML string, each changing exactly one line with comments kept. It also covers adding and removing a card and a no-change save.
    • test/tui-propose-edit.test.ts adds a schema refusal in the form, and a reader proposing from it. I changed that file's openBeacon helper to search alice/beacon, because the existing reader test leaves a kim/beacon fork that the shorter query matched first.
  • Docs and lists: docs/features/config-form.md has a terminal section and no longer says the terminal has no form. The config page gained a door, so I pruned it from scripts/doorless-allow.json.

Reused: configFields's document model, findSchema, schemaAt, validate, applyOp, writeConfig through settleConfig, editFiles, proposeEdit, the existing commit dialog, promptScreen and pickerScreen. I did not run scripts/similar.ts.

Left out

  • Reordering cards (up and down) is not in the terminal form.
  • A null value is edited as a string.
  • The form is not in the palette.
  • A writer on a protected branch gets the commit dialog's new-branch default, not a separate proposal path.

Try it: open a repository in the terminal workspace, open app.json, app.yml or app.toml, press Z, change a value with enter, press s, then ctrl+s.

commented

<!-- look-pages 28c5070fd1c7 --> Look pages for 28c5070, from the gate:

  • look pages (none): this pull changes src/web/pages/config.ts, src/web/render/config-save.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

Looks: none. This pull changes no rendered web page.

The web edits in src/web/pages/config.ts and src/web/render/config-save.ts only move the config form's field and save-refusal logic into shared functions. The terminal reads those same functions. The web form's HTML is unchanged.

No look: the gate named /settings/security/controls as the route, but nothing in this change touches that page. The src/web diff leaves the config form's output as it was, and the existing config web tests cover that.

What changed

In the terminal workspace, a .json, .yml or .toml file now opens as a form. Press Z to open it, change a value with enter, and press s to save. The form has the same fields, cards, write-back and refusals as the web config form.

  • src/tui/screens/configform.ts and config_rows.ts add the form screen and its rows.
  • src/tui/screens/workspace.ts adds the Z key.
  • src/web/pages/config.ts and src/web/render/config-save.ts export the shared pieces, with no behaviour change on the web.
  • test/tui-config-form.test.ts and test/tui-propose-edit.test.ts cover the new behaviour.
  • docs/features/config-form.md is updated, and one stale entry is removed from scripts/doorless-allow.json.

Left out

Nothing new. The form edits scalar values only, as the web form does.

Try it

Open the terminal workspace, select a config file, press Z, change a value with enter, then press s. Run bun test test/tui-config-form.test.ts.

Changes requested — before the latest push

The form works and reuses the web's code well (settleConfig shared, same applyOp/findSchema/validate, editFiles/proposeEdit, the web's words). One thing to fix first: box 4, a save from the terminal reaching web viewers live, has no test, and the PR says it was assumed. Add a test in test/tui-config-form.test.ts that saves a form edit and asserts the same live event a web viewer of the file and the branch receives (the one the web config save's test asserts), so it fails if the terminal path stops publishing. If editFiles does not publish it, fix that. Second, smaller: src/tui/screens/configform.ts imports MAX_FORM_BYTES from src/web/pages/config.ts; move the constant next to settleConfig in render/config-save.ts so the terminal does not depend on a page module. Third: a and x do nothing on a row outside a card, with no feedback; say so in a toast. No web markup changed, so the design principles are untouched. Boxes 1, 2, 3 and 5 are met.

commented

All three review points are fixed and pushed. tsc --noEmit is clean and test/tui-config-form.test.ts and test/config-form.test.ts pass, 33 tests.

  • Live save (box 4): editFiles already publishes the live event, so it needed no fix. It appends a push event to the bus, which is what a web viewer's stream hears. I added a test that saves a terminal edit and subscribes to forge.bus. It asserts exactly one push for the repo, from the saving user, naming one refs/heads/… ref that exists as a branch holding the edit. It fails if the terminal path stops publishing.
    • I did not copy the event assertion from the web config save's test, because I found none there to match. The test asserts the bus event directly.
    • The test edits its own live.json, because the other tests already create each file's default branch name.
  • MAX_FORM_BYTES: it now lives next to settleConfig in src/web/render/config-save.ts. configform.ts, src/web/pages/config.ts and test/config-form.test.ts import it from there, so the terminal no longer imports a page module.
  • a and x outside a card: they now show a note on the form, "a adds a card to a list: move to a row inside one." and "x removes a card from a list: …". A new test covers both. The form has no toast, so I used the note line it already uses for messages.

scripts/gate.ts --fix reported only advisory similarity notes (add and remove in configform.ts are alike, for example). I left those alone.

Looks: none. No web markup changed.

commented

<!-- look-pages 346f71ff3ccc --> Look pages for 346f71f, from the gate:

  • look pages (none): this pull changes src/web/pages/config.ts, src/web/render/config-save.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

No code change this round. The gate's look-pages note asks for a Looks: or No look: line in the pull description, so here it is.

No look: this pull changes no rendered web page. The edits to src/web/pages/config.ts and src/web/render/config-save.ts only move MAX_FORM_BYTES next to settleConfig, so the terminal form can import it without depending on a page module. The web config form's markup is unchanged.

The gate named /settings/security/controls as the route to look at. I disagree with that: nothing in this pull touches that page or the security controls code (src/web/pages/security_controls.ts).

What changed

  • In the terminal workspace, a .json, .yml or .toml file opens as a form with Z. Change a value with enter, save with s.
  • The form has the same fields, cards, write-back and refusals as the web config form.
  • A save from the terminal publishes a push event for the new branch, as the web save does. A test in test/tui-config-form.test.ts fails if it stops.
  • a and x on a row outside a card now say why they did nothing. They use the form's note line, since the form has no toast.

What I left out

The form edits scalar values only, as the web form does.

How to try it

Open the terminal workspace, select a config file and press Z. Change a value with enter, then press s. bun test test/tui-config-form.test.ts covers it.

commented

I fixed the "both doors" failure and pushed. The second failing test, the outbox boot test, passes when I run it alone, so I did not change anything for it.

Both doors: config.ts was being counted as a page with no terminal door. When I moved MAX_FORM_BYTES into render/config-save.ts, the terminal form stopped importing src/web/pages/config.ts. The rule finds the link either through that import or through a feature doc that names both the page and a src/tui file. I added the page's name to docs/features/config-form.md, in the sentence about the terminal door. test/doorless.test.ts now passes.

Outbox boot test: test/release-sweep-safety-14784.test.ts passes alone, 6 of 6. The check log shows it timing out at 30 seconds in the full sharded run. This pull does not touch the release sweep or the outbox, so I believe it was load on the shard. If it fails again on the next check run, that is a real failure I have not reproduced.

Looks: none. No web markup changed.

No look: the only web changes are MAX_FORM_BYTES moving into src/web/render/config-save.ts and a doc sentence. The web config form renders the same as before, and nothing here touches /settings/security/controls, which the gate named earlier.

commented

<!-- look-pages 76fc7a5c9108 --> Look pages for 76fc7a5, from the gate:

  • look pages (none): this pull changes src/web/pages/config.ts, src/web/render/config-save.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
Approved

Earlier asks, all met at this head: (1) live save: test/tui-config-form.test.ts subscribes to forge.bus and asserts one push event from the saver naming a real new branch. (2) MAX_FORM_BYTES now sits beside settleConfig, so the terminal no longer imports a page module. (3) a and x outside a card say why on the note line, with a test. The both-doors failure is fixed by naming the web page in docs/features/config-form.md, and the how-to is in docs/features, not README. No web markup changed; the web page now calls the shared settleConfig and says the same words. Two things I would do next, both non-blocking: Non-blocking: a null value is edited as a string (typed() writes a string for kind null), so a null can become an empty string or text silently; offer a null/string choice or keep null on empty input. Non-blocking: the long sentence in the docs terminal section breaks the wrap used elsewhere in that file; rewrap it.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs