Skip to content

Commit

Permalink
fix: path to chat file without project
Browse files Browse the repository at this point in the history
  • Loading branch information
Palm1r committed Dec 23, 2024
1 parent d04e5bc commit ee2c395
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions ChatView/ChatModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ void ChatModel::clear()
m_totalTokens = 0;
endResetModel();
emit totalTokensChanged();
emit modelReseted();
}

QList<MessagePart> ChatModel::processMessageContent(const QString &content) const
Expand Down
1 change: 1 addition & 0 deletions ChatView/ChatModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class ChatModel : public QAbstractListModel
signals:
void totalTokensChanged();
void tokensThresholdChanged();
void modelReseted();

private:
void trim();
Expand Down
7 changes: 2 additions & 5 deletions ChatView/ChatRootView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ ChatRootView::ChatRootView(QQuickItem *parent)
this,
&ChatRootView::autosave);

connect(m_chatModel, &ChatModel::modelReseted, [this]() { m_recentFilePath = QString(); });

generateColors();
}

Expand Down Expand Up @@ -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();
Expand Down
8 changes: 6 additions & 2 deletions settings/ProjectSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "GeneralSettings.hpp"
#include "SettingsConstants.hpp"
#include "SettingsTr.hpp"
#include <coreplugin/icore.h>
#include <projectexplorer/project.h>

namespace QodeAssist::Settings {
Expand All @@ -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));
Expand Down

0 comments on commit ee2c395

Please sign in to comment.