feat: next action suffix in the pending SELECT ITEM panel (v3.5.6)

The STK menu overlay's cached top menu showed the card-provided Items Next
Action Indicator (TS 102 223 8.24) as a gray suffix, but the pending
SELECT ITEM list the card returns mid-dialogue did not: the server already
attaches nai_name (via _parse_select_item), the panel just had its own row
markup without the suffix.

Both lists now render through stkMenuItemsHtml(items, handler) - identical
rows (id, text, optional gray suffix) with the per-list click callback
(stkMenuItemClick / stkSubItemClick).

stk_menu.test.js: the shared renderer (suffix only with nai_name, handler
in the row, null list) plus a call-site guard for both lists.

554 frontend / 421 Python green; version 3.5.6; sw cache simple-v259.
This commit is contained in:
2026-09-25 23:05:22 +03:00
parent 31ece16ada
commit 8064625d56
5 changed files with 42 additions and 20 deletions
+22
View File
@@ -23,6 +23,7 @@ function extractFunc(src, name, asyncFn) {
let code = extractFunc(html, 'stkMenuRespond', true) + '\n';
code += extractFunc(html, 'stkMenuNaiSuffix') + '\n';
code += extractFunc(html, 'stkMenuItemsHtml') + '\n';
code += 'globalThis.esc = s => s;\n';
eval(code);
@@ -47,6 +48,27 @@ test('the STK menu item suffix shows the item next action (8.24)', () => {
assert.strictEqual(stkMenuNaiSuffix(null), '');
});
test('the overlay item list shows the next action and the row handler', () => {
const list = stkMenuItemsHtml([
{ id: 1, text: 'Menu', nai: 0x25, nai_name: 'SET UP MENU' },
{ id: 2, text: 'Info' },
], 'stkSubItemClick');
assert.match(list, /onclick="stkSubItemClick\(1\)"/);
assert.match(list, /onclick="stkSubItemClick\(2\)"/);
assert.ok(list.includes('Menu'));
assert.ok(list.includes('\u25b8 SET UP MENU'));
// the second item has no indicator -> exactly one suffix in the list
assert.strictEqual((list.match(/\u25b8/g) || []).length, 1);
assert.strictEqual(stkMenuItemsHtml(null, 'stkMenuItemClick'), '<div class="space-y-1"></div>');
});
test('both overlay lists render through the shared row helper', () => {
// the cached top menu and the pending SELECT ITEM items must use the same
// renderer, otherwise the latter silently loses the NAI suffix
assert.match(html, /stkMenuItemsHtml\(data\.items, 'stkMenuItemClick'\)/);
assert.match(html, /stkMenuItemsHtml\(data\.items, 'stkSubItemClick'\)/);
});
test('back with a fetched SELECT ITEM continues the card dialogue', async () => {
const data = { type: 'select_item', items: [{ id: 1, text: 'Info' }] };
const calls = setup(data);