fix: path to chat file without project

This commit is contained in:
Petr Mironychev 2024-12-23 23:17:43 +01:00
parent d04e5bc967
commit ee2c3950e8
4 changed files with 10 additions and 7 deletions

View File

@ -121,6 +121,7 @@ void ChatModel::clear()
m_totalTokens = 0;
endResetModel();
emit totalTokensChanged();
emit modelReseted();
}
QList<MessagePart> ChatModel::processMessageContent(const QString &content) const

View File

@ -71,6 +71,7 @@ public:
signals:
void totalTokensChanged();
void tokensThresholdChanged();
void modelReseted();
private:
void trim();

View File

@ -60,6 +60,8 @@ ChatRootView::ChatRootView(QQuickItem *parent)
this,
&ChatRootView::autosave);
connect(m_chatModel, &ChatModel::modelReseted, [this]() { m_recentFilePath = QString(); });
generateColors();
}
@ -251,11 +253,6 @@ QString ChatRootView::getSuggestedFileName() const
{
QStringList parts;
if (auto project = ProjectExplorer::ProjectManager::startupProject()) {
QString projectName = project->projectDirectory().fileName();
parts << projectName;
}
if (m_chatModel->rowCount() > 0) {
QString firstMessage
= m_chatModel->data(m_chatModel->index(0), ChatModel::Content).toString();

View File

@ -22,6 +22,7 @@
#include "GeneralSettings.hpp"
#include "SettingsConstants.hpp"
#include "SettingsTr.hpp"
#include <coreplugin/icore.h>
#include <projectexplorer/project.h>
namespace QodeAssist::Settings {
@ -41,8 +42,11 @@ ProjectSettings::ProjectSettings(ProjectExplorer::Project *project)
chatHistoryPath.setSettingsKey(Constants::QODE_ASSIST_CHAT_HISTORY_PATH);
chatHistoryPath.setExpectedKind(Utils::PathChooser::ExistingDirectory);
chatHistoryPath.setLabelText(Tr::tr("Chat History Path:"));
chatHistoryPath.setDefaultValue(
project->projectDirectory().toString() + "/.qodeassist/chat_history");
QString projectChatHistoryPath
= QString("%1/qodeassist/chat_history").arg(Core::ICore::userResourcePath().toString());
chatHistoryPath.setDefaultValue(projectChatHistoryPath);
Utils::Store map = Utils::storeFromVariant(
project->namedSettings(Constants::QODE_ASSIST_PROJECT_SETTINGS_ID));