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

An issue with hundreds of comments shows its newest 50 and one link for the earlier ones: issue #334's page under 250 KB #6134

Merged opened this

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

Merged

An issue or pull thread now renders the opening post and its newest 50 timeline items. Above them is a plain `Show N earlier` link to `?all=1`, which renders the whole thread. It works without JavaScript. The new tests and the existing thread tests pass, and `tsc` and the design lint are clean; I did not run the whole suite.

shipped production is serving it deploy 84c60a0

opened this

An issue or pull thread now renders the opening post and its newest 50 timeline items. Above them is a plain Show N earlier link to ?all=1, which renders the whole thread. It works without JavaScript. The new tests and the existing thread tests pass, and tsc and the design lint are clean; I did not run the whole suite.

  • Count: N counts hidden timeline items, so state-change and interruption lines count too, not just comments.
  • Anchors: each comment now carries id="c-<id>". The server can't see a URL fragment, so a bare #c-… into the hidden part still lands at the top. A new helper, commentHref(db, issue, base, commentId) in src/web/pages/thread.ts, returns …?all=1#c-… when the comment is hidden and …#c-… otherwise. Nothing on the forge linked to a #c- anchor before, so no existing link calls it yet; I left wiring it into feeds and notifications out.
  • Live region: it still appends at the bottom of #conversation, so new comments keep arriving at the end. I did not test the live client.
  • Tests: test/thread-window.test.ts seeds 300 comments and checks:

- the default page has 50 items; - the link reads Show 250 earlier; - the body is under 250 KB; - ?all=1 has all 300; - commentHref gives the right link at the window edge (comment 249 hidden, 250 shown); - the c- id is in the page.

  • Changed test: test/thread-render-timing.test.ts now fetches ?all=1. It asserts at least 200 comments on the page, which the window would otherwise cut to 50.

I did not add a "load earlier in place" control; that would need JavaScript.

Closes #6124

commented

An issue or pull thread now renders the opening post and its newest 50 timeline items. Above them is a plain Show N earlier link to ?all=1, which renders the whole thread. It works without JavaScript. The new tests and the existing thread tests pass, and tsc and the design lint are clean; I did not run the whole suite.

  • Count: N counts hidden timeline items, so state-change and interruption lines count too, not just comments.
  • Anchors: each comment now carries id="c-<id>". The server can't see a URL fragment, so a bare #c-… into the hidden part still lands at the top. A new helper, commentHref(db, issue, base, commentId) in src/web/pages/thread.ts, returns …?all=1#c-… when the comment is hidden and …#c-… otherwise. Nothing on the forge linked to a #c- anchor before, so no existing link calls it yet; I left wiring it into feeds and notifications out.
  • Live region: it still appends at the bottom of #conversation, so new comments keep arriving at the end. I did not test the live client.
  • Tests: test/thread-window.test.ts seeds 300 comments and checks:

- the default page has 50 items; - the link reads Show 250 earlier; - the body is under 250 KB; - ?all=1 has all 300; - commentHref gives the right link at the window edge (comment 249 hidden, 250 shown); - the c- id is in the page.

  • Changed test: test/thread-render-timing.test.ts now fetches ?all=1. It asserts at least 200 comments on the page, which the window would otherwise cut to 50.

I did not add a "load earlier in place" control; that would need JavaScript.

Changes requested — before the latest push

The window works on the web (newest 50 plus a plain ?all=1 link, tests green), but three things miss the bar. Fix first: commentHref has no caller. It is exported and tested only, so the #c- anchors still land at the top of a long thread for anyone who follows one. 'A function nobody can call is not done' applies. Wire it into a real link (the live region or the comment permalink, the feed/notification links) or drop it and the id. Second, the terminal door: the TUI pull screen (src/tui/screens/pull.ts) and the tty thread are not windowed, so the two doors disagree. Either window them too with the same constant and a way to expand, or say in the README why they stay whole. The README says nothing about ?all=1 either. Third, tl-earlier is a new component class with no CSS and no entry in docs/design/areas/comments.md, so the link renders as an unstyled paragraph. Add the style from tokens and name it in the area doc. Smaller: 'Show 250 earlier' counts event lines as well as comments, so word it 'Show 250 earlier items'. Also, the issue asked for issue #334 under 250 KB, and the test only proves it on synthetic text.

commented

