Skip to content

refactor: simplify codebase — dedup agent core, harden edge cases#6

Merged
BaruchEric merged 1 commit into
mainfrom
claude/condescending-knuth-6d58f3
Apr 23, 2026
Merged

refactor: simplify codebase — dedup agent core, harden edge cases#6
BaruchEric merged 1 commit into
mainfrom
claude/condescending-knuth-6d58f3

Conversation

@BaruchEric
Copy link
Copy Markdown
Owner

  • Extract shared agent core (api/agent-core.ts) from playground/server.ts and api/agent.ts; trims ~400 lines of duplication across system prompt, SSE encoding, streamText loop, and request body parsing.
  • Consolidate DEFAULT_MODEL to a single source (api/model.ts); re-export from playground/settings.ts; drop drifted copies in api/health.ts and playground/server.ts.
  • Middleware fails closed in production when BASIC_AUTH_PASS is unset; logs on cold start when disabled.
  • Bound SSE parse buffer at 1 MB to prevent memory growth from a misbehaving server.
  • Fix wireResizers early-return leak (moved !first/!second guard before setPointerCapture + body class mutations).
  • Persist custom model input on blur/Enter instead of per keystroke.
  • Replace inline URL regex with safe-url#isExternal; adds protocol checking via URL parse instead of string prefix.
  • Extract appendChildren helper (card/stack/row/grid); CSS.escape form field name in querySelector; tighten numeric validation to HTML input[type=number] semantics.
  • design-to-css: export generate() so tests call it in-process instead of spawning bun subprocesses; switch TOKEN_GROUPS allow-list to a deny-list so new DESIGN.md sections aren't silently dropped.
  • build-styles: mkdir dist/ before write; parallelize reads.
  • lint-design: balanced-brace JSON extractor replaces fragile lastIndexOf('\n{') heuristic.
  • settings-ui: generic toggleGroup helper unifies theme/layout button groups; .settings-hide-ai-row CSS class replaces inline styles.
  • playground: single WELCOME_SPEC, unified appendLine helper, tidied isFieldChange narrowing.

- Extract shared agent core (api/agent-core.ts) from playground/server.ts
  and api/agent.ts; trims ~400 lines of duplication across system prompt,
  SSE encoding, streamText loop, and request body parsing.
- Consolidate DEFAULT_MODEL to a single source (api/model.ts); re-export
  from playground/settings.ts; drop drifted copies in api/health.ts and
  playground/server.ts.
- Middleware fails closed in production when BASIC_AUTH_PASS is unset;
  logs on cold start when disabled.
- Bound SSE parse buffer at 1 MB to prevent memory growth from a
  misbehaving server.
- Fix wireResizers early-return leak (moved !first/!second guard before
  setPointerCapture + body class mutations).
- Persist custom model input on blur/Enter instead of per keystroke.
- Replace inline URL regex with safe-url#isExternal; adds protocol
  checking via URL parse instead of string prefix.
- Extract appendChildren helper (card/stack/row/grid); CSS.escape form
  field name in querySelector; tighten numeric validation to HTML
  input[type=number] semantics.
- design-to-css: export generate() so tests call it in-process instead
  of spawning bun subprocesses; switch TOKEN_GROUPS allow-list to a
  deny-list so new DESIGN.md sections aren't silently dropped.
- build-styles: mkdir dist/ before write; parallelize reads.
- lint-design: balanced-brace JSON extractor replaces fragile
  lastIndexOf('\n{') heuristic.
- settings-ui: generic toggleGroup<T> helper unifies theme/layout
  button groups; .settings-hide-ai-row CSS class replaces inline styles.
- playground: single WELCOME_SPEC, unified appendLine helper, tidied
  isFieldChange narrowing.
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
stream-ui Ready Ready Preview, Comment Apr 23, 2026 4:22am

Request Review

@BaruchEric BaruchEric merged commit 13dabe8 into main Apr 23, 2026
3 checks passed
@BaruchEric BaruchEric deleted the claude/condescending-knuth-6d58f3 branch April 23, 2026 04:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant