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

A test pins the terminal's where-strip: every repository screen says where it reads from in plain words, and an origin's host prints inert #6930

Merged opened this

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

Merged

I added `test/tui-where.test.ts` (14 tests) and fixed one hole it found in `hostOf`. `bun x tsc --noEmit` is clean, and the new test plus the existing about, contribute and size tests pass. I did not run the whole check.

shipped production is serving it deploy db542f9

opened this

I added test/tui-where.test.ts (14 tests) and fixed one hole it found in hostOf. bun x tsc --noEmit is clean, and the new test plus the existing about, contribute and size tests pass. I did not run the whole check.

  • The strip: for each of the three sources, exactly one place is marked current. A live origin has a second line that says "reading live from <host> — read-only". A mirror and a native repo have one line. This machine shows ◆ once it is pinned, and a native repo shows no origin place.
  • The other side: otherSide and otherSideLabel name "live on <host>" for a mirror and "the workbench copy" for a live browse that has one. They give nothing for a native repo, an unmirrored browse or a guest.
  • Hostile URLs: an escape sequence or control character in an origin's host or path paints no control byte in the strip, and originKind and hostOf are covered.
  • The hole: hostOf in src/tui/screens/where.ts returned its input when it was not a URL. A web address like \x1b[31m… therefore went into the strip's spans unchanged, and the repo screen's host label would have carried the same text. It now returns "".
  • Callers: the two places that used the full name as a host label when there was no htmlUrl (where.ts and src/tui/screens/contribute.ts:74) now write hostOf(url) || fullName, so their output is unchanged.

I left out the W key and the screens that call these functions; nothing about them changed.

Closes #6909

commented

I added test/tui-where.test.ts (14 tests) and fixed one hole it found in hostOf. bun x tsc --noEmit is clean, and the new test plus the existing about, contribute and size tests pass. I did not run the whole check.

  • The strip: for each of the three sources, exactly one place is marked current. A live origin has a second line that says "reading live from <host> — read-only". A mirror and a native repo have one line. This machine shows ◆ once it is pinned, and a native repo shows no origin place.
  • The other side: otherSide and otherSideLabel name "live on <host>" for a mirror and "the workbench copy" for a live browse that has one. They give nothing for a native repo, an unmirrored browse or a guest.
  • Hostile URLs: an escape sequence or control character in an origin's host or path paints no control byte in the strip, and originKind and hostOf are covered.
  • The hole: hostOf in src/tui/screens/where.ts returned its input when it was not a URL. A web address like \x1b[31m… therefore went into the strip's spans unchanged, and the repo screen's host label would have carried the same text. It now returns "".
  • Callers: the two places that used the full name as a host label when there was no htmlUrl (where.ts and src/tui/screens/contribute.ts:74) now write hostOf(url) || fullName, so their output is unchanged.

I left out the W key and the screens that call these functions; nothing about them changed.

Changes requested — before the latest push

The hostOf fix is right and the tests are well aimed, but the pull claims text a remote sent never reaches the terminal as itself, and that is still false. When hostOf returns "", the callers fall back to link.fullName, which comes from the remote, and src/tui/term/screen.ts does not strip control bytes. An origin that sends a fullName with an escape sequence, and an htmlUrl that is not a URL, still paints it raw in the strip (where.ts places), in otherSideLabel and in contribute.ts originTarget. The hostile-URL test only varies webUrl, so it cannot see this. Fix first: add a test where link.htmlUrl is "" and fullName contains \x1b[2J or \x1b]0;x\x07, then make the fallback inert, for example by stripping C0/C1 control characters from fullName in one shared helper that all three callers use instead of repeating hostOf(...) || fullName. Smaller point: the test regex with the (?=\S*not) lookahead is hard to read. Assert on the absence of any control byte except the intended SGR sequences instead.

commented

I fixed the fallback in the review comment: a remote's fullName with control characters now prints inert in all three places.

  • Fix: hostLabel(htmlUrl, fullName) in src/tui/screens/where.ts replaces the repeated hostOf(...) || fullName. It takes the host, falls back to the full name, then drops C0 and C1 control characters. The strip's origin place, otherSideLabel and originTarget in src/tui/screens/contribute.ts all use it.
  • New test: the mirror's htmlUrl is "" and fullName is octo/\x1b[2Jwidgets or octo/\x1b]0;x\x07widgets. It checks the strip, otherSideLabel, originTarget().host and hostLabel for control bytes.
  • Test readability: the hostile-URL test no longer uses the lookahead regex. It strips the renderer's own ESC [ … m colour sequences from the painted output and asserts no other control byte remains.

bun x tsc --noEmit is clean. The where, about and size tests pass.

I did not check that the new test fails against the old fallback. I expect it would, since the old code painted the raw name.

I left live.origin.webUrl in originTarget's live branch as it was. It already goes through hostOf, which gives "" rather than raw text.

Approved

Approved. The strip, otherSide and otherSideLabel are pinned for a live origin, a mirror, a native repo and a guest. Hostile web addresses and full names now print inert: hostOf returns "" for a non-URL and hostLabel strips C0/C1 bytes from the fallback name. I checked the other hostOf callers (about.ts, contribute.ts live branch); none relied on the old echo-the-input behaviour. The change is terminal-only, so there is no web page to try in the preview. It adds no dependency and no new write path. Next: (1) show that the new full-name test fails against the old fallback by reverting hostLabel locally; the pull says that was not checked. (2) contribute.ts:66 and about.ts:504 still call hostOf(live.origin.webUrl) directly, so a hostile origin gets a blank host there. Use hostLabel with a sensible fallback so it reads as a name, and add a test.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs