Show per-account delivery status

This commit is contained in:
jjbrunton committed 2026-08-09 16:12:05 +01:00
1 parent 9b86cee9be
commit 22eb32e5bf
14 files changed
+402 -13

No files matched your search

@@ -1,5 +1,5 @@
import { useEffect, useReducer, useRef, useState } from 'react';
import type { ActivityItem, ChatSyncStatus, DashboardEvent } from '../../../../../packages/api-contracts/src/index.js';
import type { ActivityItem, ChatSyncStatus, DashboardEvent, RedditAccountOwner } from '../../../../../packages/api-contracts/src/index.js';
import { useDashboardRealtime } from '../../app/realtime-provider.js';
import { RedditUsernameLink } from '../../components/reddit-username-link.js';
import { RedditUserText } from '../../components/reddit-user-text.js';
@@ -72,6 +72,16 @@ function connectionLabel(snapshot: RealtimeConnectionSnapshot): string {
}
}
export function accountOwnerFromLogData(data: unknown): RedditAccountOwner | undefined {
if (!data || typeof data !== 'object' || Array.isArray(data)) return undefined;
const accountId = Reflect.get(data, 'accountId');
const redditUsername = Reflect.get(data, 'redditUsername');
return typeof accountId === 'string' && accountId.length > 0
&& typeof redditUsername === 'string' && redditUsername.length > 0
? { accountId, redditUsername }
: undefined;
}
export interface OperationsPageProps {
realtimeEnabled?: boolean;
}
@@ -175,9 +185,17 @@ export function OperationsPage({ realtimeEnabled = true }: OperationsPageProps)
</div>
{consoleClearNotice ? <p role="status">Cleared from this browser view. Server logs were not deleted.</p> : null}
<div aria-live="polite" className="live-console" role="log">
{logsQuery.isPending ? <p>Loading logs…</p> : visibleEntries.length === 0 ? <p>No logs match the current filters.</p> : visibleEntries.map((entry) => (
<article className={`console-entry ${entry.level}`} key={entry.id}><time dateTime={entry.occurredAt}>{formatTimestamp(entry.occurredAt)}</time><strong>{entry.level.toUpperCase()}</strong><span><RedditUserText>{entry.message}</RedditUserText></span></article>
))}
{logsQuery.isPending ? <p>Loading logs…</p> : visibleEntries.length === 0 ? <p>No logs match the current filters.</p> : visibleEntries.map((entry) => {
const owner = accountOwnerFromLogData(entry.data);
return (
<article className={`console-entry ${entry.level}`} key={entry.id}>
<time dateTime={entry.occurredAt}>{formatTimestamp(entry.occurredAt)}</time>
<strong>{entry.level.toUpperCase()}</strong>
<span className="console-account">{owner ? <RedditUsernameLink username={owner.redditUsername} /> : 'global'}</span>
<span><RedditUserText>{entry.message}</RedditUserText></span>
</article>
);
})}
<div ref={consoleEnd} />
</div>
</section>
@@ -21,9 +21,11 @@
.console-controls .checkbox-control { display: flex; flex-direction: row; align-items: center; }
.console-controls .checkbox-control input { min-height: auto; }
.live-console { height: min(30rem, 55vh); overflow: auto; padding: .65rem; color: #cbd8d1; background: #050906; border: 1px solid var(--border); border-radius: .6rem; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .78rem; }
.console-entry { display: grid; grid-template-columns: 11rem 3.5rem minmax(0, 1fr); gap: .65rem; padding: .35rem; border-bottom: 1px solid #142019; }
.console-entry { display: grid; grid-template-columns: 11rem 3.5rem minmax(6rem, auto) minmax(0, 1fr); gap: .65rem; padding: .35rem; border-bottom: 1px solid #142019; }
.console-entry time { color: #708178; }
.console-entry strong { color: #8da49a; }
.console-account { color: #708178; }
.console-account a { color: var(--accent); font-weight: 700; }
.console-entry.warn strong { color: var(--warning); }
.console-entry.error strong { color: var(--danger); }
.live-console > p { color: var(--muted); text-align: center; }