Repository navigation
fix: open job links on a phone, show a comment's replies in HN's order, and three smaller fixes - #340
Merged
Conversation
On a phone, a direct link to a job, such as #/item/50593679, showed "This item is not a story". The link resolver sent every top-level item to the story viewer, which only takes stories. It now tells stories from jobs and opens a job on the item page, as desktop does. The e2e test that expected the old message now checks for the item page.
A comment's page listed its replies oldest first, the order Algolia's item tree and search return them in, while HN ranks them. The story thread already takes the order from Firebase's kids. The page now sorts the replies it first shows by the comment's own Firebase kids, read once Algolia's item has loaded, so the order settles about 150ms after the replies appear instead of seconds later. Nested replies and flagged ones take HN's order once the story's comments load. That replacement now also happens when it adds no replies, and a thread too big for search is ordered too instead of keeping the item tree.
A plain-text URL in a comment, such as https://en.wikipedia.org/wiki/Foil_(narrative), was linked only up to the "(". The auto-linker now keeps balanced parentheses in a URL and still leaves out a closing one that wraps the whole URL, as in "(see https://...)". An unbalanced "(" inside a URL still ends the link.
A flagged or deleted comment that Algolia 404s is read from Firebase, which has no story id. It took the story from its first reply, so with no replies, as for #/item/234621, its page lost the story link and title. It now walks up the comment's Firebase parent chain to the story, up to 100 levels, and goes without the link only if a read fails.
therealsama
force-pushed
the
fix/phone-job-links-reply-order-url-parens
branch
from
November 22, 2026 00:22
ab85418 to
5143b3b
Compare
…d one On a phone, a feed opens from the stories cached on the last visit and then refreshes them. The refresh keeps every story the reader has reached, including the first one on screen, so an app launched from a cache hours old stayed on a story that may no longer lead the feed. The logo then opened the feed again from the refreshed cache and showed a different first story. Opening a feed now uses its cache only if it is under five minutes old. An older cache waits for the refresh behind the loading skeleton, and is shown if the refresh fails or the app is offline, where the refresh never settles. A story URL shows that story either way, as before. The e2e test for a refresh that lands after a swipe now seeds a minute-old cache, so the feed still opens from it.
…ection A feed opened from a cache over five minutes old waits for the refresh behind the loading skeleton. Firebase waits for a connection with no timeout, and the connection check counts its own timeout as unknown, so on a stalled connection, or with only Firebase blocked, the skeleton stayed for good. The cached stories now show after three seconds, as they did at once before the wait.
therealsama
enabled auto-merge
November 22, 2026 11:04
kplachkov
approved these changes
Nov 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes five bugs: four found while testing against live HN data, and one reported from the app installed on a phone. Each fix is its own commit.
Bug fixes
#/item/50593679led nowhere. It now tells stories from jobs and opens a job on the item page, as desktop does. The e2e test that expected the old message, added in the type refactor 4b36771 with no product reason, now checks for the item page.kids. The page now sorts the replies it first shows by the comment's own Firebasekids, read once Algolia's item has loaded. Nested and flagged replies take HN's order once the story's comments load. With only that second step, the replies on comment 50593925 jumped into place 0.6 to 5.4s after they appeared. With the first read, the order settles about 150ms after first paint. The replacement now also applies when it adds no replies, and a thread too big for search is ordered too.https://en.wikipedia.org/wiki/Foil_(narrative)was linked only up toFoil_. The auto-linker now keeps balanced parentheses. It still leaves out a closing one that wraps the whole URL, as in(see https://…). Worst-case input runs in about 0.2ms, so there's no backtracking risk.#/item/234621, the story link and title were missing. It now walks up the comment's Firebase parent chain to the story, up to 100 levels.Known limitations
https://a.com/a)borhttps://a.com/x(y, now ends the link at that parenthesis, where the old auto-linker linked all of it. This should be rare: HN links nearly every URL itself, and the auto-linker skips those. Of about 2,600 recent comments and posts, one had a URL HN left unlinked, with no parentheses.Testing
Each new test fails with its fix reverted.
npm run typecheck: passednpm run lint: passednpm run test:run: passed, 1191 tests. Each commit also passes typecheck, lint and the unit tests on its own.npm run build: passednpx playwright test --project=chromium --project="Mobile Chrome": 465 passed, 9 skipped