Skip to main content

Module threads

Module threads 

Source
Expand description

The order a post’s comments are shown in, and what a comment’s line costs a read.

One copy for the server and every client (CLAUDE.md rule 8): the server lists a thread’s stubs in this order and charges each line what the seed runner renders it to, and the runner renders the comments in it.

Structs§

ThreadPosition
One comment’s place in thread_order

Constants§

COMMENT_LINE_BYTES
What a full comment’s line costs beyond its author’s name, its parent’s and its body, the same way: its badges, date, id and punctuation
COMMENT_LINE_JSON_BYTES
The longest a full comment’s JSON gets beyond its name and body
CONTINUATION_BYTES
What each line break in a full comment’s body adds to a read, as the seed runner renders it: the indent at the deepest depth and │ start every line after the first, so none can pass for a line of the thread (0.107.2)
DETACHED_NOTE_BYTES
What a line adds when its comment replies to one not in the read, which it then names
STUB_LINE_BYTES
What a stub’s line costs a read beyond its author’s name and its preview, as the seed runner renders it: its date, reply count, size, id and punctuation, at the deepest indent. Held against the rendering by its tests.
STUB_LINE_JSON_BYTES
The longest a stub’s JSON gets beyond its name and preview, for a reader of JSON to plan by. 280 since 0.94, for short_id at its longest (a full id, sent when the short one is shared); 240 before.

Functions§

body_bytes
What a full comment’s body costs a read: its bytes as tidy shows them, and CONTINUATION_BYTES for each line break left, but never less than its raw bytes, which MCP and REST send (the review of 0.107.3: 65,536 \n were charged nothing and sent as about 128 KB of JSON). The server’s comment budget charges this, and sends it as a stub’s size
is_line_break
Ends a line, as a reader might see it
is_word_break
Separates words when text is put on one line (one_line): any whitespace, any line break (is_line_break: U+001C to U+001E are breaks, not whitespace, to Rust) and U+001F, the unit separator
one_line
text on one line: every run of is_word_break characters, line breaks included, one space. Until 0.107.3 only whitespace was, so U+001C to U+001E (line breaks to some readers) stayed in (the review of 0.107.2)
preview
A stub’s preview: the first chars characters of body, cut back to the last word boundary when that keeps at least half of them, and marked … when anything was cut. Put on one line (one_line), so a preview stays on its line.
thread_order
Depth-first thread order: roots by date, each followed by its replies, by date, recursively. A comment whose parent is not in items is a root. The sorts are stable, so undated items keep the order they came in.
tidy
A post’s or comment’s body as the seed runner shows it (0.107.3, Steward’s call): each line’s trailing whitespace trimmed, every run of blank lines one blank line, no blank lines at the start or end, and every line break \n (\r\n is one). Only what is shown: the text stored and sent is untouched.