// screens-2.jsx — Test Request, Logs, Setup screens const { useState: useState2, useEffect: useEffect2, useRef: useRef2, useMemo: useMemo2 } = React; // ─────────────────────────── TEST REQUEST ─────────────────────────── const SAMPLE_RESPONSE = `Here's a small Go function that reads ~/.codex/auth.json and returns the access token. It tolerates the file being missing (returns ErrAuthMissing) and validates that the mode is "chatgpt" before yielding a token. func loadCodexAuth(path string) (string, error) { f, err := os.Open(path) if err != nil { if errors.Is(err, os.ErrNotExist) { return "", ErrAuthMissing } return "", err } defer f.Close() var a struct { Mode string \`json:"mode"\` Token string \`json:"access_token"\` Exp int64 \`json:"expires_at"\` } if err := json.NewDecoder(f).Decode(&a); err != nil { return "", fmt.Errorf("parse auth: %w", err) } if a.Mode != "chatgpt" { return "", fmt.Errorf("unsupported auth mode %q", a.Mode) } return a.Token, nil } Want me to add a refresh-on-expiry path next?`; const TestRequest = () => { const [model, setModel] = useState2("gpt-5.3-codex"); const [stream, setStream] = useState2(true); const [prompt, setPrompt] = useState2("Read ~/.codex/auth.json in Go and return the access token. Handle missing file and wrong auth mode."); const [phase, setPhase] = useState2("idle"); // idle | sending | streaming | done | error const [output, setOutput] = useState2(""); const [duration, setDuration] = useState2(0); const [showRaw, setShowRaw] = useState2(false); const [rawResponse, setRawResponse] = useState2(null); const cancelRef = useRef2(null); const reqJson = { model, max_tokens: 1024, stream, messages: [{ role: "user", content: prompt }], }; const respJson = rawResponse || { id: "msg_01HQPX9F3YK7N2TJ8B4ZRW3DCM", type: "message", role: "assistant", model, stop_reason: "end_turn", usage: { input_tokens: 142, output_tokens: 318, total_tokens: 460 }, proxy: { forwarded_to: "gpt-5.3-codex", upstream: "codex", duration_ms: duration || 1842, }, content: [{ type: "text", text: phase === "done" ? SAMPLE_RESPONSE.slice(0, 80) + "…" : "" }], }; const send = async () => { if (phase === "sending" || phase === "streaming") return; setOutput(""); setRawResponse(null); setPhase("sending"); const start = Date.now(); try { if (stream) setPhase("streaming"); const res = await api.post("/ui/api/test", { model, prompt, stream }); setDuration(res.duration_ms || (Date.now() - start)); setOutput(res.text || res.raw || ""); setRawResponse(res); setPhase(res.status >= 200 && res.status < 300 ? "done" : "error"); } catch (e) { setOutput(e.message || String(e)); setDuration(Date.now() - start); setPhase("error"); } }; const cancel = () => { clearTimeout(cancelRef.current); setPhase("idle"); setOutput(""); }; useEffect2(() => () => clearTimeout(cancelRef.current), []); return (
Model
Stream
setStream(s => !s)} onKeyDown={(e) => e.key === " " && setStream(s => !s)}/> {stream ? "on · SSE" : "off"}
Prompt