// PRModal.jsx — the §10.2 PR creation modal. // // Opens from the §10.1 "Open PR" affordance on a branch view. The // modal fetches an AI-drafted title and description on open via the // /pr-draft endpoint, prefills both fields, lets the contributor edit // before submit. When the source branch is private, surfaces the // §11.3 universal-public confirmation inline above the form rather // than as a separate dialog — the confirmation is part of this // surface per §10.1. import { useEffect, useState } from 'react' import { draftPRText, openPR } from '../api' import { EVENTS, track } from '../lib/analytics' export default function PRModal({ slug, branch, branchIsPrivate, onClose, onOpened }) { const [title, setTitle] = useState('') const [description, setDescription] = useState('') // #26: optional ground-truth use case for this change. const [useCase, setUseCase] = useState('') const [drafting, setDrafting] = useState(true) const [submitting, setSubmitting] = useState(false) const [confirmed, setConfirmed] = useState(!branchIsPrivate) const [error, setError] = useState(null) useEffect(() => { let cancelled = false draftPRText(slug, branch) .then(d => { if (cancelled) return setTitle(d.title || '') setDescription(d.description || '') }) .catch(err => { if (!cancelled) setError(err.message) }) .finally(() => { if (!cancelled) setDrafting(false) }) return () => { cancelled = true } }, [slug, branch]) const canSubmit = !!title.trim() && !drafting && !submitting && confirmed const submit = async () => { setSubmitting(true) setError(null) try { const { pr_number } = await openPR(slug, branch, { title: title.trim(), description: description.trim(), proposedUseCase: useCase.trim() || null, }) // v0.15.0 — analytics: fire on §10.2 PR-open success. slug // and pr_number are the join keys; title/description stay out. track(EVENTS.PR_OPENED, { rfc_slug: slug, pr_number }) onOpened?.(pr_number) } catch (e) { setError(e.message) setSubmitting(false) } } return (
This branch is currently private. Per §11.3, opening a PR makes the branch and its history publicly readable. There is no notion of a private PR.
§10.2: a one-line structural description in spec voice. What was edited, in what way. AI-drafted; edit before submit.