Writing assistant v2 - #487
Conversation
There was a problem hiding this comment.
PR Summary
Added AI-powered text editing capabilities and document statistics while removing the backlink suggestions system.
- New
AIEdit.tsxcomponent sends raw text to/api/generateendpoint without content validation or sanitization, potential security concern - Missing error handling and loading states in AI editing operations in
AIEdit.tsx - Event listener cleanup missing in
DocumentStats.tsxuseEffect hook, potential memory leak - Empty
onEditcallback inEditorManager.tsxfor AI edit menu makes feature non-functional Continue writingbutton in AI menu lacks implementation
4 file(s) reviewed, 7 comment(s)
Edit PR Review Bot Settings | Greptile
| const handleAction = async (action: string) => { | ||
| const prompt = `${action} the following text: ${selectedText}` | ||
| const completion = await complete(prompt) | ||
| if (completion) { | ||
| onEdit(completion) | ||
| } | ||
| } |
There was a problem hiding this comment.
logic: no error handling for failed API calls or rate limits. Add try/catch and show error state to user
|
|
||
| const handleAction = async (action: string) => { | ||
| const prompt = `${action} the following text: ${selectedText}` | ||
| const completion = await complete(prompt) |
There was a problem hiding this comment.
logic: missing loading state while waiting for completion. User has no feedback during API call
| <Button variant="ghost" className="w-full justify-start text-gray-300 hover:bg-gray-800"> | ||
| <Play className="mr-2 size-5 text-purple-500" /> | ||
| Continue writing | ||
| </Button> |
There was a problem hiding this comment.
logic: 'Continue writing' button has no onClick handler - appears to be non-functional
| useEffect(() => { | ||
| const initDocumentStats = async () => { | ||
| const showStats = await window.electronStore.getDocumentStats() | ||
| setShow(showStats) | ||
| } | ||
|
|
||
| initDocumentStats() | ||
|
|
||
| const handleDocStatsChange = (event: Electron.IpcRendererEvent, value: boolean) => { | ||
| setShow(value) | ||
| } | ||
|
|
||
| window.ipcRenderer.on('show-doc-stats-changed', handleDocStatsChange) | ||
| }, []) |
There was a problem hiding this comment.
logic: missing cleanup function to remove IPC event listener on unmount
| }} | ||
| > | ||
| {showAIPopup ? ( | ||
| <AiEditMenu selectedText={editor.getText()} onEdit={() => {}} /> |
There was a problem hiding this comment.
logic: onEdit prop is passed an empty function - AI edits will not be applied to the editor
| className="flex gap-2 rounded-lg border border-gray-700 bg-dark-gray-c-eleven p-2 shadow-lg" | ||
| editor={editor} | ||
| tippyOptions={{ | ||
| duration: 1000, |
There was a problem hiding this comment.
style: 1000ms duration for bubble menu animation may feel slow for frequent interactions
| @@ -52,26 +42,40 @@ const EditorManager: React.FC = () => { | |||
| window.ipcRenderer.on('editor-flex-center-changed', handleEditorChange) | |||
| }, []) | |||
There was a problem hiding this comment.
logic: missing cleanup for ipcRenderer event listener
No description provided.