-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: add spell checking to prompt input area #8279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Implement useSpellCheck hook for spell checking functionality - Add SpellCheckSuggestions component for displaying corrections - Integrate spell checking into ChatTextArea component - Add wavy underline styles for misspelled words - Include comprehensive test suite for spell checking - Addresses issue #8275
- Changed from error-red to info-blue as specified in requirements - Uses --vscode-editorInfo-foreground for consistency with VSCode theme
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Self-review: Peering into my own diff like Schrödinger’s linter—both passing and failing until CI collapses the waveform.
Critical/High
- Click handling blocked: highlight overlay has pointer-events: none while onClick is attached to it; misspelling spans can’t be clicked to open suggestions.
- Suggestion menu misaligned: using viewport rects with an absolutely positioned menu relative to a container leads to offset errors in nested/scrolling layouts.
- Underline index drift: misspelling ranges are computed on raw text but markup for mentions/commands is injected first; indices shift and the wrong substrings can be wrapped.
Medium
- TS test-global guard: typeof vi !== 'undefined' in production code will error; use typeof (globalThis as any).vi !== 'undefined' or add an ambient declaration excluded from prod builds.
- Dictionary casing: key 'Febuary' is capitalized but lookups use toLowerCase(); change to 'febuary'.
- Timer typing: prefer ReturnType instead of NodeJS.Timeout in web code.
- i18n: SpellCheckSuggestions hardcodes strings ('Ignore', 'Add to dictionary', 'No suggestions available'); use translation keys.
Low
- Double overlay updates: updateHighlights is called in onChange and via useLayoutEffect; remove one to avoid duplicate innerHTML writes.
- JSDoc mismatch: hook mentions native spell check API; current implementation uses a local dictionary—clarify to avoid confusion.
- Consider adding integration tests for overlay alignment and suggestion click behavior.
References (file:line hints)
- webview-ui/src/components/chat/ChatTextArea.tsx: highlight layer pointer-events and onClick near ~1090–1120; menu positioning using getBoundingClientRect near ~960–975; index drift where processedText is mutated before spell highlights ~755–798; duplicate updateHighlights call ~1130.
- webview-ui/src/components/chat/SpellCheckSuggestions.tsx: i18n strings ~105 and ~141.
- webview-ui/src/hooks/useSpellCheck.ts: vi guard ~30; timer typing ~23; dictionary casing ~71.
Suggested fixes
- Make misspelled spans clickable by either: (a) rendering spell spans in a sibling overlay with pointer-events: auto; or (b) allowing pointer events only on .spell-check-underline and ensuring no ancestor blocks them; or (c) compute suggestions from caret position instead of overlay.
- Use position: fixed for the suggestions menu (with viewport rects) or compute offsets relative to the positioned ancestor.
- Generate the overlay from the original text by merging ranges (mentions, commands, misspellings) in a single pass to prevent index drift.
- Apply the TS/type/i18n adjustments noted above.
|
why not use the project build in |
|
Closing, it would be best to use a third party tool for this. |
This PR addresses Issue #8275 by adding spell checking functionality to the prompt input area.
Changes
useSpellCheckhook for spell checking functionalitySpellCheckSuggestionscomponent for displaying correction suggestionsChatTextAreacomponentImplementation Details
This is a proof-of-concept implementation that demonstrates the spell checking UI/UX. Currently, it uses a limited dictionary of ~50 common misspellings for demonstration purposes.
Current Features
Known Limitations
Future Enhancements
For production use, this could be enhanced with:
Testing
All tests pass successfully:
useSpellCheckhookScreenshots
The implementation provides blue wavy underlines for misspelled words and a context menu with suggestions, similar to IDE editors.
Closes #8275
Important
Adds spell checking to the prompt input area with real-time checking, suggestions, and comprehensive testing.
useSpellCheckhook for spell checking inuseSpellCheck.ts.ChatTextAreawith real-time checking and blue wavy underlines.SpellCheckSuggestionscomponent for displaying suggestions.index.css.useSpellCheckinuseSpellCheck.spec.tscovering initialization, detection, debouncing, and cleanup.This description was created by
for 8ebc17d. You can customize this summary. It will automatically update as commits are pushed.