mirror of
https://ghfast.top/https://github.com/discourse/discourse-ai.git
synced 2026-07-16 11:36:23 +08:00
Previously we had moved the AI helper from the options menu to a selection menu that appears when selecting text in the composer. This had the benefit of making the AI helper a more discoverable feature. Now that some time has passed and the AI helper is more recognized, we will be moving it back to the composer toolbar. This is better because: - It consistent with other behavior and ways of accessing tools in the composer - It has an improved mobile experience - It reduces unnecessary code and keeps things easier to migrate when we have composer V2. - It allows for easily triggering AI helper for all content by clicking the button instead of having to select everything.
29 lines
835 B
JavaScript
29 lines
835 B
JavaScript
export function showComposerAiHelper(
|
|
composerModel,
|
|
siteSettings,
|
|
currentUser,
|
|
featureType
|
|
) {
|
|
const enableHelper = _helperEnabled(siteSettings);
|
|
const enableAssistant = currentUser.can_use_assistant;
|
|
const canShowInPM = siteSettings.ai_helper_allowed_in_pm;
|
|
const enableFeature =
|
|
siteSettings.ai_helper_enabled_features.includes(featureType);
|
|
|
|
if (composerModel?.privateMessage) {
|
|
return enableHelper && enableAssistant && canShowInPM && enableFeature;
|
|
}
|
|
|
|
return enableHelper && enableAssistant && enableFeature;
|
|
}
|
|
|
|
export function showPostAIHelper(outletArgs, helper) {
|
|
return (
|
|
_helperEnabled(helper.siteSettings) &&
|
|
helper.currentUser?.can_use_assistant_in_post
|
|
);
|
|
}
|
|
|
|
function _helperEnabled(siteSettings) {
|
|
return siteSettings.discourse_ai_enabled && siteSettings.ai_helper_enabled;
|
|
}
|