fix(viewer): prevent translated button overlap and restore unread chat

This commit is contained in:
coyotte508 2026-09-26 12:01:23 +02:00
commit af8beebb2c
8 changed files with 76 additions and 16 deletions

10
pnpm-lock.yaml generated
View file

@ -86,8 +86,8 @@ importers:
viewer:
dependencies:
'@boardgamers/protocol':
specifier: 0.6.0
version: 0.6.0
specifier: 0.6.1
version: 0.6.1
container-engine:
specifier: workspace:../engine
version: link:../engine
@ -1042,10 +1042,10 @@ packages:
}
engines: { node: '>=6.9.0' }
'@boardgamers/protocol@0.6.0':
'@boardgamers/protocol@0.6.1':
resolution:
{
integrity: sha512-byHV2eOOFpnQCnhLaM0LPUpT30ew1aAOuTIYxwztkVjg4NgeTyPwjU8Efmc/xi+DGCrfIjo2LTb7YlNUhmzy0g==,
integrity: sha512-/SdqqYrRUNizjGqQygR4kxTZqCOqWfj190Uj/YHI8i0pD4eNXGofZJd2QhkB63n0iSRHMvJJRJReadof151wBg==,
}
'@cspotcode/source-map-support@0.8.1':
@ -11586,7 +11586,7 @@ snapshots:
'@babel/helper-string-parser': 7.29.7
'@babel/helper-validator-identifier': 7.29.7
'@boardgamers/protocol@0.6.0':
'@boardgamers/protocol@0.6.1':
dependencies:
zod: 4.6.2

View file

@ -18,7 +18,7 @@ allowBuilds:
autoInstallPeers: false
minimumReleaseAgeExclude:
- '@boardgamers/protocol@0.2.2 || 0.3.0 || 0.3.1 || 0.3.3 || 0.4.0 || 0.4.2 || 0.5.0 || 0.6.0'
- '@boardgamers/protocol@0.2.2 || 0.3.0 || 0.3.1 || 0.3.3 || 0.4.0 || 0.4.2 || 0.5.0 || 0.6.0 || 0.6.1'
# The cli-plugin-typescript fork-ts-checker shim does a bare
# require('@vue/compiler-sfc') expecting the vue-3 parse shape ({descriptor}).

View file

@ -19,7 +19,7 @@
"preview:tutorial": "node scripts/tutorial-preview.mjs"
},
"dependencies": {
"@boardgamers/protocol": "0.6.0",
"@boardgamers/protocol": "0.6.1",
"container-engine": "workspace:../engine",
"core-js": "^3.6.5",
"lodash": "^4.17.19",

View file

@ -354,6 +354,35 @@ try {
}, state);
await assertJournalAtEnd();
assert.deepEqual(errors, [], 'no browser errors');
// Reloaded history uses BGS's saved watermark, not just live append events.
await page.locator('.bgs-game-chat').evaluate((el) => {
el.open = false;
});
await page.evaluate(() => {
window.restoredReceipts = [];
host.on('chat:read', (payload) => restoredReceipts.push(payload));
host.emit('chat:state', { canSend: true, readState: { userId: 'self', lastReadAt: 1000 } });
host.emit('chat:messages', [
{ _id: '000000010000000000000001', type: 'text', authorId: 'bob', text: 'Already read' },
{ _id: '000000020000000000000001', type: 'text', authorId: 'bob', text: 'Unread after reload' },
{ _id: '000000030000000000000001', type: 'text', authorId: 'self', text: 'My own message' },
{ _id: '000000040000000000000001', type: 'system', text: 'Game started' },
]);
});
await page.waitForFunction(() => /1 unread/.test(document.querySelector('.bgs-game-chat summary').textContent));
await page.waitForTimeout(650);
assert.equal(
await page.evaluate(() => restoredReceipts.length),
0,
'hidden chat does not mark restored history read'
);
await page.locator('.chat-shortcut').click();
await page.waitForFunction(() => restoredReceipts.length > 0);
assert.doesNotMatch(
await page.locator('.bgs-game-chat summary').textContent(),
/unread/,
'opening chat clears restored unread'
);
await checkHostPresentation(page, 'host', `/tmp/container-board-thumbnail-${width}.png`);
assert.deepEqual(errors, []);
await page.close();

View file

@ -1856,6 +1856,11 @@ text {
}
.button {
&[data-board-control]:focus-visible {
outline: 2px solid black;
outline-offset: 3px;
}
&.enabled {
cursor: pointer;

View file

@ -1,8 +1,16 @@
<template>
<g class="button enabled" @click="$emit('click')">
<g
class="button enabled"
data-board-control="log"
role="button"
aria-label="Show log"
tabindex="0"
@click="$emit('click')"
@keydown.enter.prevent="$emit('click')"
@keydown.space.prevent="$emit('click')"
>
<rect width="80" height="26" fill="gainsboro" stroke="black" rx="2" />
<image x="11" y="5" width="16" height="16" href="../../icons/log.svg" />
<text text-anchor="middle" fill="black" x="47" y="13">Log</text>
<image x="30" y="3" width="20" height="20" href="../../icons/log.svg" aria-hidden="true" />
<title>Show log</title>
</g>
</template>

View file

@ -1,8 +1,17 @@
<template>
<g :class="['button', { enabled }]" @click="enabled && $emit('click')">
<g
:class="['button', { enabled }]"
data-board-control="pass"
role="button"
aria-label="Pass turn"
:tabindex="enabled ? 0 : -1"
:aria-disabled="!enabled"
@click="enabled && $emit('click')"
@keydown.enter.prevent="enabled && $emit('click')"
@keydown.space.prevent="enabled && $emit('click')"
>
<rect width="80" height="26" fill="gainsboro" stroke="black" rx="2" />
<image x="15" y="8" width="10" height="10" href="../../icons/pass.svg" />
<text text-anchor="middle" fill="black" x="47" y="13">Pass</text>
<image x="30" y="3" width="20" height="20" href="../../icons/pass.svg" aria-hidden="true" />
<title>Pass turn</title>
</g>
</template>

View file

@ -1,8 +1,17 @@
<template>
<g :class="['button', { enabled }]" @click="enabled && $emit('click')">
<g
:class="['button', { enabled }]"
data-board-control="undo"
role="button"
aria-label="Undo last move"
:tabindex="enabled ? 0 : -1"
:aria-disabled="!enabled"
@click="enabled && $emit('click')"
@keydown.enter.prevent="enabled && $emit('click')"
@keydown.space.prevent="enabled && $emit('click')"
>
<rect width="80" height="26" fill="gainsboro" stroke="black" rx="2" />
<image x="11" y="4" width="16" height="16" href="../../icons/undo.svg" />
<text text-anchor="middle" fill="black" x="47" y="13">Undo</text>
<image x="30" y="3" width="20" height="20" href="../../icons/undo.svg" aria-hidden="true" />
<title>Undo last move</title>
</g>
</template>