{{ message }}
refactor(frontend): extract placeholder detection utility with unit tests (follow-up to #3764)#3783
Open
MeloMei wants to merge 4 commits into
Open
refactor(frontend): extract placeholder detection utility with unit tests (follow-up to #3764)#3783MeloMei wants to merge 4 commits into
MeloMei wants to merge 4 commits into
Conversation
|
|
Collaborator
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.

Follow-up to #3764.
Summary
findSuggestionTemplatePlaceholder()function andSUGGESTION_TEMPLATE_PLACEHOLDER_PATTERNconstant frominput-box.tsxinto a standalonecore/suggestions/placeholders.tsmodulefindSuggestionTemplatePlaceholderrange detection + 2 forhasUnreplacedPlaceholderboolean wrapper)SuggestionList's rawtextareaRefprop with anonSelectPlaceholdercallback for better component decouplingtoast.errortotoast.warningfor placeholder validation (amber vs red — it's a validation hint, not an error)Why
#3764 introduced an inline
findSuggestionTemplatePlaceholderat the top ofinput-box.tsx. This works fine, but:core/suggestions/makes it independently unit-testable and reusable.textareaRef— this couples the child to the parent's DOM ref type and leaks implementation details. A callback prop (onSelectPlaceholder) inverts control properly: the child signals intent, the parent decides how.toast.erroroverstates severity — an unfilled placeholder is a validation hint (user needs to act), not a system error.toast.warningcommunicates this better.Changes
frontend/src/core/suggestions/placeholders.tsfindSuggestionTemplatePlaceholderandhasUnreplacedPlaceholderfrontend/src/components/workspace/input-box.tsxtoast.warningfrontend/tests/unit/core/suggestions/placeholders.test.tsTest Plan
tsc --noEmit— no errorseslint— no new errors