feat(web): emailgen events in Orchestrator page

The SSE pipe at /orchestrator/events/stream was already streaming
'orchestrator.email.{decky_uuid}' events (the subscription is for the
'orchestrator.>' wildcard), but the consumer side dropped them on the
floor.  Three fixes to close the loop:

* useOrchestratorStream.ts now registers an 'email' SSE listener — the
  EventSource silently ignores frames whose event name has no listener,
  so missing this entry meant every email frame was dropped before
  reaching the page's onEvent handler.

* /api/v1/orchestrator/events accepts kind=email and dispatches to
  list_orchestrator_emails, adapting rows to the existing wire shape:
  subject -> action, sender_email -> src_decky_uuid, recipient_email
  -> dst_decky_uuid, plus email-specific extras (thread_id, language,
  mail_decky_uuid, message_id, in_reply_to) ride along as top-level
  keys.

* Orchestrator.tsx gains an 'email' tab in the kind filter and a
  branch in the row renderer / inspector that:
   - shows full sender / recipient (no UUID truncation),
   - chips the language code next to the subject,
   - relabels ACTION as SUBJECT in the inspector and surfaces
     thread / in-reply-to / mail-decky details.

The 'all' tab continues to show traffic+file only (today's behavior);
operators see emails by switching to the email tab.  A union view at
the API layer is the obvious follow-up but not necessary for now.
This commit is contained in:
2026-04-26 22:56:48 -04:00
parent f97ec4c2c1
commit 818aebadfc
6 changed files with 282 additions and 31 deletions

View File

@@ -5,13 +5,22 @@ import { useToast } from './Toasts/useToast';
export interface OrchestratorInspectorEntry {
uuid: string;
ts: string;
kind: 'traffic' | 'file' | string;
kind: 'traffic' | 'file' | 'email' | string;
protocol: string;
action: string;
src_decky_uuid: string | null;
dst_decky_uuid: string;
success: boolean;
payload: string;
// Email-only extras populated when `kind === 'email'`.
subject?: string;
sender_email?: string;
recipient_email?: string;
language?: string;
thread_id?: string;
mail_decky_uuid?: string;
message_id?: string;
in_reply_to?: string | null;
}
interface Props {
@@ -52,7 +61,10 @@ const OrchestratorInspector: React.FC<Props> = ({ event, onClose }) => {
const copyEvent = () => copy(JSON.stringify(event, null, 2), 'EVENT JSON');
const copyPayload = () => copy(prettyPayload, 'PAYLOAD JSON');
const kindCls = event.kind === 'traffic' || event.kind === 'file' ? event.kind : '';
const kindCls =
event.kind === 'traffic' || event.kind === 'file' || event.kind === 'email'
? event.kind : '';
const isEmail = event.kind === 'email';
const srcSrc = sourceTag(event.src_decky_uuid);
const dstSrc = sourceTag(event.dst_decky_uuid);
const isLive = event.uuid.startsWith('live-');
@@ -87,9 +99,42 @@ const OrchestratorInspector: React.FC<Props> = ({ event, onClose }) => {
<span className="chip dim-chip">{event.protocol.toUpperCase()}</span>
</div>
<div className="k">ACTION</div>
<div className="k">{isEmail ? 'SUBJECT' : 'ACTION'}</div>
<div className="v mono matrix-text">{event.action}</div>
{isEmail && event.language && (
<>
<div className="k">LANGUAGE</div>
<div className="v">
<span className="chip dim-chip">{event.language.toUpperCase()}</span>
</div>
</>
)}
{isEmail && event.thread_id && (
<>
<div className="k">THREAD</div>
<div className="v">
<span className="hash-text">{event.thread_id}</span>
</div>
</>
)}
{isEmail && event.in_reply_to && (
<>
<div className="k">IN-REPLY-TO</div>
<div className="v">
<span className="hash-text">{event.in_reply_to}</span>
</div>
</>
)}
{isEmail && event.mail_decky_uuid && (
<>
<div className="k">MAIL DECKY</div>
<div className="v">
<span className="hash-text">{event.mail_decky_uuid}</span>
</div>
</>
)}
<div className="k">OUTCOME</div>
<div className="v">
<span className={event.success ? 'ok-yes' : 'ok-no'}>