Commit Graph
100 Commits
Author SHA1 Message Date
Théo Poizat a98368e6a6 Allow to get scribePromptUrl from LinagoraEcosystem 2026-03-25 11:52:35 +07:00
Théo Poizat 04696eecd7 Get and build prompt from local JSON file
Here we map our AI actions to the prompt from the JSON file
to be able to use them.
2026-03-25 11:52:35 +07:00
Théo Poizat 11fd808080 Add prompts.json in Scribe package
This is a default prompts.json used when no other will be available.
2026-03-25 11:52:35 +07:00
Théo Poizat fabf3ec54f Manage prompts as a "messages" object during prompt lifecycle
Before, our prompts were just a string like "Translate this text:
user text" and just before being sent to the backend, it was
converted to an "messages" object compatible with OpenAI API like [{
"role": "user", "content": "Translate this text: user text"}].

Now, we use "messages" object directly when building the prompt
because in the near future we will create more complex prompts with
system content and user content so we will need "messages" object
dirrectly.
2026-03-25 11:52:35 +07:00
Théo Poizat 2ab6e0df02 [Scribe] Add Improve button (#4335) 2026-03-25 11:52:35 +07:00
Théo Poizat c8253551b1 Add a toolbar to execute quick actions to Scribe suggestion
Actions :
 - copy
- regenerate
2026-03-25 11:52:35 +07:00
Théo Poizat 4ba6184a69 Rename bottomsheetIcon to secondaryIcon
To be able to reuse this color without loosing a correct semantic name.
2026-03-25 11:52:35 +07:00
Théo Poizat 170bdd28c9 Autofocus Scribe input bar
Help user use the Scribe input bar. Also solves issues where Scribe bar is not well positioned when focused is removed from "To" field.
2026-03-25 11:52:35 +07:00
Théo Poizat d035e40853 fixup! Display Scribe modals correctly when a keyboard is opened
Manage multiline content in scribe bar and spacing between keyboard and scribe bar
2026-03-25 11:52:35 +07:00
Théo Poizat 13f81a9bee Include spacer in tablet bottom bar Scribe button 2026-03-25 11:52:35 +07:00
Théo Poizat 269ca7116c Display Scribe modals correctly when a keyboard is opened 2026-03-25 11:52:35 +07:00
Théo Poizat 7b3e3e1b16 Do not focus composer when clicking on tablet bottom bar button 2026-03-25 11:52:35 +07:00
Théo Poizat 0d7813c368 Display AI Scribe toggle in preferences in mobile
It has been forgotten when enabling AI Scribe in mobile.
2026-03-25 11:52:35 +07:00
Théo Poizat ed53929323 fixup! Display Scribe mobile (bottomsheet) only when responsive mobile 2026-03-25 11:52:35 +07:00
Théo Poizat 03a03b9088 Fix Scribe on responsive mobile
- Button was not added in MobileResponsiveAppBar
- Mobile behavior related scripts were not correctly added for web composer
- Mobile behavior related scripts return value was not properly handled for web composer
- In responsive web, bottomsheet modal clicks were intercepted by iframe behind
2026-03-25 11:52:35 +07:00
Théo Poizat 46a12745a5 Ensure replace function respect new lines in every editor 2026-03-25 11:52:35 +07:00
Théo Poizat 17b9d97284 Adjust Scribe context menu to support tablet screens
- Support tap in addition to hover for context menu
- Improve clamping for greater screen sizes to avoid Scribe getting off screen
- Set a padding to 0 to avoid random padding depending on screen sizes
2026-03-25 11:52:35 +07:00
Théo Poizat 7a6a49fc7b Display Scribe mobile (bottomsheet) only when responsive mobile
Previosuly, we display Scribe mobile (bottomsheet) if platform was mobile, so also Android or iOS tablet.

Now we choose to display Scribe mobile relatively to display screens instead of platform to display the desktop Scribe (context menu) for tablets.
2026-03-25 11:52:35 +07:00
Théo Poizat 6540ed29d1 Add current text in a card in Scribe mobile
Because the Scribe mobile is a full screen modal, we do not see the
current content (so either the selected text or entire composer text)
when selecting our AI actions.

That's why we add here a scrollable card that displays the current
content.
2026-03-25 11:52:35 +07:00
Théo Poizat 26393c038b Upgrade enough_html_editor
To enjoy the fix from the following PR https://github.com/linagora/enough_html_editor/pull/40
2026-03-25 11:52:35 +07:00
Théo Poizat 40030fe88e Properly escape HTML in every Scribe actions
In recent commits I separated how we could add text in the editor. So
we need to escape HTML in both method that add text:
insertTextInEditor and setTextInEditor.

I had to extract the HTML escape part of
convertTextContentToHtmlContent because when using setTextInEditor we
do not need to convert \n to <br>.
2026-03-25 11:52:35 +07:00
Théo Poizat cf8ed16ed0 Use warning logs instead of error logs for Scribe 2026-03-25 11:52:35 +07:00
Théo Poizat c05a01d92a Move Scribe icon in tablet at left of icons 2026-03-25 11:52:35 +07:00
Théo Poizat b5606626f4 Fix more Scribe mobile issues
- Add getSavedSelection to check saved selection without consuming it
- Distinguish between setText (replace all) and insertText (at cursor) operations
- Fix replace callback to use setText when no selection exists
- Clean up saved selection state after restoration in HTML utils
- Move mobile editor focus and selection restore to appropriate callbacks
2026-03-25 11:52:35 +07:00
Théo Poizat be7f28f270 Fix Scribe mobile issues
- Fix Scribe replace on mobile when opened from menu bar (to be complete
this fix needs this PR https://github.com/Enough-Software/enough_html_editor/pull/37)
- Ensure all mobile editor call are awaited
- Do not clear text if a selection has been restored (which mean we replace a selection)
- Avoid collapseToEnd crash
2026-03-25 11:52:35 +07:00
Théo Poizat abd2453511 Do not display Scribe actions if no content in composer in mobile 2026-03-25 11:52:35 +07:00
Théo Poizat 752f42dc7d Ensure editor is focused before calling insert HTML
enough_html_editor uses execCommand to insert HTML. However
execCommand only works if the contenteditable element is focused. So
inserting or replacing Scribe result do not work if the user did not
click before in the composer.

Here we manually focus the contenteditable element to fix this before
inserting content.
2026-03-25 11:52:35 +07:00
Théo Poizat 84176cb113 Hide keyboard and selection icons when Scribe mobile modal opened
When opening Scribe mobile modal, we now unfocus the composer to hide the keyboard and the selection start and end icons from the OS.

Add new methods to save, restore, and clear text selection in HTML editor. These methods allow preserving and restoring user selection state when opening the Scribe mobile modal so that the "replace" action still works.
2026-03-25 11:52:35 +07:00
Théo Poizat 09fe002d3c Use proper icons and styles for bottomsheet icons in Scribe 2026-03-25 11:52:35 +07:00
Théo Poizat 14f2e557fa Add Scribe mobile
Same features than Scribe desktop but as a full screen modal instead of  a context menu.

Reuse menu and submenu components.
Reuse suggestion components.
Reuse 99% of Scribe desktop style.
2026-03-25 11:52:35 +07:00
Théo Poizat 245dfc714d Display sparkle button in mobile app bar to launch AI Scribe
- Same icon than for desktop
- Displayed only if AI Scribe is enabled
2026-03-25 11:52:35 +07:00
Théo Poizat 089eb7b75f Fix correct grammar icon not present in submenu getIcon 2026-03-25 11:52:35 +07:00
Théo Poizat b28dea732a Fix AI Scribe overlay button display in iOS
The button was never displayed because the selectionchange event listener was loaded when the WebView was not entirely loaded so selectionchange event were never fired.

Now we setup selection listener when the WebView is loaded instead of created.
2026-03-25 11:52:35 +07:00
Théo Poizat 03c70922a0 Fix selection coordinates in mobile
Because the HTML editor is different, we need a different selector to get the editable element.

We also need to add a small offset to the coordinates to avoid positionning the overlay icon above native selection UI in mobile. For example, Android adds a marker at the beginning and the end of the selection and we do not want to display the Scribe overlay icon above this marker.
2026-03-25 11:52:35 +07:00
Théo Poizat 9e601caa86 Enable AI scribe in mobile 2026-03-25 11:52:35 +07:00
Théo Poizat 0f4ed4537e Remove unused localizations arguments in Scribe suggestion 2026-03-25 11:52:35 +07:00
Théo Poizat 5abce414d4 Guard Scribe suggestion loading if interactor is null 2026-03-25 11:52:35 +07:00
Théo Poizat 5bdcff5aba Extract Scribe menu item text and icons in components 2026-03-25 11:52:35 +07:00
Théo Poizat d5a3400bb4 Allow boxShadow to be changed in AIScribeBar
We will need a custom boxShadow for mobile version.
2026-03-25 11:52:35 +07:00
Théo Poizat 4c75ec863d Extract AI Scribe menu item component
Scribe is always composed of menu (aka category) and submenu (aka action) :
- submenu item UI was already in an UI only component. I moved it to items folder.
- menu item UI was mixed in a component with desktop related UX. So I extract the UI to create an UI only component. I moved it also to items folder.
2026-03-25 11:52:35 +07:00
Théo Poizat 08899b1598 Extract AI Scribe suggestion logic
In Scribe desktop, the suggestion is displayed in a popup.
In Scribe mobile, it will be displayed in a full screen modal.

But it share the same logic about loading, success and error.

So here I extract this logic and use it in the AI Scribe desktop to be able to use it later in AI Scribe mobile.
2026-03-25 11:52:35 +07:00
Théo Poizat b6959a5ab6 Add an animated AI icon for Scribe in desktop web
I moved the previous static icon in its own component and created a component that manage the loading of the appropriate icon: static or dynamic.
2026-02-09 23:29:43 +07:00
Théo Poizat 34e1dffa0a Add lottie package
To display lottie animation in web
2026-02-09 23:29:43 +07:00
Théo Poizat 7a4d0dbf46 Add missing languages in Scribe
To fit languages supported in tmail settings
2026-02-03 14:26:28 +07:00
Théo Poizat 5f2e4512bc Ensure fallback to English for unsupported locales in Scribe
- Implement locale validation with fallback to 'en'
- Disable automatic default locale setting
2026-02-03 14:26:28 +07:00
Théo Poizat 8b71b1e995 Fix some Scribe translations
- Added missing translations
- Removed missing translations
- Some small translations updates
2026-02-03 14:26:28 +07:00
Théo Poizat d739b61c83 Fix Scribe translations by using multiple_localization package
Even if all keys were translated, Scribe UI was always in default
language.

In short, it is not possible to load multiple localization delegates
with different .arb files. But we need these translations to be
located in a separate file because in the future we will move Scribe
in a separate module.

See
https://github.com/Innim/flutter_multiple_localization for more
explanation.
2026-02-03 14:26:28 +07:00
Théo Poizat 2821ae1e0d Add AGENTS.md
First usecase I found: ensuring the agent use the correct command to update Flutter packages
2026-01-16 11:05:16 +07:00
Théo Poizat 6e08d3834d Update AI scribe "more professional" icon 2026-01-07 13:22:49 +07:00
Théo Poizat 68e55a0e22 Improve AI Scribe prompts
- Mutualize some commands
- Avoid unexpected behavior
2025-12-19 19:03:39 +07:00
Théo Poizat c78f6b8a76 Improve text replace in Scribe
- Delete selection content before inserting
- Insert correct HTML
2025-12-19 19:03:39 +07:00
Théo Poizat 1a79445711 Add a method to delete selection content 2025-12-19 19:03:39 +07:00
Théo Poizat 2b6504f8be Unpixelize gradient sparkle 2025-12-19 19:03:39 +07:00
Théo Poizat 9a8989a310 Make the AI Scribe suggestion success selectable text 2025-12-19 19:03:39 +07:00
Théo Poizat 3fe54e1847 Add Intl for Replace text 2025-12-19 19:03:39 +07:00
Théo Poizat 8ed8100e7e Add JS method to collapse selection in both composer
Collapsing a selection means removing it and keep the cursor at the
end. It will be needed by the scribe for "Insert" action where we
want to insert a text at the cursor even if the user selected text.
2025-12-19 19:03:39 +07:00
Théo Poizat 63d9a5d740 Strong typing AI exceptions 2025-12-19 19:03:39 +07:00
Théo Poizat 755e24895d Disable AI Scribe if on mobile 2025-12-19 19:03:39 +07:00
Théo Poizat 0075fd64b6 feat: Remove .env file for AI Scribe
It was used at the beginning for configuration purpose but now we
have the JMAP capability, no need anymore.
2025-12-19 19:03:39 +07:00
Théo Poizat 253f22c600 Remove value now unused
No more API key and url needed because everything is managed by the backend.

Also backend does not accept a model parameter for the moment.
2025-12-19 19:03:39 +07:00
Théo Poizat 2c364ea08a Use endpoint from AI capability instead of direct call to LLM 2025-12-19 19:03:39 +07:00
Théo Poizat 2325df616f Create an isAIScribeAvailable method
Check JMAP capability AND if AI is enabled in env.file and use this method everywhere  where we checked env.file
2025-12-19 19:03:39 +07:00
Théo Poizat 8c16bd1fad Add AI capability 2025-12-19 19:03:39 +07:00
Théo Poizat e7405051d1 fixup! Use html parser instead of regex to clean composer input
Improve efficiency and add more tests in convertHtmlContentToTextContent
2025-12-19 19:03:39 +07:00
Théo Poizat a9cfe86a59 Use html parser instead of regex to clean composer input
Before sending input to the LLM, we clean the composer input to
remove html tags. We relied on regex that we not complete enough and
could be bypassed easily. So let's use the html parser available in
Dart instead.

I also added some tests.
2025-12-19 19:03:39 +07:00
Théo Poizat f77580ed44 Fix tests by initializing DotEnv for testing 2025-12-19 19:03:39 +07:00
Théo Poizat 4d8d688afb Fix AI scribe menu going off screen to the top
If it was opened at the top of the composer, it could go off screen to the top.

modalHeight was missing so the calculateModalPosition method could not protect the AI scribe menu to go off screen from the top.
2025-12-19 19:03:39 +07:00
Théo Poizat c7886614cd Add tests to AI scribe calculcateModalPosition 2025-12-19 19:03:39 +07:00
Théo Poizat d1bec5af24 Use ValueNotifier instead of setState in AIScribeBar 2025-12-19 19:03:39 +07:00
Théo Poizat 0b139a41d2 Remove unused categoryKeys 2025-12-19 19:03:39 +07:00
Théo Poizat 77a56ae9b7 Export AI Scribe code from controller to a mixin
Avoid adding too much code in the controller
2025-12-19 19:03:39 +07:00
Théo Poizat 4d0880b8be fixup! Extract method to convert html content to text content
Move the method in utils
2025-12-19 19:03:39 +07:00
Théo Poizat d369fcbf5f Simplify observed values about text selection in composer
hasTextSelection had no interest.

The other two values have been put inside an object to observe only one object.
2025-12-19 19:03:39 +07:00
Théo Poizat 2228596c1c Mutualize event listener in web editor widget
Instead of listening multiple times for message from editor JS side,
let's add only one listener and route inside the callback.
2025-12-19 19:03:39 +07:00
Théo Poizat 75f5817e1c fixup! Implement text selection mixin in mobile and web editor
Add try/catch to JSON parse
2025-12-19 19:03:39 +07:00
Théo Poizat 0b8a814ad6 Show AI Scribe submenu on hover instead of on click 2025-12-19 19:03:39 +07:00
Théo Poizat 2f3bbe3bbb Do not display AI scribe if AI is not enabled in env.file 2025-12-19 19:03:39 +07:00
Théo Poizat bb23792fe3 Use bindings to better separate scribe presentation and data layer 2025-12-19 19:03:39 +07:00
Théo Poizat 6dc58e2eb6 Extract method to convert html content to text content
Editor exposes html content (so with html tags) and we do not want to send them to AI backend
2025-12-19 19:03:39 +07:00
Théo Poizat 7d7ccaf874 Open AI Scribe from text selection 2025-12-19 19:03:39 +07:00
Théo Poizat 96c95866c6 Open AI Scribe from bottom bar button 2025-12-19 19:03:39 +07:00
Théo Poizat b122928a38 Add methods to display AI scribe 2025-12-19 19:03:39 +07:00
Théo Poizat dced5b5dc7 Add AI scribe widgets
- Button : the button with sparkle icon to display AI scribe
- Menu : the menu where you can select the action (eg: translate)
- Bar : the input where you can write a custom action
- Suggestion : the wrapper of the result of the LLM
2025-12-19 19:03:39 +07:00
Théo Poizat 23065aa76d Forward text selection callback from editor view to editor 2025-12-19 19:03:39 +07:00
Théo Poizat 57124f70a8 Implement text selection mixin in mobile and web editor 2025-12-19 19:03:39 +07:00
Théo Poizat aaf60cf222 Update AI models default and optional values
To have stronger code
2025-12-19 19:03:39 +07:00
Théo Poizat 0c787d3d98 Throw error if AI API return null or empty reponse 2025-12-19 19:03:39 +07:00
Théo Poizat c858ac40f5 Add translations for scribe module
Added a separated ScribeLocalizations to keep it separated from main app.
2025-12-19 19:03:39 +07:00
Théo Poizat 2557c68a94 Use absolute path for scribe files 2025-12-19 19:03:39 +07:00
Théo Poizat 7e0c98b080 Add scribe module 2025-12-19 19:03:39 +07:00
Théo Poizat 26593b50ef Move AI env var from main to scribe package 2025-12-19 19:03:39 +07:00
Théo Poizat f19993bb30 Use json_serializable and const to improve AI data model 2025-12-19 19:03:39 +07:00
Théo Poizat 8b17fcdc54 fixup! Add text selection mixin 2025-12-19 19:03:39 +07:00
Théo Poizat 4013973110 Add text selection mixin
This mixin leverages HTML callbacks that can be set by WebView editor
to send text selection event to the composer so the composer will
receive text selection event necessary to display buttons related to
text selection.
2025-12-19 19:03:39 +07:00
Théo Poizat 2ccb203610 Add AI text state 2025-12-19 19:03:39 +07:00
Théo Poizat 1e2718e678 Add AI text interactor 2025-12-19 19:03:39 +07:00
Théo Poizat 52295c8c0c Add AI repository implementation 2025-12-19 19:03:39 +07:00
Théo Poizat 6564e50b74 Add AI data source implementation 2025-12-19 19:03:39 +07:00
Théo Poizat 63489b1b44 Add AI abstract repository 2025-12-19 19:03:39 +07:00
Théo Poizat c734987347 Add AI abstract datasource 2025-12-19 19:03:39 +07:00