Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
c34172b
같은 대화의 메일을 한 스레드로 묶어 보기 (1단계)
littlebit0 Nov 21, 2026
fd07017
스레드 묶기 보완: 답장 체인 루트 해석, 스레드 id 해시, 스레드 캐시 autoDispose
littlebit0 Nov 21, 2026
3d6bdad
기존 저장 메일의 스레드 메타데이터 일회성 보충: 헤더 없는 메일을 동기화 때 최대 200통씩 50통 배치로 다시 조회
littlebit0 Nov 21, 2026
3d71fdc
References·Message-ID 헤더 크기 제한: 파싱 전 16KiB로 자르고 ID 길이 998자·개수 20개(루트 …
littlebit0 Nov 21, 2026
bb1804d
스레드 메타데이터 보충을 백그라운드 50통 배치로 끝까지 진행하고, 답장 루트 해석을 O(n)으로 개선
littlebit0 Nov 21, 2026
3e0a1b4
백필 저장을 배치 단위로 묶고, 계정 중지·완료 처리와 분류 비용을 개선
littlebit0 Nov 21, 2026
0e744e6
Merge remote-tracking branch 'origin/main' into feat/issue-33-thread-…
littlebit0 Nov 26, 2026
53ef29a
Merge remote-tracking branch 'origin/main' into feat/issue-33-thread-…
littlebit0 Nov 26, 2026
93a982f
Merge remote-tracking branch 'origin/main' into feat/issue-33-thread-…
littlebit0 Nov 26, 2026
2ce5531
스레드 backfill 중 UIDVALIDITY가 바뀐 배치를 거부
littlebit0 Nov 26, 2026
a4298c9
Merge remote-tracking branch 'origin/main' into feat/issue-33-thread-…
littlebit0 Nov 26, 2026
44acf89
Merge remote-tracking branch 'origin/main' into feat/issue-33-thread-…
littlebit0 Nov 26, 2026
873343a
Merge remote-tracking branch 'origin/main' into feat/issue-33-thread-…
littlebit0 Nov 26, 2026
c5e59c7
Merge remote-tracking branch 'origin/main' into feat/issue-33-thread-…
littlebit0 Nov 26, 2026
74c6481
Merge remote-tracking branch 'origin/main' into feat/issue-33-thread-…
littlebit0 Nov 26, 2026
b3c7ee4
Merge remote-tracking branch 'origin/main' into feat/issue-33-thread-…
littlebit0 Nov 26, 2026
8513cf2
Merge remote-tracking branch 'origin/main' into feat/issue-33-thread-…
littlebit0 Nov 26, 2026
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
12 changes: 12 additions & 0 deletions apps/client/lib/core/app_router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:go_router/go_router.dart';

import '../features/accounts/account_mailbox_page.dart';
import '../features/accounts/accounts_page.dart';
import '../features/accounts/thread_page.dart';
import '../features/message/compose_page.dart';
import '../features/message/message_page.dart';
import '../features/message/reply_draft.dart';
Expand Down Expand Up @@ -34,6 +35,17 @@ final appRouterProvider = Provider<GoRouter>((ref) {
),
),
),
GoRoute(
path: '/accounts/:accountId/threads/:threadId',
pageBuilder: (context, state) => _verticalPage(
state: state,
disableTransition: true,
child: ThreadPage(
accountId: state.pathParameters['accountId']!,
threadId: state.pathParameters['threadId']!,
),
),
),
GoRoute(
path: '/accounts/:accountId/messages/:messageId',
pageBuilder: (context, state) => _verticalPage(
Expand Down
6 changes: 6 additions & 0 deletions apps/client/lib/core/i18n/language_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,12 @@ class AppStrings {
'password' => _ko ? '비밀번호' : 'Password',
_ => mode,
};
String get threadView => _ko ? '대화 보기' : 'Conversation view';
String get threadViewDescription => _ko
? '같은 대화의 메일을 한 줄로 묶어 보여줍니다.'
: 'Group mail from the same conversation into one row.';
String get thread => _ko ? '대화' : 'Conversation';
String threadMessageCount(int count) => _ko ? '$count통' : '$count';
String get mailSending => _ko ? '메일을 보내는 중입니다.' : 'Sending mail...';
String get undoSend => _ko ? '보내기 취소' : 'Undo send';
String get sendCancelled =>
Expand Down
34 changes: 22 additions & 12 deletions apps/client/lib/features/accounts/account_mailbox_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,11 @@ class _MailboxContentState extends ConsumerState<_MailboxContent> {
final _searchController = TextEditingController();
Future<List<MailSummary>>? _search;

bool get _isSyncing =>
const {'syncing', 'validating'}.contains(widget.account.syncStatus);
static bool _busy(MailAccountSummary account) =>
account.threadBackfilling ||
const {'syncing', 'validating'}.contains(account.syncStatus);

bool get _isSyncing => _busy(widget.account);

@override
void initState() {
Expand All @@ -80,10 +83,7 @@ class _MailboxContentState extends ConsumerState<_MailboxContent> {
_searchController.clear();
_search = null;
}
final wasSyncing = const {
'syncing',
'validating',
}.contains(oldWidget.account.syncStatus);
final wasSyncing = _busy(oldWidget.account);
if (oldWidget.account.id == widget.account.id &&
wasSyncing &&
!_isSyncing) {
Expand All @@ -94,7 +94,7 @@ class _MailboxContentState extends ConsumerState<_MailboxContent> {
});
}
if (oldWidget.account.id != widget.account.id ||
oldWidget.account.syncStatus != widget.account.syncStatus) {
_busy(oldWidget.account) != _isSyncing) {
_configureRefreshTimer();
}
}
Expand Down Expand Up @@ -158,8 +158,9 @@ class _MailboxContentState extends ConsumerState<_MailboxContent> {
if (mounted && _refreshTimer == null) _scheduleRefresh();
}

Widget _messageList(List<MailSummary> items) {
Widget _messageList(List<MailSummary> items, {bool threaded = false}) {
final account = widget.account;
final strings = ref.read(appStringsProvider);
return ListView.separated(
itemCount: items.length,
separatorBuilder: (context, index) => const Divider(height: 1),
Expand Down Expand Up @@ -189,11 +190,18 @@ class _MailboxContentState extends ConsumerState<_MailboxContent> {
const Icon(Icons.star, size: 18, color: Colors.amber),
const SizedBox(width: 6),
],
Text(message.receivedAtLabel),
Text(
threaded && message.threadCount > 1
? '${strings.threadMessageCount(message.threadCount)}\n${message.receivedAtLabel}'
: message.receivedAtLabel,
textAlign: TextAlign.end,
),
],
),
onTap: () => context.go(
'/accounts/${account.id}/messages/${Uri.encodeComponent(message.id)}',
threaded && message.threadCount > 1
? '/accounts/${account.id}/threads/${Uri.encodeComponent(message.threadId!)}'
: '/accounts/${account.id}/messages/${Uri.encodeComponent(message.id)}',
extra: const {'disableTransition': true},
),
);
Expand All @@ -205,6 +213,7 @@ class _MailboxContentState extends ConsumerState<_MailboxContent> {
Widget build(BuildContext context) {
final account = widget.account;
final messages = ref.watch(accountMessagesProvider(account.id));
final threaded = ref.watch(threadViewProvider);
final strings = ref.watch(appStringsProvider);

return Column(
Expand Down Expand Up @@ -298,7 +307,8 @@ class _MailboxContentState extends ConsumerState<_MailboxContent> {
},
)
: messages.when(
data: (items) {
data: (all) {
final items = threaded ? groupByThread(all) : all;
if (items.isEmpty) {
return Center(
child: Column(
Expand Down Expand Up @@ -337,7 +347,7 @@ class _MailboxContentState extends ConsumerState<_MailboxContent> {
);
}

return _messageList(items);
return _messageList(items, threaded: threaded);
},
loading: () =>
const Center(child: CircularProgressIndicator()),
Expand Down
18 changes: 18 additions & 0 deletions apps/client/lib/features/accounts/account_providers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,21 @@ final accountMessagesProvider =
FutureProvider.family<List<MailSummary>, String>((ref, accountId) {
return ref.watch(mailApiClientProvider).fetchAccountMessages(accountId);
});

final threadMessagesProvider = FutureProvider.autoDispose
.family<List<MailSummary>, ({String accountId, String threadId})>(
(ref, key) {
return ref
.watch(mailApiClientProvider)
.fetchThread(key.accountId, key.threadId);
});

class ThreadViewController extends Notifier<bool> {
@override
bool build() => true;

void set(bool value) => state = value;
}

final threadViewProvider =
NotifierProvider<ThreadViewController, bool>(ThreadViewController.new);
72 changes: 72 additions & 0 deletions apps/client/lib/features/accounts/thread_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';

import '../../core/i18n/language_controller.dart';
import '../../widgets/app_shell.dart';
import 'account_providers.dart';

class ThreadPage extends ConsumerWidget {
const ThreadPage({
super.key,
required this.accountId,
required this.threadId,
});

final String accountId;
final String threadId;

@override
Widget build(BuildContext context, WidgetRef ref) {
final strings = ref.watch(appStringsProvider);
final messages = ref.watch(
threadMessagesProvider((accountId: accountId, threadId: threadId)),
);

return AppShell(
selectedDestinationId: AppShell.accountDestinationId(accountId),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
AppBar(
leading: BackButton(
onPressed: () => context.go('/accounts/$accountId/mail'),
),
title: Text(strings.thread),
),
Expanded(
child: messages.when(
data: (items) => ListView.separated(
itemCount: items.length,
separatorBuilder: (context, index) => const Divider(height: 1),
itemBuilder: (context, index) {
final message = items[index];
return ListTile(
title: Text(
message.subject,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
subtitle: Text(
'${message.sender}\n${message.snippet}',
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
trailing: Text(message.receivedAtLabel),
onTap: () => context.go(
'/accounts/$accountId/messages/${Uri.encodeComponent(message.id)}',
extra: const {'disableTransition': true},
),
);
},
),
loading: () => const Center(child: CircularProgressIndicator()),
error: (error, stackTrace) =>
Center(child: Text(strings.mailLoadFailedTitle)),
),
),
],
),
);
}
}
7 changes: 7 additions & 0 deletions apps/client/lib/features/settings/settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../core/i18n/language_controller.dart';
import '../../services/mail_api_client.dart';
import '../../services/push_service.dart';
import '../accounts/account_providers.dart';
import '../accounts/accounts_page.dart' show friendlyError;
import '../../widgets/app_shell.dart';

Expand Down Expand Up @@ -46,6 +47,12 @@ class SettingsPage extends ConsumerWidget {
},
),
),
SwitchListTile(
value: ref.watch(threadViewProvider),
onChanged: ref.read(threadViewProvider.notifier).set,
title: Text(strings.threadView),
subtitle: Text(strings.threadViewDescription),
),
ListTile(
leading: const Icon(Icons.undo),
title: Text(strings.undoSendSetting),
Expand Down
33 changes: 33 additions & 0 deletions apps/client/lib/services/mail_api_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,19 @@ class MailApiClient {
.toList();
}

Future<List<MailSummary>> fetchThread(
String accountId,
String threadId,
) async {
final response = await _dio.get<List<dynamic>>(
'/accounts/$accountId/threads/${Uri.encodeComponent(threadId)}',
);
final data = response.data ?? [];
return data
.map((item) => MailSummary.fromJson(item as Map<String, dynamic>))
.toList();
}

Future<List<MailSummary>> searchAccountMessages(
String accountId,
String query,
Expand Down Expand Up @@ -395,6 +408,8 @@ class MailSummary {
required this.snippet,
required this.receivedAtLabel,
required this.unread,
this.threadId,
this.threadCount = 1,
this.flagged = false,
});

Expand All @@ -404,6 +419,8 @@ class MailSummary {
final String snippet;
final String receivedAtLabel;
final bool unread;
final String? threadId;
final int threadCount;
final bool flagged;

factory MailSummary.fromJson(Map<String, dynamic> json) {
Expand All @@ -413,12 +430,24 @@ class MailSummary {
subject: json['subject'] as String? ?? '',
snippet: json['snippet'] as String? ?? '',
receivedAtLabel: _formatReceivedAt(json['receivedAt'] as String?),
threadId: json['threadId'] as String?,
threadCount: json['threadCount'] as int? ?? 1,
unread: !(json['seen'] as bool? ?? false),
flagged: json['flagged'] as bool? ?? false,
);
}
}

/// Keeps the first (newest) message of each thread. Mail without a thread id
/// stays as its own row.
List<MailSummary> groupByThread(List<MailSummary> items) {
final seen = <String>{};
return [
for (final item in items)
if (item.threadId == null || seen.add(item.threadId!)) item,
];
}

class MessageDetail {
const MessageDetail({
required this.id,
Expand Down Expand Up @@ -549,6 +578,7 @@ class MailAccountSummary {
this.syncErrorCode,
required this.initialSync,
required this.lastSyncedAtLabel,
this.threadBackfilling = false,
this.idleSupported,
this.capabilitiesCheckedAtLabel = '',
this.notificationsEnabled = true,
Expand All @@ -564,6 +594,8 @@ class MailAccountSummary {
final String? syncErrorCode;
final InitialSyncOption? initialSync;
final String lastSyncedAtLabel;
// Server is still filling thread metadata for older messages.
final bool threadBackfilling;
final bool notificationsEnabled;

/// Null until the server has logged in and read the IMAP capabilities.
Expand All @@ -588,6 +620,7 @@ class MailAccountSummary {
json['initialSync'] as Map<String, dynamic>)
: null,
lastSyncedAtLabel: _formatReceivedAt(json['lastSyncedAt'] as String?),
threadBackfilling: json['threadBackfill'] == 'running',
idleSupported: capabilities?['idle'] as bool?,
capabilitiesCheckedAtLabel:
_formatReceivedAt(capabilities?['checkedAt'] as String?),
Expand Down
3 changes: 2 additions & 1 deletion apps/client/test/message_reply_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ void main() {

container.read(appRouterProvider).go('/settings');
await tester.pumpAndSettle();
expect(find.byType(SwitchListTile), findsNothing);
// Only the working conversation-view toggle; the dead push switch is gone.
expect(find.byType(SwitchListTile), findsOneWidget);
});
}
Loading
Loading