diff --git a/ChatView/ChatRootView.cpp b/ChatView/ChatRootView.cpp index f6e58de..c631dc5 100644 --- a/ChatView/ChatRootView.cpp +++ b/ChatView/ChatRootView.cpp @@ -72,7 +72,7 @@ ChatRootView::ChatRootView(QQuickItem *parent) this, &ChatRootView::updateInputTokensCount); - connect(m_chatModel, &ChatModel::modelReseted, [this]() { m_recentFilePath = QString(); }); + connect(m_chatModel, &ChatModel::modelReseted, [this]() { setRecentFilePath(QString{}); }); connect(this, &ChatRootView::attachmentFilesChanged, &ChatRootView::updateInputTokensCount); connect(this, &ChatRootView::linkedFilesChanged, &ChatRootView::updateInputTokensCount); connect(&Settings::chatAssistantSettings().useSystemPrompt, &Utils::BaseAspect::changed, @@ -107,7 +107,7 @@ void ChatRootView::sendMessage(const QString &message) if (reply == QMessageBox::Yes) { autosave(); m_chatModel->clear(); - m_recentFilePath = QString{}; + setRecentFilePath(QString{}); return; } } @@ -182,7 +182,7 @@ void ChatRootView::loadHistory(const QString &filePath) if (!result.success) { LOG_MESSAGE(QString("Failed to load chat history: %1").arg(result.errorMessage)); } else { - m_recentFilePath = filePath; + setRecentFilePath(filePath); } updateInputTokensCount(); } @@ -265,7 +265,7 @@ void ChatRootView::autosave() QString filePath = getAutosaveFilePath(); if (!filePath.isEmpty()) { ChatSerializer::saveToFile(m_chatModel, filePath); - m_recentFilePath = filePath; + setRecentFilePath(filePath); } } @@ -447,4 +447,17 @@ void ChatRootView::onEditorsClosed(QList editors) } } +QString ChatRootView::chatFileName() const +{ + return QFileInfo(m_recentFilePath).baseName(); +} + +void ChatRootView::setRecentFilePath(const QString &filePath) +{ + if (m_recentFilePath != filePath) { + m_recentFilePath = filePath; + emit chatFileNameChanged(); + } +} + } // namespace QodeAssist::Chat diff --git a/ChatView/ChatRootView.hpp b/ChatView/ChatRootView.hpp index 0eecaaf..22c2033 100644 --- a/ChatView/ChatRootView.hpp +++ b/ChatView/ChatRootView.hpp @@ -36,6 +36,7 @@ class ChatRootView : public QQuickItem Q_PROPERTY(QStringList attachmentFiles READ attachmentFiles NOTIFY attachmentFilesChanged FINAL) Q_PROPERTY(QStringList linkedFiles READ linkedFiles NOTIFY linkedFilesChanged FINAL) Q_PROPERTY(int inputTokensCount READ inputTokensCount NOTIFY inputTokensCountChanged FINAL) + Q_PROPERTY(QString chatFileName READ chatFileName NOTIFY chatFileNameChanged FINAL) QML_ELEMENT @@ -73,6 +74,9 @@ public: void onEditorAboutToClose(Core::IEditor *editor); void onEditorsClosed(QList editors); + QString chatFileName() const; + void setRecentFilePath(const QString &filePath); + public slots: void sendMessage(const QString &message); void copyToClipboard(const QString &text); @@ -87,6 +91,7 @@ signals: void linkedFilesChanged(); void inputTokensCountChanged(); void isSyncOpenFilesChanged(); + void chatFileNameChanged(); private: QString getChatsHistoryDir() const; diff --git a/ChatView/qml/RootItem.qml b/ChatView/qml/RootItem.qml index 1be7325..d43bcb2 100644 --- a/ChatView/qml/RootItem.qml +++ b/ChatView/qml/RootItem.qml @@ -72,6 +72,9 @@ ChatRootView { tokensBadge { text: qsTr("tokens:%1/%2").arg(root.inputTokensCount).arg(root.chatModel.tokensThreshold) } + recentPath { + text: qsTr("Latest chat file name: %1").arg(root.chatFileName.length > 0 ? root.chatFileName : "Unsaved") + } } ListView { diff --git a/ChatView/qml/parts/TopBar.qml b/ChatView/qml/parts/TopBar.qml index 721ab24..d7aac35 100644 --- a/ChatView/qml/parts/TopBar.qml +++ b/ChatView/qml/parts/TopBar.qml @@ -28,6 +28,7 @@ Rectangle { property alias loadButton: loadButtonId property alias clearButton: clearButtonId property alias tokensBadge: tokensBadgeId + property alias recentPath: recentPathId color: palette.window.hslLightness > 0.5 ? Qt.darker(palette.window, 1.1) : @@ -62,6 +63,14 @@ Rectangle { text: qsTr("Clear") } + Text { + id: recentPathId + + Layout.fillWidth: true + elide: Text.ElideMiddle + color: palette.text + } + Item { Layout.fillWidth: true }