fix(background): persist notification items for session resume

Background agent notifications were missing after session resume because
they were never recorded in the chat history. The model text was absent
from the API history and the display item was lost.

- Add recordNotification() to ChatRecordingService — stores as user-role
  message with subtype 'notification' and displayText payload
- Thread notificationDisplayText through submitQuery → sendMessageStream
- Restore as HistoryItemNotification in resumeHistoryUtils
This commit is contained in:
tanzhenxin 2026-04-10 08:58:11 +00:00
parent bcce78d044
commit 83f23fda5a
4 changed files with 57 additions and 4 deletions

View file

@ -1178,6 +1178,7 @@ export const useGeminiStream = (
query: PartListUnion,
submitType: SendMessageType = SendMessageType.UserQuery,
prompt_id?: string,
metadata?: { notificationDisplayText?: string },
) => {
const allowConcurrentBtwDuringResponse =
submitType === SendMessageType.UserQuery &&
@ -1314,7 +1315,10 @@ export const useGeminiStream = (
finalQueryToSend,
abortSignal,
prompt_id!,
{ type: submitType },
{
type: submitType,
notificationDisplayText: metadata?.notificationDisplayText,
},
);
const processingStatus = await processGeminiStreamEvents(
@ -1816,7 +1820,9 @@ export const useGeminiStream = (
{ type: 'notification' as const, text: item.displayText },
Date.now(),
);
submitQuery(item.modelText, SendMessageType.Notification);
submitQuery(item.modelText, SendMessageType.Notification, undefined, {
notificationDisplayText: item.displayText,
});
}
}, [streamingState, submitQuery, notificationTrigger, addItem]);