gui: add session name field to New Session dialog

Optional name field in the dialog. If provided, the session is
renamed immediately after creation via RenameSession D-Bus call.
Left blank, the auto-generated ID is used as before.
This commit is contained in:
Levi Neely 2026-07-27 09:25:00 +02:00
parent c62ae85b2c
commit 4392c7ec7b
4 changed files with 27 additions and 5 deletions

View File

@ -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

View File

@ -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

View File

@ -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<QString> 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();
});

View File

@ -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);