discourse-ai/assets/javascripts/initializers
Sam 3800728d52
FIX: clear uploads after successfully posting new PM (#1307)
This PR addresses a bug where uploads weren't being cleared after successfully posting a new private message in the AI bot conversations interface. Here's what the changes do:

## Main Fix:
- Makes the `prepareAndSubmitToBot()` method async and adds proper error handling
- Adds `this.uploads.clear()` after successful submission to clear all uploads
- Adds a test to verify that the "New Question" button properly resets the UI with no uploads

## Additional Improvements:
1. **Dynamic Character Length Validation**:
   - Uses `siteSettings.min_personal_message_post_length` instead of hardcoded 10 characters
   - Updates the error message to show the dynamic character count
   - Adds proper pluralization in the localization file for the error message

2. **Bug Fixes**:
   - Adds null checks with optional chaining (`link?.topic?.id`) in the sidebar code to prevent potential errors

3. **Code Organization**:
   - Moves error handling from the service to the controller for better separation of concerns
2025-05-02 13:46:22 +10:00
..
admin-plugin-configuration-nav.js FEATURE: Configure persona backed features in admin panel (#1245) 2025-04-10 08:16:31 -07:00
admin-reports.js DEV: Updates to sentiment analysis reports (#1161) 2025-03-05 13:53:56 -08:00
ai-artifacts.gjs DEV: Update linting (#1194) 2025-03-17 15:14:53 +11:00
ai-bot-replies.js FEATURE: correctly decorate AI bots (#1300) 2025-04-30 16:36:38 +10:00
ai-chat-summarization.js FEATURE: move summary to use llm_model (#699) 2024-07-04 10:48:18 +10:00
ai-conversations-sidebar.js FIX: clear uploads after successfully posting new PM (#1307) 2025-05-02 13:46:22 +10:00
ai-gist-topic-list-class.js DEV: include excerpt-expanded class when gists are enabled (#1267) 2025-04-16 15:26:04 -04:00
ai-helper.js DEV: Bump dependencies and fix linting (#1115) 2025-02-06 17:42:32 +01:00
ai-image-caption.js FEATURE: llm quotas (#1047) 2025-01-14 15:54:09 +11:00
ai-search-discoveries.js FEATURE: Add ability to disable search discoveries (#1177) 2025-03-10 14:17:58 -07:00
ai-semantic-search.js FIX: results not being reset when appending to query param (#912) 2024-11-13 07:19:34 -08:00
ai-sentiment-admin-nav.js DEV: Updates to sentiment analysis reports (#1161) 2025-03-05 13:53:56 -08:00
related-topics.gjs DEV: Bump dependencies and fix linting (#1115) 2025-02-06 17:42:32 +01:00