Buf fix (emit new chat also for ChatView)
This commit is contained in:
parent
04a19b2508
commit
dfe27f79ef
|
|
@ -30,9 +30,7 @@ import { Handle, Position } from 'reactflow';
|
|||
// Простой компонент для узла типа 'user'
|
||||
// Это базовый пример. Ты можешь стилизовать его по своему усмотрению.
|
||||
const UserNode: React.FC<any> = ({ data, isConnectable }) => {
|
||||
return React.createElement('div', {
|
||||
className: 'react-flow__node-user'
|
||||
},
|
||||
return React.createElement(React.Fragment, null, // Используем React.Fragment для возврата нескольких элементов без лишнего div
|
||||
React.createElement(Handle, {
|
||||
type: "source",
|
||||
position: Position.Bottom,
|
||||
|
|
@ -49,9 +47,7 @@ const UserNode: React.FC<any> = ({ data, isConnectable }) => {
|
|||
|
||||
// Простой компонент для узла типа 'llm'
|
||||
const LLMNode: React.FC<any> = ({ data, isConnectable }) => {
|
||||
return React.createElement('div', {
|
||||
className: 'react-flow__node-llm'
|
||||
},
|
||||
return React.createElement(React.Fragment, null,
|
||||
React.createElement(Handle, {
|
||||
type: "source",
|
||||
position: Position.Bottom,
|
||||
|
|
@ -68,9 +64,7 @@ const LLMNode: React.FC<any> = ({ data, isConnectable }) => {
|
|||
|
||||
// Простой компонент для узла типа 'tool'
|
||||
const ToolNode: React.FC<any> = ({ data, isConnectable }) => {
|
||||
return React.createElement('div', {
|
||||
className: 'react-flow__node-tool'
|
||||
},
|
||||
return React.createElement(React.Fragment, null,
|
||||
React.createElement(Handle, {
|
||||
type: "source",
|
||||
position: Position.Bottom,
|
||||
|
|
@ -87,27 +81,7 @@ const ToolNode: React.FC<any> = ({ data, isConnectable }) => {
|
|||
|
||||
// Простой компонент для узла типа 'error'
|
||||
const ErrorNode: React.FC<any> = ({ data, isConnectable }) => {
|
||||
return React.createElement('div', {
|
||||
className: 'react-flow__node-error'
|
||||
},
|
||||
React.createElement(Handle, {
|
||||
type: "source",
|
||||
position: Position.Bottom,
|
||||
isConnectable: isConnectable,
|
||||
}),
|
||||
React.createElement(Handle, {
|
||||
type: "target",
|
||||
position: Position.Top,
|
||||
isConnectable: isConnectable,
|
||||
}),
|
||||
data.label
|
||||
);
|
||||
};
|
||||
|
||||
const AssistantNode: React.FC<any> = ({ data, isConnectable }) => {
|
||||
return React.createElement('div', {
|
||||
className: 'react-flow__node-assistant' // Используем CSS класс для узла assistant
|
||||
},
|
||||
return React.createElement(React.Fragment, null,
|
||||
React.createElement(Handle, {
|
||||
type: "source",
|
||||
position: Position.Bottom,
|
||||
|
|
@ -128,7 +102,6 @@ const nodeTypes = {
|
|||
llm: LLMNode,
|
||||
tool: ToolNode,
|
||||
error: ErrorNode,
|
||||
assistant: AssistantNode,
|
||||
// Если у тебя есть node.type === 'default', то можешь его тоже определить,
|
||||
// либо использовать встроенный 'default' React Flow.
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3,12 +3,14 @@
|
|||
* прошлых разговоров, начала новых чатов и удаления записей графов.
|
||||
*/
|
||||
|
||||
import { EventBus } from '../utils/EventBus';
|
||||
|
||||
export class HistoryPanel {
|
||||
container: HTMLElement;
|
||||
props: {
|
||||
graphs: any[];
|
||||
onGraphSelect: (graphId: string) => void;
|
||||
onNewChat: () => void;
|
||||
eventBus: EventBus;
|
||||
};
|
||||
graphs: any[];
|
||||
newChatButton: HTMLButtonElement;
|
||||
|
|
@ -22,7 +24,7 @@ export class HistoryPanel {
|
|||
props: {
|
||||
graphs: any[];
|
||||
onGraphSelect: (graphId: string) => void;
|
||||
onNewChat: () => void;
|
||||
eventBus: EventBus;
|
||||
}
|
||||
) {
|
||||
this.container = container;
|
||||
|
|
@ -57,9 +59,7 @@ export class HistoryPanel {
|
|||
|
||||
setupEventListeners(): void {
|
||||
this.newChatButton.addEventListener('click', () => {
|
||||
if (this.props.onNewChat) {
|
||||
this.props.onNewChat();
|
||||
}
|
||||
this.props.eventBus.emit('new-chat');
|
||||
});
|
||||
|
||||
this.deleteButton.addEventListener('click', () => {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ export const GRAPH_VIEW_TYPE = 'llm-agent-graph-view';
|
|||
|
||||
export class GraphView extends ItemView {
|
||||
plugin: LLMAgentPlugin;
|
||||
graphData: { nodes: any[], edges: any[] };
|
||||
graphData: { nodes: any[]; edges: any[] };
|
||||
currentNode: string | null;
|
||||
graphsList: any[];
|
||||
selectedGraphId: string | null;
|
||||
|
|
@ -95,7 +95,7 @@ export class GraphView extends ItemView {
|
|||
this.historyPanel = new HistoryPanel(this.historyContainer, {
|
||||
graphs: this.graphsList,
|
||||
onGraphSelect: this.handleGraphSelect.bind(this),
|
||||
onNewChat: this.handleNewChat.bind(this)
|
||||
eventBus: this.plugin.eventBus
|
||||
});
|
||||
|
||||
// Инициализируем React Flow
|
||||
|
|
@ -142,7 +142,6 @@ export class GraphView extends ItemView {
|
|||
const wrapper = this.graphContainer.createDiv();
|
||||
wrapper.style.cssText = 'width: 100%; height: 100%;';
|
||||
|
||||
|
||||
if (!wrapper) {
|
||||
console.error('Не удалось создать wrapper для монтирования React Flow.');
|
||||
return;
|
||||
|
|
@ -176,7 +175,7 @@ export class GraphView extends ItemView {
|
|||
}
|
||||
}
|
||||
// ... (остальные методы API и Event Handlers без изменений)
|
||||
// ----------------------------------------------- API Methods ---------------------------------------------------------------
|
||||
// ----------------------------------------------- API Methods ---------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Загружает список всех графов с бэкенда.
|
||||
|
|
@ -223,7 +222,6 @@ export class GraphView extends ItemView {
|
|||
|
||||
// Перерендериваем граф
|
||||
this.renderGraphPanel();
|
||||
|
||||
} catch (error) {
|
||||
console.error('Ошибка загрузки данных графа:', error);
|
||||
// Optionally: show a notice to the user
|
||||
|
|
@ -248,7 +246,7 @@ export class GraphView extends ItemView {
|
|||
* Обновляет `graphData` и перерендеривает граф.
|
||||
* @param {{ graphData: { nodes: any[], edges: any[] }, currentNode: string | null }} data - Обновленные данные графа.
|
||||
*/
|
||||
handleGraphUpdate(data: { graphData: { nodes: any[], edges: any[] }, currentNode: string | null }): void {
|
||||
handleGraphUpdate(data: { graphData: { nodes: any[]; edges: any[] }; currentNode: string | null }): void {
|
||||
this.graphData = data.graphData;
|
||||
this.currentNode = data.currentNode;
|
||||
this.renderGraphPanel();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user