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:
parent
c62ae85b2c
commit
4392c7ec7b
|
|
@ -179,6 +179,7 @@ ApplicationWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
function openNewSessionDialog() {
|
function openNewSessionDialog() {
|
||||||
|
nameInput.text = ""
|
||||||
newSessionDialog.backendModel = dbus.listBackends()
|
newSessionDialog.backendModel = dbus.listBackends()
|
||||||
newSessionDialog.cwdField.text = dbus.activeCwd || ""
|
newSessionDialog.cwdField.text = dbus.activeCwd || ""
|
||||||
newSessionDialog.backendCombo.currentIndex = 0
|
newSessionDialog.backendCombo.currentIndex = 0
|
||||||
|
|
@ -204,7 +205,8 @@ ApplicationWindow {
|
||||||
if (cwd === "") cwd = dbus.activeCwd || ""
|
if (cwd === "") cwd = dbus.activeCwd || ""
|
||||||
var backend = backendSelect.currentText
|
var backend = backendSelect.currentText
|
||||||
var model = modelSelect.editText.trim() || modelSelect.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 {
|
GridLayout {
|
||||||
|
|
@ -213,6 +215,13 @@ ApplicationWindow {
|
||||||
columnSpacing: 10
|
columnSpacing: 10
|
||||||
rowSpacing: 8
|
rowSpacing: 8
|
||||||
|
|
||||||
|
Label { text: "Name:" }
|
||||||
|
TextField {
|
||||||
|
id: nameInput
|
||||||
|
Layout.fillWidth: true
|
||||||
|
placeholderText: "(auto-generated)"
|
||||||
|
}
|
||||||
|
|
||||||
Label { text: "Working directory:" }
|
Label { text: "Working directory:" }
|
||||||
RowLayout {
|
RowLayout {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
|
||||||
11
gui/main.qml
11
gui/main.qml
|
|
@ -179,6 +179,7 @@ ApplicationWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
function openNewSessionDialog() {
|
function openNewSessionDialog() {
|
||||||
|
nameInput.text = ""
|
||||||
newSessionDialog.backendModel = dbus.listBackends()
|
newSessionDialog.backendModel = dbus.listBackends()
|
||||||
newSessionDialog.cwdField.text = dbus.activeCwd || ""
|
newSessionDialog.cwdField.text = dbus.activeCwd || ""
|
||||||
newSessionDialog.backendCombo.currentIndex = 0
|
newSessionDialog.backendCombo.currentIndex = 0
|
||||||
|
|
@ -204,7 +205,8 @@ ApplicationWindow {
|
||||||
if (cwd === "") cwd = dbus.activeCwd || ""
|
if (cwd === "") cwd = dbus.activeCwd || ""
|
||||||
let backend = backendSelect.currentText
|
let backend = backendSelect.currentText
|
||||||
let model = modelSelect.editText.trim() || modelSelect.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 {
|
GridLayout {
|
||||||
|
|
@ -213,6 +215,13 @@ ApplicationWindow {
|
||||||
columnSpacing: 10
|
columnSpacing: 10
|
||||||
rowSpacing: 8
|
rowSpacing: 8
|
||||||
|
|
||||||
|
Label { text: "Name:" }
|
||||||
|
TextField {
|
||||||
|
id: nameInput
|
||||||
|
Layout.fillWidth: true
|
||||||
|
placeholderText: "(auto-generated)"
|
||||||
|
}
|
||||||
|
|
||||||
Label { text: "Working directory:" }
|
Label { text: "Working directory:" }
|
||||||
RowLayout {
|
RowLayout {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
|
||||||
|
|
@ -267,16 +267,20 @@ void OllieDBusClient::onFetchConfigFinished(QDBusPendingCallWatcher *watcher)
|
||||||
|
|
||||||
// --- User-initiated actions (fire-and-forget async) ---
|
// --- 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;
|
QString dir = cwd.isEmpty() ? QDir::homePath() : cwd;
|
||||||
auto *watcher = new QDBusPendingCallWatcher(
|
auto *watcher = new QDBusPendingCallWatcher(
|
||||||
m_iface->asyncCall("CreateSession", dir, backend, model, QString("default"), QString(), QString()),
|
m_iface->asyncCall("CreateSession", dir, backend, model, QString("default"), QString(), QString()),
|
||||||
this);
|
this);
|
||||||
connect(watcher, &QDBusPendingCallWatcher::finished, this, [this](QDBusPendingCallWatcher *w) {
|
connect(watcher, &QDBusPendingCallWatcher::finished, this, [this, name](QDBusPendingCallWatcher *w) {
|
||||||
QDBusPendingReply<QString> reply = *w;
|
QDBusPendingReply<QString> reply = *w;
|
||||||
if (reply.isError()) {
|
if (reply.isError()) {
|
||||||
emit errorOccurred(reply.error().message());
|
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();
|
w->deleteLater();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ public:
|
||||||
|
|
||||||
Q_INVOKABLE void refreshSessions();
|
Q_INVOKABLE void refreshSessions();
|
||||||
Q_INVOKABLE void fetchChat();
|
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 void createSessionWithDialog();
|
||||||
Q_INVOKABLE bool killSession(const QString &sessionId);
|
Q_INVOKABLE bool killSession(const QString &sessionId);
|
||||||
Q_INVOKABLE bool renameSession(const QString &sessionId, const QString &newName);
|
Q_INVOKABLE bool renameSession(const QString &sessionId, const QString &newName);
|
||||||
|
|
|
||||||
Reference in New Issue