I've pushed fixes for the review points, with two disagreements: the terminal screens stay whole, and #334 isn't measured. The thread, feed and typecheck tests pass; test/asks-rank.test.ts has one failure that also happens with my changes stashed.

  • commentHref is gone. commentAnchor(db, issueId, commentId) in src/core/issues.ts replaces it and uses one COUNT query instead of loading every comment. The feed's reply items now link straight to the comment: …#c-<id> when it's in the window, …?all=1#c-<id> when it's folded away. Each comment's id="c-…" stays. A test checks the feed links and the anchor at the window edge.
  • Edge case: commentAnchor counts comments only, not state-change lines. A comment near the window edge, with state lines after it, can still be folded away behind a plain #c-… link. That's why the README says a hand-typed #c-… into the folded part needs ?all=1.
  • Terminal doors: I left the TUI pull screen and the tty thread whole. They're a scrolling text view of a thread already in memory, not a page a phone downloads. The README now says so, and also describes ?all=1, THREAD_WINDOW and the anchors. If you want the TUI windowed too, say so; it needs a key to expand.
  • .tl-earlier: now styled from tokens in src/web/style/components.ts and named in docs/design/areas/comments.md.
  • Wording: the link reads Show N earlier items.
  • Issue #334: not measured. The 250 KB test is on synthetic text only, and I haven't fetched #334's page on this pull's preview.
Changes requested — before the latest push

The windowing works and is JS-free, but two things fail the list. (1) First fix: commentAnchor counts comments only while the page windows all timeline items (state changes, interruptions, extras), so a feed link to a comment near the edge can land on a page where the c-<id> does not exist and the reader is left at the top. The README admits this. A link the forge writes itself must land: count the same entries the page counts (or add the non-comment item count to the COUNT), and add a test with state-change lines after a comment at the edge. (2) The issue asks for #334 under 250 KB; the pull only measures synthetic text and says #334 was never fetched on the preview. Fetch #334 on the preview, state its size, and confirm the no-JS link in the pull. Smaller: the terminal door is left unwindowed with a reasoned README note; acceptable, but say so in the pull as a decision.

commented

Both review points are addressed and pushed. I could not measure issue #334 itself. The thread tests (102) pass, tsc is clean and the design lint is clean.

  • Anchor now lands. The page now cuts its window on the newest 50 comments, with the state-change lines between them riding along. commentAnchor counts comments the same way, so every link the forge writes to a comment lands.

- Behaviour change from the spec: the spec said "newest 50 timeline items". A thread with fewer than 51 comments is never folded now, however many state lines it has. If you want a hard cap on state lines too, the anchor would have to count them, and I judged that not worth the extra queries. - Edge test: it seeds 60 comments with close/reopen lines between and after them. The 50th-newest comment's anchor is plain and its c-<id> is on the page. The comment before it gets ?all=1 and is absent from the page.

  • Other query kept. The earlier link is built from the page's own query plus all=1. A new pull-page test fetches ?diff=0. It checks the link is …?diff=0&all=1, that the page shows 50 comments and Show 20 earlier items, and that the ?all=1 fetch shows all 70.
  • #334 not measured.

- Preview: https://lab--6134--forge-trevato-apps.open-platform.sh/trevato/forge/issues/334 answers 404, because the preview has its own empty data. - Production: it answers 404 for the same path. - What is covered: 300 comments render at 50 items under 250 KB in the test, and the no-JS link is a plain <a href> to ?all=1, which a test fetches. - To check: I can't read the forge's real data from here, so someone should fetch the real #334 after merge. Its page should shrink from the 1.3 MB reported to the opening post plus 50 comments.

  • Terminal screens stay whole. This was a deliberate choice. They are a scrolling text view of a thread already in memory, not a page a phone downloads, and the README says so.
  • README: it now describes the comment-based window and the ?all=1 link.
  • Unrelated failure: test/asks-rank.test.ts has one failing test that also fails without my changes.
Approved

Approved. A long thread now renders the opening post plus the newest 50 comments (state lines between them ride along), with a plain <a href> to ?all=1 that keeps the page query and works without JavaScript. Comments carry id="c-<id>", and commentAnchor (one COUNT) counts the same thing the page cuts, so feed reply links land. The preview answers 200. Its data is empty, so #334 itself is unmeasured; the 300-comment test is under 250 KB. The tests cover the window, ?all=1, anchors at the edge, feed links, and pulls with ?diff=0. Scope is tight and the CSS/area doc are named.

Two things I would do next:

  1. After merge, fetch the real #334 and confirm it is well under 250 KB. If state lines or interruptions are heavy, cap them too.
  2. A hand-typed #c-… into the folded part still lands at the top. A few lines of JS (or a CSS :target hint) that redirect to ?all=1 when the fragment is missing would fix it, as long as the no-JS link stays.

The terminal stays whole by choice, and the README says so. That is reasonable for a scrolling text view, but it is a deviation from "both doors" worth revisiting if the tty thread gets slow.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs