inboxer 0.1.0 → 0.3.0

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/dist/mcp.js CHANGED
@@ -1,9 +1,10 @@
1
+ import { createRequire } from "node:module";
1
2
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
3
  import { WebStandardStreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js";
3
4
  import { z } from "zod";
4
5
  import { appUrl, threadPath } from "./config.js";
5
6
  import { ConflictError, toView } from "./core/mail.js";
6
- const VERSION = "0.1.0";
7
+ const { version: VERSION } = createRequire(import.meta.url)("../package.json");
7
8
  function json(value) {
8
9
  return { content: [{ type: "text", text: JSON.stringify(value, null, 2) }] };
9
10
  }
@@ -12,7 +13,7 @@ function messageView(cfg, m) {
12
13
  return { ...m, url: appUrl(cfg, threadPath(m.thread_id, m.status === "draft" ? m.id : undefined)) };
13
14
  }
14
15
  function draftView(cfg, d) {
15
- return { ...messageView(cfg, toView(d)), bcc: d.bcc, html: d.html };
16
+ return { ...messageView(cfg, toView(d)), bcc: d.bcc, html: d.html, pending: d.pending };
16
17
  }
17
18
  function threadView(cfg, t) {
18
19
  return { ...t, url: appUrl(cfg, threadPath(t.id)) };
@@ -30,6 +31,17 @@ function wrap(cfg, fn) {
30
31
  }
31
32
  };
32
33
  }
34
+ const IMAGE_TYPES = new Set(["image/png", "image/jpeg", "image/gif", "image/webp"]);
35
+ const TEXT_TYPES = /^(text\/|application\/(json|xml|csv)$)/;
36
+ function attachmentContent(cfg, messageId, meta, body) {
37
+ const data = Buffer.from(body).toString("base64");
38
+ if (IMAGE_TYPES.has(meta.content_type))
39
+ return { type: "image", data, mimeType: meta.content_type };
40
+ if (TEXT_TYPES.test(meta.content_type))
41
+ return { type: "text", text: new TextDecoder().decode(body) };
42
+ const uri = appUrl(cfg, `/attachments/${encodeURIComponent(messageId)}/${encodeURIComponent(meta.id)}`);
43
+ return { type: "resource", resource: { uri, mimeType: meta.content_type, blob: data } };
44
+ }
33
45
  const addresses = z.array(z.string()).describe("Addresses, e.g. \"Ana <ana@example.com>\" or \"ana@example.com\"");
34
46
  const isoDate = z.string().describe("ISO 8601 timestamp");
35
47
  const metaFilter = z.record(z.string(), z.union([z.string(), z.number(), z.boolean()]))
@@ -147,9 +159,20 @@ function buildServer(mail, access, actor) {
147
159
  inputSchema: { message_id: z.string().describe("Inboxer message id"), text: z.string(), reply_all: z.boolean().optional() },
148
160
  }, wrap(cfg, async ({ message_id, text, reply_all }) => messageView(cfg, toView(await mail.reply(message_id, text, reply_all ?? false, actor)))));
