Skip to content

Commit 9ee82fd

Browse files
authored
DEV: Temporarily suppress diff animation as we fix issues (#1341)
The diff animation introduced in #1332 and with attempts to improve it in #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.
1 parent dfea784 commit 9ee82fd

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

assets/javascripts/discourse/components/modal/diff-modal.gjs

+16-6
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,21 @@ export default class ModalDiffModal extends Component {
2323

2424
@tracked loading = false;
2525
@tracked finalResult = "";
26+
@tracked showcasedDiff = "";
2627
@tracked diffStreamer = new DiffStreamer(this.args.model.selectedText);
2728
@tracked suggestion = "";
2829
@tracked
2930
smoothStreamer = new SmoothStreamer(
3031
() => this.suggestion,
3132
(newValue) => (this.suggestion = newValue)
3233
);
34+
@tracked isStreaming = false;
3335

3436
constructor() {
3537
super(...arguments);
3638
this.suggestChanges();
3739
}
3840

39-
get isStreaming() {
40-
return this.diffStreamer.isStreaming || this.smoothStreamer.isStreaming;
41-
}
42-
4341
get primaryBtnLabel() {
4442
return this.loading
4543
? i18n("discourse_ai.ai_helper.context_menu.loading")
@@ -64,12 +62,25 @@ export default class ModalDiffModal extends Component {
6462

6563
@action
6664
async updateResult(result) {
65+
// TODO(@keegan)
66+
// Temporarily we are removing the animation using the diff streamer
67+
// and simply showing the diff streamed without a proper animation
68+
// while we figure things out
69+
// so that things are not too janky in the meantime.
6770
this.loading = false;
71+
this.isStreaming = true;
6872

6973
if (result.done) {
7074
this.finalResult = result.result;
7175
}
7276

77+
this.showcasedDiff = result.diff;
78+
79+
if (result.done) {
80+
this.loading = false;
81+
this.isStreaming = false;
82+
}
83+
7384
if (this.args.model.showResultAsDiff) {
7485
this.diffStreamer.updateResult(result, "result");
7586
} else {
@@ -140,12 +151,11 @@ export default class ModalDiffModal extends Component {
140151
"composer-ai-helper-modal__suggestion"
141152
"streamable-content"
142153
(if this.isStreaming "streaming")
143-
(if this.diffStreamer.isThinking "thinking")
144154
(if @model.showResultAsDiff "inline-diff")
145155
}}
146156
>
147157
{{#if @model.showResultAsDiff}}
148-
{{htmlSafe this.diffStreamer.diff}}
158+
{{htmlSafe this.showcasedDiff}}
149159
{{else}}
150160
{{#if this.smoothStreamer.isStreaming}}
151161
<CookText

lib/ai_helper/assistant.rb

+3-5
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,9 @@ def stream_prompt(completion_prompt, input, user, channel, force_default_locale:
185185
if (streamed_result.length > 10 && (Time.now - start > 0.3)) || Rails.env.test?
186186
sanitized = sanitize_result(streamed_result)
187187

188-
if DiscourseAi::Utils::DiffUtils::SafetyChecker.safe_to_stream?(sanitized)
189-
payload = { result: sanitized, diff: streamed_diff, done: false }
190-
publish_update(channel, payload, user)
191-
start = Time.now
192-
end
188+
payload = { result: sanitized, diff: streamed_diff, done: false }
189+
publish_update(channel, payload, user)
190+
start = Time.now
193191
end
194192
end
195193

0 commit comments

Comments
 (0)