Skip to content

Commit f4b35aa

Browse files
fix(acp): refresh git tree on agent file-write tool calls
- Agents that write files via Edit/Write tool calls only emit toolCallAddedOrUpdated, not the ACP fs/write_text_file signal, so the git working tree was never marked dirty after their edits. - Connect to toolCallAddedOrUpdated and fire gitWorkingTreeDirtied when a completed Edit or Write tool call is detected.
1 parent 09fa598 commit f4b35aa

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

‎src/AcpAgentManager.cpp‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,33 @@ void AcpAgentManager::wireConnectionToModel(AcpConnection *conn, AcpSessionModel
350350
"gitWorkingTreeDirtied",
351351
Q_ARG(QString, path));
352352
});
353+
354+
// Trigger git refresh when an agent completes a file-modifying tool call
355+
// (Edit/Write). Most agents write files directly and only send tool_call
356+
// notifications — they don't use the ACP fs/write_text_file call above.
357+
connect(model, &AcpSessionModel::toolCallAddedOrUpdated, this,
358+
[model, conn](const QString &toolCallId) {
359+
const auto it = model->toolCalls().constFind(toolCallId);
360+
if (it == model->toolCalls().constEnd())
361+
return;
362+
const auto &tc = it.value();
363+
if (tc.status != QLatin1String("completed"))
364+
return;
365+
const QString titleLower = tc.title.toLower();
366+
if (titleLower != QLatin1String("edit") &&
367+
titleLower != QLatin1String("write") &&
368+
titleLower != QLatin1String("edit file") &&
369+
titleLower != QLatin1String("write file"))
370+
return;
371+
QString path = tc.rawInput[QLatin1String("file_path")].toString();
372+
if (path.isEmpty())
373+
path = conn->workingDirectory();
374+
if (path.isEmpty())
375+
return;
376+
QMetaObject::invokeMethod(QCoreApplication::instance(),
377+
"gitWorkingTreeDirtied",
378+
Q_ARG(QString, path));
379+
});
353380
}
354381

355382
void AcpAgentManager::teardownSession(Session &session)

0 commit comments

Comments
 (0)