Repository navigation
Reach discussions inside collapsed details sections #315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
HamptonMakes
merged 4 commits into
block:main
from
ThePumpingLemma:dgrochowski/details-comments
Nov 9, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
87033d1
Reach discussions inside collapsed details sections
ThePumpingLemma de63df5
Cover two discussions on the same line of a collapsed section
ThePumpingLemma b937899
Reveal collapsed source discussion anchors
HamptonMakes 00778d2
Preserve collapsed discussion keyboard focus
HamptonMakes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| // A closed <details> keeps its content in the DOM. Highlights inside it | ||
| // exist, and Chrome even reports client rects for them, but the reader | ||
| // cannot see them. Its <summary> stays visible, so content there is not | ||
| // hidden by its own section. | ||
|
|
||
| function hiddenBy(details, element) { | ||
| return !details.open && !details.querySelector(":scope > summary")?.contains(element) | ||
| } | ||
|
|
||
| function* sections(element) { | ||
| for (let details = element.closest("details"); details; details = details.parentElement?.closest("details")) { | ||
| yield details | ||
| } | ||
| } | ||
|
|
||
| // The outermost closed section hiding the element: the one whose summary | ||
| // the reader can currently see. | ||
| export function hidingSection(element) { | ||
| let hiding = null | ||
| for (const details of sections(element)) if (hiddenBy(details, element)) hiding = details | ||
| return hiding | ||
| } | ||
|
|
||
| // Open every section that hides the element. Returns whether any opened. | ||
| export function revealSections(element) { | ||
| let revealed = false | ||
| for (const details of sections(element)) { | ||
| if (!hiddenBy(details, element)) continue | ||
| details.open = true | ||
| revealed = true | ||
| } | ||
| return revealed | ||
| } |
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| Checkout got slower after the March pricing release. The p95 for `POST /checkout` went from 420 ms to 610 ms. Almost all of the extra time is spent loading discount rules for each line item. Caching the rules per cart brings the p95 back to 430 ms in staging. We plan to ship the cache behind a flag next week. | ||
|
|
||
| The evidence and the options we rejected are in the collapsed sections below. Each closed section shows how many open discussions it hides. Select the count to open the section at its first discussion, or press j to step through every discussion, hidden or not. | ||
|
|
||
| ## Findings | ||
|
|
||
| Slow carts are large carts. Carts with more than 20 line items account for most of the regression, and small carts are unchanged. | ||
|
|
||
| <details> | ||
| <summary>Raw measurements</summary> | ||
|
|
||
| We sampled 50,000 checkout requests from the week before and the week after the release. | ||
|
|
||
| | Cart size | p95 before | p95 after | | ||
| | --- | --- | --- | | ||
| | 1–5 items | 380 ms | 390 ms | | ||
| | 6–20 items | 450 ms | 520 ms | | ||
| | 21+ items | 690 ms | 1,240 ms | | ||
|
|
||
| Each line item runs one discount rule query, so a 40-item cart makes 40 round trips to the pricing database. | ||
|
|
||
| <details> | ||
| <summary>Query plan</summary> | ||
|
|
||
| The rule lookup uses the merchant index but filters item categories in memory, so every query reads all of a merchant's active rules. | ||
|
|
||
| </details> | ||
|
|
||
| Weekend traffic was excluded because a marketing campaign doubled cart sizes on those days. | ||
|
|
||
| </details> | ||
|
|
||
| ## Options | ||
|
|
||
| We compared three ways to remove the repeated lookups. | ||
|
|
||
| <details> | ||
| <summary>Alternatives considered</summary> | ||
|
|
||
| Batching the queries into one request per cart halves the time but still grows with merchant rule count. | ||
|
|
||
| Precomputing prices nightly removes the lookups, but price changes would take up to a day to appear. | ||
|
|
||
| </details> | ||
|
|
||
| ## Plan | ||
|
|
||
| Cache each merchant's active rules for the life of one cart request. Invalidate the cache when a merchant edits a rule. Roll out to 10% of merchants first and compare p95 by cart size. |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.