DEV: Temporarily suppress diff animation as we fix issues (#1341)

The diff animation introduced in https://github.com/discourse/discourse-ai/pull/1332 and with attempts to improve it in https://github.com/discourse/discourse-ai/pull/1338 still has various issues. As we work on a fix, we want to revert the animation to simply stream the diff without animation so users are not left with a janky unusable experience.
This commit is contained in:
Keegan George 2025-05-15 14:55:30 -07:00 committed by GitHub
parent dfea784fc4
commit 9ee82fd8be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 11 deletions

View File

@ -23,6 +23,7 @@ export default class ModalDiffModal extends Component {
@tracked loading = false; @tracked loading = false;
@tracked finalResult = ""; @tracked finalResult = "";
@tracked showcasedDiff = "";
@tracked diffStreamer = new DiffStreamer(this.args.model.selectedText); @tracked diffStreamer = new DiffStreamer(this.args.model.selectedText);
@tracked suggestion = ""; @tracked suggestion = "";
@tracked @tracked
@ -30,16 +31,13 @@ export default class ModalDiffModal extends Component {
() => this.suggestion, () => this.suggestion,
(newValue) => (this.suggestion = newValue) (newValue) => (this.suggestion = newValue)
); );
@tracked isStreaming = false;
constructor() { constructor() {
super(...arguments); super(...arguments);
this.suggestChanges(); this.suggestChanges();
} }
get isStreaming() {
return this.diffStreamer.isStreaming || this.smoothStreamer.isStreaming;
}
get primaryBtnLabel() { get primaryBtnLabel() {
return this.loading return this.loading
? i18n("discourse_ai.ai_helper.context_menu.loading") ? i18n("discourse_ai.ai_helper.context_menu.loading")
@ -64,12 +62,25 @@ export default class ModalDiffModal extends Component {
@action @action
async updateResult(result) { async updateResult(result) {
// TODO(@keegan)
// Temporarily we are removing the animation using the diff streamer
// and simply showing the diff streamed without a proper animation
// while we figure things out
// so that things are not too janky in the meantime.
this.loading = false; this.loading = false;
this.isStreaming = true;
if (result.done) { if (result.done) {
this.finalResult = result.result; this.finalResult = result.result;
} }
this.showcasedDiff = result.diff;
if (result.done) {
this.loading = false;
this.isStreaming = false;
}
if (this.args.model.showResultAsDiff) { if (this.args.model.showResultAsDiff) {
this.diffStreamer.updateResult(result, "result"); this.diffStreamer.updateResult(result, "result");
} else { } else {
@ -140,12 +151,11 @@ export default class ModalDiffModal extends Component {
"composer-ai-helper-modal__suggestion" "composer-ai-helper-modal__suggestion"
"streamable-content" "streamable-content"
(if this.isStreaming "streaming") (if this.isStreaming "streaming")
(if this.diffStreamer.isThinking "thinking")
(if @model.showResultAsDiff "inline-diff") (if @model.showResultAsDiff "inline-diff")
}} }}
> >
{{#if @model.showResultAsDiff}} {{#if @model.showResultAsDiff}}
{{htmlSafe this.diffStreamer.diff}} {{htmlSafe this.showcasedDiff}}
{{else}} {{else}}
{{#if this.smoothStreamer.isStreaming}} {{#if this.smoothStreamer.isStreaming}}
<CookText <CookText

View File

@ -185,13 +185,11 @@ module DiscourseAi
if (streamed_result.length > 10 && (Time.now - start > 0.3)) || Rails.env.test? if (streamed_result.length > 10 && (Time.now - start > 0.3)) || Rails.env.test?
sanitized = sanitize_result(streamed_result) sanitized = sanitize_result(streamed_result)
if DiscourseAi::Utils::DiffUtils::SafetyChecker.safe_to_stream?(sanitized)
payload = { result: sanitized, diff: streamed_diff, done: false } payload = { result: sanitized, diff: streamed_diff, done: false }
publish_update(channel, payload, user) publish_update(channel, payload, user)
start = Time.now start = Time.now
end end
end end
end
final_diff = parse_diff(input, streamed_result) if completion_prompt.diff? final_diff = parse_diff(input, streamed_result) if completion_prompt.diff?