ref0-git 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (210) hide show
  1. package/app/apps/github/.dev.vars.example +2 -1
  2. package/app/apps/github/generated/git-rest.ts +191 -25
  3. package/app/apps/github/generated/routeTree.gen.ts +21 -0
  4. package/app/apps/github/package.json +1 -1
  5. package/app/apps/github/src/branches/branch-list.tsx +8 -4
  6. package/app/apps/github/src/branches/branches.ts +10 -5
  7. package/app/apps/github/src/camo/addresses.ts +120 -0
  8. package/app/apps/github/src/camo/client.ts +125 -0
  9. package/app/apps/github/src/camo/fetch.ts +201 -0
  10. package/app/apps/github/src/camo/lookup.ts +23 -0
  11. package/app/apps/github/src/camo/node.ts +50 -0
  12. package/app/apps/github/src/camo/proxy.ts +116 -0
  13. package/app/apps/github/src/camo/sign-images.ts +307 -0
  14. package/app/apps/github/src/camo/signing.ts +80 -0
  15. package/app/apps/github/src/clients/allowed.ts +111 -18
  16. package/app/apps/github/src/clients/clients.ts +76 -61
  17. package/app/apps/github/src/clients/transport.ts +13 -0
  18. package/app/apps/github/src/code/code-tree.tsx +3 -1
  19. package/app/apps/github/src/code/file-view.tsx +15 -6
  20. package/app/apps/github/src/code/files.ts +26 -19
  21. package/app/apps/github/src/code/go-to-file.tsx +2 -1
  22. package/app/apps/github/src/code/load.ts +41 -23
  23. package/app/apps/github/src/code/markdown-files.ts +13 -2
  24. package/app/apps/github/src/code/ref-pages.ts +14 -5
  25. package/app/apps/github/src/code/ref-switcher.tsx +4 -3
  26. package/app/apps/github/src/code/refs.ts +42 -8
  27. package/app/apps/github/src/code/repo-home.tsx +6 -2
  28. package/app/apps/github/src/code/repo.ts +12 -6
  29. package/app/apps/github/src/code/saved.ts +5 -3
  30. package/app/apps/github/src/code/trees.ts +11 -9
  31. package/app/apps/github/src/components/markdown/markdown.css +6 -0
  32. package/app/apps/github/src/components/markdown/markdown.tsx +95 -10
  33. package/app/apps/github/src/components/owner-card.tsx +3 -1
  34. package/app/apps/github/src/components/repos/your-repos.tsx +3 -1
  35. package/app/apps/github/src/components/shell/owner-repos.tsx +7 -12
  36. package/app/apps/github/src/components/shell/repo-switcher.tsx +10 -16
  37. package/app/apps/github/src/components/signin/device-card.tsx +9 -2
  38. package/app/apps/github/src/components/user-avatar.tsx +2 -1
  39. package/app/apps/github/src/context/context.ts +13 -0
  40. package/app/apps/github/src/diffs/blobs.ts +37 -14
  41. package/app/apps/github/src/diffs/diff-job.ts +53 -0
  42. package/app/apps/github/src/diffs/diff-worker.ts +6 -0
  43. package/app/apps/github/src/diffs/diffing.ts +136 -0
  44. package/app/apps/github/src/diffs/files.ts +4 -3
  45. package/app/apps/github/src/diffs/hunks.tsx +101 -53
  46. package/app/apps/github/src/diffs/patch.ts +20 -11
  47. package/app/apps/github/src/history/commit-diff.ts +10 -5
  48. package/app/apps/github/src/history/commit-list.tsx +3 -1
  49. package/app/apps/github/src/history/commit-page.tsx +4 -2
  50. package/app/apps/github/src/history/history.ts +12 -10
  51. package/app/apps/github/src/hooks/allowed.ts +9 -9
  52. package/app/apps/github/src/hooks/avatars.ts +3 -3
  53. package/app/apps/github/src/hooks/open-counts.ts +5 -4
  54. package/app/apps/github/src/hooks/profiles.ts +26 -12
  55. package/app/apps/github/src/hooks/repos.ts +78 -25
  56. package/app/apps/github/src/inbox/count.ts +30 -29
  57. package/app/apps/github/src/inbox/inbox-item.tsx +3 -1
  58. package/app/apps/github/src/inbox/inbox-page.tsx +5 -2
  59. package/app/apps/github/src/inbox/marks.ts +26 -15
  60. package/app/apps/github/src/inbox/release-tags.ts +7 -6
  61. package/app/apps/github/src/inbox/subjects.ts +5 -4
  62. package/app/apps/github/src/inbox/subscription-controls.tsx +14 -5
  63. package/app/apps/github/src/inbox/subscriptions.ts +95 -35
  64. package/app/apps/github/src/inbox/threads.ts +6 -6
  65. package/app/apps/github/src/issues/changes.ts +40 -16
  66. package/app/apps/github/src/issues/counts.ts +8 -5
  67. package/app/apps/github/src/issues/issue-list.tsx +20 -6
  68. package/app/apps/github/src/issues/issue-page.tsx +30 -14
  69. package/app/apps/github/src/issues/issues.ts +195 -46
  70. package/app/apps/github/src/issues/label-dialog.tsx +8 -11
  71. package/app/apps/github/src/issues/labels-page.tsx +35 -3
  72. package/app/apps/github/src/issues/milestone-dialog.tsx +197 -0
  73. package/app/apps/github/src/issues/milestones-page.tsx +269 -0
  74. package/app/apps/github/src/issues/new-issue.tsx +3 -1
  75. package/app/apps/github/src/issues/sidebar.tsx +8 -6
  76. package/app/apps/github/src/markdown/README.md +22 -17
  77. package/app/apps/github/src/markdown/context.ts +83 -10
  78. package/app/apps/github/src/markdown/images.ts +3 -2
  79. package/app/apps/github/src/markdown/lookup.ts +9 -8
  80. package/app/apps/github/src/markdown/page-budget.ts +50 -0
  81. package/app/apps/github/src/markdown/patches.ts +74 -32
  82. package/app/apps/github/src/markdown/query.ts +7 -2
  83. package/app/apps/github/src/markdown/remote.ts +106 -0
  84. package/app/apps/github/src/markdown/render.ts +101 -24
  85. package/app/apps/github/src/markdown/texts.ts +43 -0
  86. package/app/apps/github/src/markdown/words-module.d.ts +5 -0
  87. package/app/apps/github/src/markdown/words-plugin.ts +135 -0
  88. package/app/apps/github/src/names/repos.ts +1 -1
  89. package/app/apps/github/src/palette/palette.tsx +7 -4
  90. package/app/apps/github/src/palette/rows.tsx +54 -33
  91. package/app/apps/github/src/palette/server.ts +5 -5
  92. package/app/apps/github/src/palette/targets.ts +1 -0
  93. package/app/apps/github/src/policy.ts +131 -61
  94. package/app/apps/github/src/private-repos.ts +2 -2
  95. package/app/apps/github/src/pulls/compare-page.tsx +6 -3
  96. package/app/apps/github/src/pulls/files-tab.tsx +480 -214
  97. package/app/apps/github/src/pulls/held-summary.ts +178 -0
  98. package/app/apps/github/src/pulls/live.ts +6 -4
  99. package/app/apps/github/src/pulls/merge-box.tsx +17 -10
  100. package/app/apps/github/src/pulls/pull-list.tsx +6 -3
  101. package/app/apps/github/src/pulls/pull-page.tsx +19 -10
  102. package/app/apps/github/src/pulls/pull.ts +68 -40
  103. package/app/apps/github/src/pulls/pulls.ts +39 -22
  104. package/app/apps/github/src/pulls/review-drafts.ts +131 -0
  105. package/app/apps/github/src/pulls/review.ts +374 -99
  106. package/app/apps/github/src/pulls/threads.tsx +152 -0
  107. package/app/apps/github/src/queue/queue-page.tsx +15 -8
  108. package/app/apps/github/src/queue/queue.ts +35 -20
  109. package/app/apps/github/src/releases/latest-release.tsx +3 -1
  110. package/app/apps/github/src/releases/overview.tsx +4 -2
  111. package/app/apps/github/src/releases/release-form.tsx +8 -5
  112. package/app/apps/github/src/releases/release-list.tsx +8 -5
  113. package/app/apps/github/src/releases/release-view.tsx +1 -0
  114. package/app/apps/github/src/releases/releases.ts +33 -23
  115. package/app/apps/github/src/releases/tag-list.tsx +3 -1
  116. package/app/apps/github/src/router.tsx +5 -2
  117. package/app/apps/github/src/routes/$owner/$repo/_code/blob/$.tsx +7 -1
  118. package/app/apps/github/src/routes/$owner/$repo/_code/tree/$.tsx +6 -1
  119. package/app/apps/github/src/routes/$owner/$repo/_releases/releases/index.tsx +2 -1
  120. package/app/apps/github/src/routes/$owner/$repo/_releases/tags.tsx +1 -1
  121. package/app/apps/github/src/routes/$owner/$repo/branches.tsx +5 -1
  122. package/app/apps/github/src/routes/$owner/$repo/commit/$sha.tsx +1 -1
  123. package/app/apps/github/src/routes/$owner/$repo/commits/$.tsx +6 -1
  124. package/app/apps/github/src/routes/$owner/$repo/index.tsx +1 -1
  125. package/app/apps/github/src/routes/$owner/$repo/issues/$number.tsx +4 -2
  126. package/app/apps/github/src/routes/$owner/$repo/issues/index.tsx +2 -2
  127. package/app/apps/github/src/routes/$owner/$repo/issues/new.tsx +5 -2
  128. package/app/apps/github/src/routes/$owner/$repo/labels.tsx +2 -1
  129. package/app/apps/github/src/routes/$owner/$repo/milestones.tsx +36 -0
  130. package/app/apps/github/src/routes/$owner/$repo/pull/$number/route.tsx +4 -2
  131. package/app/apps/github/src/routes/$owner/$repo/pulls/index.tsx +2 -2
  132. package/app/apps/github/src/routes/$owner/$repo/queue.tsx +2 -1
  133. package/app/apps/github/src/routes/$owner/$repo/releases/edit/$.tsx +5 -2
  134. package/app/apps/github/src/routes/$owner/$repo/releases/new.tsx +2 -1
  135. package/app/apps/github/src/routes/$owner/$repo/releases/tag/$.tsx +4 -2
  136. package/app/apps/github/src/routes/$owner/$repo/route.tsx +9 -5
  137. package/app/apps/github/src/routes/$owner/$repo/settings/hooks/index.tsx +3 -1
  138. package/app/apps/github/src/routes/$owner/$repo/settings/index.tsx +3 -1
  139. package/app/apps/github/src/routes/-nav.tsx +10 -2
  140. package/app/apps/github/src/routes/-root-testing.ts +29 -6
  141. package/app/apps/github/src/routes/__root.tsx +9 -4
  142. package/app/apps/github/src/routes/index.tsx +3 -1
  143. package/app/apps/github/src/routes/orgs/$owner/route.tsx +4 -1
  144. package/app/apps/github/src/routes/orgs/$owner/settings.tsx +4 -1
  145. package/app/apps/github/src/seed/acme.ts +1 -1
  146. package/app/apps/github/src/seed/seed.ts +199 -110
  147. package/app/apps/github/src/server.ts +24 -15
  148. package/app/apps/github/src/settings/account-avatar.tsx +4 -1
  149. package/app/apps/github/src/settings/general-settings.tsx +3 -1
  150. package/app/apps/github/src/settings/general.ts +4 -4
  151. package/app/apps/github/src/settings/hook-form.tsx +3 -1
  152. package/app/apps/github/src/settings/hook-list.tsx +5 -2
  153. package/app/apps/github/src/settings/hooks.ts +7 -7
  154. package/app/apps/github/src/settings/org-settings.tsx +3 -1
  155. package/app/apps/github/src/settings/orgs.ts +21 -11
  156. package/app/apps/github/src/settings/settings-layout.tsx +3 -1
  157. package/app/apps/github/src/signin/approval.ts +4 -3
  158. package/app/apps/github/src/signin/auth.ts +9 -2
  159. package/app/apps/github/src/signin/device-code.ts +8 -3
  160. package/app/apps/github/src/signin/device-prompt.ts +28 -3
  161. package/app/apps/github/src/signin/revoke.ts +36 -0
  162. package/app/apps/github/tsconfig.json +4 -1
  163. package/app/apps/github/vite.config.ts +8 -0
  164. package/app/pnpm-workspace.yaml +9 -5
  165. package/app/tsconfig.base.json +1 -0
  166. package/dist/cli/child.mjs +1 -1
  167. package/dist/cli/credentials.mjs +4 -4
  168. package/dist/cli/documents.mjs +32 -22
  169. package/dist/cli/events.mjs +1 -1
  170. package/dist/cli/failure.mjs +20 -7
  171. package/dist/cli/folders.mjs +2 -2
  172. package/dist/cli/git-remote-ref0.mjs +47 -22
  173. package/dist/cli/git.mjs +1 -1
  174. package/dist/cli/helpers.mjs +2 -2
  175. package/dist/cli/hosts.mjs +3 -3
  176. package/dist/cli/output.mjs +2 -2
  177. package/dist/cli/prompt.mjs +1 -1
  178. package/dist/cli/queue.mjs +7 -7
  179. package/dist/cli/ref0-git.mjs +2 -2
  180. package/dist/cli/repos.mjs +35 -18
  181. package/dist/cli/resources.mjs +5 -5
  182. package/dist/cli/retry-after.mjs +8 -0
  183. package/dist/cli/setup.mjs +172 -66
  184. package/dist/cli/sign-in.mjs +65 -23
  185. package/dist/cli/sign-ins.mjs +4 -4
  186. package/dist/cli/sqlite.mjs +2 -2
  187. package/dist/cli/tokens.mjs +3 -3
  188. package/dist/cli/vendor.mjs +1 -1
  189. package/dist/init/app.mjs +18 -20
  190. package/dist/init/choices.mjs +1 -1
  191. package/dist/init/cloudflare.mjs +15 -19
  192. package/dist/init/create.mjs +3 -2
  193. package/dist/init/detect.mjs +4 -4
  194. package/dist/init/files.mjs +120 -13
  195. package/dist/init/frameworks.mjs +16 -0
  196. package/dist/init/git-module.mjs +22 -7
  197. package/dist/init/jsonc.mjs +9 -7
  198. package/dist/init/metadata.mjs +9 -3
  199. package/dist/init/mounts.mjs +13 -10
  200. package/dist/init/next.mjs +2 -2
  201. package/dist/init/node-app.mjs +3 -3
  202. package/dist/init/node.mjs +42 -45
  203. package/dist/init/nuxt.mjs +153 -27
  204. package/dist/init/stores.mjs +14 -9
  205. package/dist/init/sveltekit.mjs +4 -2
  206. package/dist/init/template.mjs +9 -6
  207. package/dist/init/templates.mjs +63 -47
  208. package/dist/init/vercel.mjs +37 -37
  209. package/dist/init/versions.mjs +3 -3
  210. package/package.json +6 -5
