fix(plugins): retain Host progress fallback after master merge

This commit is contained in:
RockChinQ
2026-09-21 17:04:57 +00:00
parent 5d9684731e
commit a8d291e581
4 changed files with 71 additions and 2 deletions
@@ -159,6 +159,7 @@ export function asyncTaskToPluginInstallTask(
stage,
downloadCurrent: num(md.download_current),
downloadTotal: num(md.download_total),
reportedProgress: num(md.progress_percent),
stageElapsedSeconds: 0,
}),
);
@@ -326,6 +327,7 @@ export function PluginInstallTaskProvider({
stage,
downloadCurrent,
downloadTotal,
reportedProgress: num(md.progress_percent),
stageElapsedSeconds: (Date.now() - stageStartedAt) / 1000,
});
const progress = Math.min(
@@ -106,6 +106,8 @@ export interface StageProgressInput {
stage: InstallStage;
downloadCurrent?: number;
downloadTotal?: number;
/** Host coarse stage progress, used only when measured bytes are absent. */
reportedProgress?: number;
/** Seconds spent in the current stage, used to bound fallback drift. */
stageElapsedSeconds: number;
}
@@ -136,6 +138,13 @@ export function computeStageProgress(input: StageProgressInput): number {
return clampToRange(Math.round(start + (end - start) * ratio), start, end);
}
if (
input.reportedProgress != null &&
Number.isFinite(input.reportedProgress)
) {
return clampToRange(input.reportedProgress, start, end);
}
// Nothing measurable to show yet: drift slowly, but never past this stage's
// own ceiling (hence `end - start - 1`, leaving the final point to the real
// stage transition).