ref0-git 0.2.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 +17 -11
  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 +28 -10
  90. package/app/apps/github/src/palette/rows.tsx +93 -40
  91. package/app/apps/github/src/palette/server.ts +10 -7
  92. package/app/apps/github/src/palette/targets.ts +1 -0
  93. package/app/apps/github/src/policy.ts +137 -61
  94. package/app/apps/github/src/private-repos.ts +5 -5
  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 -120
  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 +26 -5
  174. package/dist/cli/helpers.mjs +168 -35
  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 +70 -13
  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 +4 -3
  193. package/dist/init/detect.mjs +4 -4
  194. package/dist/init/files.mjs +121 -9
  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 +3 -5
  201. package/dist/init/node-app.mjs +3 -3
  202. package/dist/init/node.mjs +41 -42
  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 +64 -48
  208. package/dist/init/vercel.mjs +37 -36
  209. package/dist/init/versions.mjs +3 -3
  210. package/package.json +6 -5
@@ -22,6 +22,7 @@ import { allFiles } from '../code/trees.ts';
22
22
  import { switcherList } from '../components/shell/owner-repos.tsx';
23
23
  import { sectionIcon } from '../components/shell/sections.ts';
24
24
  import type { PageOperation } from '../clients/allowed.ts';
25
+ import { type Clients, useClients } from '../clients/clients.ts';
25
26
  import { allowedHere } from '../hooks/allowed.ts';
26
27
  import { type Owner, repoList } from '../hooks/repos.ts';
27
28
  import { settingsOpen } from '../settings/settings-layout.tsx';
@@ -105,15 +106,18 @@ const refKinds: readonly Kind[] = ['branches', 'tags'];
105
106
  * Reads ahead what the palette lists with no mode, from the switchers' own reads under their own
106
107
  * keys: each owner's repos and, in a repo, its branches and tags. A read still fresh reads nothing.
107
108
  */
