Public: anyone can read this; the crew can change it.
Delete the dead exports scripts/unused-exports.ts finds, area by area #16800
Check · Review · Land · Live done — Landed and live in production.
mason/forge:mason/16269-delete-the-dead-exports-scripts-unused-e → main 0 commits fork 1 thread · 1 unresolved
36 files
changed +2
−384
- scripts/unused-exports-allow.json
- src/apps/dns_provider.ts
- src/apps/manifest.ts
- src/arcade/host.ts
- src/billing/orders.ts
- src/contract/audit.ts
- src/core/device_grants.ts
- src/core/idempotency.ts
- src/core/issue_teams.ts
- src/core/looks.ts
- src/core/meter.ts
- src/core/pulls.ts
- src/core/sealed.ts
- src/core/subscriptions.ts
- src/core/timers.ts
- src/core/usage.ts
- src/crew/models.ts
- src/data/mask.ts
- src/display/items.ts
- src/display/known.ts
- src/display/launch.ts
- src/display/selections.ts
- src/feed/chips.ts
- src/flow/kpi_words.ts
- src/git/local.ts
- src/http/script_errors.ts
- src/kernel/result.ts
- src/origins/jobs.ts
- src/perf/budgets.ts
- src/tui/screens/common.ts
- src/tui/term/ansi.ts
- src/tui/term/style.ts
- src/tui/ui/editor.ts
- src/tui/ui/image.ts
- src/web/space_view.ts
- src/web/studio/shelf.ts
scripts/unused-exports-allow.json −53
| @@ -6,20 +6,14 @@ | ||
| 6 | 6 | "src/looks/archive.ts useLookStore", |
| 7 | 7 | "src/apps/contain.ts useTreeReader", |
| 8 | 8 | "src/apps/contain.ts watchTick", |
| 9 | "src/apps/dns_provider.ts EDITABLE_TYPES", | |
| 10 | 9 | "src/apps/egress.ts resetEgressTotals", |
| 11 | 10 | "src/apps/egress_refused.ts flushRefused", |
| 12 | "src/apps/manifest.ts declaresApp", | |
| 13 | 11 | "src/apps/migration_mode.ts migrationOrigin", |
| 14 | 12 | "src/apps/relay_wait.ts clearRelayWaits", |
| 15 | 13 | "src/apps/toolbar.ts TOOLBAR_PATH", |
| 16 | "src/arcade/host.ts arcadeOn", | |
| 17 | "src/billing/orders.ts bySession", | |
| 18 | "src/billing/orders.ts recentOrders", | |
| 19 | 14 | "src/billing/sync.ts setStripeFetch", |
| 20 | 15 | "src/boards/live_hub.ts hubsOpen", |
| 21 | 16 | "src/boards/model_fill.ts useModel", |
| 22 | "src/checks/deepsec_plan.ts sweepArgvs", | |
| 23 | 17 | "src/checks/doctor.ts isDoctorHold", |
| 24 | 18 | "src/checks/order_dependent.ts orderDependent", |
| 25 | 19 | "src/checks/lent_yield.ts setLoadSource", |
| @@ -29,43 +23,29 @@ | ||
| 29 | 23 | "src/checks/scans.ts scanSeconds", |
| 30 | 24 | "src/checks/service.ts provideChecksForTest", |
| 31 | 25 | "src/cloud/ovh_sign.ts resetOvhClock", |
| 32 | "src/contract/audit.ts identitiesOf", | |
| 33 | 26 | "src/core/accounts.ts edgeOnlyAccounts", |
| 34 | 27 | "src/core/capacity.ts provideCpusForTest", |
| 35 | 28 | "src/core/credit.ts clearCreditCache", |
| 36 | "src/core/device_grants.ts appIdOfSlug", | |
| 37 | 29 | "src/core/device_grants.ts grantedSlugs", |
| 38 | 30 | "src/core/feed_chips.ts noChips", |
| 39 | "src/core/fence.ts heldIn", | |
| 40 | "src/core/idempotency.ts clearInFlight", | |
| 41 | 31 | "src/core/idempotency.ts resetPruneClock", |
| 42 | "src/core/issue_teams.ts teamsAnswered", | |
| 43 | 32 | "src/core/issues.ts countIssues", |
| 44 | 33 | "src/core/issues.ts issueRefKey", |
| 45 | 34 | "src/core/issues.ts searchIssuesVisibleTo", |
| 46 | 35 | "src/core/ledger_git.ts resetBatchClock", |
| 47 | "src/core/looks.ts isLookKind", | |
| 48 | "src/core/meter.ts PLACEMENTS", | |
| 49 | 36 | "src/core/oidc.ts rotateKeys", |
| 50 | 37 | "src/core/oidc.ts verifyIdToken", |
| 51 | 38 | "src/core/parent_releases.ts refreshIdle", |
| 52 | 39 | "src/core/pulls.ts mergeReadingsSettled", |
| 53 | 40 | "src/core/pulls.ts mergedPullClosingScan", |
| 54 | "src/core/pulls.ts pullsForIssues", | |
| 55 | 41 | "src/core/roles.ts rolesTable", |
| 56 | 42 | "src/core/route_timing.ts readTiming", |
| 57 | "src/core/sealed.ts sealedById", | |
| 58 | 43 | "src/core/search.ts grepCount", |
| 59 | 44 | "src/core/search.ts grepRepo", |
| 60 | 45 | "src/core/sessions.ts sessionUser", |
| 61 | 46 | "src/core/signin-window.ts signinKeyCount", |
| 62 | "src/core/starts.ts startOfAccount", | |
| 63 | "src/core/subscriptions.ts listAllGrants", | |
| 64 | 47 | "src/core/team-metrics.ts keptFigures", |
| 65 | "src/core/timers.ts pendingTimers", | |
| 66 | 48 | "src/core/transfer.ts transfersOf", |
| 67 | "src/core/usage.ts USAGE_BY", | |
| 68 | "src/core/usage.ts USAGE_OUTCOMES", | |
| 69 | 49 | "src/core/v1_proof.ts useProof", |
| 70 | 50 | "src/core/webhooks.ts deliveryBusy", |
| 71 | 51 | "src/flow/stuck_pile.ts forgetStuckRepos", |
| @@ -73,31 +53,17 @@ | ||
| 73 | 53 | "src/crew/first_look.ts useLookModel", |
| 74 | 54 | "src/crew/hot_history.ts forgetHeat", |
| 75 | 55 | "src/crew/hot_history.ts sampleTimes", |
| 76 | "src/crew/models.ts modelLabel", | |
| 77 | 56 | "src/crew/sandbox_cause.ts skipReason", |
| 78 | "src/crew/week_read.ts forgetWeek", | |
| 79 | "src/data/mask.ts isSecretColumn", | |
| 80 | 57 | "src/data/query.ts queriesRunning", |
| 81 | 58 | "src/design/qr.ts QR_MAX_BYTES", |
| 82 | "src/display/items.ts itemsOfKeys", | |
| 83 | "src/display/items.ts keepUnnamed", | |
| 84 | "src/display/known.ts withoutDisplay", | |
| 85 | "src/display/launch.ts coverUrl", | |
| 86 | "src/display/launch.ts downloadUrl", | |
| 87 | "src/display/launch.ts playUrl", | |
| 88 | "src/display/launch.ts shotsUrl", | |
| 89 | "src/display/selections.ts SHOWCASED", | |
| 90 | "src/display/selections.ts displaySelections", | |
| 91 | 59 | "src/display/selections.ts selectionsHolding", |
| 92 | 60 | "src/drop/store.ts streamingBytes", |
| 93 | 61 | "src/efficiency/installs.ts resetInstalls", |
| 94 | "src/feed/chips.ts chipOfKind", | |
| 95 | 62 | "src/feed/likes.ts ledgerCount", |
| 96 | 63 | "src/flow/alarm_drift.ts alarmDrift", |
| 97 | 64 | "src/flow/alarm_drift.ts clearDriftCache", |
| 98 | 65 | "src/flow/handovers.ts handoversSays", |
| 99 | 66 | "src/flow/keeper.ts listAttempts", |
| 100 | "src/flow/kpi_words.ts trafficWords", | |
| 101 | 67 | "src/flow/lanes.ts useLanesReader", |
| 102 | 68 | "src/flow/pages.ts usePagesReader", |
| 103 | 69 | "src/flow/reach.ts NO_REACH", |
| @@ -108,8 +74,6 @@ | ||
| 108 | 74 | "src/git/diff-memory.ts mergeBaseCount", |
| 109 | 75 | "src/git/local.ts aheadBehind", |
| 110 | 76 | "src/git/local.ts isClean", |
| 111 | "src/git/local.ts isRepo", | |
| 112 | "src/git/local.ts statusLetters", | |
| 113 | 77 | "src/git/merge.ts setMergeTreeAcceptsMergeBaseForTest", |
| 114 | 78 | "src/git/path_listing.ts keptListings", |
| 115 | 79 | "src/git/read.ts closeAllReaders", |
| @@ -119,9 +83,7 @@ | ||
| 119 | 83 | "src/http/crawl.ts crawlAgentCount", |
| 120 | 84 | "src/http/crawl.ts pinCrawlLag", |
| 121 | 85 | "src/http/crawl.ts setCrawlClock", |
| 122 | "src/http/mcp.ts toolNames", | |
| 123 | 86 | "src/http/mcp.ts toolRegistry", |
| 124 | "src/http/script_errors.ts SCRIPT_ERROR_PATH", | |
| 125 | 87 | "src/http/sse.ts resetSseDroppedCount", |
| 126 | 88 | "src/http/sse.ts sseDroppedCount", |
| 127 | 89 | "src/http/strangers.ts heldChanged", |
| @@ -139,7 +101,6 @@ | ||
| 139 | 101 | "src/kernel/log.ts clearErrors", |
| 140 | 102 | "src/kernel/migrate.ts notAdditive", |
| 141 | 103 | "src/kernel/result.ts andThen", |
| 142 | "src/kernel/result.ts trapAsync", | |
| 143 | 104 | "src/kernel/result.ts unwrapOr", |
| 144 | 105 | "src/looks/main_looks.ts mainLook", |
| 145 | 106 | "src/machines/shell.ts liveSessions", |
| @@ -148,14 +109,11 @@ | ||
| 148 | 109 | "src/origins/ahead.ts aheadBusy", |
| 149 | 110 | "src/origins/git-mirror.ts mirrorOutboundForTest", |
| 150 | 111 | "src/origins/git-mirror.ts provideMirrorOutboundForTest", |
| 151 | "src/origins/jobs.ts listJobs", | |
| 152 | 112 | "src/origins/jobs.ts resetJobs", |
| 153 | 113 | "src/origins/oauth.ts pruneFlows", |
| 154 | 114 | "src/origins/providers/index.ts forgetProviders", |
| 155 | 115 | "src/origins/sync.ts syncsSettled", |
| 156 | 116 | "src/packs/catalog.ts packNamed", |
| 157 | "src/perf/budgets.ts EXPLORE_READ_BUDGET", | |
| 158 | "src/perf/page_budget_read.ts pageBudgetRows", | |
| 159 | 117 | "src/perf/views_store.ts pendingViews", |
| 160 | 118 | "src/release/behind.ts readNewest", |
| 161 | 119 | "src/release/landings.ts forgetLive", |
| @@ -189,18 +147,9 @@ | ||
| 189 | 147 | "src/tui/gallery.ts galleryFrame", |
| 190 | 148 | "src/tui/local/common.ts localBusy", |
| 191 | 149 | "src/tui/local/common.ts localIdle", |
| 192 | "src/tui/screens/common.ts COMMENT_MARK", | |
| 193 | 150 | "src/tui/screens/external.ts forgetEditor", |
| 194 | "src/tui/term/ansi.ts ERASE_LINE_RIGHT", | |
| 195 | "src/tui/term/style.ts withAttr", | |
| 196 | "src/tui/term/style.ts withBg", | |
| 197 | "src/tui/term/style.ts withFg", | |
| 198 | "src/tui/term/style.ts withoutAttr", | |
| 199 | 151 | "src/tui/term/terminal.ts diffScreens", |
| 200 | "src/tui/ui/editor.ts STATUS_BOLD", | |
| 201 | "src/tui/ui/editor.ts expandLine", | |
| 202 | 152 | "src/tui/ui/icons.ts iconNames", |
| 203 | "src/tui/ui/image.ts clearImage", | |
| 204 | 153 | "src/web/chrome.ts stickyAction", |
| 205 | 154 | "src/web/code_rows_pool.ts workersForTest", |
| 206 | 155 | "src/web/diff-cache.ts clearDiffCache", |
| @@ -220,10 +169,8 @@ | ||
| 220 | 169 | "src/web/render/kinds.ts KNOWN_EXTENSIONS", |
| 221 | 170 | "src/web/script_keys.ts SCRIPT_KEYS", |
| 222 | 171 | "src/web/share_target.ts forgetShares", |
| 223 | "src/web/space_view.ts GLIDE_MS", | |
| 224 | 172 | "src/web/studio/home_cache.ts setHomeClock", |
| 225 | 173 | "src/web/studio/home_last.ts forgetHome", |
| 226 | 174 | "src/web/studio/review_evidence.ts rememberStat", |
| 227 | "src/web/studio/shelf.ts productionFactsForRepos", | |
| 228 | 175 | "src/web/sw.ts swSource" |
| 229 | 176 | ] |
src/apps/dns_provider.ts −1
src/apps/manifest.ts −7
| @@ -646,13 +646,6 @@ export function parseCloud( | ||
| 646 | 646 | return ok(out); |
| 647 | 647 | } |
| 648 | 648 | |
| 649 | /** Whether `forge.json` declares an app at all, without validating it. */ | |
| 650 | export function declaresApp(forgeJson: string | undefined): boolean { | |
| 651 | if (forgeJson === undefined) return false; | |
| 652 | const parsed = parseJson(forgeJson, "forge.json"); | |
| 653 | return parsed.ok && parsed.value["app"] !== undefined; | |
| 654 | } | |
| 655 | ||
| 656 | 649 | type Json = Record<string, unknown>; |
| 657 | 650 | |
| 658 | 651 | const isObject = (value: unknown): value is Json => |
src/arcade/host.ts −5
| @@ -58,11 +58,6 @@ export function arcadeUrl(runtime: AppsRuntime): string { | ||
| 58 | 58 | return `${scheme}://${ARCADE_SLUG}${appHostSuffix(domain)}${port}`; |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | /** Whether the forge has an Arcade: apps run and a site admin's display is titled `arcade-builds`. */ | |
| 62 | export function arcadeOn(app: App): boolean { | |
| 63 | return appsRuntime(app) !== undefined && arcadeRepoKnown(app) !== undefined; | |
| 64 | } | |
| 65 | ||
| 66 | 61 | /** The Arcade's address when the forge has one. */ |
| 67 | 62 | export function arcadeHome(app: App): string | undefined { |
| 68 | 63 | const runtime = appsRuntime(app); |
src/billing/orders.ts −10
| @@ -82,12 +82,6 @@ export function getOrder(db: Database, id: string): Order | undefined { | ||
| 82 | 82 | return r ? fromRow(r) : undefined; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | export function bySession(db: Database, sessionId: string): Order | undefined { | |
| 86 | if (sessionId === "") return undefined; | |
| 87 | const r = db.query<Row, [string]>("SELECT * FROM forge_order WHERE session_id = ?1").get(sessionId); | |
| 88 | return r ? fromRow(r) : undefined; | |
| 89 | } | |
| 90 | ||
| 91 | 85 | /** True when the ticket is the one the order was made with. */ |
| 92 | 86 | export function ticketFits(db: Database, id: string, ticket: string): boolean { |
| 93 | 87 | const r = db.query<{ ticket_hash: string }, [string]>("SELECT ticket_hash FROM forge_order WHERE id = ?1").get(id); |
| @@ -183,10 +177,6 @@ export function failedOrders(db: Database): Order[] { | ||
| 183 | 177 | return db.query<Row, []>("SELECT * FROM forge_order WHERE state = 'failed' ORDER BY updated_at DESC LIMIT 50").all().map(fromRow); |
| 184 | 178 | } |
| 185 | 179 | |
| 186 | export function recentOrders(db: Database, limit = 20): Order[] { | |
| 187 | return db.query<Row, [number]>("SELECT * FROM forge_order WHERE state != 'pending' ORDER BY updated_at DESC LIMIT ?1").all(limit).map(fromRow); | |
| 188 | } | |
| 189 | ||
| 190 | 180 | /** |
| 191 | 181 | * Orders whose forge is not up yet or is about to be made: paid, spawning or making, and pending |
| 192 | 182 | * ones still within the checkout's validity. What the ceiling counts beside its pinned rows. |
src/contract/audit.ts −5
| @@ -78,11 +78,6 @@ export function standingOf(text: string | undefined): Standing { | ||
| 78 | 78 | }; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | /** The identities of a sound standing: the floor, then the rest. */ | |
| 82 | export function identitiesOf(standing: Standing): readonly string[] { | |
| 83 | return standing.kind === "sound" ? standing.identities : []; | |
| 84 | } | |
| 85 | ||
| 86 | 81 | /** |
| 87 | 82 | * The policy as a builder is briefed on it: one line per resource with the |
| 88 | 83 | * least role each verb needs, or the problems when the contract does not |
src/core/device_grants.ts −3
| @@ -58,6 +58,3 @@ export const grantedSlugs = (db: Database, deviceId: number): string[] => | ||
| 58 | 58 | |
| 59 | 59 | export const allAppSlugs = (db: Database): string[] => |
| 60 | 60 | db.query<{ slug: string }, []>("SELECT slug FROM app ORDER BY slug").all().map((r) => r.slug); |
| 61 | ||
| 62 | export const appIdOfSlug = (db: Database, slug: string): string | undefined => | |
| 63 | db.query<{ id: string }, [string]>("SELECT id FROM app WHERE slug = ?1").get(slug)?.id; |
src/core/idempotency.ts
Binary file not shown.
src/core/issue_teams.ts −4
| @@ -94,10 +94,6 @@ export function teamVerdicts( | ||
| 94 | 94 | }); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | /** Whether every named team has a current verdict on the head (vacuously true with no teams). */ | |
| 98 | export const teamsAnswered = (verdicts: readonly TeamVerdict[]): boolean => | |
| 99 | verdicts.every((v) => v.state !== undefined && !v.stale); | |
| 100 | ||
| 101 | 97 | /** |
| 102 | 98 | * The named teams that still hold the pull: each has a crew reviewer on the |
| 103 | 99 | * pull's repository and no current approval on its head. A stale approval, |
src/core/looks.ts −2
| @@ -11,8 +11,6 @@ import { id as newId } from "../kernel/id.ts"; | ||
| 11 | 11 | /** The three widths a page is pictured at. */ |
| 12 | 12 | export type LookKind = "phone" | "narrow" | "desktop" | "thumb"; |
| 13 | 13 | export const LOOK_KINDS: readonly LookKind[] = ["phone", "narrow", "desktop", "thumb"]; |
| 14 | export const isLookKind = (value: string): value is LookKind => | |
| 15 | (LOOK_KINDS as readonly string[]).includes(value); | |
| 16 | 14 | |
| 17 | 15 | /** |
| 18 | 16 | * The three sizes a picture is kept at, as a person holds them: a phone, a |
src/core/meter.ts −1
| @@ -27,7 +27,6 @@ import { defect } from "../kernel/error.ts"; | ||
| 27 | 27 | |
| 28 | 28 | /** Where an environment ran: hardware the operator owns, or a cloud's. */ |
| 29 | 29 | export type Placement = "owned" | "cloud"; |
| 30 | export const PLACEMENTS: readonly Placement[] = ["owned", "cloud"]; | |
| 31 | 30 | |
| 32 | 31 | /** How long one storage sample stands for, in milliseconds. */ |
| 33 | 32 | export const SAMPLE_SPAN_MS = 3_600_000; |
src/core/pulls.ts −8
| @@ -750,14 +750,6 @@ export function mergedPullCount( | ||
| 750 | 750 | return row?.n ?? 0; |
| 751 | 751 | } |
| 752 | 752 | |
| 753 | /** The pull rows for a page of issues, keyed by issue id. */ | |
| 754 | export function pullsForIssues( | |
| 755 | db: Database, | |
| 756 | issues: readonly Issue[], | |
| 757 | ): Map<string, Pull> { | |
| 758 | return new Map(joinMany(db, issues).map((pull) => [pull.id, pull])); | |
| 759 | } | |
| 760 | ||
| 761 | 753 | /** |
| 762 | 754 | * Which of these pull numbers have landed. |
| 763 | 755 | * |
src/core/sealed.ts −5
| @@ -85,11 +85,6 @@ export function sealedRowById( | ||
| 85 | 85 | return row ? { sealed: row.sealed === 1, authorId: row.author_id } : undefined; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | /** Whether the issue `issueId` is sealed. */ | |
| 89 | export function sealedById(db: Database, issueId: string): boolean { | |
| 90 | return sealedRowById(db, issueId)?.sealed === true; | |
| 91 | } | |
| 92 | ||
| 93 | 88 | /** Issue `number` in `repoId` as `mayView` reads it. */ |
| 94 | 89 | export function sealedRowByNumber( |
| 95 | 90 | db: Database, |
src/core/subscriptions.ts −15
| @@ -487,21 +487,6 @@ export function listGrants(db: Database, scopeId: string): Grant[] { | ||
| 487 | 487 | })); |
| 488 | 488 | } |
| 489 | 489 | |
| 490 | /** Every grant on this forge, for the page that says where each account goes. */ | |
| 491 | export function listAllGrants(db: Database): Grant[] { | |
| 492 | return db | |
| 493 | .query<{ scope_id: string; agent_id: string; subscription_id: string }, []>( | |
| 494 | `SELECT scope_id, agent_id, subscription_id FROM subscription_grant | |
| 495 | ORDER BY subscription_id, scope_id, agent_id`, | |
| 496 | ) | |
| 497 | .all() | |
| 498 | .map((r) => ({ | |
| 499 | scopeId: r.scope_id, | |
| 500 | agentId: r.agent_id, | |
| 501 | subscriptionId: r.subscription_id, | |
| 502 | })); | |
| 503 | } | |
| 504 | ||
| 505 | 490 | /** |
| 506 | 491 | * The set of accounts one agent (or everyone) may use at a scope, replaced |
| 507 | 492 | * whole. An empty set removes the grant, and the wider one applies again. |
src/core/timers.ts −4
| @@ -252,10 +252,6 @@ export function pendingOnce(db: Database, appId: string): number { | ||
| 252 | 252 | return db.query<{ n: number }, [string]>("SELECT COUNT(*) AS n FROM timer WHERE app_id = ?1 AND kind = 'once' AND name = ''").get(appId)?.n ?? 0; |
| 253 | 253 | } |
| 254 | 254 | |
| 255 | export function pendingTimers(db: Database, appId: string, limit = 100): Timer[] { | |
| 256 | return db.query<Row, [string, number]>("SELECT * FROM timer WHERE app_id = ?1 AND kind = 'once' AND name = '' ORDER BY due_at LIMIT ?2").all(appId, limit).map(toTimer); | |
| 257 | } | |
| 258 | ||
| 259 | 255 | export function setPaused(db: Database, id: number, paused: boolean, now: number): void { |
| 260 | 256 | const t = getTimer(db, id); |
| 261 | 257 | if (t === undefined) return; |
src/core/usage.ts −13
| @@ -23,12 +23,6 @@ import type { Database } from "bun:sqlite"; | ||
| 23 | 23 | |
| 24 | 24 | /** How a run ended, as far as spend is concerned. */ |
| 25 | 25 | export type UsageOutcome = "ok" | "failed" | "paused" | "running"; |
| 26 | export const USAGE_OUTCOMES: readonly UsageOutcome[] = [ | |
| 27 | "ok", | |
| 28 | "failed", | |
| 29 | "paused", | |
| 30 | "running", | |
| 31 | ]; | |
| 32 | 26 | |
| 33 | 27 | /** |
| 34 | 28 | * What a run was for: `build` (an issue or a pull's feedback), `plan` (a |
| @@ -156,13 +150,6 @@ export function issueUsage( | ||
| 156 | 150 | |
| 157 | 151 | /** What the ledger can be summed by. Each maps to one fixed column. */ |
| 158 | 152 | export type UsageBy = "subscription" | "repo" | "agent" | "issue" | "kind"; |
| 159 | export const USAGE_BY: readonly UsageBy[] = [ | |
| 160 | "subscription", | |
| 161 | "repo", | |
| 162 | "agent", | |
| 163 | "issue", | |
| 164 | "kind", | |
| 165 | ]; | |
| 166 | 153 | const COLUMN: Readonly<Record<UsageBy, string>> = { |
| 167 | 154 | subscription: "subscription_id", |
| 168 | 155 | repo: "repo_id", |
src/crew/models.ts −5
| @@ -11,8 +11,3 @@ export const MODELS: readonly { id: string; label: string }[] = [ | ||
| 11 | 11 | { id: "sonnet", label: "Sonnet — capable and quick" }, |
| 12 | 12 | { id: "haiku", label: "Haiku — the quickest" }, |
| 13 | 13 | ]; |
| 14 | ||
| 15 | /** The label for a model id, or the id itself when it is not on the list. */ | |
| 16 | export function modelLabel(id: string): string { | |
| 17 | return MODELS.find((m) => m.id === id)?.label ?? id; | |
| 18 | } |
src/data/mask.ts −2
| @@ -35,8 +35,6 @@ export const FORCE: Readonly<Record<string, readonly string[]>> = { | ||
| 35 | 35 | ], |
| 36 | 36 | }; |
| 37 | 37 | |
| 38 | export const isSecretColumn = (column: string): boolean => SECRET.test(column); | |
| 39 | ||
| 40 | 38 | /** Whether `table.column` of a source shows only the mask. */ |
| 41 | 39 | export function masker(sourceId: string): (table: string, column: string) => boolean { |
| 42 | 40 | const allow = new Set(ALLOW[sourceId] ?? []); |
src/display/items.ts −27
| @@ -131,13 +131,6 @@ export async function selectionKeys(app: App, config: DisplayConfig, viewer: Use | ||
| 131 | 131 | return orderItems(found, config.order).map((i) => i.key); |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | /** | |
| 135 | * Items for the given keys, in that order, as `viewer` may see them: what a | |
| 136 | * display's page draws for builds that are not on it yet (its sidebar). | |
| 137 | */ | |
| 138 | export const itemsOfKeys = (app: App, display: Repo, config: DisplayConfig, keys: readonly string[], viewer: User | undefined): Promise<DisplayItem[]> => | |
| 139 | chosenItems(app, display, config, keys, viewer); | |
| 140 | ||
| 141 | 134 | /** The chosen builds a viewer may see on the display, in the chosen order. */ |
| 142 | 135 | async function chosenItems(app: App, display: Repo, config: DisplayConfig, builds: readonly string[], viewer: User | undefined): Promise<DisplayItem[]> { |
| 143 | 136 | const byRepo = new Map<string, { repo: Repo | undefined; pins: Map<string, BuildPin> }>(); |
| @@ -214,23 +207,3 @@ export function orderItems<T extends { readonly key: string; readonly pin: Pick< | ||
| 214 | 207 | .sort((a, b) => (a.pin.pinnedAt < b.pin.pinnedAt ? -1 : a.pin.pinnedAt > b.pin.pinnedAt ? 1 : a.key < b.key ? -1 : 1)); |
| 215 | 208 | return [...placed, ...rest]; |
| 216 | 209 | } |
| 217 | ||
| 218 | /** | |
| 219 | * A person's new selection for a display, made whole: `named` is the list | |
| 220 | * they gave, in their order, of builds they may name; every build already on | |
| 221 | * the display from a repository they cannot read keeps its place, so a page | |
| 222 | * that never showed its key cannot drop it. | |
| 223 | */ | |
| 224 | export async function keepUnnamed(app: App, config: DisplayConfig, named: readonly string[], viewer: User | undefined): Promise<string[]> { | |
| 225 | const current = await selectionKeys(app, config, "everyone"); | |
| 226 | const readable = (key: string): boolean => { | |
| 227 | const [owner = "", name = ""] = key.slice(0, key.lastIndexOf(":")).split("/"); | |
| 228 | const repo = getRepo(app.db, owner, name); | |
| 229 | return repo !== undefined && canRead(app.db, repo, viewer); | |
| 230 | }; | |
| 231 | const out = named.filter(readable); | |
| 232 | current.forEach((key, at) => { | |
| 233 | if (!readable(key) && !out.includes(key)) out.splice(Math.min(at, out.length), 0, key); | |
| 234 | }); | |
| 235 | return out; | |
| 236 | } |
src/display/known.ts −6
| @@ -307,12 +307,6 @@ export async function warmDisplays(app: App): Promise<void> { | ||
| 307 | 307 | }); |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | /** Of `repos`, those with no `display.json` on their default branch. */ | |
| 311 | export async function withoutDisplay(app: App, repos: readonly Repo[]): Promise<Repo[]> { | |
| 312 | const read = await inTurn(repos, (repo) => displayOf(app, repo)); | |
| 313 | return repos.filter((_, i) => read[i] === undefined); | |
| 314 | } | |
| 315 | ||
| 316 | 310 | /** What a display is; the page and the terminal screen say it once, above the list. */ |
| 317 | 311 | export const DISPLAYS_SENTENCE = "A display is a showcase screen for a repository: its pinned demos, laid out as a shelf, grid or graph, to open full screen."; |
| 318 | 312 | /** How to make one; the empty state of the page and of the terminal screen. */ |
src/display/launch.ts +1 −53
| @@ -14,14 +14,9 @@ | ||
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | 16 | import { createHmac, timingSafeEqual } from "node:crypto"; |
| 17 | import type { App } from "../app.ts"; | |
| 18 | import { appsRuntime } from "../apps/runtime.ts"; | |
| 19 | import { arcadeUrl } from "../arcade/host.ts"; | |
| 20 | import { cartFile, shownFile } from "../arcade/shelf.ts"; | |
| 21 | import { canRead, type Repo } from "../core/repos.ts"; | |
| 17 | import type { Repo } from "../core/repos.ts"; | |
| 22 | 18 | import type { BuildPin } from "../git/builds.ts"; |
| 23 | 19 | import { loadKey } from "../kernel/secret.ts"; |
| 24 | import type { DisplayItem } from "./items.ts"; | |
| 25 | 20 | |
| 26 | 21 | /** How long a grant to play a private page lasts. */ |
| 27 | 22 | export const CART_GRANT_MS = 60 * 60 * 1000; |
| @@ -45,53 +40,6 @@ export function verifyCart(dataDir: string, path: string, grant: string, now = D | ||
| 45 | 40 | return a.length === b.length && timingSafeEqual(a, b); |
| 46 | 41 | } |
| 47 | 42 | |
| 48 | /** The display origin, or undefined where no apps run. */ | |
| 49 | export function displayOrigin(app: App): string | undefined { | |
| 50 | const runtime = appsRuntime(app); | |
| 51 | return runtime === undefined ? undefined : arcadeUrl(runtime); | |
| 52 | } | |
| 53 | ||
| 54 | type Hidden = Pick<DisplayItem, "display" | "id">; | |
| 55 | ||
| 56 | /** An item's own routes on the forge, under its display. */ | |
| 57 | export const shownBase = (item: Hidden): string => `/${item.display.ownerName}/${item.display.name}/display/demo/${item.id}`; | |
| 58 | ||
| 59 | /** Where a captured demo plays, or undefined where no apps run or nothing is captured. */ | |
| 60 | export function playUrl(app: App, item: DisplayItem): string | undefined { | |
| 61 | if (item.captured === undefined) return undefined; | |
| 62 | if (item.open) return pinPlayUrl(app, item.repo, item.pin.oid, item.demo.page); | |
| 63 | const origin = displayOrigin(app); | |
| 64 | if (origin === undefined) return undefined; | |
| 65 | const path = shownFile(item); | |
| 66 | const plain = canRead(app.db, item.display, undefined); | |
| 67 | return `${origin}/${path}${plain ? "" : `?g=${signCart(app.config.dataDir, path)}`}`; | |
| 68 | } | |
| 69 | ||
| 70 | /** | |
| 71 | * Where a commit's captured page plays on the display origin, read through | |
| 72 | * its own repository: plain when anyone may read it, else with a grant. | |
| 73 | * The caller says it is captured (`captureState`). | |
| 74 | */ | |
| 75 | export function pinPlayUrl(app: App, repo: Repo, oid: string, page: string): string | undefined { | |
| 76 | const origin = displayOrigin(app); | |
| 77 | if (origin === undefined) return undefined; | |
| 78 | const path = cartFile(repo, oid, page); | |
| 79 | return `${origin}/${path}${canRead(app.db, repo, undefined) ? "" : `?g=${signCart(app.config.dataDir, path)}`}`; | |
| 80 | } | |
| 81 | ||
| 82 | /** Where a captured demo downloads, on the forge. */ | |
| 83 | export const downloadUrl = (item: DisplayItem): string => | |
| 84 | item.open | |
| 85 | ? `/${item.repo.ownerName}/${item.repo.name}/builds/${item.pin.oid}/download?page=${encodeURIComponent(item.demo.page)}` | |
| 86 | : `${shownBase(item)}/download`; | |
| 87 | ||
| 88 | 43 | /** A pin's screenshots, on its repository. */ |
| 89 | 44 | export const repoShotsUrl = (repo: Pick<Repo, "ownerName" | "name">, pin: Pick<BuildPin, "label">): string => |
| 90 | 45 | `/${repo.ownerName}/${repo.name}/builds/${encodeURIComponent(pin.label)}/shots`; |
| 91 | ||
| 92 | /** A demo's screenshots, on the forge. */ | |
| 93 | export const shotsUrl = (item: DisplayItem): string => (item.open ? repoShotsUrl(item.repo, item.pin) : `${shownBase(item)}/shots`); | |
| 94 | ||
| 95 | /** A demo's cover, or the picture of its captured page, on the forge. */ | |
| 96 | export const coverUrl = (item: DisplayItem): string => | |
| 97 | item.open ? `/${item.repo.ownerName}/${item.repo.name}/builds/${encodeURIComponent(item.pin.label)}/cover` : `${shownBase(item)}/cover`; |
src/display/selections.ts −24
| @@ -9,8 +9,6 @@ | ||
| 9 | 9 | import type { App } from "../app.ts"; |
| 10 | 10 | import { canWrite, type Repo } from "../core/repos.ts"; |
| 11 | 11 | import type { User } from "../core/users.ts"; |
| 12 | import { selectionKeys } from "./items.ts"; | |
| 13 | import { listedDisplays } from "./known.ts"; | |
| 14 | 12 | |
| 15 | 13 | /** One display, as a selection of builds. */ |
| 16 | 14 | export interface DisplaySelection { |
| @@ -26,32 +24,10 @@ export interface DisplaySelection { | ||
| 26 | 24 | readonly writes: boolean; |
| 27 | 25 | } |
| 28 | 26 | |
| 29 | /** The id the Showcased selection goes by in a URL. */ | |
| 30 | export const SHOWCASED = "showcased"; | |
| 31 | ||
| 32 | 27 | /** Whether `user` may change a display in `repo`: a person who writes it, never an agent. */ |
| 33 | 28 | export const writesDisplay = (app: App, repo: Repo, user: User | undefined): boolean => |
| 34 | 29 | user !== undefined && user.kind !== "agent" && canWrite(app.db, repo, user); |
| 35 | 30 | |
| 36 | /** Every display `viewer` reads whose file parses, as a selection, by title. */ | |
| 37 | export async function displaySelections(app: App, viewer: User | undefined): Promise<DisplaySelection[]> { | |
| 38 | const listed = await listedDisplays(app, viewer); | |
| 39 | const out: DisplaySelection[] = []; | |
| 40 | for (const d of listed) { | |
| 41 | if (!d.config.ok) continue; | |
| 42 | const config = d.config.value; | |
| 43 | out.push({ | |
| 44 | id: `${d.repo.ownerName}/${d.repo.name}`, | |
| 45 | repo: d.repo, | |
| 46 | title: config.title, | |
| 47 | keys: await selectionKeys(app, config, viewer), | |
| 48 | chosen: config.builds !== undefined, | |
| 49 | writes: writesDisplay(app, d.repo, viewer), | |
| 50 | }); | |
| 51 | } | |
| 52 | return out.sort((a, b) => (a.title.toLowerCase() < b.title.toLowerCase() ? -1 : a.title.toLowerCase() > b.title.toLowerCase() ? 1 : a.id < b.id ? -1 : 1)); | |
| 53 | } | |
| 54 | ||
| 55 | 31 | /** The names of the selections a build is in: Showcased first, then each display. */ |
| 56 | 32 | export function selectionsHolding(key: string, showcased: boolean, displays: readonly DisplaySelection[]): string[] { |
| 57 | 33 | return [...(showcased ? ["Showcased"] : []), ...displays.filter((d) => d.keys.includes(key)).map((d) => d.title)]; |
src/feed/chips.ts −2
| @@ -18,8 +18,6 @@ const CHIP_OF: Partial<Record<FeedKind, KindChip>> = { | ||
| 18 | 18 | release: "releases", |
| 19 | 19 | }; |
| 20 | 20 | |
| 21 | export const chipOfKind = (kind: FeedKind): KindChip | undefined => CHIP_OF[kind]; | |
| 22 | ||
| 23 | 21 | /** Whether the viewer's chips switch this item off. */ |
| 24 | 22 | export function chipHides( |
| 25 | 23 | chips: Chips, |
src/flow/kpi_words.ts −16
| @@ -177,22 +177,6 @@ export function trafficAttention(t: TrafficFigures): "deep" | "crawlers" | null | ||
| 177 | 177 | return null; |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | /** The tile's words. */ | |
| 181 | export function trafficWords(t: TrafficTotals): { note: string; title: string; attn: boolean } { | |
| 182 | const top = trafficTop(t); | |
| 183 | if (top === null) return { note: "no requests in 15 min", title: KPI_COUNTS.traffic, attn: false }; | |
| 184 | const by = TRAFFIC_CLASSES.map((c) => `${TRAFFIC_WORDS[c]} ${share(t.classes[c].ms, t.ms)} (${t.classes[c].requests})`).join(", "); | |
| 185 | const facts = `${by}. ${t.refused} refused, about ${t.addresses} ${t.addresses === 1 ? "address" : "addresses"}.`; | |
| 186 | const wrong = trafficAttention(t); | |
| 187 | if (wrong !== null) | |
| 188 | return { | |
| 189 | note: `of time: ${wrong === "deep" ? "anonymous deep" : "crawlers"}, too much`, | |
| 190 | title: `Something is wrong: ${TRAFFIC_WORDS[wrong]} took most of the answering time, so everyone else waits. ${facts}`, | |
| 191 | attn: true, | |
| 192 | }; | |
| 193 | return { note: `of time: ${TRAFFIC_WORDS[top]}`, title: `Share of answering time over the last 15 minutes: ${facts}`, attn: false }; | |
| 194 | } | |
| 195 | ||
| 196 | 180 | /** Home's one line over /review: `3 waiting on you, oldest 2 days` (the largest sensible unit); null at zero, so the line is absent. */ |
| 197 | 181 | export function waitingWords(count: number, oldestAt: string | null, now: Date): string | null { |
| 198 | 182 | if (count <= 0) return null; |
src/git/local.ts −15
| @@ -121,16 +121,6 @@ async function drain( | ||
| 121 | 121 | return all; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | /** `git rev-parse --show-toplevel`: the work-tree root, or an Err. */ | |
| 125 | export async function repoRoot(dir: string): Promise<LocalResult<string>> { | |
| 126 | const out = await runLocal(["rev-parse", "--show-toplevel"], { cwd: dir }); | |
| 127 | return out.ok ? ok(out.value.trim()) : out; | |
| 128 | } | |
| 129 | ||
| 130 | export async function isRepo(dir: string): Promise<boolean> { | |
| 131 | return (await repoRoot(dir)).ok; | |
| 132 | } | |
| 133 | ||
| 134 | 124 | /** When the last fetch landed, from `.git/FETCH_HEAD`'s mtime, else null. */ |
| 135 | 125 | export async function lastFetch(dir: string): Promise<Date | null> { |
| 136 | 126 | const file = Bun.file(`${dir}/.git/FETCH_HEAD`); |
| @@ -303,11 +293,6 @@ function entry( | ||
| 303 | 293 | return { path, origPath, index, work, untracked, conflicted }; |
| 304 | 294 | } |
| 305 | 295 | |
| 306 | /** The two-letter summary a file row shows: "M.", ".M", "??", "UU". */ | |
| 307 | export function statusLetters(f: FileEntry): string { | |
| 308 | return f.untracked ? "??" : `${f.index}${f.work}`; | |
| 309 | } | |
| 310 | ||
| 311 | 296 | // ── diffs ──────────────────────────────────────────────────────────────── |
| 312 | 297 | |
| 313 | 298 | /** |
src/http/script_errors.ts −1
| @@ -23,7 +23,6 @@ import { clientBucket } from "./peer.ts"; | ||
| 23 | 23 | import type { RouteOf } from "./measure.ts"; |
| 24 | 24 | import { windowStart } from "./csp_report.ts"; |
| 25 | 25 | |
| 26 | export const SCRIPT_ERROR_PATH = "/_script-error"; | |
| 27 | 26 | export const SCRIPT_ERROR_MAX = BODY_CAPS.scriptError.bytes; |
| 28 | 27 | export const MESSAGE_MAX = 120; |
| 29 | 28 | const PATH_MAX = 200; |
src/kernel/result.ts −10
| @@ -29,16 +29,6 @@ export function trap<T>(fn: () => T): Result<T, unknown> { | ||
| 29 | 29 | } |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | export async function trapAsync<T>( | |
| 33 | fn: () => Promise<T>, | |
| 34 | ): Promise<Result<T, unknown>> { | |
| 35 | try { | |
| 36 | return ok(await fn()); | |
| 37 | } catch (error) { | |
| 38 | return err(error); | |
| 39 | } | |
| 40 | } | |
| 41 | ||
| 42 | 32 | export function map<T, U, E>( |
| 43 | 33 | result: Result<T, E>, |
| 44 | 34 | fn: (value: T) => U, |
src/origins/jobs.ts −4
| @@ -135,10 +135,6 @@ export function runningJob( | ||
| 135 | 135 | return undefined; |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | /** Every job, newest first — what a "what is running?" view renders. */ | |
| 139 | export const listJobs = (): MirrorJob[] => | |
| 140 | [...jobs.values()].sort((a, b) => b.id.localeCompare(a.id)); | |
| 141 | ||
| 142 | 138 | /** |
| 143 | 139 | * Move a job on. A terminal job never moves again: a late stage report from |
| 144 | 140 | * a job that already failed must not resurrect it as "importing issues". |
src/perf/budgets.ts −6
| @@ -69,9 +69,3 @@ export function gitBudgetFor(key: string): Budget { | ||
| 69 | 69 | * largest paint at p95. |
| 70 | 70 | */ |
| 71 | 71 | export const PAGE_BUDGET = { serverP95Ms: 150, paintP95Ms: 1000 } as const; |
| 72 | ||
| 73 | /** | |
| 74 | * The ranked read behind /explore, /api/v1/explore and the MCP `explore` tool, as registered in | |
| 75 | * BUDGETS. | |
| 76 | */ | |
| 77 | export const EXPLORE_READ_BUDGET: Budget = budgetFor("/explore#read")!; |
src/tui/screens/common.ts −1
| @@ -1113,7 +1113,6 @@ export const VERDICT_MARKS = { | ||
| 1113 | 1113 | */ |
| 1114 | 1114 | export const ISSUE_MARK = G.ring; |
| 1115 | 1115 | export const PULL_MARK = G.pull; |
| 1116 | export const COMMENT_MARK = G.comment; | |
| 1117 | 1116 | |
| 1118 | 1117 | /** |
| 1119 | 1118 | * A formatter for a whole list's counts, so the numbers line up as a column |
src/tui/term/ansi.ts −1
| @@ -21,7 +21,6 @@ export const ALT_LEAVE = "\x1b[?1049l"; | ||
| 21 | 21 | export const CURSOR_HIDE = "\x1b[?25l"; |
| 22 | 22 | export const CURSOR_SHOW = "\x1b[?25h"; |
| 23 | 23 | export const ERASE_ALL = "\x1b[2J"; |
| 24 | export const ERASE_LINE_RIGHT = "\x1b[0K"; | |
| 25 | 24 | export const WRAP_OFF = "\x1b[?7l"; |
| 26 | 25 | export const WRAP_ON = "\x1b[?7h"; |
| 27 | 26 | export const SGR_RESET = "\x1b[0m"; |
src/tui/term/style.ts −18
| @@ -36,24 +36,6 @@ export function style( | ||
| 36 | 36 | return { fg, bg, attr }; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | export function withFg(s: Style, fg: Color): Style { | |
| 40 | return s.fg === fg ? s : { fg, bg: s.bg, attr: s.attr }; | |
| 41 | } | |
| 42 | ||
| 43 | export function withBg(s: Style, bg: Color): Style { | |
| 44 | return s.bg === bg ? s : { fg: s.fg, bg, attr: s.attr }; | |
| 45 | } | |
| 46 | ||
| 47 | export function withAttr(s: Style, bits: number): Style { | |
| 48 | const attr = s.attr | bits; | |
| 49 | return attr === s.attr ? s : { fg: s.fg, bg: s.bg, attr }; | |
| 50 | } | |
| 51 | ||
| 52 | export function withoutAttr(s: Style, bits: number): Style { | |
| 53 | const attr = s.attr & ~bits; | |
| 54 | return attr === s.attr ? s : { fg: s.fg, bg: s.bg, attr }; | |
| 55 | } | |
| 56 | ||
| 57 | 39 | export function sameStyle(a: Style, b: Style): boolean { |
| 58 | 40 | return a.fg === b.fg && a.bg === b.bg && a.attr === b.attr; |
| 59 | 41 | } |
src/tui/ui/editor.ts +1 −22
| @@ -36,7 +36,7 @@ import { | ||
| 36 | 36 | } from "../../web/highlight.ts"; |
| 37 | 37 | import type { KeyEvent } from "../term/input.ts"; |
| 38 | 38 | import { G, type Rect, type Screen as Surface } from "../term/screen.ts"; |
| 39 | import { style, BOLD } from "../term/style.ts"; | |
| 39 | import { style } from "../term/style.ts"; | |
| 40 | 40 | import { clusters, displayWidth, truncate } from "../term/width.ts"; |
| 41 | 41 | import { tokColor, type Tokens } from "./theme.ts"; |
| 42 | 42 | import type { CursorPos } from "./widgets.ts"; |
| @@ -93,24 +93,6 @@ export function colFromDisplay(line: string, want: number): number { | ||
| 93 | 93 | return chars.length; |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | /** The line as the terminal will show it — tabs expanded in place. */ | |
| 97 | export function expandLine(line: string): string { | |
| 98 | if (!line.includes("\t")) return line; | |
| 99 | let out = ""; | |
| 100 | let width = 0; | |
| 101 | for (const ch of clusters(line)) { | |
| 102 | if (ch === "\t") { | |
| 103 | const n = TAB - (width % TAB); | |
| 104 | out += " ".repeat(n); | |
| 105 | width += n; | |
| 106 | } else { | |
| 107 | out += ch; | |
| 108 | width += displayWidth(ch); | |
| 109 | } | |
| 110 | } | |
| 111 | return out; | |
| 112 | } | |
| 113 | ||
| 114 | 96 | export interface EditorFile { |
| 115 | 97 | readonly path: string; |
| 116 | 98 | readonly eol: "\n" | "\r\n"; |
| @@ -754,6 +736,3 @@ export class Editor { | ||
| 754 | 736 | return truncate(this.status(), width); |
| 755 | 737 | } |
| 756 | 738 | } |
| 757 | ||
| 758 | /** Bold the file name in a status line the caller has already measured. */ | |
| 759 | export const STATUS_BOLD = BOLD; |
src/tui/ui/image.ts −5
| @@ -284,11 +284,6 @@ export function clearImages(caps: TermCapabilities): Uint8Array[] { | ||
| 284 | 284 | return []; |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | /** Bytes that remove one placement by id. */ | |
| 288 | export function clearImage(id: number, caps: TermCapabilities): Uint8Array[] { | |
| 289 | return caps.graphics === "kitty" ? [kittyDelete(id)] : []; | |
| 290 | } | |
| 291 | ||
| 292 | 287 | // --------------------------------------------------------------------------- |
| 293 | 288 | // The placeholder |
| 294 | 289 | // --------------------------------------------------------------------------- |
src/web/space_view.ts −3
| @@ -9,9 +9,6 @@ | ||
| 9 | 9 | * and the other functions here, by name. |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | /** A landing slides from "in review" to "landed" over this much time (4 h). */ | |
| 13 | export const GLIDE_MS = 4 * 3600000; | |
| 14 | ||
| 15 | 12 | export function clamp(v: number, lo: number, hi: number): number { |
| 16 | 13 | return v < lo ? lo : v > hi ? hi : v; |
| 17 | 14 | } |
src/web/studio/shelf.ts −27
| @@ -129,33 +129,6 @@ function factsOf( | ||
| 129 | 129 | return out; |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | /** | |
| 133 | * Production's own fact for every one of these repositories, in one batch: | |
| 134 | * `runtime.status` is in-memory (no query), so the only reads are the app | |
| 135 | * records, who may enter them, their domains and the run rows a fact points | |
| 136 | * to — one each for the whole shelf, never one per row. | |
| 137 | */ | |
| 138 | export function productionFactsForRepos( | |
| 139 | ctx: Ctx, | |
| 140 | repos: readonly Repo[], | |
| 141 | ): Map<string, ProductionFact> { | |
| 142 | if (appsRuntime(ctx.app) === undefined) return new Map(); | |
| 143 | const records = appsForRepos( | |
| 144 | ctx.app.db, | |
| 145 | repos.map((r) => r.id), | |
| 146 | ); | |
| 147 | const enterable = enterableApps( | |
| 148 | ctx.app.db, | |
| 149 | repos.flatMap((repo) => { | |
| 150 | const app = records.get(repo.id); | |
| 151 | return app === undefined ? [] : [{ repo, app }]; | |
| 152 | }), | |
| 153 | ctx.auth.user, | |
| 154 | { named: false }, | |
| 155 | ); | |
| 156 | return factsOf(ctx, productionStatuses(ctx, repos, records, enterable)); | |
| 157 | } | |
| 158 | ||
| 159 | 132 | /** The row of a private app the viewer may not enter: its name, nothing it says. */ |
| 160 | 133 | function sealedRow(repo: Repo, user: User | undefined): Html { |
| 161 | 134 | const mine = user !== undefined && repo.ownerId === user.id; |
new above
offline