@@ -5,6 +5,7 @@ import didInsert from "@ember/render-modifiers/modifiers/did-insert";
5
5
import willDestroy from " @ember/render-modifiers/modifiers/will-destroy" ;
6
6
import { service } from " @ember/service" ;
7
7
import { htmlSafe } from " @ember/template" ;
8
+ import { or } from " truth-helpers" ;
8
9
import CookText from " discourse/components/cook-text" ;
9
10
import DButton from " discourse/components/d-button" ;
10
11
import DModal from " discourse/components/d-modal" ;
@@ -41,6 +42,10 @@ export default class ModalDiffModal extends Component {
41
42
}
42
43
43
44
get diffResult () {
45
+ if (this .loading ) {
46
+ return this .escapedSelectedText ;
47
+ }
48
+
44
49
if (this .diffStreamer .diff ? .length > 0 ) {
45
50
return this .diffStreamer .diff ;
46
51
}
@@ -50,10 +55,22 @@ export default class ModalDiffModal extends Component {
50
55
return this .escapedSelectedText ;
51
56
}
52
57
58
+ get smoothStreamerResult () {
59
+ if (this .loading ) {
60
+ return this .escapedSelectedText ;
61
+ }
62
+
63
+ return this .smoothStreamer .renderedText ;
64
+ }
65
+
53
66
get isStreaming () {
54
67
// diffStreamer stops Streaming when it is finished with a chunk, looking at isDone is safe
55
68
// it starts off not done
56
- return ! this .diffStreamer .isDone || this .smoothStreamer .isStreaming ;
69
+ if (this .args .model .showResultAsDiff ) {
70
+ return ! this .diffStreamer .isDone ;
71
+ }
72
+
73
+ return this .smoothStreamer .isStreaming ;
57
74
}
58
75
59
76
get primaryBtnLabel () {
@@ -154,42 +171,37 @@ export default class ModalDiffModal extends Component {
154
171
{{willDestroy this . cleanup}}
155
172
class =" text-preview"
156
173
>
157
- {{#if this . loading }}
158
- <div class =" composer-ai-helper-modal__loading" >
159
- {{~@ model.selectedText ~}}
160
- </div >
161
- {{else }}
162
- <div
163
- class ={{concatClass
164
- " composer-ai-helper-modal__suggestion"
165
- " streamable-content"
166
- ( if this . isStreaming " streaming" )
167
- ( if @ model.showResultAsDiff " inline-diff" )
168
- ( if this . diffStreamer.isThinking " thinking" )
169
- }}
170
- >
171
- {{~#if @ model.showResultAsDiff ~}}
172
- <span class =" diff-inner" >{{htmlSafe this . diffResult}} </span >
174
+ <div
175
+ class ={{concatClass
176
+ " composer-ai-helper-modal__suggestion"
177
+ " streamable-content"
178
+ ( if this . isStreaming " streaming" )
179
+ ( if @ model.showResultAsDiff " inline-diff" )
180
+ ( if this . diffStreamer.isThinking " thinking" )
181
+ ( if this . loading " composer-ai-helper-modal__loading" )
182
+ }}
183
+ >
184
+ {{~#if @ model.showResultAsDiff ~}}
185
+ <span class =" diff-inner" >{{htmlSafe this . diffResult}} </span >
186
+ {{else }}
187
+ {{#if ( or this . loading this . smoothStreamer.isStreaming) }}
188
+ <CookText
189
+ @ rawText ={{this .smoothStreamerResult }}
190
+ class =" cooked"
191
+ />
173
192
{{else }}
174
- {{#if this . smoothStreamer.isStreaming }}
193
+ <div class =" composer-ai-helper-modal__old-value" >
194
+ {{~this .escapedSelectedText ~}}
195
+ </div >
196
+ <div class =" composer-ai-helper-modal__new-value" >
175
197
<CookText
176
- @ rawText ={{this .smoothStreamer.renderedText }}
198
+ @ rawText ={{this .smoothStreamerResult }}
177
199
class =" cooked"
178
200
/>
179
- {{else }}
180
- <div class =" composer-ai-helper-modal__old-value" >
181
- {{@ model.selectedText }}
182
- </div >
183
- <div class =" composer-ai-helper-modal__new-value" >
184
- <CookText
185
- @ rawText ={{this .smoothStreamer.renderedText }}
186
- class =" cooked"
187
- />
188
- </div >
189
- {{/if }}
201
+ </div >
190
202
{{/if }}
191
- </ div >
192
- {{/ if }}
203
+ {{/ if }}
204
+ </ div >
193
205
</div >
194
206
</: body >
195
207
0 commit comments