Răsfoiți Sursa

feat(ui): S3——项目行任务分收入口 + 规划提示词预填 + i18n

- WorkspaceSidebarItem 更多菜单新增任务分发(ListTodo),回调携带目标 workspace path/identity
- WorkspaceSidebar 注入 handler:onCreateTask({ initialPrompt: 规划提示词, targetWorkspace })——只预填草稿不自动发送,由 agent 整理清单后走 DispatchTasks 工具;Web 远控侧栏不注入
- zh-CN/en-US 新增 workspaceSidebar.dispatchTasks 与 dispatchPlannerPrompt

验证:root typecheck 通过;workspaceSidebar 单测 18/18 通过;lint 0 error
wubinggen 1 lună în urmă
părinte
comite
37d3af5224

+ 6 - 0
packages/ui/src/SortableWorkspaceSidebar.tsx

@@ -34,6 +34,7 @@ export const SortableWorkspaceSidebarItem = memo(function SortableWorkspaceSideb
   reconnectingRemoteWorkspaceLogsByWorkspaceKey,
   onReconnectRemoteWorkspace,
   onOpenFileTree,
+  onDispatchTasks,
 }: {
   tab: WorkspaceTabState;
   isActiveWorkspace: boolean;
@@ -66,6 +67,10 @@ export const SortableWorkspaceSidebarItem = memo(function SortableWorkspaceSideb
     workspaceIdentity?: string;
     workspaceRemoteSessionId?: string;
   }) => void;
