feat(smartpicker): wire NC Assistant Smart Picker bridge#17
feat(smartpicker): wire NC Assistant Smart Picker bridge#17
Conversation
|
My cents:
Yeah, maybe don't. Rather inline (select text -> translate) like in Nextcloud Text or Talk. The Assistant menu on the top bar should, ideally, work. Not sure how feasible that is of course.
See above, then... But if not feasible in time, what you did looks decent to me. Jan might have different ideas of course ;-)
Well in an ideal world you can tell the assistant "can you create a pivot table of this data that shows the growth of shoe production over time split by factory" -> we are obviously quite far from that. The closer we get there, the better - but there's so much you can do until June 9 ;-) Being able to deal with markup would be nice, of course. What Collabora has - if there's an error in a spreadsheet, it can advise on it. Would be nice, too, such errors drive me nuts. And then being able to ask "I need to do X with column AB and AC, how do I do it" and have it give me a formula for that... That is gold already. In slides, you probably have stuff like - re-arrange, or "make it look nice" or "make it look more professional" and then it makes changes to the design... Or "create a summary slide". But I think the question is rather - what is doable. Pretty sure my ideas above won't fit in the time. |
a440598 to
f5febaa
Compare
| // The web-apps Gateway delivers the user's current selection via | ||
| // event.data.selectedText so the NC Assistant can seed its input | ||
| // with the text the user wants to operate on. | ||
| const selectedText = event && event.data && event.data.selectedText ? event.data.selectedText : '' |
There was a problem hiding this comment.
could we do:
const selectedText = event?.data?.selectedText ?? ''
I've not tested that, but I think that is the newer approach
| // Tell the editor whether the NC Assistant app is loaded so it | ||
| // can gray out the toolbar entry when the user can't actually | ||
| // reach an AI provider. | ||
| const assistantAvailable = !!(window.OCA && window.OCA.Assistant && typeof window.OCA.Assistant.openAssistantForm === 'function') |
There was a problem hiding this comment.
const assistantAvailable = typeof window.OCA?.Assistant?.openAssistantForm === 'function'
typeof check against 'function' returns boolean, so no !! needed
| } | ||
| this.showSmartPicker = true | ||
|
|
||
| const openAssistantForm = window.OCA && window.OCA.Assistant && window.OCA.Assistant.openAssistantForm |
There was a problem hiding this comment.
const openAssistantForm = window.OCA?.Assistant?.openAssistantForm
we can collapse it using the optional chaining operator
| OCA.Eurooffice.onRequestInsertImage(event.data.param) | ||
| break | ||
| case 'editorRequestSmartPicker': | ||
| OCA.Eurooffice.onSmartPickerRequest(event.data.param && event.data.param.selectedText) |
There was a problem hiding this comment.
OCA.Eurooffice.onSmartPickerRequest(event.data.param?.selectedText)
Same deal
|
@chrip I added a few minor comments |
Adds the editor<->NC bridge needed for the toolbar's Smart Picker / Nextcloud Assistant button (registered on the OO web-apps side): editor.js (runs inside the editor iframe): - config.events.onRequestSmartPicker forwards the editor's postMessage payload to the host with the user's current selection - onAppReady detects window.OCA.Assistant.openAssistantForm and calls docEditor.setSmartPickerEnabled so the toolbar entry grays out when the Assistant app is not loaded - editorInsertLink / editorInsertPlainText expose Promise-wrapped hooks the host calls to insert the AI result back at the cursor listener.js (runs in the NC parent window): - onSmartPickerRequest opens window.OCA.Assistant.openAssistantForm with taskType core:text2text and the selected text seeded into prompt/input/text keys (covers chat/text2text/translate/summarize /rewrite); registers an 'Insert into editor' action button that routes the finished task's output back through the editor - editorRequestSmartPicker case in the postMessage switch - Falls back to the plain getLinkWithPicker bridge if the Assistant app is not installed Signed-off-by: Christoph Schaefer <christoph.schaefer@nextcloud.com>
f5febaa to
a3e0a9c
Compare
Adds the editor<->NC bridge needed for the toolbar's Smart Picker / Nextcloud Assistant button (registered on the OO web-apps side):
editor.js (runs inside the editor iframe):
listener.js (runs in the NC parent window):
Things to discuss
To make that feature work, one needs the web-apps counter part:
Euro-Office/web-apps#58