@octarq/plugin-mail 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/api.ts CHANGED
@@ -1,87 +1,8 @@
1
1
  // Mail feature API surface — the slice of the JSON API owned by the mail plugin.
2
2
  // Fully self-contained without relative host leaks.
3
3
 
4
- export class ApiError extends Error {
5
- status: number;
6
- body?: any;
7
- requestId?: string;
8
- constructor(status: number, message: string, body?: any, requestId?: string) {
9
- super(message);
10
- this.status = status;
11
- this.body = body;
12
- this.requestId = requestId;
13
- }
14
- }
15
-
16
- export function getAppLang(): string {
17
- try {
18
- const saved = localStorage.getItem("lang");
19
- if (saved) return saved;
20
- } catch {
21
- /* ignore */
22
- }
23
- return typeof navigator !== "undefined" ? navigator.language || "en" : "en";
24
- }
4
+ import { req } from "@octarq/plugin-sdk";
25
5
 
26
- interface ErrorEnvelope {
27
- message?: string;
28
- error?: string;
29
- detail?: string;
30
- details?: Array<string | { location?: string; message?: string }>;
31
- }
32
-
33
- export async function req<T>(method: string, path: string, body?: unknown, lang?: string): Promise<T> {
34
- const currentLang = lang || getAppLang();
35
- const headers: Record<string, string> = {
36
- "Accept-Language": currentLang,
37
- };
38
- if (body) {
39
- headers["Content-Type"] = "application/json";
40
- }
41
- const res = await fetch(path, {
42
- method,
43
- headers,
44
- body: body ? JSON.stringify(body) : undefined,
45
- });
46
- if (!res.ok) {
47
- let msg = res.statusText;
48
- let parsed: ErrorEnvelope | null = null;
49
- try {
50
- parsed = (await res.json()) as ErrorEnvelope;
51
- if (parsed?.message) {
52
- msg = parsed.message;
53
- if (parsed.details && Array.isArray(parsed.details) && parsed.details.length > 0) {
54
- const detailMsgs = parsed.details
55
- .map((d) => {
56
- if (typeof d === "string") return d;
57
- if (d?.message) {
58
- const loc = d.location ? `${d.location.replace(/^body\./, "")}: ` : "";
59
- return `${loc}${d.message}`;
60
- }
61
- return "";
62
- })
63
- .filter(Boolean)
64
- .join("; ");
65
- if (detailMsgs) msg = `${msg} (${detailMsgs})`;
66
- }
67
- } else if (parsed?.error) {
68
- msg = parsed.error;
69
- } else if (parsed?.detail) {
70
- msg = parsed.detail;
71
- }
72
- } catch {
73
- // Non-JSON error body: fall through to statusText.
74
- }
75
- const requestId = res.headers.get("x-request-id") || undefined;
76
- throw new ApiError(res.status, msg || `HTTP ${res.status}`, parsed, requestId);
77
- }
78
- if (res.status === 204) return undefined as unknown as T;
79
- const contentType = res.headers.get("content-type");
80
- if (contentType && contentType.includes("application/json")) {
81
- return (await res.json()) as T;
82
- }
83
- return (await res.text()) as unknown as T;
84
- }
85
6
 
86
7
  export interface HostEntry {
87
8
  host: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@octarq/plugin-mail",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Mailboxes, SMTP relay, and inbound webhook processing plugin for Octarq",
5
5
  "type": "module",
6
6
  "main": "./index.ts",
@@ -9,7 +9,7 @@
9
9
  ".": "./index.ts"
10
10
  },
11
11
  "peerDependencies": {
12
- "@octarq/plugin-sdk": "^0.21.0",
12
+ "@octarq/plugin-sdk": "^0.25.0",
13
13
  "react": "^18.3.1",
14
14
  "react-dom": "^18.3.1",
15
15
  "react-router-dom": "^6.28.0 || ^7.0.0"
@@ -18,7 +18,7 @@
18
18
  "lucide-react": "^1.21.0"
19
19
  },
