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

A detach records the follow mode the fork had #16537

Merged opened this

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

Merged

Most of #16168 was already on main (#16089). src/actions/detach.ts already writes mode into the repo.detached payload, and severedFrom in src/actions/severundo.ts already reads it back as null when absent. The two things still missing were the helper that returns the default with a flag, and a test of that pairing.

Notes

shipped production is serving it deploy f411bbe

opened this

Most of #16168 was already on main (#16089). src/actions/detach.ts already writes mode into the repo.detached payload, and severedFrom in src/actions/sever_undo.ts already reads it back as null when absent. The two things still missing were the helper that returns the default with a flag, and a test of that pairing. I added both.

severedMode(s) in src/actions/sever_undo.ts returns { mode, olderSever }. It gives the recorded mode with olderSever: false, or FORK_DEFAULT_MODE (tell-me) with olderSever: true when the event has no field. I reused severedFrom, isForkFollowMode and FORK_DEFAULT_MODE, and I did not run scripts/similar.ts.

test/fork-detach-mode.test.ts severs a fork in each of the three modes and reads each back. A fourth test strips mode from the event and checks the default comes back flagged as an older sever.

bun x tsc --noEmit is clean and the new test plus fork-rejoin.test.ts pass (8 tests); I did not run the full suite. scripts/gate.ts --fix rewrapped comments in one file, and that rewrap is in the commit.

I left relink as it is. It still tracks modeKnown itself, because the undo path leaves the stored mode untouched when none was recorded, which severedMode cannot express. Nothing user-facing changes.

The pre-push hook refused the push until a commit carried a Try: line, so the branch has an extra empty commit for that. The branch is pushed.

Closes #16168

commented

This pull adds severedMode and its tests; the follow-mode recording was already on main (#16089), so nothing else in the detach path changed. A detach already writes mode into the repo.detached payload (src/actions/detach.ts), and severedFrom already read it back, as null when absent.

What changed

  • severedMode(s) in src/actions/sever_undo.ts returns { mode, olderSever }. It gives the recorded mode with olderSever: false, or FORK_DEFAULT_MODE (tell-me) with olderSever: true when the event has no mode.
  • test/fork-detach-mode.test.ts severs a fork in each of the three modes and reads each back. A fourth test strips mode from the event and checks the default comes back flagged as an older sever.
  • The sever-then-find-the-fork setup was nearly the same in two tests, which the gate flagged. It now lives once in test/helpers/severed-fork.ts, and both test/fork-rejoin.test.ts and the new test use it.

What I chose not to do

  • relink still tracks modeKnown itself, because the undo path leaves the stored mode alone when none was recorded, and severedMode can't express that.
  • No terminal door. severedMode only names what severedFrom already read and shows nothing new, so a commit message carries a "No door:" line saying so. The gate runs on the push; I ran it locally and saw nothing red, but I have not seen its verdict on this push.

Checked here

  • bun x tsc --noEmit is clean.
  • The new test and fork-rejoin.test.ts pass (8 tests); I did not run the full suite.

Try it: bun test test/fork-detach-mode.test.ts

🤖 Generated with Claude Code

commented

severedMode now has a caller, so the dead-code and hollow-work checks that failed on #16537 should pass; I ran both locally and they pass.

relink in src/actions/sever_undo.ts now reads a sever's recorded follow mode through severedMode ({ mode, olderSever }) instead of working it out inline from s.mode. Rejoin and undo behave as before, including leaving the stored mode alone on undo when none was recorded.

The detach path already recorded mode before this pull (#16089). This pull adds the severedMode helper, the tests in test/fork-detach-mode.test.ts, and a shared test/helpers/severed-fork.ts that fork-rejoin.test.ts also uses.

I ran bun x tsc --noEmit (clean), scripts/gate.ts --fix (rewrapped comments in one file earlier; this run printed only a note about unrelated unused exports), and these test files, all green (39 tests):

  • test/fork-detach-mode.test.ts
  • test/fork-rejoin.test.ts
  • test/unused-exports.test.ts
  • test/hollow.test.ts

The full suite was not run here.

No door: the new commit carries a "No door:" line because it only changes how relink reads the mode, so the terminal has nothing new to reach.

Try it: bun test test/fork-detach-mode.test.ts test/fork-rejoin.test.ts

🤖 Generated with Claude Code

Approved

Recording was already on main (detach.ts:122 writes mode into repo.detached). This head adds the helper, gives it a real caller in relink, and tests it: each of the three modes round-trips, and an event with the field stripped gives tell-me flagged as an older sever. The shared test helper removes duplicated setup. No page change, so no door or preview to check. Next: (1) relink's olderSever && !defaultMode ? forkFollowMode(...) : recorded is harder to read than before; a one-line comment on why undo leaves the stored mode alone would help. (2) Add a rejoin test that asserts modeKnown is false for an older sever.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs