|
|
@@ -18,6 +18,13 @@ |
| 18 | 18 |
|
| 19 | 19 |
|
| 20 | 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 21 | 28 |
|
| 22 | 29 |
|
| 23 | 30 |
import { mayViewId, sealedScope } from "../../core/sealed.ts"; |
|
|
@@ -58,7 +65,7 @@ import { |
| 58 | 65 |
import { liveRegionsJs } from "../client.ts"; |
| 59 | 66 |
import { html, type Html } from "../html.ts"; |
| 60 | 67 |
import { page } from "../layout.ts"; |
| 61 | |
import { avatar, hueOf, icon } from "../ui.ts"; |
| 68 |
import { icon } from "../ui.ts"; |
| 62 | 69 |
import { autonomyStatus, type AutonomyStatus } from "../../crew/autonomy.ts"; |
| 63 | 70 |
import { |
| 64 | 71 |
parkedTwice, |
|
|
@@ -576,6 +583,8 @@ const GUTTER_LEAN = GX / 2 / (W + GX); |
| 576 | 583 |
const RULE = 30; |
| 577 | 584 |
|
| 578 | 585 |
const LINE = 26; |
| 586 |
|
| 587 |
const WORD_CH = 6.3; |
| 579 | 588 |
|
| 580 | 589 |
function trim(text: string, max: number): string { |
| 581 | 590 |
return text.length <= max ? text : `${text.slice(0, max - 1).trimEnd()}…`; |
|
|
@@ -676,7 +685,7 @@ function node( |
| 676 | 685 |
const bottom = py + H - 11; |
| 677 | 686 |
const number = `#${n.issue.number}`; |
| 678 | 687 |
const who = n.issue.assigneeName; |
| 679 | |
const whoX = left + 9 + number.length * 6.4; |
| 688 |
const whoX = left + 8 + number.length * 6.6; |
| 680 | 689 |
return html`<a |
| 681 | 690 |
class="map-node" |
| 682 | 691 |
data-state="${word}" |
|
|
@@ -711,21 +720,20 @@ function node( |
| 711 | 720 |
</text> |
| 712 | 721 |
<text class="map-meta" x="${left}" y="${bottom}">${number}</text> |
| 713 | 722 |
${who |
| 714 | |
? html`<g class="map-who" data-h="${hueOf(who)}"> |
| 715 | |
<circle cx="${whoX + 7}" cy="${bottom - 4}" r="7" /> |
| 716 | |
<text class="map-who-i" x="${whoX + 7}" y="${bottom - 1}" |
| 717 | |
>${who[0]}</text |
| 718 | |
> |
| 719 | |
<text class="map-who-n" x="${whoX + 19}" y="${bottom}" |
| 720 | |
>${trim(who, 11)}</text |
| 721 | |
> |
| 722 | |
</g>` |
| 723 |
? html`<text class="map-who-n" x="${whoX}" y="${bottom}" |
| 724 |
>${trim(who, 11)}</text |
| 725 |
>` |
| 723 | 726 |
: null} |
| 727 |
${word === "done" |
| 728 |
? null |
| 729 |
: html`<circle |
| 730 |
class="map-dot" |
| 731 |
cx="${px + W - 16 - word.length * WORD_CH}" |
| 732 |
cy="${bottom - 4}" |
| 733 |
r="2.5" |
| 734 |
/>`} |
| 724 | 735 |
<text class="map-word" x="${px + W - 12}" y="${bottom}" text-anchor="end"> |
| 725 | |
${word === "done" |
| 726 | |
? null |
| 727 | |
: html`<tspan class="map-dot" dy="-1">●</tspan |
| 728 | |
><tspan dy="1"> </tspan>`}${word} |
| 736 |
${word} |
| 729 | 737 |
</text> |
| 730 | 738 |
</a>`; |
| 731 | 739 |
} |
|
|
@@ -1089,17 +1097,11 @@ function chart(points: DayPoint[]): Html { |
| 1089 | 1097 |
</section>`; |
| 1090 | 1098 |
} |
| 1091 | 1099 |
|
| 1092 | |
const hueRules = Array.from( |
| 1093 | |
{ length: 12 }, |
| 1094 | |
(_, i) => `.map-who[data-h="${i}"] { --hue: ${i * 30 + 8}; }`, |
| 1095 | |
).join("\n"); |
| 1096 | |
|
| 1097 | 1100 |
export const mapCss = ` |
| 1098 | 1101 |
.map-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 272px; gap: 24px; align-items: start; margin-top: 4px; } |
| 1099 | 1102 |
@media (max-width: 860px) { .map-wrap { grid-template-columns: 1fr; } } |
| 1100 | 1103 |
.map-main { min-width: 0; } |
| 1101 | 1104 |
.map-autonomy { flex-basis: 100%; color: var(--muted-fg); text-wrap: pretty; } |
| 1102 | |
.map-autonomy .ico { color: var(--faint); vertical-align: -3px; margin-right: 2px; } |
| 1103 | 1105 |
|
| 1104 | 1106 |
/* ---- the canvas ---- */ |
| 1105 | 1107 |
.map-canvas { position: relative; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); touch-action: pan-y; user-select: none; -webkit-user-select: none; } |
|
|
@@ -1110,7 +1112,7 @@ export const mapCss = /* css */ ` |
| 1110 | 1112 |
.map-canvas.is-view .map-svg { height: 100%; } |
| 1111 | 1113 |
.map-svg text { font-family: var(--font); pointer-events: none; } |
| 1112 | 1114 |
.map-tools { position: absolute; top: 8px; right: 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--card); box-shadow: var(--shadow-1); overflow: hidden; } |
| 1113 | |
.map-tool { min-width: 26px; height: 24px; padding: 0 7px; border: 0; background: transparent; color: var(--muted-fg); font-size: 12px; font-weight: 550; line-height: 1; cursor: pointer; } |
| 1115 |
.map-tool { min-width: 26px; height: 24px; padding: 0 7px; border: 0; background: transparent; color: var(--muted-fg); font-size: 12.5px; font-weight: 550; line-height: 1; cursor: pointer; } |
| 1114 | 1116 |
.map-tool + .map-tool { border-left: 1px solid var(--border); } |
| 1115 | 1117 |
.map-tool:hover { background: var(--muted); color: var(--fg); } |
| 1116 | 1118 |
.map-tool:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; } |
|
|
@@ -1136,12 +1138,10 @@ export const mapCss = /* css */ ` |
| 1136 | 1138 |
.map-node[data-state="deferred"] .map-card { fill: none; stroke-dasharray: 4 3; } |
| 1137 | 1139 |
.map-node[data-state="deferred"] .map-title { fill: var(--muted-fg); } |
| 1138 | 1140 |
.map-node[data-state="blocked"] .map-title { fill: var(--muted-fg); } |
| 1139 | |
.map-meta { font-size: 11px; fill: var(--faint); font-variant-numeric: tabular-nums; } |
| 1140 | |
.map-who circle { fill: color-mix(in srgb, hsl(var(--hue, 220) 62% 52%) 22%, var(--card)); stroke: color-mix(in srgb, hsl(var(--hue, 220) 62% 52%) 30%, transparent); } |
| 1141 | |
.map-who-i { font-size: 8px; font-weight: 650; text-transform: uppercase; fill: color-mix(in srgb, hsl(var(--hue, 220) 62% 42%) 88%, var(--fg)); } |
| 1142 | |
.map-who-n { font-size: 11px; fill: var(--muted-fg); } |
| 1143 | |
.map-word { font-size: 11px; font-weight: 550; fill: var(--muted-fg); } |
| 1144 | |
.map-word .map-dot { font-size: 7px; fill: var(--faint); } |
| 1141 |
.map-meta { font-size: 11.5px; fill: var(--faint); font-variant-numeric: tabular-nums; } |
| 1142 |
.map-who-n { font-size: 11.5px; fill: var(--muted-fg); } |
| 1143 |
.map-word { font-size: 11.5px; font-weight: 550; fill: var(--muted-fg); } |
| 1144 |
.map-dot { fill: var(--faint); } |
| 1145 | 1145 |
.map-node[data-state="ready"] .map-dot { fill: var(--success); } |
| 1146 | 1146 |
.map-node[data-state="working"] .map-dot { fill: var(--accent); } |
| 1147 | 1147 |
.map-node[data-state="working"] .map-word { fill: var(--accent); } |
|
|
@@ -1157,10 +1157,10 @@ export const mapCss = /* css */ ` |
| 1157 | 1157 |
.map-edge-crit { stroke: var(--accent); } |
| 1158 | 1158 |
.map-edge-done { opacity: .45; } |
| 1159 | 1159 |
.map-rule line { stroke: var(--border); stroke-width: 1; } |
| 1160 | |
.map-rule text { font-size: 10.5px; fill: var(--faint); letter-spacing: .02em; } |
| 1160 |
.map-rule text { font-size: 11.5px; fill: var(--faint); letter-spacing: .02em; } |
| 1161 | 1161 |
|
| 1162 | 1162 |
/* ---- the line under a drawing ---- */ |
| 1163 | |
.map-counts { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 8px 2px 0; font-size: 12px; color: var(--muted-fg); } |
| 1163 |
.map-counts { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 8px 2px 0; font-size: 12.5px; color: var(--muted-fg); } |
| 1164 | 1164 |
.map-counts b { font-weight: 550; color: var(--fg); font-variant-numeric: tabular-nums; } |
| 1165 | 1165 |
.map-counts i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; background: var(--faint); } |
| 1166 | 1166 |
.map-counts i[data-state="ready"] { background: var(--success); } |
|
|
@@ -1172,12 +1172,12 @@ export const mapCss = /* css */ ` |
| 1172 | 1172 |
|
| 1173 | 1173 |
/* ---- beside the drawing ---- */ |
| 1174 | 1174 |
.map-list h2 { font-size: 13px; margin: 0 0 6px; } |
| 1175 | |
.map-list ol { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 13.5px; list-style: decimal; } |
| 1175 |
.map-list ol { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 13px; list-style: decimal; } |
| 1176 | 1176 |
.map-list ol li::marker { color: var(--faint); font-variant-numeric: tabular-nums; } |
| 1177 | 1177 |
.map-list li span { display: block; } |
| 1178 | 1178 |
.map-list + .map-list { margin-top: 18px; } |
| 1179 | 1179 |
.map-ask { display: block; } |
| 1180 | |
.map-pillars ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 13.5px; } |
| 1180 |
.map-pillars ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 13px; } |
| 1181 | 1181 |
.map-chart { width: 100%; height: auto; display: block; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); } |
| 1182 | 1182 |
.map-level { fill: none; stroke: var(--accent); stroke-width: 1.5; } |
| 1183 | 1183 |
.map-flow { fill: color-mix(in srgb, var(--fg) 14%, transparent); } |
|
|
@@ -1193,15 +1193,8 @@ export const mapCss = /* css */ ` |
| 1193 | 1193 |
.map-lane[open] > .map-lane-head .map-lane-caret { transform: rotate(90deg); } |
| 1194 | 1194 |
.map-lane-name { font-weight: 620; font-size: 15px; letter-spacing: -0.01em; } |
| 1195 | 1195 |
.map-lane-name .muted { font-weight: 500; } |
| 1196 | |
.map-lane-word { font-size: 12px; color: var(--muted-fg); padding: 1px 8px; border: 1px solid var(--border); border-radius: 999px; line-height: 18px; } |
| 1196 |
.map-lane-word { font-size: 11.5px; color: var(--muted-fg); padding: 1px 8px; border: 1px solid var(--border); border-radius: 999px; line-height: 18px; } |
| 1197 | 1197 |
.map-lane-word[data-autonomy="autonomous"] { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 34%, transparent); } |
| 1198 | |
.map-spend { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted-fg); font-variant-numeric: tabular-nums; } |
| 1199 | |
.map-spend svg { width: 72px; height: 4px; border-radius: 2px; overflow: hidden; } |
| 1200 | |
.map-spend-track { fill: var(--muted); } |
| 1201 | |
.map-spend-fill { fill: var(--muted-fg); } |
| 1202 | |
.map-spend[data-near="1"] .map-spend-fill { fill: var(--attn); } |
| 1203 | |
.map-lane-crew { display: inline-flex; align-items: center; gap: 4px; } |
| 1204 | |
.map-lane-crew .avatar { box-shadow: 0 0 0 2px var(--card); } |
| 1205 | 1198 |
.map-lane-head .map-counts { margin: 0 0 0 auto; } |
| 1206 | 1199 |
.map-lane[data-idle="1"] > .map-lane-head .map-lane-name { color: var(--muted-fg); font-weight: 560; } |
| 1207 | 1200 |
.map-lane > .map-canvas, .map-lane > .map-empty { border: 0; border-top: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius); } |
|
|
@@ -1209,7 +1202,6 @@ export const mapCss = /* css */ ` |
| 1209 | 1202 |
.map-lane-head { gap: 6px 10px; } |
| 1210 | 1203 |
.map-lane-head .map-counts { margin-left: 0; flex-basis: 100%; } |
| 1211 | 1204 |
} |
| 1212 | |
${hueRules} |
| 1213 | 1205 |
`; |
| 1214 | 1206 |
|
| 1215 | 1207 |
|
|
|
@@ -1368,26 +1360,14 @@ export const mapViewJs = /* js */ ` |
| 1368 | 1360 |
})(); |
| 1369 | 1361 |
`; |
| 1370 | 1362 |
|
| 1371 | |
|
| 1372 | |
function autonomyLine(ctx: Ctx, repo: Repo): Html | null { |
| 1373 | |
if (repo.autonomy === "off") |
| 1374 | |
return repo.crewOutsiders |
| 1375 | |
? html`<p class="small map-autonomy">${OUTSIDERS_NOTE}</p>` |
| 1376 | |
: null; |
| 1377 | |
const s = autonomyStatus(ctx.app, repo); |
| 1378 | |
const paused = |
| 1379 | |
s.paused === "ceiling" |
| 1380 | |
? " · paused at the ceiling until 00:00 UTC" |
| 1381 | |
: s.paused === "no crew" |
| 1382 | |
? " · paused: no crew" |
| 1383 | |
: s.paused === "nobody" |
| 1384 | |
? " · paused: nobody to act as" |
| 1385 | |
: ""; |
| 1386 | |
const line = `${repo.autonomy === "autonomous" ? "Autonomous" : "Assisted"} · $${s.spentTodayUsd.toFixed(2)} of $${s.ceilingUsd.toFixed(0)} today · ${s.active} of ${s.slots} slots${paused} · ${repo.crewOutsiders ? "anyone signed in directs the crew" : "only writers direct the crew"}`; |
| 1387 | |
return html`<p class="small map-autonomy"> |
| 1388 | |
${icon("play")} ${line} · |
| 1389 | |
<a href="${repoBase(repo)}/settings/autonomy">settings</a> |
| 1390 | |
</p>`; |
| 1363 |
|
| 1364 |
|
| 1365 |
|
| 1366 |
|
| 1367 |
function outsidersLine(repo: Repo): Html | null { |
| 1368 |
return repo.crewOutsiders |
| 1369 |
? html`<p class="small map-autonomy">${OUTSIDERS_NOTE}</p>` |
| 1370 |
: null; |
| 1391 | 1371 |
} |
| 1392 | 1372 |
|
| 1393 | 1373 |
const LIVE_KINDS = "run.*,issue.*,pull.*"; |
|
|
@@ -1428,7 +1408,7 @@ export async function mapPage(ctx: Ctx): Promise<Response> { |
| 1428 | 1408 |
is the least work that still has to happen in order. |
| 1429 | 1409 |
<a href="${repoBase(repo)}/milestones">How far each milestone is</a>. |
| 1430 | 1410 |
</p> |
| 1431 | |
${autonomyLine(ctx, repo)} |
| 1411 |
${outsidersLine(repo)} |
| 1432 | 1412 |
</div> |
| 1433 | 1413 |
<div |
| 1434 | 1414 |
class="map-wrap" |
|
|
@@ -1691,29 +1671,10 @@ export function globalLanes(app: App, viewer: User | undefined): Lane[] { |
| 1691 | 1671 |
); |
| 1692 | 1672 |
} |
| 1693 | 1673 |
|
| 1694 | |
|
| 1695 | |
function spendWords(status: AutonomyStatus): string { |
| 1696 | |
return `$${status.spentTodayUsd.toFixed(2)} of $${status.ceilingUsd.toFixed(0)}`; |
| 1697 | |
} |
| 1698 | |
|
| 1699 | |
function spendBar(status: AutonomyStatus): Html { |
| 1700 | |
const share = |
| 1701 | |
status.ceilingUsd > 0 ? status.spentTodayUsd / status.ceilingUsd : 0; |
| 1702 | |
const pct = Math.max(0, Math.min(100, share * 100)); |
| 1703 | |
return html`<span |
| 1704 | |
class="map-spend" |
| 1705 | |
${share >= 0.9 ? html`data-near="1"` : null} |
| 1706 | |
title="Spent today against the day's ceiling" |
| 1707 | |
> |
| 1708 | |
<svg viewBox="0 0 100 4" preserveAspectRatio="none" aria-hidden="true"> |
| 1709 | |
<rect class="map-spend-track" width="100" height="4" /> |
| 1710 | |
<rect class="map-spend-fill" width="${pct.toFixed(1)}" height="4" /> |
| 1711 | |
</svg> |
| 1712 | |
<span>${spendWords(status)}</span> |
| 1713 | |
</span>`; |
| 1714 | |
} |
| 1715 | |
|
| 1716 | |
|
| 1674 |
|
| 1675 |
|
| 1676 |
|
| 1677 |
|
| 1717 | 1678 |
export function laneHtml(lane: Lane, width: number): Html { |
| 1718 | 1679 |
const { repo } = lane; |
| 1719 | 1680 |
const id = `lane-${repo.ownerName}-${repo.name}`; |
|
|
@@ -1732,19 +1693,6 @@ export function laneHtml(lane: Lane, width: number): Html { |
| 1732 | 1693 |
<span class="map-lane-word" data-autonomy="${repo.autonomy}" |
| 1733 | 1694 |
>${repo.autonomy}</span |
| 1734 | 1695 |
> |
| 1735 | |
${lane.status === undefined ? null : spendBar(lane.status)} |
| 1736 | |
${lane.workers.length === 0 |
| 1737 | |
? null |
| 1738 | |
: html`<span |
| 1739 | |
class="map-lane-crew" |
| 1740 | |
title="Working: ${lane.workers.join(", ")}" |
| 1741 | |
>${lane.workers.slice(0, 5).map((w) => avatar(w))}${lane.workers |
| 1742 | |
.length > 5 |
| 1743 | |
? html`<span class="muted small" |
| 1744 | |
>+${lane.workers.length - 5}</span |
| 1745 | |
>` |
| 1746 | |
: null}</span |
| 1747 | |
>`} |
| 1748 | 1696 |
${countsLine(lane.counts)} |
| 1749 | 1697 |
</summary> |
| 1750 | 1698 |
${drawMap( |