fix(wework): make task supervision lifecycle atomic - #2396
Conversation
|
Warning Review limit reached
Next review available in: 12 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (24)
📝 WalkthroughWalkthroughThe change adds pre-creation supervisor configuration. The executor persists initial settings during task creation and waits for runtime session readiness before evaluation. The desktop UI adds controlled configuration dialogs, pending indicators, runtime status displays, forwarding logic, tests, localization, and documentation. ChangesSupervisor lifecycle
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant User
participant DesktopWorkbenchMain
participant ProjectChatComposer
participant RuntimeMessaging
participant Executor
participant RuntimeSession
User->>ProjectChatComposer: Configure supervisor
ProjectChatComposer->>DesktopWorkbenchMain: Invoke configuration callback
User->>ProjectChatComposer: Submit first task message
ProjectChatComposer->>RuntimeMessaging: Send initialSupervisor
RuntimeMessaging->>Executor: Create task with supervisor settings
Executor->>RuntimeSession: Establish runtime session
RuntimeSession-->>DesktopWorkbenchMain: Return task readiness
DesktopWorkbenchMain->>ProjectChatComposer: Clear pending indicator
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 3📝 Generate docstrings 💡
⚔️ Resolve merge conflicts 💡
🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
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. Comment |
6198e7a to
02e2010
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (3)
wework/src/components/layout/TaskSupervisorControl.test.tsx (1)
74-99: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a test for clicking disable when only
initialConfigis set.This test confirms the disable button renders when only
initialConfigis present (Line 98), but no test clicks it and assertsonClearis called. Add afireEvent.clickontask-supervisor-disable-buttonand assertonClearis invoked, to cover the new pre-task disable path.🤖 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 `@wework/src/components/layout/TaskSupervisorControl.test.tsx` around lines 74 - 99, Extend the test “reopens supervision configured before the task starts” to click task-supervisor-disable-button and assert that the onClear mock is called, covering the pre-task disable behavior when only initialConfig is provided.wework/src/i18n/locales/zh-CN/common.json (1)
158-163: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAlign
supervisor_titlewording across locales.The English
supervisor_titlestays "Personal supervisor," but this Chinese update simplifies it to "监督" ("Supervision"), dropping the "personal" nuance present in English. Both strings render from the same UI element (TaskSupervisorControl.tsx's dialog heading), so the two locales now convey different meanings. Align the wording in one of the two files.As per path instructions: "Add new user-facing copy to the appropriate Wework namespace in both
src/i18n/locales/en/andsrc/i18n/locales/zh-CN/."🤖 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 `@wework/src/i18n/locales/zh-CN/common.json` around lines 158 - 163, Update the zh-CN supervisor_title translation in the common locale to preserve the “personal supervisor” meaning conveyed by the English supervisor_title, while leaving the other supervisor translations unchanged.Source: Path instructions
wework/src/components/layout/TaskSupervisorControl.tsx (1)
122-345: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy liftSplit
TaskSupervisorDialogContentinto smaller pieces.
TaskSupervisorDialogContentspans roughly 220 lines and mixes form state, escape-key handling, save/disable async logic, and the full dialog markup (header, status message, mode selector, model/frequency selectors, instructions textarea, footer). Extract the header, status message, and form fields into smaller sub-components to keep the function focused.As per coding guidelines: "functions should remain focused, preferably under 50 lines."
🤖 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 `@wework/src/components/layout/TaskSupervisorControl.tsx` around lines 122 - 345, Refactor TaskSupervisorDialogContent into focused sub-components, extracting the dialog header, supervisor status message, and form fields/footer markup while keeping state, escape-key handling, save, and disable orchestration in the parent. Preserve all existing props, translations, test IDs, accessibility attributes, and behavior; keep each component focused and preferably under 50 lines.Source: Path instructions
🤖 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 `@wework/src/components/chat/composer/AddContextMenu.tsx`:
- Around line 158-178: Update the supervisor menu button in AddContextMenu,
identified by data-testid="task-supervisor-toggle-button", to receive
disabled={disabled} so it cannot invoke handleConfigureSupervisor when the
composer becomes disabled. Add a rerender test covering the transition from
enabled to disabled while the menu is open, verifying the action is disabled.
In `@wework/src/components/layout/DesktopWorkbenchMain.tsx`:
- Around line 579-588: Update the supervisorFeatureAvailable logic near
currentRuntimeTaskSupportsSupervisor to derive the selected model’s runtime
using inferRuntimeName(selectedModel), and require that runtime to be Codex when
no currentRuntimeTask exists. Preserve the existing current-task runtime check
and other feature/service guards.
- Around line 629-690: Guard supervisor updates in setTaskSupervisor and
clearTaskSupervisor until sendPreparedRuntimeMessage has confirmed runtime task
creation, not merely when currentRuntimeTask is populated by the optimistic
view. Disable or defer both callbacks while
executorClient.runtime.createRuntimeTask is pending, then use the confirmed task
address for supervisor endpoint calls and preserve pending configuration until
creation succeeds.
---
Nitpick comments:
In `@wework/src/components/layout/TaskSupervisorControl.test.tsx`:
- Around line 74-99: Extend the test “reopens supervision configured before the
task starts” to click task-supervisor-disable-button and assert that the onClear
mock is called, covering the pre-task disable behavior when only initialConfig
is provided.
In `@wework/src/components/layout/TaskSupervisorControl.tsx`:
- Around line 122-345: Refactor TaskSupervisorDialogContent into focused
sub-components, extracting the dialog header, supervisor status message, and
form fields/footer markup while keeping state, escape-key handling, save, and
disable orchestration in the parent. Preserve all existing props, translations,
test IDs, accessibility attributes, and behavior; keep each component focused
and preferably under 50 lines.
In `@wework/src/i18n/locales/zh-CN/common.json`:
- Around line 158-163: Update the zh-CN supervisor_title translation in the
common locale to preserve the “personal supervisor” meaning conveyed by the
English supervisor_title, while leaving the other supervisor translations
unchanged.
🪄 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: 740aa892-ead1-4ca9-9e75-dd851cfdf96f
📒 Files selected for processing (24)
docs/en/wegent/developer-guide/architecture.mddocs/zh/wegent/developer-guide/architecture.mdexecutor/src/runtime_work/handler/supervisor.rsexecutor/src/runtime_work/handler/tasks.rsexecutor/src/runtime_work/handler/tests.rswework/e2e/desktop/task-flow.e2e.mjswework/src/components/chat/ChatInput.test.tsxwework/src/components/chat/ChatInput.tsxwework/src/components/chat/composer/AddContextMenu.test.tsxwework/src/components/chat/composer/AddContextMenu.tsxwework/src/components/chat/composer/ComposerToolbar.tsxwework/src/components/chat/composer/ProjectChatComposer.tsxwework/src/components/layout/DesktopWorkbenchMain.tsxwework/src/components/layout/EnvironmentInfoPopover.test.tsxwework/src/components/layout/EnvironmentInfoPopover.tsxwework/src/components/layout/TaskSupervisorControl.test.tsxwework/src/components/layout/TaskSupervisorControl.tsxwework/src/components/layout/useWorkbenchPaneSession.tswework/src/components/layout/workspace-panels/WorkspacePanelActions.tsxwework/src/features/workbench/useWorkbenchRuntimeMessaging.tswework/src/features/workbench/workbenchContextTypes.tswework/src/i18n/locales/en/common.jsonwework/src/i18n/locales/zh-CN/common.jsonwework/src/types/api.ts
| {onConfigureSupervisor && ( | ||
| <button | ||
| type="button" | ||
| role="menuitem" | ||
| data-testid="task-supervisor-toggle-button" | ||
| onClick={handleConfigureSupervisor} | ||
| className="flex h-9 w-full items-center gap-2.5 rounded-lg px-3 text-left text-base font-normal leading-[18px] text-text-primary hover:bg-muted" | ||
| > | ||
| <Eye className="h-[18px] w-[18px] shrink-0 text-text-secondary" /> | ||
| <span className="min-w-0 truncate"> | ||
| <span>{t('workbench.supervisor_title')}</span> | ||
| <span className="ml-2 text-text-muted"> | ||
| {supervisorPending | ||
| ? t('workbench.supervisor_pending_menu') | ||
| : supervisorEnabled | ||
| ? t('workbench.supervisor_configure') | ||
| : t('workbench.supervisor_enable')} | ||
| </span> | ||
| </span> | ||
| </button> | ||
| )} |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Disable the supervisor menu action when the composer is disabled.
If the menu opens before disabled changes to true, this action remains enabled and can call onConfigureSupervisor. The pending indicator in ProjectChatComposer disables the same action. Pass disabled={disabled} here. Add a rerender test for this state transition.
Proposed fix
<button
type="button"
role="menuitem"
data-testid="task-supervisor-toggle-button"
+ disabled={disabled}
onClick={handleConfigureSupervisor}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| {onConfigureSupervisor && ( | |
| <button | |
| type="button" | |
| role="menuitem" | |
| data-testid="task-supervisor-toggle-button" | |
| onClick={handleConfigureSupervisor} | |
| className="flex h-9 w-full items-center gap-2.5 rounded-lg px-3 text-left text-base font-normal leading-[18px] text-text-primary hover:bg-muted" | |
| > | |
| <Eye className="h-[18px] w-[18px] shrink-0 text-text-secondary" /> | |
| <span className="min-w-0 truncate"> | |
| <span>{t('workbench.supervisor_title')}</span> | |
| <span className="ml-2 text-text-muted"> | |
| {supervisorPending | |
| ? t('workbench.supervisor_pending_menu') | |
| : supervisorEnabled | |
| ? t('workbench.supervisor_configure') | |
| : t('workbench.supervisor_enable')} | |
| </span> | |
| </span> | |
| </button> | |
| )} | |
| {onConfigureSupervisor && ( | |
| <button | |
| type="button" | |
| role="menuitem" | |
| data-testid="task-supervisor-toggle-button" | |
| disabled={disabled} | |
| onClick={handleConfigureSupervisor} | |
| className="flex h-9 w-full items-center gap-2.5 rounded-lg px-3 text-left text-base font-normal leading-[18px] text-text-primary hover:bg-muted" | |
| > | |
| <Eye className="h-[18px] w-[18px] shrink-0 text-text-secondary" /> | |
| <span className="min-w-0 truncate"> | |
| <span>{t('workbench.supervisor_title')}</span> | |
| <span className="ml-2 text-text-muted"> | |
| {supervisorPending | |
| ? t('workbench.supervisor_pending_menu') | |
| : supervisorEnabled | |
| ? t('workbench.supervisor_configure') | |
| : t('workbench.supervisor_enable')} | |
| </span> | |
| </span> | |
| </button> | |
| )} |
🤖 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 `@wework/src/components/chat/composer/AddContextMenu.tsx` around lines 158 -
178, Update the supervisor menu button in AddContextMenu, identified by
data-testid="task-supervisor-toggle-button", to receive disabled={disabled} so
it cannot invoke handleConfigureSupervisor when the composer becomes disabled.
Add a rerender test covering the transition from enabled to disabled while the
menu is open, verifying the action is disabled.
| const currentRuntimeTaskSupportsSupervisor = | ||
| runtimeTaskSummary?.runtime?.toLowerCase() === 'codex' | ||
| const supervisorFeatureAvailable = Boolean( | ||
| experimentalFeaturesEnabled && | ||
| services?.runtimeWorkApi && | ||
| (!currentRuntimeTask || currentRuntimeTaskSupportsSupervisor) | ||
| ) | ||
| const supervisorModels = projectChat.models.filter( | ||
| model => model.isActive !== false && !model.compatibilityDisabled | ||
| ) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Check whether initialSupervisor handling or supervisor availability
# is restricted to Codex runtime for newly created tasks.
rg -n -C5 "initialSupervisor" wework/src/features/workbench/useWorkbenchRuntimeMessaging.ts
rg -n -C5 "runtime.*codex|inferRuntimeName" wework/src/features/workbench/useWorkbenchRuntimeMessaging.tsRepository: wecode-ai/Wegent
Length of output: 3309
🏁 Script executed:
#!/bin/bash
# Inspect current-task derivation, supervisor gating, model runtime inference, and initialSupervisor send path.
sed -n '530,615p' wework/src/components/layout/DesktopWorkbenchMain.tsx
printf '\n--- runtimeModelSelection ---\n'
sed -n '1,200p' wework/src/features/workbench/runtimeModelSelection.ts
printf '\n--- createRuntime flow ---\n'
sed -n '480,690p' wework/src/features/workbench/useWorkbenchRuntimeMessaging.ts
printf '\n--- sendPreparedRuntimeMessage / RuntimeTaskCreateRequest consumers ---\n'
sed -n '960,1195p' wework/src/features/workbench/useWorkbenchRuntimeMessaging.ts
rg -n -C4 "RuntimeTaskCreateRequest|initialSupervisor|collaborationMode|currentRuntimeTask|runWithRuntime" wework/src/features/workbench wework/src/components/layout/DesktopWorkbenchMain.tsxRepository: wecode-ai/Wegent
Length of output: 50373
🌐 Web query:
Wegot wecode wegent supervisor initialSupervisor runtime codex create_task
💡 Result:
The terms you provided relate to different systems for AI agent orchestration and task management. There is no single integrated framework containing all these specific identifiers together, but they appear in the following distinct technical contexts: Wegent (often associated with the organization WeCode-AI) is an open-source, AI-native platform designed for defining, organizing, and running agent teams [1][2]. It uses a modular architecture with an Executor Manager to handle agent task execution [1][3]. The command create_task and the concept of a supervisor or task manager are central features across several MCP (Model Context Protocol) servers and agent-orchestration tools: 1. MCP-Codex-Teams and TaskFlow: These tools provide functions like create_task, create_team, and various status management commands to orchestrate multi-agent coding workflows [4][5]. 2. MCP-Task-Manager: This library provides specific tools for task management (create_task, update_task) within AI-driven coding environments [6]. 3. CostMarshal: This system uses a scheduler that supports commands such as create_task and dispatch_task to manage bounded, AI-driven coding tasks [7]. The term initialSupervisor (or initial supervisor) is generally not a standard programming API keyword in these frameworks but appears in academic, clinical, or industrial regulatory documentation (such as training manuals or compliance checklists) to describe professional reporting structures or initial training levels [8][9][10][11]. If you are working with a specific codebase or implementation that links these terms (such as a custom project utilizing Wegent alongside an MCP task manager), it is likely a bespoke integration using standard task-management patterns (create_task) and custom supervisory logic.
Citations:
- 1: https://github.com/wecode-ai/wegent
- 2: https://wecode-ai.github.io/wegent-docs/docs/wegent
- 3: https://github.com/wecode-ai/Wegent/blob/main/docs/en/getting-started/quick-start.md
- 4: https://www.npmjs.com/package/mcp-codex-teams
- 5: https://github.com/ZhuchenZhong/TaskFlow
- 6: https://pkg.go.dev/github.com/gpayer/mcp-task-manager
- 7: https://github.com/yptang98/CostMarshal
- 8: https://dpu-p-001.sitecorecontenthub.cloud/api/public/content/6593ea54338a40658fde6b4abc8da5e5?v=31cf49f3
- 9: https://mro.massey.ac.nz/server/api/core/bitstreams/cfc17418-7620-4079-8e3b-2d22551bbc55/content
- 10: https://www.pa.gov/content/dam/copapwp-pagov/en/dli/documents/individuals/labor-management-relations/bois/documents/asbsch.htm
- 11: https://nepis.epa.gov/Exe/ZyPURL.cgi?Dockey=9101IKRR.TXT
🏁 Script executed:
#!/bin/bash
# Locate all code paths that read or validate initialSupervisor.
rg -n -C3 "initialSupervisor" . --glob '!**/node_modules/**' --glob '!**/.git/**'Repository: wecode-ai/Wegent
Length of output: 11865
🏁 Script executed:
#!/bin/bash
# Inspect executor-side supervisor configuration and nearby runtime validation.
sed -n '120,225p' executor/src/runtime_work/handler/tasks.rs
rg -n -C5 "configured_supervisor|runtime|runtime_session|codex|claude_code" executor/src/runtime_work executor/src/runtime executor/src -g '*.rs' | head -n 200Repository: wecode-ai/Wegent
Length of output: 19936
Gate new-task supervisors by the selected model runtime.
For a new task, sendPreparedRuntimeMessage derives the task runtime from the selected model with inferRuntimeName(selectedModel), but supervisorFeatureAvailable still enables supervisor configuration whenever !currentRuntimeTask. If a non-Codex model is selected, RuntimeTaskCreateRequest.runtime becomes claude_code while initialSupervisor is still sent. Restrict the new-task branch to selected models that route to Codex runtime before exposing supervisor configuration.
🤖 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 `@wework/src/components/layout/DesktopWorkbenchMain.tsx` around lines 579 -
588, Update the supervisorFeatureAvailable logic near
currentRuntimeTaskSupportsSupervisor to derive the selected model’s runtime
using inferRuntimeName(selectedModel), and require that runtime to be Codex when
no currentRuntimeTask exists. Preserve the existing current-task runtime check
and other feature/service guards.
02e2010 to
085b081
Compare
What changed
+menu as the configuration entry point and show active supervision in the right-side information panel.Root cause
The pre-task UI previously called supervisor setup before the runtime task address and Codex session existed. That produced invalid
thread_id=none/session_id=nonestate, and the later task upsert could overwrite the configuration. The first message path also failed to forward the initial supervisor configuration into runtime task creation.Validation
supervisor-lifecyclepassed twice, including pending-state assertion and post-create state removal.wework/test-results/desktop-e2e/2026-08-03T16-56-39-372Z-75116/supervisor-pending-context.png.Summary by CodeRabbit
New Features
Documentation
Tests