ref0-git 0.6.0 → 0.7.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 (39) hide show
  1. package/app/apps/github/README.md +3 -7
  2. package/app/apps/github/generated/git-rest.ts +12 -12
  3. package/app/apps/github/src/clients/allowed.ts +7 -9
  4. package/app/apps/github/src/clients/avatars.ts +5 -3
  5. package/app/apps/github/src/clients/graphql.ts +12 -2
  6. package/app/apps/github/src/clients/host-calls.ts +2 -1
  7. package/app/apps/github/src/clients/transfers.ts +56 -19
  8. package/app/apps/github/src/context/context.ts +5 -5
  9. package/app/apps/github/src/context/host.ts +115 -0
  10. package/app/apps/github/src/ingress.ts +28 -0
  11. package/app/apps/github/src/policy.ts +113 -78
  12. package/app/apps/github/src/private-repos.ts +7 -7
  13. package/app/apps/github/src/pulls/review.ts +2 -1
  14. package/app/apps/github/src/releases/release-form.tsx +40 -4
  15. package/app/apps/github/src/releases/releases.ts +148 -22
  16. package/app/apps/github/src/routes/uploads/$owner/$repo/$release.tsx +9 -2
  17. package/app/apps/github/src/seed/seed.ts +9 -2
  18. package/app/apps/github/src/server.ts +28 -11
  19. package/app/apps/github/src/signin/approval.ts +20 -15
  20. package/app/apps/github/src/signin/attempts.ts +306 -0
  21. package/app/apps/github/src/signin/auth.ts +9 -0
  22. package/app/apps/github/src/signin/host-session.ts +30 -18
  23. package/app/apps/github/src/signin/limits.ts +35 -0
  24. package/app/pnpm-workspace.yaml +37 -36
  25. package/dist/cli/setup.mjs +1 -1
  26. package/dist/init/app.mjs +43 -23
  27. package/dist/init/cloudflare.mjs +8 -4
  28. package/dist/init/create.mjs +1 -1
  29. package/dist/init/detect.mjs +5 -3
  30. package/dist/init/files.mjs +6 -1
  31. package/dist/init/git-module.mjs +4 -6
  32. package/dist/init/metadata.mjs +6 -6
  33. package/dist/init/node-app.mjs +5 -2
  34. package/dist/init/stores.mjs +3 -2
  35. package/dist/init/template.mjs +13 -7
  36. package/dist/init/templates.mjs +51 -39
  37. package/dist/init/vercel.mjs +1 -1
  38. package/dist/init/versions.mjs +1 -1
  39. package/package.json +13 -13
