feat: add prompt comparison feature #704
Merged
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.
PR Checklist
Description
This PR adds a prompt comparison feature to the prompt preset interface. Now, users can compare two different prompts to identify differences.
How to Use
Diff Display Details
Implementation Details
handleDiffMode
manages prompt selection and clearing.checkDiff
compares prompts and useshighlightChanges
to mark differences.escapeHtml
to ensure the text is displayed as-is.resultHtml
is rendered viaalertMd
.Notes
jsdiff
library to compare prompts efficiently.alertMd
appears to sanitize potentially dangerous content. However, additional escaping is applied to ensure that the text is displayed as-is.botpreset.svelte
grew significantly due to this feature; modularization was considered but not implemented.If this feature, its implementation, or any other issue doesn't fit the project's vision, feel free to reject this PR! Thank you for reviewing!