Skip to content

Commit 29785d1

Browse files
committed
Move the thinking "spinner" in the toggle button text
No need to send the spinner as the message text.
1 parent 1c08c7c commit 29785d1

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

llamachatmessage.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ bool ChatMessage::eventFilter(QObject *obj, QEvent *event)
258258
void ChatMessage::renderMarkdown(const QString &text)
259259
{
260260
if (m_thoughtToggle) {
261+
bool isThinking = false;
261262
if (m_thoughtToggle->isChecked()) {
262263
QString message = text;
263264
message.replace(thinkingToken, ">");
@@ -269,6 +270,7 @@ void ChatMessage::renderMarkdown(const QString &text)
269270
newLineIdx = message.indexOf("\n", newLineIdx + 2);
270271
}
271272
} else {
273+
isThinking = true;
272274
message.replace("\n", "\n>");
273275
}
274276
message.replace(endToken, "\n\n");
@@ -278,13 +280,18 @@ void ChatMessage::renderMarkdown(const QString &text)
278280
if (endIdx != notfound) {
279281
m_markdownLabel->setMarkdown(text.mid(endIdx + endToken.size()));
280282
} else {
281-
static QVector<QChar>
282-
chars{u'', u'', u'', u'', u'', u'', u'', u'', u'', u''};
283-
// Dividing with 33ms results in 30fps
284-
m_markdownLabel->setMarkdown(QString("%1").arg(
285-
chars[(QDateTime::currentMSecsSinceEpoch() / 33) % chars.size()]));
283+
isThinking = true;
284+
m_markdownLabel->setMarkdown("");
286285
}
287286
}
287+
288+
static QVector<QChar> chars{u'', u'', u'', u'', u'', u'', u'', u'', u'', u''};
289+
// Dividing with 33ms results in 30fps
290+
m_thoughtToggle->setText(
291+
isThinking ? Tr::tr("Thinking %1")
292+
.arg(chars[(QDateTime::currentMSecsSinceEpoch() / 33) % chars.size()])
293+
: Tr::tr("Thought Process"));
294+
288295
} else {
289296
m_markdownLabel->setMarkdown(text);
290297
}

0 commit comments

Comments
 (0)