fix: correct Settings actions in Laya ready state and clear stale AI warning (#12)

Offer the right actions in Settings when Laya is ready/available
instead of leaving irrelevant ones, and stop showing the ChannelList
local-AI warning once the runtime is actually available. Derive both
from layaStatusPresentation and cover the ready/available action set
with tests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
blomios
2026-10-02 14:34:30 +02:00
parent 9a70d18d30
commit 4f65588893
5 changed files with 43 additions and 9 deletions

View File

@ -1,6 +1,6 @@
const test = require('node:test');
const assert = require('node:assert/strict');
const { presentLayaStatus } = require('../public/js/services/layaStatusPresentation.js');
const { channelListWarning, presentLayaStatus } = require('../public/js/services/layaStatusPresentation.js');
test('presents unknown-size downloads as indeterminate with downloaded bytes', () => {
const view = presentLayaStatus({
@ -37,9 +37,25 @@ test('failed downloads expose retry, safe details and Standard fallback', () =>
});
test('ready models expose removal without download actions', () => {
const view = presentLayaStatus({ phase: 'ready', modelPresent: true, runtimeAvailable: true });
const view = presentLayaStatus({ phase: 'idle', modelPresent: true, runtimeAvailable: true, sizeBytes: 678323814 });
assert.equal(view.statusLabel, 'Ready');
assert.equal(view.showRemove, true);
assert.equal(view.showDownload, false);
assert.equal(view.showCheckAgain, false);
assert.equal(view.showStartCommand, false);
assert.equal(view.availabilityMessage, '');
});
test('ChannelList warning only appears for active Laya modes when unavailable or failed', () => {
const ready = { modelPresent: true, runtimeAvailable: true };
assert.equal(channelListWarning('hybrid', ready), '');
assert.equal(channelListWarning('laya', ready), '');
assert.equal(channelListWarning('algo', { modelPresent: false, runtimeAvailable: false }), '');
assert.equal(
channelListWarning('hybrid', { modelPresent: true, runtimeAvailable: false }),
'Local AI service is unavailable. Standard channel matching is being used.'
);
assert.equal(channelListWarning('laya', ready, true), 'Local AI service is unavailable. Standard channel matching is being used.');
});
test('installed model with unavailable service is not reported ready', () => {