Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(pi): 跨引擎提交时同步本机 renderer 的思考记忆

Zhang Yunjin8bb0d51b996b
diff --git a/apps/desktop/src/main/__tests__/sessionRuntimeControlWiring.test.ts b/apps/desktop/src/main/__tests__/sessionRuntimeControlWiring.test.ts
index e6d3bf4b83..ca4e6455d2 100644
--- a/apps/desktop/src/main/__tests__/sessionRuntimeControlWiring.test.ts
+++ b/apps/desktop/src/main/__tests__/sessionRuntimeControlWiring.test.ts
@@ -792,6 +792,16 @@ describe('session runtime control wiring', () => {
expect(registerSource).toContain(
"runtimeAgentKind === 'pi' && atomicSelection?.thinking !== undefined",
);
+ // 提交写入镜像后同步本机 renderer 记忆:renderer 的全量快照才会带上该选择,
+ // 镜像里的钉子得以撤销(否则会长期压住被控端后来的显式改动)。
+ const rememberThinking = registerSource.slice(
+ registerSource.indexOf('rememberThinkingIntent: ({'),
+ registerSource.indexOf('bootstrapSwitchedSession: async (sessionId, opts)'),
+ );
+ expect(rememberThinking).toContain(
+ 'setThinkingEnabledInMemory(agentKind, providerId, model, thinking)',
+ );
+ expect(rememberThinking).toContain('DRAFT_PREF_APPLY');
});
it('only relinks retained cross-host writers without rewriting native history', () => {
diff --git a/apps/desktop/src/main/maker-ipc/register.ts b/apps/desktop/src/main/maker-ipc/register.ts
index 57c5289ab7..c64683204e 100644
--- a/apps/desktop/src/main/maker-ipc/register.ts
+++ b/apps/desktop/src/main/maker-ipc/register.ts
@@ -8589,6 +8589,16 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
readPendingHandoffGeneration: (sessionId) => agentHandoffPending.readGeneration(sessionId),
rememberThinkingIntent: ({ agentKind, providerId, model, thinking }) => {
setThinkingEnabledInMemory(agentKind, providerId, model, thinking);
+ // 同步本机 renderer 的记忆:主进程写的只是镜像,renderer 才是 providerModelMemory
+ // 的真相源。不写回这一笔,renderer 的全量快照会一直「尚未包含该选择」,提交时写入
+ // 的钉子也就撤不掉,反而会长期压住用户在被控端后来的显式改动(Greptile P1)。
+ broadcastToAllWindows(MAKER_PUSH.DRAFT_PREF_APPLY, {
+ agent: agentKind,
+ providerId: providerId ?? '',
+ modelId: model,
+ active: false,
+ thinking,
+ });
},
bootstrapSwitchedSession: async (sessionId, opts) => {
// 切换已提交,从 DB 行(新引擎值)重建 live session。resumeSessionId 直接取