Show completed core actions and summarize notice bursts

Tag committed ordinary movement, shipping, revival, collection, battle,
native Guild transport and HMS relocation for the existing house notices
and optional sounds. Keep pending and canceled actions free of false
completion notices and preserve richer Smuggler and card-specific labels.

Bound feedback to three 1.5-second notices including the active notice.
Summarize older pending events with an exact count and retain individual
chronicle entries. Consume stale, duplicate, muted and hidden updates
without replay; clear visible and queued feedback when the page hides.
These changes add log metadata and cosmetic presentation only.

Validation: types, lint, 5137 offline tests and production build passed.
Independent review resolved one duplicate Smuggler notice. Nine engine
regressions and six queue/cursor/component tests cover the new behavior.
Two Basic/Advanced four-player games completed with 821 legal actions,
21 JSON restores and zero rejected actions; no AI tuning was done.

Browser QA 76CMLL8Z used genuine Basic setup and private real-action batches.
A seven-event burst displayed Revival plus four earlier actions, then
drained. Chronicle navigation and silent toggle/refresh were checked;
refresh kept the saved row identical. Phone notice bounds fit without
overflow. Transient phone text and actual background visibility were not
captured; screenshot and full visual acceptance remain open.
All 1,585 prior rooms, 3,353 seats and auxiliary records stayed unchanged.
One QA room and human seat were added; no reset, restart or automation.
This commit is contained in:
Quintine committed 2026-09-21 16:06:35 +10:00
1 parent 7136c8dd19
commit a3bc0ac837
12 files changed
+495 -48

No files matched your search

+30 -26
View File
@@ -8,19 +8,14 @@ import {
useSyncExternalStore,
} from 'react';
import { Bell, BellOff } from 'lucide-react';
import { FACTIONS, type FactionId } from '@/game/catalog';
import { FACTIONS } from '@/game/catalog';
import { advanceActionNotices, type AutomaticActionEvent, type QueuedActionNotice } from '@/lib/action-notice-queue';
import { Button } from './ui/button';
export type AutomaticActionEvent = {
id: string;
seq: number;
faction: FactionId;
name: string;
};
export type { AutomaticActionEvent } from '@/lib/action-notice-queue';
const PREFERENCE_KEY = 'dune.automatic-action-notices';
const PREFERENCE_EVENT = 'dune-automatic-action-notices-preference';
const MAX_QUEUED_NOTICES = 250;
let memoryPreference: boolean | undefined;
function readPreference() {
if (memoryPreference !== undefined) return memoryPreference;
@@ -51,10 +46,10 @@ export function AutomaticActionNotice({
const seenSeq = useRef(
events.reduce((last, event) => Math.max(last, event.seq), -1),
);
const queue = useRef<AutomaticActionEvent[]>([]);
const active = useRef<AutomaticActionEvent | null>(null);
const queue = useRef<QueuedActionNotice[]>([]);
const active = useRef<QueuedActionNotice | null>(null);
const [notice, setNotice] = useState<
(AutomaticActionEvent & { fading: boolean }) | null
(QueuedActionNotice & { fading: boolean }) | null
>(null);
const [completed, setCompleted] = useState(0);
const timers = useRef<ReturnType<typeof setTimeout>[]>([]);
@@ -65,7 +60,7 @@ export function AutomaticActionNotice({
const showNext = useCallback(() => {
if (active.current) return;
if (!readPreference()) {
if (!readPreference() || document.visibilityState === 'hidden') {
queue.current = [];
return;
}
@@ -91,23 +86,29 @@ export function AutomaticActionNotice({
}, [clearTimers]);
useEffect(() => {
const fresh = events
.filter((event) => event.seq > seenSeq.current)
.toSorted((a, b) => a.seq - b.seq);
const additions: AutomaticActionEvent[] = [];
for (const event of fresh) {
if (event.seq <= seenSeq.current) continue;
seenSeq.current = event.seq;
additions.push(event);
}
// Disabled notices are consumed, so enabling cannot replay missed events.
if (!readPreference()) return;
const capacity = MAX_QUEUED_NOTICES - (active.current ? 1 : 0);
// Preserve the active notice and retain the newest pending events on overflow.
queue.current = [...queue.current, ...additions].slice(-capacity);
// Preserve the visible notice. Summarize older pending actions so a bot
// batch cannot leave minutes of stale feedback; the chronicle keeps detail.
const next = advanceActionNotices({ seenSeq: seenSeq.current, pending: queue.current }, events, {
active: !!active.current,
show: readPreference() && document.visibilityState !== 'hidden',
});
seenSeq.current = next.seenSeq;
queue.current = next.pending;
showNext();
}, [events, showNext, completed]);
useEffect(() => {
const hide = () => {
if (document.visibilityState !== 'hidden') return;
clearTimers();
queue.current = [];
active.current = null;
setNotice(null);
};
document.addEventListener('visibilitychange', hide);
return () => document.removeEventListener('visibilitychange', hide);
}, [clearTimers]);
useEffect(
() => () => {
clearTimers();
@@ -168,6 +169,9 @@ export function AutomaticActionNotice({
<span className="mt-1 block break-words text-sm font-medium leading-5">
{notice.name}
</span>
{notice.count > 1 && <span className="mt-1 block text-sm leading-5 text-[#d6cdb8]">
{notice.count - 1} earlier {notice.count === 2 ? 'action' : 'actions'} also completed. Details are in the table chronicle.
</span>}
</span>
)}
</output>