diff --git a/changelog.d/issue-463-card-pill.change.md b/changelog.d/issue-463-card-pill.change.md new file mode 100644 index 00000000..5a10dff3 --- /dev/null +++ b/changelog.d/issue-463-card-pill.change.md @@ -0,0 +1,2 @@ +卡片视图不再显示开机中等状态标签,开机失败时点画面区查看原因 +Cards no longer show a status label; for a failed boot, click the screen for the reason diff --git a/internal/ui/API.md b/internal/ui/API.md index b802a1ea..f43e344a 100644 --- a/internal/ui/API.md +++ b/internal/ui/API.md @@ -125,7 +125,7 @@ GET `/api/keymap/vendor-sources?vendor=ldplayer` 列出安装,带 `sourceInsta - `progress.step`:开机用 emu 的 `launch` / `boot` / `tune` / `ime` / `first_boot` / `vulkan_fix` / `done`;关机(含等被取消的开机停下)是 `stop`,安装是 `install`,这两种做完是 `done`;整理磁盘进行中是 `disk_compact`、做完是 `done`;复制实例是 `copy`(`done` / `total` 按复制的字节折成千分比)(进行中没有百分比,`total` 为 0,页面显示不定长进度条;做完 `done` = `total` = 1000);装执行桥的每一轮是 `bridge`;商店的装、卸进行中是 `playstore-install` / `playstore-uninstall`(没有百分比)、做完是 `done`;导入时核对文件是 `verifying`、解压镜像是 `extracting`(`done` / `total` 是字节);新建是 `create`、其中几次开机的上述各步(开机做完是 `setup`)、`create_stop`、`done`,几次开机合成一条不回退的进度。`total` 一律 1000。 - 安装任务的 `result.apk` 是用户上传的文件名,不是服务端的临时路径(临时文件任务结束就删了)。 - `progress` 在没有进度时为 `null`;`result` 是 `StartResult` / `StopResult` / `InstallResult` / `DiskCompactResult` / `InstanceInfo`(新建)/ `PlayStoreResult` / `PlayStoreImportResult` / `GLES32Result`,没完成时为 `null`;`error` 失败时是错误对象,否则 `null`。 -- 页面怎么提示失败:卡片下面不放失败提示框。有任务失败(`state` 为 `failed`,什么种类都算;`canceled` 不算),或有实例是 `create_failed` 而管理器里没有它的新建任务(比如命令行建的),而这一条还没在「问题反馈」里看过时,顶栏的「问题反馈」入口和不能开机时的「组件」一样变红、一明一暗地闪,悬停和读屏说是哪几条。点开直接定位到最新的那条(在「最近任务和消息」里,带原因、建议,内存不够的带「调小内存」);没有任务的 `create_failed` 实例按任务的样子列在最上面。卡片上「开机失败」「新建失败」的状态标签悬停是原因和建议,点它(或按 Enter、空格)同样打开「问题反馈」定位到那条任务;没有任务的新建失败定位到最上面那台实例的那一行。抽屉里列出来就算看过,入口变回原样;看过的记在页面的 `localStorage`(`modavd.feedback.seen:<根目录>`,最近 100 条),刷新不会再闪。软件渲染、磁盘空间这类一直在的状态不算。失败时右下角的提示照旧。 +- 页面怎么提示失败:卡片下面不放失败提示框。有任务失败(`state` 为 `failed`,什么种类都算;`canceled` 不算),或有实例是 `create_failed` 而管理器里没有它的新建任务(比如命令行建的),而这一条还没在「问题反馈」里看过时,顶栏的「问题反馈」入口和不能开机时的「组件」一样变红、一明一暗地闪,悬停和读屏说是哪几条。点开直接定位到最新的那条(在「最近任务和消息」里,带原因、建议,内存不够的带「调小内存」);没有任务的 `create_failed` 实例按任务的样子列在最上面。卡片视图不显示状态标签(读屏照旧读得到状态名);「开机失败」「新建失败」时画面区写着失败,悬停是原因和建议,点画面区(或按 Enter、空格)打开「问题反馈」定位到那条任务(开机失败的重新开机在「更多」里;列表视图的状态标签照旧);没有任务的新建失败定位到最上面那台实例的那一行。抽屉里列出来就算看过,入口变回原样;看过的记在页面的 `localStorage`(`modavd.feedback.seen:<根目录>`,最近 100 条),刷新不会再闪。软件渲染、磁盘空间这类一直在的状态不算。失败时右下角的提示照旧。 `DiskCompactResult` 保留非负的 `freed_bytes`。`before_on_disk_bytes` 和 `after_on_disk_bytes` 是整理前后宿主实际占用,新增的 `on_disk_delta_bytes` 等于后者减前者,正值表示占用增大。`skipped=true` 表示检查通过、预计收益不足,未重写原盘;此时前后占用相等、变化和释放量均为零。结果还包含 `reclaim_threshold_bytes` 和可省略的 `estimated_reclaimable_bytes`,详见 [整理预算与结果契约](../emu/COMPACT.md)。 - 同一实例同时只能有一个任务在跑;第二个回 409 `busy`。**例外**:开机任务进行中可以发关机(和 emu 一致:开机中照样能关)。 diff --git a/internal/ui/web/app.css b/internal/ui/web/app.css index d79ca07e..b2d82dc0 100644 --- a/internal/ui/web/app.css +++ b/internal/ui/web/app.css @@ -240,8 +240,8 @@ button { -webkit-tap-highlight-color: transparent; } .num { font-variant-numeric: tabular-nums; } .muted { color: var(--text-3); } .spacer { flex: 1; } -/* .pill-quiet: the card view's status label for 运行中 and 已关机, kept for screen readers (the list view shows it) */ -.sr-only, .grid:not(.is-list) .pill-quiet { +/* the card view's status label (.pill) is for screen readers only, in every state: the screen says it (the list view shows it) */ +.sr-only, .grid:not(.is-list) .pill { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; } @@ -603,9 +603,8 @@ html.kbd .brand-link:focus-visible { outline: 2px solid var(--accent, currentCol /* the title and, when 按应用走代理 is on, its mark (a button: it opens the dialog) */ .card-tline { display: flex; align-items: center; gap: 6px; min-width: 0; } .card-tline .card-title { min-width: 0; } -/* Card view: the name takes the rest of the title line, so the marks sit at its right end, where the status label is - (left of the label when it shows: the gap to it is the head's 8px). The head keeps the label's height (22px + the - label's 1px margin) whether or not the label is in the flow, so the card is the same height in every state. The list +/* Card view: the name takes the rest of the title line, so the marks sit at its right end. The status label is out of the + flow in every state; the head keeps a fixed height (23px), so the card is the same height in every state. The list view's title is a grid cell: its marks follow the name. */ .grid:not(.is-list) .card-head { gap: 8px; min-height: 23px; } .grid:not(.is-list) .card-tline .card-title { flex: 1; } @@ -622,9 +621,8 @@ html.kbd .brand-link:focus-visible { outline: 2px solid var(--accent, currentCol title and aria-label. Today: cat head = 按应用走代理, G = Google Play 商店, K = KernelSU, monitor with a slash = 无头 (headless), A = copy the ADB address. Always-there marks come first, marks that follow the run state come last, so one appearing never pushes the others. - In the card view they are at the right end of the title line. The card view does not write 运行中 or 已关机 (the - screen and the power button say it): the status label shows only for the states in between and the failed ones, and - for the other two it is for screen readers only (.pill-quiet). + In the card view they are at the right end of the title line. The card view shows no status label in any state (the + screen says it: the picture, 未开机, the progress, 开机失败 / 新建失败); the label is for screen readers only (.sr-only). The card view is the title and one config line: a new state is another single glyph or a hover text, not a word and not a line. The cat head is the only mark that is a button (it opens the proxy dialog) and the only one that can have a state colour (--tf from .tone-*; the icon only, never a background), and only when something is wrong (tone-warn, tone-err): while the diff --git a/internal/ui/web/js/cards.js b/internal/ui/web/js/cards.js index de5f072a..289b5f0d 100644 --- a/internal/ui/web/js/cards.js +++ b/internal/ui/web/js/cards.js @@ -135,8 +135,12 @@ function makeCard(i) { // no live region here: a boot reports every 2.5 s; the toast at the end says how it went // decoration only: the screen itself is the button (a nested button would open the viewer twice) c.peek = h('span', { class: 'peek', 'aria-hidden': 'true' }, icon('screen')); + // 开机失败 and 新建失败: to the task in 问题反馈, landed on the way a click on the glowing 问题反馈 lands on a failure + const showFailure = () => { if (c.failure) panels.openActivity(c.failure.job, c.failure.inst); }; const activateScreen = () => { if (!c.inst) return; + // 开机失败 and 新建失败: the screen is the way to 问题反馈 at that task (开机 and 重试初始化 are in 更多) + if (c.failure) return showFailure(); if (c.inst.status === 'online') return openViewer(i); const mode = c.primary.dataset.mode; if (mode === 'blocked') panels.openComponents(); @@ -163,17 +167,16 @@ function makeCard(i) { // - Order: marks that are always there come first; marks that come and go with the run state come last, so one // appearing never pushes the others. // - In the card view the marks sit at the right end of the title line (the name takes the rest of the width), where - // the status label is; when the label is shown the marks are right next to it, on its left. The list view keeps - // them after the name. - // - The card view does not write 运行中 or 已关机: the screen (or the 未开机 placeholder) already says it. - // The status label shows only for the states in between and the failed ones (开机中, 关机中, 新建中, - // 开机失败, 新建失败); for the other two it stays in the DOM for screen readers only (.pill-quiet). The list view - // always shows it (it has a status column). 诊断模式 is on the name's hover text in the card view. + // the status label is in the list view. The list view keeps them after the name. + // - The card view shows no status label in any state (ModAVD/ModAVD#463): the screen already says it (the live picture, + // the 未开机 placeholder, the boot or shutdown progress, 开机失败 / 新建失败). The label stays in the DOM for screen + // readers only (.sr-only in the card view); the list view always shows it (it has a status column). + // 诊断模式 is on the name's hover text in the card view. // - The card view is the title and one config line. A new state is another single glyph or a hover text, not a // word and not a line; the label showing or not never changes the card's height. // - There is no box under the card: nothing is added below the config line, so no state makes a card taller than - // another. The reason of a failure (开机失败, 新建失败) is the status label's hover text, and clicking the label - // opens 问题反馈 at that task; software rendering and a data disk that is nearly full are lines on the name's hover + // another. The reason of a failure (开机失败, 新建失败) is the screen's hover text, and clicking the screen + // (Enter, Space) opens 问题反馈 at that task (the list view's label does the same); software rendering and a data disk that is nearly full are lines on the name's hover // text, the first start's setup (about 1–2 minutes) is a line on the screen's hover text. // - The cat head (pmark) is a single glyph too: an icon-only button that opens the 按应用走代理 dialog. It is // the only mark that is clickable and the only one that can carry a state colour, and only when something is wrong: @@ -197,11 +200,9 @@ function makeCard(i) { c.cfg = h('span', { 'aria-hidden': 'true' }); c.cfgFull = h('span', { class: 'sr-only' }); c.pillText = h('span'); - // 开机失败 and 新建失败: the label is the way to the reason (its hover text) and to the task in 问题反馈 (click, Enter, - // Space), landed on the way a click on the glowing 问题反馈 lands on a failure - const showFailure = () => { if (c.failure) panels.openActivity(c.failure.job, c.failure.inst); }; - c.pill = h('span', { class: 'pill', onclick: showFailure, - onkeydown: (e) => { if (c.failure && (e.key === 'Enter' || e.key === ' ')) { e.preventDefault(); showFailure(); } } }, c.pillText); + // the list view's label is the same way in (the card view's is for screen readers only, with no click) + c.pill = h('span', { class: 'pill', onclick: () => { if (getView() === 'list') showFailure(); }, + onkeydown: (e) => { if (getView() === 'list' && c.failure && (e.key === 'Enter' || e.key === ' ')) { e.preventDefault(); showFailure(); } } }, c.pillText); const copyAdb = () => A.copy(c.inst.adb_address); c.adbTag = btn('adb-tag tone-idle', 'A', copyAdb); c.adb = h('span', { class: 'adb-addr' }); @@ -268,15 +269,18 @@ function updateCard(c, inst) { if (cp != null) pt = t('新建中 {pct}%', { pct: Math.floor(cp) }); if (v.key === 'error') pt = FAIL[v.failed.kind]; setText(c.pillText, pt); - // the card view leaves 运行中 and 已关机 out (screen and power button say it); the label stays for screen readers - // 开机失败 and 新建失败: the hover text is the reason and the advice, the label opens 问题反馈 at the task + // The card view shows no label (it is sr-only there, with its text for screen readers); the failure's reason is the + // screen's hover text and the screen opens 问题反馈 at the task. The list view's label keeps both. const failure = failureOf(inst, v); c.failure = failure; - attr(c.pill, 'class', 'pill tone-' + tone + (v.key === 'online' || v.key === 'offline' ? ' pill-quiet' : '') + (failure ? ' pill-link' : '')); - attr(c.pill, 'title', [failure && (failure.advice ? failure.text + '\n' + failure.advice : failure.text), diag].filter(Boolean).join('\n') || null); - attr(c.pill, 'role', failure ? 'button' : diag ? 'img' : null); - attr(c.pill, 'tabindex', failure ? '0' : null); - attr(c.pill, 'aria-label', diag || failure ? [pt, diag, failure && t('查看详情')].filter(Boolean).join(' · ') : null); + const listed = getView() === 'list'; + const failTip = failure && (failure.advice ? failure.text + '\n' + failure.advice : failure.text); + const linked = !!failure && listed; + attr(c.pill, 'class', 'pill tone-' + tone + (linked ? ' pill-link' : '')); + attr(c.pill, 'title', listed ? [failTip, diag].filter(Boolean).join('\n') || null : null); + attr(c.pill, 'role', linked ? 'button' : diag ? 'img' : null); + attr(c.pill, 'tabindex', linked ? '0' : null); + attr(c.pill, 'aria-label', diag || linked ? [pt, diag, linked && t('查看详情')].filter(Boolean).join(' · ') : null); const address = inst.adb_address || null; c.adbTag.hidden = c.adbList.hidden = !address; @@ -313,7 +317,7 @@ function updateCard(c, inst) { c.el.classList.toggle('is-busy', busy); c.screen.classList.toggle('has-shot', live && v.key !== 'stopping' && !!c.url); c.screen.classList.toggle('busy', busy); - setText(c.phText, v.key === 'error' ? t('上次开机没有成功') : v.key === 'createfail' ? t('新建时的初始化没做完') : live ? t('正在取画面…') : t('未开机')); + setText(c.phText, v.key === 'error' ? t('开机失败') : v.key === 'createfail' ? t('新建失败') : live ? t('正在取画面…') : t('未开机')); if (busy) { const p = v.job && v.job.progress; const msg = (p && stripInst(p.message)) || (store ? store[1] : v.key === 'stopping' ? t('正在关机…') : v.key === 'creating' ? t('正在新建:后台开机做初始化…') : v.kind === 'import-game' ? t('正在导入游戏…') : v.kind === 'install' ? t('正在安装 APK…') @@ -349,16 +353,17 @@ function updateCard(c, inst) { attr(b, 'aria-busy', mode[0] === 'busy'); attr(b, 'aria-disabled', mode[0] === 'busy' || mode[0] === 'blocked'); } - const screenInteractive = live || mode[0] === 'start' || mode[0] === 'blocked' || mode[0] === 'resume'; + const screenInteractive = live || !!failure || mode[0] === 'start' || mode[0] === 'blocked' || mode[0] === 'resume'; attr(c.screen, 'tabindex', screenInteractive ? '0' : null); attr(c.screen, 'aria-disabled', screenInteractive ? null : 'true'); - attr(c.screen, 'aria-label', live ? t('打开「{name}」的画面', { name }) : mode[0] === 'blocked' ? t('打开组件') : mode[0] === 'start' ? t('开机') : mode[0] === 'resume' ? t('重试初始化') : null); + // a failed boot or create: the screen opens 问题反馈 at the task (the status for screen readers goes with it) + attr(c.screen, 'aria-label', failure ? [pt, t('查看详情')].join(' · ') : live ? t('打开「{name}」的画面', { name }) : mode[0] === 'blocked' ? t('打开组件') : mode[0] === 'start' ? t('开机') : mode[0] === 'resume' ? t('重试初始化') : null); // the card view hides the power button: what its hover text says (why a start is not possible, the first start's setup) is the screen's - c.screen.title = mode[0] === 'start' || mode[0] === 'blocked' ? [mode[0] === 'blocked' && BLOCKED, first && FIRST_START].filter(Boolean).join('\n') || null : null; + c.screen.title = failure ? failTip : mode[0] === 'start' || mode[0] === 'blocked' ? [mode[0] === 'blocked' && BLOCKED, first && FIRST_START].filter(Boolean).join('\n') || null : null; if (live && v.key !== 'stopping' && !c.url) tick(); } -// What the 开机失败 / 新建失败 label says and opens: the reason and the advice (its hover text), and where 问题反馈 +// What the 开机失败 / 新建失败 screen says and opens: the reason and the advice (its hover text), and where 问题反馈 // lands in 最近任务和消息: job, the task's row; inst, for a 新建失败 with no 新建 / 重试初始化 task of this manager // behind it (created from the command line), the instance's own row on top of the list. Nothing else is shown on the // card about it. @@ -392,6 +397,8 @@ function menuItems(c) { v.key === 'starting' && { label: t('关机'), icon: 'power', run: () => A.stop(i) }, // the card view has no power button (the list view does): the screen starts, and shutting down is here view !== 'list' && v.key === 'online' && { label: t('关机'), icon: 'power', run: () => A.stop(i) }, + // the screen of a failed boot opens 问题反馈, so the retry is here + view !== 'list' && v.key === 'error' && { label: t('开机'), icon: 'power', run: () => (rootBlocked() ? panels.openComponents() : A.start(i)) }, view !== 'list' && v.key === 'createfail' && { label: t('重试初始化'), icon: 'refresh', run: () => A.resumeCreate(i) }, // create's setup: our own create job is cancelled, one of another process (CLI, AUTO-MAS) is ended by a normal // stop with explicit cancellation; either way it shuts down normally and reads create_failed (resumable) diff --git a/scripts/test_create_cancel.mjs b/scripts/test_create_cancel.mjs index e273dbe6..8806cb17 100644 --- a/scripts/test_create_cancel.mjs +++ b/scripts/test_create_cancel.mjs @@ -573,7 +573,7 @@ test('cards show diagnostics mode on the list line under the name, on the name\' h.patchCard(plain, inst); assert.equal(plain.title.title, '诊断模式'); assert.equal(plain.sub.textContent, '诊断模式'); - assert.equal(plain.pill.getAttribute('title'), '诊断模式'); + assert.ok(!plain.pill.getAttribute('title'), 'the card view label has no hover text'); assert.equal(plain.pill.getAttribute('aria-label'), `${plain.pillText.textContent} · 诊断模式`); h.patchCard(plain, { ...inst, diagnostics: undefined }); assert.equal(plain.title.title, ''); @@ -693,40 +693,51 @@ test('the proxy mark is a cat-head button without words; only a problem gives it assert.equal(c.pmark.hidden, true); }); -// The card view writes neither 运行中 nor 已关机 (the screen and the power button say it); the label stays in the DOM for -// screen readers (.pill-quiet is the sr-only styling, only in the card view), and every other state shows it. -test('the status label is only for screen readers while running or shut down', async () => { +// ModAVD/ModAVD#463: the card view shows no status label in any state (the screen says it); the label stays in the DOM +// for screen readers (the sr-only styling is in the stylesheet, only in the card view) and takes no click, focus or +// hover text there. The list view keeps it as it was. +test('the card view has no visible status label in any state; the list view keeps it', async () => { const h = await settingsHarness({ diagnostics: false }); const c = h.makeCard({ ...h.inst, status: 'online', running: true }); - const quiet = cls => cls.split(' ').includes('pill-quiet'); - assert.equal(c.pillText.textContent, '运行中'); - assert.ok(quiet(c.pill.className), c.pill.className); - h.patchCard(c, { ...h.inst, status: 'offline', running: false }); - assert.equal(c.pillText.textContent, '已关机'); - assert.ok(quiet(c.pill.className), c.pill.className); - // the states in between, the failed ones and a create in progress show it - const failed = { id: 'j9', index: 3, kind: 'start', state: 'failed', created_at: '2026-12-02T10:00:00Z', finished_at: '2026-12-02T10:00:02Z' }; - for (const [inst, text, jobs] of [ + const failed = { id: 'j9', index: 3, kind: 'start', state: 'failed', created_at: '2026-12-02T10:00:00Z', finished_at: '2026-12-02T10:00:02Z', + error: { message: '原因', advice: '建议' } }; + const states = [ + [{ ...h.inst, status: 'online', running: true }, '运行中', []], + [{ ...h.inst, status: 'offline', running: false }, '已关机', []], [{ ...h.inst, status: 'starting', running: true, busy: 'starting' }, '开机中', []], [{ ...h.inst, status: 'online', running: true, busy: 'stopping' }, '关机中', []], [{ ...h.inst, status: 'creating', running: true }, '新建中', []], [{ ...h.inst, status: 'create_failed', running: false }, '新建失败', []], [{ ...h.inst, status: 'offline', running: false }, '开机失败', [failed]], - ]) { + ]; + for (const [inst, text, jobs] of states) { h.state.jobs.clear(); for (const j of jobs) h.state.jobs.set(j.id, j); h.patchCard(c, inst); - assert.equal(c.pillText.textContent, text); - assert.ok(!quiet(c.pill.className), `${text}: ${c.pill.className}`); - assert.match(c.pill.className, /^pill tone-/); + assert.equal(c.pillText.textContent, text, 'the state name stays in the DOM for screen readers'); + assert.match(c.pill.className, /^pill tone-\w+$/, `${text}: nothing but the tone in the card view`); + assert.equal(c.pill.getAttribute('title'), null, text); + assert.equal(c.pill.getAttribute('role'), null, text); + assert.equal(c.pill.getAttribute('tabindex'), null, `${text}: the invisible label is not a tab stop`); + h.activity.length = 0; + c.pill.dispatch('click'); + for (const fn of c.pill.events.get('keydown') || []) fn({ key: 'Enter', preventDefault() {} }); + assert.deepEqual(h.activity, [], `${text}: the card view's label opens nothing`); } + // the list view still shows the label, and a failed one is the link it was + h.setView('list'); + h.patchCard(c, states.at(-1)[0]); + assert.match(c.pill.className, /\bpill-link\b/); + assert.equal(c.pill.getAttribute('tabindex'), '0'); + assert.equal(c.pill.getAttribute('title'), '开机失败:原因\n建议'); + c.pill.dispatch('click'); + assert.deepEqual(h.activity, [['j9', null]]); + h.setView('card'); h.state.jobs.clear(); - // back to running: quiet again, and the name for screen readers still has the state + // 诊断模式 stays in the status name for screen readers h.patchCard(c, { ...h.inst, status: 'online', running: true, diagnostics: true }); - assert.ok(quiet(c.pill.className)); assert.equal(c.pill.getAttribute('aria-label'), '运行中 · 诊断模式'); }); - // ModAVD/ModAVD#377: nothing is under the config line, in any state: no box for a failure, a first start, software // rendering or a nearly full disk, so no state makes a card taller. What the boxes said is in hover texts. const failedStart = { id: 'j9', index: 3, kind: 'start', state: 'failed', created_at: '2026-12-02T10:00:00Z', finished_at: '2026-12-02T10:00:02Z', @@ -772,63 +783,66 @@ test('software rendering and a nearly full disk are lines on the name hover text assert.equal(c.pill.getAttribute('aria-label'), null, 'the status name for screen readers does not carry them'); }); -test('a failed boot or create: the reason is the status label hover text, and the label opens 问题反馈 at the task', async () => { +test('a failed boot or create: the reason is the screen hover text, and the screen opens 问题反馈 at the task', async () => { const h = await settingsHarness({ diagnostics: false }); - const quiet = cls => cls.split(' ').includes('pill-quiet'); h.state.jobs.clear(); h.state.jobs.set(failedStart.id, failedStart); const c = h.makeCard({ ...h.inst, status: 'offline', running: false }); - assert.equal(c.pillText.textContent, '开机失败'); - assert.equal(c.pill.getAttribute('title'), '开机失败:电脑内存不足,模拟器分不到实例的内存\n请关闭部分程序、调小实例内存'); - assert.equal(c.pill.getAttribute('aria-label'), '开机失败 · 查看详情'); - assert.equal(c.pill.getAttribute('role'), 'button'); - assert.equal(c.pill.getAttribute('tabindex'), '0'); - assert.match(c.pill.className, /\bpill-link\b/); assert.equal(c.el.dataset.status, 'error'); - assert.equal(c.phText.textContent, '上次开机没有成功'); - // click, Enter and Space open 问题反馈 at the failed job; other keys do nothing - c.pill.dispatch('click'); - for (const key of ['Enter', ' ', 'a']) for (const fn of c.pill.events.get('keydown')) fn({ key, preventDefault() {} }); + assert.equal(c.phText.textContent, '开机失败', 'the screen says it'); + assert.equal(c.screen.title, '开机失败:电脑内存不足,模拟器分不到实例的内存\n请关闭部分程序、调小实例内存'); + assert.equal(c.screen.getAttribute('aria-label'), '开机失败 · 查看详情'); + assert.equal(c.screen.getAttribute('role'), 'button'); + assert.equal(c.screen.getAttribute('tabindex'), '0'); + assert.equal(c.screen.getAttribute('aria-disabled'), null); + // the label is not the way in any more (no title, no button role, no tab stop); screen readers still read its text + assert.equal(c.pillText.textContent, '开机失败'); + assert.equal(c.pill.getAttribute('title'), null); + assert.equal(c.pill.getAttribute('tabindex'), null); + // click, Enter and Space on the screen open 问题反馈 at the failed job (not a start); other keys do nothing + const started = h.started; + c.screen.dispatch('click'); + for (const key of ['Enter', ' ', 'a']) for (const fn of c.screen.events.get('keydown')) fn({ key, preventDefault() {} }); assert.deepEqual(h.activity, [['j9', null], ['j9', null], ['j9', null]]); - // with the diagnostics line the title and the name carry it too + if (started) assert.deepEqual(started, []); + // with the diagnostics line: it is on the name's hover text, not the screen's h.patchCard(c, { ...h.inst, status: 'offline', running: false, diagnostics: true }); - assert.equal(c.pill.getAttribute('title'), '开机失败:电脑内存不足,模拟器分不到实例的内存\n请关闭部分程序、调小实例内存\n诊断模式'); - assert.equal(c.pill.getAttribute('aria-label'), '开机失败 · 诊断模式 · 查看详情'); + assert.equal(c.title.title, '诊断模式'); + assert.equal(c.screen.title, '开机失败:电脑内存不足,模拟器分不到实例的内存\n请关闭部分程序、调小实例内存'); // nothing on the card closes it: it stays through updates, until a newer job (the next boot) starts h.patchCard(c, { ...h.inst, status: 'offline', running: false }); - assert.equal(c.pillText.textContent, '开机失败'); + assert.equal(c.phText.textContent, '开机失败'); assert.equal(h.state.dismissed, undefined, 'there is no way to dismiss it any more'); h.state.jobs.set('j10', { id: 'j10', index: 3, kind: 'start', state: 'running', created_at: '2026-12-02T10:05:00Z' }); h.patchCard(c, { ...h.inst, status: 'starting', running: true, busy: 'starting' }); assert.equal(c.pillText.textContent, '开机中'); - assert.equal(c.pill.getAttribute('title'), null); - assert.equal(c.pill.getAttribute('role'), null); - assert.equal(c.pill.getAttribute('tabindex'), null); - assert.doesNotMatch(c.pill.className, /pill-link/); + assert.equal(c.screen.title, null); + assert.equal(c.screen.getAttribute('aria-label'), null); h.activity.length = 0; - c.pill.dispatch('click'); - assert.deepEqual(h.activity, [], 'a label that is not a failure opens nothing'); - // a failed job of another kind is not a card state: the label stays quiet and opens nothing + c.screen.dispatch('click'); + assert.deepEqual(h.activity, [], 'a screen that is not a failure opens no 问题反馈'); + // a failed job of another kind is not a card state: the screen is the plain 开机 one and opens nothing h.state.jobs.clear(); h.state.jobs.set('j11', { ...failedStart, id: 'j11', kind: 'install' }); h.patchCard(c, { ...h.inst, status: 'offline', running: false }); assert.equal(c.pillText.textContent, '已关机'); - assert.ok(quiet(c.pill.className)); - c.pill.dispatch('click'); + assert.equal(c.screen.getAttribute('aria-label'), '开机'); + c.screen.dispatch('click'); assert.deepEqual(h.activity, []); - // 新建失败: the reason and the advice (with the log) on hover; its create job when there is one, else the instance's own row + // 新建失败: the reason and the advice (with the log) on the screen's hover; its create job when there is one, else the instance's own row h.state.jobs.clear(); const created = { ...h.inst, status: 'create_failed', running: false, initialized: false, creation_error: '后台开机做初始化时模拟器退出了', creation_log: 'logs\\mas_3.log' }; const cf = h.makeCard(created); assert.equal(cf.pillText.textContent, '新建失败'); - assert.equal(cf.pill.getAttribute('title'), '新建失败:后台开机做初始化时模拟器退出了\n点「重试初始化」再做一次,或在「更多」里删除这台实例;日志 logs\\mas_3.log'); - assert.equal(cf.pill.getAttribute('aria-label'), '新建失败 · 查看详情'); - cf.pill.dispatch('click'); + assert.equal(cf.phText.textContent, '新建失败'); + assert.equal(cf.screen.title, '新建失败:后台开机做初始化时模拟器退出了\n点「重试初始化」再做一次,或在「更多」里删除这台实例;日志 logs\\mas_3.log'); + assert.equal(cf.screen.getAttribute('aria-label'), '新建失败 · 查看详情'); + cf.screen.dispatch('click'); assert.deepEqual(h.activity, [[null, 3]]); h.state.jobs.set('j12', { ...failedStart, id: 'j12', kind: 'create' }); h.patchCard(cf, created); - cf.pill.dispatch('click'); + cf.screen.dispatch('click'); assert.deepEqual(h.activity, [[null, 3], ['j12', null]]); // the newest 新建 / 重试初始化 task, failed or canceled, is the row (问题反馈 lists the instance as that task); a newer // task of another kind does not take its place @@ -836,17 +850,16 @@ test('a failed boot or create: the reason is the status label hover text, and th h.state.jobs.set('j14', { ...failedStart, id: 'j14', kind: 'disk-compact', state: 'done', created_at: '2026-12-02T10:02:00Z' }); h.patchCard(cf, created); h.activity.length = 0; - cf.pill.dispatch('click'); + cf.screen.dispatch('click'); assert.deepEqual(h.activity, [['j13', null]]); h.patchCard(cf, { ...created, creation_error: '', creation_log: '' }); - assert.equal(cf.pill.getAttribute('title'), '新建失败:初始化没做完\n点「重试初始化」再做一次,或在「更多」里删除这台实例'); + assert.equal(cf.screen.title, '新建失败:初始化没做完\n点「重试初始化」再做一次,或在「更多」里删除这台实例'); // no 调小内存 link (it is on the task in 问题反馈), no dismiss button, no 详情 link: the visible text buttons are the retry and 画面 controls (not the A mark) const buttons = descendants(cf.el).filter(x => x.tagName === 'BUTTON' && x !== cf.adbTag).map(x => x.textContent.trim()).filter(Boolean); assert.deepEqual(buttons, ['重试初始化', '画面']); assert.doesNotMatch(cf.el.textContent, /调小内存|不再显示|详情/); h.state.jobs.clear(); }); - test('the first start of a new instance is a line on the 开机 button hover text', async () => { const h = await settingsHarness({ diagnostics: false, running: false }); const line = '首次开机会做初始化,约 1⁠–⁠2 分钟'; @@ -868,17 +881,18 @@ test('the first start of a new instance is a line on the 开机 button hover tex // The styling the tests above rely on, read from the stylesheet: quiet is the sr-only way (not display: none, which // would take it from screen readers) and only in the card view; the card head keeps the label's height; the proxy mark // is plain unless it carries tone-warn or tone-err; the name takes the width so the marks are at the right end. -test('the stylesheet hides the quiet status label for the card view only and keeps the card height', async () => { +test('the stylesheet hides the status label in the card view only and keeps the card height', async () => { const css = await readFile(new URL('../internal/ui/web/app.css', import.meta.url), 'utf8'); const rule = sel => { const i = css.indexOf(sel + ' {'); assert.ok(i >= 0, sel); return css.slice(i, css.indexOf('}', i)); }; - const srOnly = rule('.sr-only, .grid:not(.is-list) .pill-quiet'); + const srOnly = rule('.sr-only, .grid:not(.is-list) .pill'); assert.match(srOnly, /position: absolute; width: 1px; height: 1px/); assert.match(srOnly, /clip: rect\(0 0 0 0\)/); - assert.doesNotMatch(css, /pill-quiet[^{]*\{[^}]*display: none/); + assert.doesNotMatch(css, /\.grid:not\(\.is-list\) \.pill[^{]*\{[^}]*display: none/); + assert.doesNotMatch(css, /pill-quiet/); assert.match(rule('.grid:not(.is-list) .card-head'), /min-height: 23px/); assert.match(rule('.grid:not(.is-list) .card-tline .card-title'), /flex: 1/); assert.doesNotMatch(rule('.pmark, .smark, .kmark, .hmark'), /var\(--(tb|sunken)\)/, 'no background colour behind a mark'); @@ -932,14 +946,16 @@ test('card screen: one button, decoration inside, and every hidden power action assert.equal((c.peek.events.get('click') || []).length, 0); c.screen.dispatch('click'); assert.deepEqual(opened, [3], 'one click, one viewer'); - // a failed create: the screen retries the setup + // a failed create: the screen opens 问题反馈 (ModAVD/ModAVD#463); the retry is in 更多 const f = h.makeCard({ ...h.inst, status: 'create_failed', running: false, initialized: false }); assert.equal(f.primary.dataset.mode, 'resume'); assert.equal(f.screen.getAttribute('tabindex'), '0'); - assert.equal(f.screen.getAttribute('aria-label'), '重试初始化'); + assert.equal(f.screen.getAttribute('aria-label'), '新建失败 · 查看详情'); f.screen.dispatch('click'); - assert.deepEqual(resumed, [3]); + assert.deepEqual(resumed, []); + assert.deepEqual(h.activity, [[null, 3]]); assert.deepEqual(started, []); + h.activity.length = 0; // a stopped one starts, with the first start's line as the screen's hover text const s = h.makeCard({ ...h.inst, status: 'offline', running: false, initialized: false }); assert.equal(s.screen.title, '首次开机会做初始化,约 1⁠–⁠2 分钟'); @@ -949,14 +965,22 @@ test('card screen: one button, decoration inside, and every hidden power action assert.equal(s.screen.title, null); h.patchCard(s, { ...h.inst, status: 'online', running: true, initialized: false }); assert.equal(s.screen.title, null); - // the menu: 关机 for a running instance and 重试初始化 for a failed create in the card view, neither in the list view + // the menu: 关机 for a running instance, 重试初始化 for a failed create and 开机 for a failed boot in the card view, none in the list view const labels = inst => h.cards.menuItems({ i: 3, inst }).filter(Boolean).map(x => x.label); const on = { index: 3, status: 'online', running: true }, bad = { index: 3, status: 'create_failed', running: false }; assert.ok(labels(on).includes('关机')); assert.ok(labels(bad).includes('重试初始化')); + h.state.jobs.set(failedStart.id, failedStart); + const failedBoot = { index: 3, status: 'offline', running: false }; + assert.ok(labels(failedBoot).includes('开机'), 'a failed boot is retried from 更多'); + h.state.jobs.clear(); + assert.ok(!labels(failedBoot).includes('开机'), 'a plain shut down instance starts from the screen'); + h.state.jobs.set(failedStart.id, failedStart); h.setView('list'); assert.ok(!labels(on).includes('关机'), 'the list view has the power button'); assert.ok(!labels(bad).includes('重试初始化')); + assert.ok(!labels(failedBoot).includes('开机')); + h.state.jobs.clear(); h.setView('card'); assert.ok(labels(on).includes('关机')); });