mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
feat: add push notifications with VAPID (#110)
* Add OAuth authentication support for MCP servers * Improve mobile text sizing with responsive text classes * refactor: improve virtualized text viewer with React Query infinite scroll and simplified buffering * Add push notifications with VAPID and PWA support * feat: add VAPID environment variables for push notifications * Replace SquareFill with MicOff icon for stop recording buttons * Send push notifications when app is not focused * Fix stop generation button icons to use X instead of MicOff * feat: enhance push notification logging and debugging - Add structured logging throughout push notification flow - Improve error handling with detailed diagnostics - Add /api/notifications/debug endpoint for troubleshooting - Enhanced test notification response with per-subscription results - Add service worker logging and better install/activate handling * Improve VAPID push notification configuration with validation and better defaults - Add validation warnings for VAPID_SUBJECT format (requires mailto: prefix for iOS/Safari) - Expose VAPID details via notifications API endpoint - Update default VAPID_SUBJECT from mailto:admin@opencode.local to empty string - Enhance VAPID logging with key lengths and subject info - Improve documentation in .env.example with setup instructions * Fix notification URL to use repo ID instead of filesystem path * Clean up push notification logging and debug endpoints * Add push notifications documentation
This commit is contained in:
1 parent
3d9e9b8322
commit
ae644e851d
47 files changed
+4506
-67
No files matched your search
@@ -0,0 +1,64 @@
|
||||
import type { PushSubscriptionRecord } from "@opencode-manager/shared/types";
|
||||
import { API_BASE_URL } from "@/config";
|
||||
import { fetchWrapper } from "./fetchWrapper";
|
||||
|
||||
export const notificationsApi = {
|
||||
getVapidPublicKey: async (): Promise<{ publicKey: string }> => {
|
||||
return fetchWrapper(`${API_BASE_URL}/api/notifications/vapid-public-key`);
|
||||
},
|
||||
|
||||
subscribe: async (
|
||||
subscription: PushSubscriptionJSON,
|
||||
deviceName?: string,
|
||||
userId = 'default'
|
||||
): Promise<{ subscription: PushSubscriptionRecord }> => {
|
||||
return fetchWrapper(`${API_BASE_URL}/api/notifications/subscribe`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
endpoint: subscription.endpoint,
|
||||
keys: subscription.keys,
|
||||
deviceName,
|
||||
}),
|
||||
params: { userId },
|
||||
});
|
||||
},
|
||||
|
||||
unsubscribe: async (endpoint: string, userId = 'default'): Promise<{ success: boolean }> => {
|
||||
return fetchWrapper(`${API_BASE_URL}/api/notifications/subscribe`, {
|
||||
method: "DELETE",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ endpoint }),
|
||||
params: { userId },
|
||||
});
|
||||
},
|
||||
|
||||
getSubscriptions: async (userId = 'default'): Promise<{
|
||||
subscriptions: PushSubscriptionRecord[];
|
||||
}> => {
|
||||
return fetchWrapper(`${API_BASE_URL}/api/notifications/subscriptions`, {
|
||||
params: { userId },
|
||||
});
|
||||
},
|
||||
|
||||
removeSubscription: async (
|
||||
id: number,
|
||||
userId = 'default'
|
||||
): Promise<{ success: boolean }> => {
|
||||
return fetchWrapper(
|
||||
`${API_BASE_URL}/api/notifications/subscriptions/${id}`,
|
||||
{ method: "DELETE", params: { userId } }
|
||||
);
|
||||
},
|
||||
|
||||
sendTest: async (userId = 'default'): Promise<{
|
||||
success: boolean;
|
||||
devicesNotified: number;
|
||||
}> => {
|
||||
return fetchWrapper(`${API_BASE_URL}/api/notifications/test`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
params: { userId },
|
||||
});
|
||||
},
|
||||
};
|
||||
@@ -8,8 +8,9 @@ import {
|
||||
type STTConfig,
|
||||
type OpenCodeConfigContent,
|
||||
} from '@opencode-manager/shared'
|
||||
import type { NotificationPreferences } from '@opencode-manager/shared/types'
|
||||
|
||||
export type { TTSConfig, STTConfig, OpenCodeConfigContent }
|
||||
export type { TTSConfig, STTConfig, OpenCodeConfigContent, NotificationPreferences }
|
||||
export { DEFAULT_TTS_CONFIG, DEFAULT_STT_CONFIG, DEFAULT_KEYBOARD_SHORTCUTS, DEFAULT_USER_PREFERENCES, DEFAULT_LEADER_KEY }
|
||||
|
||||
export interface CustomCommand {
|
||||
@@ -54,6 +55,7 @@ export interface UserPreferences {
|
||||
gitIdentity?: GitIdentity
|
||||
tts?: TTSConfig
|
||||
stt?: STTConfig
|
||||
notifications?: NotificationPreferences
|
||||
repoOrder?: number[]
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user