mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-15 02:42:45 +08:00
feat: add orchestrator execution engine, observability panel, and LSP document caching
Wire FlowExecutor into orchestrator routes for actual flow execution with
pause/resume/stop lifecycle management. Add CLI session audit system with
audit-routes backend and Observability tab in IssueHub frontend. Introduce
cli-session-mux for cross-workspace session routing and QueueSendToOrchestrator
UI component. Normalize frontend API response handling for { data: ... }
wrapper format and propagate projectPath through flow hooks.
In codex-lens, add per-server opened-document cache in StandaloneLspManager
to avoid redundant didOpen notifications (using didChange for updates), and
skip warmup delay for already-warmed LSP server instances in ChainSearchEngine.
This commit is contained in:
@@ -4,9 +4,9 @@
|
||||
// Dynamic header component for IssueHub
|
||||
|
||||
import { useIntl } from 'react-intl';
|
||||
import { AlertCircle, Radar, ListTodo, LayoutGrid } from 'lucide-react';
|
||||
import { AlertCircle, Radar, ListTodo, LayoutGrid, Activity } from 'lucide-react';
|
||||
|
||||
type IssueTab = 'issues' | 'board' | 'queue' | 'discovery';
|
||||
type IssueTab = 'issues' | 'board' | 'queue' | 'discovery' | 'observability';
|
||||
|
||||
interface IssueHubHeaderProps {
|
||||
currentTab: IssueTab;
|
||||
@@ -37,6 +37,11 @@ export function IssueHubHeader({ currentTab }: IssueHubHeaderProps) {
|
||||
title: formatMessage({ id: 'issues.discovery.pageTitle' }),
|
||||
description: formatMessage({ id: 'issues.discovery.description' }),
|
||||
},
|
||||
observability: {
|
||||
icon: <Activity className="w-6 h-6 text-primary" />,
|
||||
title: formatMessage({ id: 'issues.observability.pageTitle' }),
|
||||
description: formatMessage({ id: 'issues.observability.description' }),
|
||||
},
|
||||
};
|
||||
|
||||
const config = tabConfig[currentTab];
|
||||
|
||||
@@ -7,7 +7,8 @@ import { useIntl } from 'react-intl';
|
||||
import { Button } from '@/components/ui/Button';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
export type IssueTab = 'issues' | 'board' | 'queue' | 'discovery';
|
||||
// Keep in sync with IssueHubHeader/IssueHubPage
|
||||
export type IssueTab = 'issues' | 'board' | 'queue' | 'discovery' | 'observability';
|
||||
|
||||
interface IssueHubTabsProps {
|
||||
currentTab: IssueTab;
|
||||
@@ -22,6 +23,7 @@ export function IssueHubTabs({ currentTab, onTabChange }: IssueHubTabsProps) {
|
||||
{ value: 'board', label: formatMessage({ id: 'issues.hub.tabs.board' }) },
|
||||
{ value: 'queue', label: formatMessage({ id: 'issues.hub.tabs.queue' }) },
|
||||
{ value: 'discovery', label: formatMessage({ id: 'issues.hub.tabs.discovery' }) },
|
||||
{ value: 'observability', label: formatMessage({ id: 'issues.hub.tabs.observability' }) },
|
||||
];
|
||||
|
||||
return (
|
||||
|
||||
294
ccw/frontend/src/components/issue/hub/ObservabilityPanel.tsx
Normal file
294
ccw/frontend/src/components/issue/hub/ObservabilityPanel.tsx
Normal file
@@ -0,0 +1,294 @@
|
||||
// ========================================
|
||||
// Observability Panel
|
||||
// ========================================
|
||||
// Audit log UI for issue workbench (read-only)
|
||||
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { useIntl } from 'react-intl';
|
||||
import { ChevronDown, ChevronRight, RefreshCw } from 'lucide-react';
|
||||
import { Card } from '@/components/ui/Card';
|
||||
import { Badge } from '@/components/ui/Badge';
|
||||
import { Button } from '@/components/ui/Button';
|
||||
import { Input } from '@/components/ui/Input';
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/Select';
|
||||
import { useCliSessionAudit } from '@/hooks';
|
||||
import { cn } from '@/lib/utils';
|
||||
import type { CliSessionAuditEvent, CliSessionAuditEventType } from '@/lib/api';
|
||||
|
||||
const EVENT_TYPES: CliSessionAuditEventType[] = [
|
||||
'session_created',
|
||||
'session_closed',
|
||||
'session_send',
|
||||
'session_execute',
|
||||
'session_resize',
|
||||
'session_share_created',
|
||||
'session_share_revoked',
|
||||
'session_idle_reaped',
|
||||
];
|
||||
|
||||
function badgeVariantForType(type: CliSessionAuditEventType): 'default' | 'secondary' | 'destructive' | 'outline' | 'success' | 'warning' | 'info' {
|
||||
switch (type) {
|
||||
case 'session_created':
|
||||
return 'success';
|
||||
case 'session_closed':
|
||||
case 'session_idle_reaped':
|
||||
return 'secondary';
|
||||
case 'session_execute':
|
||||
return 'info';
|
||||
case 'session_send':
|
||||
case 'session_resize':
|
||||
return 'outline';
|
||||
case 'session_share_created':
|
||||
return 'warning';
|
||||
case 'session_share_revoked':
|
||||
return 'secondary';
|
||||
default:
|
||||
return 'default';
|
||||
}
|
||||
}
|
||||
|
||||
function stableEventKey(ev: CliSessionAuditEvent, index: number): string {
|
||||
return `${ev.timestamp}|${ev.type}|${ev.sessionKey ?? ''}|${index}`;
|
||||
}
|
||||
|
||||
export function ObservabilityPanel() {
|
||||
const { formatMessage } = useIntl();
|
||||
|
||||
const [q, setQ] = useState('');
|
||||
const [sessionKey, setSessionKey] = useState('');
|
||||
const [type, setType] = useState<string>('');
|
||||
const [limit, setLimit] = useState<number>(200);
|
||||
const [offset, setOffset] = useState<number>(0);
|
||||
const [expandedKey, setExpandedKey] = useState<string | null>(null);
|
||||
|
||||
// Reset paging when filters change
|
||||
useEffect(() => {
|
||||
setOffset(0);
|
||||
}, [q, sessionKey, type, limit]);
|
||||
|
||||
const query = useCliSessionAudit({
|
||||
q: q.trim() || undefined,
|
||||
sessionKey: sessionKey.trim() || undefined,
|
||||
type: type ? (type as CliSessionAuditEventType) : undefined,
|
||||
limit,
|
||||
offset,
|
||||
});
|
||||
|
||||
const events = query.data?.data.events ?? [];
|
||||
const total = query.data?.data.total ?? 0;
|
||||
const hasMore = query.data?.data.hasMore ?? false;
|
||||
|
||||
const headerRight = useMemo(() => {
|
||||
const start = total === 0 ? 0 : offset + 1;
|
||||
const end = Math.min(total, offset + limit);
|
||||
return `${start}-${end} / ${total}`;
|
||||
}, [limit, offset, total]);
|
||||
|
||||
const handleRefresh = async () => {
|
||||
try {
|
||||
await query.refetch();
|
||||
} catch (e) {
|
||||
// Errors are surfaced by query.error
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<Card className="p-4">
|
||||
<div className="flex flex-col gap-3">
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<div className="text-sm font-semibold text-foreground">
|
||||
{formatMessage({ id: 'issues.observability.audit.title' })}
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="text-xs text-muted-foreground font-mono">
|
||||
{headerRight}
|
||||
</div>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={handleRefresh}
|
||||
disabled={query.isFetching}
|
||||
className="gap-2"
|
||||
>
|
||||
<RefreshCw className={cn('h-4 w-4', query.isFetching && 'animate-spin')} />
|
||||
{formatMessage({ id: 'common.actions.refresh' })}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-4 gap-3">
|
||||
<div className="md:col-span-2">
|
||||
<label className="block text-xs font-medium text-muted-foreground mb-1">
|
||||
{formatMessage({ id: 'issues.observability.filters.search' })}
|
||||
</label>
|
||||
<Input
|
||||
value={q}
|
||||
onChange={(e) => setQ(e.target.value)}
|
||||
placeholder={formatMessage({ id: 'issues.observability.filters.searchPlaceholder' })}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-xs font-medium text-muted-foreground mb-1">
|
||||
{formatMessage({ id: 'issues.observability.filters.sessionKey' })}
|
||||
</label>
|
||||
<Input
|
||||
value={sessionKey}
|
||||
onChange={(e) => setSessionKey(e.target.value)}
|
||||
placeholder={formatMessage({ id: 'issues.observability.filters.sessionKeyPlaceholder' })}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-xs font-medium text-muted-foreground mb-1">
|
||||
{formatMessage({ id: 'issues.observability.filters.type' })}
|
||||
</label>
|
||||
<Select value={type} onValueChange={(v) => setType(v)}>
|
||||
<SelectTrigger>
|
||||
<SelectValue placeholder={formatMessage({ id: 'issues.observability.filters.typeAll' })} />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="">{formatMessage({ id: 'issues.observability.filters.typeAll' })}</SelectItem>
|
||||
{EVENT_TYPES.map((t) => (
|
||||
<SelectItem key={t} value={t}>
|
||||
{t}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-wrap items-center justify-between gap-2">
|
||||
<div className="flex items-center gap-2">
|
||||
<label className="block text-xs font-medium text-muted-foreground">
|
||||
{formatMessage({ id: 'issues.observability.filters.limit' })}
|
||||
</label>
|
||||
<Select value={String(limit)} onValueChange={(v) => setLimit(parseInt(v, 10))}>
|
||||
<SelectTrigger className="w-[140px]">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{[50, 100, 200, 500, 1000].map((n) => (
|
||||
<SelectItem key={n} value={String(n)}>{n}</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={() => setOffset(Math.max(0, offset - limit))}
|
||||
disabled={offset === 0 || query.isFetching}
|
||||
>
|
||||
{formatMessage({ id: 'common.actions.previous' })}
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={() => setOffset(offset + limit)}
|
||||
disabled={!hasMore || query.isFetching}
|
||||
>
|
||||
{formatMessage({ id: 'common.actions.next' })}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
{query.error && (
|
||||
<Card className="p-6 border-destructive/50 bg-destructive/5">
|
||||
<div className="text-sm text-destructive">
|
||||
{(query.error as Error).message || formatMessage({ id: 'issues.observability.error' })}
|
||||
</div>
|
||||
</Card>
|
||||
)}
|
||||
|
||||
{!query.isLoading && events.length === 0 && (
|
||||
<Card className="p-10 text-center text-muted-foreground">
|
||||
{formatMessage({ id: 'issues.observability.empty' })}
|
||||
</Card>
|
||||
)}
|
||||
|
||||
{events.length > 0 && (
|
||||
<Card className="p-0 overflow-hidden">
|
||||
<div className="px-4 py-2 border-b border-border bg-card/50 text-xs font-medium text-muted-foreground grid grid-cols-12 gap-3">
|
||||
<div className="col-span-3">{formatMessage({ id: 'issues.observability.table.timestamp' })}</div>
|
||||
<div className="col-span-2">{formatMessage({ id: 'issues.observability.table.type' })}</div>
|
||||
<div className="col-span-3">{formatMessage({ id: 'issues.observability.table.sessionKey' })}</div>
|
||||
<div className="col-span-2">{formatMessage({ id: 'issues.observability.table.tool' })}</div>
|
||||
<div className="col-span-2">{formatMessage({ id: 'issues.observability.table.resumeKey' })}</div>
|
||||
</div>
|
||||
|
||||
<div className="divide-y divide-border">
|
||||
{events.map((ev, index) => {
|
||||
const key = stableEventKey(ev, index);
|
||||
const expanded = expandedKey === key;
|
||||
return (
|
||||
<div key={key} className="px-4 py-2">
|
||||
<button
|
||||
type="button"
|
||||
className="w-full text-left grid grid-cols-12 gap-3 items-center hover:bg-muted/40 rounded-md px-2 py-2"
|
||||
onClick={() => setExpandedKey(expanded ? null : key)}
|
||||
>
|
||||
<div className="col-span-3 flex items-center gap-2 min-w-0">
|
||||
{expanded ? (
|
||||
<ChevronDown className="h-4 w-4 text-muted-foreground shrink-0" />
|
||||
) : (
|
||||
<ChevronRight className="h-4 w-4 text-muted-foreground shrink-0" />
|
||||
)}
|
||||
<span className="font-mono text-xs text-foreground truncate">
|
||||
{ev.timestamp}
|
||||
</span>
|
||||
</div>
|
||||
<div className="col-span-2">
|
||||
<Badge variant={badgeVariantForType(ev.type)} className="font-mono text-xs">
|
||||
{ev.type}
|
||||
</Badge>
|
||||
</div>
|
||||
<div className="col-span-3 font-mono text-xs text-muted-foreground truncate">
|
||||
{ev.sessionKey || '-'}
|
||||
</div>
|
||||
<div className="col-span-2 font-mono text-xs text-muted-foreground truncate">
|
||||
{ev.tool || '-'}
|
||||
</div>
|
||||
<div className="col-span-2 font-mono text-xs text-muted-foreground truncate">
|
||||
{ev.resumeKey || '-'}
|
||||
</div>
|
||||
</button>
|
||||
|
||||
{expanded && (
|
||||
<div className="mt-2 ml-6 space-y-2">
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-2 text-xs">
|
||||
<div className="text-muted-foreground">
|
||||
<span className="font-medium text-foreground">{formatMessage({ id: 'issues.observability.table.workingDir' })}: </span>
|
||||
<span className="font-mono break-all">{ev.workingDir || '-'}</span>
|
||||
</div>
|
||||
<div className="text-muted-foreground">
|
||||
<span className="font-medium text-foreground">{formatMessage({ id: 'issues.observability.table.ip' })}: </span>
|
||||
<span className="font-mono break-all">{ev.ip || '-'}</span>
|
||||
</div>
|
||||
</div>
|
||||
{ev.userAgent && (
|
||||
<div className="text-xs text-muted-foreground">
|
||||
<span className="font-medium text-foreground">{formatMessage({ id: 'issues.observability.table.userAgent' })}: </span>
|
||||
<span className="font-mono break-all">{ev.userAgent}</span>
|
||||
</div>
|
||||
)}
|
||||
<pre className="text-xs bg-muted/50 rounded-md p-3 overflow-x-auto">
|
||||
{JSON.stringify(ev.details ?? {}, null, 2)}
|
||||
</pre>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</Card>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default ObservabilityPanel;
|
||||
@@ -0,0 +1,355 @@
|
||||
// ========================================
|
||||
// QueueSendToOrchestrator
|
||||
// ========================================
|
||||
// Create a flow from a queue item and execute it via Orchestrator (tmux-like delivery to PTY session).
|
||||
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { useIntl } from 'react-intl';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { Plus, RefreshCw, Workflow } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/Button';
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/Select';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { useWorkflowStore, selectProjectPath } from '@/stores/workflowStore';
|
||||
import { toast, useExecutionStore, useFlowStore } from '@/stores';
|
||||
import { useIssues } from '@/hooks';
|
||||
import {
|
||||
createCliSession,
|
||||
createOrchestratorFlow,
|
||||
executeOrchestratorFlow,
|
||||
fetchCliSessions,
|
||||
type CliSession,
|
||||
type QueueItem,
|
||||
} from '@/lib/api';
|
||||
import { useCliSessionStore } from '@/stores/cliSessionStore';
|
||||
|
||||
type ToolName = 'claude' | 'codex' | 'gemini' | 'qwen';
|
||||
type ResumeStrategy = 'nativeResume' | 'promptConcat';
|
||||
|
||||
function buildQueueItemInstruction(item: QueueItem, issue: any | undefined): string {
|
||||
const lines: string[] = [];
|
||||
lines.push(`Queue Item: ${item.item_id}`);
|
||||
lines.push(`Issue: ${item.issue_id}`);
|
||||
lines.push(`Solution: ${item.solution_id}`);
|
||||
if (item.task_id) lines.push(`Task: ${item.task_id}`);
|
||||
lines.push('');
|
||||
|
||||
if (issue) {
|
||||
if (issue.title) lines.push(`Title: ${issue.title}`);
|
||||
if (issue.context) {
|
||||
lines.push('');
|
||||
lines.push('Context:');
|
||||
lines.push(String(issue.context));
|
||||
}
|
||||
|
||||
const solution = Array.isArray(issue.solutions)
|
||||
? issue.solutions.find((s: any) => s?.id === item.solution_id)
|
||||
: undefined;
|
||||
if (solution) {
|
||||
lines.push('');
|
||||
lines.push('Solution Description:');
|
||||
if (solution.description) lines.push(String(solution.description));
|
||||
if (solution.approach) {
|
||||
lines.push('');
|
||||
lines.push('Approach:');
|
||||
lines.push(String(solution.approach));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lines.push('');
|
||||
lines.push('Instruction:');
|
||||
lines.push(
|
||||
'Implement the above queue item in this repository. Prefer small, testable changes; run relevant tests; report blockers if any.'
|
||||
);
|
||||
|
||||
return lines.join('\n');
|
||||
}
|
||||
|
||||
function generateId(prefix: string): string {
|
||||
return `${prefix}-${Date.now()}-${Math.random().toString(36).slice(2, 10)}`;
|
||||
}
|
||||
|
||||
export function QueueSendToOrchestrator({ item, className }: { item: QueueItem; className?: string }) {
|
||||
const { formatMessage } = useIntl();
|
||||
const navigate = useNavigate();
|
||||
const projectPath = useWorkflowStore(selectProjectPath);
|
||||
|
||||
const { issues } = useIssues();
|
||||
const issue = useMemo(() => issues.find((i) => i.id === item.issue_id) as any, [issues, item.issue_id]);
|
||||
|
||||
const sessionsByKey = useCliSessionStore((s) => s.sessions);
|
||||
const setSessions = useCliSessionStore((s) => s.setSessions);
|
||||
const upsertSession = useCliSessionStore((s) => s.upsertSession);
|
||||
|
||||
const sessions = useMemo(
|
||||
() => Object.values(sessionsByKey).sort((a, b) => a.createdAt.localeCompare(b.createdAt)),
|
||||
[sessionsByKey]
|
||||
);
|
||||
|
||||
const [selectedSessionKey, setSelectedSessionKey] = useState<string>('');
|
||||
const [tool, setTool] = useState<ToolName>('claude');
|
||||
const [mode, setMode] = useState<'analysis' | 'write'>('write');
|
||||
const [resumeStrategy, setResumeStrategy] = useState<ResumeStrategy>('nativeResume');
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [isSending, setIsSending] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [lastResult, setLastResult] = useState<{ flowId: string; execId: string } | null>(null);
|
||||
|
||||
const refreshSessions = async () => {
|
||||
setIsLoading(true);
|
||||
setError(null);
|
||||
try {
|
||||
const r = await fetchCliSessions(projectPath || undefined);
|
||||
setSessions(r.sessions as unknown as CliSession[]);
|
||||
} catch (e) {
|
||||
setError(e instanceof Error ? e.message : String(e));
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
void refreshSessions();
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [projectPath]);
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedSessionKey) return;
|
||||
if (sessions.length === 0) return;
|
||||
setSelectedSessionKey(sessions[sessions.length - 1]?.sessionKey ?? '');
|
||||
}, [sessions, selectedSessionKey]);
|
||||
|
||||
const ensureSession = async (): Promise<string> => {
|
||||
if (selectedSessionKey) return selectedSessionKey;
|
||||
if (!projectPath) throw new Error('No project path selected');
|
||||
const created = await createCliSession({
|
||||
workingDir: projectPath,
|
||||
preferredShell: 'bash',
|
||||
resumeKey: item.issue_id,
|
||||
}, projectPath);
|
||||
upsertSession(created.session as unknown as CliSession);
|
||||
setSelectedSessionKey(created.session.sessionKey);
|
||||
return created.session.sessionKey;
|
||||
};
|
||||
|
||||
const handleCreateSession = async () => {
|
||||
setError(null);
|
||||
try {
|
||||
if (!projectPath) throw new Error('No project path selected');
|
||||
const created = await createCliSession({
|
||||
workingDir: projectPath,
|
||||
preferredShell: 'bash',
|
||||
resumeKey: item.issue_id,
|
||||
}, projectPath);
|
||||
upsertSession(created.session as unknown as CliSession);
|
||||
setSelectedSessionKey(created.session.sessionKey);
|
||||
await refreshSessions();
|
||||
} catch (e) {
|
||||
setError(e instanceof Error ? e.message : String(e));
|
||||
}
|
||||
};
|
||||
|
||||
const handleSend = async () => {
|
||||
setIsSending(true);
|
||||
setError(null);
|
||||
setLastResult(null);
|
||||
try {
|
||||
const sessionKey = await ensureSession();
|
||||
const instruction = buildQueueItemInstruction(item, issue);
|
||||
|
||||
const nodeId = generateId('node');
|
||||
const flowName = `Queue ${item.issue_id} / ${item.solution_id}${item.task_id ? ` / ${item.task_id}` : ''}`;
|
||||
const flowDescription = `Queue item ${item.item_id} -> Orchestrator`;
|
||||
|
||||
const created = await createOrchestratorFlow({
|
||||
name: flowName,
|
||||
description: flowDescription,
|
||||
version: '1.0.0',
|
||||
nodes: [
|
||||
{
|
||||
id: nodeId,
|
||||
type: 'prompt-template',
|
||||
position: { x: 100, y: 100 },
|
||||
data: {
|
||||
label: flowName,
|
||||
instruction,
|
||||
tool,
|
||||
mode,
|
||||
delivery: 'sendToSession',
|
||||
targetSessionKey: sessionKey,
|
||||
resumeKey: item.issue_id,
|
||||
resumeStrategy,
|
||||
tags: ['queue', item.item_id, item.issue_id, item.solution_id].filter(Boolean),
|
||||
},
|
||||
},
|
||||
],
|
||||
edges: [],
|
||||
variables: {},
|
||||
metadata: {
|
||||
source: 'local',
|
||||
tags: ['queue', item.item_id, item.issue_id, item.solution_id].filter(Boolean),
|
||||
},
|
||||
}, projectPath || undefined);
|
||||
|
||||
if (!created.success) {
|
||||
throw new Error('Failed to create flow');
|
||||
}
|
||||
|
||||
// Best-effort: hydrate Orchestrator stores so the user lands on the created flow.
|
||||
const flowDto = created.data as any;
|
||||
const parsedVersion = parseInt(String(flowDto.version ?? '1'), 10);
|
||||
const flowForStore = {
|
||||
...flowDto,
|
||||
version: Number.isFinite(parsedVersion) ? parsedVersion : 1,
|
||||
} as any;
|
||||
useFlowStore.getState().setCurrentFlow(flowForStore);
|
||||
|
||||
// Trigger execution (backend returns execId; engine wiring may run async).
|
||||
const executed = await executeOrchestratorFlow(created.data.id, {}, projectPath || undefined);
|
||||
if (!executed.success) {
|
||||
throw new Error('Failed to execute flow');
|
||||
}
|
||||
|
||||
const execId = executed.data.execId;
|
||||
useExecutionStore.getState().startExecution(execId, created.data.id);
|
||||
useExecutionStore.getState().setMonitorPanelOpen(true);
|
||||
|
||||
setLastResult({ flowId: created.data.id, execId });
|
||||
toast.success(
|
||||
formatMessage({ id: 'issues.queue.orchestrator.sentTitle' }),
|
||||
formatMessage({ id: 'issues.queue.orchestrator.sentDesc' }, { flowId: created.data.id })
|
||||
);
|
||||
|
||||
navigate('/orchestrator');
|
||||
} catch (e) {
|
||||
const message = e instanceof Error ? e.message : String(e);
|
||||
setError(message);
|
||||
toast.error(formatMessage({ id: 'issues.queue.orchestrator.sendFailed' }), message);
|
||||
} finally {
|
||||
setIsSending(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={cn('space-y-3', className)}>
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
<h3 className="text-sm font-semibold text-foreground flex items-center gap-2">
|
||||
<Workflow className="h-4 w-4" />
|
||||
{formatMessage({ id: 'issues.queue.orchestrator.title' })}
|
||||
</h3>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={refreshSessions}
|
||||
disabled={isLoading}
|
||||
className="gap-2"
|
||||
>
|
||||
<RefreshCw className={cn('h-4 w-4', isLoading && 'animate-spin')} />
|
||||
{formatMessage({ id: 'issues.terminal.session.refresh' })}
|
||||
</Button>
|
||||
<Button variant="outline" size="sm" onClick={handleCreateSession} className="gap-2">
|
||||
<Plus className="h-4 w-4" />
|
||||
{formatMessage({ id: 'issues.terminal.session.new' })}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-3">
|
||||
<div>
|
||||
<label className="block text-xs font-medium text-muted-foreground mb-1">
|
||||
{formatMessage({ id: 'issues.queue.orchestrator.targetSession' })}
|
||||
</label>
|
||||
<Select value={selectedSessionKey} onValueChange={(v) => setSelectedSessionKey(v)}>
|
||||
<SelectTrigger>
|
||||
<SelectValue placeholder={formatMessage({ id: 'issues.terminal.session.none' })} />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{sessions.length === 0 ? (
|
||||
<SelectItem value="" disabled>
|
||||
{formatMessage({ id: 'issues.terminal.session.none' })}
|
||||
</SelectItem>
|
||||
) : (
|
||||
sessions.map((s) => (
|
||||
<SelectItem key={s.sessionKey} value={s.sessionKey}>
|
||||
{(s.tool || 'cli') + ' · ' + s.sessionKey}
|
||||
</SelectItem>
|
||||
))
|
||||
)}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="block text-xs font-medium text-muted-foreground mb-1">
|
||||
{formatMessage({ id: 'issues.queue.orchestrator.tool' })}
|
||||
</label>
|
||||
<Select value={tool} onValueChange={(v) => setTool(v as ToolName)}>
|
||||
<SelectTrigger>
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="claude">claude</SelectItem>
|
||||
<SelectItem value="codex">codex</SelectItem>
|
||||
<SelectItem value="gemini">gemini</SelectItem>
|
||||
<SelectItem value="qwen">qwen</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="block text-xs font-medium text-muted-foreground mb-1">
|
||||
{formatMessage({ id: 'issues.queue.orchestrator.mode' })}
|
||||
</label>
|
||||
<Select value={mode} onValueChange={(v) => setMode(v as 'analysis' | 'write')}>
|
||||
<SelectTrigger>
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="analysis">analysis</SelectItem>
|
||||
<SelectItem value="write">write</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="block text-xs font-medium text-muted-foreground mb-1">
|
||||
{formatMessage({ id: 'issues.queue.orchestrator.resumeStrategy' })}
|
||||
</label>
|
||||
<Select value={resumeStrategy} onValueChange={(v) => setResumeStrategy(v as ResumeStrategy)}>
|
||||
<SelectTrigger>
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="nativeResume">nativeResume</SelectItem>
|
||||
<SelectItem value="promptConcat">promptConcat</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{error && <div className="text-sm text-destructive">{error}</div>}
|
||||
{lastResult && (
|
||||
<div className="text-xs text-muted-foreground font-mono break-all">
|
||||
{lastResult.flowId} · {lastResult.execId}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="flex items-center justify-end">
|
||||
<Button onClick={handleSend} disabled={isSending || !projectPath} className="gap-2">
|
||||
{isSending ? (
|
||||
<>
|
||||
<RefreshCw className="h-4 w-4 animate-spin" />
|
||||
{formatMessage({ id: 'issues.queue.orchestrator.sending' })}
|
||||
</>
|
||||
) : (
|
||||
formatMessage({ id: 'issues.queue.orchestrator.send' })
|
||||
)}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default QueueSendToOrchestrator;
|
||||
@@ -10,6 +10,7 @@ import { Badge } from '@/components/ui/Badge';
|
||||
import { Button } from '@/components/ui/Button';
|
||||
import { Tabs, TabsList, TabsTrigger, TabsContent } from '@/components/ui/Tabs';
|
||||
import { QueueExecuteInSession } from '@/components/issue/queue/QueueExecuteInSession';
|
||||
import { QueueSendToOrchestrator } from '@/components/issue/queue/QueueSendToOrchestrator';
|
||||
import { IssueTerminalTab } from '@/components/issue/hub/IssueTerminalTab';
|
||||
import { useIssueQueue } from '@/hooks';
|
||||
import { cn } from '@/lib/utils';
|
||||
@@ -179,6 +180,9 @@ export function SolutionDrawer({ item, isOpen, onClose }: SolutionDrawerProps) {
|
||||
{/* Execute in Session */}
|
||||
<QueueExecuteInSession item={item} />
|
||||
|
||||
{/* Send to Orchestrator */}
|
||||
<QueueSendToOrchestrator item={item} />
|
||||
|
||||
{/* Dependencies */}
|
||||
{item.depends_on && item.depends_on.length > 0 && (
|
||||
<div>
|
||||
|
||||
Reference in New Issue
Block a user