Skip to content

fix: file recurring Todoist imports - #83

Open
solankydev wants to merge 2 commits into
mainfrom
fix/todoist-repeat-post-import-filing
Open

fix: file recurring Todoist imports#83
solankydev wants to merge 2 commits into
mainfrom
fix/todoist-repeat-post-import-filing

Conversation

@solankydev

@solankydev solankydev commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • apply Todoist post-import filing to newly auto-imported recurring tasks
  • keep normal waiting source items on the existing manual import path
  • avoid repeating the move for recurring tasks already known locally

Tests

  • dotnet test src\Openza.Tasks.Tests\Openza.Tasks.Tests.csproj -c Release --no-restore --verbosity minimal

Summary by CodeRabbit

  • New Features

    • Tasks can now be automatically moved to a project after import when the sync rules call for it.
    • Todoist tasks now support project moves during sync.
  • Bug Fixes

    • Improved sync behavior so automatic project filing runs only for eligible recurring tasks.
    • Prevented duplicate project moves on later syncs.
    • Skipped project filing when a task is already in the correct project.

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@solankydev, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 18 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 8476698f-649c-4fa0-bcd6-258fba01d972

📥 Commits

Reviewing files that changed from the base of the PR and between b9658f7 and 7c182fc.

📒 Files selected for processing (2)
  • src/Openza.Tasks.Core/Sync/TaskSyncEngine.cs
  • src/Openza.Tasks.Tests/TaskSyncEngineTests.cs
📝 Walkthrough

Walkthrough

Introduces an ITaskProjectMoveProvider interface for moving tasks between projects, implements it in TodoistProvider, and integrates automatic post-import project moves into TaskSyncEngine's sync loop based on routing match and recurrence/date criteria. Adds test coverage via FakeProvider enhancements and four new sync tests.

Changes

Post-import project move feature

Layer / File(s) Summary
Project move contract and TodoistProvider
src/Openza.Tasks.Core/Sync/SyncContracts.cs, src/Openza.Tasks.Core/Sync/TodoistProvider.cs
Adds ITaskProjectMoveProvider with MoveTaskAsync(taskId, projectId, cancellationToken); TodoistProvider now implements this interface alongside ITaskDateUpdateProvider.
Sync engine routing and automatic move logic
src/Openza.Tasks.Core/Sync/TaskSyncEngine.cs
SyncAsync computes isNewSourceItem and routeMatch once per task, upserts routed tasks, and for new items conditionally calls MoveTaskAsync when ShouldApplyAutomaticPostImportAction passes; ApplyRouting and post-import helpers now operate on ProviderSourceRouteMatch and match.PostImportAction.MoveToProjectId.
Test coverage and FakeProvider support
src/Openza.Tasks.Tests/TaskSyncEngineTests.cs
Adds four tests covering filing of recurring tasks, skipping for non-recurring items, skipping when already in target project, and non-repetition across syncs; extends FakeProvider with ITaskProjectMoveProvider, ProjectId, ProjectMoves, and MoveTaskAsync.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant TaskSyncEngine
  participant ApplyRouting
  participant ShouldApplyAutomaticPostImportAction
  participant TodoistProvider

  TaskSyncEngine->>ApplyRouting: apply routeMatch to task
  ApplyRouting-->>TaskSyncEngine: routedTask
  TaskSyncEngine->>TaskSyncEngine: upsert routedTask
  alt isNewSourceItem
    TaskSyncEngine->>ShouldApplyAutomaticPostImportAction: evaluate routeMatch, task
    ShouldApplyAutomaticPostImportAction-->>TaskSyncEngine: true
    TaskSyncEngine->>TodoistProvider: MoveTaskAsync(taskId, moveToProjectId)
    TodoistProvider-->>TaskSyncEngine: move recorded
  else existing item
    TaskSyncEngine->>TaskSyncEngine: increment sourceItemsUpdated
  end
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly reflects the main change: recurring Todoist imports now get filed after auto-import.
Description check ✅ Passed The description includes a relevant summary and test command, though it omits the template's Notes and Screenshots sections.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/todoist-repeat-post-import-filing

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/Openza.Tasks.Core/Sync/TaskSyncEngine.cs (1)

