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
@@ -1,19 +1,35 @@
1
1
  import { queryOptions, useMutation, useQueryClient } from '@tanstack/react-query';
2
2
  import * as Schema from 'effect/Schema';
3
3
 
4
- import { mutate, query } from '../clients/clients.ts';
4
+ import { type Clients, useClients } from '../clients/clients.ts';
5
5
  import type { RepoPlace } from '../code/places.ts';
6
6
  import { repoAt } from '../code/repo.ts';
7
7
 
8
8
  /**
9
9
  * How the viewer hears of a repo and of each issue and pull request in it, through the drop-in's
10
10
  * GraphQL `viewerSubscription` and `updateSubscription`: the repo header's Watch menu and the
11
- * sidebar's Subscribe button.
11
+ * sidebar's Subscribe button. The sidebar's line says why from `viewerThreadSubscriptionReason`,
12
+ * which only the drop-in serves.
12
13
  */
13
14
 
14
15
  /** GitHub's `SubscriptionState`. For a repo, `SUBSCRIBED` is All activity, `UNSUBSCRIBED` the default. */
15
16
  export type SubscriptionState = 'SUBSCRIBED' | 'UNSUBSCRIBED' | 'IGNORED';
16
17
 
18
+ /** Why the viewer hears a subject: the drop-in's `ThreadSubscriptionReason`, REST's thread `reason`. */
19
+ const ThreadSubscriptionReason = Schema.Literals([
20
+ 'ASSIGN',
21
+ 'AUTHOR',
22
+ 'CI_ACTIVITY',
23
+ 'COMMENT',
24
+ 'MANUAL',
25
+ 'MENTION',
26
+ 'REVIEW_REQUESTED',
27
+ 'STATE_CHANGE',
28
+ 'SUBSCRIBED',
29
+ ]);
30
+
31
+ export type ThreadSubscriptionReason = typeof ThreadSubscriptionReason.Type;
32
+
17
33
  /** What the viewer can read of a repo's or a subject's subscription. */
