fix(vscode): wire native notifications from runtime events
This commit is contained in:
@@ -79,6 +79,16 @@ type ApiProxyResponsePayload = {
|
||||
bodyBase64: string;
|
||||
};
|
||||
|
||||
type NotificationBridgePayload = {
|
||||
title?: string;
|
||||
body?: string;
|
||||
tag?: string;
|
||||
};
|
||||
|
||||
type NotificationsNotifyRequestPayload = {
|
||||
payload?: NotificationBridgePayload;
|
||||
};
|
||||
|
||||
interface FileEntry {
|
||||
name: string;
|
||||
path: string;
|
||||
@@ -2792,6 +2802,28 @@ export async function handleBridgeMessage(message: BridgeRequest, ctx?: BridgeCo
|
||||
}
|
||||
}
|
||||
|
||||
case 'notifications:can-notify': {
|
||||
return { id, type, success: true, data: true };
|
||||
}
|
||||
|
||||
case 'notifications:notify': {
|
||||
const request = (payload || {}) as NotificationsNotifyRequestPayload;
|
||||
const notification = request.payload || {};
|
||||
const title = typeof notification.title === 'string' ? notification.title.trim() : '';
|
||||
const body = typeof notification.body === 'string' ? notification.body.trim() : '';
|
||||
|
||||
const message = title && body
|
||||
? `${title}: ${body}`
|
||||
: title || body;
|
||||
|
||||
if (!message) {
|
||||
return { id, type, success: true, data: { shown: false } };
|
||||
}
|
||||
|
||||
void vscode.window.showInformationMessage(message);
|
||||
return { id, type, success: true, data: { shown: true } };
|
||||
}
|
||||
|
||||
// ============== Git Operations ==============
|
||||
|
||||
case 'api:git/check': {
|
||||
|
||||
Reference in New Issue
Block a user