diff --git a/web/public/cloud/announcements.js b/web/public/cloud/announcements.js
index c425552a..6aec472a 100644
--- a/web/public/cloud/announcements.js
+++ b/web/public/cloud/announcements.js
@@ -195,6 +195,12 @@ async function load(page = 1, source = 'manual') {
scroll.scrollTop = scrollTop;
}
setMessage('');
+ // Only a completed read advances this timestamp; pending/failed refreshes
+ // keep it visible and never replace it with progress messages.
+ const readTime = byId('panel-announcements-read-time');
+ const label = `读取于 ${new Date().toLocaleTimeString('zh-CN', { hour12: false, hour: '2-digit', minute: '2-digit', second: '2-digit' })}`;
+ if (readTime.textContent !== label) readTime.textContent = label;
+ if (readTime.hidden) readTime.hidden = false;
} catch (error) {
if (serial !== state.serial || !canRefresh() || (controller.signal.aborted && controller.signal.reason !== 'timeout')) return;
if (source !== 'auto' || !hadSnapshot) setMessage(error.message, 'error');
diff --git a/web/public/cloud/client.css b/web/public/cloud/client.css
index 92cad63a..03ae0618 100644
--- a/web/public/cloud/client.css
+++ b/web/public/cloud/client.css
@@ -48,7 +48,8 @@ html.panel-announcements-open body { position: fixed; top: var(--panel-announcem
.panel-announcements-header > div { min-width: 0; }
.panel-announcements-header h2 { margin: 0 0 7px; font-size: 19px; line-height: 1.5; font-weight: 800; }
.panel-announcements-header p { margin: 0; color: #7a8c9d; font-size: 12px; line-height: 1.7; }
-.panel-announcements-toolbar { display: flex; flex: 0 0 auto; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 14px 24px; border-bottom: 1px solid #e5edf2; background: #f8fbfc; }
+.panel-announcements-toolbar { display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 24px; border-bottom: 1px solid #e5edf2; background: #f8fbfc; }
+.panel-announcements-status { min-width: 0; display: grid; gap: 4px; }
.panel-announcements-toolbar .button { flex: 0 0 auto; min-height: 44px; margin-left: auto; }
.panel-announcements-state { margin: 0; color: #647d90; font-size: 12px; line-height: 1.8; overflow-wrap: anywhere; }
.panel-announcements-state[hidden] { display: none; }
diff --git a/web/resources/views/venix/layout_assets.tpl b/web/resources/views/venix/layout_assets.tpl
index 99cc86f8..637796fd 100644
--- a/web/resources/views/venix/layout_assets.tpl
+++ b/web/resources/views/venix/layout_assets.tpl
@@ -1,2 +1,2 @@
{* Shared Venix CSS/JS cache key. Increment whenever a shared browser asset changes. *}
-{assign var=venix_asset_version value='2026093009' scope='global'}
+{assign var=venix_asset_version value='2026093010' scope='global'}
diff --git a/web/resources/views/venix/user/announcement_drawer.tpl b/web/resources/views/venix/user/announcement_drawer.tpl
index bbae562f..e5d2cee8 100644
--- a/web/resources/views/venix/user/announcement_drawer.tpl
+++ b/web/resources/views/venix/user/announcement_drawer.tpl
@@ -3,7 +3,13 @@
diff --git a/web/tests/AnnouncementDrawerBehaviorTest.mjs b/web/tests/AnnouncementDrawerBehaviorTest.mjs
index 281bcb08..dbe71589 100644
--- a/web/tests/AnnouncementDrawerBehaviorTest.mjs
+++ b/web/tests/AnnouncementDrawerBehaviorTest.mjs
@@ -43,8 +43,9 @@ class Node {
const flush = async () => { for (let turn = 0; turn < 16; turn += 1) await Promise.resolve(); };
function fixture() {
- const names = ['drawer', 'state', 'refresh', 'more', 'count', 'list', 'scroll', 'close'];
+ const names = ['drawer', 'state', 'read-time', 'refresh', 'more', 'count', 'list', 'scroll', 'close'];
const nodes = Object.fromEntries(names.map(name => [name, new Node(name === 'drawer' ? 'dialog' : 'div')]));
+ nodes['read-time'].hidden = true;
const document = new Node(); document.visibilityState = 'visible'; document.hidden = false;
document.documentElement = new Node(); document.body = new Node();
const trigger = new Node('button'); trigger.isTrigger = true;
@@ -55,6 +56,15 @@ function fixture() {
const window = new Node(); window.scrollX = 0; window.scrollY = 125; window.scrollTo = () => {};
const history = { state: null, replaceState(value) { this.state = value; } };
let now = 0; let timerId = 0;
+ const epoch = Date.UTC(2026, 8, 30, 6, 27, 20);
+ class FakeDate extends Date {
+ constructor(...values) { super(...(values.length ? values : [epoch + now])); }
+ static now() { return epoch + now; }
+ toLocaleTimeString(locale, options) {
+ assert.equal(locale, 'zh-CN'); assert.equal(options.hour12, false);
+ return this.toISOString().slice(11, 19);
+ }
+ }
const timers = new Map(); const requests = [];
const setTimeout = (callback, delay = 0) => {
const id = ++timerId; timers.set(id, { callback, due: now + delay }); return id;
@@ -64,7 +74,7 @@ function fixture() {
});
vm.runInNewContext(source, {
document, window, history, location: { href: 'https://example.test/user/cloud' },
- URL, AbortController, fetch, setTimeout, clearTimeout: id => timers.delete(id),
+ URL, Date: FakeDate, AbortController, fetch, setTimeout, clearTimeout: id => timers.delete(id),
requestAnimationFrame: callback => setTimeout(callback, 0), console,
}, { filename: 'announcements.js' });
return {
@@ -149,6 +159,44 @@ function assertQuiet(test) {
assert.equal(articles(test).length, 0); assert.match(test.nodes.list.textContent, /暂无已发布/); assertQuiet(test);
}
+// Only a complete successful read updates the independent timestamp, never status text.
+{
+ const test = fixture(); const readTime = test.nodes['read-time'];
+ const first = Array.from({ length: 10 }, (_, index) => announcement(11 - index));
+ assert.equal(readTime.hidden, true); assert.equal(readTime.textContent, '');
+ await test.click('open'); await test.advance(2000);
+ assert.equal(readTime.hidden, true); assert.equal(readTime.textContent, '');
+ await test.respond(page(first, 1, 11));
+ assert.equal(readTime.hidden, false); assert.equal(readTime.textContent, '读取于 06:27:22'); assertQuiet(test);
+ await test.advance(1000); await test.click('more'); await test.advance(2000);
+ assert.equal(readTime.textContent, '读取于 06:27:22');
+ await test.respond(page([announcement(1)], 2, 11));
+ assert.equal(readTime.textContent, '读取于 06:27:25');
+ const renders = test.nodes.list.replacements;
+ await test.advance(30000); await test.advance(1000);
+ await test.respond(page(first, 1, 11));
+ assert.equal(readTime.textContent, '读取于 06:27:25', 'A successful first page is not a completed multi-page refresh.');
+ await test.advance(1000); await test.respond(page([announcement(1)], 2, 11));
+ assert.equal(readTime.textContent, '读取于 06:27:57');
+ assert.equal(test.nodes.list.replacements, renders, 'Updating read time must not redraw unchanged announcements.');
+ assertQuiet(test);
+ await test.advance(30000); await test.respond(page(first, 1, 11));
+ await test.advance(1000); await test.respond({ detail: '暂时不可用' }, 503);
+ assert.equal(readTime.textContent, '读取于 06:27:57', 'Failed automatic refreshes retain the last successful time.');
+ assertQuiet(test);
+ await test.click('refresh'); await test.respond(page(first, 1, 11));
+ await test.advance(1000); await test.respond({ detail: '暂时不可用' }, 503);
+ assert.equal(readTime.textContent, '读取于 06:27:57', 'Manual errors cannot be labelled as successful reads.');
+ assert.match(test.nodes.state.textContent, /暂时不可用/);
+ await test.click('refresh'); await test.respond(page(first, 1, 11));
+ await test.advance(1000); await test.respond(page([announcement(1)], 2, 11));
+ assert.equal(readTime.textContent, '读取于 06:28:30'); assertQuiet(test);
+ await test.advance(30000); const cancelled = test.requests.at(-1);
+ await test.click('close'); await test.advance(1000);
+ await test.respond(page(first, 1, 11), 200, cancelled);
+ assert.equal(readTime.textContent, '读取于 06:28:30', 'Cancelled reads never advance the displayed timestamp.');
+}
+
// Refresh the entire loaded window atomically, including edits/withdrawals on later pages.
{
const test = fixture(); const first = Array.from({ length: 10 }, (_, index) => announcement(12 - index));
@@ -198,6 +246,7 @@ function assertQuiet(test) {
const test = fixture(); await test.click('open');
await test.respond({ detail: '公告服务暂不可用' }, 503);
assert.match(test.nodes.state.textContent, /暂不可用/);
+ assert.equal(test.nodes['read-time'].hidden, true); assert.equal(test.nodes['read-time'].textContent, '');
assert.doesNotMatch(test.nodes.list.textContent, /暂无已发布/);
await test.click('refresh'); await test.respond(page([announcement(1)]));
assert.equal(articles(test).length, 1); assertQuiet(test);
@@ -264,4 +313,4 @@ function assertQuiet(test) {
await test.click('refresh'); await test.respond(page([announcement(1)])); assertQuiet(test);
}
-console.log('Announcement drawer lazy loading, silent polling, atomic pagination, cancellation and plain-text behavior passed.');
+console.log('Announcement drawer lazy loading, silent polling, successful read time, atomic pagination, cancellation and plain-text behavior passed.');
diff --git a/web/tests/UserAnnouncementDrawerViewTest.php b/web/tests/UserAnnouncementDrawerViewTest.php
index 52a7754a..d6f04730 100644
--- a/web/tests/UserAnnouncementDrawerViewTest.php
+++ b/web/tests/UserAnnouncementDrawerViewTest.php
@@ -78,6 +78,8 @@ foreach (['account' => $accountHtml, 'cloud' => $cloudHtml] as $mode => $html) {
$mode . ': routine announcement loading and refresh must not display status messages.');
$assert($xpath->query('//button[@id="panel-announcements-refresh" and not(@hidden)]')->length === 1,
$mode . ': retain the manual refresh button.');
+ $assert($xpath->query('//*[@id="panel-announcements-read-time" and @hidden and not(@role) and not(@aria-live)]')->length === 1,
+ $mode . ': show read time only after a successful response, without recurring live announcements.');
$assert($xpath->query('//link[contains(@href,"admin-home.css")]')->length === 0,
$mode . ': user shell must not load the administrator theme.');
$assert($xpath->query('//button[@id="panel-announcements-close" and @autofocus]')->length === 1,
@@ -98,7 +100,7 @@ $assert(str_contains($script, '/api/v1/announcements?page=') && !str_contains($s
&& !str_contains($script, 'from \'./runtime.js\''), 'Announcements must not depend on a VM session.');
$assert(str_contains($script, "item.status !== 'published'") && str_contains($script, 'visibilitychange'),
'Visible drawers must revalidate published content without background polling when hidden.');
-foreach (['读取于', '旧内容', '正在刷新', '正在读取最新公告', '正在加载更多公告'] as $retiredMessage) {
+foreach (['旧内容', '正在刷新', '正在读取最新公告', '正在加载更多公告'] as $retiredMessage) {
$assert(!str_contains($script, $retiredMessage), 'Retired announcement status message remains: ' . $retiredMessage);
}
$css = file_get_contents(dirname(__DIR__) . '/public/cloud/client.css');