18
34
  export interface Subscription {
19
35
  /** The node `updateSubscription` changes. */
@@ -22,6 +38,8 @@ export interface Subscription {
22
38
  readonly canSubscribe: boolean;
23
39
  /** Their state, or `null` when they may not read their notifications. */
24
40
  readonly state: SubscriptionState | null;
41
+ /** A subject's: why they hear it, `null` unless they do, and always `null` for a repo. */
42
+ readonly reason: ThreadSubscriptionReason | null;
25
43
  }
26
44
 
27
45
  /**
@@ -44,11 +62,13 @@ export const subscriptionOperations = {
44
62
  id
45
63
  viewerCanSubscribe
46
64
  viewerSubscription
65
+ viewerThreadSubscriptionReason
47
66
  }
48
67
  ... on PullRequest {
49
68
  id
50
69
  viewerCanSubscribe
51
70
  viewerSubscription
71
+ viewerThreadSubscriptionReason
52
72
  }
53
73
  }
54
74
  }
@@ -74,28 +94,44 @@ const Subscribable = Schema.Struct({
74
94
  viewerSubscription: Schema.NullOr(Schema.Literals(['SUBSCRIBED', 'UNSUBSCRIBED', 'IGNORED'])),
75
95
  });
76
96
 
97
+ const SubscribableThread = Schema.Struct({
98
+ ...Subscribable.fields,
99
+ viewerThreadSubscriptionReason: Schema.NullOr(ThreadSubscriptionReason),
100
+ });
101
+
77
102
  const RepositoryAnswer = Schema.Struct({ repository: Schema.NullOr(Subscribable) });
78
103
 
79
104
  const SubjectAnswer = Schema.Struct({
80
- repository: Schema.NullOr(Schema.Struct({ issueOrPullRequest: Schema.NullOr(Subscribable) })),
105
+ repository: Schema.NullOr(
106
+ Schema.Struct({ issueOrPullRequest: Schema.NullOr(SubscribableThread) }),
107
+ ),
81
108
  });
82
109
 
83
- const subscriptionOf = (node: typeof Subscribable.Type | null): Subscription | null =>
110
+ /** A repo's subscription, or with `reason`, a subject's. */
111
+ const subscriptionOf = (
112
+ node: typeof Subscribable.Type | null,
113
+ reason: ThreadSubscriptionReason | null = null,
114
+ ): Subscription | null =>
84
115
  node === null
85
116
  ? null
86
- : { id: node.id, canSubscribe: node.viewerCanSubscribe, state: node.viewerSubscription };
117
+ : {
118
+ id: node.id,
119
+ canSubscribe: node.viewerCanSubscribe,
120
+ state: node.viewerSubscription,
121
+ reason,
122
+ };
87
123
 
88
124
  /** Every subscription the app holds in `place`: the repo's and each subject's, which a watch moves. */
89
125
  const subscriptionsKey = (place: RepoPlace) => ['subscription', place.owner, place.repo] as const;
90
126
 
91
127
  /** The viewer's watch of the repo `place` names, or `null` where they can't read it. */
92
- export const repoSubscription = (place: RepoPlace) =>
128
+ export const repoSubscription = (clients: Clients, place: RepoPlace) =>
93
129
  queryOptions({
94
130
  queryKey: [...subscriptionsKey(place), 'repo'],
95
131
  queryFn: async () =>
96
132
  subscriptionOf(
97
133
  (
98
- await query(
134
+ await clients.query(
99
135
  "How you watch this repository didn't load",
100
136
  subscriptionOperations.repository,
101
137
  { owner: place.owner, name: place.repo },
@@ -108,20 +144,20 @@ export const repoSubscription = (place: RepoPlace) =>
108
144
  });
109
145
 
110
146
  /** The viewer's subscription to issue or pull request `number` in `place`, or `null` for none. */
111
- export const subjectSubscription = (place: RepoPlace, number: number) =>
147
+ export const subjectSubscription = (clients: Clients, place: RepoPlace, number: number) =>
112
148
  queryOptions({
113
149
  queryKey: [...subscriptionsKey(place), 'subject', number],
114
- queryFn: async () =>
115
- subscriptionOf(
116
- (
117
- await query(
118
- "Your subscription didn't load",
119
- subscriptionOperations.subject,
120
- { owner: place.owner, name: place.repo, number },
121
- SubjectAnswer,
122
- )
123
- ).repository?.issueOrPullRequest ?? null,
124
- ),
150
+ queryFn: async () => {
151
+ const answer = await clients.query(
152
+ "Your subscription didn't load",
153
+ subscriptionOperations.subject,
154
+ { owner: place.owner, name: place.repo, number },
155
+ SubjectAnswer,
156
+ );
157
+ const node = answer.repository?.issueOrPullRequest ?? null;
158
+
159
+ return subscriptionOf(node, node?.viewerThreadSubscriptionReason ?? null);
160
+ },
125
161
  staleTime: 30_000,
126
162
  retry: false,
127
163
  });
@@ -131,36 +167,56 @@ export const subjectSubscription = (place: RepoPlace, number: number) =>
131
167
  * since a repo's watch moves each of its subjects', and the repo, whose watcher count it moves.
132
168
  */
133
169
  export const useSubscriptionChange = (place: RepoPlace) => {
170
+ const clients = useClients();
134
171
  const client = useQueryClient();
135
172
 
136
173
  return useMutation({
137
174
  mutationFn: ({ id, state }: { readonly id: string; readonly state: SubscriptionState }) =>
138
- mutate("Your subscription didn't change", subscriptionOperations.update, { id, state }),
175
+ clients.mutate("Your subscription didn't change", subscriptionOperations.update, {
176
+ id,
177
+ state,
178
+ }),
139
179
  onSettled: () =>
140
180
  Promise.all([
141
181
  client.invalidateQueries({ queryKey: subscriptionsKey(place) }),
142
- client.invalidateQueries({ queryKey: repoAt(place).queryKey }),
182
+ client.invalidateQueries({ queryKey: repoAt(clients, place).queryKey }),
143
183
  ]),
144
184
  });
145
185
  };
146
186
 
147
187
  /**
148
- * Why the viewer does or doesn't hear of a subject, from what the app can read: its state, and
149
- * the repo's, where `SUBSCRIBED` is All activity. An ignored repo comes first, then a thread that
150
- * sends nothing, unsubscribed or ignored on its own, then a subscription by watching, and any
151
- * other is the thread's own. A subject is `IGNORED` in an ignored repo too, so only the repo's
152
- * state tells the two ignores apart.
188
+ * What the line says after "because" for each reason: GitHub's own words for a mention, the
189
+ * author, a comment, an assignee, watching and a subscription of the viewer's own, the drop-in's
190
+ * for a review request and a state change, where GitHub's aren't known, and for `ci_activity`
191
+ * GitHub's docs' meaning, a workflow run the viewer triggered that completed.
153
192
  */
154
- const reasonLine = (subject: SubscriptionState, repo: SubscriptionState | null) => {
193
+ const because: Record<ThreadSubscriptionReason, string> = {
194
+ ASSIGN: 'you were assigned',
195
+ AUTHOR: 'you authored the thread',
196
+ CI_ACTIVITY: 'a workflow run you triggered finished',
197
+ COMMENT: 'you commented',
198
+ MANUAL: "you're subscribed to this thread",
199
+ MENTION: 'you were mentioned',
200
+ REVIEW_REQUESTED: 'your review was requested',
201
+ STATE_CHANGE: "you changed the thread's state",
202
+ SUBSCRIBED: "you're watching this repository",
203
+ };
204
+
205
+ /**
206
+ * Why the viewer does or doesn't hear of a subject: an ignored repo first, then a thread that
207
+ * sends nothing, unsubscribed or ignored on its own, then the reason the drop-in gives. A subject
208
+ * is `IGNORED` in an ignored repo too, so only the repo's state tells the two ignores apart.
209
+ */
210
+ const reasonLine = (
211
+ subject: SubscriptionState,
212
+ reason: ThreadSubscriptionReason | null,
213
+ repo: SubscriptionState | null,
214
+ ) => {
155
215
  if (subject === 'IGNORED' && repo === 'IGNORED') return "You're ignoring this repository.";
156
216
 
157
217
  if (subject !== 'SUBSCRIBED') return "You're not receiving notifications from this thread.";
158
218
 
159
- if (repo === 'SUBSCRIBED') {
160
- return "You're receiving notifications because you're watching this repository.";
161
- }
162
-
163
- return "You're receiving notifications because you're subscribed to this thread.";
219
+ return `You're receiving notifications because ${because[reason ?? 'MANUAL']}.`;
164
220
  };
165
221
 
166
222
  /** What a sidebar's Notifications shows: the line that says why, and the button's state to set. */
@@ -171,16 +227,20 @@ export interface Notifications {
171
227
  }
172
228
 
173
229
  /**
174
- * A subject's Notifications, from its state and the repo's: `reasonLine`'s line, and a button
230
+ * A subject's Notifications, from its state, its reason and the repo's: `reasonLine`'s line, and a button
175
231
  * wherever the viewer may change it, as GitHub's always shows one. Unsubscribe turns off what
176
232
  * they hear; any other state's Subscribe turns it on, a thread's ignore too. An ignored repo
177
233
  * still hears nothing then: the drop-in lets no thread's row beat it.
178
234
  */
179
235
  export const notificationsOf = (
180
- subject: { readonly state: SubscriptionState; readonly canSubscribe: boolean },
236
+ subject: {
237
+ readonly state: SubscriptionState;
238
+ readonly reason: ThreadSubscriptionReason | null;
239
+ readonly canSubscribe: boolean;
240
+ },
181
241
  repo: SubscriptionState | null,
182
242
  ): Notifications => ({
183
- line: reasonLine(subject.state, repo),
243
+ line: reasonLine(subject.state, subject.reason, repo),
184
244
  next: subject.canSubscribe
185
245
  ? subject.state === 'SUBSCRIBED'
186
246
  ? 'UNSUBSCRIBED'
@@ -1,7 +1,7 @@
1
1
  import type { components } from '@octokit/openapi-types';
2
2
  import { infiniteQueryOptions } from '@tanstack/react-query';
3
3
 
4
- import { github } from '../clients/clients.ts';
4
+ import type { Clients } from '../clients/clients.ts';
5
5
  import { releaseHref, repoHref, type RepoPlace } from '../code/places.ts';
6
6
  import { failure } from '../hooks/answers.ts';
7
7
  import { nextCursor } from '../hooks/repos.ts';
@@ -145,14 +145,14 @@ const listQueries = {
145
145
  } as const satisfies Record<InboxList, { readonly all: boolean; readonly is_done?: boolean }>;
146
146
 
147
147
  /** One page of `filter`'s tab from `after`: the repo's own inbox when it names one. */
148
- const pageOf = async (filter: InboxFilter, after: string | undefined) => {
148
+ const pageOf = async (clients: Clients, filter: InboxFilter, after: string | undefined) => {
149
149
  // `after` is the drop-in's cursor and `is_done` its list of done threads, neither of which
150
150
  // GitHub's types name: a spread passes them.
151
151
  const paging = { per_page: threadsPerPage, ...listQueries[filter.list], ...{ after } };
152
152
  const answer =
153
153
  filter.repo === undefined
154
- ? await github.GET('/notifications', { params: { query: paging } })
155
- : await github.GET('/repos/{owner}/{repo}/notifications', {
154
+ ? await clients.github.GET('/notifications', { params: { query: paging } })
155
+ : await clients.github.GET('/repos/{owner}/{repo}/notifications', {
156
156
  params: { path: filter.repo, query: paging },
157
157
  });
158
158
  if (answer.data === undefined) throw failure("The inbox didn't load", answer);
@@ -170,7 +170,7 @@ export const inboxListKey = ['inbox', 'list'] as const;
170
170
  * `filter`'s threads, newest first, a page at a time. A filter by reason keeps a page's threads of
171
171
  * that reason, and reads on, up to `readsPerPage` pages, while a page keeps none and more are left.
172
172
  */
173
- export const inboxList = (filter: InboxFilter) =>
173
+ export const inboxList = (clients: Clients, filter: InboxFilter) =>
174
174
  infiniteQueryOptions({
175
175
  queryKey: [...inboxListKey, filter.list, filter.repo ?? null, filter.reason ?? null],
176
176
  queryFn: async ({
@@ -181,7 +181,7 @@ export const inboxList = (filter: InboxFilter) =>
181
181
  let after = pageParam;
182
182
 
183
183
  for (let read = 1; ; read += 1) {
184
- const page = await pageOf(filter, after);
184
+ const page = await pageOf(clients, filter, after);
185
185
  const threads =
186
186
  filter.reason === undefined
187
187
  ? page.threads
@@ -9,18 +9,20 @@ import {
9
9
  import { useRef, useState } from 'react';
10
10
  import { toast } from 'sonner';
11
11
 
12
+ import type { Clients } from '../clients/clients.ts';
12
13
  import type { RepoPlace } from '../code/places.ts';
13
14
  import {
14
15
  changeIssue,
15
16
  createMilestone,
16
- issueAt,
17
+ issueKey,
17
18
  issueLists,
18
- vocabularyOf,
19
+ vocabularyKey,
19
20
  type Issue,
20
21
  type IssueChange,
21
22
  type IssuePage,
22
23
  type Label,
23
24
  type Milestone,
25
+ type Numbered,
24
26
  } from './issues.ts';
25
27
 
26
28
  /**
@@ -114,7 +116,7 @@ export const issueHolding = (client: QueryClient, place: RepoPlace, number: numb
114
116
 
115
117
  return {
116
118
  confirm: (shown) =>
117
- client.setQueryData(issueAt(place, number).queryKey, (at) =>
119
+ client.setQueryData<Numbered>(issueKey(place, number), (at) =>
118
120
  at === null || at === undefined ? at : { ...at, issue: withShown(at.issue, shown) },
119
121
  ),
120
122
  show: async (shown) => {
@@ -129,7 +131,7 @@ export const issueHolding = (client: QueryClient, place: RepoPlace, number: numb
129
131
  ),
130
132
  );
131
133
  },
132
- refreshed: [issueAt(place, number).queryKey, ['issues', place.owner, place.repo]],
134
+ refreshed: [issueKey(place, number), ['issues', place.owner, place.repo]],
133
135
  };
134
136
  };
135
137
 
@@ -228,10 +230,15 @@ const shownOf = (issue: Issue, field: 'labels' | 'assignees' | 'milestone' | 'st
228
230
 
229
231
  /** Sends `asked`, and confirms `field` as the drop-in answers it. */
230
232
  const patched =
231
- (changing: Changing, asked: IssueChange, shown: Shown & { readonly field: keyof IssueChange }) =>
233
+ (
234
+ clients: Clients,
235
+ changing: Changing,
236
+ asked: IssueChange,
237
+ shown: Shown & { readonly field: keyof IssueChange },
238
+ ) =>
232
239
  async () => {
233
240
  try {
234
- const issue = await changeIssue(changing.place, changing.number, asked);
241
+ const issue = await changeIssue(clients, changing.place, changing.number, asked);
235
242
  changing.holding.confirm(shownOf(issue, shown.field));
236
243
  } catch (cause) {
237
244
  if (shown.field === 'state') {
@@ -245,20 +252,28 @@ const patched =
245
252
  };
246
253
 
247
254
  /** The issue's labels set to `labels`, which the repo holds: a new one is made in its Dialog first. */
248
- export const labelsChange = (changing: Changing, labels: readonly Label[]): Change => {
255
+ export const labelsChange = (
256
+ clients: Clients,
257
+ changing: Changing,
258
+ labels: readonly Label[],
259
+ ): Change => {
249
260
  const value = { field: 'labels', value: labels } as const;
250
261
 
251
262
  return {
252
263
  ...value,
253
- send: patched(changing, { labels: labels.map((label) => label.name) }, value),
264
+ send: patched(clients, changing, { labels: labels.map((label) => label.name) }, value),
254
265
  };
255
266
  };
256
267
 
257
268
  /** The issue's assignees set to `assignees`. */
258
- export const assigneesChange = (changing: Changing, assignees: readonly string[]): Change => {
269
+ export const assigneesChange = (
270
+ clients: Clients,
271
+ changing: Changing,
272
+ assignees: readonly string[],
273
+ ): Change => {
259
274
  const value = { field: 'assignees', value: assignees } as const;
260
275
 
261
- return { ...value, send: patched(changing, { assignees }, value) };
276
+ return { ...value, send: patched(clients, changing, { assignees }, value) };
262
277
  };
263
278
 
264
279
  /**
@@ -266,6 +281,7 @@ export const assigneesChange = (changing: Changing, assignees: readonly string[]
266
281
  * repo first, by that title, and the page shows it by its title until it's made.
267
282
  */
268
283
  export const milestoneChange = (
284
+ clients: Clients,
269
285
  changing: Changing,
270
286
  milestone: Milestone | null,
271
287
  made?: string,
@@ -273,7 +289,10 @@ export const milestoneChange = (
273
289
  const value = { field: 'milestone', value: milestone } as const;
274
290
 
275
291
  if (made === undefined) {
276
- return { ...value, send: patched(changing, { milestone: milestone?.number ?? null }, value) };
292
+ return {
293
+ ...value,
294
+ send: patched(clients, changing, { milestone: milestone?.number ?? null }, value),
295
+ };
277
296
  }
278
297
 
279
298
  // What a try made, so trying again only sets it.
@@ -286,23 +305,28 @@ export const milestoneChange = (
286
305
  const { place, client } = changing;
287
306
 
288
307
  if (created === undefined) {
289
- created = await createMilestone(place, made).catch((cause: unknown) => {
308
+ const fields = { title: made, description: null, due: null };
309
+ created = await createMilestone(clients, place, fields).catch((cause: unknown) => {
290
310
  throw new Error(`Couldn't create the milestone ${made}`, { cause });
291
311
  });
292
312
  toast.success(`Created the milestone ${created.title}`);
293
- await client.invalidateQueries({ queryKey: vocabularyOf(place).queryKey });
313
+ await client.invalidateQueries({ queryKey: vocabularyKey(place) });
294
314
  }
295
315
 
296
- await patched(changing, { milestone: created.number }, value)();
316
+ await patched(clients, changing, { milestone: created.number }, value)();
297
317
  },
298
318
  };
299
319
  };
300
320
 
301
321
  /** The issue closed, or reopened. */
302
- export const stateChange = (changing: Changing, state: 'open' | 'closed'): Change => {
322
+ export const stateChange = (
323
+ clients: Clients,
324
+ changing: Changing,
325
+ state: 'open' | 'closed',
326
+ ): Change => {
303
327
  const value = { field: 'state', value: state } as const;
304
328
 
305
- return { ...value, send: patched(changing, { state }, value) };
329
+ return { ...value, send: patched(clients, changing, { state }, value) };
306
330
  };
307
331
 
308
332
  /**
@@ -1,6 +1,6 @@
1
1
  import { queryOptions, skipToken } from '@tanstack/react-query';
2
2
 
3
- import { github } from '../clients/clients.ts';
3
+ import type { Clients } from '../clients/clients.ts';
4
4
  import type { RepoPlace } from '../code/places.ts';
5
5
  import { failure } from '../hooks/answers.ts';
6
6
 
@@ -27,8 +27,10 @@ export const tabQueries = (
27
27
  };
28
28
 
29
29
  /** How many the drop-in's search finds for `q`, as its `total_count` says. */
30
- const totalOf = async (q: string) => {
31
- const answer = await github.GET('/search/issues', { params: { query: { q, per_page: 1 } } });
30
+ const totalOf = async (clients: Clients, q: string) => {
31
+ const answer = await clients.github.GET('/search/issues', {
32
+ params: { query: { q, per_page: 1 } },
33
+ });
32
34
  if (answer.data === undefined) throw failure("The counts didn't load", answer);
33
35
 
34
36
  return answer.data.total_count;
@@ -39,6 +41,7 @@ const totalOf = async (q: string) => {
39
41
  * changes the repo's issues or pull requests counts them again.
40
42
  */
41
43
  export const tabCounts = (
44
+ clients: Clients,
42
45
  place: RepoPlace,
43
46
  list: 'issues' | 'pulls',
44
47
  queries: TabQueries | undefined,
@@ -50,8 +53,8 @@ export const tabCounts = (
50
53
  ? skipToken
51
54
  : async (): Promise<Counts> => {
52
55
  const [open, closed] = await Promise.all([
53
- totalOf(queries.open),
54
- totalOf(queries.closed),
56
+ totalOf(clients, queries.open),
57
+ totalOf(clients, queries.closed),
55
58
  ]);
56
59
 
57
60
  return { open, closed };
@@ -4,6 +4,7 @@ import {
4
4
  CircleCheckIcon,
5
5
  CircleDotIcon,
6
6
  MessageSquareIcon,
7
+ MilestoneIcon,
7
8
  SearchIcon,
8
9
  TagIcon,
9
10
  UserRoundXIcon,
@@ -14,6 +15,7 @@ import { useEffect, useState, type ReactNode } from 'react';
14
15
  import { cn } from '#/lib/cn';
15
16
 
16
17
  import { day, Go, usePreloaded } from '../code/controls.tsx';
18
+ import { useClients } from '../clients/clients.ts';
17
19
  import type { RepoPlace } from '../code/places.ts';
18
20
  import { ItemList, More } from '../components/item-list.tsx';
19
21
  import { OwnerCard } from '../components/owner-card.tsx';
@@ -198,9 +200,10 @@ function Authors({
198
200
  readonly author: string | undefined;
199
201
  readonly onPick: (author: string | undefined) => void;
200
202
  }) {
203
+ const clients = useClients();
201
204
  const [open, setOpen] = useState(false);
202
205
  const [typed, setTyped] = useState('');
203
- const authors = useInfiniteQuery({ ...authorsOf(place), enabled: open });
206
+ const authors = useInfiniteQuery({ ...authorsOf(clients, place), enabled: open });
204
207
  const { fetchNextPage, isFetchingNextPage } = authors;
205
208
  const current = author === me ? viewer : author;
206
209
  const read = authors.data?.pages.flatMap((page) => page.logins) ?? [];
@@ -343,7 +346,8 @@ function Issues({
343
346
  readonly filter: IssueFilter;
344
347
  readonly vocabulary: Vocabulary;
345
348
  }) {
346
- const pages = useInfiniteQuery(issueList(place, filter, vocabulary));
349
+ const clients = useClients();
350
+ const pages = useInfiniteQuery(issueList(clients, place, filter, vocabulary));
347
351
  const issues = pages.data?.pages.flatMap((page) => page.issues) ?? [];
348
352
  if (pages.isPending) return <Skeleton className="h-40" />;
349
353
 
@@ -594,7 +598,8 @@ export function WithVocabulary({
594
598
  readonly place: RepoPlace;
595
599
  readonly children: (vocabulary: Vocabulary) => ReactNode;
596
600
  }) {
597
- const vocabulary = useQuery(vocabularyOf(place));
601
+ const clients = useClients();
602
+ const vocabulary = useQuery(vocabularyOf(clients, place));
598
603
  if (vocabulary.error !== null) return <LoadAlert message={vocabulary.error.message} />;
599
604
 
600
605
  return vocabulary.data === undefined ? <Skeleton className="h-40" /> : children(vocabulary.data);
@@ -614,12 +619,13 @@ export function IssueList({
614
619
  /** Who's signed in, whose own issues the author menu offers first. */
615
620
  readonly viewer: string | undefined;
616
621
  }) {
622
+ const clients = useClients();
617
623
  const navigate = useNavigate();
618
624
  const filter = filterOf(query);
619
- const vocabulary = useQuery(vocabularyOf(place));
625
+ const vocabulary = useQuery(vocabularyOf(clients, place));
620
626
  const allowed = useAllowed(place);
621
627
  const queries = tabQueries((state) => searchQueryOf(place, { ...filter, state }));
622
- const counts = useQuery(tabCounts(place, 'issues', queries));
628
+ const counts = useQuery(tabCounts(clients, place, 'issues', queries));
623
629
  const go = (next: IssueFilter) => void navigate({ href: issuesHref(place, queryOf(next)) });
624
630
 
625
631
  return (
@@ -631,7 +637,7 @@ export function IssueList({
631
637
  unfilteredOf={(text) => filterOf(text).unfiltered}
632
638
  buttons={
633
639
  <>
634
- {/* Named apart from the Labels filter below it, and its icon alone on a phone. */}
640
+ {/* Named apart from the filters below them, and each its icon alone on a phone. */}
635
641
  <Go
636
642
  href={`/${place.owner}/${place.repo}/labels`}
637
643
  aria-label="All labels"
@@ -640,6 +646,14 @@ export function IssueList({
640
646
  <TagIcon aria-hidden />
641
647
  <span className="@max-md:sr-only">Labels</span>
642
648
  </Go>
649
+ <Go
650
+ href={`/${place.owner}/${place.repo}/milestones`}
651
+ aria-label="All milestones"
652
+ className={cn(buttonVariants({ variant: 'outline', size: 'lg' }), iconOnPhone)}
653
+ >
654
+ <MilestoneIcon aria-hidden />
655
+ <span className="@max-md:sr-only">Milestones</span>
656
+ </Go>
643
657
  {allowed.has('issue.create') && (
644
658
  <CreateButton
645
659
  hotkey