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

A test pins writing a commit in the local terminal: an empty subject is refused, and a subject past 50 columns is marked #7083

Merged opened this

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

Merged

I added `test/tui-local-commit.test.ts` for the commit screen and fixed one bug it found: a pasted multi-line message used to end up entirely in the subject. `bun x tsc --noEmit` is clean and the new test passes, along with `test/tui-local*` (18 tests). I didn't run the full check, and I didn't try the new paste test against the old code to see it fail.

shipped production is serving it deploy e11532c

opened this

I added test/tui-local-commit.test.ts for the commit screen and fixed one bug it found: a pasted multi-line message used to end up entirely in the subject. bun x tsc --noEmit is clean and the new test passes, along with test/tui-local* (18 tests). I didn't run the full check, and I didn't try the new paste test against the old code to see it fail.

Bug fixed in src/tui/local/commit.ts: a paste into the subject field collapsed every newline into a space. Now the first line stays as the subject and the rest goes to the body, with focus moving there. A paste that is only a single line, or a first line plus blank lines, stays in the subject.

What the tests pin, each in a real temporary repository with a staged change, driven through createLocalApp:

  • Empty subject: ctrl+d with an empty or all-spaces subject toasts "a subject is required", leaves HEAD unchanged, and stays on the commit screen.
  • Long subject: 25 wide characters read "0 left". One more (26 characters, 52 columns) reads "2 over the 50-column subject line", the field's bar changes colour, and ctrl+d still commits.
  • Pasted message: a bracketed paste of fix the thing, a blank line, then two body lines commits as fix the thing\n\nbecause it was broken\nand slow. The test compares against git.headMessage, which strips the trailing newline.

I left out the amend path and a body-only paste into the body field.

Closes #7069

commented

I added test/tui-local-commit.test.ts for the commit screen and fixed one bug it found: a pasted multi-line message used to end up entirely in the subject. bun x tsc --noEmit is clean and the new test passes, along with test/tui-local* (18 tests). I didn't run the full check, and I didn't try the new paste test against the old code to see it fail.

Bug fixed in src/tui/local/commit.ts: a paste into the subject field collapsed every newline into a space. Now the first line stays as the subject and the rest goes to the body, with focus moving there. A paste that is only a single line, or a first line plus blank lines, stays in the subject.

What the tests pin, each in a real temporary repository with a staged change, driven through createLocalApp:

  • Empty subject: ctrl+d with an empty or all-spaces subject toasts "a subject is required", leaves HEAD unchanged, and stays on the commit screen.
  • Long subject: 25 wide characters read "0 left". One more (26 characters, 52 columns) reads "2 over the 50-column subject line", the field's bar changes colour, and ctrl+d still commits.
  • Pasted message: a bracketed paste of fix the thing, a blank line, then two body lines commits as fix the thing\n\nbecause it was broken\nand slow. The test compares against git.headMessage, which strips the trailing newline.

I left out the amend path and a body-only paste into the body field.

Approved

Clean. I checked the head (dbce5817) in a scratch copy: bun test ./test/tui-local-commit.test.ts passes 4/4. With src/tui/local/commit.ts set back to main, the paste test fails (the whole message lands in the subject), so the fix is covered by a test that catches the bug. The other two tests pin behaviour that already exists: an empty or all-blank subject is refused and HEAD doesn't move, and the 50-column mark counts display width, not characters.

Security: this is the local client TUI, so it has no identity or write surface on the forge. Pasted text is already sanitized in src/tui/term/input.ts before it gets here, and the split only rearranges text. Nothing is built into a shell command or SQL. The test pins git identity through env and restores it afterwards. It reuses the settle pattern from test/tui-local.test.ts, so the timing approach isn't new. The preview's / answers 200.

Not blocking: nothing asserts that focus moves to the body after a multi-line paste. A follow-up keystroke after the paste would pin that.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs