Small improvements to reasoning UI

c5016732415291491da891ef093347f2ae5f994a

Wolfsblvt <wolfsblvt@gmail.com>

1 files changed, +15 -2Showing whitespace changes
public/scripts/reasoning.js+15 -2
@@ -372,15 +372,28 @@ export class ReasoningHandler {
372372 #updateReasoningTimeUI() {
373373 const element = this.messageReasoningHeaderDom;
374374 const duration = this.getDuration();
375+ let data = null;
375376 if (duration) {
376377 const durationStr = moment.duration(duration).locale(getCurrentLocale()).humanize({ s: 50, ss: 3 });
377378 const secondsStr = moment.duration(duration).asSeconds();
378- element.innerHTML = t`Thought for <span title="${secondsStr} seconds">${durationStr}</span>`;
379+
380+ const span = document.createElement('span');
381+ span.title = t`${secondsStr} seconds`;
382+ span.textContent = durationStr;
383+
384+ element.textContent = t`Thought for `;
385+ element.appendChild(span);
386+ data = String(secondsStr);
379387 } else if (this.state === ReasoningState.Thinking) {
380388 element.textContent = t`Thinking...`;
389+ data = null;
381390 } else {
382391 element.textContent = t`Thought for some time`;
392+ data = 'unknown';
383393 }
394+
395+ this.messageReasoningDetailsDom.dataset.duration = data;
396+ element.dataset.duration = data;
384397 }
385398}
386399
@@ -711,7 +724,7 @@ function setReasoningEventHandlers() {
711724 e.stopPropagation();
712725 e.preventDefault();
713726
714727 const confirm = await Popup.show.confirm(t`Remove Reasoning`, t`Are you sure you want to clear the reasoning?`,<br t`/>Visible message contents will stay intact.`);
715728
716729 if (!confirm) {
717730 return;