@@ -1,9 +1,9 @@
1
- import { accept, gitError, Rules, reject } from '@ref0/git';
1
+ import { accept, gitError, Policy, Rules, reject } from '@ref0/git';
2
2
  import type {
3
3
  ActorId,
4
4
  AuthorizeInput,
5
+ Caller,
5
6
  GitError,
6
- GitAuthorize,
7
7
  InternalRepoId,
8
8
  NamedActor,
9
9
  PushRule,
@@ -35,6 +35,7 @@ import type {
35
35
  PeopleUser,
36
36
  PeopleViewer,
37
37
  } from '@ref0/github';
38
+ import * as Clock from 'effect/Clock';
38
39
  import * as Effect from 'effect/Effect';
39
40
 
40
41
  import { type StarterApprovalOptions, starterApprovalPage } from './signin/approval.ts';
@@ -61,7 +62,7 @@ interface Listed<Item> {
61
62
  readonly next?: string;
62
63
  }
63
64
 
64
- /** A membership the policy read, and when: `Date.now()`'s. */
65
+ /** A membership the policy read, and when, by the `Clock`. */
65
66
  interface KeptMembership {
66
67
  readonly at: number;
67
68
  readonly answer: Promise<Membership | undefined>;
@@ -144,7 +145,10 @@ const authorsOwn: ReadonlySet<string> = new Set([
144
145
  'review.resolve',
145
146
  ]);
146
147
 
147
- const signInFirst = reject({ message: 'Sign in first' });
148
+ const signInFirstRefusal = { message: 'Sign in first' };
149
+
150
+ /** `signInFirstRefusal`, as the drop-in's half answers it. */
151
+ const signInFirst = reject(signInFirstRefusal);
148
152
 
149
153
  /**
150
154
  * The owner a token reaches past its subject's own login, if any: a repo token's repo's owner, by
@@ -175,7 +179,7 @@ const orgCoverage = (operation: TokenOperation) => {
175
179
 
176
180
  /** Who a call's token holds for, a token's caller or the host's own sign-in. */
177
181
  interface Holder {
178
- readonly actor: AuthorizeInput['actor'];
182
+ readonly actor: AuthorizeInput['actor'] | Caller['actor'];
179
183
  readonly subject?: ActorId;
180
184
  readonly token?: TokenInfo;
181
185
  }
@@ -184,14 +188,25 @@ interface Holder {
184
188
  * The refusal of a token whose person left the org it's over, or joined it again after it was
185
189
  * made: it works for nothing, public reads included, as GitHub's inactive token (Q740).
186
190
  */
187
- const tokenEnded = reject({ message: "This token's person no longer holds the org it's over" });
191
+ const tokenEndedRefusal = { message: "This token's person no longer holds the org it's over" };
192
+
193
+ /** `tokenEndedRefusal`, as the drop-in's half answers it. */
194
+ const tokenEnded = reject(tokenEndedRefusal);
188
195
 
189
- /** The host's policy and directory, the drop-in's and Git's, over its people and orgs. */
196
+ /** At most `most` of an owner's private repos the caller may read, as the owner index asks. */
197
+ export type ReadableRepos = (
198
+ input: GitHubReadableReposInput,
199
+ ) => Effect.Effect<Awaited<ReturnType<GitHubReadableRepos>>, GitError>;
200
+
201
+ /**
202
+ * The host's policy and directory, the drop-in's and Git's, over its people and orgs: Git's
203
+ * `Policy`'s decision, the drop-in's `authorize` and `People`, and the owner index's hook.
204
+ */
190
205
  export interface HostPolicy {
191
- readonly authorize: GitAuthorize;
206
+ readonly authorize: Policy.PolicyService['authorize'];
192
207
  readonly authorizeGitHub: GitHubAuthorize;
193
208
  readonly people: PeopleFor;
194
- readonly readableRepos: GitHubReadableRepos;
209
+ readonly readableRepos: ReadableRepos;
195
210
  }
196
211
 
197
212
  /**
@@ -289,23 +304,23 @@ export const hostPolicy = (orgs: Orgs, options: HostPolicyOptions = {}): HostPol
289
304
  const memberships = new WeakMap<ActorId, Map<string, KeptMembership>>();
290
305
 
291
306
  /** `actor`'s membership of the org `org`, asked once a request, and again past its life. */
292
- const membershipOf = (actor: ActorId, org: string) => {
293
- const held = memberships.get(actor) ?? new Map<string, KeptMembership>();
294
- memberships.set(actor, held);
307
+ const membershipOf = (actor: ActorId, org: string) =>
308
+ Effect.flatMap(Clock.currentTimeMillis, (now) => {
309
+ const held = memberships.get(actor) ?? new Map<string, KeptMembership>();
310
+ memberships.set(actor, held);
295
311
 
296
- const now = Date.now();
297
- const kept = held.get(org);
298
- if (kept !== undefined && now - kept.at < membershipLife) return kept.answer;
312
+ const kept = held.get(org);
313
+ if (kept !== undefined && now - kept.at < membershipLife) return read(() => kept.answer);
299
314
 
300
- const answer = orgs.membership(org, actor.id);
301
- held.set(org, { at: now, answer });
315
+ const answer = orgs.membership(org, actor.id);
316
+ held.set(org, { at: now, answer });
302
317
 
303
- return answer;
304
- };
318
+ return read(() => answer);
319
+ });
305
320
 
306
321
  /** Whether `actor` belongs to the org `org`, in any role. */
307
- const belongs = async (actor: ActorId, org: string) =>
308
- (await membershipOf(actor, org)) !== undefined;
322
+ const belongs = (actor: ActorId, org: string) =>
323
+ Effect.map(membershipOf(actor, org), (membership) => membership !== undefined);
309
324
 
310
325
  /**
311
326
  * Whether a call's token holds (Q740): one over an owner other than its subject holds only while
@@ -314,21 +329,25 @@ export const hostPolicy = (orgs: Orgs, options: HostPolicyOptions = {}): HostPol
314
329
  * Worker's clock reads both, a token made then holds. A session's token, the host's own sign-in
315
330
  * and a token over the subject's own login hold as they are.
316
331
  */
317
- const tokenHolds = async ({ actor, subject, token }: Holder) => {
332
+ const tokenHolds = Effect.fnUntraced(function* ({ actor, subject, token }: Holder) {
318
333
  if (token === undefined || actor.anonymous === true) return true;
319
334
 
320
335
  const person = subject !== undefined && subject.id !== actor.id ? subject : actor;
321
336
  const owner = tokenOwner(token);
322
337
  if (owner === undefined || owner === person.id) return true;
323
338
 
324
- const membership = await membershipOf(person, owner);
339
+ const membership = yield* membershipOf(person, owner);
325
340
 
326
341
  return membership !== undefined && membership.since <= token.createdAt;
327
- };
342
+ });
328
343
 
329
344
  /** Whether `actor` owns what `owner` holds: their own login's, and each org's they belong to. */
330
- const owns = async (actor: NamedActor, owner: string | undefined) =>
331
- owner === actor.id || (owner !== undefined && (await belongs(actor, owner)));
345
+ const owns = (actor: NamedActor, owner: string | undefined) =>
346
+ owner === actor.id
347
+ ? Effect.succeed(true)
348
+ : owner === undefined
349
+ ? Effect.succeed(false)
350
+ : belongs(actor, owner);
332
351
 
333
352
  /**
334
353
  * The owner now of the repo a drop-in operation on `name` acts on: its current name's, read by
@@ -336,59 +355,66 @@ export const hostPolicy = (orgs: Orgs, options: HostPolicyOptions = {}): HostPol
336
355
  * its new owner's, and none once no name holds it or the input names no repo. With no
337
356
  * `repoName`, the owner of `name`.
338
357
  */
339
- const ownerNow = async (name: RepoName, input: GitHubAuthorization) => {
358
+ const ownerNow = Effect.fnUntraced(function* (name: RepoName, input: GitHubAuthorization) {
340
359
  if (repoName === undefined) return ownerOf(name);
341
360
 
342
- if (input.repo === undefined) return undefined;
361
+ const { repo } = input;
362
+ if (repo === undefined) return undefined;
343
363
 
344
- const now = await repoName(input.repo.internalId, input.signal);
364
+ const now = yield* read(() => repoName(repo.internalId, input.signal));
345
365
 
346
366
  return now === undefined ? undefined : ownerOf(now);
347
- };
367
+ });
348
368
 
349
369
  /**
350
- * Git's `authorize`: public repos for anyone to read and list, who they are for anyone signed in,
351
- * and the rest for a repo's owner, once the caller's token still holds.
370
+ * Git's `Policy`: public repos for anyone to read and list, who they are for anyone signed in,
371
+ * and the rest for a repo's owner, once the caller's token still holds. A directory read that
372
+ * fails fails the decision, which Git answers `UNAVAILABLE`, never an accept.
352
373
  */
353
- const authorize: GitAuthorize = async (input: AuthorizeInput) => {
354
- const { actor, operation, repo } = input;
355
- if (!(await tokenHolds(input))) return tokenEnded;
374
+ const authorize: Policy.PolicyService['authorize'] = Effect.fnUntraced(function* (
375
+ input: Policy.Input,
376
+ ) {
377
+ const { caller, operation, repo } = input;
378
+ const { actor } = caller;
379
+ if (!(yield* tokenHolds(caller))) return yield* Policy.reject(tokenEndedRefusal);
356
380
 
357
381
  // Who the caller is, at Git's `/me`: theirs, once their token holds.
358
- if (operation.kind === 'me') return actor.anonymous === true ? signInFirst : accept();
382
+ if (operation.kind === 'me') {
383
+ return yield* actor.anonymous === true ? Policy.reject(signInFirstRefusal) : Policy.accept();
384
+ }
359
385
 
360
386
  const reads = operation.kind === 'read' || operation.kind === 'fetch';
361
- if (reads && repo?.public === true) return accept();
387
+ if (reads && repo?.public === true) return yield* Policy.accept();
362
388
 
363
389
  // Anyone lists: Git lists a caller not signed in only the public repos' own index, whose names
364
390
  // the rule above lets anyone read, as GitHub lists an owner's public repos to anyone (Q791).
365
- if (operation.kind === 'repo.list') return accept();
391
+ if (operation.kind === 'repo.list') return yield* Policy.accept();
366
392
 
367
- if (actor.anonymous === true) return signInFirst;
393
+ if (actor.anonymous === true) return yield* Policy.reject(signInFirstRefusal);
368
394
 
369
395
  // A repo is made only under a login a person or an org holds, so no one's sign-up or org
370
396
  // later finds repos waiting under its name.
371
397
  if (operation.kind === 'repo.create') {
372
398
  const owner = ownerOf(operation.repo);
373
399
 
374
- if (owner === undefined || !(await orgs.held(owner))) {
375
- return reject({ message: 'No person or org holds that owner' });
400
+ if (owner === undefined || !(yield* read(() => orgs.held(owner)))) {
401
+ return yield* Policy.reject({ message: 'No person or org holds that owner' });
376
402
  }
377
403
  }
378
404
 
379
405
  // A protected or locked ref stays so for everyone, the admin too: a rule asks this on each
380
406
  // change it refuses, so accepting it would lift every rule for whoever passes.
381
407
  if (operation.kind === 'protect.bypass' || operation.kind === 'lock.bypass') {
382
- return reject({ message: 'No rule is lifted for anyone' });
408
+ return yield* Policy.reject({ message: 'No rule is lifted for anyone' });
383
409
  }
384
410
 
385
411
  if (actor.id === admin.id) {
386
- return operation.kind === 'push'
387
- ? reject({
412
+ return yield* operation.kind === 'push'
413
+ ? Policy.reject({
388
414
  message: "The admin token can't push",
389
415
  hint: 'Sign in at /login, or make a write token for yourself: POST /repos/<repo>/-/tokens',
390
416
  })
391
- : accept();
417
+ : Policy.accept();
392
418
  }
393
419
 
394
420
  // A person mints only for themselves, as no one else acts for them: a token's caller is its
@@ -397,7 +423,7 @@ export const hostPolicy = (orgs: Orgs, options: HostPolicyOptions = {}): HostPol
397
423
  operation.kind === 'token.create' &&
398
424
  (operation.subject.id !== actor.id || operation.actor !== undefined)
399
425
  ) {
400
- return reject({
426
+ return yield* Policy.reject({
401
427
  message: 'Only tokens for yourself',
402
428
  hint: 'The admin makes tokens for others',
403
429
  });
@@ -408,20 +434,20 @@ export const hostPolicy = (orgs: Orgs, options: HostPolicyOptions = {}): HostPol
408
434
  operation.kind === 'token.list' ||
409
435
  operation.kind === 'token.revoke'
410
436
  ) {
411
- return tokenRule(actor, operation);
437
+ return yield* tokenRule(actor, operation);
412
438
  }
413
439
 
414
440
  // A fork lands under its holder, from any repo the person may read.
415
441
  if (operation.kind === 'fork.create') {
416
- return operation.holder === actor.id
417
- ? accept()
418
- : reject({ message: 'Fork under your own login' });
442
+ return yield* operation.holder === actor.id
443
+ ? Policy.accept()
444
+ : Policy.reject({ message: 'Fork under your own login' });
419
445
  }
420
446
 
421
- return 'repo' in operation && (await owns(actor, ownerOf(operation.repo)))
422
- ? accept()
423
- : reject({ message: 'Not yours' });
424
- };
447
+ const mine = 'repo' in operation && (yield* owns(actor, ownerOf(operation.repo)));
448
+
449
+ return yield* mine ? Policy.accept() : Policy.reject({ message: 'Not yours' });
450
+ });
425
451
 
426
452
  /**
427
453
  * A person's token calls (Q521, Q740), the admin's being accepted above:
@@ -434,31 +460,38 @@ export const hostPolicy = (orgs: Orgs, options: HostPolicyOptions = {}): HostPol
434
460
  * - a list, or a revoke of another's token, over an org they're an owner or an admin of,
435
461
  * read at this call.
436
462
  */
437
- const tokenRule = async (actor: NamedActor | ActorId, operation: TokenOperation) => {
438
- if (operation.kind === 'token.revoke' && operation.subject.id === actor.id) return accept();
463
+ const tokenRule = Effect.fnUntraced(function* (
464
+ actor: NamedActor | ActorId,
465
+ operation: TokenOperation,
466
+ ) {
467
+ if (operation.kind === 'token.revoke' && operation.subject.id === actor.id) {
468
+ return yield* Policy.accept();
469
+ }
439
470
 
440
471
  const own =
441
472
  operation.repo === undefined
442
473
  ? operation.prefix.startsWith(`${actor.id}/`)
443
474
  : ownerOf(operation.repo) === actor.id;
444
- if (own && operation.kind !== 'token.revoke') return accept();
475
+ if (own && operation.kind !== 'token.revoke') return yield* Policy.accept();
445
476
 
446
477
  const org = orgCoverage(operation);
447
- const membership = org === undefined ? undefined : await membershipOf(actor, org);
478
+ const membership = org === undefined ? undefined : yield* membershipOf(actor, org);
448
479
 
449
480
  if (operation.kind === 'token.create') {
450
- return membership === undefined
451
- ? reject({
481
+ return yield* membership === undefined
482
+ ? Policy.reject({
452
483
  message: 'Only tokens over your own repos, or an org you belong to',
453
484
  hint: "Over an org, a token covers all of its repos or one: '<org>/' or '<org>/<repo>'",
454
485
  })
455
- : accept();
486
+ : Policy.accept();
456
487
  }
457
488
 
458
- return orgTokenView(membership) === 'all'
459
- ? accept()
460
- : reject({ message: "Only an org's owners and admins list and revoke its members' tokens" });
461
- };
489
+ return yield* orgTokenView(membership) === 'all'
490
+ ? Policy.accept()
491
+ : Policy.reject({
492
+ message: "Only an org's owners and admins list and revoke its members' tokens",
493
+ });
494
+ });
462
495
 
463
496
  /**
464
497
  * The drop-in's `authorize`: a public repo's reads for anyone, as Git's, and its contributions
@@ -474,12 +507,12 @@ export const hostPolicy = (orgs: Orgs, options: HostPolicyOptions = {}): HostPol
474
507
  input: GitHubAuthorization,
475
508
  ) {
476
509
  const { actor, operation } = input;
477
- if (!(yield* read(() => tokenHolds(input)))) return tokenEnded;
510
+ if (!(yield* tokenHolds(input))) return tokenEnded;
478
511
 
479
512
  if ('org' in operation) {
480
513
  if (actor.anonymous === true) return signInFirst;
481
514
 
482
- return actor.id === admin.id || (yield* read(() => owns(actor, operation.org)))
515
+ return actor.id === admin.id || (yield* owns(actor, operation.org))
483
516
  ? accept()
484
517
  : reject({ message: "Only the org's members may do this" });
485
518
  }
@@ -511,7 +544,7 @@ export const hostPolicy = (orgs: Orgs, options: HostPolicyOptions = {}): HostPol
511
544
  // holding the repo is all that's left to ask.
512
545
  if (operation.asAuthor === true && authorsOwn.has(operation.kind)) return accept();
513
546
 
514
- return (yield* read(async () => owns(actor, await ownerNow(operation.repo, input))))
547
+ return (yield* owns(actor, yield* ownerNow(operation.repo, input)))
515
548
  ? accept()
516
549
  : reject({ message: 'Only the owner may do this' });
517
550
  });
@@ -524,19 +557,22 @@ export const hostPolicy = (orgs: Orgs, options: HostPolicyOptions = {}): HostPol
524
557
  * A token over one repo names it alone, which `authorize` holds as any name. Git lists them newest
525
558
  * made first, since it keeps no time a repo was updated.
526
559
  */
527
- const readableRepos: GitHubReadableRepos = async (input) => {
560
+ const readableRepos: ReadableRepos = Effect.fnUntraced(function* (input) {
528
561
  const { actor, owner, most, token, host } = input;
529
- if (actor.anonymous === true || !(await tokenHolds(input))) return { names: [], more: false };
562
+ const none = { names: [], more: false };
563
+ if (actor.anonymous === true || !(yield* tokenHolds(input))) return none;
530
564
 
531
- if (actor.id !== admin.id && !(await owns(actor, owner))) return { names: [], more: false };
565
+ if (actor.id !== admin.id && !(yield* owns(actor, owner))) return none;
532
566
 
533
567
  const cover = coverOf(owner, token);
534
- if (cover === undefined || most <= 0) return { names: [], more: false };
568
+ if (cover === undefined || most <= 0) return none;
535
569
 
536
570
  if (cover.repo !== undefined) return { names: [cover.repo], more: false };
537
571
 
538
- return privateRepos(cover.prefix, most, host);
539
- };
572
+ const { prefix } = cover;
573
+
574
+ return yield* read(() => privateRepos(prefix, most, host));
575
+ });
540
576
 
541
577
  /**
542
578
  * The host's directory, for the drop-in (Q522): a user only once they've signed up, an org only
@@ -650,9 +686,8 @@ export const hostPolicy = (orgs: Orgs, options: HostPolicyOptions = {}): HostPol
650
686
  function lookup(input: PeopleInput): Effect.Effect<PeopleAnswer, GitError> {
651
687
  // A token whose person left the org it's over reads no one and lists nothing: `/user` 404s,
652
688
  // as every other use of it is refused.
653
- return Effect.flatMap(
654
- read(() => tokenHolds(input)),
655
- (holds) => (holds ? answer(input) : Effect.succeed(refusedLookup(input))),
689
+ return Effect.flatMap(tokenHolds(input), (holds) =>
690
+ holds ? answer(input) : Effect.succeed(refusedLookup(input)),
656
691
  );
657
692
  }
658
693
 
@@ -696,7 +731,7 @@ export const hostRules: readonly HostRule[] = [
696
731
 
697
732
  /**
698
733
  * Git's `identify`, as the approval page asks it. A host's `git.ts` gives its callback this return
699
- * type, since `createGitServer`'s type is inferred from options that name `git`.
734
+ * type, since the runtime's type is inferred from Layers whose approval page names it.
700
735
  */
701
736
  export type Identify = StarterApprovalOptions['identify'];
702
737
 
@@ -1,11 +1,11 @@
1
- import type { Actor, GitServer, RepoName } from '@ref0/git';
1
+ import type { Actor, RepoCalls, RepoName } from '@ref0/git';
2
2
 
3
3
  import { admin } from './policy.ts';
4
4
  import type { PrivateRepos } from './policy.ts';
5
5
 
6
6
  /**
7
- * At most `most` of the private repos under `prefix` on `git`, among the newest `most` there,
8
- * newest made first: those `host` lists, unchecked, less what `git` lists a caller not signed in,
7
+ * At most `most` of the private repos under `prefix`, among the newest `most` there, newest made
8
+ * first: those `host` lists, unchecked, less what Git's `list` lists a caller not signed in,
9
9
  * which reads the public repos' own index. Both lists are one page of `most`, newest first by one
10
10
  * key, a repo's created row, so the two windows hold the same repos and differ by the private ones
11
11
  * alone. The search asks for as many as it checks of the owner, so a private repo is named as far
@@ -19,12 +19,12 @@ import type { PrivateRepos } from './policy.ts';
19
19
  * `store/catalogue.ts`, `cursorSeal` in `store/cursor-seal.ts`).
20
20
  */
21
21
  export const privateReposOf =
22
- (git: Pick<GitServer, 'repos'>): PrivateRepos =>
22
+ (list: RepoCalls['list']): PrivateRepos =>
23
23
  async (prefix, most, host) => {
24
24
  if (most <= 0) return { names: [], more: true };
25
25
 
26
- const listed = async (list: GitServer['repos']['list'], actor: Actor) => {
27
- const page = await list({
26
+ const listed = async (from: RepoCalls['list'], actor: Actor) => {
27
+ const page = await from({
28
28
  actor,
29
29
  prefix,
30
30
  order: 'newest',
@@ -38,7 +38,7 @@ export const privateReposOf =
38
38
  // The host's own calls read no actor: the admin's stands in, as `repos.list` takes one.
39
39
  const [all, shown] = await Promise.all([
40
40
  listed(host.list, admin),
41
- listed(git.repos.list, { anonymous: true }),
41
+ listed(list, { anonymous: true }),
42
42
  ]);
43
43
  const open = new Set<RepoName>(shown.names);
44
44
  const hidden = all.names.filter((name) => !open.has(name));
@@ -324,7 +324,8 @@ export const resolveThread = async (clients: Clients, thread: ThreadState, resol
324
324
 
325
325
  /**
326
326
  * The drafts of the viewer's pending review `review`, as the drop-in keeps them: written here, in
327
- * another tab, or with `gh`, so a reload shows each. Every page, since bytes, not a count, bound them.
327
+ * another tab, or with `gh`, so a reload shows each. Every page: each draft is a row of its own,
328
+ * and a count bounds how many a review holds.
328
329
  */
329
330
  export const pendingCommentsOf = (
330
331
  clients: Clients,
@@ -3,7 +3,7 @@ import { useNavigate } from '@tanstack/react-router';
3
3
  import { LockIcon, PackageIcon } from 'lucide-react';
4
4
  import { useRef, useState } from 'react';
5
5
 
6
- import { assetBytesMost } from '../clients/transfers.ts';
6
+ import { assetBytesMost, partBytes } from '../clients/transfers.ts';
7
7
  import { sizeText } from '../code/controls.tsx';
8
8
  import { useClients } from '../clients/clients.ts';
9
9
  import { releaseHref, type RepoPlace } from '../code/places.ts';
@@ -100,6 +100,11 @@ function ReleaseFields({ place, target, release }: FormProps) {
100
100
  const held = useRef(release);
101
101
  // Files sent whose answer never came: each may have landed.
102
102
  const unsure = useRef(new Set<File>());
103
+ // The upload under way, which the page's stop aborts.
104
+ const stopper = useRef<AbortController | undefined>(undefined);
105
+ const [uploading, setUploading] = useState<
106
+ { file: File; sent: number; checking: boolean } | undefined
107
+ >();
103
108
  const draft = useDraft(
104
109
  {
105
110
  tag: release?.tag ?? '',
@@ -154,7 +159,15 @@ function ReleaseFields({ place, target, release }: FormProps) {
154
159
  setAssets((shown) => [...shown, ...landed]);
155
160
 
156
161
  for (const file of files.filter((each) => !done.has(each))) {
157
- const asset = await uploadAsset(place, made.id, file, () => unsure.current.add(file));
162
+ const stop = new AbortController();
163
+ stopper.current = stop;
164
+ setUploading({ file, sent: 0, checking: false });
165
+ const asset = await uploadAsset(place, made.id, file, {
166
+ lost: () => unsure.current.add(file),
167
+ sent: (sent) => setUploading({ file, sent, checking: false }),
168
+ checking: () => setUploading({ file, sent: file.size, checking: true }),
169
+ signal: stop.signal,
170
+ }).finally(() => setUploading(undefined));
158
171
  setFiles((left) => left.filter((each) => each !== file));
159
172
  setAssets((shown) => [...shown, asset]);
160
173
  }
@@ -299,8 +312,8 @@ function ReleaseFields({ place, target, release }: FormProps) {
299
312
  onChange={(event) => setFiles([...(event.target.files ?? [])])}
300
313
  />
301
314
  <FieldDescription>
302
- Each file at most {sizeText(assetBytesMost)}, the drop-in's limit, as GitHub's. A host
303
- may take less in one request.
315
+ Each file at most {sizeText(assetBytesMost)}, the drop-in's limit, as GitHub's. One past{' '}
316
+ {sizeText(partBytes)} uploads in parts.
304
317
  </FieldDescription>
305
318
  {files.length > 0 && (
306
319
  <FieldDescription>
@@ -343,6 +356,29 @@ function ReleaseFields({ place, target, release }: FormProps) {
343
356
  <HotkeyHint keys={hotkeys.submit} />
344
357
  </SaveButton>
345
358
  </div>
359
+ {uploading !== undefined && (
360
+ <div role="status" className="flex items-center justify-end gap-2 text-sm">
361
+ <span className="wrap-anywhere">
362
+ {uploading.checking
363
+ ? `Checking ${uploading.file.name}…`
364
+ : `Uploading ${uploading.file.name}: ${sizeText(uploading.sent)} of ${sizeText(uploading.file.size)}`}
365
+ </span>
366
+ {/* Checking has no bytes to count, so its bar shows only that it's working. */}
367
+ <progress
368
+ aria-label={`${uploading.file.name}'s upload`}
369
+ value={uploading.checking ? undefined : uploading.sent}
370
+ max={uploading.file.size}
371
+ />
372
+ <Button
373
+ type="button"
374
+ variant="outline"
375
+ size="sm"
376
+ onClick={() => stopper.current?.abort()}
377
+ >
378
+ Stop upload
379
+ </Button>
380
+ </div>
381
+ )}
346
382
  {[saved.error, removed.error].map(
347
383
  (error) =>
348
384
  error !== null && (