From 3b42c9ee25a5c81778a93a02b5dca7f988c5720f Mon Sep 17 00:00:00 2001 From: Levi Neely <141506390+lneely@users.noreply.github.com> Date: Tue, 7 Jul 2026 15:02:55 +0200 Subject: [PATCH] plasmoid: folder picker for new sessions, fix chat offset encoding - New session button opens a FolderDialog to choose the working directory before creating the session. - Fix chat truncation: use toUtf8().size() for offset tracking to match the server byte-based offsets. QString::size() (UTF-16 code units) caused drift on non-ASCII characters, leading to stalled output. --- plasmoid/contents/ui/main.qml | 12 +++++++++++- plasmoid/plugin/olliedbusclient.cpp | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/plasmoid/contents/ui/main.qml b/plasmoid/contents/ui/main.qml index 093346f..91ba383 100644 --- a/plasmoid/contents/ui/main.qml +++ b/plasmoid/contents/ui/main.qml @@ -24,6 +24,16 @@ PlasmoidItem { } } + FolderDialog { + id: newSessionFolderDialog + title: "Choose working directory for new session" + currentFolder: dbus.activeCwd ? "file://" + dbus.activeCwd : StandardPaths.writableLocation(StandardPaths.HomeLocation) + onAccepted: { + let path = selectedFolder.toString().replace("file://", "") + dbus.createSession(path) + } + } + // On the desktop (Planar), the widget has plenty of room so Plasma will // automatically use fullRepresentation. In a panel, the available space // is smaller than switchWidth/switchHeight so compactRepresentation is used. @@ -122,7 +132,7 @@ PlasmoidItem { PlasmaComponents.ToolButton { icon.name: "list-add" - onClicked: dbus.createSession("") + onClicked: newSessionFolderDialog.open() PlasmaComponents.ToolTip { text: "New session" } } } diff --git a/plasmoid/plugin/olliedbusclient.cpp b/plasmoid/plugin/olliedbusclient.cpp index 4708f83..fe8b1ea 100644 --- a/plasmoid/plugin/olliedbusclient.cpp +++ b/plasmoid/plugin/olliedbusclient.cpp @@ -304,7 +304,7 @@ void OllieDBusClient::onChatUpdated(const QString &session_id, qlonglong offset, // Append directly from the signal — no need to poll if (offset == m_chatOffset) { m_chatText += new_text; - m_chatOffset += new_text.size(); + m_chatOffset += new_text.toUtf8().size(); emit chatTextChanged(); } else { // Offset mismatch — do a full fetch