GUI: handle ollie:// plumb URLs to display chat blocks
Plumb ollie://session/agent#blockid URLs fetch the block via chat.search and append to the chat pane. Non-persistent display for quick reference.
This commit is contained in:
parent
c186c87525
commit
e53d612bdb
|
|
@ -10,6 +10,7 @@
|
|||
#include <QQmlContext>
|
||||
#include <QQuickStyle>
|
||||
#include <QStandardPaths>
|
||||
#include <QUrl>
|
||||
|
||||
#include "ollie9pclient.h"
|
||||
#include "sessionmodel.h"
|
||||
|
|
@ -54,6 +55,28 @@ int main(int argc, char *argv[])
|
|||
QObject::connect(ollie, &Ollie9pClient::chatReceived,
|
||||
chatModel, &ChatBlockModel::appendData);
|
||||
|
||||
// Handle ollie:// URLs from plumber — fetch block and display in chat
|
||||
QObject::connect(plumber, &Plumber::ollieMessage, [ollie, chatModel](const QString &url) {
|
||||
// Parse ollie://session/agent#blockid
|
||||
QUrl parsed(url);
|
||||
if (parsed.scheme() != QStringLiteral("ollie"))
|
||||
return;
|
||||
QString path = parsed.path();
|
||||
if (path.startsWith('/'))
|
||||
path = path.mid(1);
|
||||
QStringList parts = path.split('/');
|
||||
if (parts.size() < 2)
|
||||
return;
|
||||
QString sessionId = parts.value(0);
|
||||
QString agentId = parts.value(1);
|
||||
QString blockId = parsed.fragment();
|
||||
if (blockId.isEmpty())
|
||||
return;
|
||||
|
||||
QString block = ollie->fetchBlock(sessionId, agentId, blockId);
|
||||
if (!block.isEmpty())
|
||||
chatModel->appendData(block);
|
||||
});
|
||||
|
||||
engine.rootContext()->setContextProperty("ollie", ollie);
|
||||
engine.rootContext()->setContextProperty("sessionModel", sessionModel);
|
||||
|
|
|
|||
|
|
@ -1073,6 +1073,18 @@ QVariantList Ollie9pClient::listAgentsInSession(const QString &sessionId)
|
|||
return result;
|
||||
}
|
||||
|
||||
QString Ollie9pClient::fetchBlock(const QString &sessionId, const QString &agentId, const QString &blockId)
|
||||
{
|
||||
if (sessionId.isEmpty() || agentId.isEmpty() || blockId.isEmpty())
|
||||
return QString();
|
||||
if (!m_9p || !m_9p->isConnected())
|
||||
return QString();
|
||||
|
||||
QString path = QStringLiteral("session/%1/agent/%2/chat.search").arg(sessionId, agentId);
|
||||
QByteArray out = m_9p->rdwr(path, blockId.toUtf8());
|
||||
return QString::fromUtf8(out);
|
||||
}
|
||||
|
||||
// --- Root data loading (lazy) ---
|
||||
|
||||
void Ollie9pClient::ensureRootDataLoaded()
|
||||
|
|
|
|||
|
|
@ -112,6 +112,9 @@ public:
|
|||
Q_INVOKABLE bool addPeer(const QString &sessionId, const QString &agentId, const QString &peerName);
|
||||
Q_INVOKABLE bool removePeer(const QString &sessionId, const QString &agentId, const QString &peerName);
|
||||
Q_INVOKABLE QVariantList listAgentsInSession(const QString &sessionId);
|
||||
|
||||
// Block lookup via chat.search
|
||||
Q_INVOKABLE QString fetchBlock(const QString &sessionId, const QString &agentId, const QString &blockId);
|
||||
|
||||
signals:
|
||||
void sessionsChanged();
|
||||
|
|
|
|||
Loading…
Reference in New Issue