← Public packages
@kentcdodds/closing-the-agentic-loop
Closing the Agentic Loop: Kent C. Dodds's talk and workshop deck. Default short talk; ?event=aie-2026 is the AIE hour cut with a Podium QR; ?format=full adds labs.
Files
// Reveal.js setup, matching the kody.codes Reveal deck (PSE) config, plus theme handling and the
// editable timers. ?static turns transitions off; ?linear uses linear navigation; ?theme=light|dark
// forces a theme.
const params = new URLSearchParams(window.location.search)
const root = document.documentElement
const forcedTheme = params.get('theme')
const colorScheme = window.matchMedia('(prefers-color-scheme: light)')
const THEME_KEY = 'ato-deck-theme'
const savedTheme = () => {
try {
const value = localStorage.getItem(THEME_KEY)
return value === 'light' || value === 'dark' ? value : null
} catch {
return null
}
}
const applyTheme = () => {
if (forcedTheme === 'light' || forcedTheme === 'dark') {
root.dataset.theme = forcedTheme
return
}
root.dataset.theme = savedTheme() ?? (colorScheme.matches ? 'light' : 'dark')
}
applyTheme()
colorScheme.addEventListener('change', applyTheme)
// T toggles light/dark (Reveal doesn't use T). Pressing it again after returning to the system
// theme's value clears the override, so the deck follows the system again.
const toggleTheme = () => {
const next = root.dataset.theme === 'light' ? 'dark' : 'light'
const system = colorScheme.matches ? 'light' : 'dark'
try {
if (next === system) localStorage.removeItem(THEME_KEY)
else localStorage.setItem(THEME_KEY, next)
} catch {}
root.dataset.theme = next
}
// Removed slides: old deep links land on the slide that now carries their content.
const movedIds = { 'deploy-guard': 'health-checks', 'backup-score': 'ladder', 'backup-mediarss': 'ladder', 'feature-map': 'primitives' }
const hashId = window.location.hash.replace(/^#\/?/, '')
if (movedIds[hashId]) history.replaceState(null, '', `${window.location.pathname}${window.location.search}#/${movedIds[hashId]}`)
// One deck, three formats, plus optional events. The default is the short talk. ?format=full
// adds the full-day workshop slides (labs). ?event=<slug> (data/events.json) selects that
// event's format, title, and Podium QR. ?format=hour is an alias for ?event=aie-2026 (the
// one-hour AIE Code Summit cut). A slide with data-format="full" shows only in full-day mode,
// data-format="short" in the default and the hour, and data-format="hour" only in the hour.
// Slides are removed before Reveal starts, so numbering and the overview match.
// The hour is the short talk minus HOUR_HIDE, plus its two hour-only slides, with Your turn
// moved before the final slide and the notes in data/hour.json (a session with no live
// autopilot run). Event-specific title, Podium URL and notes come from data/events.json.
// The FAQ stays after the final slide, so it opens by link or #/faq-... outside the main flow.
const HOUR_HIDE = [
// Detours and Kody internals
'lineage', 'kody-what', 'agents-md', 'friction-checks', 'doors', 'control-kody', 'pr-3765', 'rollback', 'credentials', 'codebase-cleanup', 'kody-mcp',
// Autopilot demo, live or recorded (the hour-only autopilot-what slide explains it; Your turn is the exercise)
'run-autopilot',
// Mid-talk Q&A stops and the break (Q&A is at the end)
'qa-1', 'qa-2', 'break', 'qa-3',
// Flags and backups: the hour-only deploy-hour slide combines them
'flags', 'backups',
]
const events = JSON.parse(document.getElementById('events-data').textContent)
const requestedEvent = params.get('event')
const requestedFormat = params.get('format')
const eventFromAlias = !requestedEvent && requestedFormat
? Object.keys(events).find((slug) => (events[slug].aliases ?? []).includes(requestedFormat))
: null
if (requestedEvent && !events[requestedEvent]) console.error(`unknown event: ${JSON.stringify(requestedEvent)}`)
const eventSlug = events[requestedEvent] ? requestedEvent : eventFromAlias
const event = eventSlug ? events[eventSlug] : null
const format = event?.format === 'full' || event?.format === 'hour' || event?.format === 'short'
? event.format
: requestedFormat === 'full' ? 'full' : requestedFormat === 'hour' ? 'hour' : 'short'
root.dataset.format = format
if (eventSlug) root.dataset.event = eventSlug
const shows = { short: ['short'], full: ['full'], hour: ['short', 'hour'] }[format]
for (const s of document.querySelectorAll('.reveal .slides section[data-format]')) if (!shows.includes(s.dataset.format)) s.remove()
const slide = (id) => document.querySelector(`.reveal .slides section#${CSS.escape(id)}`)
const applyNotes = (editsById, label) => {
for (const [id, edits] of Object.entries(editsById ?? {})) {
const paras = [...(slide(id)?.querySelectorAll('aside.notes > p') ?? [])]
for (const { starts, text } of edits) {
const hits = paras.filter((p) => p.textContent.trim().startsWith(starts))
if (hits.length !== 1) {
console.error(`${label} notes: ${id} has ${hits.length} paragraphs starting ${JSON.stringify(starts)}`)
continue
}
if (text === null) hits[0].remove()
else hits[0].textContent = text
}
}
}
if (format === 'hour') {
const hour = JSON.parse(document.getElementById('hour-data').textContent)
for (const id of HOUR_HIDE) slide(id)?.remove()
for (const [id, before] of Object.entries(hour.moveBefore ?? {})) slide(before).before(slide(id))
applyNotes(hour.notes, 'hour')
}
if (event) {
document.title = event.pageTitle
slide('title').querySelector('.event').textContent = event.title
const podium = slide('title').querySelector('.event-podium')
const link = podium.querySelector('a')
const img = podium.querySelector('img')
link.href = event.podiumUrl
img.src = event.qrDataUri
img.alt = `QR code for ${event.displayUrl}`
podium.querySelector('.qrl').textContent = event.displayUrl
podium.classList.add('is-on')
applyNotes(event.notes, 'event')
const qr = document.createElement('a')
qr.className = 'event-qr'
qr.href = event.podiumUrl
qr.target = '_blank'
qr.rel = 'noopener'
const urlLabel = event.displayUrl.replace(/(\.run\/)/, '$1\n')
qr.innerHTML = `<span class="event-qr-card"><img src="${event.qrDataUri}" alt="QR code for ${event.displayUrl}"></span><span class="event-qr-url">${urlLabel}</span>`
document.body.append(qr)
const placeEventQr = () => {
const current = deck.getCurrentSlide?.() ?? document.querySelector('.reveal .slides section.present')
const hide = !current || current.querySelector('.event-podium.is-on')
qr.hidden = !!hide
for (const s of document.querySelectorAll('.reveal .slides section.event-qr-on')) s.classList.remove('event-qr-on')
if (hide) return
current.classList.add('event-qr-on')
const box = current.getBoundingClientRect()
const scale = box.width / 1920
const inset = 28 * scale
qr.style.position = 'fixed'
qr.style.left = 'auto'
qr.style.top = 'auto'
qr.style.right = `${Math.max(0, window.innerWidth - box.right) + inset}px`
qr.style.bottom = `${Math.max(0, window.innerHeight - box.bottom) + inset}px`
qr.style.transform = `scale(${scale})`
qr.style.transformOrigin = 'bottom right'
}
window.__placeEventQr = placeEventQr
window.addEventListener('resize', placeEventQr)
}
const staticDeck = params.has('static')
if (staticDeck) root.dataset.static = ''
const deck = new Reveal({
hash: true,
// PSE sets hashOneBasedIndex: true. Every slide here has an id (the hash is #/<id>), and with
// that option on, Reveal's speaker view opens one slide behind, so it's left off.
controls: false,
controlsTutorial: true,
controlsLayout: 'bottom-right',
controlsBackArrows: 'faded',
progress: true,
slideNumber: 'c/t',
// PSE uses 1280x720; this deck's slides are laid out on a 1920x1080 canvas (same 16:9).
width: 1920,
height: 1080,
margin: 0,
minScale: 0.2,
maxScale: 2,
display: 'flex',
center: false,
transition: staticDeck ? 'none' : 'slide',
transitionSpeed: 'slow',
backgroundTransition: 'none',
viewDistance: 10,
mobileViewDistance: 10,
navigationMode: params.has('linear') ? 'linear' : 'default',
plugins: [RevealNotes],
})
// Timers: <input data-countdown="8"> counts down from its own default (minutes) each time its slide
// is shown. Click or focus it to edit: type mm:ss, m:ss or plain minutes, Enter restarts from that
// time, Escape or blur without Enter cancels, and an invalid value is flagged and changes nothing.
// While editing, keys stay in the input, so Reveal shortcuts (S, T, F, arrows...) don't fire.
const fmt = (s) => `${Math.floor(s / 60)}:${String(s % 60).padStart(2, '0')}`
const parseTime = (text) => {
const t = text.trim()
let m = /^(\d{1,3}):([0-5]\d)$/.exec(t)
const total = m ? Number(m[1]) * 60 + Number(m[2]) : (m = /^(\d{1,3})$/.exec(t)) ? Number(m[1]) * 60 : NaN
return total > 0 ? total : null
}
let tick
let active = null // { el, end }
// Lab timers (data-countdown-keep) keep running while you visit other slides: showing the slide
// again resumes the same countdown instead of restarting it. The end time is kept per slide for
// this tab (sessionStorage), so a reload resumes too. A timer that ran out more than 15 minutes
// ago starts over. Editing the timer (Enter) sets a new end time as usual.
const keepKey = (el) => `deck-timer:${el.closest('section')?.id}`
const keptEnd = (el) => {
if (!el.hasAttribute('data-countdown-keep')) return null
try {
const end = Number(sessionStorage.getItem(keepKey(el)))
return end && end > Date.now() - 15 * 60 * 1000 ? end : null
} catch {
return null
}
}
const keepEnd = (el, end) => {
if (!el.hasAttribute('data-countdown-keep')) return
try {
sessionStorage.setItem(keepKey(el), String(end))
} catch {}
}
const left = () => (active ? Math.ceil(Math.max(0, active.end - Date.now()) / 1000) : 0)
const draw = () => {
if (!active) return
const s = left()
if (!active.el.matches('.editing')) active.el.value = fmt(s)
active.el.dataset.remaining = String(s)
if (!s) clearInterval(tick)
}
const runUntil = (el, end) => {
clearInterval(tick)
active = { el, end }
draw()
tick = setInterval(draw, 250)
}
const runTimer = (el, seconds) => {
const end = Date.now() + seconds * 1000
keepEnd(el, end)
runUntil(el, end)
}
const startCountdown = (slide) => {
clearInterval(tick)
active = null
const el = slide?.querySelector('[data-countdown]')
if (!el) return
const end = keptEnd(el)
if (end) runUntil(el, end)
else runTimer(el, Math.round(Number(el.dataset.countdown) * 60))
}
const stopEditing = (el) => {
el.classList.remove('editing', 'invalid')
el.removeAttribute('aria-invalid')
el.value = active?.el === el ? fmt(left()) : fmt(Math.round(Number(el.dataset.countdown) * 60))
}
for (const el of document.querySelectorAll('[data-countdown]')) {
el.addEventListener('focus', () => {
el.classList.add('editing')
el.select()
})
el.addEventListener('input', () => {
el.classList.remove('invalid')
el.removeAttribute('aria-invalid')
})
for (const type of ['keydown', 'keypress', 'keyup']) el.addEventListener(type, (event) => event.stopPropagation())
el.addEventListener('keydown', (event) => {
if (event.key === 'Escape') {
event.preventDefault()
el.blur() // blur cancels
} else if (event.key === 'Enter') {
event.preventDefault()
const seconds = parseTime(el.value)
if (seconds === null) {
el.classList.add('invalid')
el.setAttribute('aria-invalid', 'true')
return
}
el.classList.remove('editing', 'invalid')
el.removeAttribute('aria-invalid')
runTimer(el, seconds)
el.blur()
}
})
el.addEventListener('blur', () => stopEditing(el))
}
deck.addKeyBinding({ keyCode: 84, key: 'T', description: 'Toggle light / dark theme' }, toggleTheme)
// Below 435px wide (a phone in portrait) Reveal switches to its scroll view, which starts at the
// first slide and overwrites the hash. Scroll straight to the requested slide's page instead.
const requestedSlide = decodeURIComponent(window.location.hash.replace(/^#\/?/, '').split('/')[0])
function scrollToSlidePage(target) {
const page = target.closest('.scroll-page')
const viewport = document.querySelector('.reveal-viewport')
if (page && viewport) viewport.scrollTop = page.offsetTop
}
function settleOn(id) {
if (!deck.isScrollView?.() || !id || /^\d/.test(id)) return
const target = document.getElementById(id)
if (target?.closest('.reveal .slides') && target !== deck.getCurrentSlide()) scrollToSlidePage(target)
}
deck.on('ready', (event) => {
window.__kodyDeck = deck
startCountdown(event.currentSlide)
window.__placeEventQr?.()
setTimeout(() => settleOn(requestedSlide))
window.addEventListener('hashchange', () => {
if (!deck.isScrollView?.()) return
const id = decodeURIComponent(window.location.hash.replace(/^#\/?/, '').split('/')[0])
setTimeout(() => settleOn(id), 60)
})
})
deck.on('slidechanged', (event) => {
startCountdown(event.currentSlide)
window.__placeEventQr?.()
// The scroll view leaves the hash on the first slide; keep it on the slide being read so reloads and shares land there.
const id = event.currentSlide?.id
if (deck.isScrollView?.() && id && window.location.hash !== `#/${id}`) history.replaceState(null, '', `#/${id}`)
})
deck.on('resize', () => window.__placeEventQr?.())
deck.initialize()
window.__deck = deck