+  onDispatchTasks?: (target: {
+    workspacePath: string;
+    workspaceIdentity?: string;
+  }) => void;
 }) {
   const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({
     id: tab.id,
@@ -131,6 +136,7 @@ export const SortableWorkspaceSidebarItem = memo(function SortableWorkspaceSideb
       reconnectingRemoteWorkspaceLogsByWorkspaceKey={reconnectingRemoteWorkspaceLogsByWorkspaceKey}
       onReconnectRemoteWorkspace={onReconnectRemoteWorkspace}
       onOpenFileTree={onOpenFileTree}
+      onDispatchTasks={onDispatchTasks}
       itemRef={setNodeRef}
       itemStyle={style}
       sortableBindings={sortableBindings}

+ 23 - 0
packages/ui/src/WorkspaceSidebar.tsx

@@ -1824,6 +1824,29 @@ export const WorkspaceSidebar = memo(function WorkspaceSidebarComponent({
                                             }
                                             onReconnectRemoteWorkspace={onReconnectRemoteWorkspace}
                                             onOpenFileTree={handleOpenWorkspaceFileTree}
+                                            onDispatchTasks={
+                                              isWebRemoteControlSidebar
+                                                ? undefined
+                                                : (target) => {
+                                                    // 任务分收入口:在目标项目打开预填规划
+                                                    // 提示词的新任务草稿(只预填不发送),
+                                                    // 由 agent 整理清单后走 DispatchTools 工具。
+                                                    onCreateTask({
+                                                      initialPrompt: intl.formatMessage({
+                                                        id: "workspaceSidebar.dispatchPlannerPrompt",
+                                                      }),
+                                                      targetWorkspace: {
+                                                        workspacePath: target.workspacePath,
+                                                        ...(target.workspaceIdentity
+                                                          ? {
+                                                              workspaceIdentity:
+                                                                target.workspaceIdentity,
+                                                            }
+                                                          : {}),
+                                                      },
+                                                    });
+                                                  }
+                                            }
                                           />
                                         );
                                       })}

+ 24 - 0
packages/ui/src/WorkspaceSidebarItem.tsx

@@ -19,6 +19,7 @@ import {
   House,
   InfoIcon,
   ListTree,
+  ListTodo,
   LoaderCircle,
   RefreshCwIcon,
   MessageCirclePlus,
@@ -152,6 +153,7 @@ export const WorkspaceSidebarItem = memo(function WorkspaceSidebarItem({
   reconnectingRemoteWorkspaceLogsByWorkspaceKey,
   onReconnectRemoteWorkspace,
   onOpenFileTree,
+  onDispatchTasks,
   itemRef,
   itemStyle,
   sortableBindings,
@@ -188,6 +190,11 @@ export const WorkspaceSidebarItem = memo(function WorkspaceSidebarItem({
     workspaceIdentity?: string;
     workspaceRemoteSessionId?: string;
   }) => void;
+  /** 项目级任务分收入口:在目标 workspace 打开预填规划提示词的新任务草稿。 */
+  onDispatchTasks?: (target: {
+    workspacePath: string;
+    workspaceIdentity?: string;
+  }) => void;
   itemRef?: (node: HTMLLIElement | null) => void;
   itemStyle?: CSSProperties;
   sortableBindings?: SortableBindings;
@@ -969,6 +976,23 @@ export const WorkspaceSidebarItem = memo(function WorkspaceSidebarItem({
                             onOpenMcpSync={() => setRemoteMcpSyncOpen(true)}
                             onOpenPluginSync={() => setRemotePluginSyncOpen(true)}
                           />
+                          {onDispatchTasks ? (
+                            <DropdownMenuItem
+                              onSelect={(event) => {
+                                event.preventDefault();
+                                setWorkspaceActionMenuOpen(false);
+                                onDispatchTasks({
+                                  workspacePath: tab.workspacePath,
+                                  ...(tab.workspaceIdentity
+                                    ? { workspaceIdentity: tab.workspaceIdentity }
+                                    : {}),
+                                });
+                              }}
+                            >
+                              <ListTodo className="h-3.5 w-3.5" />
+                              {intl.formatMessage({ id: "workspaceSidebar.dispatchTasks" })}
+                            </DropdownMenuItem>
+                          ) : null}
                           <DropdownMenuItem
                             onSelect={(event) => {
                               event.preventDefault();

+ 3 - 0
packages/ui/src/i18n/locales/en-US.ts

@@ -1853,6 +1853,9 @@ const enUS: Record<string, string> = {
   "workspaceSidebar.closeTaskSearch": "Close task search",
   "workspaceSidebar.remove": "Remove",
   "workspaceSidebar.renameProject": "Rename project",
+  "workspaceSidebar.dispatchTasks": "Dispatch tasks",
+  "workspaceSidebar.dispatchPlannerPrompt":
+    "Organize the batch of bugs/requests I describe into a list of independent tasks (deduplicate and merge overlapping items first). For each item give a short title and self-contained instructions, then use the DispatchTasks tool to create them under this project after I confirm the list. Always confirm the list with me before dispatching.",
   "workspaceSidebar.renameProjectPlaceholder": "Custom project name (leave empty to reset)",
   "workspaceSidebar.renameProjectFailed": "Could not save project name",
   "chat.dashboard.turnsSteps": "{turns} turns · {steps} steps",

+ 3 - 0
packages/ui/src/i18n/locales/zh-CN.ts

@@ -1726,6 +1726,9 @@ const zhCN: Record<string, string> = {
   "workspaceSidebar.closeTaskSearch": "关闭任务搜索",
   "workspaceSidebar.remove": "移除",
   "workspaceSidebar.renameProject": "项目重命名",
+  "workspaceSidebar.dispatchTasks": "任务分发",
+  "workspaceSidebar.dispatchPlannerPrompt":
+    "请把我要处理的一批 bug/需求整理成独立任务清单(去重、合并重叠项),每项给出简短标题和自包含的处理说明,然后使用 DispatchTasks 工具在我确认后于本项目下创建这些任务。请先向我确认清单再分发。",
   "workspaceSidebar.renameProjectPlaceholder": "自定义项目名称(留空恢复默认)",
   "workspaceSidebar.renameProjectFailed": "保存项目名称失败",
   "chat.dashboard.turnsSteps": "{turns} 轮 · {steps} 步",