Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ jobs:
- run: bun run test:a11y
env:
CI: true
- name: upload Playwright diagnostics
if: ${{ failure() }}
- name: upload Playwright diagnostics and UI evidence
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: playwright-diagnostics-${{ github.run_id }}
Expand Down
16 changes: 16 additions & 0 deletions DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -854,3 +854,19 @@ API 受理不能显示为“已送达”。在 webhook 确认之前使用“已
本轮浏览器证据使用隔离的本地 Worker、D1/R2 合成 fixture 和 Chromium Playwright fallback;Browser plugin 不在当前环境中。回归尺寸包含 320、390、480、768、900、901、1023、1024、1280、1366 px,并覆盖短视口、移动横屏、中文/英文、浅色/深色、标准/紧凑密度、侧栏状态、长主题和长正文。1366 × 768 的几何验收要求正文起点不超过 220 px,实际可见正文至少占视口 60%;可见高度按视口、详情面板和祖先裁剪区域的交集计算,不使用 `scrollHeight` 或 iframe 声明高度冒充可见空间。

可访问性和 CSS 依据于 2026-09-17 复核的 [W3C WCAG 2.2](https://www.w3.org/TR/WCAG22/)、[WAI-ARIA Authoring Practices Guide](https://www.w3.org/WAI/ARIA/apg/)、[Tailwind CSS 加载样式层文档](https://tailwindcss.com/docs/adding-custom-styles#using-css-layers);实现保留项目现有组件和 token,不引入全局 `!important`、隐藏滚动条、缩放/变形或无证据的大范围重构。

## 25. 2026-09-30 Gmail 式收件工作流

本节更新默认邮件列表与收件分类的交互规范;颜色、FlareMail 品牌、邮件安全和多地址身份规则保持原规范。

- 默认使用全宽邮件列表。桌面每行依次展示选择框、星标、对端、主题与摘要、日期;未读行使用浅色背景和加粗文字。打开邮件后进入阅读页,返回恢复同一列表和触发控件焦点。浏览器前进/后退保留文件夹、搜索、地址筛选与分类。
- 文件夹标题提供“显示分栏预览 / 关闭分栏预览”。分栏继续支持原有宽度拖拽与键盘操作;阅读布局与显示密度独立保存在当前浏览器。窄屏继续一次显示一个主面板。
- 收件箱分类只以横向 Tab 展示:全部、主要、推广、社交、更新、论坛。窄屏在分类条内部横向滚动,页面本身不横向溢出。Tab 使用 roving tabindex、方向键、Home/End、tabpanel 关系和可见选中下划线;侧栏不增加分类菜单。
- “全部”为默认入口,避免旧邮件因启用分类而看似消失。其余分类根据发件地址与主题的本地保守规则判定,不调用外部 AI,不读取正文。分类只是组织提示,不是垃圾邮件、安全或身份认证判断。可为选中邮件手动指定分类,也可恢复自动分类。
- 分类在服务端筛选后分页,并进入游标和批量操作范围;列表计数不是当前加载页的数量。搜索、未读/星标与域名/地址筛选和分类共同生效。邮件按明确选择操作,不因一个 Tab 扩大到别的地址或会话。
- 全宽模式下点击草稿直接续写。草稿列表有可发现的移入垃圾箱入口,沿用可撤销删除和垃圾箱恢复;已接收/已发送邮件正文保持只读,修改内容应通过草稿、回复或转发完成。
- 列表提供归档/移回收件箱、已读/未读、删除等快捷操作;鼠标悬停与键盘焦点可显示桌面行操作,手机仍可通过阅读页完成同等操作。
- Ctrl/Cmd+Enter 仅表示明确发送,不接受收件人联想后顺带发送;IME 组合输入和长按不触发发送。附件准备只合并服务器持久化元数据,不覆盖正在编辑的正文;上传/取消进行中不能关闭或保存退出编辑器。
- 深链接可读取当前分页之外的 Owner 邮件,但不能把它插入当前分类/搜索分页或污染游标。迟到的读/星标响应不能抢回用户已切换的阅读选择,更新后的读/星标状态不能被下一页旧缓存覆盖。

数据库新增 `0028_inbox_categories.sql`(schema 28);部署该版本前需要按既有发布流程应用迁移。本轮仅本地合成数据验证,不代表生产收发信已验收。
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,10 @@ Domain、Resend、D1 Time Travel 与 Email Routing 顺序的唯一权威说明
- [docs/SLO.md](./docs/SLO.md):建议性 SLO、阻塞阈值与无 PII 可观测性契约。
- [TODO.md](./TODO.md):重构完成后的剩余产品路线。
- [GEMINI_UI_PROMPT.md](./GEMINI_UI_PROMPT.md):已归档的旧视觉提示,不再是实现依据。

### 收件分类与邮件日常操作

- 收件箱顶部提供横向分类标签:全部、主要、推广、社交、更新、论坛。默认显示全部邮件;自动分类只在本地依据发件人和主题匹配,可以勾选邮件后手动更改或恢复自动分类。
- 默认使用全宽列表,点击进入阅读,再返回原筛选;标题栏可切换为分栏预览。分类、搜索、邮件地址筛选、分页和浏览器前进/后退可组合使用。
- 点击草稿即可续写;列表支持星标、已读/未读、归档和移入垃圾箱。删除后可撤销,也可从垃圾箱恢复。收件与已发送正文不直接改写,通过回复、转发或草稿编辑生成新邮件。
- 分类功能需要数据库迁移 `0028_inbox_categories.sql`,沿用部署文档中的迁移与发布流程。已有邮箱地址、回复发件身份和正文安全隔离不变。
4 changes: 2 additions & 2 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions migrations/0028_inbox_categories.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- NULL keeps automatic metadata classification; a value records the Owner's choice.
ALTER TABLE workspace_messages ADD COLUMN inbox_category TEXT
CHECK (inbox_category IS NULL OR inbox_category IN ('primary', 'promotions', 'social', 'updates', 'forums'));
ALTER TABLE email_messages ADD COLUMN inbox_category TEXT
CHECK (inbox_category IS NULL OR inbox_category IN ('primary', 'promotions', 'social', 'updates', 'forums'));

UPDATE workspace_schema_metadata
SET schema_version = 28, updated_at = strftime('%Y-%m-%dT%H:%M:%fZ', 'now')
WHERE schema_name = 'flaremail';
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"test": "bun test src scripts",
"test:unit": "bun test src/lib/client src/lib/components/mail/domain-capabilities.test.ts src/lib/components/ui src/lib/domain/mail src/lib/domain/utf8.test.ts src/lib/i18n src/lib/server/auth src/lib/server/config src/lib/server/body.test.ts src/lib/server/cloudflare-email-routing.test.ts src/lib/server/db/attachments.test.ts src/lib/server/db/capabilities.test.ts src/lib/server/db/deliveries.test.ts src/lib/server/db/mail-identities.test.ts src/lib/server/db/messages.test.ts src/lib/server/email.test.ts src/lib/server/inbound/parser.test.ts src/lib/server/mail-identities/check.test.ts src/lib/server/mail-identities/health-refresh.test.ts src/lib/server/mail-identities/routing.test.ts src/lib/server/mail-identities/sending.test.ts src/lib/server/mail-identities/validation.test.ts src/lib/server/mail/html-sanitize.test.ts src/lib/server/outbound/gateway.test.ts src/lib/server/outbound/rate-limit.test.ts src/lib/server/outbound/system.test.ts src/lib/server/resend-domains.test.ts src/lib/server/search/fts.test.ts src/lib/server/workspace/compose-body.test.ts src/lib/server/telegram/api.test.ts src/lib/server/telegram/config.test.ts src/lib/server/telegram/message.test.ts src/lib/server/scheduled.test.ts",
"test:integration": "bun test src/lib/server/email.integration.test.ts src/lib/server/workspace/attachment.integration.test.ts src/lib/server/workspace/outbound.integration.test.ts src/lib/server/workspace/delivery.integration.test.ts src/lib/server/workspace/draft.integration.test.ts src/lib/server/workspace/mailbox.integration.test.ts src/lib/server/workspace/mutation-query-counter.integration.test.ts src/lib/server/workspace/trash.integration.test.ts src/lib/server/db/migrations.test.ts src/lib/server/db/telegram.test.ts src/lib/server/telegram/dispatcher.test.ts src/routes/api/health/health.test.ts src/routes/api/readiness/readiness.test.ts src/routes/api/workspace/mailbox/mutate/server.test.ts 'src/routes/api/workspace/mail-identities/[addressId]/server.test.ts'",
"test:integration": "bun test src/lib/server/email.integration.test.ts src/lib/server/workspace/attachment.integration.test.ts src/lib/server/workspace/outbound.integration.test.ts src/lib/server/workspace/delivery.integration.test.ts src/lib/server/workspace/draft.integration.test.ts src/lib/server/workspace/mailbox.integration.test.ts src/lib/server/workspace/mutation-query-counter.integration.test.ts src/lib/server/workspace/trash.integration.test.ts src/lib/server/db/migrations.test.ts src/lib/server/db/telegram.test.ts src/lib/server/telegram/dispatcher.test.ts src/routes/api/health/health.test.ts src/routes/api/readiness/readiness.test.ts src/routes/api/workspace/mailbox/mutate/server.test.ts src/routes/api/workspace/mailbox/categories/server.test.ts 'src/routes/api/workspace/mail-identities/[addressId]/server.test.ts'",
"test:remaining": "bun test scripts src/hooks.server.test.ts src/lib/server/attachment-download.test.ts src/lib/server/attachment-integrity.test.ts src/lib/server/http/api.test.ts src/lib/server/resend-webhook.test.ts src/lib/server/workspace/mailbox-query.test.ts src/lib/server/workspace/reader.test.ts src/lib/server/workspace/r2-cleanup.test.ts src/lib/server/workspace/session.test.ts src/lib/server/workspace/shared.test.ts src/routes/api/send/server.test.ts src/routes/api/webhooks/resend/server.test.ts src/routes/api/webhooks/telegram/server.test.ts src/routes/api/workspace/notifications/telegram/settings/server.test.ts 'src/routes/api/workspace/messages/[id]/html/html.test.ts' 'src/routes/api/workspace/messages/[id]/server.test.ts' src/routes/api/workspace/session/server.test.ts src/routes/api/workspace/trash/trash.test.ts",
"test:e2e": "bun scripts/playwright-projects.ts chromium",
"test:e2e:webkit": "bun scripts/playwright-projects.ts webkit",
Expand Down Expand Up @@ -69,7 +69,7 @@
"@cloudflare/workerd-linux-arm64": "1.20260820.1",
"@cloudflare/workerd-windows-64": "1.20260820.1",
"sharp": "0.35.4",
"undici": "7.29.0",
"undici": "7.29.1",
"workerd": "1.20260820.1"
}
}
2 changes: 1 addition & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const webkitLaunchOptions = process.env.PLAYWRIGHT_WEBKIT_EXECUTABLE_PATH
const firefoxLaunchOptions = process.env.PLAYWRIGHT_FIREFOX_EXECUTABLE_PATH
? { executablePath: process.env.PLAYWRIGHT_FIREFOX_EXECUTABLE_PATH }
: undefined;
const chromiumTestMatch = /workspace\.spec\.ts/u;
const chromiumTestMatch = /(?:workspace|gmail-workflows|compose-safety)\.spec\.ts/u;
const webkitSmokeTestMatch = /webkit-smoke\.spec\.ts/u;
const firefoxSmokeTestMatch = /firefox-smoke\.spec\.ts/u;
// Linux browser video finalization is unreliable here; failures still retain
Expand Down
2 changes: 2 additions & 0 deletions schema.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
CREATE TABLE IF NOT EXISTS email_messages (
inbox_category TEXT CHECK (inbox_category IS NULL OR inbox_category IN ('primary', 'promotions', 'social', 'updates', 'forums')),
id TEXT PRIMARY KEY,
message_id TEXT,
"from" TEXT NOT NULL,
Expand Down Expand Up @@ -188,6 +189,7 @@ CREATE TABLE IF NOT EXISTS workspace_sessions (
);

CREATE TABLE IF NOT EXISTS workspace_messages (
inbox_category TEXT CHECK (inbox_category IS NULL OR inbox_category IN ('primary', 'promotions', 'social', 'updates', 'forums')),
id TEXT PRIMARY KEY,
user_id TEXT NOT NULL,
folder TEXT NOT NULL CHECK (folder IN ('inbox', 'sent')),
Expand Down
5 changes: 4 additions & 1 deletion scripts/e2e/start-local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,10 @@ await run('bunx', [
const worker = Bun.spawn(
[
'bunx', 'wrangler', 'dev', '--config', 'wrangler.toml', '--local', '--persist-to', persistTo,
'--port', port, '--ip', '127.0.0.1', '--show-interactive-dev-session=false',
'--port', port, '--ip', '127.0.0.1',
// Keep parallel local suites deterministic without network-interface probing.
'--inspector-port', process.env.FLAREMAIL_E2E_INSPECTOR_PORT ?? String(Number(port) + 10000),
'--inspector-ip', '127.0.0.1', '--show-interactive-dev-session=false',
'--var', 'APP_ENV:development', '--var', 'ALLOW_FAKE_SERVICES:true', '--var', 'OUTBOUND_PROVIDER:demo',
'--var', 'OUTBOUND_FROM_EMAIL:e2e@flaremail.test', '--var', 'OUTBOUND_FROM_NAME:FlareMail E2E',
'--var', `RESEND_WEBHOOK_SECRET:${webhookSecret}`
Expand Down
26 changes: 26 additions & 0 deletions src/lib/client/compose-controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
createEmptyComposeInput,
formatComposeSavedAt,
hasComposeContent,
mergePreparedComposeInput,
mergeSavedDraftMetadata,
serializeComposeInput,
withComposeDraftId,
Expand Down Expand Up @@ -89,6 +90,31 @@ describe('compose controller', () => {
expect(merged.bodyRevision).toBe('body-object-2');
});

test('attachment preparation preserves newer editor content and only adopts server metadata', () => {
const attachment = { id: 'attachment-1', filename: 'evidence.txt', contentType: 'text/plain', size: 8, inline: false };
const current = {
...createEmptyComposeInput(),
to: [{ name: 'New recipient', email: 'new@example.com' }],
subject: 'Latest subject', body: 'Latest body', html: '<p>Latest HTML</p>',
senderAddressId: 'latest-sender', bodyRevision: 'old-body',
forwardAttachmentCandidates: [attachment]
};
const prepared = {
...current, draftId: 'draft-1', expectedUpdatedAt: '2026-09-30T10:00:00.000Z',
to: [{ name: 'Old recipient', email: 'old@example.com' }],
subject: 'Old subject', body: 'Old body', html: '<p>Old HTML</p>',
senderAddressId: 'old-sender', bodyRevision: 'prepared-body',
attachments: [attachment], attachmentRevision: 3,
forwardAttachmentCandidates: undefined
};
expect(mergePreparedComposeInput(current, prepared)).toEqual({
...current, draftId: 'draft-1', expectedUpdatedAt: prepared.expectedUpdatedAt,
bodyRevision: 'prepared-body', attachments: [attachment], attachmentRevision: 3
});
expect(mergePreparedComposeInput(current, { ...prepared, bodyRevision: undefined }).bodyRevision).toBeUndefined();
expect(current.bodyRevision).toBe('old-body');
});

test('treats attachments as content and preserves their optimistic revision in draft metadata', () => {
const attachment = { id: 'attachment-1', filename: 'evidence.txt', contentType: 'text/plain', size: 8, inline: false };
const input = { ...createEmptyComposeInput(), attachments: [attachment], attachmentRevision: 3 };
Expand Down
13 changes: 13 additions & 0 deletions src/lib/client/compose-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ export function withComposePersistence(
};
}

/** Attachment preparation persists an older snapshot; only its server metadata is authoritative. */
export function mergePreparedComposeInput(current: ComposeInput, prepared: ComposeInput): ComposeInput {
return {
...withComposePersistence(current, {
draftId: prepared.draftId,
expectedUpdatedAt: prepared.expectedUpdatedAt,
bodyRevision: prepared.bodyRevision ?? null
}),
attachments: prepared.attachments ?? [],
attachmentRevision: prepared.attachmentRevision ?? 0
};
}

export function hasComposeContent(input: ComposeInput | null) {
return Boolean(input && (parseAddressList(input.to ?? input.toEmail ?? '').length || parseAddressList(input.cc ?? '').length || parseAddressList(input.bcc ?? '').length || input.subject.trim() || input.body.trim() || input.html?.trim() || input.attachments?.length));
}
Expand Down
41 changes: 41 additions & 0 deletions src/lib/client/compose-shortcuts.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { describe, expect, test } from 'bun:test';
import { isComposeSendShortcut, isRecipientCommitKey, shouldHandleRecipientKey } from './compose-shortcuts';

const key = (overrides: Partial<KeyboardEvent> = {}) => ({
key: 'Enter', ctrlKey: false, metaKey: false, altKey: false, shiftKey: false,
isComposing: false, repeat: false, defaultPrevented: false, ...overrides
});

describe('compose keyboard actions', () => {
test('reserves Ctrl and Command Enter for sending without selecting a suggestion', () => {
for (const modifier of [{ ctrlKey: true }, { metaKey: true }]) {
expect(isComposeSendShortcut(key(modifier))).toBe(true);
expect(shouldHandleRecipientKey(key(modifier))).toBe(false);
expect(isRecipientCommitKey(key(modifier))).toBe(false);
}
expect(isComposeSendShortcut(key())).toBe(false);
expect(isRecipientCommitKey(key())).toBe(true);
});

test('ignores IME confirmation, held keys, already-handled events and extra modifiers', () => {
for (const suppressed of [
{ isComposing: true }, { keyCode: 229 }, { repeat: true },
{ defaultPrevented: true }, { altKey: true }, { shiftKey: true }
]) {
expect(isComposeSendShortcut(key({ ctrlKey: true, ...suppressed }))).toBe(false);
expect(shouldHandleRecipientKey(key(suppressed))).toBe(false);
expect(isRecipientCommitKey(key(suppressed))).toBe(false);
}
});

test('supports address separators without consuming ordinary text or navigation keys', () => {
for (const separator of [',', ',', ';', ';']) {
expect(isRecipientCommitKey(key({ key: separator }))).toBe(true);
expect(isRecipientCommitKey(key({ key: separator, isComposing: true }))).toBe(false);
}
for (const ordinary of ['a', '@', 'Tab', 'ArrowDown', 'Escape']) {
expect(isRecipientCommitKey(key({ key: ordinary }))).toBe(false);
expect(isComposeSendShortcut(key({ key: ordinary, ctrlKey: true }))).toBe(false);
}
});
});
22 changes: 22 additions & 0 deletions src/lib/client/compose-shortcuts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
type ComposeKeyEvent = Pick<KeyboardEvent,
'key' | 'ctrlKey' | 'metaKey' | 'altKey' | 'shiftKey' | 'isComposing' | 'repeat' | 'defaultPrevented'
> & { keyCode?: number };

function isFreshKey(event: ComposeKeyEvent) {
// Safari can report the final IME Enter as keyCode 229 without isComposing.
return !event.defaultPrevented && !event.isComposing && event.keyCode !== 229 && !event.repeat;
}

export function isComposeSendShortcut(event: ComposeKeyEvent) {
return isFreshKey(event) && event.key === 'Enter' && (event.ctrlKey || event.metaKey)
&& !event.altKey && !event.shiftKey;
}

/** Recipient selection must never consume a send shortcut or an IME candidate key. */
export function shouldHandleRecipientKey(event: ComposeKeyEvent) {
return isFreshKey(event) && !event.ctrlKey && !event.metaKey && !event.altKey && !event.shiftKey;
}

export function isRecipientCommitKey(event: ComposeKeyEvent) {
return shouldHandleRecipientKey(event) && ['Enter', ',', ',', ';', ';'].includes(event.key);
}
Loading
Loading