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.
- package/app/apps/github/.dev.vars.example +2 -1
- package/app/apps/github/generated/git-rest.ts +191 -25
- package/app/apps/github/generated/routeTree.gen.ts +21 -0
- package/app/apps/github/package.json +1 -1
- package/app/apps/github/src/branches/branch-list.tsx +8 -4
- package/app/apps/github/src/branches/branches.ts +10 -5
- package/app/apps/github/src/camo/addresses.ts +120 -0
- package/app/apps/github/src/camo/client.ts +125 -0
- package/app/apps/github/src/camo/fetch.ts +201 -0
- package/app/apps/github/src/camo/lookup.ts +23 -0
- package/app/apps/github/src/camo/node.ts +50 -0
- package/app/apps/github/src/camo/proxy.ts +116 -0
- package/app/apps/github/src/camo/sign-images.ts +307 -0
- package/app/apps/github/src/camo/signing.ts +80 -0
- package/app/apps/github/src/clients/allowed.ts +111 -18
- package/app/apps/github/src/clients/clients.ts +76 -61
- package/app/apps/github/src/clients/transport.ts +13 -0
- package/app/apps/github/src/code/code-tree.tsx +3 -1
- package/app/apps/github/src/code/file-view.tsx +15 -6
- package/app/apps/github/src/code/files.ts +26 -19
- package/app/apps/github/src/code/go-to-file.tsx +2 -1
- package/app/apps/github/src/code/load.ts +41 -23
- package/app/apps/github/src/code/markdown-files.ts +13 -2
- package/app/apps/github/src/code/ref-pages.ts +14 -5
- package/app/apps/github/src/code/ref-switcher.tsx +4 -3
- package/app/apps/github/src/code/refs.ts +42 -8
- package/app/apps/github/src/code/repo-home.tsx +6 -2
- package/app/apps/github/src/code/repo.ts +12 -6
- package/app/apps/github/src/code/saved.ts +5 -3
- package/app/apps/github/src/code/trees.ts +11 -9
- package/app/apps/github/src/components/markdown/markdown.css +6 -0
- package/app/apps/github/src/components/markdown/markdown.tsx +95 -10
- package/app/apps/github/src/components/owner-card.tsx +3 -1
- package/app/apps/github/src/components/repos/your-repos.tsx +3 -1
- package/app/apps/github/src/components/shell/owner-repos.tsx +7 -12
- package/app/apps/github/src/components/shell/repo-switcher.tsx +10 -16
- package/app/apps/github/src/components/signin/device-card.tsx +9 -2
- package/app/apps/github/src/components/user-avatar.tsx +2 -1
- package/app/apps/github/src/context/context.ts +13 -0
- package/app/apps/github/src/diffs/blobs.ts +37 -14
- package/app/apps/github/src/diffs/diff-job.ts +53 -0
- package/app/apps/github/src/diffs/diff-worker.ts +6 -0
- package/app/apps/github/src/diffs/diffing.ts +136 -0
- package/app/apps/github/src/diffs/files.ts +4 -3
- package/app/apps/github/src/diffs/hunks.tsx +101 -53
- package/app/apps/github/src/diffs/patch.ts +20 -11
- package/app/apps/github/src/history/commit-diff.ts +10 -5
- package/app/apps/github/src/history/commit-list.tsx +3 -1
- package/app/apps/github/src/history/commit-page.tsx +4 -2
- package/app/apps/github/src/history/history.ts +12 -10
- package/app/apps/github/src/hooks/allowed.ts +9 -9
- package/app/apps/github/src/hooks/avatars.ts +3 -3
- package/app/apps/github/src/hooks/open-counts.ts +5 -4
- package/app/apps/github/src/hooks/profiles.ts +26 -12
- package/app/apps/github/src/hooks/repos.ts +78 -25
- package/app/apps/github/src/inbox/count.ts +30 -29
- package/app/apps/github/src/inbox/inbox-item.tsx +3 -1
- package/app/apps/github/src/inbox/inbox-page.tsx +5 -2
- package/app/apps/github/src/inbox/marks.ts +26 -15
- package/app/apps/github/src/inbox/release-tags.ts +7 -6
- package/app/apps/github/src/inbox/subjects.ts +5 -4
- package/app/apps/github/src/inbox/subscription-controls.tsx +14 -5
- package/app/apps/github/src/inbox/subscriptions.ts +95 -35
- package/app/apps/github/src/inbox/threads.ts +6 -6
- package/app/apps/github/src/issues/changes.ts +40 -16
- package/app/apps/github/src/issues/counts.ts +8 -5
- package/app/apps/github/src/issues/issue-list.tsx +20 -6
- package/app/apps/github/src/issues/issue-page.tsx +30 -14
- package/app/apps/github/src/issues/issues.ts +195 -46
- package/app/apps/github/src/issues/label-dialog.tsx +8 -11
- package/app/apps/github/src/issues/labels-page.tsx +35 -3
- package/app/apps/github/src/issues/milestone-dialog.tsx +197 -0
- package/app/apps/github/src/issues/milestones-page.tsx +269 -0
- package/app/apps/github/src/issues/new-issue.tsx +3 -1
- package/app/apps/github/src/issues/sidebar.tsx +8 -6
- package/app/apps/github/src/markdown/README.md +22 -17
- package/app/apps/github/src/markdown/context.ts +83 -10
- package/app/apps/github/src/markdown/images.ts +3 -2
- package/app/apps/github/src/markdown/lookup.ts +17 -11
- package/app/apps/github/src/markdown/page-budget.ts +50 -0
- package/app/apps/github/src/markdown/patches.ts +74 -32
- package/app/apps/github/src/markdown/query.ts +7 -2
- package/app/apps/github/src/markdown/remote.ts +106 -0
- package/app/apps/github/src/markdown/render.ts +101 -24
- package/app/apps/github/src/markdown/texts.ts +43 -0
- package/app/apps/github/src/markdown/words-module.d.ts +5 -0
- package/app/apps/github/src/markdown/words-plugin.ts +135 -0
- package/app/apps/github/src/names/repos.ts +1 -1
- package/app/apps/github/src/palette/palette.tsx +28 -10
- package/app/apps/github/src/palette/rows.tsx +93 -40
- package/app/apps/github/src/palette/server.ts +10 -7
- package/app/apps/github/src/palette/targets.ts +1 -0
- package/app/apps/github/src/policy.ts +137 -61
- package/app/apps/github/src/private-repos.ts +5 -5
- package/app/apps/github/src/pulls/compare-page.tsx +6 -3
- package/app/apps/github/src/pulls/files-tab.tsx +480 -214
- package/app/apps/github/src/pulls/held-summary.ts +178 -0
- package/app/apps/github/src/pulls/live.ts +6 -4
- package/app/apps/github/src/pulls/merge-box.tsx +17 -10
- package/app/apps/github/src/pulls/pull-list.tsx +6 -3
- package/app/apps/github/src/pulls/pull-page.tsx +19 -10
- package/app/apps/github/src/pulls/pull.ts +68 -40
- package/app/apps/github/src/pulls/pulls.ts +39 -22
- package/app/apps/github/src/pulls/review-drafts.ts +131 -0
- package/app/apps/github/src/pulls/review.ts +374 -99
- package/app/apps/github/src/pulls/threads.tsx +152 -0
- package/app/apps/github/src/queue/queue-page.tsx +15 -8
- package/app/apps/github/src/queue/queue.ts +35 -20
- package/app/apps/github/src/releases/latest-release.tsx +3 -1
- package/app/apps/github/src/releases/overview.tsx +4 -2
- package/app/apps/github/src/releases/release-form.tsx +8 -5
- package/app/apps/github/src/releases/release-list.tsx +8 -5
- package/app/apps/github/src/releases/release-view.tsx +1 -0
- package/app/apps/github/src/releases/releases.ts +33 -23
- package/app/apps/github/src/releases/tag-list.tsx +3 -1
- package/app/apps/github/src/router.tsx +5 -2
- package/app/apps/github/src/routes/$owner/$repo/_code/blob/$.tsx +7 -1
- package/app/apps/github/src/routes/$owner/$repo/_code/tree/$.tsx +6 -1
- package/app/apps/github/src/routes/$owner/$repo/_releases/releases/index.tsx +2 -1
- package/app/apps/github/src/routes/$owner/$repo/_releases/tags.tsx +1 -1
- package/app/apps/github/src/routes/$owner/$repo/branches.tsx +5 -1
- package/app/apps/github/src/routes/$owner/$repo/commit/$sha.tsx +1 -1
- package/app/apps/github/src/routes/$owner/$repo/commits/$.tsx +6 -1
- package/app/apps/github/src/routes/$owner/$repo/index.tsx +1 -1
- package/app/apps/github/src/routes/$owner/$repo/issues/$number.tsx +4 -2
- package/app/apps/github/src/routes/$owner/$repo/issues/index.tsx +2 -2
- package/app/apps/github/src/routes/$owner/$repo/issues/new.tsx +5 -2
- package/app/apps/github/src/routes/$owner/$repo/labels.tsx +2 -1
- package/app/apps/github/src/routes/$owner/$repo/milestones.tsx +36 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/route.tsx +4 -2
- package/app/apps/github/src/routes/$owner/$repo/pulls/index.tsx +2 -2
- package/app/apps/github/src/routes/$owner/$repo/queue.tsx +2 -1
- package/app/apps/github/src/routes/$owner/$repo/releases/edit/$.tsx +5 -2
- package/app/apps/github/src/routes/$owner/$repo/releases/new.tsx +2 -1
- package/app/apps/github/src/routes/$owner/$repo/releases/tag/$.tsx +4 -2
- package/app/apps/github/src/routes/$owner/$repo/route.tsx +9 -5
- package/app/apps/github/src/routes/$owner/$repo/settings/hooks/index.tsx +3 -1
- package/app/apps/github/src/routes/$owner/$repo/settings/index.tsx +3 -1
- package/app/apps/github/src/routes/-nav.tsx +10 -2
- package/app/apps/github/src/routes/-root-testing.ts +29 -6
- package/app/apps/github/src/routes/__root.tsx +9 -4
- package/app/apps/github/src/routes/index.tsx +3 -1
- package/app/apps/github/src/routes/orgs/$owner/route.tsx +4 -1
- package/app/apps/github/src/routes/orgs/$owner/settings.tsx +4 -1
- package/app/apps/github/src/seed/acme.ts +1 -1
- package/app/apps/github/src/seed/seed.ts +199 -120
- package/app/apps/github/src/server.ts +24 -15
- package/app/apps/github/src/settings/account-avatar.tsx +4 -1
- package/app/apps/github/src/settings/general-settings.tsx +3 -1
- package/app/apps/github/src/settings/general.ts +4 -4
- package/app/apps/github/src/settings/hook-form.tsx +3 -1
- package/app/apps/github/src/settings/hook-list.tsx +5 -2
- package/app/apps/github/src/settings/hooks.ts +7 -7
- package/app/apps/github/src/settings/org-settings.tsx +3 -1
- package/app/apps/github/src/settings/orgs.ts +21 -11
- package/app/apps/github/src/settings/settings-layout.tsx +3 -1
- package/app/apps/github/src/signin/approval.ts +4 -3
- package/app/apps/github/src/signin/auth.ts +9 -2
- package/app/apps/github/src/signin/device-code.ts +8 -3
- package/app/apps/github/src/signin/device-prompt.ts +28 -3
- package/app/apps/github/src/signin/revoke.ts +36 -0
- package/app/apps/github/tsconfig.json +4 -1
- package/app/apps/github/vite.config.ts +8 -0
- package/app/pnpm-workspace.yaml +9 -5
- package/app/tsconfig.base.json +1 -0
- package/dist/cli/child.mjs +1 -1
- package/dist/cli/credentials.mjs +4 -4
- package/dist/cli/documents.mjs +32 -22
- package/dist/cli/events.mjs +1 -1
- package/dist/cli/failure.mjs +20 -7
- package/dist/cli/folders.mjs +2 -2
- package/dist/cli/git-remote-ref0.mjs +47 -22
- package/dist/cli/git.mjs +26 -5
- package/dist/cli/helpers.mjs +168 -35
- package/dist/cli/hosts.mjs +3 -3
- package/dist/cli/output.mjs +2 -2
- package/dist/cli/prompt.mjs +1 -1
- package/dist/cli/queue.mjs +7 -7
- package/dist/cli/ref0-git.mjs +2 -2
- package/dist/cli/repos.mjs +35 -18
- package/dist/cli/resources.mjs +5 -5
- package/dist/cli/retry-after.mjs +8 -0
- package/dist/cli/setup.mjs +172 -66
- package/dist/cli/sign-in.mjs +65 -23
- package/dist/cli/sign-ins.mjs +70 -13
- package/dist/cli/sqlite.mjs +2 -2
- package/dist/cli/tokens.mjs +3 -3
- package/dist/cli/vendor.mjs +1 -1
- package/dist/init/app.mjs +18 -20
- package/dist/init/choices.mjs +1 -1
- package/dist/init/cloudflare.mjs +15 -19
- package/dist/init/create.mjs +4 -3
- package/dist/init/detect.mjs +4 -4
- package/dist/init/files.mjs +121 -9
- package/dist/init/frameworks.mjs +16 -0
- package/dist/init/git-module.mjs +22 -7
- package/dist/init/jsonc.mjs +9 -7
- package/dist/init/metadata.mjs +9 -3
- package/dist/init/mounts.mjs +13 -10
- package/dist/init/next.mjs +3 -5
- package/dist/init/node-app.mjs +3 -3
- package/dist/init/node.mjs +41 -42
- package/dist/init/nuxt.mjs +153 -27
- package/dist/init/stores.mjs +14 -9
- package/dist/init/sveltekit.mjs +4 -2
- package/dist/init/template.mjs +9 -6
- package/dist/init/templates.mjs +64 -48
- package/dist/init/vercel.mjs +37 -36
- package/dist/init/versions.mjs +3 -3
- 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({
|
|
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
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
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(
|
|
221
|
-
page
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
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(
|
|
248
|
-
page
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
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
|
-
? {
|
|
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 = (
|
|
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({
|
|
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
|
-
? {
|
|
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
|
-
/**
|
|
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: '' }, {
|
|
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
|
-
? {
|
|
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 {
|
|
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: [
|
|
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: [
|
|
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)),
|