108
- export const prefetchLists = (client: QueryClient, at: PaletteAt) => {
109
+ export const prefetchLists = (clients: Clients, client: QueryClient, at: PaletteAt) => {
109
110
  for (const owner of ownersOf(at)) {
110
- void client.prefetchInfiniteQuery({ ...repoList(owner, switcherList), staleTime: 30_000 });
111
+ void client.prefetchInfiniteQuery({
112
+ ...repoList(clients, owner, switcherList),
113
+ staleTime: 30_000,
114
+ });
111
115
  }
112
116
 
113
117
  const place = placeOf(at.here);
114
118
  if (place === undefined) return;
115
119
 
116
- for (const kind of refKinds) void client.prefetchInfiniteQuery(refNameList(place, kind));
120
+ for (const kind of refKinds) void client.prefetchInfiniteQuery(refNameList(clients, place, kind));
117
121
  };
118
122
 
119
123
  /** Draws again whenever a read lands in the cache, so lists read ahead show once they arrive. */
@@ -172,11 +176,16 @@ const noOperations: ReadonlySet<PageOperation> = new Set();
172
176
  * What the viewer may do on the page's repo, as its route read it ahead: the palette reads nothing
173
177
  * of its own, so before that answer lands, and off a repo, it offers no gated row.
174
178
  */
175
- export const useAllowedAt = (here: Here): ReadonlySet<PageOperation> =>
176
- useQuery({
177
- ...allowedHere({ owner: here.owner ?? '', repo: here.repo ?? '' }),
178
- enabled: false,
179
- }).data ?? noOperations;
179
+ export const useAllowedAt = (here: Here): ReadonlySet<PageOperation> => {
180
+ const clients = useClients();
181
+
182
+ return (
183
+ useQuery({
184
+ ...allowedHere(clients, { owner: here.owner ?? '', repo: here.repo ?? '' }),
185
+ enabled: false,
186
+ }).data ?? noOperations
187
+ );
188
+ };
180
189
 
181
190
  /** Whether `page` is one of the repo's settings, which open only as the sidebar's Settings does. */
182
191
  const repoSettings = (page: Target, here: Here) =>
@@ -187,6 +196,7 @@ const repoSettings = (page: Target, here: Here) =>
187
196
 
188
197
  /** The rows with no mode: what a pasted value names, then recent places, pages, repos, orgs and refs. */
189
198
  const useFound = (at: PaletteAt, text: string): readonly Group[] => {
199
+ const clients = useClients();
190
200
  const client = useCacheLanded();
191
201
  const place = placeOf(at.here);
192
202
  const owners = ownersOf(at);
@@ -217,21 +227,22 @@ const useFound = (at: PaletteAt, text: string): readonly Group[] => {
217
227
  (a, b) => Number(b.login === at.here.owner) - Number(a.login === at.here.owner),
218
228
  );
219
229
  const repos = ordered.flatMap((owner) =>
220
- (client.getQueryData(repoList(owner, switcherList).queryKey)?.pages ?? []).flatMap((page) =>
221
- page.repos.map((repo): Row => ({
222
- id: `repo:${owner.login}/${repo.name}`,
223
- label: `${owner.login}/${repo.name}`,
224
- icon: BookMarkedIcon,
225
- act: {
226
- kind: 'go',
227
- href: `/${segment(owner.login)}/${segment(repo.name)}`,
228
- keep: {
229
- kind: 'repo',
230
- label: `${owner.login}/${repo.name}`,
230
+ (client.getQueryData(repoList(clients, owner, switcherList).queryKey)?.pages ?? []).flatMap(
231
+ (page) =>
232
+ page.repos.map((repo): Row => ({
233
+ id: `repo:${owner.login}/${repo.name}`,
234
+ label: `${owner.login}/${repo.name}`,
235
+ icon: BookMarkedIcon,
236
+ act: {
237
+ kind: 'go',
231
238
  href: `/${segment(owner.login)}/${segment(repo.name)}`,
239
+ keep: {
240
+ kind: 'repo',
241
+ label: `${owner.login}/${repo.name}`,
242
+ href: `/${segment(owner.login)}/${segment(repo.name)}`,
243
+ },
232
244
  },
233
- },
234
- })),
245
+ })),
235
246
  ),
236
247
  );
237
248
  const orgs = owners.map((owner): Row => ({
@@ -244,14 +255,15 @@ const useFound = (at: PaletteAt, text: string): readonly Group[] => {
244
255
  const refs = (kind: Kind): readonly Row[] =>
245
256
  place === undefined
246
257
  ? []
247
- : (client.getQueryData(refNameList(place, kind).queryKey)?.pages ?? []).flatMap((page) =>
248
- page.names.map((name): Row => ({
249
- id: `${kind}:${name}`,
250
- label: name,
251
- note: kind === 'branches' ? 'Branch' : 'Tag',
252
- icon: kind === 'branches' ? GitBranchIcon : TagIcon,
253
- act: { kind: 'go', href: treeHref(place, name, '') },
254
- })),
258
+ : (client.getQueryData(refNameList(clients, place, kind).queryKey)?.pages ?? []).flatMap(
259
+ (page) =>
260
+ page.names.map((name): Row => ({
261
+ id: `${kind}:${name}`,
262
+ label: name,
263
+ note: kind === 'branches' ? 'Branch' : 'Tag',
264
+ icon: kind === 'branches' ? GitBranchIcon : TagIcon,
265
+ act: { kind: 'go', href: treeHref(place, name, '') },
266
+ })),
255
267
  );
256
268
  const jump = jumpOf(text, at.here, window.location.origin);
257
269
 
@@ -268,8 +280,9 @@ const useFound = (at: PaletteAt, text: string): readonly Group[] => {
268
280
 
269
281
  /** `@`: the viewer's own owners, then their orgs' members, read once typing stops. */
270
282
  const usePeople = (at: PaletteAt, text: string, asking: boolean): readonly Group[] => {
283
+ const clients = useClients();
271
284
  const members = useQueries({
272
- queries: at.orgs.map((org) => ({ ...orgMembers(org), enabled: asking })),
285
+ queries: at.orgs.map((org) => ({ ...orgMembers(clients, org), enabled: asking })),
273
286
  });
274
287
  const owners = ownersOf(at).map((owner): Row => ({
275
288
  id: `owner:${owner.login}`,
@@ -294,7 +307,12 @@ const usePeople = (at: PaletteAt, text: string, asking: boolean): readonly Group
294
307
  ? undefined
295
308
  : { kind: 'searching' }
296
309
  : failed.length > 0
297
- ? { kind: 'failed', retry: () => failed.forEach((each) => void each.refetch()) }
310
+ ? {
311
+ kind: 'failed',
312
+ retry: () => {
313
+ if (asking) failed.forEach((each) => void each.refetch());
314
+ },
315
+ }
298
316
  : undefined;
299
317
 
300
318
  return [
@@ -308,10 +326,19 @@ const usePeople = (at: PaletteAt, text: string, asking: boolean): readonly Group
308
326
  };
309
327
 
310
328
  /** `#`: `#12` goes to that number, and other words search the page's repo once typing stops. */
311
- const useIssues = (at: PaletteAt, text: string, settled: string): readonly Group[] => {
329
+ const useIssues = (
330
+ at: PaletteAt,
331
+ text: string,
332
+ settled: string,
333
+ asking: boolean,
334
+ ): readonly Group[] => {
335
+ const clients = useClients();
312
336
  const wanted = issueQueryOf(settled, at.here);
313
337
  const typing = issueQueryOf(text, at.here);
314
- const found = useQuery({ ...issueSearch(wanted ?? ''), enabled: wanted !== undefined });
338
+ const found = useQuery({
339
+ ...issueSearch(clients, wanted ?? ''),
340
+ enabled: asking && wanted !== undefined,
341
+ });
315
342
  const number = numberJump(text, at.here);
316
343
 
317
344
  const rows = (found.data?.items ?? []).map((item): Row => {
@@ -338,7 +365,12 @@ const useIssues = (at: PaletteAt, text: string, settled: string): readonly Group
338
365
  : typing !== wanted || found.isFetching
339
366
  ? { kind: 'searching' }
340
367
  : found.isError
341
- ? { kind: 'failed', retry: () => void found.refetch() }
368
+ ? {
369
+ kind: 'failed',
370
+ retry: () => {
371
+ if (asking) void found.refetch();
372
+ },
373
+ }
342
374
  : found.data?.incomplete === true
343
375
  ? { kind: 'incomplete' }
344
376
  : undefined;
@@ -356,18 +388,30 @@ const useIssues = (at: PaletteAt, text: string, settled: string): readonly Group
356
388
  ];
357
389
  };
358
390
 
359
- /** `/`: the page's repo's files, from Go to file's own read of its default branch. */
391
+ /**
392
+ * `/`: the page's repo's files, from Go to file's own read of its default branch. Neither read
393
+ * retries by itself, as the palette's own don't: `enabled` can't stop a retry already waiting, so
394
+ * one would ask again while the palette closes, and a failure shows Retry at once instead. A
395
+ * query retries as the observer whose fetch runs says, so Go to file's own tree read keeps its
396
+ * retries.
397
+ */
360
398
  const useFiles = (at: PaletteAt, text: string, asking: boolean): readonly Group[] => {
399
+ const clients = useClients();
361
400
  const place = placeOf(at.here);
362
401
  const branch = at.here.defaultBranch;
363
402
  const head = useQuery({
364
- ...headCommit(place ?? { owner: '', repo: '' }, { kind: 'branch', name: branch ?? '' }),
403
+ ...headCommit(clients, place ?? { owner: '', repo: '' }, {
404
+ kind: 'branch',
405
+ name: branch ?? '',
406
+ }),
365
407
  enabled: asking && place !== undefined && branch !== undefined,
408
+ retry: false,
366
409
  });
367
410
  const tree = head.data?.tree;
368
411
  const files = useQuery({
369
- ...allFiles(place ?? { owner: '', repo: '' }, tree ?? ''),
412
+ ...allFiles(clients, place ?? { owner: '', repo: '' }, tree ?? ''),
370
413
  enabled: asking && place !== undefined && tree !== undefined,
414
+ retry: false,
371
415
  });
372
416
 
373
417
  if (place === undefined || branch === undefined) {
@@ -379,7 +423,12 @@ const useFiles = (at: PaletteAt, text: string, asking: boolean): readonly Group[
379
423
  const failed = head.isError ? head : files.isError ? files : undefined;
380
424
  const status: Status | undefined =
381
425
  failed !== undefined
382
- ? { kind: 'failed', retry: () => void failed.refetch() }
426
+ ? {
427
+ kind: 'failed',
428
+ retry: () => {
429
+ if (asking) void failed.refetch();
430
+ },
431
+ }
383
432
  : head.isPending || (tree !== undefined && files.isPending)
384
433
  ? { kind: 'searching' }
385
434
  : files.data?.truncated === true
@@ -414,21 +463,25 @@ const helpRows = (switchTo: (typed: Typed) => void): readonly Row[] =>
414
463
  /**
415
464
  * The groups for `typed`: with no mode, what's local; with one, its own. A mode that asks the
416
465
  * drop-in asks only once typing has stopped for `typingWait`, and only for what was typed then.
466
+ * A palette no longer `shown`, whose input takes keys until its exit animation ends, asks nothing,
467
+ * and its retries ask nothing either.
417
468
  */
418
469
  export const useGroups = (
419
470
  at: PaletteAt,
420
471
  typed: Typed,
421
472
  commands: readonly Row[],
422
473
  switchTo: (typed: Typed) => void,
474
+ shown: boolean,
423
475
  ): readonly Group[] => {
424
476
  const settled = useSettled(typed.text) ?? '';
425
- const people = usePeople(at, typed.text, typed.symbol === '@');
477
+ const people = usePeople(at, typed.text, shown && typed.symbol === '@');
426
478
  const issues = useIssues(
427
479
  at,
428
480
  typed.symbol === '#' ? typed.text : '',
429
481
  typed.symbol === '#' ? settled : '',
482
+ shown,
430
483
  );
431
- const files = useFiles(at, typed.text, typed.symbol === '/');
484
+ const files = useFiles(at, typed.text, shown && typed.symbol === '/');
432
485
  const found = useFound(at, typed.symbol === undefined ? typed.text : '');
433
486
 
434
487
  switch (typed.symbol) {
@@ -1,7 +1,7 @@
1
1
  import { queryOptions } from '@tanstack/react-query';
2
2
  import { useEffect, useState } from 'react';
3
3
 
4
- import { github } from '../clients/clients.ts';
4
+ import type { Clients } from '../clients/clients.ts';
5
5
 
6
6
  /**
7
7
  * What the palette asks the drop-in for, once typing stops: one request a mode, each with its
@@ -15,6 +15,9 @@ export const resultsMost = 8;
15
15
  /** How long typing must stop before a mode asks the drop-in. */
16
16
  export const typingWait = 150;
17
17
 
18
+ /** The key every read of the palette's own starts with, which closing it cancels. */
19
+ export const paletteReads = ['palette'] as const;
20
+
18
21
  /** An answer kept for the session: a search typed again shows at once. */
19
22
  const forTheSession = { staleTime: Infinity, gcTime: Infinity, retry: false } as const;
20
23
 
@@ -42,11 +45,11 @@ const repoOfUrl = (url: string) => {
42
45
  };
43
46
 
44
47
  /** The issues and pull requests `GET /search/issues` finds for `q`, at most `resultsMost`. */
45
- export const issueSearch = (q: string) =>
48
+ export const issueSearch = (clients: Clients, q: string) =>
46
49
  queryOptions({
47
- queryKey: ['palette', 'issues', q],
50
+ queryKey: [...paletteReads, 'issues', q],
48
51
  queryFn: async ({ signal }): Promise<Found<FoundIssue>> => {
49
- const answer = await github.GET('/search/issues', {
52
+ const answer = await clients.github.GET('/search/issues', {
50
53
  params: { query: { q, per_page: resultsMost } },
51
54
  signal,
52
55
  });
@@ -73,11 +76,11 @@ export const issueSearch = (q: string) =>
73
76
  * The logins of `org`'s members, its first 100, which `@` matches in the browser until the
74
77
  * drop-in serves `GET /search/users` (Q778).
75
78
  */
76
- export const orgMembers = (org: string) =>
79
+ export const orgMembers = (clients: Clients, org: string) =>
77
80
  queryOptions({
78
- queryKey: ['palette', 'members', org],
81
+ queryKey: [...paletteReads, 'members', org],
79
82
  queryFn: async ({ signal }): Promise<readonly string[]> => {
80
- const answer = await github.GET('/orgs/{org}/members', {
83
+ const answer = await clients.github.GET('/orgs/{org}/members', {
81
84
  params: { path: { org }, query: { per_page: 100 } },
82
85
  signal,
83
86
  });
@@ -106,6 +106,7 @@ const repoPages = (owner: string, repo: string, defaultBranch: string | undefine
106
106
  ['Tags', '/tags'],
107
107
  ['Releases', '/releases', 'releases'],
108
108
  ['Labels', '/labels'],
109
+ ['Milestones', '/milestones'],
109
110
  ...(defaultBranch === undefined
110
111
  ? []
111
112
  : ([['Commits', `/commits/${segment(defaultBranch)}`]] as const)),