20
20
  "devDependencies": {
21
- "@octarq/plugin-sdk": "^0.21.0",
21
+ "@octarq/plugin-sdk": "^0.25.0",
22
22
  "@types/react": "^18.3.1",
23
23
  "@types/react-dom": "^18.3.1",
24
24
  "react": "^18.3.1",
@@ -17,9 +17,9 @@ export function AuthBadges({
17
17
  const warn = result === "softfail" || result === "neutral";
18
18
  if (compact && pass) return null; // only show problems in list view
19
19
 
20
- let tone: "green" | "amber" | "red" = "red";
21
- if (pass) tone = "green";
22
- else if (warn) tone = "amber";
20
+ let tone: "success" | "warning" | "danger" = "danger";
21
+ if (pass) tone = "success";
22
+ else if (warn) tone = "warning";
23
23
 
24
24
  return (
25
25
  <Badge key={label} tone={tone} className="font-mono text-[10px] uppercase tracking-wider">
package/pages/Compose.tsx CHANGED
@@ -48,11 +48,11 @@ export function Compose({
48
48
  setLoadingSenders(true);
49
49
  (async () => {
50
50
  try {
51
- const res = await fetch("/api/integrations?provider_type=communication", {
51
+ const res = await fetch("/api/vault/items?provider_type=communication", {
52
52
  credentials: "same-origin",
53
53
  });
54
54
  if (res.status === 404) {
55
- // No Integrations Hub on this instance: the local SMTP sender
55
+ // Core Vault is unavailable on this instance: the local SMTP sender
56
56
  // registry is the only source, so offer it instead of an empty list.
57
57
  const list = await mailApi.smtpSenders();
58
58
  if (cancelled) return;
@@ -63,7 +63,8 @@ export function Compose({
63
63
  }
64
64
  if (!res.ok) throw new Error(`HTTP ${res.status}`);
65
65
  const data = await res.json();
66
- const commSenders = (Array.isArray(data) ? data : []).filter(
66
+ const raw = Array.isArray(data) ? data : (data?.body ?? []);
67
+ const commSenders = (Array.isArray(raw) ? raw : []).filter(
67
68
  (item: any) => item.provider === "smtp" || item.provider === "resend"
68
69
  );
69
70
  if (cancelled) return;
@@ -192,14 +193,18 @@ export function Compose({
192
193
  className="text-sm"
193
194
  value={String(smtpSenderId)}
194
195
  onValueChange={(v) => setSmtpSenderId(Number(v))}
195
- options={senders.map((s) => ({
196
- value: String(s.id),
197
- label: s.summary
198
- ? `${s.name} (${s.summary})`
199
- : s.fromEmail
200
- ? `${s.name} (${s.fromEmail})`
201
- : `${s.name} (${s.provider})`,
202
- }))}
196
+ options={senders.map((s) => {
197
+ const detail =
198
+ s.metadata?.fromEmail ||
199
+ s.fromEmail ||
200
+ s.summary ||
201
+ s.metadata?.smtpHost ||
202
+ s.provider;
203
+ return {
204
+ value: String(s.id),
205
+ label: detail ? `${s.name} (${detail})` : s.name,
206
+ };
207
+ })}
203
208
  />
204
209
  </Field>
205
210
  )}
@@ -224,7 +229,7 @@ export function Compose({
224
229
  />
225
230
  </Field>
226
231
  {showSuggestions && contacts.length > 0 && (
227
- <div className="absolute left-0 right-0 top-full mt-1 z-30 bg-card border border-border rounded-xl shadow-lg overflow-hidden divide-y divide-border">
232
+ <div className="absolute left-0 right-0 top-full mt-1 z-30 bg-card border border-border rounded-lg shadow-lg overflow-hidden divide-y divide-border">
228
233
  {contacts.map((c) => (
229
234
  <button
230
235
  key={c.id}
@@ -10,11 +10,11 @@ interface EmailListItemProps {
10
10
  onSelect: () => void;
11
11
  }
12
12
 
13
- const CATEGORY_META: Record<string, { tone: "amber" | "cyan" | "red" | "neutral"; label: string }> = {
14
- bill: { tone: "amber", label: "Bill" },
15
- otp: { tone: "cyan", label: "OTP" },
16
- marketing: { tone: "neutral", label: "Marketing" },
17
- important: { tone: "red", label: "Important" },
13
+ const CATEGORY_META: Record<string, { tone: "warning" | "info" | "danger" | "default"; label: string }> = {
14
+ bill: { tone: "warning", label: "Bill" },
15
+ otp: { tone: "info", label: "OTP" },
16
+ marketing: { tone: "default", label: "Marketing" },
17
+ important: { tone: "danger", label: "Important" },
18
18
  };
19
19
 
20
20
  function renderImportanceDots(n?: number) {
@@ -1,4 +1,4 @@
1
- import { GlassCard, Empty, Button, Input, ListSkeleton, useTranslation } from "@octarq/plugin-sdk";
1
+ import { PageCard, Empty, Button, Input, Skeleton, useTranslation } from "@octarq/plugin-sdk";
2
2
  import { Search, X, Mail as MailIcon, Inbox } from "lucide-react";
3
3
  import { Email, Mailbox } from "../api";
4
4
  import { MailFolder } from "./types";
@@ -56,15 +56,31 @@ export function EmailListPane({
56
56
  )}
57
57
  </div>
58
58
 
59
- <GlassCard className="flex-1 overflow-hidden">
59
+ <PageCard className="mt-0 flex-1 overflow-hidden p-0">
60
60
  {emails.length === 0 && loading ? (
61
- <ListSkeleton rows={7} ariaLabel={t("mail.loading")} />
61
+ <div
62
+ role="status"
63
+ aria-busy="true"
64
+ aria-label={t("mail.loading")}
65
+ className="divide-y divide-border"
66
+ >
67
+ {Array.from({ length: 7 }).map((_, i) => (
68
+ <div key={i} className="flex flex-col gap-1.5 p-3.5">
69
+ <div className="flex items-center justify-between gap-2">
70
+ <Skeleton className="h-3.5 w-36" />
71
+ <Skeleton className="h-3 w-12" />
72
+ </div>
73
+ <Skeleton className="h-3.5 w-4/5" />
74
+ <Skeleton className="h-3 w-3/5" />
75
+ </div>
76
+ ))}
77
+ </div>
62
78
  ) : (
63
79
  <div className="max-h-[650px] divide-y divide-border overflow-y-auto" onScroll={onScroll}>
64
80
  {emails.length === 0 ? (
65
81
  q ? (
66
82
  <div className="flex flex-col items-center gap-2.5 px-6 py-10 text-center">
67
- <div className="flex h-10 w-10 items-center justify-center rounded-xl bg-muted text-muted-foreground">
83
+ <div className="flex h-10 w-10 items-center justify-center rounded-lg bg-muted text-muted-foreground">
68
84
  <Search className="h-4 w-4" />
69
85
  </div>
70
86
  <p className="text-[13px] text-muted-foreground">
@@ -112,12 +128,25 @@ export function EmailListPane({
112
128
  onSelect={() => onOpenEmail(e)}
113
129
  />
114
130
  ))}
115
- {loading && <div className="p-3 text-center text-xs text-muted-foreground">{t("mail.loading")}</div>}
131
+ {loading && (
132
+ <div
133
+ role="status"
134
+ aria-busy="true"
135
+ aria-label={t("mail.loading")}
136
+ className="flex flex-col gap-1.5 p-3.5"
137
+ >
138
+ <div className="flex items-center justify-between gap-2">
139
+ <Skeleton className="h-3.5 w-32" />
140
+ <Skeleton className="h-3 w-12" />
141
+ </div>
142
+ <Skeleton className="h-3.5 w-3/4" />
143
+ </div>
144
+ )}
116
145
  </>
117
146
  )}
118
147
  </div>
119
148
  )}
120
- </GlassCard>
149
+ </PageCard>
121
150
  </div>
122
151
  );
123
152
  }
@@ -1,4 +1,4 @@
1
- import { Field, Input, GlassCard, Badge, Button, toast, confirmDialog, useTranslation, roleSatisfies, useCurrentRole } from "@octarq/plugin-sdk";
1
+ import { Field, Input, PageCard, Badge, Button, toast, confirmDialog, useTranslation, roleSatisfies, useCurrentRole } from "@octarq/plugin-sdk";
2
2
  import { useEffect, useState } from "react";
3
3
  import { mailApi, Attachment, Email } from "../api";
4
4
  import { Paperclip, Trash2, Reply, Download, X, Sparkles, ExternalLink, ShieldAlert, ArchiveRestore, Edit3, Copy, KeyRound } from "lucide-react";
@@ -16,11 +16,11 @@ function parseAttachments(json: string): Attachment[] {
16
16
  }
17
17
  }
18
18
 
19
- const CATEGORY_META: Record<string, { tone: "amber" | "cyan" | "red" | "neutral"; label: string }> = {
20
- bill: { tone: "amber", label: "Bill" },
21
- otp: { tone: "cyan", label: "OTP" },
22
- marketing: { tone: "neutral", label: "Marketing" },
23
- important: { tone: "red", label: "Important" },
19
+ const CATEGORY_META: Record<string, { tone: "warning" | "info" | "danger" | "default"; label: string }> = {
20
+ bill: { tone: "warning", label: "Bill" },
21
+ otp: { tone: "info", label: "OTP" },
22
+ marketing: { tone: "default", label: "Marketing" },
23
+ important: { tone: "danger", label: "Important" },
24
24
  };
25
25
 
26
26
  function renderImportanceDots(n?: number) {
@@ -89,7 +89,7 @@ export function EmailViewForm({
89
89
  }
90
90
 
91
91
  return (
92
- <GlassCard className="flex flex-col h-full max-h-full min-h-0">
92
+ <PageCard className="mt-0 flex flex-col h-full max-h-full min-h-0 p-0">
93
93
  <div className="p-5 border-b border-border flex justify-between items-start shrink-0 gap-4">
94
94
  <div className="flex-1 min-w-0">
95
95
  <h2 className="text-lg font-bold text-foreground mb-2 leading-snug">{email.subject || t("mail.noSubject")}</h2>
@@ -116,7 +116,7 @@ export function EmailViewForm({
116
116
  {(email.otp || (email.category === "otp" && email.subject.match(/\b([A-Z0-9]{4,8})\b/i)?.[1])) && (
117
117
  <div
118
118
  data-testid="otp-copy-bar"
119
- className="mx-5 mt-3 flex items-center justify-between gap-3 px-4 py-2.5 bg-accent-soft border border-primary/20 rounded-xl text-xs shrink-0"
119
+ className="mx-5 mt-3 flex items-center justify-between gap-3 px-4 py-2.5 bg-accent-soft border border-primary/20 rounded-lg text-xs shrink-0"
120
120
  >
121
121
  <div className="flex items-center gap-2.5">
122
122
  <KeyRound className="h-4 w-4 text-accent-fg shrink-0" />
@@ -142,7 +142,7 @@ export function EmailViewForm({
142
142
  )}
143
143
 
144
144
  {email.unsubscribeUrl && (
145
- <div className="mx-5 mt-3 flex items-center justify-between gap-3 px-3.5 py-2 bg-warning-bg border border-warning-border rounded-xl text-xs shrink-0">
145
+ <div className="mx-5 mt-3 flex items-center justify-between gap-3 px-3.5 py-2 bg-warning-bg border border-warning-border rounded-lg text-xs shrink-0">
146
146
  <span className="text-warning-fg font-medium truncate">{t("mail.unsubscribe")}</span>
147
147
  <Button
148
148
  variant="outline"
@@ -159,7 +159,7 @@ export function EmailViewForm({
159
159
  )}
160
160
 
161
161
  {(summary || email.summary) && (
162
- <div className="mx-5 mt-4 rounded-xl bg-info-bg border border-info-border p-3.5 shrink-0" data-testid="email-summary-box">
162
+ <div className="mx-5 mt-4 rounded-lg bg-info-bg border border-info-border p-3.5 shrink-0" data-testid="email-summary-box">
163
163
  <div className="flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wider text-accent-fg mb-1.5">
164
164
  <Sparkles className="h-3 w-3" />
165
165
  {t("mail.aiSummaryTitle")}
@@ -170,7 +170,8 @@ export function EmailViewForm({
170
170
 
171
171
  <div className="flex-1 overflow-y-auto p-5 min-h-[400px] bg-well">
172
172
  {email.html ? (
173
- <iframe srcDoc={email.html} className="h-full min-h-[400px] w-full bg-white rounded-xl shadow-inner border-0" sandbox="" title={t("mail.iframeTitle")} />
173
+ /* ui-color-ok: HTML emails assume a light paper viewport */
174
+ <iframe srcDoc={email.html} className="h-full min-h-[400px] w-full rounded-lg border border-border bg-white" sandbox="" title={t("mail.iframeTitle")} />
174
175
  ) : (
175
176
  <pre className="whitespace-pre-wrap break-words font-sans text-sm text-foreground leading-relaxed">{email.text}</pre>
176
177
  )}
@@ -184,7 +185,7 @@ export function EmailViewForm({
184
185
  <Paperclip className="h-3 w-3 text-accent-fg" />
185
186
  {a.filename || t("mail.attachmentFallback")} <span className="font-mono tnum">({Math.max(1, Math.round(a.size / 1024))} KB)</span>
186
187
  {a.truncated && (
187
- <Badge tone="amber" className="font-mono text-[10px] uppercase tracking-wider ml-1">
188
+ <Badge tone="warning" className="font-mono text-[10px] uppercase tracking-wider ml-1">
188
189
  {t("mail.truncated")}
189
190
  </Badge>
190
191
  )}
@@ -277,6 +278,6 @@ export function EmailViewForm({
277
278
  </div>
278
279
  </div>
279
280
  </div>
280
- </GlassCard>
281
+ </PageCard>
281
282
  );
282
283
  }
@@ -20,6 +20,7 @@ export function FolderNav({ currentFolder, onSelectFolder }: FolderNavProps) {
20
20
 
21
21
  return (
22
22
  <TabBar
23
+ className="flex-wrap"
23
24
  size="sm"
24
25
  value={currentFolder}
25
26
  onValueChange={(v) => onSelectFolder(v as MailFolder)}
@@ -1,4 +1,4 @@
1
- import { Field, Input, Textarea, Switch, Button, Panel, toast, useTranslation } from "@octarq/plugin-sdk";
1
+ import { Field, Input, Textarea, Switch, Button, PageSection, PageCard, PageRows, PageRow, Separator, Skeleton, toast, useTranslation } from "@octarq/plugin-sdk";
2
2
  import { useCallback, useEffect, useState } from "react";
3
3
  import { mailApi, MailSettingsData } from "../api";
4
4
 
@@ -75,61 +75,100 @@ export function MailSettings() {
75
75
  setTimeout(() => setCopied(false), 1500);
76
76
  }
77
77
 
78
- if (!s) return <div className="text-sm text-muted-foreground">{t("settings.loadingLower")}</div>;
78
+ if (!s) {
79
+ return (
80
+ <div role="status" aria-busy="true" aria-label={t("settings.loadingLower")}>
81
+ <PageSection className="mt-0" title={t("settings.inboundMailboxesSettings")}>
82
+ <PageCard className="space-y-5">
83
+ <div className="space-y-2">
84
+ <Skeleton className="h-3.5 w-36" />
85
+ <Skeleton className="h-16 w-full rounded-lg" />
86
+ </div>
87
+ <div className="space-y-2">
88
+ <Skeleton className="h-3.5 w-40" />
89
+ <Skeleton className="h-9 w-full rounded-lg" />
90
+ </div>
91
+ <div className="space-y-2">
92
+ <Skeleton className="h-3.5 w-32" />
93
+ <Skeleton className="h-9 w-full rounded-lg" />
94
+ </div>
95
+ </PageCard>
96
+ <PageRows>
97
+ <div data-slot="page-row" className="flex min-h-[var(--row-height,3.5rem)] items-center justify-between gap-4 px-4 py-3">
98
+ <div className="flex-1 space-y-1.5">
99
+ <Skeleton className="h-4 w-36" />
100
+ <Skeleton className="h-3 w-64" />
101
+ </div>
102
+ <Skeleton className="h-6 w-11 shrink-0 rounded-full" />
103
+ </div>
104
+ <Separator />
105
+ <div data-slot="page-row" className="flex min-h-[var(--row-height,3.5rem)] items-center justify-between gap-4 px-4 py-3">
106
+ <div className="flex-1 space-y-1.5">
107
+ <Skeleton className="h-4 w-40" />
108
+ <Skeleton className="h-3 w-56" />
109
+ </div>
110
+ <Skeleton className="h-6 w-11 shrink-0 rounded-full" />
111
+ </div>
112
+ </PageRows>
113
+ </PageSection>
114
+ </div>
115
+ );
116
+ }
79
117
 
80
118
  const displayed = tokenLoaded && revealed ? inboundToken : MASK;
81
119
 
82
120
  return (
83
- <Panel title={t("settings.inboundMailboxesSettings")} className="space-y-6">
84
- <Field label={t("settings.reservedMailboxesLabel")} hint={t("settings.reservedMailboxesHint")}>
85
- <Textarea className="font-mono text-xs" rows={2} value={reservedMailboxes} onChange={(e) => setReservedMailboxes(e.target.value)} placeholder="admin&#10;postmaster" />
86
- </Field>
87
- {adminView && (
88
- <>
89
- <Field label={t("settings.inboundWebhookUrlLabel")} hint={t("settings.inboundWebhookUrlHint")}>
90
- <Input
91
- readOnly
92
- className="font-mono text-xs"
93
- value={`${location.origin}/api/v1/webhook/${s?.orgSlug || ""}/email/inbound/${displayed}`}
94
- onFocus={(e) => e.currentTarget.select()}
95
- />
96
- </Field>
97
- <Field label={t("settings.inboundTokenLabel")} hint={t("settings.inboundTokenHint")}>
98
- <div className="flex gap-2">
121
+ <PageSection className="mt-0" title={t("settings.inboundMailboxesSettings")}>
122
+ <PageCard className="space-y-5">
123
+ <Field label={t("settings.reservedMailboxesLabel")} hint={t("settings.reservedMailboxesHint")}>
124
+ <Textarea className="font-mono text-xs" rows={2} value={reservedMailboxes} onChange={(e) => setReservedMailboxes(e.target.value)} placeholder="admin&#10;postmaster" />
125
+ </Field>
126
+ {adminView && (
127
+ <>
128
+ <Field label={t("settings.inboundWebhookUrlLabel")} hint={t("settings.inboundWebhookUrlHint")}>
99
129
  <Input
130
+ readOnly
100
131
  className="font-mono text-xs"
101
- value={displayed}
102
- readOnly={!revealed || !tokenLoaded}
103
- onChange={(e) => setInboundToken(e.target.value)}
104
- placeholder={t("settings.inboundTokenPlaceholder")}
132
+ value={`${location.origin}/api/v1/webhook/${s?.orgSlug || ""}/email/inbound/${displayed}`}
133
+ onFocus={(e) => e.currentTarget.select()}
105
134
  />
106
- <Button variant="outline" className="shrink-0 text-xs" onClick={reveal}>
107
- {revealed ? t("settings.inboundTokenHide") : t("settings.inboundTokenReveal")}
108
- </Button>
109
- <Button variant="subtle" className="shrink-0 text-xs" onClick={copyToken}>
110
- {copied ? t("uiCommon.copied") : t("settings.inboundTokenCopy")}
111
- </Button>
112
- </div>
113
- </Field>
114
- </>
115
- )}
116
- <div className="flex items-center gap-3 border-t border-border pt-4">
117
- <Switch checked={catchAll} onCheckedChange={setCatchAll} aria-label={t("settings.enableCatchAll")} />
118
- <div>
119
- <span className="block select-none text-xs font-semibold text-muted-foreground">{t("settings.enableCatchAll")}</span>
120
- <span className="select-none text-[10px] text-muted-foreground">{t("settings.enableCatchAllDesc")}</span>
121
- </div>
122
- </div>
123
- <div className="flex items-center gap-3 border-t border-border pt-4">
124
- <Switch checked={autoWrap} onCheckedChange={setAutoWrap} aria-label={t("settings.autoWrapLinks")} />
125
- <div>
126
- <span className="block select-none text-xs font-semibold text-muted-foreground">{t("settings.autoWrapLinks")}</span>
127
- <span className="select-none text-[10px] text-muted-foreground">{t("settings.autoWrapLinksDesc")}</span>
128
- </div>
129
- </div>
130
- <div className="border-t border-border pt-4 flex justify-end">
135
+ </Field>
136
+ <Field label={t("settings.inboundTokenLabel")} hint={t("settings.inboundTokenHint")}>
137
+ <div className="flex gap-2">
138
+ <Input
139
+ className="font-mono text-xs"
140
+ value={displayed}
141
+ readOnly={!revealed || !tokenLoaded}
142
+ onChange={(e) => setInboundToken(e.target.value)}
143
+ placeholder={t("settings.inboundTokenPlaceholder")}
144
+ />
145
+ <Button variant="outline" className="shrink-0 text-xs" onClick={reveal}>
146
+ {revealed ? t("settings.inboundTokenHide") : t("settings.inboundTokenReveal")}
147
+ </Button>
148
+ <Button variant="subtle" className="shrink-0 text-xs" onClick={copyToken}>
149
+ {copied ? t("uiCommon.copied") : t("settings.inboundTokenCopy")}
150
+ </Button>
151
+ </div>
152
+ </Field>
153
+ </>
154
+ )}
155
+ </PageCard>
156
+ <PageRows>
157
+ <PageRow
158
+ title={t("settings.enableCatchAll")}
159
+ description={t("settings.enableCatchAllDesc")}
160
+ control={<Switch checked={catchAll} onCheckedChange={setCatchAll} aria-label={t("settings.enableCatchAll")} />}
161
+ />
162
+ <Separator />
163
+ <PageRow
164
+ title={t("settings.autoWrapLinks")}
165
+ description={t("settings.autoWrapLinksDesc")}
166
+ control={<Switch checked={autoWrap} onCheckedChange={setAutoWrap} aria-label={t("settings.autoWrapLinks")} />}
167
+ />
168
+ </PageRows>
169
+ <div className="mt-4 flex justify-end">
131
170
  <Button variant="primary" className="text-xs" onClick={save} disabled={busy}>{busy ? t("settings.saving") : t("settings.saveSettings")}</Button>
132
171
  </div>
133
- </Panel>
172
+ </PageSection>
134
173
  );
135
174
  }
@@ -12,7 +12,7 @@ export function MailTabs({ tab, onTabChange }: MailTabsProps) {
12
12
 
13
13
  return (
14
14
  <TabBar
15
- className="mb-6"
15
+ className="mb-6 flex-wrap"
16
16
  value={tab}
17
17
  onValueChange={(v) => onTabChange(v as MailTab)}
18
18
  items={[
@@ -41,6 +41,7 @@ export function MailboxBar({
41
41
  <div className="flex flex-wrap items-center justify-between gap-3">
42
42
  <div className="min-w-0 flex-1">
43
43
  <TabBar
44
+ className="flex-wrap"
44
45
  size="sm"
45
46
  value={active === undefined ? "all" : String(active)}
46
47
  onValueChange={(v) => onSelect(v === "all" ? undefined : Number(v))}
@@ -1,4 +1,4 @@
1
- import { Code, Field, Input, Textarea, Guide, Modal, Switch, timeAgo, ScreenWrap, PageHeader, GlassCard, Badge, Button, Select, Alert, confirmDialog, FormError, useTranslation, roleSatisfies, useCurrentRole } from "@octarq/plugin-sdk";
1
+ import { Code, Field, Input, Textarea, Guide, Modal, Switch, timeAgo, Badge, Button, Select, Alert, confirmDialog, FormError, useTranslation, roleSatisfies, useCurrentRole } from "@octarq/plugin-sdk";
2
2
  import { useEffect, useState } from "react";
3
3
  import { useSearchParams } from "react-router-dom";
4
4
  import { mailApi, Attachment, Email, Mailbox } from "../api";
@@ -1,15 +1,26 @@
1
- import { Empty, Field, Input, Modal, Badge, Button, Panel, toast, confirmDialog, FormError, useTranslation, roleSatisfies, useCurrentRole } from "@octarq/plugin-sdk";
2
- import { useEffect, useState } from "react";
1
+ import { Empty, Field, Input, Modal, Badge, StatusBadge, Button, PageSection, PageRows, Separator, Skeleton, toast, confirmDialog, FormError, useTranslation, roleSatisfies, useCurrentRole } from "@octarq/plugin-sdk";
2
+ import { Fragment, useEffect, useState } from "react";
3
3
  import { NavLink } from "react-router-dom";
4
4
  import { mailApi, SMTPSender } from "../api";
5
5
  import { KeyRound, Send, Blocks } from "lucide-react";
6
6
 
7
- // Which registry owns the sender rows. An instance with the Integrations Hub
8
- // mounted uses hub credentials; a standalone Core instance has no hub and uses
7
+ // Which registry owns the sender rows. An instance with Core Vault
8
+ // mounted uses vault items; a standalone instance without vault uses
9
9
  // the local mail_smtp_senders table. The two registries number rows
10
10
  // independently, so a page must read exactly one of them.
11
11
  type SenderMode = "integration" | "local" | null;
12
12
 
13
+ function formatIntegrationSenderSummary(s: any): string {
14
+ const fromEmail = s.metadata?.fromEmail || s.fromEmail;
15
+ const host = s.metadata?.smtpHost || s.host;
16
+ const port = s.metadata?.smtpPort || s.port || 587;
17
+ if (fromEmail && host) return `${fromEmail} via ${host}:${port}`;
18
+ if (s.summary) return s.summary;
19
+ if (fromEmail) return fromEmail;
20
+ if (host) return `${host}:${port}`;
21
+ return s.metadata?.fromName || s.provider || s.name || "";
22
+ }
23
+
13
24
  export function SMTPSenders() {
14
25
  const { t } = useTranslation();
15
26
  const { role, isInstanceAdmin } = useCurrentRole();
@@ -24,7 +35,7 @@ export function SMTPSenders() {
24
35
  async function load() {
25
36
  setLoading(true);
26
37
  try {
27
- const res = await fetch("/api/integrations?provider_type=communication", {
38
+ const res = await fetch("/api/vault/items?provider_type=communication", {
28
39
  credentials: "same-origin",
29
40
  });
30
41
  if (res.status === 404) {
@@ -38,9 +49,10 @@ export function SMTPSenders() {
38
49
  return;
39
50
  }
40
51
  const data = await res.json();
52
+ const raw = Array.isArray(data) ? data : (data?.body ?? []);
41
53
  setMode("integration");
42
54
  setSenders(
43
- (Array.isArray(data) ? data : []).filter(
55
+ (Array.isArray(raw) ? raw : []).filter(
44
56
  (item: any) => item.provider === "smtp" || item.provider === "resend"
45
57
  )
46
58
  );
@@ -70,7 +82,7 @@ export function SMTPSenders() {
70
82
  await mailApi.testSMTPSender(sender.id);
71
83
  toast.success(t("settings.smtpTestSent", { to: sender.fromEmail }));
72
84
  } else {
73
- const res = await fetch(`/api/integrations/${sender.id}/test`, {
85
+ const res = await fetch(`/api/vault/items/${sender.id}/test`, {
74
86
  method: "POST",
75
87
  credentials: "same-origin",
76
88
  });
@@ -88,7 +100,8 @@ export function SMTPSenders() {
88
100
  }
89
101
 
90
102
  return (
91
- <Panel
103
+ <PageSection
104
+ className="mt-0"
92
105
  title={t("settings.smtpOutgoingGateways")}
93
106
  description={t("settings.smtpOutgoingGatewaysDesc")}
94
107
  action={
@@ -107,7 +120,7 @@ export function SMTPSenders() {
107
120
  >
108
121
 
109
122
  {mode === "integration" && (
110
- <div className="flex items-center justify-between p-3 rounded-lg border border-primary/20 bg-accent-soft text-xs text-foreground">
123
+ <div className="mt-3 flex items-center justify-between p-3 rounded-lg border border-primary/20 bg-accent-soft text-xs text-foreground">
111
124
  <div className="flex items-center gap-2">
112
125
  <Blocks className="h-4 w-4 text-accent-fg shrink-0" />
113
126
  <span>{t("settings.integrationsHubBanner")}</span>
@@ -122,76 +135,106 @@ export function SMTPSenders() {
122
135
  )}
123
136
 
124
137
  {loading ? (
125
- <div className="text-muted-foreground text-sm py-6 text-center">{t("settings.loadingLower")}</div>
138
+ <div role="status" aria-busy="true" aria-label={t("settings.loadingLower")}>
139
+ <PageRows>
140
+ {Array.from({ length: 3 }).map((_, i) => (
141
+ <Fragment key={i}>
142
+ {i > 0 && <Separator />}
143
+ <div
144
+ data-slot="page-row"
145
+ className="flex min-h-[var(--row-height,3.5rem)] items-center justify-between gap-4 px-4 py-3"
146
+ >
147
+ <div className="flex-1 space-y-1.5">
148
+ <div className="flex items-center gap-2">
149
+ <Skeleton className="h-4 w-36" />
150
+ <Skeleton className="h-4 w-16 rounded-full" />
151
+ </div>
152
+ <Skeleton className="h-3 w-56" />
153
+ </div>
154
+ <div className="flex shrink-0 items-center gap-2">
155
+ <Skeleton className="h-7 w-14 rounded-lg" />
156
+ <Skeleton className="h-7 w-20 rounded-lg" />
157
+ </div>
158
+ </div>
159
+ </Fragment>
160
+ ))}
161
+ </PageRows>
162
+ </div>
126
163
  ) : senders.length === 0 ? (
127
164
  // The heading carries the add/open control, so the empty state states
128
165
  // the fact and adds no second button.
129
- <Empty reason={t("settings.noSmtpSenders")}>
166
+ <Empty reason={t("settings.noSmtpSenders")} className="mt-3">
130
167
  <Send />
131
168
  </Empty>
132
169
  ) : (
133
- <div className="divide-y divide-border border border-border rounded-xl bg-well overflow-hidden">
134
- {senders.map(s => (
135
- <div key={s.id} className="flex items-center justify-between p-4 group">
136
- <div>
137
- <div className="font-semibold text-sm text-foreground flex items-center gap-1.5">
138
- {s.name}
139
- {mode === "integration" ? (
140
- <>
141
- <Badge tone={s.provider === "resend" ? "indigo" : "cyan"} className="uppercase tracking-wider text-[10px]">
142
- {s.provider}
143
- </Badge>
144
- {s.configured ?? true
145
- ? <Badge tone="green" className="text-[10px]"><KeyRound className="h-2.5 w-2.5 mr-0.5 inline" />{t("settings.smtpPasswordSet")}</Badge>
146
- : <Badge tone="amber" className="text-[10px]">{t("settings.smtpNoPassword")}</Badge>}
147
- </>
148
- ) : (
149
- s.passSet
150
- ? <Badge tone="green" className="text-[10px]"><KeyRound className="h-2.5 w-2.5 mr-0.5 inline" />{t("settings.smtpPasswordSet")}</Badge>
151
- : <Badge tone="amber" className="text-[10px]">{t("settings.smtpNoPassword")}</Badge>
152
- )}
153
- </div>
154
- <div className="text-xs text-muted-foreground mt-1 font-mono">
155
- {mode === "integration"
156
- ? (s.summary || `${s.fromEmail} via ${s.host}:${s.port || 587}`)
157
- : `${s.fromEmail} via ${s.host}:${s.port}`}
170
+ <PageRows>
171
+ {senders.map((s, idx) => (
172
+ <Fragment key={s.id}>
173
+ {idx > 0 && <Separator />}
174
+ <div
175
+ data-slot="page-row"
176
+ className="flex min-h-[var(--row-height,3.5rem)] items-center justify-between gap-4 px-4 py-3 group"
177
+ >
178
+ <div className="min-w-0">
179
+ <div className="font-semibold text-sm text-foreground flex flex-wrap items-center gap-1.5">
180
+ {s.name}
181
+ {mode === "integration" ? (
182
+ <>
183
+ <Badge tone={s.provider === "resend" ? "secondary" : "info"} className="uppercase tracking-wider text-[10px]">
184
+ {s.provider}
185
+ </Badge>
186
+ {s.configured ?? true
187
+ ? <StatusBadge tone="success" className="text-[10px]"><KeyRound className="h-2.5 w-2.5 mr-0.5 inline" />{t("settings.smtpPasswordSet")}</StatusBadge>
188
+ : <StatusBadge tone="warning" className="text-[10px]">{t("settings.smtpNoPassword")}</StatusBadge>}
189
+ </>
190
+ ) : (
191
+ s.passSet
192
+ ? <StatusBadge tone="success" className="text-[10px]"><KeyRound className="h-2.5 w-2.5 mr-0.5 inline" />{t("settings.smtpPasswordSet")}</StatusBadge>
193
+ : <StatusBadge tone="warning" className="text-[10px]">{t("settings.smtpNoPassword")}</StatusBadge>
194
+ )}
195
+ </div>
196
+ <div className="text-xs text-muted-foreground mt-1 font-mono">
197
+ {mode === "integration"
198
+ ? formatIntegrationSenderSummary(s)
199
+ : `${s.fromEmail} via ${s.host}:${s.port}`}
200
+ </div>
158
201
  </div>
202
+ {canManageSMTP && (
203
+ <div className="flex shrink-0 items-center gap-2">
204
+ <Button
205
+ variant="subtle"
206
+ onClick={() => test(s)}
207
+ disabled={testingId === s.id}
208
+ className="text-xs py-1 px-2.5"
209
+ >
210
+ {testingId === s.id ? t("settings.testing") : t("settings.test")}
211
+ </Button>
212
+ {mode === "integration" ? (
213
+ <NavLink to="/settings/integrations?category=communication">
214
+ <Button variant="subtle" className="text-xs py-1 px-2.5">
215
+ {t("settings.openIntegrationsHub")}
216
+ </Button>
217
+ </NavLink>
218
+ ) : (
219
+ <>
220
+ <Button variant="subtle" onClick={() => setEditing(s)} className="text-xs py-1 px-2.5">
221
+ {t("settings.editSmtp")}
222
+ </Button>
223
+ <Button
224
+ variant="danger"
225
+ onClick={() => remove(s.id)}
226
+ className="text-xs py-1 px-2.5 border-0"
227
+ >
228
+ {t("settings.remove")}
229
+ </Button>
230
+ </>
231
+ )}
232
+ </div>
233
+ )}
159
234
  </div>
160
- {canManageSMTP && (
161
- <div className="flex items-center gap-2">
162
- <Button
163
- variant="subtle"
164
- onClick={() => test(s)}
165
- disabled={testingId === s.id}
166
- className="text-xs py-1 px-2.5"
167
- >
168
- {testingId === s.id ? t("settings.testing") : t("settings.test")}
169
- </Button>
170
- {mode === "integration" ? (
171
- <NavLink to="/settings/integrations?category=communication">
172
- <Button variant="subtle" className="text-xs py-1 px-2.5">
173
- {t("settings.openIntegrationsHub")}
174
- </Button>
175
- </NavLink>
176
- ) : (
177
- <>
178
- <Button variant="subtle" onClick={() => setEditing(s)} className="text-xs py-1 px-2.5">
179
- {t("settings.editSmtp")}
180
- </Button>
181
- <Button
182
- variant="danger"
183
- onClick={() => remove(s.id)}
184
- className="text-xs py-1 px-2.5 border-0"
185
- >
186
- {t("settings.remove")}
187
- </Button>
188
- </>
189
- )}
190
- </div>
191
- )}
192
- </div>
235
+ </Fragment>
193
236
  ))}
194
- </div>
237
+ </PageRows>
195
238
  )}
196
239
  {(creating || editing) && (
197
240
  <SMTPSenderModal
@@ -200,7 +243,7 @@ export function SMTPSenders() {
200
243
  onSaved={() => { setCreating(false); setEditing(null); load(); }}
201
244
  />
202
245
  )}
203
- </Panel>
246
+ </PageSection>
204
247
  );
205
248
  }
206
249
 
@@ -1,4 +1,4 @@
1
- import { Button, Modal, Field, Input, Badge, Empty, Panel, confirmDialog, timeAgo, Table, THead, TBody, TR, TH, TD, FormError, useTranslation } from "@octarq/plugin-sdk";
1
+ import { Button, Modal, Field, Input, Badge, Empty, Panel, confirmDialog, timeAgo, Table, THead, TBody, TR, TH, TD, TableSkeleton, FormError, useTranslation } from "@octarq/plugin-sdk";
2
2
  import { useEffect, useState } from "react";
3
3
  import { mailApi, MailSuppression } from "../api";
4
4
  import { Plus, Trash2, ShieldAlert } from "lucide-react";
@@ -76,7 +76,9 @@ export function SuppressionList() {
76
76
  >
77
77
 
78
78
  {loading && items.length === 0 ? (
79
- <div className="p-8 text-center text-xs text-muted-foreground">{t("mail.loading")}</div>
79
+ <div className="overflow-x-auto border border-border rounded-lg">
80
+ <TableSkeleton columnsCount={5} rowsCount={5} ariaLabel={t("mail.loading")} />
81
+ </div>
80
82
  ) : items.length === 0 ? (
81
83
  <Empty reason={t("mail.noSuppressions")}>
82
84
  <ShieldAlert />
@@ -39,8 +39,30 @@ const mockIntegrations = [
39
39
  provider: "smtp",
40
40
  providerType: "communication",
41
41
  configured: true,
42
- summary: "noreply@acme.com via smtp.mailgun.org:587",
43
42
  isDefault: true,
43
+ metadata: {
44
+ fromEmail: "noreply@acme.com",
45
+ fromName: "Acme Mail",
46
+ smtpHost: "smtp.mailgun.org",
47
+ smtpPort: 587,
48
+ },
49
+ },
50
+ {
51
+ id: 2,
52
+ name: "Transactional Resend",
53
+ provider: "resend",
54
+ providerType: "communication",
55
+ configured: true,
56
+ metadata: {
57
+ fromEmail: "alerts@acme.com",
58
+ },
59
+ },
60
+ {
61
+ id: 3,
62
+ name: "Bare SMTP",
63
+ provider: "smtp",
64
+ providerType: "communication",
65
+ configured: false,
44
66
  },
45
67
  ];
46
68
 
@@ -92,6 +114,7 @@ const testResources = {
92
114
  noSmtpConfigured: "No SMTP outgoing senders configured.",
93
115
  noSmtpSenders: "No SMTP outgoing senders configured.",
94
116
  smtpPasswordSet: "password set",
117
+ smtpNoPassword: "no password",
95
118
  integrationsHubBanner: "Manage third-party credentials and cloud provider integrations centrally.",
96
119
  openIntegrationsHub: "Integrations Hub",
97
120
  addSmtpSender: "Add SMTP Sender",
@@ -147,10 +170,10 @@ describe("Mail Forms", () => {
147
170
  const urlObj = new URL(rawUrl, "http://localhost");
148
171
  const path = urlObj.pathname;
149
172
 
150
- if (method === "GET" && path === "/api/integrations") {
173
+ if (method === "GET" && path === "/api/vault/items") {
151
174
  return jsonResponse(mockIntegrations);
152
175
  }
153
- if (method === "POST" && path.startsWith("/api/integrations/") && path.endsWith("/test")) {
176
+ if (method === "POST" && path.startsWith("/api/vault/items/") && path.endsWith("/test")) {
154
177
  return jsonResponse({ ok: true, message: "Sent test email via Corporate Mailgun." });
155
178
  }
156
179
 
@@ -237,7 +260,9 @@ describe("Mail Forms", () => {
237
260
  // Wait for settings & senders to load and checkbox to appear
238
261
  await waitFor(() => {
239
262
  expect(screen.getByRole("checkbox")).toBeDefined();
263
+ expect(screen.getAllByText("Corporate Mailgun (noreply@acme.com)").length).toBeGreaterThan(0);
240
264
  });
265
+ expect(document.body.textContent).not.toContain("undefined");
241
266
 
242
267
  // Fill in recipients, subject, body
243
268
  const toInput = screen.getByPlaceholderText("hello@world.com");
@@ -316,7 +341,7 @@ describe("Mail Forms", () => {
316
341
  const urlObj = new URL(rawUrl, "http://localhost");
317
342
  const path = urlObj.pathname;
318
343
 
319
- if (method === "GET" && (path === "/api/integrations" || path === "/api/smtp-senders")) return jsonResponse(mockIntegrations);
344
+ if (method === "GET" && (path === "/api/vault/items" || path === "/api/smtp-senders")) return jsonResponse(mockIntegrations);
320
345
  if (method === "GET" && path === "/api/settings") return jsonResponse({});
321
346
  if (method === "POST" && path === "/api/emails/send") {
322
347
  return jsonResponse({ message: "SMTP relay authentication failed" }, 400);
@@ -348,7 +373,7 @@ describe("Mail Forms", () => {
348
373
  const rawUrl = typeof input === "string" ? input : input instanceof URL ? input.toString() : (input as Request).url;
349
374
  const urlObj = new URL(rawUrl, "http://localhost");
350
375
  const path = urlObj.pathname;
351
- if (method === "GET" && (path === "/api/integrations" || path === "/api/smtp-senders")) return jsonResponse([]);
376
+ if (method === "GET" && (path === "/api/vault/items" || path === "/api/smtp-senders")) return jsonResponse([]);
352
377
  if (method === "GET" && path === "/api/settings") return jsonResponse({});
353
378
  throw new Error(`Unhandled fetch: ${method} ${rawUrl}`);
354
379
  });
@@ -361,16 +386,15 @@ describe("Mail Forms", () => {
361
386
  });
362
387
  });
363
388
 
364
- // Standalone Core has no Integrations Hub. The local sender registry must
365
- // still be usable, and the send must name that registry.
366
- it("falls back to local SMTP senders when the Integrations Hub is absent", async () => {
389
+ // Standalone instances without Core Vault still serve the local sender registry.
390
+ it("falls back to local SMTP senders when Core Vault is absent", async () => {
367
391
  fetchMock.mockImplementation(async (input: RequestInfo | URL, init?: RequestInit) => {
368
392
  const method = (init?.method ?? "GET").toUpperCase();
369
393
  const rawUrl = typeof input === "string" ? input : input instanceof URL ? input.toString() : (input as Request).url;
370
394
  const urlObj = new URL(rawUrl, "http://localhost");
371
395
  const path = urlObj.pathname;
372
396
 
373
- if (method === "GET" && path === "/api/integrations") return jsonResponse({ detail: "Not Found" }, 404);
397
+ if (method === "GET" && path === "/api/vault/items") return jsonResponse({ detail: "Not Found" }, 404);
374
398
  if (method === "GET" && path === "/api/smtp-senders") return jsonResponse(mockSenders);
375
399
  if (method === "GET" && path === "/api/settings") return jsonResponse({});
376
400
  if (method === "POST" && path === "/api/emails/send") return jsonResponse({ ok: true });
@@ -491,40 +515,63 @@ describe("Mail Forms", () => {
491
515
  });
492
516
 
493
517
  describe("SMTPSenders", () => {
494
- it("uses the Integrations Hub when it is mounted and hides the local sender form", async () => {
518
+ it("uses Core Vault when it is mounted and hides the local sender form", async () => {
495
519
  renderWithProviders(<SMTPSenders />);
496
520
 
497
521
  await waitFor(() => {
498
522
  expect(screen.getByText("Corporate Mailgun")).toBeDefined();
499
523
  expect(screen.getByText("noreply@acme.com via smtp.mailgun.org:587")).toBeDefined();
500
- expect(screen.getByText("password set")).toBeDefined();
524
+ expect(screen.getByText("alerts@acme.com")).toBeDefined();
525
+ expect(screen.getByText("Bare SMTP")).toBeDefined();
526
+ expect(screen.getAllByText("password set").length).toBeGreaterThan(0);
527
+ expect(screen.getByText("no password")).toBeDefined();
501
528
  expect(screen.getByText("Manage third-party credentials and cloud provider integrations centrally.")).toBeDefined();
502
529
  });
503
530
 
504
- // Test connection goes through the hub, not the local table.
505
- fireEvent.click(screen.getByRole("button", { name: "Test" }));
531
+ expect(document.body.textContent).not.toContain("undefined");
532
+
533
+ // Test connection goes through Core Vault, not the local table.
534
+ fireEvent.click(screen.getAllByRole("button", { name: "Test" })[0]);
506
535
 
507
536
  await waitFor(() => {
508
537
  const tested = fetchMock.mock.calls.some((c) => {
509
538
  const url = typeof c[0] === "string" ? c[0] : (c[0] as Request).url;
510
- return url.includes("/api/integrations/1/test");
539
+ return url.includes("/api/vault/items/1/test");
511
540
  });
512
541
  expect(tested).toBe(true);
513
542
  });
514
543
 
515
- // The local CRUD surfaces stay absent while the hub is authoritative.
544
+ // The local CRUD surfaces stay absent while Core Vault is authoritative.
516
545
  expect(screen.queryByRole("button", { name: "Add SMTP" })).toBeNull();
517
546
  expect(screen.queryByRole("button", { name: "Edit SMTP" })).toBeNull();
518
547
  expect(screen.queryByRole("button", { name: "Remove" })).toBeNull();
519
548
  });
520
549
 
521
- it("renders empty state with deep link when the hub has no senders", async () => {
550
+ it("unwraps { body: [...] } envelope from Core Vault API", async () => {
551
+ fetchMock.mockImplementation(async (input: RequestInfo | URL, init?: RequestInit) => {
552
+ const method = (init?.method ?? "GET").toUpperCase();
553
+ const rawUrl = typeof input === "string" ? input : input instanceof URL ? input.toString() : (input as Request).url;
554
+ const urlObj = new URL(rawUrl, "http://localhost");
555
+ if (method === "GET" && urlObj.pathname === "/api/vault/items" && urlObj.searchParams.get("provider_type") === "communication") {
556
+ return jsonResponse({ body: mockIntegrations });
557
+ }
558
+ throw new Error(`Unhandled fetch: ${method} ${rawUrl}`);
559
+ });
560
+
561
+ renderWithProviders(<SMTPSenders />);
562
+
563
+ await waitFor(() => {
564
+ expect(screen.getByText("Corporate Mailgun")).toBeDefined();
565
+ });
566
+ });
567
+
568
+ it("renders empty state with deep link when Core Vault has no senders", async () => {
522
569
  fetchMock.mockImplementation(async (input: RequestInfo | URL, init?: RequestInit) => {
523
570
  const method = (init?.method ?? "GET").toUpperCase();
524
571
  const rawUrl = typeof input === "string" ? input : input instanceof URL ? input.toString() : (input as Request).url;
525
572
  const urlObj = new URL(rawUrl, "http://localhost");
526
573
  const path = urlObj.pathname;
527
- if (method === "GET" && path === "/api/integrations") return jsonResponse([]);
574
+ if (method === "GET" && path === "/api/vault/items") return jsonResponse([]);
528
575
  throw new Error(`Unhandled fetch: ${method} ${rawUrl}`);
529
576
  });
530
577
 
@@ -536,16 +583,15 @@ describe("Mail Forms", () => {
536
583
  });
537
584
  });
538
585
 
539
- // Standalone Core mounts no Integrations Hub, so the page must serve the
540
- // local registry and keep its CRUD controls.
541
- it("serves the local sender registry when the Integrations Hub is absent", async () => {
586
+ // Standalone instances without Core Vault serve the local registry and keep its CRUD controls.
587
+ it("serves the local sender registry when Core Vault is absent", async () => {
542
588
  fetchMock.mockImplementation(async (input: RequestInfo | URL, init?: RequestInit) => {
543
589
  const method = (init?.method ?? "GET").toUpperCase();
544
590
  const rawUrl = typeof input === "string" ? input : input instanceof URL ? input.toString() : (input as Request).url;
545
591
  const urlObj = new URL(rawUrl, "http://localhost");
546
592
  const path = urlObj.pathname;
547
593
 
548
- if (method === "GET" && path === "/api/integrations") return jsonResponse({ detail: "Not Found" }, 404);
594
+ if (method === "GET" && path === "/api/vault/items") return jsonResponse({ detail: "Not Found" }, 404);
549
595
  if (method === "GET" && path === "/api/smtp-senders") return jsonResponse(mockSenders);
550
596
  if (method === "POST" && path === "/api/smtp-senders/1/test") return jsonResponse({ ok: true });
551
597
  if (method === "POST" && path === "/api/smtp-senders") {
package/pages/index.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import { ScreenWrap, PageHeader, GlassCard, Button, useTranslation } from "@octarq/plugin-sdk";
1
+ import { PageShell, Button, useTranslation } from "@octarq/plugin-sdk";
2
2
  import { useEffect, useState, useMemo } from "react";
3
3
  import { useSearchParams } from "react-router-dom";
4
4
  import { mailApi, Domain, effectiveMailHosts, Email, Mailbox } from "../api";
@@ -121,26 +121,25 @@ export default function MailPage() {
121
121
  const totalUnread = useMemo(() => boxes.reduce((acc, b) => acc + (b.unread || 0), 0), [boxes]);
122
122
 
123
123
  return (
124
- <ScreenWrap>
125
- <PageHeader
126
- title={t("mail.pageTitle")}
127
- description={t("mail.pageDesc")}
128
- action={
129
- <div className="flex items-center gap-2">
130
- <Button variant="ghost" size="sm" onClick={markAllRead}>
131
- {t("mail.markRead")}
132
- </Button>
133
- <Button variant="outline" size="sm" onClick={() => setCompose(true)}>
134
- <Send className="h-3.5 w-3.5" />
135
- {t("mail.compose")}
136
- </Button>
137
- <Button variant="primary" size="sm" onClick={() => setNewBox(true)}>
138
- <Plus className="h-3.5 w-3.5" />
139
- {t("mail.newMailbox")}
140
- </Button>
141
- </div>
142
- }
143
- />
124
+ <PageShell
125
+ title={t("mail.pageTitle")}
126
+ description={t("mail.pageDesc")}
127
+ action={
128
+ <div className="flex items-center gap-2">
129
+ <Button variant="ghost" size="sm" onClick={markAllRead}>
130
+ {t("mail.markRead")}
131
+ </Button>
132
+ <Button variant="outline" size="sm" onClick={() => setCompose(true)}>
133
+ <Send className="h-3.5 w-3.5" />
134
+ {t("mail.compose")}
135
+ </Button>
136
+ <Button variant="primary" size="sm" onClick={() => setNewBox(true)}>
137
+ <Plus className="h-3.5 w-3.5" />
138
+ {t("mail.newMailbox")}
139
+ </Button>
140
+ </div>
141
+ }
142
+ >
144
143
 
145
144
  <MailTabs tab={tab} onTabChange={setTab} />
146
145
 
@@ -184,8 +183,8 @@ export default function MailPage() {
184
183
  onChanged={() => { loadEmails(true); loadBoxes(); }}
185
184
  />
186
185
  ) : (
187
- <div className="flex min-h-[420px] flex-col items-center justify-center gap-3 rounded-2xl border border-dashed border-border bg-well px-6 py-16 text-center">
188
- <div className="flex h-12 w-12 items-center justify-center rounded-2xl bg-card text-accent-fg shadow-[var(--shadow-card)] ring-1 ring-border">
186
+ <div className="flex min-h-[420px] flex-col items-center justify-center gap-3 rounded-lg border border-dashed border-border bg-well px-6 py-16 text-center">
187
+ <div className="flex h-12 w-12 items-center justify-center rounded-lg border border-border bg-card text-accent-fg">
189
188
  <Inbox className="h-5 w-5" />
190
189
  </div>
191
190
  <p className="font-display text-[13px] text-foreground">{t("mail.selectEmail")}</p>
@@ -209,6 +208,6 @@ export default function MailPage() {
209
208
  onDraftSaved={() => { loadEmails(true); }}
210
209
  />
211
210
  )}
212
- </ScreenWrap>
211
+ </PageShell>
213
212
  );
214
213
  }
@@ -14,9 +14,9 @@ export default function MailSetupStepWidget() {
14
14
  let cancelled = false;
15
15
  (async () => {
16
16
  try {
17
- // The Integrations Hub owns mail senders when it is mounted. Count the
17
+ // Core Vault owns mail senders when it is mounted. Count the
18
18
  // same registry the mail pages offer, not just the local table.
19
- const res = await fetch("/api/integrations?provider_type=communication", {
19
+ const res = await fetch("/api/vault/items?provider_type=communication", {
20
20
  credentials: "same-origin",
21
21
  });
22
22
  if (res.status === 404) {
@@ -26,7 +26,8 @@ export default function MailSetupStepWidget() {
26
26
  }
27
27
  if (!res.ok) return;
28
28
  const data = await res.json();
29
- const list = (Array.isArray(data) ? data : []).filter(
29
+ const raw = Array.isArray(data) ? data : (data?.body ?? []);
30
+ const list = (Array.isArray(raw) ? raw : []).filter(
30
31
  (item: any) => item.provider === "smtp" || item.provider === "resend"
31
32
  );
32
33
  if (!cancelled) setSmtpCount(list.length);