Public: anyone can read this; the crew can change it.
crewNow shows nothing sealed, private or hidden to someone who may not see it #14920
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/14906-crewnow-shows-nothing-sealed-private-or → main 1 commit fork
2 files
changed +102
−6
src/core/crew_now.ts +12 −6
| @@ -6,6 +6,7 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | import type { Database } from "bun:sqlite"; |
| 9 | import { OWNER_STANDING } from "./visibility.ts"; | |
| 9 | 10 | |
| 10 | 11 | export const CREW_NOW_MAX = 3; |
| 11 | 12 | |
| @@ -46,20 +47,25 @@ const clip = (s: string, n: number): string => { | ||
| 46 | 47 | const STATES = ["running", "queued", "ok", "failed", "cancelled"] as const; |
| 47 | 48 | |
| 48 | 49 | const BY_STATE = (n: number): string => `SELECT r.id AS id, u.username AS username, i.title AS title, r.summary AS summary, |
| 49 | r.reason AS reason, p.name AS repo, r.state AS state | |
| 50 | r.reason AS reason, repo.name AS repo, r.state AS state | |
| 50 | 51 | FROM run r |
| 51 | JOIN repo p ON p.id = r.repo_id AND p.visibility = 'public' | |
| 52 | JOIN repo ON repo.id = r.repo_id AND repo.visibility = 'public' | |
| 52 | 53 | LEFT JOIN user u ON u.id = r.actor_id |
| 53 | 54 | LEFT JOIN issue i ON i.id = r.issue_id |
| 54 | 55 | WHERE r.kind = 'agent' AND r.state = ?${n} |
| 56 | AND (i.id IS NULL OR i.sealed = 0) | |
| 57 | AND ${OWNER_STANDING} | |
| 58 | AND NOT EXISTS (SELECT 1 FROM app WHERE app.repo_id = repo.id AND app.access = 'private') | |
| 55 | 59 | ORDER BY r.id DESC |
| 56 | 60 | LIMIT ?6`; |
| 57 | 61 | |
| 58 | 62 | /** |
| 59 | * Only public repositories are shown: this runs for anyone who holds the link, so a private | |
| 60 | * repository's name, issue title and summary never reach it. Each state is read through the | |
| 61 | * (kind, state) index, newest first, three rows at most, so the cost does not grow with the | |
| 62 | * number of runs: one statement, five LIMITed reads, merged here. | |
| 63 | * Only what a signed-out reader may see is shown: this runs for anyone who holds the link, so | |
| 64 | * a private repository's name, a sealed report's title (`sealed.ts`), a private app's runs | |
| 65 | * (`mayReadRuns`) and a suspended or removed owner's repository (`OWNER_STANDING`) never reach | |
| 66 | * it. No viewer is asked: the page and the terminal screen show everyone the same list. Each state | |
| 67 | * is read through the (kind, state) index, newest first, three rows at most, so the cost does not | |
| 68 | * grow with the number of runs: one statement, five LIMITed reads, merged here. | |
| 63 | 69 | */ |
| 64 | 70 | const ALL = STATES.map((_, i) => `SELECT * FROM (${BY_STATE(i + 1)})`).join(" UNION ALL "); |
| 65 | 71 |
new above
offline