Skip to content

fix(wework): track project tasks with stable APIs - #2427

Merged
qdaxb merged 1 commit into
mainfrom
fix/wework-project-task-tracking
Aug 5, 2026
Merged

fix(wework): track project tasks with stable APIs#2427
qdaxb merged 1 commit into
mainfrom
fix/wework-project-task-tracking

Conversation

@qdaxb

@qdaxb qdaxb commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • remove duplicate Backend task-tracking and status-sync aggregate endpoints
  • compose existing create-TODO, bind-task, read-context, and update-TODO APIs in Wework
  • deduplicate concurrent associations and reuse a created TODO when a binding retry is needed
  • ensure only Backend-backed project spaces are sent as runtime cloud context
  • document the stable cross-version tracking flow in Chinese and English

Root cause

The desktop client called newly added aggregate endpoints that were not present on the deployed Backend, causing route-level 404 Not Found when a task was created from a linked project space.

Validation

  • pnpm --filter wework exec vitest run src/api/deliveries.test.ts src/api/local/localDelivery.test.ts src/features/todo/projectSpaceSelection.test.ts
  • pnpm --filter wework exec tsc --noEmit
  • focused Wework ESLint
  • uv run pytest tests/api/test_cloud_projects_api.py tests/api/test_deliveries_api.py (37 passed)
  • Black and isort checks
  • pnpm --filter wework e2e:desktop -- --segment core-task-flow (passed; 6m 57s)
  • pre-push ESLint, TypeScript, unit tests, Black, isort, Python syntax, settings, and Alembic checks

Summary by CodeRabbit

  • New Features

    • Improved runtime task tracking with concurrent-request deduplication and reuse of existing tasks.
    • Added retry handling when task binding temporarily fails.
    • Added task status updates for running, succeeded, failed, and cancelled executions.
    • Limited runtime task creation to valid cloud projects.
  • Documentation

    • Expanded cloud project collaboration guidance with task orchestration, authorization, retry, and concurrency details.
  • Bug Fixes

    • Improved handling of missing task contexts and valid status transitions.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Wework now performs cloud runtime-task tracking and status synchronization locally. Backend tracking schemas, endpoints, helper logic, and tests were removed. Project submission now supplies cloud IDs only for backend projects.

Changes

Runtime task tracking

Layer / File(s) Summary
Remove backend tracking contracts and endpoints
backend/app/schemas/delivery.py, backend/app/services/loop_items/service.py, backend/tests/api/test_cloud_projects_api.py
Removed runtime tracking schemas, backend endpoints, the public binding helper, and the related API test.
Move tracking orchestration into Wework
wework/src/api/deliveries.ts, wework/src/api/deliveries.test.ts, docs/en/wegent/developer-guide/cloud-project-collaboration.md, docs/zh/wegent/developer-guide/cloud-project-collaboration.md
Added request deduplication, task-context lookup, loop-item reuse or creation, binding, retry handling, and versioned status updates. Added API coverage and documented the workflow.
Share status transitions and restrict project scope
wework/src/api/local/localDelivery.ts, wework/src/features/todo/projectSpaceSelection.ts, wework/src/features/todo/projectSpaceSelection.test.ts, wework/src/components/layout/DesktopWorkbenchMain.tsx
Shared task-status transition logic across delivery APIs. Cloud project IDs now apply only to backend projects, with corresponding submission wiring and tests.

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

Sequence Diagram(s)

sequenceDiagram
  participant Wework
  participant CloudContext as Cloud task context API
  participant LoopItems as Loop item API
  Wework->>CloudContext: Resolve task context
  Wework->>LoopItems: Find or create and bind loop item
  Wework->>CloudContext: Resolve context for status update
  Wework->>LoopItems: Patch item status with version
Loading

Possibly related PRs

Suggested reviewers: micro66

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: fixing Wework project task tracking by using stable APIs.
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 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/wework-project-task-tracking

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.

