diff --git a/assets/javascripts/discourse/components/ai-gist-disclosure.gjs b/assets/javascripts/discourse/components/ai-gist-disclosure.gjs
deleted file mode 100644
index 7534d6c2..00000000
--- a/assets/javascripts/discourse/components/ai-gist-disclosure.gjs
+++ /dev/null
@@ -1,23 +0,0 @@
-import Component from "@glimmer/component";
-import { service } from "@ember/service";
-import icon from "discourse-common/helpers/d-icon";
-import i18n from "discourse-common/helpers/i18n";
-
-export default class AiGistDisclosure extends Component {
- @service router;
-
- get shouldShow() {
- return this.router.currentRoute.attributes?.list?.topics?.some(
- (topic) => topic.ai_topic_gist
- );
- }
-
-
- {{#if this.shouldShow}}
-
- {{icon "discourse-sparkles"}}
- {{i18n "discourse_ai.summarization.disclosure"}}
-
- {{/if}}
-
-}
diff --git a/assets/javascripts/discourse/components/ai-gist-toggle.gjs b/assets/javascripts/discourse/components/ai-gist-toggle.gjs
new file mode 100644
index 00000000..76f35157
--- /dev/null
+++ b/assets/javascripts/discourse/components/ai-gist-toggle.gjs
@@ -0,0 +1,84 @@
+import Component from "@glimmer/component";
+import { concat, fn } from "@ember/helper";
+import { action } from "@ember/object";
+import { service } from "@ember/service";
+import DButton from "discourse/components/d-button";
+import DropdownMenu from "discourse/components/dropdown-menu";
+import icon from "discourse-common/helpers/d-icon";
+import i18n from "discourse-common/helpers/i18n";
+import DMenu from "float-kit/components/d-menu";
+
+export default class AiGistToggle extends Component {
+ @service router;
+ @service gistPreference;
+
+ get shouldShow() {
+ return this.router.currentRoute.attributes?.list?.topics?.some(
+ (topic) => topic.ai_topic_gist
+ );
+ }
+
+ get buttons() {
+ return [
+ {
+ id: "gists_enabled",
+ label: "discourse_ai.summarization.gists_enabled_long",
+ icon: "discourse-sparkles",
+ },
+ {
+ id: "gists_disabled",
+ label: "discourse_ai.summarization.gists_disabled",
+ icon: "far-eye-slash",
+ },
+ ];
+ }
+
+ @action
+ onRegisterApi(api) {
+ this.dMenu = api;
+ }
+
+ @action
+ onSelect(optionId) {
+ this.gistPreference.setPreference(optionId);
+ this.dMenu.close();
+ }
+
+
+ {{#if this.shouldShow}}
+
+
+ <:trigger>
+
+ {{i18n
+ (concat
+ "discourse_ai.summarization." this.gistPreference.preference
+ )
+ }}
+
+ {{icon "angle-down"}}
+
+ <:content>
+
+ {{#each this.buttons as |button|}}
+
+
+
+ {{/each}}
+
+
+
+ {{/if}}
+
+}
diff --git a/assets/javascripts/discourse/components/ai-topic-gist.gjs b/assets/javascripts/discourse/components/ai-topic-gist.gjs
index 9e68e816..3b5ad21e 100644
--- a/assets/javascripts/discourse/components/ai-topic-gist.gjs
+++ b/assets/javascripts/discourse/components/ai-topic-gist.gjs
@@ -3,11 +3,18 @@ import { service } from "@ember/service";
export default class AiTopicGist extends Component {
@service router;
+ @service gistPreference;
+
+ get prefersGist() {
+ return this.gistPreference.preference === "gists_enabled";
+ }
get showGist() {
return (
this.router.currentRoute.attributes?.filterType === "hot" &&
this.args.topic?.ai_topic_gist &&
+ !this.args.topic?.excerpt &&
+ this.prefersGist &&
!this.args.topic?.excerpt
);
}
diff --git a/assets/javascripts/discourse/connectors/discovery-above/mobile-gist-disclosure.gjs b/assets/javascripts/discourse/connectors/discovery-above/mobile-gist-toggle.gjs
similarity index 55%
rename from assets/javascripts/discourse/connectors/discovery-above/mobile-gist-disclosure.gjs
rename to assets/javascripts/discourse/connectors/discovery-above/mobile-gist-toggle.gjs
index cbad8c77..71b47d52 100644
--- a/assets/javascripts/discourse/connectors/discovery-above/mobile-gist-disclosure.gjs
+++ b/assets/javascripts/discourse/connectors/discovery-above/mobile-gist-toggle.gjs
@@ -1,13 +1,13 @@
import Component from "@glimmer/component";
-import AiGistDisclosure from "../../components/ai-gist-disclosure";
+import AiGistToggle from "../../components/ai-gist-toggle";
-export default class AiTopicGistDisclosure extends Component {
+export default class AiTopicGistToggle extends Component {
static shouldRender(outletArgs, helper) {
const isMobileView = helper.site.mobileView;
return isMobileView;
}
-
+
}
diff --git a/assets/javascripts/discourse/connectors/topic-list-heading-bottom/desktop-gist-disclosure.gjs b/assets/javascripts/discourse/connectors/topic-list-heading-bottom/desktop-gist-toggle.gjs
similarity index 80%
rename from assets/javascripts/discourse/connectors/topic-list-heading-bottom/desktop-gist-disclosure.gjs
rename to assets/javascripts/discourse/connectors/topic-list-heading-bottom/desktop-gist-toggle.gjs
index d13f05a2..f838d84f 100644
--- a/assets/javascripts/discourse/connectors/topic-list-heading-bottom/desktop-gist-disclosure.gjs
+++ b/assets/javascripts/discourse/connectors/topic-list-heading-bottom/desktop-gist-toggle.gjs
@@ -1,5 +1,5 @@
import Component from "@glimmer/component";
-import AiGistDisclosure from "../../components/ai-gist-disclosure";
+import AiGistToggle from "../../components/ai-gist-toggle";
export default class AiTopicGist extends Component {
static shouldRender(outletArgs) {
@@ -11,6 +11,6 @@ export default class AiTopicGist extends Component {
}
-
+
}
diff --git a/assets/javascripts/discourse/services/gist-preference.js b/assets/javascripts/discourse/services/gist-preference.js
new file mode 100644
index 00000000..d9a35eeb
--- /dev/null
+++ b/assets/javascripts/discourse/services/gist-preference.js
@@ -0,0 +1,12 @@
+import { tracked } from "@glimmer/tracking";
+import Service from "@ember/service";
+
+export default class GistPreference extends Service {
+ @tracked
+ preference = localStorage.getItem("aiGistPreference") || "gists_disabled";
+
+ setPreference(value) {
+ this.preference = value;
+ localStorage.setItem("aiGistPreference", value);
+ }
+}
diff --git a/assets/stylesheets/modules/summarization/common/ai-summary.scss b/assets/stylesheets/modules/summarization/common/ai-summary.scss
index e733e20b..2ee486a4 100644
--- a/assets/stylesheets/modules/summarization/common/ai-summary.scss
+++ b/assets/stylesheets/modules/summarization/common/ai-summary.scss
@@ -238,22 +238,18 @@
color: var(--primary-medium);
}
}
+}
- &__disclosure {
- font-size: var(--font-down-1);
- color: var(--primary-600);
- .desktop-view & {
- margin-left: 0.5em;
- }
- .mobile-view & {
- display: block;
- margin-top: -0.5em;
- margin-bottom: 0.5em;
- }
- .d-icon {
- font-size: var(--font-down-1);
- position: relative;
- top: -0.05em; // improve vertical alignment
- }
+.ai-gists-dropdown-trigger {
+ font-size: var(--font-down-1);
+ color: var(--primary-medium);
+ padding-left: 0.25em;
+ .mobile-view & {
+ padding-left: 0;
+ color: var(--primary-high);
+ }
+ .d-icon {
+ color: var(--primary-low-mid);
+ margin-left: 0.15em;
}
}
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 7cea7b07..471baa0d 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -465,7 +465,9 @@ en:
topic:
title: "Topic summary"
close: "Close summary panel"
- disclosure: "Summaries generated by AI"
+ gists_enabled: "with summary"
+ gists_enabled_long: "with AI-generated summary"
+ gists_disabled: "without summary"
review:
types:
reviewable_ai_post: