refactor(core): move background injection wiring from UI to backend

Wire ExecutionLifecycleService.setInjectionService() in Config constructor
so backgrounded executions inject directly via settleExecution instead of
routing through a useEffect bridge in AppContainer.
This commit is contained in:
Adam Weidman
2026-03-15 15:11:13 -04:00
parent 931b80206b
commit 8b7321ea8d
3 changed files with 23 additions and 24 deletions
-24
View File
@@ -85,8 +85,6 @@ import {
buildUserSteeringHintPrompt,
logBillingEvent,
ApiKeyUpdatedEvent,
ExecutionLifecycleService,
type BackgroundCompletionInfo,
type InjectionSource,
} from '@google/gemini-cli-core';
import { validateAuthMethod } from '../config/auth.js';
@@ -1119,28 +1117,6 @@ Logging in with Google... Restarting Gemini CLI to continue.
};
}, [config]);
// Wire background completion events from ExecutionLifecycleService into the
// injection service so completed backgrounded executions are reinjected.
useEffect(() => {
const bgListener = (info: BackgroundCompletionInfo) => {
// Use the execution creator's custom injection text if provided.
let text = info.injectionText;
if (text === null || text === undefined) {
// Fallback: generic format for executions without a custom formatter.
const header = info.error
? `[Background execution (ID: ${info.executionId}) completed with error: ${info.error.message}]`
: `[Background execution (ID: ${info.executionId}) completed]`;
const body = info.output ? `\n${info.output}` : '';
text = `${header}${body}`;
}
config.injectionService.addInjection(text, 'background_completion');
};
ExecutionLifecycleService.onBackgroundComplete(bgListener);
return () => {
ExecutionLifecycleService.offBackgroundComplete(bgListener);
};
}, [config]);
const {
streamingState,
submitQuery,