189-192: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

RemoveProviderProjectPrefix hardcodes the Todoist prefix in a provider-agnostic engine.

ITaskProjectMoveProvider is a generic contract, but RemoveProviderProjectPrefix only strips "todoist_". If another provider (e.g., Microsoft ToDo with "mstodo_") later implements ITaskProjectMoveProvider, IsInProviderProject will fail to detect that a task is already in the target project, causing unnecessary move calls. Consider deriving the prefix from task.IntegrationId (the same pattern used in BuildParentExternalId).

♻️ Proposed refactor: use IntegrationId to resolve prefix
-    private static string RemoveProviderProjectPrefix(string projectId) =>
-        projectId.StartsWith("todoist_", StringComparison.Ordinal)
-            ? projectId["todoist_".Length..]
-            : projectId;
+    private static string RemoveProviderProjectPrefix(string projectId, string integrationId)
+    {
+        var prefix = integrationId switch
+        {
+            IntegrationIds.Todoist => "todoist_",
+            IntegrationIds.MicrosoftToDo => "mstodo_",
+            _ => string.Empty,
+        };
+        return !string.IsNullOrEmpty(prefix) && projectId.StartsWith(prefix, StringComparison.Ordinal)
+            ? projectId[prefix.Length..]
+            : projectId;
+    }

Then update the call site in IsInProviderProject to pass task.IntegrationId.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/Openza.Tasks.Core/Sync/TaskSyncEngine.cs` around lines 189 - 192,
`RemoveProviderProjectPrefix` is provider-specific today because it hardcodes
the Todoist prefix, which breaks generic `ITaskProjectMoveProvider` handling.
Update `TaskSyncEngine` so the prefix is derived from `task.IntegrationId` the
same way `BuildParentExternalId` does, and pass `task.IntegrationId` from
`IsInProviderProject` into `RemoveProviderProjectPrefix`. Keep the method
responsible only for stripping the resolved provider prefix so other
integrations like Microsoft To Do work correctly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/Openza.Tasks.Core/Sync/TaskSyncEngine.cs`:
- Around line 59-65: In TaskSyncEngine.Sync, the current order in the
upsert-and-move flow causes a failed MoveTaskAsync to leave the source item
persisted and prevents retries on later syncs. Update the logic around
UpsertProviderSourceItemAsync and MoveTaskAsync so the automatic post-import
move executes first for new items, then persist the source item only after a
successful move. Keep the check using ShouldApplyAutomaticPostImportAction,
isNewSourceItem, and routeMatch.PostImportAction intact while swapping the
persistence order to preserve retry behavior.

---

Nitpick comments:
In `@src/Openza.Tasks.Core/Sync/TaskSyncEngine.cs`:
- Around line 189-192: `RemoveProviderProjectPrefix` is provider-specific today
because it hardcodes the Todoist prefix, which breaks generic
`ITaskProjectMoveProvider` handling. Update `TaskSyncEngine` so the prefix is
derived from `task.IntegrationId` the same way `BuildParentExternalId` does, and
pass `task.IntegrationId` from `IsInProviderProject` into
`RemoveProviderProjectPrefix`. Keep the method responsible only for stripping
the resolved provider prefix so other integrations like Microsoft To Do work
correctly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 54419728-e7e0-4e78-8d72-5460f592018f

📥 Commits

Reviewing files that changed from the base of the PR and between 16c00bf and b9658f7.

📒 Files selected for processing (4)
  • src/Openza.Tasks.Core/Sync/SyncContracts.cs
  • src/Openza.Tasks.Core/Sync/TaskSyncEngine.cs
  • src/Openza.Tasks.Core/Sync/TodoistProvider.cs
  • src/Openza.Tasks.Tests/TaskSyncEngineTests.cs

Comment thread src/Openza.Tasks.Core/Sync/TaskSyncEngine.cs Outdated
- Fix P1: retry Todoist filing when the move fails before import persistence (#3553587567)
- Fix P2: derive provider project prefixes from the task integration (#PRR_kwDOQn0m5s8AAAABFhNggQ)

Addresses: #3553587567, #PRR_kwDOQn0m5s8AAAABFhNggQ
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.

1 participant