149
161
  server.registerTool("get_attachment", {
150
- description: "Temporary download URL for an inbound attachment.",
162
+ description: "Content of an inbound attachment: images as images, text as text, anything else (e.g. PDF) as an embedded resource. Larger than the server's limit returns an error.",
151
163
  inputSchema: { message_id: z.string(), attachment_id: z.string() },
152
- }, wrap(cfg, async ({ message_id, attachment_id }) => ({ url: await mail.getAttachmentUrl(message_id, attachment_id, actor.scope) })));
164
+ }, async ({ message_id, attachment_id }) => {
165
+ try {
166
+ const { meta, body } = await mail.getAttachment(message_id, attachment_id, actor.scope);
167
+ if (body.byteLength > cfg.mcp.maxAttachmentMb * 1024 * 1024) {
168
+ throw new Error(`Attachment is ${(body.byteLength / 1048576).toFixed(1)} MB, over the ${cfg.mcp.maxAttachmentMb} MB limit`);
169
+ }
170
+ return { content: [{ type: "text", text: JSON.stringify(meta) }, attachmentContent(cfg, message_id, meta, body)] };
171
+ }
172
+ catch (err) {
173
+ return { ...json({ error: err.message }), isError: true };
174
+ }
175
+ });
153
176
  server.registerTool("create_login_link", {
154
177
  description: "One-time link that signs one browser into the review UI, limited to the mailboxes this token reaches. Expires unused after a few minutes. Pass thread_id to land on that thread after signing in. Browsers already signed in can open a result's url directly.",
155
178
  inputSchema: {
@@ -137,17 +137,35 @@ export function createResendProvider(config) {
137
137
  body.bcc = message.bcc;
138
138
  if (message.replyTo.length)
139
139
  body.reply_to = message.replyTo;
140
+ if (message.attachments.length) {
141
+ body.attachments = message.attachments.map(a => ({
142
+ filename: a.filename,
143
+ content: Buffer.from(a.content).toString("base64"),
144
+ content_type: a.contentType,
145
+ }));
146
+ }
140
147
  const res = await request("POST", "/emails", body, { "Idempotency-Key": idempotencyKey });
141
148
  return { providerId: res.id };
142
149
  },
143
- async getAttachmentUrl(providerMessageId, attachmentId) {
144
- const res = await request("GET", `/emails/receiving/${encodeURIComponent(providerMessageId)}/attachments/${encodeURIComponent(attachmentId)}`);
145
- return res.download_url;
150
+ async getAttachment(providerMessageId, attachmentId) {
151
+ const { download_url } = await request("GET", `/emails/receiving/${encodeURIComponent(providerMessageId)}/attachments/${encodeURIComponent(attachmentId)}`);
152
+ const res = await fetch(download_url);
153
+ if (!res.ok)
154
+ throw new Error(`Resend attachment ${attachmentId} download failed: ${res.status}`);
155
+ return new Uint8Array(await res.arrayBuffer());
146
156
  },
147
157
  };
148
158
  }
149
159
  function toAttachmentMeta(a) {
150
- return { id: a.id, filename: a.filename, content_type: a.content_type, size: a.size ?? null };
160
+ const contentId = a.content_id ? a.content_id.replace(/^<|>$/g, "") : null;
161
+ return {
162
+ id: a.id,
163
+ filename: a.filename,
164
+ content_type: a.content_type,
165
+ size: a.size ?? null,
166
+ inline: a.content_disposition === "inline" && !!contentId,
167
+ content_id: contentId,
168
+ };
151
169
  }
152
170
  function normalizeHeaders(headers) {
153
171
  const out = {};
@@ -38,6 +38,12 @@ export interface OutboundMessage {
38
38
  text: string;
39
39
  html: string;
40
40
  headers: Record<string, string>;
41
+ attachments: OutboundAttachment[];
42
+ }
43
+ export interface OutboundAttachment {
44
+ filename: string;
45
+ contentType: string;
46
+ content: Uint8Array;
41
47
  }
42
48
  export interface OutboundStatus {
43
49
  providerId: string;
@@ -62,7 +68,8 @@ export interface MailProvider {
62
68
  send(message: OutboundMessage, idempotencyKey: string): Promise<{
63
69
  providerId: string;
64
70
  }>;
65
- getAttachmentUrl(providerMessageId: string, attachmentId: string): Promise<string>;
71
+ /** The bytes of an inbound attachment. */
72
+ getAttachment(providerMessageId: string, attachmentId: string): Promise<Uint8Array>;
66
73
  }
67
74
  export type ProviderFactory = (config: Record<string, unknown>) => MailProvider;
68
75
  export declare class WebhookSignatureError extends Error {
package/dist/types.d.ts CHANGED
@@ -19,10 +19,13 @@ export interface InboxerConfig {
19
19
  provider: ProviderConfig;
20
20
  mcp: {
21
21
  tokens: Record<string, string>;
22
+ maxAttachmentMb: number;
22
23
  };
23
24
  ui: {
24
25
  cookieSecret: string;
25
26
  loginLinkTtlMin: number;
27
+ undoSec: number;
28
+ maxUploadMb: number;
26
29
  };
27
30
  }
28
31
  export declare const CATCHALL = "catchall";
@@ -40,6 +43,9 @@ export interface AttachmentMeta {
40
43
  filename: string;
41
44
  content_type: string;
42
45
  size: number | null;
46
+ /** Shown inside the body (e.g. an embedded image referenced by `cid:`), not offered as a file. */
47
+ inline: boolean;
48
+ content_id: string | null;
43
49
  }
44
50
  export interface Message {
45
51
  id: string;
@@ -71,6 +77,13 @@ export interface Message {
71
77
  sent_at: string | null;
72
78
  version: number;
73
79
  edited_by_human: boolean;
80
+ /** A send or discard a human started, carried out at `at` unless undone first. */
81
+ pending: PendingAction | null;
82
+ }
83
+ export interface PendingAction {
84
+ action: "send" | "discard";
85
+ at: string;
86
+ by: string;
74
87
  }
75
88
  export interface Thread {
76
89
  id: string;
package/dist/ui/assets.js CHANGED
@@ -9,4 +9,5 @@ function load(file, type) {
9
9
  export const ASSETS = {
10
10
  "style.css": load("style.css", "text/css; charset=utf-8"),
11
11
  "htmx.min.js": load("htmx.min.js", "text/javascript; charset=utf-8"),
12
+ "app.js": load("app.js", "text/javascript; charset=utf-8"),
12
13
  };
@@ -1,7 +1,7 @@
1
1
  import type { Hono } from "hono";
2
2
  import type { Access } from "../auth.ts";
3
3
  import { type Mail } from "../core/mail.ts";
4
- import type { InboxerConfig, Session } from "../types.ts";
4
+ import { type InboxerConfig, type Session } from "../types.ts";
5
5
  export type UiEnv = {
6
6
  Variables: {
7
7
  session: Session;
package/dist/ui/routes.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { deleteCookie, getCookie, getSignedCookie, setCookie, setSignedCookie } from "hono/cookie";
2
- import { bareAddress, splitAddresses } from "../core/address.js";
2
+ import { bareAddress, domainOf, splitAddresses } from "../core/address.js";
3
3
  import { ConflictError, InvalidRequestError } from "../core/mail.js";
4
+ import { CATCHALL } from "../types.js";
4
5
  import { S } from "./strings.js";
5
6
  import * as V from "./views.js";
6
7
  const SESSION_COOKIE = "inboxer_session";
@@ -16,16 +17,31 @@ function clientInfo(c) {
16
17
  const forwarded = c.req.header("x-forwarded-for")?.split(",")[0]?.trim();
17
18
  return { ip: forwarded || c.req.header("x-real-ip") || null, userAgent: c.req.header("user-agent") ?? null };
18
19
  }
20
+ /** htmx sends the page URL; draft cards on a thread page leave out the thread around them. */
21
+ function onThreadPage(c) {
22
+ const current = c.req.header("hx-current-url");
23
+ return !!current && new URL(current).pathname.startsWith("/threads/");
24
+ }
19
25
  function uiActor(session) {
20
26
  return { kind: "ui", name: session.label ?? session.id.slice(0, 12), scope: session.scope };
21
27
  }
22
28
  export function registerUi(app, mail, access, cfg) {
23
29
  const secret = cfg.ui.cookieSecret;
24
30
  const cookieOptions = { httpOnly: true, secure: true, sameSite: "Lax", path: "/", maxAge: COOKIE_MAX_AGE };
31
+ const own = new Set(Object.values(cfg.mailboxes).map(m => bareAddress(m.address)));
32
+ /** Recipients that are our own mailboxes are implied by the mailbox badge. */
33
+ const shown = (m) => ({
34
+ ...m,
35
+ to: m.to.filter(a => !own.has(bareAddress(a))),
36
+ cc: m.cc.filter(a => !own.has(bareAddress(a))),
37
+ });
25
38
  const page = async (c, title, body, current, status = 200) => {
26
39
  const session = c.get("session");
27
40
  const draftCount = session ? (await mail.listDrafts(undefined, session.scope)).length : 0;
28
- return c.html(V.layout(title, body, { theme: theme(c), page: current, draftCount, signedIn: !!session }), status);
41
+ const domains = session
42
+ ? [...new Set(mail.listMailboxes(session.scope).filter(m => m.id !== CATCHALL).map(m => domainOf(m.address)))]
43
+ : [];
44
+ return c.html(V.layout(title, body, { theme: theme(c), page: current, draftCount, signedIn: !!session, domains }), status);
29
45
  };
30
46
  // Sign-in: GET only shows a button, so link previews and scanners do not burn the link.
31
47
  app.get("/auth/:token", async (c) => {
@@ -48,7 +64,7 @@ export function registerUi(app, mail, access, cfg) {
48
64
  const path = back && new URL(back).origin === new URL(c.req.url).origin ? new URL(back).pathname + new URL(back).search : "/";
49
65
  return c.redirect(path, 303);
50
66
  });
51
- const ui = ["/", "/inbox", "/threads/*", "/drafts/*", "/devices", "/devices/*", "/logout"];
67
+ const ui = ["/", "/inbox", "/threads/*", "/drafts/*", "/attachments/*", "/devices", "/devices/*", "/logout"];
52
68
  for (const path of ui) {
53
69
  app.use(path, async (c, next) => {
54
70
  const value = await getSignedCookie(c, secret, SESSION_COOKIE);
@@ -64,10 +80,24 @@ export function registerUi(app, mail, access, cfg) {
64
80
  await next();
65
81
  });
66
82
  }
67
- /** The sent and received messages around a draft, and the context of its thread. */
83
+ /** The sent and received messages around a draft, newest first, and the context of its thread. */
68
84
  const draftExtras = async (draft, session) => {
69
85
  const { messages, context, contacts } = await mail.getThread(draft.thread_id, session.scope);
70
- return { history: messages.filter(m => m.id !== draft.id && m.status !== "draft"), ctx: { context, contacts } };
86
+ const history = messages.filter(m => m.id !== draft.id && m.status !== "draft").reverse().map(shown);
87
+ return { history, ctx: { context, contacts } };
88
+ };
89
+ /** The card for a draft in whatever state it is now. */
90
+ const draftView = async (c, id) => {
91
+ const session = c.get("session");
92
+ const draft = await mail.requireMessage(id, session.scope);
93
+ if (draft.status === "discarded")
94
+ return V.draftDone(id, S.discarded);
95
+ if (draft.status !== "draft")
96
+ return V.draftDone(id, `${S.sentTo} ${draft.to.join(", ")}`);
97
+ if (onThreadPage(c))
98
+ return V.draftCard(draft, [], null);
99
+ const { history, ctx } = await draftExtras(draft, session);
100
+ return V.draftCard(draft, history, ctx);
71
101
  };
72
102
  app.get("/", async (c) => {
73
103
  const session = c.get("session");
@@ -75,17 +105,11 @@ export function registerUi(app, mail, access, cfg) {
75
105
  const items = await Promise.all(drafts.map(async (draft) => ({ draft, ...(await draftExtras(draft, session)) })));
76
106
  return page(c, S.navDrafts, V.draftsPage(items), "drafts");
77
107
  });
78
- app.get("/drafts/:id/card", async (c) => {
79
- const draft = await mail.requireMessage(c.req.param("id"), c.get("session").scope);
80
- if (draft.status !== "draft")
81
- return c.html(V.draftDone(draft.id, `${S.status}: ${draft.status}`));
82
- const { history, ctx } = await draftExtras(draft, c.get("session"));
83
- return c.html(V.draftCard(draft, history, ctx));
84
- });
108
+ app.get("/drafts/:id/card", async (c) => c.html(await draftView(c, c.req.param("id"))));
85
109
  app.get("/drafts/:id/edit", async (c) => {
86
110
  const draft = await mail.requireMessage(c.req.param("id"), c.get("session").scope);
87
- if (draft.status !== "draft")
88
- return c.html(V.draftDone(draft.id, `${S.status}: ${draft.status}`));
111
+ if (draft.status !== "draft" || draft.pending)
112
+ return c.html(await draftView(c, draft.id));
89
113
  const form = { to: draft.to.join(", "), cc: draft.cc.join(", "), subject: draft.subject, text: draft.text };
90
114
  return c.html(V.draftEditor(draft, form, null));
91
115
  });
@@ -101,13 +125,9 @@ export function registerUi(app, mail, access, cfg) {
101
125
  subject: form.subject,
102
126
  text: form.text,
103
127
  }, actor);
104
- if (body.send === "1") {
105
- const sent = await mail.sendDraft(id, actor);
106
- return c.html(V.draftDone(id, `${S.sentTo} ${sent.to.join(", ")}`));
107
- }
108
- const draft = await mail.requireMessage(id, actor.scope);
109
- const { history, ctx } = await draftExtras(draft, c.get("session"));
110
- return c.html(V.draftCard(draft, history, ctx));
128
+ if (body.send === "1")
129
+ await mail.schedule(id, "send", actor);
130
+ return c.html(await draftView(c, id));
111
131
  }
112
132
  catch (err) {
113
133
  if (err instanceof ConflictError)
@@ -117,30 +137,44 @@ export function registerUi(app, mail, access, cfg) {
117
137
  throw err;
118
138
  }
119
139
  });
120
- app.post("/drafts/:id/send", async (c) => {
140
+ app.post("/drafts/:id/attachments", async (c) => {
121
141
  const id = c.req.param("id");
122
- try {
123
- const sent = await mail.sendDraft(id, uiActor(c.get("session")));
124
- return c.html(V.draftDone(id, `${S.sentTo} ${sent.to.join(", ")}`));
125
- }
126
- catch (err) {
127
- if (err instanceof InvalidRequestError)
128
- return c.html(V.draftDone(id, err.message));
129
- throw err;
142
+ const actor = uiActor(c.get("session"));
143
+ const body = await c.req.parseBody({ all: true });
144
+ const files = [].concat(body.files ?? []).filter((f) => f instanceof File);
145
+ const limit = cfg.ui.maxUploadMb * 1024 * 1024;
146
+ let error = null;
147
+ for (const file of files) {
148
+ if (file.size > limit) {
149
+ error = `${file.name} ${S.tooLarge} ${cfg.ui.maxUploadMb} MB`;
150
+ continue;
151
+ }
152
+ await mail.attach(id, { filename: file.name, contentType: file.type, body: new Uint8Array(await file.arrayBuffer()) }, actor);
130
153
  }
154
+ return c.html(V.draftFiles(await mail.requireMessage(id, actor.scope), error));
131
155
  });
132
- app.post("/drafts/:id/discard", async (c) => {
133
- const id = c.req.param("id");
134
- try {
135
- await mail.discardDraft(id, uiActor(c.get("session")));
136
- return c.html(V.draftDone(id, S.discarded));
137
- }
138
- catch (err) {
139
- if (err instanceof InvalidRequestError)
140
- return c.html(V.draftDone(id, err.message));
141
- throw err;
142
- }
156
+ app.post("/drafts/:id/attachments/:attachmentId/remove", async (c) => {
157
+ const draft = await mail.detach(c.req.param("id"), c.req.param("attachmentId"), uiActor(c.get("session")));
158
+ return c.html(V.draftFiles(draft, null));
143
159
  });
160
+ // Send, discard and undo answer with the draft's current card, so a late click shows what happened.
161
+ for (const [path, act] of [
162
+ ["send", (id, actor) => mail.schedule(id, "send", actor)],
163
+ ["discard", (id, actor) => mail.schedule(id, "discard", actor)],
164
+ ["undo", (id, actor) => mail.undo(id, actor)],
165
+ ]) {
166
+ app.post(`/drafts/:id/${path}`, async (c) => {
167
+ const id = c.req.param("id");
168
+ try {
169
+ await act(id, uiActor(c.get("session")));
170
+ }
171
+ catch (err) {
172
+ if (!(err instanceof InvalidRequestError))
173
+ throw err;
174
+ }
175
+ return c.html(await draftView(c, id));
176
+ });
177
+ }
144
178
  app.get("/inbox", async (c) => {
145
179
  const mailbox = c.req.query("mailbox") ?? "";
146
180
  const requested = c.req.query("status");
@@ -160,7 +194,7 @@ export function registerUi(app, mail, access, cfg) {
160
194
  thread = await mail.requireThread(id, scope);
161
195
  }
162
196
  const { messages, context, contacts } = await mail.getThread(id, scope);
163
- const items = await Promise.all(messages.map(async (m) => m.status === "draft" ? V.draftCard(await mail.store.requireMessage(m.id), [], null) : V.messageCard(m)));
197
+ const items = await Promise.all([...messages].reverse().map(async (m) => m.status === "draft" ? V.draftCard(await mail.store.requireMessage(m.id), [], null) : V.messageCard(shown(m))));
164
198
  return page(c, thread.subject || S.navInbox, V.threadPage(thread, items, { context, contacts }), "inbox");
165
199
  });
166
200
  app.post("/threads/:id/archive", async (c) => {
@@ -169,6 +203,18 @@ export function registerUi(app, mail, access, cfg) {
169
203
  await mail.mark([id], { archived }, uiActor(c.get("session")));
170
204
  return c.html(V.archiveButton(await mail.store.requireThread(id)));
171
205
  });
206
+ // Attachments are untrusted: only plain images and PDFs open in the browser, everything runs sandboxed.
207
+ app.get("/attachments/:messageId/:attachmentId", async (c) => {
208
+ const { meta, body } = await mail.getAttachment(c.req.param("messageId"), c.req.param("attachmentId"), c.get("session").scope);
209
+ const opens = V.isPreviewable(meta.content_type) || meta.content_type === "application/pdf";
210
+ return c.body(body, 200, {
211
+ "Content-Type": opens ? meta.content_type : "application/octet-stream",
212
+ "Content-Disposition": `${opens ? "inline" : "attachment"}; filename*=UTF-8''${encodeURIComponent(meta.filename)}`,
213
+ "Content-Security-Policy": "sandbox; default-src 'none'; img-src 'self'; style-src 'unsafe-inline'",
214
+ "X-Content-Type-Options": "nosniff",
215
+ "Cache-Control": "private, max-age=31536000, immutable",
216
+ });
217
+ });
172
218
  app.get("/devices", async (c) => {
173
219
  const session = c.get("session");
174
220
  return page(c, S.navDevices, V.devicesPage(await access.listSessions(session.scope), session.id), "devices");
@@ -0,0 +1,27 @@
1
+ // Files dropped on a [data-drop] zone go to its file input, which uploads them through htmx.
2
+ const zoneOf = event => event.target instanceof Element ? event.target.closest("[data-drop]") : null;
3
+ const hasFiles = event => [...(event.dataTransfer?.types ?? [])].includes("Files");
4
+
5
+ document.addEventListener("dragover", event => {
6
+ if (!hasFiles(event)) return;
7
+ event.preventDefault();
8
+ const zone = zoneOf(event);
9
+ event.dataTransfer.dropEffect = zone ? "copy" : "none";
10
+ zone?.classList.add("dragging");
11
+ });
12
+
13
+ document.addEventListener("dragleave", event => {
14
+ const zone = zoneOf(event);
15
+ if (zone && !zone.contains(event.relatedTarget)) zone.classList.remove("dragging");
16
+ });
17
+
18
+ document.addEventListener("drop", event => {
19
+ if (!hasFiles(event)) return;
20
+ event.preventDefault();
21
+ const zone = zoneOf(event);
22
+ if (!zone) return;
23
+ zone.classList.remove("dragging");
24
+ const input = zone.querySelector("input[type=file]");
25
+ input.files = event.dataTransfer.files;
26
+ input.dispatchEvent(new Event("change", { bubbles: true }));
27
+ });
@@ -69,7 +69,42 @@ header form { margin: 0; }
69
69
  .context dd { margin: 0; overflow-wrap: anywhere; }
70
70
  .context p { margin: 8px 0 0; white-space: pre-wrap; font-size: .8125rem; color: var(--muted); }
71
71
  .body { white-space: pre-wrap; overflow-wrap: anywhere; margin: 14px 0 0; font: inherit; }
72
+ .images { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin-top: 16px; }
73
+ .images a { display: block; aspect-ratio: 1; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: var(--soft); }
74
+ .images img { width: 100%; height: 100%; object-fit: cover; display: block; transition: opacity .15s; }
75
+ .images a:hover img { opacity: .8; }
76
+ .files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
77
+ .file {
78
+ display: inline-flex; align-items: center; gap: 10px; max-width: 100%;
79
+ padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px;
80
+ font-family: var(--mono); font-size: .72rem; transition: border-color .15s;
81
+ }
82
+ .file:hover { border-color: var(--focus); }
83
+ .file span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
84
+ .file .size { color: var(--muted); flex: none; }
85
+ .draft-files { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 16px; }
86
+ .draft-files .warn { flex-basis: 100%; margin: 0; color: var(--danger); font-family: var(--mono); font-size: .72rem; }
87
+ .draft-files .link { font-size: 1rem; line-height: 1; }
88
+ .attach { cursor: pointer; color: var(--muted); }
89
+ .attach:hover { color: var(--fg); }
90
+ [data-drop] { position: relative; }
91
+ .drop-hint {
92
+ display: none; position: absolute; inset: 8px 0; z-index: 1;
93
+ align-items: center; justify-content: center;
94
+ border: 1px dashed var(--accent); border-radius: 8px;
95
+ background: color-mix(in srgb, var(--bg) 88%, transparent);
96
+ font-family: var(--mono); font-size: .8rem; color: var(--accent); pointer-events: none;
97
+ }
98
+ [data-drop].dragging .drop-hint { display: flex; }
72
99
  .notice { color: var(--muted); font-family: var(--mono); font-size: .8rem; }
100
+ .thread-head { margin-bottom: 28px; }
101
+ .domain { font-family: var(--mono); font-size: .72rem; letter-spacing: .02em; color: var(--muted); margin-bottom: 10px; }
102
+ .pending { position: relative; }
103
+ .pending-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; font-size: .9rem; }
104
+ .pending-row span { min-width: 0; overflow-wrap: anywhere; color: var(--muted); }
105
+ .pending-row strong { color: var(--fg); font-weight: 500; }
106
+ .countdown { position: absolute; left: 0; top: -1px; height: 1px; width: 100%; background: var(--accent); transform-origin: left; animation: countdown linear forwards; }
107
+ @keyframes countdown { from { transform: scaleX(1); } to { transform: scaleX(0); } }
73
108
  .conflict { border-top: 2px solid var(--danger); }
74
109
  .conflict .warn { color: var(--danger); font-weight: 600; margin: 14px 0 4px; }
75
110
 
@@ -22,8 +22,13 @@ export declare const S: {
22
22
  readonly save: "Save";
23
23
  readonly saveAndSend: "Save & Send";
24
24
  readonly cancel: "Cancel";
25
- readonly confirmSend: "Send this message now?";
26
- readonly confirmDiscard: "Discard this draft?";
25
+ readonly attach: "Attach";
26
+ readonly remove: "Remove";
27
+ readonly dropFiles: "Drop files to attach";
28
+ readonly tooLarge: "is larger than";
29
+ readonly sending: "Sending to";
30
+ readonly discarding: "Discarding draft";
31
+ readonly undo: "Undo";
27
32
  readonly sentTo: "Sent to";
28
33
  readonly discarded: "Draft discarded.";
29
34
  readonly editedByHuman: "Edited by you";
@@ -48,7 +53,6 @@ export declare const S: {
48
53
  readonly devicesEmpty: "No signed-in devices.";
49
54
  readonly thisDevice: "This device";
50
55
  readonly revoke: "Revoke";
51
- readonly confirmRevoke: "Sign this device out?";
52
56
  readonly createdBy: "Link from";
53
57
  readonly lastSeen: "Last seen";
54
58
  readonly signedIn: "Signed in";
@@ -22,8 +22,13 @@ export const S = {
22
22
  save: "Save",
23
23
  saveAndSend: "Save & Send",
24
24
  cancel: "Cancel",
25
- confirmSend: "Send this message now?",
26
- confirmDiscard: "Discard this draft?",
25
+ attach: "Attach",
26
+ remove: "Remove",
27
+ dropFiles: "Drop files to attach",
28
+ tooLarge: "is larger than",
29
+ sending: "Sending to",
30
+ discarding: "Discarding draft",
31
+ undo: "Undo",
27
32
  sentTo: "Sent to",
28
33
  discarded: "Draft discarded.",
29
34
  editedByHuman: "Edited by you",
@@ -48,7 +53,6 @@ export const S = {
48
53
  devicesEmpty: "No signed-in devices.",
49
54
  thisDevice: "This device",
50
55
  revoke: "Revoke",
51
- confirmRevoke: "Sign this device out?",
52
56
  createdBy: "Link from",
53
57
  lastSeen: "Last seen",
54
58
  signedIn: "Signed in",
@@ -9,9 +9,12 @@ export declare function layout(title: string, body: View, opts: {
9
9
  page: Page;
10
10
  draftCount?: number;
11
11
  signedIn: boolean;
12
+ domains?: string[];
12
13
  }): View;
13
14
  export declare function message(lines: string[]): View;
14
15
  export declare function signIn(token: string, valid: boolean): View;
16
+ /** Image types a browser renders without running code; SVG is left out on purpose. */
17
+ export declare function isPreviewable(contentType: string): boolean;
15
18
  export declare function messageCard(m: MessageView): View;
16
19
  export interface ContextView {
17
20
  context: Context | null;
@@ -25,6 +28,8 @@ export interface DraftForm {
25
28
  text: string;
26
29
  }
27
30
  export declare function draftEditor(d: Message, form: DraftForm, conflict: Message | null): View;
31
+ /** The editor's attachment list with remove buttons, and the picker that drag and drop also feeds. */
32
+ export declare function draftFiles(d: Message, error: string | null): View;
28
33
  export declare function draftDone(id: string, text: string): View;
29
34
  export declare function draftsPage(drafts: {
30
35
  draft: Message;