({
stateDir,
platformPlugin,
}: {
stateDir: string;
platformPlugin: {
start(): Promise<void>;
sendText(params: { externalScopeId: string; content: string }): Promise<{
success: boolean;
} | null | undefined>;
};
})
| 865 | } |
| 866 | |
| 867 | async function flushPendingRestartNotifications({ |
| 868 | stateDir, |
| 869 | platformPlugin, |
| 870 | }: { |
| 871 | stateDir: string; |
| 872 | platformPlugin: { |
| 873 | start(): Promise<void>; |
| 874 | sendText(params: { externalScopeId: string; content: string }): Promise<{ |
| 875 | success: boolean; |
| 876 | } | null | undefined>; |
| 877 | }; |
| 878 | }) { |
| 879 | const filePath = pendingRestartNotificationsFile(stateDir); |
| 880 | const queued = readPendingRestartNotifications(filePath); |
| 881 | if (queued.length === 0) { |
| 882 | return; |
| 883 | } |
| 884 | const remaining: PendingRestartNotification[] = []; |
| 885 | await platformPlugin.start(); |
| 886 | for (const item of queued) { |
| 887 | try { |
| 888 | const result = await platformPlugin.sendText({ |
| 889 | externalScopeId: item.externalScopeId, |
| 890 | content: item.content, |
| 891 | }); |
| 892 | if (!result?.success) { |
| 893 | remaining.push(item); |
| 894 | } |
| 895 | } catch { |
| 896 | remaining.push(item); |
| 897 | } |
| 898 | } |
| 899 | writePendingRestartNotifications(filePath, remaining); |
| 900 | } |
| 901 | |
| 902 | async function enqueuePendingRestartNotification({ |
| 903 | stateDir, |
no test coverage detected