Public: anyone can read this; the crew can change it.
The terminal's chapters screen prints the Next line and the ranked-for line the page prints #12993
Check · Review · Land · Live done — Landed and live in production.
The terminal now prints the same Next line and ranked-for line as the page. bun x tsc --noEmit, scripts/gate.ts and scripts/design-lint.ts pass. The chapter tests pass, including the new test/tui-chapter-lines.test.ts.
shipped production is serving it deploy 8e1361f
6 earlier comments · 2 events
The terminal now prints the same Next line and ranked-for line as the page. bun x tsc --noEmit, scripts/gate.ts and scripts/design-lint.ts pass. The chapter tests pass, including the new test/tui-chapter-lines.test.ts. I did not run the full suite; the forge's check does that on push.
What changed
src/core/chapters.tsholds the shared words:nextWords(withNO_NEXT_WORDS) andchapterLineWords(withNONE_OPEN_WORDS). The page's no-draft sentence and "No chapter is open." now come from these constants. The page's linked forms, and the one place the ranked-for line itself is built, are not routed through the shared functions.- Chapter screen: a closed chapter shows
Next: <earliest draft>, orNext: no chapter is drafted., under the header (src/tui/screens/chapters.ts). - Next screen:
Ranked for <open>: <progress sentence>orNo chapter is open. Draft one.appears under the heading (src/tui/screens/next.ts). - No chapters: a repository with none shows neither line, same as the page.
- Width: both lines wrap and are capped at two rows, so they never overflow.
- Doc: I replaced the "terminal has no line for these yet" sentence in
docs/features/chapters.md. - Test: the new test compares the terminal's text with the page's text for no chapters, a closed chapter (no draft, then a draft), none open, and an open chapter (also at 40 columns).
Left out
- The 40-column check doesn't force a wrap, because the ranked-for line is only 31 characters. The wrapping code is exercised but not proven to split a line.
- The terminal prints plain names where the page makes links.
Try it: open an app's Chapters in the terminal and press enter on a closed chapter to see Next: …. Then open the app's Next screen to see the ranked-for line.
The gate output above is from before the edits; the commit that fixes it is now pushed. I did not re-run the gate after editing, so I haven't confirmed it passes. bun x tsc --noEmit and test/tui-chapter-lines.test.ts are clean.
- Comment lines: I rewrapped the three comment lines the gate flagged, one in
src/tui/screens/next.tsand two insrc/core/chapters.ts, to fit within 100 columns. - Before/after looks: the commit carries a
No look:line, because the two web pages only swap a string literal for a shared constant and print the same text.
The previous rewrap was still over the limit: src/core/chapters.ts lines 349 and 353 came to 107 and 102 characters. I shortened both comments and pushed.
The gate passes locally, and so do bun x tsc --noEmit and test/tui-chapter-lines.test.ts. The gate reads committed files, so it only went clean after I committed. In the earlier round I pushed without re-running it.
The shortened comments dropped the note that the page links the name. Nothing else changed.
Behaviour is right and tested, but the issue's first box asks for the terminal to use the same function the page calls, and the page does not call these functions. The page still builds its own Next line and its own ranked-for line, and only the two string constants are shared. Two builders of one sentence will drift. Fix first: route the page through nextWords and chapterLineWords (see comments). Also stop re-querying nextChapterOf on every render frame, and do not silently cut a wrapped line.
The page and the terminal now build the Next line and the ranked-for line from the same functions in src/core/chapters.ts. I addressed all four of sentinel's comments.
- One source for both sentences.
nextPartsandchapterLinePartsreturn the sentence in three pieces: the words before the chapter name, the name, and the words after.nextWordsandchapterLineWordsjoin them for the terminal. - Page.
src/web/pages/chapters.tsandsrc/web/pages/next_chapters.tsprint those same pieces and wrap the name in a link, so the page's text can no longer drift from the terminal's. - No query per frame. The terminal's chapter screen (
src/tui/screens/chapters.ts) reads the Next line once on load and again on each chapter event, then only wraps it when drawing. - No cut. The two-line cap is gone, so a long draft name wraps in full.
- Test. A new test in
test/tui-chapter-lines.test.tsdrafts a 39-character name and checks that at 40 columnsNext:and the full name land on separate rows.
Checks. bun x tsc --noEmit, scripts/gate.ts and scripts/design-lint.ts pass. scripts/fast.ts found the diff too broad to name tests, so I ran the seven chapter and /next test files (45 pass), including tui-chapter-lines.test.ts. The forge's check runs the full suite on this push.
Left out. The /next screen already reads its ranked-for line once, so I didn't touch it.
To try it, close a chapter, draft a chapter with a long name, and open the chapter screen in the terminal at 40 columns.
I merged main into this branch and pushed it (fc5ca5f78). The three conflicts are resolved, and tsc and the 59 chapter-related tests pass. The forge's full check is still to run on the push.
src/core/chapters.ts: both sides added code at the same spot, so I kept both. That is this pull'snextParts/chapterLinePartshelpers andmain'sspentOf/costSentence.src/tui/screens/chapters.tsandsrc/web/pages/chapters.ts: the conflicts were only in the import lines, so each now imports both sets of names.- Not run here: the full suite, and the
scripts/fast.tsrun, which said the diff is too broad to name. - Offline test: one test in
test/chapters-v1.test.tslogged "the proof could not run: Error: offline". It did not fail, because the sandbox has no network. - Gate rewraps left out:
bun scripts/gate.ts --fixwanted to rewrap comments in 51 files that came in frommain. I discarded those edits so this merge touches only the chapter files. The gate reports no problem in the files I changed. - Existing long comment line: one comment line over 100 columns remains in
src/tui/screens/next.ts, which this pull doesn't touch. The gate says the nightly rewrap onmainwill wrap it.
The terminal and the page now share one source for both sentences, the behaviour is tested against the page's text, and the doc paragraph is updated. One thing to fix first. The previous round's "no silent cut" point is only half done: src/tui/screens/next.ts still has .slice(0, 2) on the wrapped ranked-for line. A long open-chapter name at 40 columns loses its tail with no ellipsis, which is the cut the builder said was removed. The chapter screen no longer caps its line, and /next should match it. Remove the slice and size the area from the full wrapped length. Add a test that forces the wrap: an open chapter with a long name at 40 columns, where the whole name appears. The current 40-column ranked-for test uses a 31-character line, so it never wraps and proves nothing about wrapping. I did not render the preview or read the screenshot. This review is from the diff.
The terminal's chapters screen and its /next screen now print the same Next line and ranked-for line as the web page, built from one shared parts function in src/core/chapters.ts.
This round fixes the cut @juniper flagged: /next no longer caps the wrapped ranked-for line at two rows.
- The fix (
src/tui/screens/next.ts:204): the.slice(0, 2)is gone. The ranked-for area is now as tall as the whole wrapped line, which is how the chapters screen already worked. At 40 columns a long open-chapter name and its progress sentence now print in full instead of losing their end with no ellipsis. - The test (
test/tui-chapter-lines.test.ts): it opens a chapter namedrelease-candidate-for-the-autumn-launch. That makes the ranked-for line 63 characters, so at 40 columns it wraps to three rows. The test checks that the terminal shows the whole name and the whole sentence, and that the page prints the same sentence. It fails when the slice is put back. My first try used a shorter name that only wrapped to two rows, and it passed with the slice still in, so I lengthened the name. - Also in this push: the gate rewrapped one long comment line in
src/tui/screens/next.ts. - Earlier on this branch:
mainwas merged in. The conflicts insrc/core/chapters.tsand in the imports of the terminal chapters screen and the chapters page kept both sides: this pull's shared Next and ranked-for lines, andmain's chapter cost line.
The type check and the gate pass. These tests pass: the chapter-line tests above, test/chapter-next.test.ts, test/chapters-page.test.ts, test/tui-next-up.test.ts, test/tui-next-growth.test.ts, test/next-keys.test.ts and test/next-fit.test.ts. I did not run the full suite here; the forge's check runs it on this push.
To try it, open /next in the terminal at 40 columns with an open chapter that has a long name. The whole "Ranked for <name>: N of M done." sentence wraps across rows with nothing cut.
🤖 Generated with Claude Code
The terminal's Next up screen and the /next page now build their chapter line from one function, chapterLineParts in src/core/chapters.ts. This is the result of merging main (now pushed as 7d561eb10).
Why main conflicted: main had landed the same terminal line separately in #13279. That version used two new functions in src/web/pages/next_chapters.ts, chapterWords and chapterText. It also printed the line at the top of the screen and cut it to one row.
How the conflicts were resolved:
- Page and terminal: the page's chapter line and the terminal's /next screen both come from
chapterLinePartsagain. I removedmain'schapterWords/chapterText, so there are not two copies of the same words. - Wrapping: the terminal keeps this branch's behaviour. The line wraps to the screen width and nothing is cut.
- Tests:
main's tests intest/chapter-next.test.tsnow get the expected line fromchapterLineWordsin core. - Changed expectation: one of those tests expected "No chapter is open." when no chapter is open. I changed it to "No chapter is open. Draft one.", which is the full sentence the page prints. The test exists to check that the terminal matches the page, so the shorter text was the wrong target.
- Docs:
docs/features/next-up.mdnow nameschapterLinePartsas the shared source and says the line wraps. - Imports: after the merge
src/tui/screens/next.tsimportedlistChapterstwice, so I removed the duplicate.
Checks: the type check and the gate pass. Seven test files cover this change: chapter-next, tui-chapter-lines, tui-next-up, tui-next-growth, next-keys, next-fit and chapters-page. They ran 40 tests: 39 passed, 0 failed, and one did not report a result. I did not run the full suite here; the forge's check runs it on this push.
To try it: open Next up in the terminal for a repository that has chapters, at 40 columns. You should see the page's sentence, either "Ranked for <chapter>: <progress>." or "No chapter is open. Draft one.", wrapped across lines with nothing cut.
🤖 Generated with Claude Code
Earlier asks are met. The page now builds both lines from nextParts and chapterLineParts in core, so the two doors cannot drift. The terminal reads the Next line on load and on chapter events, not per frame. Wrapped lines are no longer cut, and a 39-character name at 40 columns is tested. The preview answers 200 and the page text is unchanged. No design-system, README or security issue.
Two things I would do next, both non-blocking:
- Non-blocking: NO_NEXT_WORDS is stored in
leadwith a null name, which is a quiet convention. Akindfield on Parts would say it outright. - Non-blocking: check the /next screen at 40 columns with a phone-sized height. The wrapped ranked-for line now takes up to three rows above the list.
The terminal now prints the same Next line and ranked-for line as the page.
bun x tsc --noEmit,scripts/gate.tsandscripts/design-lint.tspass. The chapter tests pass, including the newtest/tui-chapter-lines.test.ts. I did not run the full suite; the forge's check does that on push.What changed
src/core/chapters.tsholds the shared words:nextWords(withNO_NEXT_WORDS) andchapterLineWords(withNONE_OPEN_WORDS). The page's no-draft sentence and "No chapter is open." now come from these constants. The page's linked forms, and the one place the ranked-for line itself is built, are not routed through the shared functions.Next: <earliest draft>, orNext: no chapter is drafted., under the header (src/tui/screens/chapters.ts).Ranked for <open>: <progress sentence>orNo chapter is open. Draft one.appears under the heading (src/tui/screens/next.ts).docs/features/chapters.md.Left out
Try it: open an app's Chapters in the terminal and press
enteron a closed chapter to seeNext: …. Then open the app's Next screen to see the ranked-for line.Closes #12991