diff --git a/gui/main-kf5.qml b/gui/main-kf5.qml index a0658b6..69e637c 100644 --- a/gui/main-kf5.qml +++ b/gui/main-kf5.qml @@ -179,6 +179,7 @@ ApplicationWindow { } function openNewSessionDialog() { + nameInput.text = "" newSessionDialog.backendModel = dbus.listBackends() newSessionDialog.cwdField.text = dbus.activeCwd || "" newSessionDialog.backendCombo.currentIndex = 0 @@ -204,7 +205,8 @@ ApplicationWindow { if (cwd === "") cwd = dbus.activeCwd || "" var backend = backendSelect.currentText var model = modelSelect.editText.trim() || modelSelect.currentText - dbus.createSession(cwd, backend, model) + var name = nameInput.text.trim() + dbus.createSession(cwd, backend, model, name) } GridLayout { @@ -213,6 +215,13 @@ ApplicationWindow { columnSpacing: 10 rowSpacing: 8 + Label { text: "Name:" } + TextField { + id: nameInput + Layout.fillWidth: true + placeholderText: "(auto-generated)" + } + Label { text: "Working directory:" } RowLayout { Layout.fillWidth: true diff --git a/gui/main.qml b/gui/main.qml index fac6395..e95c276 100644 --- a/gui/main.qml +++ b/gui/main.qml @@ -179,6 +179,7 @@ ApplicationWindow { } function openNewSessionDialog() { + nameInput.text = "" newSessionDialog.backendModel = dbus.listBackends() newSessionDialog.cwdField.text = dbus.activeCwd || "" newSessionDialog.backendCombo.currentIndex = 0 @@ -204,7 +205,8 @@ ApplicationWindow { if (cwd === "") cwd = dbus.activeCwd || "" let backend = backendSelect.currentText let model = modelSelect.editText.trim() || modelSelect.currentText - dbus.createSession(cwd, backend, model) + let name = nameInput.text.trim() + dbus.createSession(cwd, backend, model, name) } GridLayout { @@ -213,6 +215,13 @@ ApplicationWindow { columnSpacing: 10 rowSpacing: 8 + Label { text: "Name:" } + TextField { + id: nameInput + Layout.fillWidth: true + placeholderText: "(auto-generated)" + } + Label { text: "Working directory:" } RowLayout { Layout.fillWidth: true diff --git a/plasmoid/plugin/olliedbusclient.cpp b/plasmoid/plugin/olliedbusclient.cpp index 117e72b..7716053 100644 --- a/plasmoid/plugin/olliedbusclient.cpp +++ b/plasmoid/plugin/olliedbusclient.cpp @@ -267,16 +267,20 @@ void OllieDBusClient::onFetchConfigFinished(QDBusPendingCallWatcher *watcher) // --- User-initiated actions (fire-and-forget async) --- -QString OllieDBusClient::createSession(const QString &cwd, const QString &backend, const QString &model) +QString OllieDBusClient::createSession(const QString &cwd, const QString &backend, const QString &model, const QString &name) { QString dir = cwd.isEmpty() ? QDir::homePath() : cwd; auto *watcher = new QDBusPendingCallWatcher( m_iface->asyncCall("CreateSession", dir, backend, model, QString("default"), QString(), QString()), this); - connect(watcher, &QDBusPendingCallWatcher::finished, this, [this](QDBusPendingCallWatcher *w) { + connect(watcher, &QDBusPendingCallWatcher::finished, this, [this, name](QDBusPendingCallWatcher *w) { QDBusPendingReply reply = *w; if (reply.isError()) { emit errorOccurred(reply.error().message()); + } else if (!name.trimmed().isEmpty()) { + // Rename the newly created session + QString sessionId = reply.value(); + m_iface->asyncCall("RenameSession", sessionId, name.trimmed()); } w->deleteLater(); }); diff --git a/plasmoid/plugin/olliedbusclient.h b/plasmoid/plugin/olliedbusclient.h index 82dd308..1ad2b90 100644 --- a/plasmoid/plugin/olliedbusclient.h +++ b/plasmoid/plugin/olliedbusclient.h @@ -47,7 +47,7 @@ public: Q_INVOKABLE void refreshSessions(); Q_INVOKABLE void fetchChat(); - Q_INVOKABLE QString createSession(const QString &cwd, const QString &backend = QString(), const QString &model = QString()); + Q_INVOKABLE QString createSession(const QString &cwd, const QString &backend = QString(), const QString &model = QString(), const QString &name = QString()); Q_INVOKABLE void createSessionWithDialog(); Q_INVOKABLE bool killSession(const QString &sessionId); Q_INVOKABLE bool renameSession(const QString &sessionId, const QString &newName);