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.
This commit is contained in:
Levi Neely 2026-07-07 15:02:55 +02:00
parent 327030293b
commit 3b42c9ee25
2 changed files with 12 additions and 2 deletions

View File

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

View File

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