fix(acp): sync native agent session titles (#1028)

* fix(acp): sync native session titles

* fix(acp): keep title refresh off turn path

* fix: reconcile native ACP titles with skill lookup

* fix: preserve OpenCode image tool instruction
This commit is contained in:
SSU-WEI HUANG
2026-07-24 10:59:47 +08:00
committed by GitHub
parent 72476b9cea
commit 40c1789357
14 changed files with 339 additions and 51 deletions
+6 -2
View File
@@ -1,4 +1,5 @@
import React from 'react';
import { registerAcpSessionTitleSync } from '@/agent/acpSessionTitle';
import { logger } from '@/ui/logger';
import { buildHapiMcpBridge } from '@/codex/utils/buildHapiMcpBridge';
import { convertAgentMessage } from '@/agent/messageConverter';
@@ -10,7 +11,7 @@ import type { OpencodeMode, PermissionMode } from './types';
import { RPC_METHODS } from '@hapi/protocol/rpcMethods';
import { createOpencodeBackend } from './utils/opencodeBackend';
import { OpencodePermissionHandler } from './utils/permissionHandler';
import { PLAN_MODE_INSTRUCTION, TITLE_INSTRUCTION } from './utils/systemPrompt';
import { OPENCODE_NATIVE_TOOL_INSTRUCTION, PLAN_MODE_INSTRUCTION } from './utils/systemPrompt';
import { resolveThoughtLevelEffort } from './thoughtLevelEffort';
type OpencodeRemoteLauncherOptions = {
@@ -56,6 +57,7 @@ class OpencodeRemoteLauncher extends RemoteLauncherBase {
const messageBuffer = this.messageBuffer;
const { server: happyServer, mcpServers } = await buildHapiMcpBridge(session.client, {
enableChangeTitle: false,
skillLookup: { workingDirectory: session.path, flavor: 'opencode' }
});
this.happyServer = happyServer;
@@ -64,6 +66,7 @@ class OpencodeRemoteLauncher extends RemoteLauncherBase {
cwd: session.path
});
this.backend = backend;
registerAcpSessionTitleSync(backend, session.client);
backend.onStderrError((error) => {
logger.debug('[opencode-remote] stderr error', error);
@@ -274,7 +277,7 @@ class OpencodeRemoteLauncher extends RemoteLauncherBase {
messageText = `${PLAN_MODE_INSTRUCTION}\n\n${messageText}`;
}
if (!this.instructionsSent) {
messageText = `${TITLE_INSTRUCTION}\n\n${messageText}`;
messageText = `${OPENCODE_NATIVE_TOOL_INSTRUCTION}\n\n${messageText}`;
this.instructionsSent = true;
}
@@ -289,6 +292,7 @@ class OpencodeRemoteLauncher extends RemoteLauncherBase {
await backend.prompt(acpSessionId, promptContent, (message: AgentMessage) => {
this.handleAgentMessage(message);
});
void backend.refreshSessionInfo(acpSessionId, session.path);
} catch (error) {
logger.warn('[opencode-remote] prompt failed', error);
session.sendSessionEvent({