|
@@ -17,6 +17,7 @@ import {
|
|
|
SelectValue,
|
|
SelectValue,
|
|
|
} from "@/components/ui/select.js";
|
|
} from "@/components/ui/select.js";
|
|
|
import { useZCodeIntl } from "@/i18n/IntlProvider.js";
|
|
import { useZCodeIntl } from "@/i18n/IntlProvider.js";
|
|
|
|
|
+import { Textarea } from "@/components/ui/textarea.js";
|
|
|
import { useTabStore } from "@/store/TabStoreProvider.js";
|
|
import { useTabStore } from "@/store/TabStoreProvider.js";
|
|
|
import { isWorkspaceTab } from "@/store/tabStore.js";
|
|
import { isWorkspaceTab } from "@/store/tabStore.js";
|
|
|
import { useLocalWorkspaceScopes } from "@/hooks/useLocalWorkspaceScopes.js";
|
|
import { useLocalWorkspaceScopes } from "@/hooks/useLocalWorkspaceScopes.js";
|
|
@@ -40,6 +41,7 @@ import {
|
|
|
type TaskDispatchDraft,
|
|
type TaskDispatchDraft,
|
|
|
} from "@/task-dispatch/TaskDispatchPlanList.js";
|
|
} from "@/task-dispatch/TaskDispatchPlanList.js";
|
|
|
import { TaskDispatchHistoryAside } from "@/task-dispatch/TaskDispatchHistoryAside.js";
|
|
import { TaskDispatchHistoryAside } from "@/task-dispatch/TaskDispatchHistoryAside.js";
|
|
|
|
|
+import { TaskDispatchFooterBars } from "@/task-dispatch/TaskDispatchFooterBars.js";
|
|
|
|
|
|
|
|
/** 模块内可选的项目目标(本地 + 远程 workspace)。 */
|
|
/** 模块内可选的项目目标(本地 + 远程 workspace)。 */
|
|
|
export interface TaskDispatchWorkspaceOption {
|
|
export interface TaskDispatchWorkspaceOption {
|
|
@@ -142,6 +144,8 @@ export function TaskDispatchModule({
|
|
|
}, [activeAnalysis]);
|
|
}, [activeAnalysis]);
|
|
|
const [drafts, setDrafts] = useState<TaskDispatchDraft[]>([]);
|
|
const [drafts, setDrafts] = useState<TaskDispatchDraft[]>([]);
|
|
|
const [error, setError] = useState<string | null>(null);
|
|
const [error, setError] = useState<string | null>(null);
|
|
|
|
|
+ // 需求输入:用户描述要拆解的目标/会话内容,模型据此生成任务清单。
|
|
|
|
|
+ const [inputTextState, setInputText] = useState("");
|
|
|
const history = useSyncExternalStore(
|
|
const history = useSyncExternalStore(
|
|
|
taskDispatchHistoryStore.subscribe,
|
|
taskDispatchHistoryStore.subscribe,
|
|
|
taskDispatchHistoryStore.getSnapshot,
|
|
taskDispatchHistoryStore.getSnapshot,
|
|
@@ -162,16 +166,18 @@ export function TaskDispatchModule({
|
|
|
|
|
|
|
|
const handleAnalyze = useCallback(() => {
|
|
const handleAnalyze = useCallback(() => {
|
|
|
if (!selected) return;
|
|
if (!selected) return;
|
|
|
|
|
+ const inputText = inputTextState.trim();
|
|
|
|
|
+ if (!inputText) return;
|
|
|
setError(null);
|
|
setError(null);
|
|
|
setDrafts([]);
|
|
setDrafts([]);
|
|
|
- void startAnalysis(targetFromOption(selected)).then((result) => {
|
|
|
|
|
|
|
+ void startAnalysis(targetFromOption(selected), inputText).then((result) => {
|
|
|
if (!result.ok || !result.record) {
|
|
if (!result.ok || !result.record) {
|
|
|
setError(result.error ?? "createSession failed");
|
|
setError(result.error ?? "createSession failed");
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
setActiveAnalysis({ record: result.record, target: targetFromOption(selected) });
|
|
setActiveAnalysis({ record: result.record, target: targetFromOption(selected) });
|
|
|
});
|
|
});
|
|
|
- }, [selected, startAnalysis, targetFromOption]);
|
|
|
|
|
|
|
+ }, [inputTextState, selected, startAnalysis, targetFromOption]);
|
|
|
|
|
|
|
|
const handleTerminal = useCallback(
|
|
const handleTerminal = useCallback(
|
|
|
(phase: string) => {
|
|
(phase: string) => {
|
|
@@ -249,14 +255,18 @@ export function TaskDispatchModule({
|
|
|
<h1 className="text-ui-lg font-medium">
|
|
<h1 className="text-ui-lg font-medium">
|
|
|
{intl.formatMessage({ id: "taskDispatch.module.title" })}
|
|
{intl.formatMessage({ id: "taskDispatch.module.title" })}
|
|
|
</h1>
|
|
</h1>
|
|
|
- <Button size="sm" disabled={!selected || pending || analyzing} onClick={handleAnalyze}>
|
|
|
|
|
|
|
+ <Button
|
|
|
|
|
+ size="sm"
|
|
|
|
|
+ disabled={!selected || !inputTextState.trim() || pending || analyzing}
|
|
|
|
|
+ onClick={handleAnalyze}
|
|
|
|
|
+ >
|
|
|
{analyzing ? (
|
|
{analyzing ? (
|
|
|
<>
|
|
<>
|
|
|
<Loader2 className="size-4 animate-spin" />
|
|
<Loader2 className="size-4 animate-spin" />
|
|
|
{intl.formatMessage({ id: "taskDispatch.module.analyzing" })}
|
|
{intl.formatMessage({ id: "taskDispatch.module.analyzing" })}
|
|
|
</>
|
|
</>
|
|
|
) : (
|
|
) : (
|
|
|
- intl.formatMessage({ id: "taskDispatch.module.analyze" })
|
|
|
|
|
|
|
+ intl.formatMessage({ id: "taskDispatch.module.generateTasks" })
|
|
|
)}
|
|
)}
|
|
|
</Button>
|
|
</Button>
|
|
|
</header>
|
|
</header>
|
|
@@ -281,6 +291,25 @@ export function TaskDispatchModule({
|
|
|
</SelectContent>
|
|
</SelectContent>
|
|
|
</Select>
|
|
</Select>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
+ {/* 需求输入区:用户描述目标,模型据此拆解任务(不是让模型分析项目本身)。 */}
|
|
|
|
|
+ <div className="flex shrink-0 flex-col gap-1 border-b border-border px-4 py-2">
|
|
|
|
|
+ <label
|
|
|
|
|
+ htmlFor="task-dispatch-input"
|
|
|
|
|
+ className="text-ui-sm text-foreground-subtle"
|
|
|
|
|
+ >
|
|
|
|
|
+ {intl.formatMessage({ id: "taskDispatch.module.inputLabel" })}
|
|
|
|
|
+ </label>
|
|
|
|
|
+ <Textarea
|
|
|
|
|
+ id="task-dispatch-input"
|
|
|
|
|
+ value={inputTextState}
|
|
|
|
|
+ onChange={(event) => setInputText(event.target.value)}
|
|
|
|
|
+ disabled={analyzing}
|
|
|
|
|
+ placeholder={intl.formatMessage({
|
|
|
|
|
+ id: "taskDispatch.module.inputPlaceholder",
|
|
|
|
|
+ })}
|
|
|
|
|
+ className="min-h-20 text-ui-sm"
|
|
|
|
|
+ />
|
|
|
|
|
+ </div>
|
|
|
{error !== null ? (
|
|
{error !== null ? (
|
|
|
<div
|
|
<div
|
|
|
role="alert"
|
|
role="alert"
|
|
@@ -323,86 +352,17 @@ export function TaskDispatchModule({
|
|
|
{/* 侧区:模块会话历史(UI 注册表 + sessions-index 活性;spec §8 M3 口径)。 */}
|
|
{/* 侧区:模块会话历史(UI 注册表 + sessions-index 活性;spec §8 M3 口径)。 */}
|
|
|
<TaskDispatchHistoryAside records={historyForSelected} onLoad={handleLoadHistory} />
|
|
<TaskDispatchHistoryAside records={historyForSelected} onLoad={handleLoadHistory} />
|
|
|
</div>
|
|
</div>
|
|
|
- {/* 统一权限确认栏(spec §8):清单在主区勾选/编辑,此处一次确认权限范围与执行模式。 */}
|
|
|
|
|
- {drafts.length > 0 && dispatchPhase === "idle" ? (
|
|
|
|
|
- <footer className="flex shrink-0 flex-wrap items-center justify-between gap-2 border-t border-border px-4 py-2">
|
|
|
|
|
- <div className="flex min-w-0 items-center gap-3">
|
|
|
|
|
- <span className="text-ui-sm text-foreground">
|
|
|
|
|
- {intl.formatMessage(
|
|
|
|
|
- { id: "taskDispatch.module.selectedCount" },
|
|
|
|
|
- { selected: checkedCount, total: drafts.length },
|
|
|
|
|
- )}
|
|
|
|
|
- </span>
|
|
|
|
|
- <span className="truncate text-ui-caption text-foreground-subtle">
|
|
|
|
|
- {intl.formatMessage({ id: "taskDispatch.module.permissionScopeHint" })}
|
|
|
|
|
- </span>
|
|
|
|
|
- </div>
|
|
|
|
|
- <div className="flex items-center gap-2">
|
|
|
|
|
- <Select
|
|
|
|
|
- value={executeMode}
|
|
|
|
|
- onValueChange={(value) => setExecuteMode(value as "execute" | "createOnly")}
|
|
|
|
|
- >
|
|
|
|
|
- <SelectTrigger className="h-8 w-[150px]" size="sm">
|
|
|
|
|
- <SelectValue />
|
|
|
|
|
- </SelectTrigger>
|
|
|
|
|
- <SelectContent>
|
|
|
|
|
- <SelectItem value="execute">
|
|
|
|
|
- {intl.formatMessage({ id: "taskDispatch.module.executeMode" })}
|
|
|
|
|
- </SelectItem>
|
|
|
|
|
- <SelectItem value="createOnly">
|
|
|
|
|
- {intl.formatMessage({ id: "taskDispatch.module.createOnly" })}
|
|
|
|
|
- </SelectItem>
|
|
|
|
|
- </SelectContent>
|
|
|
|
|
- </Select>
|
|
|
|
|
- <Button
|
|
|
|
|
- size="sm"
|
|
|
|
|
- disabled={checkedCount === 0}
|
|
|
|
|
- onClick={handleConfirmDispatch}
|
|
|
|
|
- >
|
|
|
|
|
- {intl.formatMessage({ id: "taskDispatch.module.confirmDispatch" })}
|
|
|
|
|
- </Button>
|
|
|
|
|
- </div>
|
|
|
|
|
- </footer>
|
|
|
|
|
- ) : null}
|
|
|
|
|
- {dispatchPhase === "running" ? (
|
|
|
|
|
- <footer className="flex shrink-0 items-center gap-2 border-t border-border px-4 py-2 text-ui-sm text-foreground">
|
|
|
|
|
- <Loader2 className="size-4 animate-spin" />
|
|
|
|
|
- <span>
|
|
|
|
|
- {intl.formatMessage(
|
|
|
|
|
- { id: "taskDispatch.module.dispatchProgress" },
|
|
|
|
|
- {
|
|
|
|
|
- current: executor.state.completedGroups + 1,
|
|
|
|
|
- total: executor.state.totalGroups,
|
|
|
|
|
- },
|
|
|
|
|
- )}
|
|
|
|
|
- </span>
|
|
|
|
|
- {executor.state.currentGroupPending > 0 ? (
|
|
|
|
|
- <span className="text-ui-caption text-foreground-subtle">
|
|
|
|
|
- {intl.formatMessage(
|
|
|
|
|
- { id: "taskDispatch.module.awaitingGroup" },
|
|
|
|
|
- { count: executor.state.currentGroupPending },
|
|
|
|
|
- )}
|
|
|
|
|
- </span>
|
|
|
|
|
- ) : null}
|
|
|
|
|
- </footer>
|
|
|
|
|
- ) : null}
|
|
|
|
|
- {dispatchPhase === "done" ? (
|
|
|
|
|
- <footer className="flex shrink-0 items-center justify-between gap-2 border-t border-border px-4 py-2 text-ui-sm text-foreground">
|
|
|
|
|
- <span>
|
|
|
|
|
- {intl.formatMessage(
|
|
|
|
|
- { id: "taskDispatch.module.dispatchDone" },
|
|
|
|
|
- {
|
|
|
|
|
- created: executor.state.results.filter((item) => item.status === "created").length,
|
|
|
|
|
- started: executor.state.results.filter((item) => item.status === "started").length,
|
|
|
|
|
- failed: executor.state.results.filter((item) => item.status === "failed").length,
|
|
|
|
|
- },
|
|
|
|
|
- )}
|
|
|
|
|
- </span>
|
|
|
|
|
- <Button size="sm" variant="ghost" onClick={executor.reset}>
|
|
|
|
|
- {intl.formatMessage({ id: "taskDispatch.module.dispatchBack" })}
|
|
|
|
|
- </Button>
|
|
|
|
|
- </footer>
|
|
|
|
|
- ) : null}
|
|
|
|
|
|
|
+ {/* 统一权限确认/进度/结果栏(spec §8 M4)。 */}
|
|
|
|
|
+ <TaskDispatchFooterBars
|
|
|
|
|
+ draftsCount={drafts.length}
|
|
|
|
|
+ checkedCount={checkedCount}
|
|
|
|
|
+ dispatchPhase={dispatchPhase}
|
|
|
|
|
+ execState={executor.state}
|
|
|
|
|
+ executeMode={executeMode}
|
|
|
|
|
+ onExecuteModeChange={setExecuteMode}
|
|
|
|
|
+ onConfirm={handleConfirmDispatch}
|
|
|
|
|
+ onReset={executor.reset}
|
|
|
|
|
+ />
|
|
|
{activeAnalysis ? (
|
|
{activeAnalysis ? (
|
|
|
<TaskDispatchSessionWatcher
|
|
<TaskDispatchSessionWatcher
|
|
|
target={activeAnalysis.target}
|
|
target={activeAnalysis.target}
|