Skip to content

Implement background tasks - #193

Merged
HalidOdat merged 8 commits into
mainfrom
feature/background-tasks
Aug 4, 2026
Merged

Implement background tasks#193
HalidOdat merged 8 commits into
mainfrom
feature/background-tasks

Conversation

@HalidOdat

Copy link
Copy Markdown
Member

This pull request introduces background task support for periodic repository synchronization and integrates the new background task APIs into the app. The main changes include adding the new stride_background crate and Dart API, updating the TaskBloc to use background tasks for syncing repositories, and updating dependencies and generated bindings to support these features.

Background task support and integration:

  • Added the new stride_background crate to the workspace and as a dependency in Cargo.toml, and updated dependencies to include async-trait for async background tasks. [1] [2] [3]

Flutter/Dart API and code changes:

  • Added the generated Dart API for background tasks in app/lib/bridge/api/background.dart, including the BackgroundResult type and methods for initializing and executing background tasks.
  • Updated app/lib/blocs/tasks_bloc.dart to register and unregister periodic background sync tasks per repository using the new background API, replacing previous timer-based logic. Now, syncs are scheduled as background tasks and handled more robustly. [1] [2] [3]

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds background task infrastructure spanning Rust (a new stride_background crate and FRB bindings) and Flutter/Dart (Workmanager-based scheduling) to support periodic repository sync running outside the foreground UI.

Changes:

  • Added a new Rust stride_background crate and wired it into the workspace and flutter_bridge error model.
  • Introduced new Flutter Rust Bridge APIs for background task init/execute and a Dart-side background task manager built on workmanager.
  • Updated the Flutter TaskBloc + Tasks drawer UI to schedule, cancel, and visualize per-repository background sync tasks.

Reviewed changes

Copilot reviewed 20 out of 23 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
crates/flutter_bridge/src/frb_generated.rs Regenerated FRB bindings to expose background task APIs and result types.
crates/flutter_bridge/src/api/mod.rs Exposes the new background API module.
crates/flutter_bridge/src/api/error.rs Adds Background error kind and an is_background() discriminator.
crates/flutter_bridge/src/api/background.rs Implements Rust-side background task entrypoint/stream hook.
crates/flutter_bridge/Cargo.toml Adds stride_background + async-trait dependencies.
crates/background/src/tests.rs Adds initial unit tests for the background runner.
crates/background/src/lib.rs Introduces the background task runtime (tokio runtime on a dedicated thread).
crates/background/src/error.rs Defines background task error types and downcasting helpers.
crates/background/Cargo.toml Adds the new stride_background crate manifest.
Cargo.toml Adds crates/background to the workspace and workspace deps; adds async-trait.
Cargo.lock Locks new Rust dependencies (tokio-related + new crate).
app/pubspec.yaml Adds workmanager and async dependencies for background scheduling.
app/pubspec.lock Locks new Dart dependencies.
app/lib/routes/tasks_route.dart Updates drawer UI to reflect background sync status per repository.
app/lib/main.dart Initializes background system during app startup.
app/lib/bridge/frb_generated.io.dart Updates generated IO-side FRB bindings for background types.
app/lib/bridge/frb_generated.dart Updates generated FRB API surface to include background init/execute.
app/lib/bridge/api/settings.dart Minor generated-comment update.
app/lib/bridge/api/error.dart Adds RustError.isBackground() to the Dart API.
app/lib/bridge/api/background.freezed.dart Generated Freezed model for BackgroundResult.
app/lib/bridge/api/background.dart Generated Dart API for background init/execute and result type.
app/lib/blocs/tasks_bloc.dart Migrates periodic sync from timers to background tasks; schedules per-repo work.
app/lib/background.dart Adds Dart background task framework + desktop Workmanager shim.
Files not reviewed (1)
  • app/lib/bridge/api/background.freezed.dart: Generated file
Suppressed comments (2)

crates/background/src/tests.rs:54

  • Same compare_exchange issue as notify: transitioning true -> false returns Ok(true) on success, so == Ok(false) is never satisfied and reset() never resets the flag.
        if self
            .flag
            .compare_exchange(true, false, Ordering::SeqCst, Ordering::SeqCst)
            == Ok(false)
        {}

crates/flutter_bridge/src/api/background.rs:62

  • Same issue as on_task_start: unwrapping StreamSink::add can panic during shutdown / stream cancellation.
        state.stream_sink.add(result).unwrap();

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/background/src/lib.rs Outdated
Comment thread crates/background/src/lib.rs
Comment thread crates/background/src/lib.rs Outdated
Comment thread crates/background/src/tests.rs
Comment thread crates/background/src/tests.rs
Comment thread crates/flutter_bridge/src/api/background.rs
Comment thread crates/flutter_bridge/src/api/background.rs Outdated
Comment thread app/lib/blocs/tasks_bloc.dart
Comment thread app/lib/blocs/tasks_bloc.dart
Comment thread app/lib/background.dart
@HalidOdat
HalidOdat force-pushed the feature/background-tasks branch from 36f0d98 to 0e9e370 Compare August 4, 2026 07:29
@HalidOdat
HalidOdat force-pushed the feature/background-tasks branch from 0e9e370 to a6247f2 Compare August 4, 2026 07:31
@HalidOdat
HalidOdat merged commit a6b8268 into main Aug 4, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants