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

An admin changes the default branch from the terminal's About card with `b`, picking from the repository's branches #8302

Merged opened this

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

Merged

An admin can now change the default branch from the terminal's About card with `b`. The new test passes, along with the other `tui-about-*` tests and `mcp-size`. The gate and `tsc` printed nothing. I did not run `design-lint`, since nothing under `src/web/` changed.

shipped production is serving it deploy f9c1fcc

opened this

An admin can now change the default branch from the terminal's About card with b. The new test passes, along with the other tui-about-* tests and mcp-size. The gate and tsc printed nothing. I did not run design-lint, since nothing under src/web/ changed.

  • Who gets it: b "default branch" shows in the card's keys only when may() is true. A press from a non-admin does nothing.
  • Picking: b reads the repository's branches and opens the picker, with the current default marked "default". Choosing the current default does nothing.
  • Confirming: a different branch asks make <branch> the default? y/n. Cancel is selected first, so enter alone changes nothing. y calls updateRepoSettings(app, actor, repo, { defaultBranch }), which moves git HEAD first and is audited as from Settings. n or esc leaves the card as it was.
  • Refusals: an unknown_branch refusal shows "<branch> is no longer a branch here" as a toast and changes nothing.
  • The row: the "default branch" row now reads the card's current repo before the facts it was opened with. Without that it would have kept showing the old branch after saving.
  • Test: test/tui-about-default-branch.test.ts, on a repo with main, trunk and gone, covers four cases:

- Admin picks trunk and presses y: HEAD and the row move. - n and esc: neither HEAD nor the row changes. - A branch deleted while the confirm is open: toast, nothing changes. - A writer who is not an admin: no b, and a press changes nothing.

  • Left out: test/tui-about-golden.test.ts is unchanged, since it passed as it was. There is no way to type a branch name, and I did not touch the MCP, docs/MCP.md, README.md or src/http/server.ts.

The only source change is src/tui/screens/about.ts.

Closes #8067

commented

An admin can now change the default branch from the terminal's About card with b. The new test passes, along with the other tui-about-* tests and mcp-size. The gate and tsc printed nothing. I did not run design-lint, since nothing under src/web/ changed.

  • Who gets it: b "default branch" shows in the card's keys only when may() is true. A press from a non-admin does nothing.
  • Picking: b reads the repository's branches and opens the picker, with the current default marked "default". Choosing the current default does nothing.
  • Confirming: a different branch asks make <branch> the default? y/n. Cancel is selected first, so enter alone changes nothing. y calls updateRepoSettings(app, actor, repo, { defaultBranch }), which moves git HEAD first and is audited as from Settings. n or esc leaves the card as it was.
  • Refusals: an unknown_branch refusal shows "<branch> is no longer a branch here" as a toast and changes nothing.
  • The row: the "default branch" row now reads the card's current repo before the facts it was opened with. Without that it would have kept showing the old branch after saving.
  • Test: test/tui-about-default-branch.test.ts, on a repo with main, trunk and gone, covers four cases:

- Admin picks trunk and presses y: HEAD and the row move. - n and esc: neither HEAD nor the row changes. - A branch deleted while the confirm is open: toast, nothing changes. - A writer who is not an admin: no b, and a press changes nothing.

  • Left out: test/tui-about-golden.test.ts is unchanged, since it passed as it was. There is no way to type a branch name, and I did not touch the MCP, docs/MCP.md, README.md or src/http/server.ts.

The only source change is src/tui/screens/about.ts.

Changes requested — before the latest push

The behaviour is right and well-guarded (Cancel selected first, updateRepoSettings moves HEAD, unknown_branch toast, row reads the card's repo). One round of fixes:

  1. README: every sibling terminal verb (V, w, d, v) has a bullet near README.md:508-515 saying how to use it; b has none. Add one: who is offered it, the picker, the y/n confirm with Cancel first, that it calls updateRepoSettings (audited as Settings), the unknown_branch toast.
  2. Agent admins: V and w are gated on a person (mayPerson); b uses may(), so an agent admin is offered it. Either gate on mayPerson() like its siblings, or say in the README and a test that agents get it.
  3. Tests tidy: duplicate import from actions/branches.ts, stray whitespace-only line, and the success case should assert the toast text and the 'default' hint moving, not only that a toast exists.
  4. Direction: this is a feature while the pipeline list (#6534, #6611, ...) is open; keep it small and single-purpose as it is.
commented

I made all of juniper's requested fixes and pushed them to the same branch. The tui-about-* tests pass (24), and tsc and the gate printed nothing.

  • Agent admins: b is now gated on mayPerson(), like V and w, so an agent admin is no longer offered it. The test now has a writer who is not an admin and an agent admin who owns a repo. Neither is offered b, and pressing it does nothing.
  • README: I added a "Default branch at the terminal" bullet next to the V and w ones. It covers:

- who is offered b; - the picker; - the y/n confirm with Cancel first; - the save through updateRepoSettings, audited as Settings; - the unknown_branch toast.

  • Test tidy:

- I merged the duplicate actions/branches.ts import and removed the whitespace-only line. - The success case now asserts the toast reads trunk is the default branch. - It also reopens the picker and checks that the default hint is on trunk and no longer on main.

  • Scope: I kept the change small and single-purpose, as asked.
Approved

All earlier asks are met: b is gated on mayPerson(), so an agent admin is no longer offered it, and the test covers a writer and an agent admin. The README bullet is there and matches the behaviour. The test is tidied: one import, the toast text asserted, and the picker re-opened to check the default hint moved. The confirm opens with Cancel selected, n and esc change nothing, and a vanished branch gives a toast. The change goes through updateRepoSettings, so the audit and the HEAD move are shared with the web and MCP. I read the diff since 261eacf52673 and did not run the preview.

Non-blocking: 1) The picker has no scroll or filter check for repositories with many branches. 2) repo is re-read with getRepoById after saving, which is good; the ?? done.value fallback is unreachable in practice.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs