fix: make Laya status consistent between Settings and ChannelList (#12)
The model was reported as ready while the AI runtime was actually unreachable, and the Download action stayed visible afterwards. Distinguish model-downloaded from runtime-available in layaStatusPresentation, derive the Download action from the real combined state, and align Settings and ChannelList rendering on that single source of truth. Cover the combined status cases with tests. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@ -37,11 +37,24 @@
|
||||
const progressPercent = determined ? Math.max(0, Math.min(100, Math.round(percentValue))) : null;
|
||||
const error = errorParts(status);
|
||||
const failed = phase === 'failed';
|
||||
const modelPresent = status.modelPresent === true;
|
||||
const runtimeAvailable = status.runtimeAvailable === true;
|
||||
const ready = modelPresent && runtimeAvailable && !busy && !failed;
|
||||
const statusLabel = ready
|
||||
? 'Ready'
|
||||
: failed || busy
|
||||
? PHASE_LABELS[phase]
|
||||
: modelPresent && !runtimeAvailable
|
||||
? 'Local AI service unavailable'
|
||||
: !modelPresent
|
||||
? 'Model not downloaded'
|
||||
: PHASE_LABELS[phase];
|
||||
return {
|
||||
phase,
|
||||
statusLabel: status.modelPresent && phase === 'idle'
|
||||
? (status.runtimeAvailable ? 'Model ready' : 'Model downloaded · runtime unavailable')
|
||||
: PHASE_LABELS[phase],
|
||||
ready,
|
||||
statusLabel,
|
||||
modelLabel: `Model: ${modelPresent ? 'Downloaded' : 'Not downloaded'}`,
|
||||
serviceLabel: `Local AI service: ${runtimeAvailable ? 'Available' : 'Unavailable'}`,
|
||||
busy,
|
||||
showProgress: phase === 'downloading',
|
||||
progressIndeterminate: phase === 'downloading' && progressPercent === null,
|
||||
@ -53,9 +66,14 @@
|
||||
errorMessage: failed ? (error.message || 'The local AI model could not be downloaded.') : '',
|
||||
errorDetail: failed ? error.detail : '',
|
||||
downloadLabel: failed ? 'Retry download' : 'Download model',
|
||||
showDownload: !busy && !status.modelPresent && (phase === 'idle' || failed),
|
||||
showRemove: !busy && Boolean(status.modelPresent) && !failed,
|
||||
showUseStandard: failed && mode !== 'algo'
|
||||
showDownload: !busy && !modelPresent && (phase === 'idle' || failed),
|
||||
showRemove: !busy && modelPresent,
|
||||
showUseStandard: failed && mode !== 'algo',
|
||||
showCheckAgain: !busy && modelPresent && !runtimeAvailable,
|
||||
showStartCommand: !busy && modelPresent && !runtimeAvailable,
|
||||
availabilityMessage: modelPresent && !runtimeAvailable
|
||||
? 'The model is installed, but the Local AI service is not running. Standard channel matching is being used.'
|
||||
: ''
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user