Skip to content

refactor: generalize spec components to Heading and Button#827

Merged
miurla merged 2 commits intomainfrom
refactor/generalize-spec-components
Apr 15, 2026
Merged

refactor: generalize spec components to Heading and Button#827
miurla merged 2 commits intomainfrom
refactor/generalize-spec-components

Conversation

@miurla
Copy link
Copy Markdown
Owner

@miurla miurla commented Apr 15, 2026

Summary

  • Rename SectionHeader → Heading (more generic, matches h1–h6 semantics).
  • Replace QuestionButton → Button, a generic shadcn-wrapped button with { text, icon?, variant? }. Related-questions now render with variant="link" + icon="arrow-right" to preserve the prior look without baking the follow-up intent into the catalog.
  • Share an iconMap (currently related, arrow-right) between Heading and Button via components/shared.ts.
  • Add a parse-time spec migration layer (lib/render/migrations.ts) so future catalog renames can be handled without breaking persisted chat history. Supports type renames with optional defaultProps merge, transitive chain resolution, and is idempotent. The actual migration map is empty for now — infrastructure only.
  • Update the related-questions prompt and tests to emit Heading + Button.

Breaking change

No backward-compat alias is kept for SectionHeader / QuestionButton. Historical related-questions blocks in the DB will render as nothing (renderer silently skips unknown types). We intentionally did not add migration entries for this rename since related questions are ephemeral suggestions rather than core answer content; the migration infrastructure is in place for future cases.

Test plan

  • bun typecheck / lint / format:check / test (178 passing)
  • Manual: new search → related questions render with Heading + Button variant=link.
  • Manual: old chats load without errors (related questions are absent as expected).

miurla added 2 commits April 15, 2026 18:23
- Rename SectionHeader → Heading; the component was never section-specific,
  and the new name matches common UI vocabulary (h1–h6 semantics).
- Replace the hard-coded QuestionButton with a generic Button that wraps the
  project's shadcn Button and supports:
    { text, icon?, variant?: default|outline|ghost|link|secondary }
  Related-question suggestions now render with variant="link" + icon=
  "arrow-right", preserving the prior muted look without baking the
  follow-up question intent into the catalog.
- Consolidate the icon registry into components/shared.ts so Heading and
  Button share the same `iconMap` (currently: related, arrow-right).
- Update the related-questions prompt and example JSONL to emit Heading +
  Button. Update parse-spec-block and llm-image-output E2E tests to match.

BREAKING: no backward-compat alias is kept for SectionHeader / QuestionButton.
Persisted spec blocks that reference the old type names will have their
individual elements rendered as null by @json-render/react (verified by a
throw-away probe test). For related-questions blocks this means old
suggestions vanish entirely in historical chats — acceptable since they are
ephemeral prompts rather than core answer content, and pairing both renames
in a single break avoids degrading old messages twice.
- Add lib/render/migrations.ts with a pure, idempotent migrateSpec()
  function and an (intentionally empty) typeMigrations map. Entries may
  rename a legacy type and optionally merge defaultProps without
  overriding existing values; chained renames are resolved transitively
  with a cycle guard.
- Apply migrateSpec() in both the partial streaming parser and the
  strict parseSpecBlock path so historical specs can be handled before
  catalog validation.
- Unit tests (7) cover rename, defaultProps merge, idempotency, chain
  resolution, no-op reference preservation, unknown-type passthrough,
  and existing-prop protection. They use a synthetic migration map so
  the infra is validated without committing to any real entries.
- Stop overriding shadcn link variant's hover underline on the Button
  spec component — keep the default underline behaviour.
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 15, 2026

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

Project Deployment Actions Updated (UTC)
morphic Ready Ready Preview, Comment Apr 15, 2026 10:11am

@miurla miurla merged commit 0905c5c into main Apr 15, 2026
8 checks passed
@miurla miurla deleted the refactor/generalize-spec-components branch April 15, 2026 10:16
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