git clone https://garage44.eu/jeroen/midas.git.. /web/src/components/landing.tsx
import m, {MithrilComponent} from '@garage44/mithril'
import {Badge} from '@garage44/mithril/components'
import {confirmButton} from '@/components/confirm'
import {Until, clockOf, usually} from '@/components/elapsed'
import {act} from '@/lib/actions'
import {api} from '@/lib/api'
import {age, now, shortName, span} from '@/lib/format'
import {deployOf, journey, queue, shortWords} from '@/lib/landing'
import type {Deploy, Journey} from '@/lib/landing'
import {nameOf} from '@/lib/names'
import {projectName, projectTag, reposOf} from '@/lib/projects'
import {go} from '@/lib/route'
import {awaitsPerson} from '@/lib/status'
import {$s} from '@/lib/store'
import {cards, hosted} from '@/lib/stream'
import type {BoardCard, DeployRun, Hosted} from '@/lib/stream'
import type {Ship} from '@/lib/types'
/**
* The way from "Land it" to live, drawn: as a gauge of its steps (in line,
* checked, on main, deploying, live) in a session's message box and its rows,
* which opens it in full; in the conversation as a line where each step
* happened; and on Home as the next deploy over every session on its way, and
* a list of what landed today. The block at the conversation's foot it
* replaced stood under every message, and its lines ran off a phone's screen
* (2026-11-01). What each step waits for is
* said in words — whose landing is ahead, what the gate is doing, why the
* deploy has not gone yet — so the person need not ask the agent.
*/
const clock = (t: number) => new Date(t * 1000).toLocaleTimeString([], {hour: '2-digit', minute: '2-digit'})
/** A card's projects: its session's, as midas runs it, else as its start said. */
const reposOfCard = (c: BoardCard | undefined, h: Hosted | undefined): string[] => (h && reposOf(h).length ? reposOf(h) : c?.repo ? [c.repo] : [])
/** The session midas runs for a card, the latest of an owner's. */
const hostedOf = (owner: string) => [...hosted()].filter((h) => h.owner === owner).sort((a, b) => b.updated - a.updated)[0]
/** A session's way to live, from the page's store; null while it is not on it. */
export function journeyOf(h: Hosted | undefined, c: BoardCard | undefined = h ? cards().find((x) => x.session === h.owner) : undefined): Journey | null {
return journey(h, c, cards(), $s.deploys?.ships, reposOfCard(c, h))
}
/** Another session on the way, by name, linked where midas runs it. */
function other(c: BoardCard): m.Children {
const h = hostedOf(c.session)
const title = shortName(h?.title ?? nameOf(c.session).title, 60)
return h ? (
<a href={`/sessions/${h.id}`} onclick={(e: Event) => e.stopPropagation()}>
{title}
</a>
) : (
title
)
}
/** What a card in the landing queue does now, short. */
function queueWords(c: BoardCard): string {
if (c.stage === 'landing') return `${c.node_gate && c.node ? `checks on ${c.node}` : (c.step ?? 'checks')} · ${age(c.since)}`
return `in line ${age(c.since)}`
}
/** The landing queue, with this session's place lit. */
function line(self: string): m.Children {
const q = queue(cards())
if (q.length < 2) return null
return (
<ol class="land__queue">
{q.map((c, i) => (
<li class={c.session === self ? 'is-self' : ''}>
<span class="land__qn">{c.stage === 'landing' ? '▸' : (c.position ?? i)}</span>
<span class="land__qt">{c.session === self ? 'this session' : other(c)}</span>
<span class="land__qs">{queueWords(c)}</span>
</li>
))}
</ol>
)
}
/** What the deploy after landings waits for, or does, in words. */
export function deployWords(d: Deploy): m.Children {
switch (d.kind) {
case 'waits':
return (
<>
Waits for {d.for.length === 1 ? 'the landing' : `the ${d.for.length} landings`} in line, so one deploy carries them:{' '}
{d.for.map((c, i) => (
<span>
{i ? ', ' : ''}
{other(c)}
</span>
))}
{d.by ? <>. Goes by {clock(d.by)} at the latest (<Until at={d.by} />).</> : '.'}
</>
)
case 'running':
return 'Waits for the deploy running now to end.'
case 'deploying':
return deployTargets(d.targets)
case 'held':
return `Held by ${d.by}${d.why ? `: "${d.why}"` : ''} (${age(d.at)} ago). It stays on main until someone deploys or releases.`
case 'failed':
return `The deploy failed (${d.targets
.filter((t) => t.state === 'failed')
.map((t) => t.target)
.join(', ')}); the next landing tries again, or deploy by hand.`
case 'ungated':
return 'Main has no receipt from the landing gate, so the hub will not deploy it by itself.'
case 'notice':
// Put off: the hub's words say by whom and why. Announced: they only count down, which the line does live.
return (
<>
{d.at ? <>Goes live around {clock(d.at)} (<Until at={d.at} />). </> : null}
{d.deferred
? `${d.words[0].toUpperCase()}${d.words.slice(1)}.`
: 'The sessions at work were told first, since the deploy restarts what they use; one can put it off a while.'}
</>
)
case 'planning':
return 'Landed a moment ago: the hub plans its deploy now.'
case 'none':
return 'Goes out with the next deploy.'
}
}
/** Deploy now, or release a hold: what the person can do about a deploy that waits. */
function deployActions(d: Deploy, ship: Ship | null): m.Children {
if (!$s.hasKey) return null
const auto = (ship?.targets ?? []).map((t) => t.target)
if (!auto.length || d.kind === 'deploying' || d.kind === 'none' || d.kind === 'planning' || d.kind === 'running') return null
const now = confirmButton(`land-deploy-now-${ship?.repo ?? ''}`, {
label: 'Deploy now',
armedLabel: `Tap again: deploy ${auto.join(', ')}`,
title: 'publish the tip of main now, without waiting',
run: () =>
act('deploying main', async () => {
for (const t of auto) await api.deploy(t)
}),
})
if (d.kind !== 'held') return <div class="land__actions">{now}</div>
return (
<div class="land__actions">
{confirmButton('land-release', {
label: 'Release the hold',
armedLabel: 'Tap again to release',
run: () => act('deploys after landings resume', () => api.releaseDeploys()),
})}
{now}
</div>
)
}
/** The share of a step a clock has run against what it takes as a rule; a half where nothing says. */
const shareOf = (since: number | null | undefined, typical: number | null | undefined) => (since == null || !typical ? 0.5 : Math.max(0, Math.min(1, (now() - since) / typical)))
/** A deploy's start, in unix seconds. */
const startOf = (r: DeployRun) => Date.parse(r.since) / 1000 || null
/** The deploys going now for these targets, by target. */
const runsOf = (targets: Ship['targets']) => {
const going = $s.deploys?.running ?? []
return new Map(targets.flatMap((t) => (t.state === 'live' || t.state === 'skip' ? [] : going.filter((r) => r.target === t.target).map((r) => [t.target, r] as const))))
}
/** How far a deploy has come, from nothing to all of its targets live: each running one counts for its share of its usual time. */
function deployShare(targets: Ship['targets']): number {
const picked = targets.filter((t) => t.state !== 'unpicked' && t.state !== 'skip')
if (!picked.length) return 1
const runs = runsOf(picked)
const done = picked.reduce((n, t) => {
if (t.state === 'live') return n + 1
const r = runs.get(t.target)
return n + (r ? Math.min(0.95, shareOf(startOf(r), r.typical)) : 0)
}, 0)
return Math.max(0.05, Math.min(0.97, done / picked.length))
}
type Tone = 'warning' | 'info' | 'success' | 'danger'
/**
* Where a session is on its way, as the gauge draws it: the step it is in (0 to
* 4, 5 once live), how far into it, the colour of its phase (amber waiting for
* the gate, blue on main and deploying, green live, red failed), and the step's
* number for its middle.
*/
export function gaugeOf(j: Journey): {at: number; frac: number; tone: Tone; mid: string; words: string} {
const words = (n: number) => `On its way to live: step ${n} of 5, ${shortWords(j)}`
switch (j.phase) {
case 'queued':
// The line shortens toward it: #3 is a third of the way, next is half.
return {at: 0, frac: j.position && j.position > 1 ? 1 / j.position : 0.5, tone: 'warning', mid: '1', words: words(1)}
case 'gate':
return {at: 1, frac: 0.5, tone: 'warning', mid: '2', words: words(2)}
case 'on_main': {
const d = j.deploy
if (d.kind === 'failed') return {at: 3, frac: deployShare(d.targets), tone: 'danger', mid: '!', words: words(4)}
if (d.kind === 'deploying') return {at: 3, frac: deployShare(d.targets), tone: 'info', mid: '4', words: words(4)}
return {at: 2, frac: 1, tone: d.kind === 'held' || d.kind === 'ungated' ? 'warning' : 'info', mid: '3', words: words(3)}
}
case 'live':
case 'finished':
return {at: 5, frac: 1, tone: 'success', mid: '✓', words: j.phase === 'live' ? 'Live' : 'Landed and live'}
}
}
/**
* The way to live as a gauge: five arcs, one a step, those done full and the one
* it is in filled as far as it has come. A ring in pieces, so it is not read as
* the context's ring, which is whole.
*/
export function gauge(j: Journey, size: number): m.Vnode {
const g = gaugeOf(j)
const c = size / 2
const r = c - 2
const gap = 14
const pt = (a: number) => `${(c + r * Math.sin((a * Math.PI) / 180)).toFixed(2)} ${(c - r * Math.cos((a * Math.PI) / 180)).toFixed(2)}`
const arc = (a0: number, a1: number) => `M${pt(a0)}A${r} ${r} 0 0 1 ${pt(a1)}`
const arcs: m.Children[] = []
for (let i = 0; i < 5; i++) {
const a0 = i * 72 + gap / 2
const a1 = (i + 1) * 72 - gap / 2
arcs.push(<path class="gauge__track" d={arc(a0, a1)} />)
const f = i < g.at ? 1 : i === g.at ? g.frac : 0
if (f > 0) arcs.push(<path class="gauge__fill" d={arc(a0, a0 + (a1 - a0) * f)} />)
}
return (
<svg class={`gauge gauge--${g.tone}`} width={size} height={size} viewBox={`0 0 ${size} ${size}`} stroke-width={size >= 28 ? 3 : 2.5} role="img" aria-label={g.words}>
<title>{g.words}</title>
{arcs}
<text class="gauge__mid" x={c} y={c} dy="0.36em" font-size={size >= 28 ? 11 : 9}>
{g.mid}
</text>
</svg>
)
}
/**
* The gauge as a button, in a session's message box while it is on its way:
* it opens the sheet's To live.
*/
export function wayButton(s: Hosted | undefined, open: () => void): m.Vnode | null {
const j = s ? journeyOf(s) : null
if (!j) return null
return (
<button type="button" class="frame__icon way-button" title={gaugeOf(j).words} aria-label={gaugeOf(j).words} onclick={open}>
{gauge(j, 28)}
</button>
)
}
interface RunAttrs {
run: DeployRun
}
/**
* One deploy on its way, as a block: its target and clock against how long one
* takes as a rule, one bar in its steps (each as wide as it takes as a rule, the
* one it is at filling), and that step in words; tapped open, every step with
* what it took. A step past twice its usual time is striped and said in words.
* It sets its own clocks each second, so a ticking clock redraws nothing else.
*/
class RunView extends MithrilComponent<RunAttrs> {
run: DeployRun | null = null
timer = 0
tick = () => {}
oncreate(v: m.VnodeDOM<RunAttrs>) {
this.run = v.attrs.run
const el = v.dom as HTMLElement
const tick = (this.tick = () => {
const r = this.run!
const from = startOf(r)
const gone = from == null ? 0 : now() - from
const over = !!r.typical && gone > r.typical
;(el.querySelector('.deploy-run__clock') as HTMLElement).textContent = clockOf(gone)
el.classList.toggle('deploy-run--over', over)
const steps = r.steps ?? []
const i = steps.findIndex((s) => s.state === 'now')
const segs = el.querySelectorAll<HTMLElement>('.deploy-run__bar > i')
const at = steps[i]
const stepGone = at?.since != null ? now() - at.since : null
const slow = !!at?.typical && stepGone != null && stepGone > 2 * at.typical && stepGone - at.typical > 30
segs.forEach((seg, k) => {
const f = steps.length ? (k === i ? shareOf(at?.since, at?.typical) : 0) : shareOf(from, r.typical)
seg.style.setProperty('--f', `${Math.round(f * 100)}%`)
seg.classList.toggle('is-slow', k === i && slow)
})
;(el.querySelector('.deploy-run__now') as HTMLElement).textContent = at
? `${i + 1}/${steps.length} · ${at.name}${stepGone != null ? ` · ${clockOf(stepGone)}` : ''}`
: r.phase
const said = el.querySelector('.deploy-run__slow') as HTMLElement
said.hidden = !slow
if (slow) said.textContent = `${at.name.charAt(0).toUpperCase()}${at.name.slice(1)} has taken ${clockOf(stepGone!)}; it usually takes ${usually(at.typical!)}.`
})
tick()
this.timer = window.setInterval(tick, 1000)
}
onupdate(v: m.VnodeDOM<RunAttrs>) {
this.run = v.attrs.run
this.tick()
}
onremove() {
window.clearInterval(this.timer)
}
view(v: m.Vnode<RunAttrs>) {
const r = v.attrs.run
const steps = r.steps ?? []
// Each step as wide as it takes as a rule, none too narrow to see.
const sizes = steps.map((s) => s.typical ?? s.seconds ?? 0)
const total = sizes.reduce((a, b) => a + b, 0)
const grow = (x: number) => (total ? Math.max(x, total * 0.05) : 1)
return (
<div class="deploy-run">
<div class="deploy-run__top">
<b>{r.target}</b>
<span class="deploy-run__time">
<span class="deploy-run__clock" />
{r.typical ? <span class="deploy-run__usual"> / {usually(r.typical)}</span> : null}
</span>
</div>
<div class="deploy-run__bar" aria-hidden="true">
{steps.length ? steps.map((s, k) => <i class={`is-${s.state}`} style={`flex-grow:${grow(sizes[k])}`} />) : <i class="is-now" style="flex-grow:1" />}
</div>
{steps.length ? (
<details class="deploy-run__steps">
<summary>
<span class="deploy-run__now" />
</summary>
<ol>
{steps.map((s) => (
<li class={`is-${s.state}`}>
<span aria-hidden="true">{s.state === 'done' ? '✓' : s.state === 'now' ? '●' : '·'}</span>
<span class="deploy-run__name">{s.name}</span>
<span class="deploy-run__took">
{s.state === 'done' && s.seconds != null ? clockOf(s.seconds) : s.state === 'now' ? (s.typical ? `now · ${usually(s.typical)}` : 'now') : s.typical ? usually(s.typical) : ''}
</span>
</li>
))}
</ol>
</details>
) : (
<span class="deploy-run__now" />
)}
<div class="deploy-run__slow" hidden />
</div>
)
}
}
/**
* A deploy's targets: a block for each going now, then one line for those left
* to later and one for those live. Each target says when it is live, not only
* the last: the page waited on the APK to say the web page was out (2026-10-31).
*/
export function deployTargets(targets: Ship['targets']): m.Children {
const runs = runsOf(targets)
const live = targets.filter((t) => t.state === 'live' || t.state === 'skip')
const later = targets.filter((t) => t.state === 'unpicked')
const starting = targets.filter((t) => !live.includes(t) && !later.includes(t) && !runs.has(t.target))
const names = (ts: typeof targets) => ts.map((t) => t.target).join(', ')
return (
<div class="deploy-runs">
{targets.filter((t) => runs.has(t.target)).map((t) => m(RunView, {key: t.target, run: runs.get(t.target)!}))}
{starting.length ? (
<div class="deploy-runs__line">
<Badge tone={starting.some((t) => t.state === 'failed') ? 'danger' : 'info'}>{starting.some((t) => t.state === 'failed') ? 'failed' : 'starting'}</Badge>
{names(starting)}
</div>
) : null}
{later.length ? (
// One no landing picked goes later, once no session is at work: the hub's words say so.
<div class="deploy-runs__line" title={later[0].words}>
<Badge tone="neutral">later</Badge>
<span>
{names(later)}
{later.length === 1 && later[0].words ? <span class="hint"> · {later[0].words}</span> : null}
</span>
</div>
) : null}
{live.length ? (
<div class="deploy-runs__line">
<Badge tone="success">✓ live</Badge>
{names(live)}
</div>
) : null}
</div>
)
}
/** What a deploy waits for or does, as a sheet or Home shows it: its targets while it goes, else in words. */
function deployDetail(d: Deploy): m.Children {
return d.kind === 'deploying' ? deployTargets(d.targets) : <p class="way__words">{deployWords(d)}</p>
}
/** Its gate's step, in words: what `land` said it does, and where. */
function gateWords(j: Journey): m.Children {
const w = j.nodeWait
if (w) {
// Which nodes it may take and who holds each, so a wait has a reason and a name.
const held = (w.held ?? []).map((h) =>
h.offline
? `${h.node} is offline`
: `${h.node} is held by ${h.by ?? 'someone'}${h.since ? ` for ${age(h.since)}` : ''}${h.intent ? ` ("${h.intent}"${h.intent_until ? `, until ${clock(h.intent_until)}` : ''})` : h.purpose ? ` (${h.purpose})` : ''}${h.yielding ? ', giving it over after its build' : ''}`,
)
const place = w.position > 1 ? `#${w.position} in line` : 'next in line'
const which = w.wants === 'any' ? 'a node' : `a ${w.wants} node`
return `The gate waits for ${which}, ${place}${held.length ? `: ${held.join('; ')}` : ''}. Gates go before sessions' own builds, and the holder has been asked to give it over.`
}
return [j.step ? `${j.step.charAt(0).toUpperCase()}${j.step.slice(1)}` : 'Rebasing onto main and running the checks', j.node ? ` on ${j.node}` : '', '. It starts over when main moves meanwhile.']
}
/** The steps across, as the sheet heads them: done, the one it is in, to come. */
function stepper(j: Journey, at: number, bad: boolean): m.Children {
const names = j.shipped ? ['In line', 'Checked', 'On main', 'Deploying', 'Live'] : ['In line', 'Checked', 'On main']
return (
<ol class="way__steps" style={`--n:${names.length}`}>
{names.map((name, i) => {
const mark = i < at ? 'done' : i === at ? (bad ? 'bad' : 'now') : 'todo'
return (
<li class={`is-${mark}`}>
<span class="way__mark" aria-hidden="true">
{mark === 'done' ? '✓' : mark === 'bad' ? '!' : i + 1}
</span>
{name}
</li>
)
})}
</ol>
)
}
/**
* A session's way to live, for the sheet its gauge opens: the gauge and where it
* is, the steps across, and the step it is in said out in full — whose landing
* is ahead, what the gate is doing, each target of the deploy. Under a row in
* the list (`open`), without the steps across, and with what opens the session.
*/
export function wayToLive(s: Hosted, open?: () => void): m.Children {
const j = journeyOf(s)
if (!j) return <p class="hint">It is not on its way to live.</p>
const g = gaugeOf(j)
const d = j.deploy
const sha = j.sha ? <code>{j.sha.slice(0, 8)}</code> : null
const [title, sub]: [string, m.Children] =
j.phase === 'queued'
? [j.position && j.position > 1 ? `#${j.position} in line to land` : 'Next to land', `in line ${age(j.since)}`]
: j.phase === 'gate'
? ['Being checked', `${j.node ? `on ${j.node} · ` : ''}${age(j.since)}`]
: j.phase === 'on_main'
? [
d.kind === 'deploying' ? 'Deploying' : d.kind === 'held' ? 'Deploys held' : d.kind === 'failed' ? 'Deploy failed' : 'On main',
<>on main{sha ? <> as {sha}</> : null}{j.since ? ` since ${clock(j.since)}` : ''}</>,
]
: [j.phase === 'live' ? 'Live' : 'Landed', <>{sha ?? 'on main'}{j.since ? ` · ${clock(j.liveAt ?? j.since)}` : ''}</>]
const detail =
j.phase === 'queued' ? (
<p class="way__words">One landing is checked at a time.{line(s.owner)}</p>
) : j.phase === 'gate' ? (
<p class="way__words">{gateWords(j)}{line(s.owner)}</p>
) : j.phase === 'on_main' && j.shipped ? (
<>
{deployDetail(d)}
{deployActions(d, j.ship)}
</>
) : j.phase === 'live' && !j.finishes ? (
<p class="way__words">It stays open: it landed with "keep working". Reply to go on.</p>
) : null
return (
<div class={`way way--${g.tone}`}>
<div class="way__head">
{open ? null : gauge(j, 40)}
<span class="way__title">
<b>{open ? `${title} · step ${Math.min(5, g.at + 1)} of 5` : title}</b>
<span>{sub}</span>
</span>
{open ? (
<button type="button" class="way__open" onclick={open}>
Open ›
</button>
) : null}
</div>
{open ? null : stepper(j, g.at, g.tone === 'danger')}
{detail}
{!open && j.finishes && j.phase !== 'finished' ? <p class="hint">The session ends by itself once {j.shipped ? 'it is live' : 'its turn is over'}, and moves to Landed on Home.</p> : null}
</div>
)
}
/**
* What happened on its way to live, as short lines in the conversation where
* they happened: on main (unless its finishing already says so), the deploy
* going, live. Each with when, so it sits among the messages by time and
* scrolls away with them; the gauge says where it is now.
*/
export function milestones(s: Hosted, finishing: boolean): {at: number; key: string; view: m.Vnode}[] {
const j = journeyOf(s)
if (!j || j.phase === 'queued' || j.phase === 'gate' || j.phase === 'finished') return []
const out: {at: number; key: string; view: m.Vnode}[] = []
const mile = (key: string, at: number, tone: string, body: m.Children) =>
out.push({at, key, view: <div key={key} class={`msg__mile msg__mile--${tone}`}><span>{body}</span></div>})
if (j.since && !finishing) mile('mile:main', j.since, 'info', <>On main{j.sha ? <> · <code>{j.sha.slice(0, 8)}</code></> : null} · {clock(j.since)}</>)
const d = j.deploy
if (d.kind === 'deploying') {
const runs = [...runsOf(d.targets).values()]
const from = Math.min(...runs.map((r) => startOf(r) ?? Infinity))
if (runs.length && Number.isFinite(from)) mile('mile:deploy', from, 'info', `Deploy started · ${runs.map((r) => r.target).join(', ')} · ${clock(from)}`)
}
if (d.kind === 'failed') mile('mile:failed', now(), 'bad', `Deploy failed · ${d.targets.filter((t) => t.state === 'failed').map((t) => t.target).join(', ')}`)
if (j.phase === 'live') mile('mile:live', j.liveAt ?? now(), 'ok', `Live${j.liveAt ? ` · ${clock(j.liveAt)}` : ''}`)
return out
}
/** A session on Home: what it is called, and what opens it. */
export interface LaneItem {
c: BoardCard
h: Hosted | undefined
j: Journey
}
/** A session's chip on Home: its gauge, its name, then where it is, short; tapped, it opens. */
function chip(it: LaneItem, open: (it: LaneItem) => void): m.Children {
const title = shortName(it.h?.title ?? nameOf(it.c.session).title, 70)
const detail =
it.j.phase === 'queued'
? `${shortWords(it.j)} · ${age(it.j.since)}`
: it.j.phase === 'gate'
? `${it.j.nodeWait ? 'gate waits for a node' : it.j.node ? `checks on ${it.j.node}` : 'checks'} · ${age(it.j.since)}`
: `${it.j.sha ? it.j.sha.slice(0, 8) : 'on main'}${it.j.since ? ` · ${clock(it.j.since)}` : ''}`
return (
<li class="lane__chip" key={it.c.session} onclick={() => open(it)}>
{gauge(it.j, 26)}
<span class="lane__main">
<span class="lane__title">{title}</span>
<span class="lane__meta">
{projectTag(reposOfCard(it.c, it.h))}
{detail}
</span>
{it.j.phase === 'gate' && it.j.step ? <span class="lane__step">{shortName(it.j.step, 60)}</span> : null}
</span>
</li>
)
}
/**
* Home's Landing: what the next deploy carries and does over every session
* from "Land it" to live, one list, the furthest along first; each one's gauge
* says its step, so lanes for the steps only took room (three, mostly empty).
*/
export function landingLane(items: LaneItem[], open: (it: LaneItem) => void): m.Children {
if (!items.length) return null
const rank = (j: Journey) => (j.phase === 'on_main' ? 0 : j.phase === 'gate' ? 1 : 2)
const these = [...items].sort((a, b) => rank(a.j) - rank(b.j) || (a.j.position ?? 99) - (b.j.position ?? 99) || (b.j.since ?? 0) - (a.j.since ?? 0))
// One card per project whose landings wait on main for its deploy.
const ships = [...new Set(items.filter((i) => i.j.phase === 'on_main' && i.j.ship).map((i) => i.j.ship!))]
return (
<section class="home__section">
<h3 class="home__head">
Landing <span class="home__count">{items.length}</span>
</h3>
{ships.map((ship) => {
const d = deployOf(ship, cards())
const carries = items.filter((i) => i.j.ship === ship && i.j.phase === 'on_main').length
return (
<div class="lane__deploy">
<div class="lane__deploy-head">
<b>Next deploy{ships.length > 1 && ship.repo ? ` · ${projectName(ship.repo)}` : ''}</b>
<span class="hint">
{carries} landing{carries === 1 ? '' : 's'}
</span>
</div>
{deployDetail(d)}
{deployActions(d, ship)}
</div>
)
})}
<ul class="lane__list">{these.map((it) => chip(it, open))}</ul>
</section>
)
}
/** What landed today, one line each: live and finished, or on main where that is the end. */
export function landedToday(items: {title: string; repos: string[]; sha: string | null; at: number; live: boolean; how_s: number | null; href: string | null}[]): m.Children {
if (!items.length) return null
return (
<section class="home__section">
<h3 class="home__head">
Landed today <span class="home__count">{items.length}</span>
</h3>
<ul class="landed">
{items.map((it) => (
<li class="landed__row" onclick={() => it.href && go(it.href)}>
<span class="landed__tick" aria-hidden="true">
✓
</span>
<span class="landed__title">{shortName(it.title, 80)}</span>
{projectTag(it.repos)}
{it.sha ? <code class="landed__sha">{it.sha.slice(0, 8)}</code> : null}
<span class="landed__when" title={it.how_s != null ? 'from its first message to live' : undefined}>
{it.live ? 'live' : 'on main'} {clock(it.at)}
{it.how_s != null ? ` · ${span(it.how_s)}` : ''}
</span>
</li>
))}
</ul>
</section>
)
}
/** Landed today, from the sessions midas runs (finished on landing) and the cards of those it does not. */
export function landedItems(inView: (repos: string[]) => boolean) {
const day = now() - 86400
const fromHosted = hosted()
.filter((h) => h.finished?.outcome === 'landed' && h.finished.at > day && inView(reposOf(h)))
.map((h) => {
const at = h.finished!.live_at ?? h.finished!.at
return {owner: h.owner, title: h.title, repos: reposOf(h), sha: h.finished!.sha ?? null, at, live: !!h.finished!.live_at, how_s: at - h.created, href: `sessions/${h.id}`}
})
const seen = new Set(fromHosted.map((x) => x.owner))
const fromCards = cards()
.filter((c) => c.stage === 'landed' && !seen.has(c.session))
.map((c) => ({c, h: hostedOf(c.session), j: journeyOf(hostedOf(c.session), c)}))
// Landed, but waiting on the person for a step only they can take: under Needs you, not done.
.filter(({c, h, j}) => j?.phase === 'live' && !(h && awaitsPerson(h)) && inView(reposOfCard(c, h)))
.map(({c, h, j}) => ({
owner: c.session,
title: h?.title ?? nameOf(c.session).title,
repos: reposOfCard(c, h),
sha: c.sha ?? null,
at: c.since ?? now(),
live: j!.shipped,
how_s: null,
href: h ? `sessions/${h.id}` : null,
}))
return [...fromHosted, ...fromCards].sort((a, b) => b.at - a.at)
}