Skip to content
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

Feat 441 writing assistant checkbox for feeding current editor contents to llm #474

Conversation

subin-chella
Copy link
Collaborator

@subin-chella subin-chella commented Nov 4, 2024

fixes #441

  • Add checkbox to automatically include entire file content when no text is selected
  • Store auto-context preference in electron-store
  • Fix undefined message error in currentConversation display
  • Add proper type safety and null checks
  • Update UI with clear labeling for auto-context feature

Evidence:
Updated:
https://github.com/user-attachments/assets/28ff5089-72e7-4d69-ae4a-392c5784cb33

Old:
https://github.com/user-attachments/assets/c8848edf-d89f-40bc-b0c3-bcf50c07ecbe

/claim #441

- Add checkbox to automatically include entire file content when no text is selected
- Store auto-context preference in electron-store
- Fix undefined message error in currentConversation display
- Add proper type safety and null checks
- Update UI with clear labeling for auto-context feature
- Add checkbox to automatically include entire file content when no text is selected
- Store auto-context preference in electron-store
- Fix undefined message error in currentConversation display
- Add proper type safety and null checks
- Update UI with clear labeling for auto-context feature
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

Implements a new auto-context feature for the writing assistant that automatically includes full file content when no text is selected, with persistent user preferences stored in electron-store.

  • Added autoContext boolean field to StoreSchema in /electron/main/electron-store/storeConfig.ts for persistent storage
  • Implemented IPC handlers set-auto-context and get-auto-context in /electron/main/electron-store/ipcHandlers.ts
  • Added checkbox UI with proper accessibility in /src/components/WritingAssistant/ConversationHistory.tsx
  • Inconsistent IPC handler pattern in /electron/preload/index.ts deviates from createIPCHandler usage, potentially affecting type safety
  • Modified text replacement logic in /src/components/WritingAssistant/WritingAssistant.tsx to handle both selected and full-file contexts with proper null checks

5 file(s) reviewed, 8 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines +218 to +219
store.set(StoreKeys.AutoContext, autoContext)
event.sender.send('auto-context-changed', autoContext)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider adding error handling in case the store.set() operation fails

Comment on lines +217 to +220
ipcMain.handle('set-auto-context', (event, autoContext: boolean) => {
store.set(StoreKeys.AutoContext, autoContext)
event.sender.send('auto-context-changed', autoContext)
})
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: event.sender.send() is called after store.set() - if store.set() fails, the UI could get out of sync with the actual stored value

Comment on lines +222 to +224
ipcMain.handle('get-auto-context', () => {
return store.get(StoreKeys.AutoContext, true) // Default to true
})
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Missing type annotation for the return value which should be boolean

@@ -82,4 +83,5 @@ export enum StoreKeys {
SpellCheck = 'spellCheck',
EditorFlexCenter = 'editorFlexCenter',
showDocumentStats = 'showDocumentStats',
AutoContext = 'autoContext',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Key name 'autoContext' in enum differs from schema property 'AutoContext' - should match case

electron/preload/index.ts Outdated Show resolved Hide resolved
Comment on lines +211 to +213
const savedAutoContext = await window.electronStore.getAutoContext()
setAutoContext(savedAutoContext)
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: savedAutoContext could be undefined on first load - should provide a default value of true to match initial state

Comment on lines +300 to +302
if (autoContext && !selectedText && editor) {
selectedText = editor.state.doc.textBetween(0, editor.state.doc.content.size)
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: large files could cause performance issues when getting entire document content - consider adding a size limit check

Comment on lines +166 to +168
const $pos = editor.state.doc.resolve(from)
if (!$pos?.parent?.textContent?.startsWith(' ')) {
resetSpaceTrigger()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: optional chaining on textContent could mask underlying issues - consider more explicit null checks

- Add checkbox to automatically include entire file content when no text is selected
- Store auto-context preference in electron-store
- Fix undefined message error in currentConversation display
- Add proper type safety and null checks
- Update UI with clear labeling for auto-context feature
@weilirs
Copy link
Collaborator

weilirs commented Nov 6, 2024

This looks awesome! But would it be better to place the toggler in this window instead of where the response is already being generated?
image

…ngAssistant

- Remove autoContext checkbox and related props from ConversationHistory component
- Add autoContext checkbox to WritingAssistant's options container
- Update component interfaces and prop passing
- Maintain existing autoContext functionality and styling
@subin-chella
Copy link
Collaborator Author

This looks awesome! But would it be better to place the toggler in this window instead of where the response is already being generated? image

Yes. Fixed it.

image

@weilirs weilirs merged commit 0df494c into reorproject:main Nov 10, 2024
0 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Writing assistant checkbox for feeding current editor contents to llm
2 participants