Files
AIclinicalresearch/frontend-v2/src/modules/aia/index.tsx
HaHafeng 4d7d97ca19 feat(aia): Protocol Agent streaming + editable state panel + protocol generation plan
Day 2 Development (2026-01-24):

Backend Enhancements:
- Implement SSE streaming in ProtocolAgentController using createStreamingService
- Add data condensation via LLM in ProtocolOrchestrator.handleProtocolSync
- Support stage editing without resetting progress
- Add explicit JSON output format for each stage in system prompt
- Create independent seed script for Protocol Agent (seed-protocol-agent.ts)

Frontend Improvements:
- Integrate useAIStream hook for typewriter effect in ChatArea
- Add MarkdownContent component for basic Markdown rendering
- Implement StageEditModal for editing stage data (scientific question, PICO, etc.)
- Add edit button to StageCard (visible on hover)
- Fix routing paths from /aia to /ai-qa
- Enhance CSS with full-screen layout and Markdown styles

New Documentation:
- One-click protocol generation development plan (v1.1)
- Editor selection evaluation (Novel vs BlockNote vs Tiptap)
- Novel fork strategy for AI-native editing

Technical Decisions:
- Choose Novel (Fork) as protocol editor for AI-first design
- Two-stage progressive generation: summary in chat, full protocol in editor
- 10-day development plan for protocol generation feature

Code Stats:
- Backend: 3 files modified, 1 new file
- Frontend: 9 files modified, 2 new files
- Docs: 3 new files

Status: Streaming and editable features working, protocol generation pending
2026-01-24 23:06:33 +08:00

82 lines
2.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* AIA - AI Intelligent Assistant 模块入口
*
* 路由管理:
* - /ai-qa -> Hub: 智能体大厅12个模块展示
* - /ai-qa/chat -> Chat: 沉浸式对话工作台原12个智能体
* - /ai-qa/protocol-agent/:conversationId? -> Protocol Agent全流程方案制定
*/
import React, { useState } from 'react';
import { Routes, Route, useNavigate, useLocation } from 'react-router-dom';
import { AgentHub } from './components/AgentHub';
import { ChatWorkspace } from './components/ChatWorkspace';
import { ProtocolAgentPage } from './protocol-agent';
import type { AgentConfig } from './types';
const AIAModule: React.FC = () => {
return (
<Routes>
{/* 智能体大厅 */}
<Route index element={<AIAHub />} />
{/* Protocol Agent全流程研究方案制定 */}
<Route path="protocol-agent/:conversationId?" element={<ProtocolAgentPage />} />
{/* 传统智能体对话(向后兼容) */}
<Route path="chat" element={<AIAChat />} />
</Routes>
);
};
/**
* Hub 页面
*/
const AIAHub: React.FC = () => {
const navigate = useNavigate();
const handleAgentSelect = (agent: AgentConfig & { initialQuery?: string }) => {
console.log('[AIAHub] Agent selected:', agent.id, 'isProtocolAgent:', agent.isProtocolAgent);
if (agent.isProtocolAgent) {
// Protocol Agent跳转专属页面
console.log('[AIAHub] Navigating to /ai-qa/protocol-agent');
navigate('/ai-qa/protocol-agent');
} else {
// 传统智能体:跳转对话页面
console.log('[AIAHub] Navigating to /ai-qa/chat');
navigate('/ai-qa/chat', { state: { agent, initialQuery: agent.initialQuery } });
}
};
return <AgentHub onAgentSelect={handleAgentSelect} />;
};
/**
* 传统智能体对话页面
*/
const AIAChat: React.FC = () => {
const navigate = useNavigate();
const location = useLocation();
const state = location.state as { agent: AgentConfig; initialQuery?: string } | null;
const handleBack = () => {
navigate('/ai-qa');
};
if (!state?.agent) {
navigate('/ai-qa');
return null;
}
return (
<ChatWorkspace
agent={state.agent}
initialQuery={state.initialQuery}
onBack={handleBack}
/>
);
};
export default AIAModule;