@@ -3,6 +3,7 @@ import { FileTextIcon, GitCommitIcon, PackageIcon, TagIcon } from 'lucide-react'
3
3
  import { useState } from 'react';
4
4
 
5
5
  import { Go } from '../code/controls.tsx';
6
+ import { useClients } from '../clients/clients.ts';
6
7
  import { releaseHref, type RepoPlace } from '../code/places.ts';
7
8
  import { More } from '../components/item-list.tsx';
8
9
  import { RelativeTime } from '../components/relative-time.tsx';
@@ -78,7 +79,8 @@ function TagRow({ place, tag }: { readonly place: RepoPlace; readonly tag: Tag }
78
79
 
79
80
  /** The repo's tags, newest version first, 10 a page. */
80
81
  export function TagList({ place }: { readonly place: RepoPlace }) {
81
- const tags = useQuery(tagsOf(place));
82
+ const clients = useClients();
83
+ const tags = useQuery(tagsOf(clients, place));
82
84
  const [shown, setShown] = useState(tagsPerPage);
83
85
  const all = tags.data?.tags ?? [];
84
86
  // The page has read every tag it orders, so More shows the next 10 of those, as the lists' does.
@@ -3,6 +3,8 @@ import { createRouter } from '@tanstack/react-router';
3
3
  import { setupRouterSsrQueryIntegration } from '@tanstack/react-router-ssr-query';
4
4
 
5
5
  import { routeTree } from '../generated/routeTree.gen.ts';
6
+ import { createClients } from './clients/clients.ts';
7
+ import { serverTransport } from './clients/transport.ts';
6
8
 
7
9
  /**
8
10
  * How long a read with no `staleTime` of its own is trusted, as long as the lists are: a page
@@ -13,13 +15,14 @@ const freshFor = 10_000;
13
15
  /**
14
16
  * A router, with a QueryClient of its own: each server request gets one, so no data is shared.
15
17
  * The server's page sends the queries its loaders read, and the browser starts from them, so it
16
- * draws what the server drew rather than a page still loading.
18
+ * draws what the server drew rather than a page still loading. Its clients send every call
19
+ * through Start's server functions, on the server as in the browser.
17
20
  */
18
21
  export function getRouter() {
19
22
  const queryClient = new QueryClient({ defaultOptions: { queries: { staleTime: freshFor } } });
20
23
  const router = createRouter({
21
24
  routeTree,
22
- context: { queryClient },
25
+ context: { queryClient, clients: createClients(serverTransport) },
23
26
  scrollRestoration: true,
24
27
  // A link's page loads ahead on intent, a pointer resting 50 ms, and each preload runs its
25
28
  // loaders, whose reads the Query cache keeps for their own `staleTime`s, so the router keeps
@@ -13,7 +13,13 @@ export const Route = createFileRoute('/$owner/$repo/_code/blob/$')({
13
13
  validateSearch: plainOf,
14
14
  loaderDeps: ({ search }) => ({ plain: search.plain === 1 }),
15
15
  loader: async ({ params, context, deps }) => {
16
- const load = await loadFile(context.queryClient, params, params._splat ?? '', deps.plain);
16
+ const load = await loadFile(
17
+ context.clients,
18
+ context.queryClient,
19
+ params,
20
+ params._splat ?? '',
21
+ deps.plain,
22
+ );
17
23
  if (load === undefined) throw notFound();
18
24
 
19
25
  return { ...load, plain: deps.plain };
@@ -7,7 +7,12 @@ import { LoadFailed } from '../../../../../components/states/states.tsx';
7
7
 
8
8
  export const Route = createFileRoute('/$owner/$repo/_code/tree/$')({
9
9
  loader: async ({ params, context }) => {
10
- const load = await loadFolder(context.queryClient, params, params._splat ?? '');
10
+ const load = await loadFolder(
11
+ context.clients,
12
+ context.queryClient,
13
+ params,
14
+ params._splat ?? '',
15
+ );
11
16
  if (load === undefined) throw notFound();
12
17
 
13
18
  return load;
@@ -6,7 +6,8 @@ import { ReleaseList } from '../../../../../releases/release-list.tsx';
6
6
  import { releaseList } from '../../../../../releases/releases.ts';
7
7
 
8
8
  export const Route = createFileRoute('/$owner/$repo/_releases/releases/')({
9
- loader: ({ params, context }) => readPagesAhead(context.queryClient, releaseList(params)),
9
+ loader: ({ params, context }) =>
10
+ readPagesAhead(context.queryClient, releaseList(context.clients, params)),
10
11
  component: ReleasesPage,
11
12
  errorComponent: ({ error }) => (
12
13
  <LoadFailed message={error instanceof Error ? error.message : "The releases didn't load"} />
@@ -6,7 +6,7 @@ import { tagsOf } from '../../../../releases/releases.ts';
6
6
  import { TagList } from '../../../../releases/tag-list.tsx';
7
7
 
8
8
  export const Route = createFileRoute('/$owner/$repo/_releases/tags')({
9
- loader: ({ params, context }) => readAhead(context.queryClient, tagsOf(params)),
9
+ loader: ({ params, context }) => readAhead(context.queryClient, tagsOf(context.clients, params)),
10
10
  component: TagsPage,
11
11
  errorComponent: ({ error }) => (
12
12
  <LoadFailed message={error instanceof Error ? error.message : "The tags didn't load"} />
@@ -23,7 +23,11 @@ export const Route = createFileRoute('/$owner/$repo/branches')({
23
23
  loader: ({ params, context, deps }) =>
24
24
  readPagesAhead(
25
25
  context.queryClient,
26
- refPages(params, { prefix: 'refs/heads/', first: branchesPerPage, search: deps.q }),
26
+ refPages(context.clients, params, {
27
+ prefix: 'refs/heads/',
28
+ first: branchesPerPage,
29
+ search: deps.q,
30
+ }),
27
31
  ),
28
32
  component: BranchesPage,
29
33
  errorComponent: ({ error }) => (
@@ -12,7 +12,7 @@ export const Route = createFileRoute('/$owner/$repo/commit/$sha')({
12
12
  staticData: { ownHeading: true },
13
13
  loader: async ({ params, context }) => {
14
14
  const commit = isOid(params.sha)
15
- ? await cached(context.queryClient, commitAt(params, params.sha))
15
+ ? await cached(context.queryClient, commitAt(context.clients, params, params.sha))
16
16
  : null;
17
17
  if (commit === null) throw notFound();
18
18
 
@@ -10,7 +10,12 @@ import { loadHistory } from '../../../../history/history.ts';
10
10
 
11
11
  export const Route = createFileRoute('/$owner/$repo/commits/$')({
12
12
  loader: async ({ params, context }) => {
13
- const load = await loadHistory(context.queryClient, params, params._splat ?? '');
13
+ const load = await loadHistory(
14
+ context.clients,
15
+ context.queryClient,
16
+ params,
17
+ params._splat ?? '',
18
+ );
14
19
  if (load === undefined) throw notFound();
15
20
 
16
21
  return load;
@@ -6,7 +6,7 @@ import { loadOverview, Overview } from '../../../releases/overview.tsx';
6
6
 
7
7
  export const Route = createFileRoute('/$owner/$repo/')({
8
8
  loader: async ({ params, context }) => {
9
- const load = await loadOverview(context.queryClient, params);
9
+ const load = await loadOverview(context.clients, context.queryClient, params);
10
10
  if (load === undefined) throw notFound();
11
11
 
12
12
  return load;
@@ -2,6 +2,7 @@ import { useQuery } from '@tanstack/react-query';
2
2
  import { createFileRoute, getRouteApi, notFound, redirect } from '@tanstack/react-router';
3
3
 
4
4
  import { cached } from '../../../../clients/cached.ts';
5
+ import { useClients } from '../../../../clients/clients.ts';
5
6
  import { CodeNotFound } from '../../../../code/code-page.tsx';
6
7
  import { LoadFailed } from '../../../../components/states/states.tsx';
7
8
  import { IssuePage } from '../../../../issues/issue-page.tsx';
@@ -21,7 +22,7 @@ export const Route = createFileRoute('/$owner/$repo/issues/$number')({
21
22
  const number = numberOf(params.number);
22
23
  if (number === undefined) throw notFound();
23
24
 
24
- const at = await cached(context.queryClient, issueAt(params, number));
25
+ const at = await cached(context.queryClient, issueAt(context.clients, params, number));
25
26
  if (at === null) throw notFound();
26
27
 
27
28
  // A pull request's number is its issue's too, and its own page shows it.
@@ -38,10 +39,11 @@ export const Route = createFileRoute('/$owner/$repo/issues/$number')({
38
39
 
39
40
  /** An issue's page, redrawn from its query as each change lands. */
40
41
  function Issue() {
42
+ const clients = useClients();
41
43
  const { number } = Route.useLoaderData();
42
44
  const { repo } = layout.useLoaderData();
43
45
  const params = Route.useParams();
44
- const at = useQuery(issueAt(params, number)).data;
46
+ const at = useQuery(issueAt(clients, params, number)).data;
45
47
  if (at === undefined || at === null || at.kind === 'pull') return null;
46
48
 
47
49
  if (!repo.hasIssues) return <IssuesOff />;
@@ -27,8 +27,8 @@ export const Route = createFileRoute('/$owner/$repo/issues/')({
27
27
  loaderDeps: ({ search }) => ({ q: search.q ?? defaultQuery }),
28
28
  loader: async ({ params, context, deps }) => {
29
29
  const client = context.queryClient;
30
- const vocabulary = await cached(client, vocabularyOf(params));
31
- await readPagesAhead(client, issueList(params, filterOf(deps.q), vocabulary));
30
+ const vocabulary = await cached(client, vocabularyOf(context.clients, params));
31
+ await readPagesAhead(client, issueList(context.clients, params, filterOf(deps.q), vocabulary));
32
32
 
33
33
  return { q: deps.q };
34
34
  },
@@ -15,8 +15,11 @@ const layout = getRouteApi('/$owner/$repo');
15
15
  export const Route = createFileRoute('/$owner/$repo/issues/new')({
16
16
  loader: async ({ params, context }) => {
17
17
  const client = context.queryClient;
18
- const vocabulary = await cached(client, vocabularyOf(params));
19
- await readPagesAhead(client, issueList(params, filterOf(defaultQuery), vocabulary));
18
+ const vocabulary = await cached(client, vocabularyOf(context.clients, params));
19
+ await readPagesAhead(
20
+ client,
21
+ issueList(context.clients, params, filterOf(defaultQuery), vocabulary),
22
+ );
20
23
  },
21
24
  component: NewIssuePage,
22
25
  });
@@ -8,7 +8,8 @@ import { LabelsPage } from '../../../issues/labels-page.tsx';
8
8
  export const Route = createFileRoute('/$owner/$repo/labels')({
9
9
  // Its page draws its own heading, so the shell draws none.
10
10
  staticData: { ownHeading: true },
11
- loader: ({ params, context }) => cached(context.queryClient, vocabularyOf(params)),
11
+ loader: ({ params, context }) =>
12
+ cached(context.queryClient, vocabularyOf(context.clients, params)),
12
13
  head: ({ params }) => ({ meta: [{ title: `Labels · ${params.owner}/${params.repo}` }] }),
13
14
  component: Labels,
14
15
  errorComponent: ({ error }) => (
@@ -0,0 +1,36 @@
1
+ import { createFileRoute } from '@tanstack/react-router';
2
+ import { flow } from 'effect/Function';
3
+ import * as Option from 'effect/Option';
4
+ import * as Schema from 'effect/Schema';
5
+
6
+ import { cached } from '../../../clients/cached.ts';
7
+ import { LoadFailed } from '../../../components/states/states.tsx';
8
+ import { milestonesOf } from '../../../issues/issues.ts';
9
+ import { MilestonesPage } from '../../../issues/milestones-page.tsx';
10
+
11
+ /** The tab the page shows, as its URL carries it in `state`: open unless it says closed. */
12
+ const MilestoneSearch = Schema.Struct({ state: Schema.optional(Schema.Literals(['closed'])) });
13
+
14
+ /** The page's URL query, read: one it can't read is the open tab's. */
15
+ const searchOf = flow(
16
+ Schema.decodeUnknownOption(MilestoneSearch),
17
+ Option.getOrElse((): typeof MilestoneSearch.Type => ({})),
18
+ );
19
+
20
+ export const Route = createFileRoute('/$owner/$repo/milestones')({
21
+ // Its page draws its own heading, so the shell draws none.
22
+ staticData: { ownHeading: true },
23
+ validateSearch: searchOf,
24
+ loader: ({ params, context }) =>
25
+ cached(context.queryClient, milestonesOf(context.clients, params)),
26
+ head: ({ params }) => ({ meta: [{ title: `Milestones · ${params.owner}/${params.repo}` }] }),
27
+ component: Milestones,
28
+ errorComponent: ({ error }) => (
29
+ <LoadFailed message={error instanceof Error ? error.message : "The milestones didn't load"} />
30
+ ),
31
+ });
32
+
33
+ /** The repo's milestones, open or closed, to make and change. */
34
+ function Milestones() {
35
+ return <MilestonesPage place={Route.useParams()} state={Route.useSearch().state ?? 'open'} />;
36
+ }
@@ -2,6 +2,7 @@ import { useQuery } from '@tanstack/react-query';
2
2
  import { createFileRoute, getRouteApi, notFound, Outlet } from '@tanstack/react-router';
3
3
 
4
4
  import { cached } from '../../../../../clients/cached.ts';
5
+ import { useClients } from '../../../../../clients/clients.ts';
5
6
  import { CodeNotFound } from '../../../../../code/code-page.tsx';
6
7
  import { LoadFailed } from '../../../../../components/states/states.tsx';
7
8
  import { PullHeader } from '../../../../../pulls/pull-page.tsx';
@@ -15,7 +16,7 @@ export const Route = createFileRoute('/$owner/$repo/pull/$number')({
15
16
  const number = numberOf(params.number);
16
17
  if (number === undefined) throw notFound();
17
18
 
18
- const pull = await cached(context.queryClient, pullAt(params, number));
19
+ const pull = await cached(context.queryClient, pullAt(context.clients, params, number));
19
20
  if (pull === null) throw notFound();
20
21
 
21
22
  return { number };
@@ -31,11 +32,12 @@ const layout = getRouteApi('/$owner/$repo/pull/$number');
31
32
 
32
33
  /** The pull request a tab shows, from the query its layout's loader filled. */
33
34
  export const usePull = () => {
35
+ const clients = useClients();
34
36
  const { number } = layout.useLoaderData();
35
37
  const { owner, repo } = layout.useParams();
36
38
  const place = { owner, repo };
37
39
 
38
- return { place, pull: useQuery(pullAt(place, number)).data ?? null };
40
+ return { place, pull: useQuery(pullAt(clients, place, number)).data ?? null };
39
41
  };
40
42
 
41
43
  /** A pull request's header and tabs, over the tab its path names. */
@@ -24,9 +24,9 @@ export const Route = createFileRoute('/$owner/$repo/pulls/')({
24
24
  loaderDeps: ({ search }) => ({ q: search.q ?? defaultPullQuery }),
25
25
  loader: async ({ params, context, deps }) => {
26
26
  const client = context.queryClient;
27
- const vocabulary = await cached(client, vocabularyOf(params));
27
+ const vocabulary = await cached(client, vocabularyOf(context.clients, params));
28
28
  const filter = asViewer(pullFilterOf(deps.q), context.viewer?.login);
29
- await readPagesAhead(client, pullList(params, filter, vocabulary));
29
+ await readPagesAhead(client, pullList(context.clients, params, filter, vocabulary));
30
30
 
31
31
  return { q: deps.q };
32
32
  },
@@ -8,7 +8,8 @@ import { queueEntries } from '../../../queue/queue.ts';
8
8
  export const Route = createFileRoute('/$owner/$repo/queue')({
9
9
  // Its page draws its own heading, so the shell draws none.
10
10
  staticData: { ownHeading: true },
11
- loader: ({ params, context }) => readPagesAhead(context.queryClient, queueEntries(params)),
11
+ loader: ({ params, context }) =>
12
+ readPagesAhead(context.queryClient, queueEntries(context.clients, params)),
12
13
  head: ({ params }) => ({ meta: [{ title: `Merge queue · ${params.owner}/${params.repo}` }] }),
13
14
  component: QueueRoute,
14
15
  errorComponent: ({ error }) => (
@@ -14,10 +14,13 @@ const layout = getRouteApi('/$owner/$repo');
14
14
 
15
15
  export const Route = createFileRoute('/$owner/$repo/releases/edit/$')({
16
16
  loader: async ({ params, context }) => {
17
- const release = await cached(context.queryClient, releaseAt(params, params._splat ?? ''));
17
+ const release = await cached(
18
+ context.queryClient,
19
+ releaseAt(context.clients, params, params._splat ?? ''),
20
+ );
18
21
  if (release === null) throw notFound();
19
22
 
20
- await readPagesAhead(context.queryClient, releaseList(params));
23
+ await readPagesAhead(context.queryClient, releaseList(context.clients, params));
21
24
 
22
25
  return { release };
23
26
  },
@@ -12,7 +12,8 @@ import { releaseList } from '../../../../releases/releases.ts';
12
12
  const layout = getRouteApi('/$owner/$repo');
13
13
 
14
14
  export const Route = createFileRoute('/$owner/$repo/releases/new')({
15
- loader: ({ params, context }) => readPagesAhead(context.queryClient, releaseList(params)),
15
+ loader: ({ params, context }) =>
16
+ readPagesAhead(context.queryClient, releaseList(context.clients, params)),
16
17
  component: NewReleasePage,
17
18
  });
18
19
 
@@ -2,6 +2,7 @@ import { useQuery } from '@tanstack/react-query';
2
2
  import { createFileRoute, notFound } from '@tanstack/react-router';
3
3
 
4
4
  import { cached } from '../../../../../clients/cached.ts';
5
+ import { useClients } from '../../../../../clients/clients.ts';
5
6
  import { CodeNotFound } from '../../../../../code/code-page.tsx';
6
7
  import { LoadFailed } from '../../../../../components/states/states.tsx';
7
8
  import { ReleasePage } from '../../../../../releases/release-list.tsx';
@@ -12,7 +13,7 @@ export const Route = createFileRoute('/$owner/$repo/releases/tag/$')({
12
13
  staticData: { ownHeading: true },
13
14
  loader: async ({ params, context }) => {
14
15
  const tag = params._splat ?? '';
15
- const release = await cached(context.queryClient, releaseAt(params, tag));
16
+ const release = await cached(context.queryClient, releaseAt(context.clients, params, tag));
16
17
  if (release === null) throw notFound();
17
18
 
18
19
  return { tag };
@@ -26,9 +27,10 @@ export const Route = createFileRoute('/$owner/$repo/releases/tag/$')({
26
27
 
27
28
  /** A release's page, redrawn from its query as each change lands. */
28
29
  function Release() {
30
+ const clients = useClients();
29
31
  const { tag } = Route.useLoaderData();
30
32
  const params = Route.useParams();
31
- const release = useQuery(releaseAt(params, tag)).data;
33
+ const release = useQuery(releaseAt(clients, params, tag)).data;
32
34
  if (release === undefined || release === null) return null;
33
35
 
34
36
  return <ReleasePage place={params} release={release} />;
@@ -3,6 +3,7 @@ import { createFileRoute, notFound, Outlet } from '@tanstack/react-router';
3
3
  import { LockIcon } from 'lucide-react';
4
4
 
5
5
  import { cached, readAhead } from '../../../clients/cached.ts';
6
+ import { useClients } from '../../../clients/clients.ts';
6
7
  import { OwnerCard } from '../../../components/owner-card.tsx';
7
8
  import { CodeNotFound } from '../../../code/code-page.tsx';
8
9
  import { Go } from '../../../code/controls.tsx';
@@ -26,15 +27,17 @@ export const Route = createFileRoute('/$owner/$repo')({
26
27
  // sections and controls it allows, such as Settings, and the owner as an org or a person,
27
28
  // rather than the browser adding them once it asks.
28
29
  const [repo] = await Promise.all([
29
- cached(context.queryClient, repoAt(params)),
30
- readAhead(context.queryClient, allowedHere(params)),
31
- readAhead(context.queryClient, ownerAt(params.owner, context.viewer?.login)),
30
+ cached(context.queryClient, repoAt(context.clients, params)),
31
+ readAhead(context.queryClient, allowedHere(context.clients, params)),
32
+ readAhead(context.queryClient, ownerAt(context.clients, params.owner, context.viewer?.login)),
32
33
  ]);
33
34
 
34
35
  // A repo the viewer can't read gives exactly the page a missing one gives, with nothing of
35
36
  // what they may do there in the page's data.
36
37
  if (repo === null) {
37
- context.queryClient.removeQueries({ queryKey: allowedHere(params).queryKey });
38
+ context.queryClient.removeQueries({
39
+ queryKey: allowedHere(context.clients, params).queryKey,
40
+ });
38
41
  throw notFound();
39
42
  }
40
43
 
@@ -53,10 +56,11 @@ export const Route = createFileRoute('/$owner/$repo')({
53
56
  * releases'. A private repository's pages read only for those it's shared with.
54
57
  */
55
58
  function RepoLayout() {
59
+ const clients = useClients();
56
60
  const { repo } = Route.useLoaderData();
57
61
  const { viewer } = Route.useRouteContext();
58
62
  // The owner, as the loader read it beside the repo, so its card reads an org's profile at once.
59
- const owner = useQuery(ownerAt(repo.owner, viewer?.login)).data;
63
+ const owner = useQuery(ownerAt(clients, repo.owner, viewer?.login)).data;
60
64
 
61
65
  return (
62
66
  <>
@@ -7,7 +7,9 @@ import { hookList } from '../../../../../settings/hooks.ts';
7
7
  export const Route = createFileRoute('/$owner/$repo/settings/hooks/')({
8
8
  // The webhooks, read before the page draws, as its layout reads what the viewer may do.
9
9
  loader: ({ params, context }) =>
10
- context.viewer === null ? undefined : readAhead(context.queryClient, hookList(params)),
10
+ context.viewer === null
11
+ ? undefined
12
+ : readAhead(context.queryClient, hookList(context.clients, params)),
11
13
  component: Hooks,
12
14
  });
13
15
 
@@ -7,7 +7,9 @@ import { GeneralSettings } from '../../../../settings/general-settings.tsx';
7
7
  export const Route = createFileRoute('/$owner/$repo/settings/')({
8
8
  // The settings, read before the page draws, as its layout reads what the viewer may do.
9
9
  loader: ({ params, context }) =>
10
- context.viewer === null ? undefined : readAhead(context.queryClient, generalSettings(params)),
10
+ context.viewer === null
11
+ ? undefined
12
+ : readAhead(context.queryClient, generalSettings(context.clients, params)),
11
13
  component: General,
12
14
  });
13
15
 
@@ -16,6 +16,7 @@ import {
16
16
  SidebarMenuItem,
17
17
  } from '../components/ui/sidebar.tsx';
18
18
  import type { PageOperation } from '../clients/allowed.ts';
19
+ import { useClients } from '../clients/clients.ts';
19
20
  import { allowedHere } from '../hooks/allowed.ts';
20
21
  import { tabCounts, tabQueries } from '../issues/counts.ts';
21
22
  import { defaultQuery, filterOf, searchQueryOf } from '../issues/search.ts';
@@ -64,6 +65,7 @@ const sections: readonly {
64
65
  const repoSegments: ReadonlyMap<string, Section> = new Map([
65
66
  ['issues', 'issues'],
66
67
  ['labels', 'issues'],
68
+ ['milestones', 'issues'],
67
69
  ['pulls', 'pulls'],
68
70
  ['pull', 'pulls'],
69
71
  ['compare', 'pulls'],
@@ -163,8 +165,10 @@ export const headingOf = (
163
165
  * switched off.
164
166
  */
165
167
  const useOpenCounts = (place: RepoPlace | undefined, repo: Repo | undefined) => {
168
+ const clients = useClients();
166
169
  const issues = useQuery(
167
170
  tabCounts(
171
+ clients,
168
172
  place ?? { owner: '', repo: '' },
169
173
  'issues',
170
174
  place !== undefined && repo?.hasIssues === true
@@ -174,6 +178,7 @@ const useOpenCounts = (place: RepoPlace | undefined, repo: Repo | undefined) =>
174
178
  );
175
179
  const pulls = useQuery(
176
180
  tabCounts(
181
+ clients,
177
182
  place ?? { owner: '', repo: '' },
178
183
  'pulls',
179
184
  place === undefined
@@ -214,12 +219,15 @@ export function Nav({
214
219
  readonly path: string;
215
220
  readonly viewer: string | undefined;
216
221
  }) {
222
+ const clients = useClients();
217
223
  const at = place ?? { owner: viewer ?? '' };
218
224
  const inRepo = at.repo === undefined ? undefined : { owner: at.owner, repo: at.repo };
219
225
  // What the viewer may do in the repo, as its layout read it: nothing is asked at the org level.
220
226
  const allowed =
221
- useQuery({ ...allowedHere(inRepo ?? { owner: '', repo: '' }), enabled: inRepo !== undefined })
222
- .data ?? nothing;
227
+ useQuery({
228
+ ...allowedHere(clients, inRepo ?? { owner: '', repo: '' }),
229
+ enabled: inRepo !== undefined,
230
+ }).data ?? nothing;
223
231
  const counts = useOpenCounts(inRepo, repo);
224
232
  // The Inbox is the viewer's own, in none of the owner's sections.
225
233
  const current = inInbox(path) ? undefined : sectionOf(path);
@@ -12,6 +12,10 @@ import { expect, vi } from 'vite-plus/test';
12
12
 
13
13
  import { untilFileEnd } from '#/lib/testing/roots';
14
14
 
15
+ import type { Clients } from '../clients/clients.ts';
16
+ import { clientsOver } from '../clients/testing/clients.ts';
17
+ import { Markdown } from '../components/markdown/markdown.tsx';
18
+
15
19
  import type { Viewer } from '../signin/viewer.ts';
16
20
  import { Route as AppRoot } from './__root.tsx';
17
21
 
@@ -53,17 +57,25 @@ export const undraw = () => {
53
57
  };
54
58
 
55
59
  /**
56
- * The app's own shell at `path`, for `viewer`, or signed out for `null`, over any page, and a page
57
- * at `/own` that draws its own heading. Resolves once the shell has drawn. React's act stays off, as in a browser: it would
60
+ * The app's own shell at `path`, for `viewer`, or signed out for `null`, over any page, a page at
61
+ * `/own` that draws its own heading, and one at `/notes` that draws each of `notes` as Markdown,
62
+ * its calls made through `clients`. Resolves once the shell has drawn. React's act stays off, as in a browser: it would
58
63
  * wait on an open menu's frames, which never end. A test opens one popup at most, and leaves it
59
64
  * open: under happy-dom, closing one, or opening another after it, never returns.
60
65
  */
61
- export const drawShell = async (path: string, viewer: Viewer | null) => {
66
+ export const drawShell = async (
67
+ path: string,
68
+ viewer: Viewer | null,
69
+ {
70
+ notes = [],
71
+ clients = clientsOver(),
72
+ }: { readonly notes?: readonly string[]; readonly clients?: Clients } = {},
73
+ ) => {
62
74
  vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', false);
63
75
  const component = AppRoot.options.component;
64
76
  if (component === undefined) throw new Error('The app draws no root');
65
77
 
66
- const root = createRootRouteWithContext<{ queryClient: QueryClient }>()({
78
+ const root = createRootRouteWithContext<{ queryClient: QueryClient; clients: Clients }>()({
67
79
  beforeLoad: () => ({ viewer, signInEnded: false }),
68
80
  component,
69
81
  });
@@ -73,11 +85,22 @@ export const drawShell = async (path: string, viewer: Viewer | null) => {
73
85
  staticData: { ownHeading: true },
74
86
  component: () => createElement('h1', null, 'Its own'),
75
87
  });
88
+ const notesPage = createRoute({
89
+ getParentRoute: () => root,
90
+ path: 'notes',
91
+ component: () =>
92
+ notes.map((text, at) =>
93
+ createElement(Markdown, { key: at, text, context: { kind: 'comment', repo: 'acme/web' } }),
94
+ ),
95
+ });
76
96
  const anywhere = createRoute({ getParentRoute: () => root, path: '$', component: () => null });
77
97
  const router = createRouter({
78
- routeTree: root.addChildren([own, anywhere]),
98
+ routeTree: root.addChildren([own, notesPage, anywhere]),
79
99
  history: createMemoryHistory({ initialEntries: [path] }),
80
- context: { queryClient: new QueryClient({ defaultOptions: { queries: { retry: false } } }) },
100
+ context: {
101
+ queryClient: new QueryClient({ defaultOptions: { queries: { retry: false } } }),
102
+ clients,
103
+ },
81
104
  });
82
105
  const container = document.createElement('div');
83
106
  document.body.append(container);
@@ -11,6 +11,7 @@ import {
11
11
  } from '@tanstack/react-router';
12
12
  import { useEffect } from 'react';
13
13
 
14
+ import type { Clients } from '../clients/clients.ts';
14
15
  import { onSessionEnded } from '../clients/session-ended.ts';
15
16
  import { refsStaleOnFocus } from '../code/refs.ts';
16
17
  import { canSave, forgetEverySaved, forgetSaved, saveAs } from '../code/saved.ts';
@@ -22,6 +23,7 @@ import { ThemeProvider, themeScript } from '../components/theme-provider.tsx';
22
23
  import { prefetchPicturesWhenIdle } from '../components/user-avatar.tsx';
23
24
  import { Toaster } from '../components/ui/sonner.tsx';
24
25
  import { TooltipProvider } from '../components/ui/tooltip.tsx';
26
+ import { PageHtmlBudget } from '../components/markdown/markdown.tsx';
25
27
  import markdownStyles from '../components/markdown/markdown.css?url';
26
28
  import styles from '../components/ui/styles.css?url';
27
29
  import { type Owner, ownerAt } from '../hooks/repos.ts';
@@ -33,7 +35,7 @@ import { forgetRecentPlaces } from '../palette/recent.ts';
33
35
  import { onSignedOut, onSignOut } from '../signin/auth-client.ts';
34
36
  import { headingOf, Nav, placeOf, sectionHref, sectionOf } from './-nav.tsx';
35
37
 
36
- export const Route = createRootRouteWithContext<{ queryClient: QueryClient }>()({
38
+ export const Route = createRootRouteWithContext<{ queryClient: QueryClient; clients: Clients }>()({
37
39
  head: () => ({
38
40
  meta: [
39
41
  { charSet: 'utf-8' },
@@ -67,7 +69,7 @@ export const Route = createRootRouteWithContext<{ queryClient: QueryClient }>()(
67
69
  * each of those ways too.
68
70
  */
69
71
  function Shell() {
70
- const { viewer, signInEnded, queryClient } = Route.useRouteContext();
72
+ const { viewer, signInEnded, queryClient, clients } = Route.useRouteContext();
71
73
  const router = useRouter();
72
74
  const location = useLocation();
73
75
  useEffect(
@@ -115,7 +117,7 @@ function Shell() {
115
117
  const section = sectionOf(location.pathname);
116
118
  // The owner, as the route that names it read it before the page drew: the viewer is known.
117
119
  const named = useQuery({
118
- ...ownerAt(place?.owner ?? '', login),
120
+ ...ownerAt(clients, place?.owner ?? '', login),
119
121
  enabled: place !== undefined && place.owner !== login,
120
122
  }).data;
121
123
  const repo =
@@ -200,6 +202,7 @@ function Shell() {
200
202
 
201
203
  function Root() {
202
204
  const { queryClient } = Route.useRouteContext();
205
+ const location = useLocation();
203
206
  useAskBeforeLosingDrafts(queryClient);
204
207
 
205
208
  return (
@@ -213,7 +216,9 @@ function Root() {
213
216
  <ThemeProvider defaultTheme="system">
214
217
  <TooltipProvider>
215
218
  <QueryClientProvider client={queryClient}>
216
- <Shell />
219
+ <PageHtmlBudget page={location.href}>
220
+ <Shell />
221
+ </PageHtmlBudget>
217
222
  </QueryClientProvider>
218
223
  <Toaster />
219
224
  </TooltipProvider>
@@ -25,7 +25,9 @@ export const Route = createFileRoute('/')({
25
25
  ];
26
26
 
27
27
  await Promise.all(
28
- owners.map((owner) => readPagesAhead(context.queryClient, repoList(owner, filter))),
28
+ owners.map((owner) =>
29
+ readPagesAhead(context.queryClient, repoList(context.clients, owner, filter)),
30
+ ),
29
31
  );
30
32
  },
31
33
  component: Home,
@@ -13,7 +13,10 @@ export const Route = createFileRoute('/orgs/$owner')({
13
13
  loader: async ({ params, context }) => {
14
14
  if (ownerProblem(params.owner) !== undefined) throw notFound();
15
15
 
16
- const owner = await cached(context.queryClient, ownerAt(params.owner, context.viewer?.login));
16
+ const owner = await cached(
17
+ context.queryClient,
18
+ ownerAt(context.clients, params.owner, context.viewer?.login),
19
+ );
17
20
  if (owner === null) throw notFound();
18
21
 
19
22
  return { owner };