Support context injection via SessionStart hook. (#15746)

This commit is contained in:
Christian Gunderman
2026-01-05 13:27:53 -08:00
committed by GitHub
parent 2da911e4a0
commit 6d1e27633a
7 changed files with 261 additions and 19 deletions
+31 -1
View File
@@ -300,7 +300,31 @@ export const AppContainer = (props: AppContainerProps) => {
const sessionStartSource = resumedSessionData
? SessionStartSource.Resume
: SessionStartSource.Startup;
await fireSessionStartHook(hookMessageBus, sessionStartSource);
const result = await fireSessionStartHook(
hookMessageBus,
sessionStartSource,
);
if (result) {
if (result.systemMessage) {
historyManager.addItem(
{
type: MessageType.INFO,
text: result.systemMessage,
},
Date.now(),
);
}
const additionalContext = result.getAdditionalContext();
const geminiClient = config.getGeminiClient();
if (additionalContext && geminiClient) {
await geminiClient.addHistory({
role: 'user',
parts: [{ text: additionalContext }],
});
}
}
}
// Fire-and-forget: generate summary for previous session in background
@@ -321,6 +345,12 @@ export const AppContainer = (props: AppContainerProps) => {
await fireSessionEndHook(hookMessageBus, SessionEndReason.Exit);
}
});
// Disable the dependencies check here. historyManager gets flagged
// but we don't want to react to changes to it because each new history
// item, including the ones from the start session hook will cause a
// re-render and an error when we try to reload config.
//
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [config, resumedSessionData]);
useEffect(