feat(offline): tier 2 phase 4 — per-row pending-sync indicators

A small cloud-upload glyph appears next to any row whose id has a
queued offline write (offline-created temp ids and pending edits both
count). Tooltip reads "Pending sync — will save when online". Renders
nothing during normal online operation so the list stays clean.

- DB: `watchPendingIds(domain)` streams the union of target_id and
  temp_id across the queue, scoped per domain.
- Per-domain Riverpod stream providers for notes / tasks / projects.
- New `PendingSyncBadge` widget — used by KnowledgeItemCard (both
  list and grid variants), `_ProjectCard`, and `_TaskRow` in the
  project workspace.

flutter analyze clean; 21 tests pass. Closes #147 — all four phases
of Tier 2 offline mode are in place.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-04-28 22:14:36 -04:00
parent 7df7b5ff85
commit 76aff4ea9e
6 changed files with 135 additions and 17 deletions
+24 -12
View File
@@ -4,6 +4,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import '../../core/constants.dart';
import '../../data/local/database.dart';
import '../../data/models/milestone.dart';
import '../../data/models/project.dart';
import '../../data/models/task.dart';
@@ -11,6 +12,7 @@ import '../../providers/api_client_provider.dart';
import '../../providers/milestones_provider.dart';
import '../../providers/projects_provider.dart';
import '../../providers/tasks_provider.dart';
import '../../widgets/pending_sync_badge.dart';
class ProjectTasksScreen extends ConsumerStatefulWidget {
final int projectId;
@@ -346,18 +348,28 @@ class _TaskRow extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
task.title.isNotEmpty ? task.title : 'Untitled',
style: theme.textTheme.titleSmall?.copyWith(
decoration: effectiveStatus == TaskStatus.done
? TextDecoration.lineThrough
: null,
color: effectiveStatus == TaskStatus.done
? theme.colorScheme.onSurfaceVariant
: null,
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
Row(
children: [
Flexible(
child: Text(
task.title.isNotEmpty ? task.title : 'Untitled',
style: theme.textTheme.titleSmall?.copyWith(
decoration: effectiveStatus == TaskStatus.done
? TextDecoration.lineThrough
: null,
color: effectiveStatus == TaskStatus.done
? theme.colorScheme.onSurfaceVariant
: null,
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
),
PendingSyncBadge(
domain: kSyncDomainTasks,
id: task.id,
),
],
),
if (task.dueDate != null) ...[
const SizedBox(height: 2),
+8 -1
View File
@@ -3,8 +3,10 @@ import 'package:lucide_icons/lucide_icons.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import '../../data/local/database.dart';
import '../../data/models/project.dart';
import '../../providers/projects_provider.dart';
import '../../widgets/pending_sync_badge.dart';
class ProjectsScreen extends ConsumerWidget {
const ProjectsScreen({super.key});
@@ -50,7 +52,12 @@ class _ProjectCard extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ListTile(
title: Text(project.title),
title: Row(
children: [
Flexible(child: Text(project.title)),
PendingSyncBadge(domain: kSyncDomainProjects, id: project.id),
],
),
subtitle: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [