Public: anyone can read this; the crew can change it.
The Dependencies screen is busy until its report is read, so a and f are never dropped #17524
Merged 18h ago, live in production
fix/dep-accept-keys → main 0 commits
1 file
changed +11
−4
src/tui/screens/dependencies.ts +11 −4
| @@ -56,12 +56,19 @@ export function dependenciesScreen(f: Session, ctx: Ctx, repo: Repo): Screen { | ||
| 56 | 56 | report = fresh && withAcceptances(f.app.db, repo.id, fresh); |
| 57 | 57 | note = report === undefined ? "No such branch." : report.findings.length === 0 ? `No known advisory in ${report.packages} pinned packages.` : `${report.findings.length} findings in ${report.packages} pinned packages.`; |
| 58 | 58 | }; |
| 59 | const again = (): void => void read().catch(() => (note = "The lockfiles could not be read.")).finally(() => ctx.invalidate()); | |
| 59 | // The read is awaited by `load` and tracked on R, so the app is busy until the report is in: a | |
| 60 | // key pressed before it (a, f) is not dropped on a screen with nothing to act on yet. | |
| 61 | const again = (): Promise<void> => | |
| 62 | read() | |
| 63 | .catch(() => { | |
| 64 | note = "The lockfiles could not be read."; | |
| 65 | }) | |
| 66 | .finally(() => ctx.invalidate()); | |
| 60 | 67 | const screen: Screen = { |
| 61 | 68 | title: `${repo.ownerName}/${repo.name} — Dependencies`, |
| 62 | 69 | keys: [binding(["j", "k"], "move cursor"), binding([keyOf("reread")], "read again"), binding(["a"], "accept the risk"), binding(["f"], "file the fix")], |
| 63 | 70 | async load() { |
| 64 | again(); | |
| 71 | await again(); | |
| 65 | 72 | }, |
| 66 | 73 | render(area, s) { |
| 67 | 74 | const c = ctx.theme.c; |
| @@ -73,7 +80,7 @@ export function dependenciesScreen(f: Session, ctx: Ctx, repo: Repo): Screen { | ||
| 73 | 80 | if (state.key(e, report?.findings.length ?? 0)) return true; |
| 74 | 81 | if (e.ctrl || e.alt) return false; |
| 75 | 82 | if (e.key === keyOf("reread")) { |
| 76 | again(); | |
| 83 | void ctx.track(again()); | |
| 77 | 84 | return true; |
| 78 | 85 | } |
| 79 | 86 | const row = report?.findings[state.index]; |
| @@ -93,7 +100,7 @@ export function dependenciesScreen(f: Session, ctx: Ctx, repo: Repo): Screen { | ||
| 93 | 100 | onSubmit: (reason) => { |
| 94 | 101 | const done = acceptAdvisory(f.app, repo, f.user, held, { package: row.package, version: row.version, advisory: row.advisory, reason }); |
| 95 | 102 | if (!done.ok) return done.why; |
| 96 | return Promise.resolve().then(() => again()); | |
| 103 | return Promise.resolve().then(() => void ctx.track(again())); | |
| 97 | 104 | }, |
| 98 | 105 | }), |
| 99 | 106 | ); |
new above
offline