Captain UI

Transcript

A chat thread where the agent's work is drawn: plans you edit, live swarms, diffs, previews and tests.

npx shadcn@latest add https://captain-transcript.vercel.app/r/captain-transcript.json

Add passkeys to sign-in. Keep passwords as a fallback, and don’t break the mobile app.

Captain

Six pieces of work for 14 agents. Password stays as the fallback, and the iOS deep link gets its own tests from the first minute. Change anything below, then approve.

  1. Check passkey support on Safari, Chrome and AndroidResearch×2
  2. Threat-model the sign-in flowSecurity
  3. WebAuthn register and verify routesBuild×3
  4. Passkey button first, password behind itDesign×2
  5. Tests for every path, the mobile deep link tooTests×4
  6. Review it all, then open one PRReview×2
  • src
  • auth
  • db
  • app/(auth)/sign-in
  • tests/auth
src/auth/passkey.tsadded +86
addedimport { generateAuthenticationOptions, verifyAuthenticationResponse } from '@simplewebauthn/server';
addedimport { db } from '../db';
addedimport { createSession } from './session';
added
addedconst rpID = process.env.RP_ID ?? 'northwind.dev';
added
addedexport async function options(email: string) {
added const user = await db.user.findUnique({ where: { email }, include: { passkeys: true } });
added return generateAuthenticationOptions({
added rpID,
added userVerification: 'preferred',
added allowCredentials: user?.passkeys.map(k => ({ id: k.credentialId, transports: k.transports })) ?? [],
added });
added}
added
addedexport async function verify(email: string, response: AuthenticationResponseJSON, challenge: string) {
added const key = await db.passkey.findFirstOrThrow({ where: { credentialId: response.id } });
added const { verified, authenticationInfo } = await verifyAuthenticationResponse({
added response, expectedChallenge: challenge, expectedOrigin: `https://${rpID}`, expectedRPID: rpID,
added credential: { id: key.credentialId, publicKey: key.publicKey, counter: key.counter },
added });
added if (!verified) throw new Error('passkey did not verify');
added await db.passkey.update({ where: { id: key.id }, data: { counter: authenticationInfo.newCounter } });
added return createSession(key.userId);
added}
  • src
  • auth
  • passkey.tsadded +86
  • routes.tsadded +24removed −6
  • db
  • schema.tsadded +12
  • app/(auth)/sign-in
  • page.tsxadded +52removed −31
  • tests/auth
  • passkey.test.tsadded +64
pnpm vitest run tests/auth --reporter=dot
 ↓ tests/auth/legacy-sso.test.ts (3 skipped)  Test Files  6 passed | 1 skipped (7)      Tests  140 passed | 3 skipped (143)   Duration  6.41s
exit 06s
northwind.dev/sign-in
140passed3 skipped · 6s
research-01WebAuthn spec 0:02 to 0:38
security-01Threat model 0:04 to 1:01
build-01passkey.ts 0:40 to 1:44, Return 401 2:30 to 2:46
design-01Sign-in screen 0:42 to 2:01, Waited on you 2:01 to 2:19
tests-02Deep link 1:04 to 1:32, Failed 1:32 to 1:41, Retried, passed 1:41 to 2:13
review-01Review 2:14 to 2:56
design-01Behind a link(picked)
<PasskeyButton />
<TextButton>Use your password instead</TextButton>
build-02Beside the passkey
<PasskeyButton />
<PasswordForm compact />
Where does the password field go?
Who gets passkeys first?
$3.84of $20.001.9M tokens · 14 agents
  • Build$1.42
  • Tests$0.86
  • Design$0.58
  • Review$0.41
  • Research$0.34
  • Security$0.23
emailchallengesignedYouSign-in pagepasskey/optionsThis devicepasskey/verifySession?next or /home
Worked for 3m 12s · 14 agents · $3.84

Usage

import { CaptainTranscript } from "@/components/captain-transcript"

<div style={{ height: 600 }}>
  <CaptainTranscript messages={messages} onAction={(e) => captain.act(e)} />
</div>

Props

PropTypeDefaultWhat it does
messagesMessage[]The thread, controlled.
defaultMessagesMessage[]Uncontrolled start.
onAction(e) => voidApprove, answer, pick, accept, run, ship.

Keyboard

J / K
Next and previous turn
End
Jump to latest

Accessibility

  • A log with an announcer for new turns.
  • Virtualised to 100k messages.
  • axe 0 violations in CI.