@qdaxb
qdaxb marked this pull request as ready for review August 5, 2026 04:28
@qdaxb
qdaxb enabled auto-merge August 5, 2026 04:28

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@docs/zh/wegent/developer-guide/cloud-project-collaboration.md`:
- Around line 149-150: Add /v1/runtime-tasks/cloud-context to the cloud-project
API inventory in both
docs/zh/wegent/developer-guide/cloud-project-collaboration.md (lines 149-150)
and docs/en/wegent/developer-guide/cloud-project-collaboration.md (lines
149-150), identifying it as the task-context lookup API used before TODO
updates.
🪄 Autofix

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: b1d0373c-e0a0-45b7-b8c1-0acefd8a1021

📥 Commits

Reviewing files that changed from the base of the PR and between a6c3ead and 6a918f5.

📒 Files selected for processing (12)
  • backend/app/api/endpoints/deliveries.py
  • backend/app/schemas/delivery.py
  • backend/app/services/loop_items/service.py
  • backend/tests/api/test_cloud_projects_api.py
  • docs/en/wegent/developer-guide/cloud-project-collaboration.md
  • docs/zh/wegent/developer-guide/cloud-project-collaboration.md
  • wework/src/api/deliveries.test.ts
  • wework/src/api/deliveries.ts
  • wework/src/api/local/localDelivery.ts
  • wework/src/components/layout/DesktopWorkbenchMain.tsx
  • wework/src/features/todo/projectSpaceSelection.test.ts
  • wework/src/features/todo/projectSpaceSelection.ts
💤 Files with no reviewable changes (4)
  • backend/tests/api/test_cloud_projects_api.py
  • backend/app/services/loop_items/service.py
  • backend/app/schemas/delivery.py
  • backend/app/api/endpoints/deliveries.py

Comment on lines +149 to +150
Wework 把新运行任务加入云项目空间时,使用已有的基础能力组合完成:先创建 `LoopItem`,再绑定运行任务;运行状态变化时先读取任务上下文,再更新对应 TODO。Backend 不提供仅为这条编排流程设计的聚合追踪接口,因此桌面端和 Backend 可以独立发布,同时仍由 TODO 创建、任务绑定和乐观锁更新这三类稳定 API 保证行为一致。桌面端会对同一运行任务的并发关联请求去重;如果绑定临时失败,会复用已创建的 TODO 后重试,避免产生重复卡片。

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Document the cloud-context API route.

The tracking flow reads task context before it updates a TODO. The API inventories list /v1/runtime-tasks/loop-item, but the implementation uses /v1/runtime-tasks/cloud-context. Add this route and identify it as the task-context lookup API.

  • docs/zh/wegent/developer-guide/cloud-project-collaboration.md#L149-L150: Add /v1/runtime-tasks/cloud-context and name its task-context purpose.
  • docs/en/wegent/developer-guide/cloud-project-collaboration.md#L149-L150: Add /v1/runtime-tasks/cloud-context and name its task-context purpose.
📍 Affects 2 files
  • docs/zh/wegent/developer-guide/cloud-project-collaboration.md#L149-L150 (this comment)
  • docs/en/wegent/developer-guide/cloud-project-collaboration.md#L149-L150
🤖 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 `@docs/zh/wegent/developer-guide/cloud-project-collaboration.md` around lines
149 - 150, Add /v1/runtime-tasks/cloud-context to the cloud-project API
inventory in both docs/zh/wegent/developer-guide/cloud-project-collaboration.md
(lines 149-150) and
docs/en/wegent/developer-guide/cloud-project-collaboration.md (lines 149-150),
identifying it as the task-context lookup API used before TODO updates.

@qdaxb
qdaxb added this pull request to the merge queue Aug 5, 2026
Merged via the queue into main with commit 74d5db1 Aug 5, 2026
70 of 74 checks passed
@qdaxb
qdaxb deleted the fix/wework-project-task-tracking branch August 5, 2026 05:02
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