Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| Last commits read trees two dozen commits at a time, and the file list waits at most 3 s for them | 1 | /** |
| 2 | * Each entry's last commit for the file list, waited on only so long. An | |
| 3 | * answer not yet kept walks history, which can take seconds on a large or | |
| 4 | * busy repository; the page goes out without it then, the column empty, | |
| 5 | * while the walk finishes in the background (waitUntil) so the next view | |
| 6 | * has it from the cache. The page's stream never waits on it past its own | |
| 7 | * timeout. | |
| 8 | */ | |
| 9 | import { waitUntil } from "cloudflare:workers"; | |
| 10 | ||
| Commits show their accounts, and every name opens a card (repos 0016) | 11 | import type { RepoPath, Viewer } from "@g1t/contracts"; |
| Last commits read trees two dozen commits at a time, and the file list waits at most 3 s for them | 12 | |
| Commits show their accounts, and every name opens a card (repos 0016) | 13 | import type { FileCommits } from "./commit-people"; |
| Last commits read trees two dozen commits at a time, and the file list waits at most 3 s for them | 14 | import { repos } from "./services.server"; |
| 15 | ||
| 16 | /** How long the page waits for the column. */ | |
| 17 | const WAIT_MS = 3_000; | |
| 18 | ||
| Commits show their accounts, and every name opens a card (repos 0016) | 19 | export function lastCommitsFor(path: RepoPath, viewer: Viewer, ref: string | null, treePath: string): Promise<FileCommits | null> { |
| Last commits read trees two dozen commits at a time, and the file list waits at most 3 s for them | 20 | const walk = repos |
| 21 | .lastCommits(path, viewer, ref, treePath) | |
| Commits show their accounts, and every name opens a card (repos 0016) | 22 | // The rows show a commit's subject and age, never who made it: their |
| 23 | // addresses stay on the server. | |
| 24 | .then((found): FileCommits | null => | |
| 25 | found.ok | |
| 26 | ? { | |
| 27 | complete: found.value.complete, | |
| 28 | entries: found.value.entries.map(({ name, commit }) => ({ | |
| 29 | name, | |
| 30 | commit: { hash: commit.hash, message: commit.message, authoredAt: commit.authoredAt }, | |
| 31 | })), | |
| 32 | } | |
| 33 | : null, | |
| 34 | ) | |
| Last commits read trees two dozen commits at a time, and the file list waits at most 3 s for them | 35 | .catch(() => null); |
| 36 | waitUntil(walk); | |
| 37 | return Promise.race([walk, new Promise<null>((resolve) => setTimeout(() => resolve(null), WAIT_MS))]); | |
| 38 | } |