Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions packages/cli/src/acp-integration/session/Session.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33357,12 +33357,37 @@ describe('Session', () => {
});

// The generator received an AbortSignal so the daemon can cancel
// mid-flight if the next prompt arrives first.
// mid-flight if the next prompt arrives first. `merged.ui` above leaves
// `enableCacheSharing` UNSET, so the gate must honour the schema's
// declared `default: true` — `mergeSettings` never applies schema
// defaults, and gating on `=== true` turned the cache-aware fork into
// dead code unless the user explicitly set the flag (#9230).
expect(generateMock).toHaveBeenCalledWith(
mockConfig,
expect.any(Array),
expect.any(AbortSignal),
expect.objectContaining({ enableCacheSharing: expect.any(Boolean) }),
expect.objectContaining({ enableCacheSharing: true }),
Comment thread
yiliang114 marked this conversation as resolved.
Resolved
);
});

it('forwards an explicit enableCacheSharing=false opt-out', async () => {
(mockSettings as unknown as { merged: { ui: unknown } }).merged.ui = {
enableFollowupSuggestions: true,
enableCacheSharing: false,
};
generateMock.mockResolvedValue({ suggestion: null });

await session.prompt({
sessionId: 'test-session-id',
prompt: [{ type: 'text', text: 'hello' }],
});

await vi.waitFor(() => expect(generateMock).toHaveBeenCalled());
expect(generateMock).toHaveBeenCalledWith(
mockConfig,
expect.any(Array),
expect.any(AbortSignal),
expect.objectContaining({ enableCacheSharing: false }),
);
});

Expand Down
13 changes: 8 additions & 5 deletions packages/cli/src/acp-integration/session/Session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3929,24 +3929,27 @@ export class Session implements SessionContext {

void (async () => {
try {
const fullHistory = chat.getHistory(true);
const lastEntry = fullHistory[fullHistory.length - 1];
const conversationHistory = chat.getHistoryTail(40, true);
Comment thread
yiliang114 marked this conversation as resolved.
Resolved
const lastEntry = conversationHistory[conversationHistory.length - 1];
Comment thread
yiliang114 marked this conversation as resolved.
Resolved
if (!lastEntry || lastEntry.role !== 'model') {
debugLogger.debug(
'Skipping followup suggestion: last history entry is not model',
);
return;
}
const conversationHistory =
fullHistory.length > 40 ? fullHistory.slice(-40) : fullHistory;

const r = await generatePromptSuggestion(
this.config,
conversationHistory,
ac.signal,
{
// On by default: the schema declares `default: true`, but
// `mergeSettings` doesn't apply schema defaults, so an unset value
// is `undefined` and a `=== true` gate left the cache-aware fork
// as dead code unless the flag was explicitly set (#9230). Mirrors
// AppContainer — only an explicit `false` opts out.
enableCacheSharing:
this.settings.merged.ui?.enableCacheSharing === true,
this.settings.merged.ui?.enableCacheSharing !== false,
Comment thread
yiliang114 marked this conversation as resolved.
Resolved
},
);
if (ac.signal.aborted) return;
Expand Down
8 changes: 7 additions & 1 deletion packages/cli/src/ui/AppContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3153,7 +3153,13 @@ export const AppContainer = (props: AppContainerProps) => {
// causes transient heap peaks that trigger OOM (#4624).
const conversationHistory = geminiClient.getHistoryTail(40, true);
generatePromptSuggestion(config, conversationHistory, ac.signal, {
enableCacheSharing: settings.merged.ui?.enableCacheSharing === true,
// On by default: the schema declares `default: true`, but
// `mergeSettings` doesn't apply schema defaults, so an unset value is
// `undefined` and a `=== true` gate left the cache-aware fork as dead
// code unless the flag was explicitly set (#9230). Same treatment as
// `enableFollowupSuggestions` above — only an explicit `false` opts
// out.
enableCacheSharing: settings.merged.ui?.enableCacheSharing !== false,
Comment thread
yiliang114 marked this conversation as resolved.
Resolved
Comment thread
yiliang114 marked this conversation as resolved.
Resolved
Comment thread
yiliang114 marked this conversation as resolved.
Resolved
})
.then((result) => {
if (ac.signal.aborted) return;
Expand Down
12 changes: 5 additions & 7 deletions packages/core/src/followup/suggestionGenerator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,13 @@ describe('generatePromptSuggestion', () => {
getModel: vi.fn(() => 'main-model'),
} as unknown as Config;

await generatePromptSuggestion(
config,
conversationHistory,
new AbortController().signal,
{ enableCacheSharing: true },
);
const signal = new AbortController().signal;
await generatePromptSuggestion(config, conversationHistory, signal, {
enableCacheSharing: true,
});

expect(mockRunForkedAgent).toHaveBeenCalledWith(
expect.objectContaining({ model: 'main-model' }),
expect.objectContaining({ model: 'main-model', abortSignal: signal }),
);
});

Expand Down
1 change: 1 addition & 0 deletions packages/core/src/followup/suggestionGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ async function generateViaForkedQuery(
jsonSchema: SUGGESTION_SCHEMA,
model,
preserveTools: model === cacheSafeParams.model,
abortSignal,
});

if (result.jsonResult) {
Expand Down
Loading