Public: anyone can read this; the crew can change it.
A detach records the follow mode the fork had #16537
Check · Review · Land · Live done — Landed and live in production.
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.
shipped production is serving it deploy f411bbe
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)insrc/actions/sever_undo.tsreturns{ mode, olderSever }. It gives the recorded mode witholderSever: false, orFORK_DEFAULT_MODE(tell-me) witholderSever: truewhen the event has nomode.test/fork-detach-mode.test.tssevers a fork in each of the three modes and reads each back. A fourth test stripsmodefrom 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 bothtest/fork-rejoin.test.tsand the new test use it.
What I chose not to do
relinkstill tracksmodeKnownitself, because the undo path leaves the stored mode alone when none was recorded, andseveredModecan't express that.- No terminal door.
severedModeonly names whatseveredFromalready 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 --noEmitis clean.- The new test and
fork-rejoin.test.tspass (8 tests); I did not run the full suite.
Try it: bun test test/fork-detach-mode.test.ts
🤖 Generated with Claude Code
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.tstest/fork-rejoin.test.tstest/unused-exports.test.tstest/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
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.
Most of #16168 was already on main (#16089).
src/actions/detach.tsalready writesmodeinto therepo.detachedpayload, andseveredFrominsrc/actions/sever_undo.tsalready reads it back asnullwhen 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)insrc/actions/sever_undo.tsreturns{ mode, olderSever }. It gives the recorded mode witholderSever: false, orFORK_DEFAULT_MODE(tell-me) witholderSever: truewhen the event has no field. I reusedseveredFrom,isForkFollowModeandFORK_DEFAULT_MODE, and I did not runscripts/similar.ts.test/fork-detach-mode.test.tssevers a fork in each of the three modes and reads each back. A fourth test stripsmodefrom the event and checks the default comes back flagged as an older sever.bun x tsc --noEmitis clean and the new test plusfork-rejoin.test.tspass (8 tests); I did not run the full suite.scripts/gate.ts --fixrewrapped comments in one file, and that rewrap is in the commit.I left
relinkas it is. It still tracksmodeKnownitself, because the undo path leaves the stored mode untouched when none was recorded, whichseveredModecannot 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