From 5bf29198ff9ba53e348f755f36a8b3f7bbf3c41a Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Thu, 8 Oct 2026 15:44:39 +0200 Subject: [PATCH] gui: pass session cwd as plumb wdir for relative path resolution Plumb messages now include the current session's cwd as wdir. Added sessionCwd() helper to ChatPane and ChatBlockDelegate. Updated plumber.plumb() to accept optional wdir parameter. --- kde/gui/ChatBlockDelegate.qml | 13 ++++++++++--- kde/gui/ChatPane.qml | 9 ++++++++- kde/gui/plumber.h | 4 ++-- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/kde/gui/ChatBlockDelegate.qml b/kde/gui/ChatBlockDelegate.qml index 0d4c064..ee34501 100644 --- a/kde/gui/ChatBlockDelegate.qml +++ b/kde/gui/ChatBlockDelegate.qml @@ -253,7 +253,7 @@ Column { // B3: Plumb selection (no context menu) var sel = mainTextEdit.selectedText if (sel && sel.trim() !== "" && plumber.available()) { - plumber.plumb(sel.trim()) + plumber.plumb(sel.trim(), sessionCwd()) } mouse.accepted = true } @@ -332,6 +332,13 @@ Column { return false } + // Get current session's working directory for plumb basedir + function sessionCwd() { + if (!ollie.activeSessionId) return "" + var cfg = ollie.readSessionConfig(ollie.activeSessionId) + return cfg ? (cfg.cwd || "") : "" + } + // Text segment component Component { id: textComponent @@ -392,7 +399,7 @@ Column { // B3: Plumb selection (no context menu) var sel = textEdit.selectedText if (sel && sel.trim() !== "" && plumber.available()) { - plumber.plumb(sel.trim()) + plumber.plumb(sel.trim(), sessionCwd()) } mouse.accepted = true } @@ -501,7 +508,7 @@ Column { // B3: Plumb selection (no context menu) var sel = sourceEdit.selectedText if (sel && sel.trim() !== "" && plumber.available()) { - plumber.plumb(sel.trim()) + plumber.plumb(sel.trim(), sessionCwd()) } mouse.accepted = true } diff --git a/kde/gui/ChatPane.qml b/kde/gui/ChatPane.qml index 9379045..474769d 100644 --- a/kde/gui/ChatPane.qml +++ b/kde/gui/ChatPane.qml @@ -37,6 +37,13 @@ Item { scrollToBottom() } + // Get current session's working directory for plumb basedir + function sessionCwd() { + if (!ollie.activeSessionId) return "" + var cfg = ollie.readSessionConfig(ollie.activeSessionId) + return cfg ? (cfg.cwd || "") : "" + } + Component.onCompleted: { loadChat() scrollToBottom() @@ -499,7 +506,7 @@ Item { // B3: Plumb selection (no context menu) var sel = promptInput.selectedText if (sel && sel.trim() !== "" && plumber.available()) { - plumber.plumb(sel.trim()) + plumber.plumb(sel.trim(), sessionCwd()) } } } diff --git a/kde/gui/plumber.h b/kde/gui/plumber.h index 99372f2..e0611cc 100644 --- a/kde/gui/plumber.h +++ b/kde/gui/plumber.h @@ -56,8 +56,8 @@ public: Q_INVOKABLE bool available() const; // Legacy compatibility aliases - Q_INVOKABLE void plumb(const QString &text) { send(text); } - Q_INVOKABLE void plumbTo(const QString &text, const QString &dst) { sendTo(text, dst); } + Q_INVOKABLE void plumb(const QString &text, const QString &wdir = QString()) { send(text, wdir); } + Q_INVOKABLE void plumbTo(const QString &text, const QString &dst, const QString &wdir = QString()) { sendTo(text, dst, wdir); } /*! * Start the edit-port reader thread. Safe to call once; further calls are