Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit ded8733

Browse files
committed
Bug 1957226 - Progress indicator for initial model download for Link Preview - r=atossou,firefox-ai-ml-reviewers
- change text on Generating key points... if downloading model - show % progress on below instead of the static text "This may take a moment the first time you preview a link. Key points should appear more quickly next time." - add aiContentTitle to manage state of the heading text Differential Revision: https://phabricator.services.mozilla.com/D243602
1 parent ed48987 commit ded8733

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

browser/components/genai/LinkPreview.sys.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,10 @@ export const LinkPreview = {
215215
await lazy.LinkPreviewModel.generateTextAI(
216216
ogCard.pageData.article.textContent,
217217
{
218-
onDownload: state => {
218+
onDownload: (state, progressPercentage) => {
219219
ogCard.showWait = state;
220220
this.downloadingModel = state;
221+
ogCard.progressPercentage = progressPercentage;
221222
},
222223
onError: console.error,
223224
onText: text => {

browser/components/genai/LinkPreviewModel.sys.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,8 @@ export const LinkPreviewModel = {
308308
data => {
309309
if (data.type == lazy.Progress.ProgressType.DOWNLOAD) {
310310
onDownload?.(
311-
data.statusText != lazy.Progress.ProgressStatusText.DONE
311+
data.statusText != lazy.Progress.ProgressStatusText.DONE,
312+
Math.round((100 * data.totalLoaded) / data.total)
312313
);
313314
}
314315
}

browser/components/genai/content/link-preview-card.mjs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ class LinkPreviewCard extends MozLitElement {
2727
keyPoints: { type: Array },
2828
pageData: { type: Object },
2929
showWait: { type: Boolean },
30+
progressPercentage: { type: Number },
3031
};
3132

3233
constructor() {
3334
super();
3435
this.keyPoints = [];
36+
this.progress = 0;
3537
}
3638

3739
addKeyPoint(text) {
@@ -110,6 +112,12 @@ class LinkPreviewCard extends MozLitElement {
110112
const readingTimeMinsFast = articleData.readingTimeMinsFast || "";
111113
const readingTimeMinsSlow = articleData.readingTimeMinsSlow || "";
112114

115+
let displayProgressPercentage = this.progressPercentage;
116+
// Handle non-finite values (NaN, Infinity) by defaulting to 100%
117+
if (!Number.isFinite(displayProgressPercentage)) {
118+
displayProgressPercentage = 100;
119+
}
120+
113121
return html`
114122
<link
115123
rel="stylesheet"
@@ -158,10 +166,18 @@ class LinkPreviewCard extends MozLitElement {
158166
</ul>
159167
<hr />
160168
${this.showWait
161-
? html`<p>
162-
This may take a moment the first time you preview a link.
163-
Key points should appear more quickly next time.
164-
</p>`
169+
? html`
170+
<p>
171+
${this.progressPercentage > 0
172+
? html`Preparing Firefox •
173+
<strong>${displayProgressPercentage}%</strong>`
174+
: ""}
175+
</p>
176+
<p>
177+
This may take a moment the first time you preview a
178+
link. Key points should appear more quickly next time.
179+
</p>
180+
`
165181
: ""}
166182
<p>
167183
Key points are AI-generated and may have mistakes.

0 commit comments

Comments
 (0)