ref0-git 0.3.0 → 0.6.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 +9 -8
- 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 +7 -4
- package/app/apps/github/src/palette/rows.tsx +54 -33
- package/app/apps/github/src/palette/server.ts +5 -5
- package/app/apps/github/src/palette/targets.ts +1 -0
- package/app/apps/github/src/policy.ts +165 -66
- package/app/apps/github/src/private-repos.ts +2 -2
- 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 -110
- 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 +12 -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 +1 -1
- package/dist/cli/helpers.mjs +2 -2
- 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 +4 -4
- 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 +20 -21
- package/dist/init/choices.mjs +1 -1
- package/dist/init/cloudflare.mjs +15 -19
- package/dist/init/create.mjs +3 -2
- package/dist/init/detect.mjs +4 -4
- package/dist/init/files.mjs +120 -13
- 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 +2 -2
- package/dist/init/node-app.mjs +3 -3
- package/dist/init/node.mjs +42 -45
- 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 +63 -47
- package/dist/init/vercel.mjs +37 -37
- package/dist/init/versions.mjs +3 -3
- package/package.json +6 -5
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { useCallback, useRef, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
/** What each state holds: the drop-in's summary, `server`, the summary as typed, and the fence. */
|
|
4
|
+
interface Held {
|
|
5
|
+
readonly server: string;
|
|
6
|
+
readonly text: string;
|
|
7
|
+
readonly at: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Review changes' summary, as the page holds it: the pending review's body as the drop-in has it,
|
|
12
|
+
* `server`, and as typed, `text`, kept across the box's close until a save lands. One save is in
|
|
13
|
+
* flight at a time, and its answer moves only the state that sent it, by the fence `at`.
|
|
14
|
+
*/
|
|
15
|
+
export type Summary =
|
|
16
|
+
/** `text` is what the drop-in holds: nothing to save. */
|
|
17
|
+
| (Held & { readonly kind: 'synced' })
|
|
18
|
+
/** `text` isn't saved, and no save is in flight: it's sent after the pause, or as the box closes. */
|
|
19
|
+
| (Held & { readonly kind: 'typed' })
|
|
20
|
+
/** `sent` is in flight under the fence `at`; `text` may have moved on since. */
|
|
21
|
+
| (Held & { readonly kind: 'saving'; readonly sent: string })
|
|
22
|
+
/** `text` was refused: it waits for a key, Try again, or the box's next open. */
|
|
23
|
+
| (Held & { readonly kind: 'refused'; readonly error: Error })
|
|
24
|
+
/** The review's submit or discard is in flight: no save starts, and `text` is what it sends. */
|
|
25
|
+
| (Held & { readonly kind: 'ending' });
|
|
26
|
+
|
|
27
|
+
export type SummaryEvent =
|
|
28
|
+
| { readonly type: 'type'; readonly text: string }
|
|
29
|
+
/** Starts a save of the text, after the pause, as the box closes, or on Try again. */
|
|
30
|
+
| { readonly type: 'send' }
|
|
31
|
+
| { readonly type: 'landed'; readonly at: number }
|
|
32
|
+
| { readonly type: 'refused'; readonly at: number; readonly error: Error }
|
|
33
|
+
/** The pending review's body, as the page read it again. */
|
|
34
|
+
| { readonly type: 'read'; readonly body: string }
|
|
35
|
+
/** The box opens: a refused text is tried once more after the pause. */
|
|
36
|
+
| { readonly type: 'open' }
|
|
37
|
+
/** A submit or discard starts: never past a save in flight, which it waits for. */
|
|
38
|
+
| { readonly type: 'end' }
|
|
39
|
+
/** The submit or discard was refused: the text is as it was. */
|
|
40
|
+
| { readonly type: 'kept' }
|
|
41
|
+
/** The submit or discard landed: nothing is pending, and no answer in flight counts. */
|
|
42
|
+
| { readonly type: 'ended' };
|
|
43
|
+
|
|
44
|
+
/** The summary at `server`, the drop-in's, and nothing typed past it. */
|
|
45
|
+
export const syncedAt = (server: string, at = 0): Summary => ({
|
|
46
|
+
kind: 'synced',
|
|
47
|
+
server,
|
|
48
|
+
text: server,
|
|
49
|
+
at,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
/** `text` against `server`, saved or not, with no save in flight. */
|
|
53
|
+
const settled = (server: string, text: string, at: number): Summary =>
|
|
54
|
+
text === server ? { kind: 'synced', server, text, at } : { kind: 'typed', server, text, at };
|
|
55
|
+
|
|
56
|
+
/** The one move `event` makes from `state`, or `state` itself when it makes none. */
|
|
57
|
+
export const moveSummary = (state: Summary, event: SummaryEvent): Summary => {
|
|
58
|
+
switch (event.type) {
|
|
59
|
+
case 'type':
|
|
60
|
+
if (state.kind === 'saving' || state.kind === 'ending') return { ...state, text: event.text };
|
|
61
|
+
|
|
62
|
+
return settled(state.server, event.text, state.at);
|
|
63
|
+
|
|
64
|
+
case 'send':
|
|
65
|
+
if (state.kind !== 'typed' && state.kind !== 'refused') return state;
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
kind: 'saving',
|
|
69
|
+
server: state.server,
|
|
70
|
+
text: state.text,
|
|
71
|
+
at: state.at + 1,
|
|
72
|
+
sent: state.text,
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
case 'landed':
|
|
76
|
+
if (state.kind !== 'saving' || state.at !== event.at) return state;
|
|
77
|
+
|
|
78
|
+
return settled(state.sent, state.text, state.at);
|
|
79
|
+
|
|
80
|
+
case 'refused':
|
|
81
|
+
if (state.kind !== 'saving' || state.at !== event.at) return state;
|
|
82
|
+
|
|
83
|
+
if (state.text !== state.sent) return settled(state.server, state.text, state.at);
|
|
84
|
+
|
|
85
|
+
return {
|
|
86
|
+
kind: 'refused',
|
|
87
|
+
server: state.server,
|
|
88
|
+
text: state.text,
|
|
89
|
+
at: state.at,
|
|
90
|
+
error: event.error,
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
case 'read':
|
|
94
|
+
if (state.server === event.body) return state;
|
|
95
|
+
|
|
96
|
+
// A save or an end in flight settles only on its own answer, whatever is read meanwhile.
|
|
97
|
+
if (state.kind === 'saving' || state.kind === 'ending')
|
|
98
|
+
return { ...state, server: event.body };
|
|
99
|
+
|
|
100
|
+
if (state.kind === 'synced' || state.text === event.body) {
|
|
101
|
+
return syncedAt(event.body, state.at);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return { ...state, server: event.body };
|
|
105
|
+
|
|
106
|
+
case 'open':
|
|
107
|
+
if (state.kind !== 'refused') return state;
|
|
108
|
+
|
|
109
|
+
return settled(state.server, state.text, state.at);
|
|
110
|
+
|
|
111
|
+
case 'end':
|
|
112
|
+
if (state.kind === 'saving' || state.kind === 'ending') return state;
|
|
113
|
+
|
|
114
|
+
return { kind: 'ending', server: state.server, text: state.text, at: state.at };
|
|
115
|
+
|
|
116
|
+
case 'kept':
|
|
117
|
+
if (state.kind !== 'ending') return state;
|
|
118
|
+
|
|
119
|
+
return settled(state.server, state.text, state.at);
|
|
120
|
+
|
|
121
|
+
case 'ended':
|
|
122
|
+
if (state.kind !== 'ending') return state;
|
|
123
|
+
|
|
124
|
+
return syncedAt('', state.at + 1);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* The summary's machine for one pull request's page: `send` moves it and answers the state it
|
|
130
|
+
* moved to, so a save starts only from the move into `saving`, and its answer carries that fence.
|
|
131
|
+
*/
|
|
132
|
+
export const useHeldSummary = (save: (text: string) => Promise<void>) => {
|
|
133
|
+
const current = useRef(syncedAt(''));
|
|
134
|
+
const [summary, setSummary] = useState(current.current);
|
|
135
|
+
const saveRef = useRef(save);
|
|
136
|
+
saveRef.current = save;
|
|
137
|
+
// The save in flight, answered, which an end waits for.
|
|
138
|
+
const flight = useRef<Promise<void>>(Promise.resolve());
|
|
139
|
+
|
|
140
|
+
const send = useCallback((event: SummaryEvent): Summary => {
|
|
141
|
+
const before = current.current;
|
|
142
|
+
const next = moveSummary(before, event);
|
|
143
|
+
if (next === before) return before;
|
|
144
|
+
|
|
145
|
+
current.current = next;
|
|
146
|
+
setSummary(next);
|
|
147
|
+
|
|
148
|
+
// A save starts from its own move, and its answer is fenced on the state it started from.
|
|
149
|
+
if (next.kind === 'saving' && before.kind !== 'saving') {
|
|
150
|
+
const { at, sent } = next;
|
|
151
|
+
flight.current = saveRef.current(sent).then(
|
|
152
|
+
() => void send({ type: 'landed', at }),
|
|
153
|
+
(error: Error) => void send({ type: 'refused', at, error }),
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return next;
|
|
158
|
+
}, []);
|
|
159
|
+
|
|
160
|
+
/** Runs `act`, a submit or a discard, once no save is in flight, and none starts until it's done. */
|
|
161
|
+
const end = useCallback(
|
|
162
|
+
async (act: (text: string) => Promise<void>) => {
|
|
163
|
+
while (send({ type: 'end' }).kind !== 'ending') await flight.current;
|
|
164
|
+
|
|
165
|
+
try {
|
|
166
|
+
await act(current.current.text);
|
|
167
|
+
} catch (error) {
|
|
168
|
+
send({ type: 'kept' });
|
|
169
|
+
throw error;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
send({ type: 'ended' });
|
|
173
|
+
},
|
|
174
|
+
[send],
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
return { summary, send, end };
|
|
178
|
+
};
|
|
@@ -2,7 +2,7 @@ import type { QueryClient } from '@tanstack/react-query';
|
|
|
2
2
|
import * as Option from 'effect/Option';
|
|
3
3
|
import * as Schema from 'effect/Schema';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import type { Clients } from '../clients/clients.ts';
|
|
6
6
|
import type { RepoPlace } from '../code/places.ts';
|
|
7
7
|
import type { Ending, Followed } from '../live/follow.ts';
|
|
8
8
|
import type { StreamMessage } from '../live/sse.ts';
|
|
@@ -45,6 +45,7 @@ const apiPathOf = (url: string) => {
|
|
|
45
45
|
* and opens its stream after `cursor`. A subscription lasts a day, so each opening asks again.
|
|
46
46
|
*/
|
|
47
47
|
const openPullStream = async (
|
|
48
|
+
clients: Clients,
|
|
48
49
|
origin: () => string,
|
|
49
50
|
place: RepoPlace,
|
|
50
51
|
number: number,
|
|
@@ -52,7 +53,7 @@ const openPullStream = async (
|
|
|
52
53
|
signal: AbortSignal,
|
|
53
54
|
) => {
|
|
54
55
|
const resource = `${origin()}/${place.owner}/${place.repo}/pull/${number}`;
|
|
55
|
-
const subscribed = await callAt('github', '/event-subscriptions', {
|
|
56
|
+
const subscribed = await clients.callAt('github', '/event-subscriptions', {
|
|
56
57
|
method: 'POST',
|
|
57
58
|
headers: { 'content-type': 'application/json', accept: 'application/json' },
|
|
58
59
|
body: JSON.stringify({ resource_url: resource, event_types: Object.values(pullEvents) }),
|
|
@@ -67,7 +68,7 @@ const openPullStream = async (
|
|
|
67
68
|
const headers = new Headers({ accept: 'text/event-stream' });
|
|
68
69
|
if (cursor !== undefined) headers.set('last-event-id', cursor);
|
|
69
70
|
|
|
70
|
-
return callAt('github', path, { headers, signal });
|
|
71
|
+
return clients.callAt('github', path, { headers, signal });
|
|
71
72
|
};
|
|
72
73
|
|
|
73
74
|
/** How `github.stream.end` ends a stream: it says why in its data. */
|
|
@@ -101,13 +102,14 @@ const refreshFor = (client: QueryClient, place: RepoPlace, number: number, type:
|
|
|
101
102
|
* reads the whole page again, since the stream gives nothing from before it.
|
|
102
103
|
*/
|
|
103
104
|
export const pullStream = (
|
|
105
|
+
clients: Clients,
|
|
104
106
|
origin: () => string,
|
|
105
107
|
client: QueryClient,
|
|
106
108
|
place: RepoPlace,
|
|
107
109
|
number: number,
|
|
108
110
|
): Omit<Followed, 'state'> => ({
|
|
109
111
|
start: fromNow,
|
|
110
|
-
open: (cursor, signal) => openPullStream(origin, place, number, cursor, signal),
|
|
112
|
+
open: (cursor, signal) => openPullStream(clients, origin, place, number, cursor, signal),
|
|
111
113
|
opened: (fresh) => {
|
|
112
114
|
if (!fresh) return;
|
|
113
115
|
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
import { useEffect, useState, type ReactNode } from 'react';
|
|
12
12
|
import { toast } from 'sonner';
|
|
13
13
|
|
|
14
|
+
import { useClients } from '../clients/clients.ts';
|
|
14
15
|
import type { PageOperation } from '../clients/allowed.ts';
|
|
15
16
|
import { Go } from '../code/controls.tsx';
|
|
16
17
|
import type { RepoPlace } from '../code/places.ts';
|
|
@@ -39,6 +40,7 @@ import {
|
|
|
39
40
|
mergePull,
|
|
40
41
|
protectionOf,
|
|
41
42
|
pullAt,
|
|
43
|
+
queuedKey,
|
|
42
44
|
queuedOf,
|
|
43
45
|
refreshPull,
|
|
44
46
|
type Check,
|
|
@@ -117,13 +119,14 @@ export function MergeBox({
|
|
|
117
119
|
readonly pull: PullDetail;
|
|
118
120
|
readonly allowed: ReadonlySet<PageOperation>;
|
|
119
121
|
}) {
|
|
122
|
+
const clients = useClients();
|
|
120
123
|
const client = useQueryClient();
|
|
121
124
|
const open = pull.state === 'open' && pull.merged === null;
|
|
122
|
-
const protection = useQuery({ ...protectionOf(place, pull.base.ref), enabled: open });
|
|
125
|
+
const protection = useQuery({ ...protectionOf(clients, place, pull.base.ref), enabled: open });
|
|
123
126
|
// While the queue holds it, the box reads its entry and the pull request again, so its place in
|
|
124
127
|
// the queue, its leaving it and its merge all show.
|
|
125
128
|
const queued = useQuery({
|
|
126
|
-
...queuedOf(place, pull.base.ref, pull.number),
|
|
129
|
+
...queuedOf(clients, place, pull.base.ref, pull.number),
|
|
127
130
|
enabled: open,
|
|
128
131
|
refetchInterval: ({ state }) => (state.data === null ? false : queuePoll),
|
|
129
132
|
});
|
|
@@ -138,7 +141,7 @@ export function MergeBox({
|
|
|
138
141
|
if (entry !== undefined) client.setQueryData(queryKey, entry);
|
|
139
142
|
}, [client, owner, name, pull.number, entry]);
|
|
140
143
|
const ended = useQuery({
|
|
141
|
-
...entryStateOf(last ?? ''),
|
|
144
|
+
...entryStateOf(clients, last ?? ''),
|
|
142
145
|
enabled: open && last !== undefined && queued.data === null,
|
|
143
146
|
refetchInterval: ({ state }) => (endedOf(state.data) ? false : queuePoll),
|
|
144
147
|
});
|
|
@@ -147,16 +150,16 @@ export function MergeBox({
|
|
|
147
150
|
// The queue let it go, and how isn't known yet: the box offers nothing until it is.
|
|
148
151
|
const leaving = open && queued.data === null && last !== undefined && !endedOf(ended.data);
|
|
149
152
|
useQuery({
|
|
150
|
-
...pullAt(place, pull.number),
|
|
153
|
+
...pullAt(clients, place, pull.number),
|
|
151
154
|
refetchInterval: waiting || landing || leaving ? queuePoll : false,
|
|
152
155
|
});
|
|
153
|
-
const checks = useQuery(checksOf(place, pull.head.sha)).data ?? [];
|
|
156
|
+
const checks = useQuery(checksOf(clients, place, pull.head.sha)).data ?? [];
|
|
154
157
|
const [method, setMethod] = useState<MergeMethod | undefined>();
|
|
155
158
|
|
|
156
159
|
const refresh = () =>
|
|
157
160
|
Promise.all([
|
|
158
161
|
refreshPull(client, place, pull.number),
|
|
159
|
-
client.invalidateQueries({ queryKey:
|
|
162
|
+
client.invalidateQueries({ queryKey: queuedKey(place, pull.base.ref, pull.number) }),
|
|
160
163
|
]);
|
|
161
164
|
// A failed act reads again too: a refusal can mean the queue moved on, as an entry gone does.
|
|
162
165
|
const acted = useMutation({
|
|
@@ -166,9 +169,9 @@ export function MergeBox({
|
|
|
166
169
|
// Adding answers the drop-in's entry, not Git's, so the box reads the queue at once and keeps the
|
|
167
170
|
// entry it finds there, as it keeps one it saw waiting: a merge before the page reads again shows.
|
|
168
171
|
const add = async () => {
|
|
169
|
-
await enqueuePull(pull);
|
|
172
|
+
await enqueuePull(clients, pull);
|
|
170
173
|
const found = await client.fetchQuery({
|
|
171
|
-
...queuedOf(place, pull.base.ref, pull.number),
|
|
174
|
+
...queuedOf(clients, place, pull.base.ref, pull.number),
|
|
172
175
|
staleTime: 0,
|
|
173
176
|
});
|
|
174
177
|
if (found !== null) client.setQueryData(lastEntryOf(place, pull.number).queryKey, found.entry);
|
|
@@ -273,7 +276,7 @@ export function MergeBox({
|
|
|
273
276
|
description="It leaves the queue, and isn't merged by it. You can add it again."
|
|
274
277
|
disabled={acted.isPending}
|
|
275
278
|
onConfirm={() =>
|
|
276
|
-
acted.mutate(() => dequeuePull(pull), {
|
|
279
|
+
acted.mutate(() => dequeuePull(clients, pull), {
|
|
277
280
|
onSuccess: () => toast.success(`Removed #${pull.number} from the merge queue`),
|
|
278
281
|
})
|
|
279
282
|
}
|
|
@@ -302,7 +305,11 @@ export function MergeBox({
|
|
|
302
305
|
disabled={acted.isPending}
|
|
303
306
|
onClick={() =>
|
|
304
307
|
acted.mutate(
|
|
305
|
-
() =>
|
|
308
|
+
() =>
|
|
309
|
+
mergePull(clients, place, pull.number, {
|
|
310
|
+
method: chosen,
|
|
311
|
+
sha: pull.head.sha,
|
|
312
|
+
}),
|
|
306
313
|
{ onSuccess: () => toast.success(`Merged #${pull.number}`) },
|
|
307
314
|
)
|
|
308
315
|
}
|
|
@@ -2,6 +2,7 @@ import { useInfiniteQuery, useQuery } from '@tanstack/react-query';
|
|
|
2
2
|
import { useNavigate } from '@tanstack/react-router';
|
|
3
3
|
import { ListOrderedIcon } from 'lucide-react';
|
|
4
4
|
|
|
5
|
+
import { useClients } from '../clients/clients.ts';
|
|
5
6
|
import { Go } from '../code/controls.tsx';
|
|
6
7
|
import { repoHref, type RepoPlace } from '../code/places.ts';
|
|
7
8
|
import { cn } from '#/lib/cn';
|
|
@@ -110,7 +111,8 @@ function Pulls({
|
|
|
110
111
|
readonly filter: PullFilter;
|
|
111
112
|
readonly vocabulary: Vocabulary;
|
|
112
113
|
}) {
|
|
113
|
-
const
|
|
114
|
+
const clients = useClients();
|
|
115
|
+
const pages = useInfiniteQuery(pullList(clients, place, filter, vocabulary));
|
|
114
116
|
const pulls = pages.data?.pages.flatMap((page) => page.pulls) ?? [];
|
|
115
117
|
if (pages.isPending) return <Skeleton className="h-40" />;
|
|
116
118
|
|
|
@@ -160,9 +162,10 @@ export function PullList({
|
|
|
160
162
|
/** The signed-in viewer's login, which `@me` names. */
|
|
161
163
|
readonly viewer: string | undefined;
|
|
162
164
|
}) {
|
|
165
|
+
const clients = useClients();
|
|
163
166
|
const navigate = useNavigate();
|
|
164
167
|
const filter = pullFilterOf(query);
|
|
165
|
-
const vocabulary = useQuery(vocabularyOf(place));
|
|
168
|
+
const vocabulary = useQuery(vocabularyOf(clients, place));
|
|
166
169
|
const allowed = useAllowed(place);
|
|
167
170
|
const go = (next: PullFilter) => void navigate({ href: pullsHref(place, pullQueryOf(next)) });
|
|
168
171
|
// Open and Closed name a state alone, as GitHub's links do: neither keeps `is:merged`.
|
|
@@ -174,7 +177,7 @@ export function PullList({
|
|
|
174
177
|
const queries = reviewed
|
|
175
178
|
? undefined
|
|
176
179
|
: tabQueries((state) => pullSearchQueryOf(place, { ...filter, state, merged: undefined }));
|
|
177
|
-
const counts = useQuery(tabCounts(place, 'pulls', queries));
|
|
180
|
+
const counts = useQuery(tabCounts(clients, place, 'pulls', queries));
|
|
178
181
|
|
|
179
182
|
return (
|
|
180
183
|
<div className="flex flex-col gap-3">
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
} from 'lucide-react';
|
|
10
10
|
import type { ReactNode } from 'react';
|
|
11
11
|
|
|
12
|
+
import { useClients } from '../clients/clients.ts';
|
|
12
13
|
import type { PageOperation } from '../clients/allowed.ts';
|
|
13
14
|
import { day, Go } from '../code/controls.tsx';
|
|
14
15
|
import type { RepoPlace } from '../code/places.ts';
|
|
@@ -42,6 +43,7 @@ import { Section, Sidebar } from '../issues/sidebar.tsx';
|
|
|
42
43
|
import { useFollow } from '../live/use-follow.ts';
|
|
43
44
|
import { pullStream } from './live.ts';
|
|
44
45
|
import { MergeBox } from './merge-box.tsx';
|
|
46
|
+
import { UnresolvedThreads } from './threads.tsx';
|
|
45
47
|
import { pullStatuses } from '../components/pull-status.tsx';
|
|
46
48
|
import { pullHref } from './pull-list.tsx';
|
|
47
49
|
import {
|
|
@@ -84,6 +86,7 @@ export function PullHeader({
|
|
|
84
86
|
readonly place: RepoPlace;
|
|
85
87
|
readonly pull: PullDetail;
|
|
86
88
|
}) {
|
|
89
|
+
const clients = useClients();
|
|
87
90
|
const client = useQueryClient();
|
|
88
91
|
const pull = useShown(place, held);
|
|
89
92
|
const allowed = useAllowed(place, pull.number);
|
|
@@ -94,7 +97,7 @@ export function PullHeader({
|
|
|
94
97
|
const { viewer } = useRouteContext({ from: '__root__' });
|
|
95
98
|
const live = useFollow(
|
|
96
99
|
viewer == null ? undefined : `${place.owner}/${place.repo}#${pull.number}`,
|
|
97
|
-
pullStream(pageOrigin, client, place, pull.number),
|
|
100
|
+
pullStream(clients, pageOrigin, client, place, pull.number),
|
|
98
101
|
);
|
|
99
102
|
const href = pullHref(place, pull.number);
|
|
100
103
|
const commits = `${pull.commits} ${pull.commits === 1 ? 'commit' : 'commits'}`;
|
|
@@ -106,7 +109,7 @@ export function PullHeader({
|
|
|
106
109
|
);
|
|
107
110
|
|
|
108
111
|
const saveTitle = async (title: string) => {
|
|
109
|
-
await changeIssue(place, pull.number, { title });
|
|
112
|
+
await changeIssue(clients, place, pull.number, { title });
|
|
110
113
|
await refreshPull(client, place, pull.number);
|
|
111
114
|
};
|
|
112
115
|
|
|
@@ -199,7 +202,7 @@ const reviewDid = (state: string) => {
|
|
|
199
202
|
};
|
|
200
203
|
|
|
201
204
|
/** Reviews in the conversation, each where it was submitted: a pending one shows to no one. */
|
|
202
|
-
const reviewEvents = (repo: string, reviews: readonly Review[]): TimelineEvent[] =>
|
|
205
|
+
const reviewEvents = (repo: string, number: number, reviews: readonly Review[]): TimelineEvent[] =>
|
|
203
206
|
reviews.flatMap((review) =>
|
|
204
207
|
review.submitted === null
|
|
205
208
|
? []
|
|
@@ -216,6 +219,7 @@ const reviewEvents = (repo: string, reviews: readonly Review[]): TimelineEvent[]
|
|
|
216
219
|
standing={standingOf(review.state)}
|
|
217
220
|
created={review.submitted}
|
|
218
221
|
body={review.body}
|
|
222
|
+
from={{ kind: 'review', repo, number, id: review.id }}
|
|
219
223
|
save={undefined}
|
|
220
224
|
/>
|
|
221
225
|
),
|
|
@@ -241,7 +245,8 @@ function Reviewers({
|
|
|
241
245
|
readonly allowed: ReadonlySet<PageOperation>;
|
|
242
246
|
readonly holding: Holding;
|
|
243
247
|
}) {
|
|
244
|
-
const
|
|
248
|
+
const clients = useClients();
|
|
249
|
+
const vocabulary = useQuery(vocabularyOf(clients, place)).data;
|
|
245
250
|
const shown = useShown(place, pull);
|
|
246
251
|
const { commit, changing } = useChange(place, pull.number, holding);
|
|
247
252
|
// What the open picker holds, shown at once and sent as it closes.
|
|
@@ -252,7 +257,7 @@ function Reviewers({
|
|
|
252
257
|
const picked = draft.take();
|
|
253
258
|
if (picked === undefined || sameSet(picked, shown.requested)) return;
|
|
254
259
|
|
|
255
|
-
commit(reviewersChange(changing, picked));
|
|
260
|
+
commit(reviewersChange(clients, changing, picked));
|
|
256
261
|
};
|
|
257
262
|
|
|
258
263
|
const reviewers = [...new Set(reviews.map((review) => review.login))].filter(
|
|
@@ -328,14 +333,15 @@ export function PullConversation({
|
|
|
328
333
|
readonly repo: Repo;
|
|
329
334
|
readonly pull: PullDetail;
|
|
330
335
|
}) {
|
|
336
|
+
const clients = useClients();
|
|
331
337
|
const client = useQueryClient();
|
|
332
338
|
const pull = useShown(place, held);
|
|
333
339
|
const allowed = useAllowed(place, pull.number);
|
|
334
|
-
const reviews = useQuery(reviewsOf(place, pull.number));
|
|
340
|
+
const reviews = useQuery(reviewsOf(clients, place, pull.number));
|
|
335
341
|
const holding = pullHolding(client, place, pull.number);
|
|
336
342
|
|
|
337
343
|
const change = async (asked: IssueChange) => {
|
|
338
|
-
await changeIssue(place, pull.number, asked);
|
|
344
|
+
await changeIssue(clients, place, pull.number, asked);
|
|
339
345
|
await refreshPull(client, place, pull.number);
|
|
340
346
|
};
|
|
341
347
|
|
|
@@ -349,10 +355,11 @@ export function PullConversation({
|
|
|
349
355
|
href={pullHref(place, pull.number)}
|
|
350
356
|
change={change}
|
|
351
357
|
holding={holding}
|
|
352
|
-
events={reviewEvents(`${place.owner}/${place.repo}`, reviews.data ?? [])}
|
|
358
|
+
events={reviewEvents(`${place.owner}/${place.repo}`, pull.number, reviews.data ?? [])}
|
|
353
359
|
settled={pull.merged !== null}
|
|
354
360
|
>
|
|
355
361
|
{reviews.error !== null && <Failed error={reviews.error} />}
|
|
362
|
+
<UnresolvedThreads place={place} pull={pull.number} />
|
|
356
363
|
<MergeBox place={place} repo={repo} pull={pull} allowed={allowed} />
|
|
357
364
|
</Conversation>
|
|
358
365
|
<Sidebar
|
|
@@ -394,7 +401,8 @@ export function PullCommits({
|
|
|
394
401
|
readonly place: RepoPlace;
|
|
395
402
|
readonly pull: PullDetail;
|
|
396
403
|
}) {
|
|
397
|
-
const
|
|
404
|
+
const clients = useClients();
|
|
405
|
+
const commits = useQuery(pullCommitsOf(clients, place, pull.number));
|
|
398
406
|
const at = { ...place, ref: { name: pull.head.ref, kind: 'branch' as const }, path: '' };
|
|
399
407
|
if (commits.error !== null) return <Failed error={commits.error} />;
|
|
400
408
|
|
|
@@ -432,7 +440,8 @@ const checkLooks: Readonly<
|
|
|
432
440
|
* token reports, sends no event to a pull request's stream.
|
|
433
441
|
*/
|
|
434
442
|
export function CommitChecks({ place, sha }: { readonly place: RepoPlace; readonly sha: string }) {
|
|
435
|
-
const
|
|
443
|
+
const clients = useClients();
|
|
444
|
+
const checks = useQuery({ ...checksOf(clients, place, sha), refetchInterval: checksPoll });
|
|
436
445
|
if (checks.error !== null) return <Failed error={checks.error} />;
|
|
437
446
|
|
|
438
447
|
if (checks.data === undefined) return <Skeleton className="h-24 w-full" />;
|