Change to show graph title in graph panel
This commit is contained in:
parent
47cff8a121
commit
b0d802241b
|
|
@ -24,6 +24,7 @@ export class GraphView extends ItemView {
|
||||||
graphsList: any[];
|
graphsList: any[];
|
||||||
selectedGraphId: string | null;
|
selectedGraphId: string | null;
|
||||||
selectedNodeIds: Set<string>; // Добавляем Set для хранения ID выделенных узлов
|
selectedNodeIds: Set<string>; // Добавляем Set для хранения ID выделенных узлов
|
||||||
|
selectedGraphTitle: string | null;
|
||||||
|
|
||||||
// UI Elements
|
// UI Elements
|
||||||
historyPanel: HistoryPanel | null;
|
historyPanel: HistoryPanel | null;
|
||||||
|
|
@ -48,6 +49,7 @@ export class GraphView extends ItemView {
|
||||||
this.reactRoot = null;
|
this.reactRoot = null;
|
||||||
this.isHistoryCollapsed = true;
|
this.isHistoryCollapsed = true;
|
||||||
this.selectedNodeIds = new Set<string>(); // Инициализируем Set
|
this.selectedNodeIds = new Set<string>(); // Инициализируем Set
|
||||||
|
this.selectedGraphTitle = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -61,7 +63,7 @@ export class GraphView extends ItemView {
|
||||||
* @returns {string} Отображаемое имя представления.
|
* @returns {string} Отображаемое имя представления.
|
||||||
*/
|
*/
|
||||||
getDisplayText(): string {
|
getDisplayText(): string {
|
||||||
return 'LLM Agent Graph';
|
return this.selectedGraphTitle || 'LLM Agent Graph';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -143,6 +145,20 @@ export class GraphView extends ItemView {
|
||||||
this.plugin.eventBus.off('delete-node', this.handleDeleteNodeFromChat);
|
this.plugin.eventBus.off('delete-node', this.handleDeleteNodeFromChat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------- Custom Title Update ---------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Обновляет текстовое содержимое заголовка представления.
|
||||||
|
* Этот метод должен быть вызван для динамического изменения заголовка
|
||||||
|
* после первоначальной отрисовки представления.
|
||||||
|
*/
|
||||||
|
updateTitle(): void {
|
||||||
|
const titleElement = this.containerEl.querySelector('.view-header-title');
|
||||||
|
if (titleElement) {
|
||||||
|
titleElement.textContent = this.selectedGraphTitle || 'LLM Agent Graph';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------- History Panel Toggle --------------------------------------------------
|
// ----------------------------------------------- History Panel Toggle --------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -283,6 +299,8 @@ export class GraphView extends ItemView {
|
||||||
this.graphData = { nodes: [], edges: [] };
|
this.graphData = { nodes: [], edges: [] };
|
||||||
this.currentNode = null;
|
this.currentNode = null;
|
||||||
this.selectedNodeIds.clear(); // Очищаем выделения
|
this.selectedNodeIds.clear(); // Очищаем выделения
|
||||||
|
this.selectedGraphTitle = null; // Сброс заголовка
|
||||||
|
this.updateTitle(); // Обновляем заголовок
|
||||||
this.renderGraphPanel();
|
this.renderGraphPanel();
|
||||||
this.plugin.eventBus.emit('chat-history-updated', { graphId: null, messages: [], current_node_id: null });
|
this.plugin.eventBus.emit('chat-history-updated', { graphId: null, messages: [], current_node_id: null });
|
||||||
return;
|
return;
|
||||||
|
|
@ -301,6 +319,9 @@ export class GraphView extends ItemView {
|
||||||
};
|
};
|
||||||
this.currentNode = data.current_node_id;
|
this.currentNode = data.current_node_id;
|
||||||
|
|
||||||
|
// Устанавливаем заголовок графа
|
||||||
|
this.selectedGraphTitle = data.title || data.first_message || `Граф ${graphId.substring(0, 8)}...`;
|
||||||
|
this.updateTitle(); // Обновляем заголовок
|
||||||
// Перерендериваем граф
|
// Перерендериваем граф
|
||||||
this.renderGraphPanel();
|
this.renderGraphPanel();
|
||||||
|
|
||||||
|
|
@ -310,9 +331,10 @@ export class GraphView extends ItemView {
|
||||||
messages: data.messages || [],
|
messages: data.messages || [],
|
||||||
current_node_id: data.current_node_id // Передаем актуальный current_node_id
|
current_node_id: data.current_node_id // Передаем актуальный current_node_id
|
||||||
});
|
});
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Ошибка загрузки данных графа:', error);
|
console.error('Ошибка загрузки данных графа:', error);
|
||||||
|
this.selectedGraphTitle = null;
|
||||||
|
this.updateTitle(); // Обновляем заголовок
|
||||||
// Optionally: show a notice to the user
|
// Optionally: show a notice to the user
|
||||||
// new Notice(`Ошибка загрузки данных графа: ${error.message}`);
|
// new Notice(`Ошибка загрузки данных графа: ${error.message}`);
|
||||||
}
|
}
|
||||||
|
|
@ -347,7 +369,6 @@ export class GraphView extends ItemView {
|
||||||
|
|
||||||
// Сбрасываем выделение, если удаленный узел был выделен
|
// Сбрасываем выделение, если удаленный узел был выделен
|
||||||
this.selectedNodeIds.delete(nodeId);
|
this.selectedNodeIds.delete(nodeId);
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Ошибка при удалении узла ${nodeId}:`, error);
|
console.error(`Ошибка при удалении узла ${nodeId}:`, error);
|
||||||
new Notice(`Ошибка при удалении узла: ${error.message}`, 5000);
|
new Notice(`Ошибка при удалении узла: ${error.message}`, 5000);
|
||||||
|
|
@ -393,6 +414,8 @@ export class GraphView extends ItemView {
|
||||||
this.currentNode = null;
|
this.currentNode = null;
|
||||||
this.selectedGraphId = null;
|
this.selectedGraphId = null;
|
||||||
this.selectedNodeIds.clear(); // Очищаем выделения
|
this.selectedNodeIds.clear(); // Очищаем выделения
|
||||||
|
this.selectedGraphTitle = null; // Сброс заголовка при новом чате
|
||||||
|
this.updateTitle(); // Обновляем заголовок
|
||||||
this.renderGraphPanel();
|
this.renderGraphPanel();
|
||||||
this.fetchGraphsList(); // Обновить список графов, чтобы показать новый пустой чат
|
this.fetchGraphsList(); // Обновить список графов, чтобы показать новый пустой чат
|
||||||
this.plugin.eventBus.emit('chat-history-updated', { graphId: null, messages: [], current_node_id: null });
|
this.plugin.eventBus.emit('chat-history-updated', { graphId: null, messages: [], current_node_id: null });
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user