Hide context blocks in KDE chat
This commit is contained in:
parent
07dcd60d19
commit
bb6df3a073
|
|
@ -232,6 +232,7 @@ void ChatBlockModel::reset()
|
|||
beginResetModel();
|
||||
m_blocks.clear();
|
||||
m_lineBuffer.clear();
|
||||
m_inContext = false;
|
||||
m_state = State::BlockStart;
|
||||
m_inCodeFence = false;
|
||||
m_fenceLanguage.clear();
|
||||
|
|
@ -680,6 +681,18 @@ void ChatBlockModel::processLine(const QString &line)
|
|||
}
|
||||
|
||||
case State::BlockEnd:
|
||||
// Hide prompt context blocks from the rendered chat, matching olliesrv.
|
||||
if (line.trimmed() == QStringLiteral("<context>")) {
|
||||
m_inContext = true;
|
||||
return;
|
||||
}
|
||||
if (line.trimmed() == QStringLiteral("</context>")) {
|
||||
m_inContext = false;
|
||||
return;
|
||||
}
|
||||
if (m_inContext)
|
||||
return;
|
||||
|
||||
// [[[end]]] closes the current block
|
||||
if (s_endRe.match(line).hasMatch()) {
|
||||
// Emit final update so QML picks up the completed segment state.
|
||||
|
|
|
|||
|
|
@ -134,6 +134,9 @@ private:
|
|||
QList<ChatBlock> m_blocks;
|
||||
QString m_lineBuffer;
|
||||
|
||||
// Context blocks are injected into prompts but hidden from chat rendering.
|
||||
bool m_inContext = false;
|
||||
|
||||
// Code fence state (for streaming)
|
||||
bool m_inCodeFence = false;
|
||||
QString m_fenceLanguage;
|
||||
|
|
|
|||
Loading…
Reference in New Issue