refactor: generalize spec components to Heading and Button#827
Merged
Conversation
- 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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
{ text, icon?, variant? }. Related-questions now render withvariant="link"+icon="arrow-right"to preserve the prior look without baking the follow-up intent into the catalog.iconMap(currentlyrelated,arrow-right) between Heading and Button viacomponents/shared.ts.lib/render/migrations.ts) so future catalog renames can be handled without breaking persisted chat history. Supports type renames with optionaldefaultPropsmerge, transitive chain resolution, and is idempotent. The actual migration map is empty for now — infrastructure only.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)