Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces Server-Sent Events (SSE) to report progress for long-running admin operations (publishing events with SendGrid emailing, and generating/downloading results ZIPs), plus corresponding admin UI progress indicators.
Changes:
- Added shared frontend SSE client helper (
connectSseStream) and backend SSE emitter utility. - Updated admin “Publish” and “Download results” flows to stream progress and handle async completion via SSE.
- Changed results download to generate ZIP server-side, store it temporarily, and return a token for a follow-up file download request.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| libs/shared/src/lib/sse.ts | Adds fetch-based SSE client helper and shared SseEvent type. |
| libs/shared/src/index.ts | Re-exports SSE helper from shared package. |
| apps/backend/src/lib/sse.ts | Adds backend SSE emitter for consistent SSE responses. |
| apps/backend/src/lib/temp-download-store.ts | Adds in-memory token store for temporary ZIP downloads. |
| apps/backend/src/lib/results-download.ts | Adds progress callback support during ZIP generation. |
| apps/backend/src/routers/admin/events/settings/index.ts | Switches publish/download endpoints to SSE; adds token-based ZIP download endpoint. |
| apps/backend/src/routers/integrations/sendgrid/publish.ts | Adds progress callback support and additional SendGrid-key handling/logging. |
| apps/admin/.../publish-event-dialog.tsx | Adds progress UI (linear progress + message) for publish flow. |
| apps/admin/.../download-results-dialog.tsx | Adds linear progress UI for ZIP generation flow. |
| apps/admin/.../event-actions-section.tsx | Uses SSE client for publish/download actions and triggers file download via token URL. |
| apps/admin/locale/en.json / pl.json / he.json | Adds new localized strings for progress and success-with-emails messaging. |
Comments suppressed due to low confidence (1)
apps/backend/src/routers/admin/events/settings/index.ts:65
published: trueis persisted before SendGrid email sending, but the SendGrid error path sends an SSEfailure. This makes the client treat the publish as failed even though it may already be published. Consider moving the published update after emails succeed, rolling it back on email failure, or returningsuccesswith email failure details instead offailure.
const updatedSettings = await db.events.byId(req.eventId).updateSettings({ published: true });
if (!updatedSettings) {
throw new Error('Failed to publish event');
}
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds Server-Sent Events (SSE) to support progress reporting for long-running admin operations (publishing w/ SendGrid emails and generating/downloading results ZIPs), improving UX by streaming start/progress/success/failure states.
Changes:
- Introduce shared fetch-based SSE client helper and backend SSE emitter.
- Stream progress updates for SendGrid publish and results ZIP generation.
- Change results download flow to: POST (generate + get token via SSE) → GET (download by token).
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| libs/shared/src/lib/sse.ts | New SSE client helper using fetch + streaming reader. |
| libs/shared/src/index.ts | Re-export SSE helper from shared package. |
| apps/backend/src/lib/sse.ts | New SSE emitter for Express responses. |
| apps/backend/src/lib/temp-download-store.ts | In-memory TTL token store for generated ZIP files. |
| apps/backend/src/lib/results-download.ts | Add progress callback support during ZIP generation. |
| apps/backend/src/routers/admin/events/settings/index.ts | Convert publish/download endpoints to SSE; add token-based download route. |
| apps/backend/src/routers/integrations/sendgrid/publish.ts | Add progress callback during SendGrid email sending. |
| apps/admin/src/app/[locale]/(dashboard)/events/[slug]/settings/components/event-actions-section.tsx | Use SSE client for publish/download; start token-based download. |
| apps/admin/src/app/[locale]/(dashboard)/events/[slug]/settings/components/publish-event-dialog.tsx | Show publish progress UI (message + progress bar). |
| apps/admin/src/app/[locale]/(dashboard)/events/[slug]/settings/components/download-results-dialog.tsx | Show download generation progress UI (progress bar). |
| apps/admin/locale/en.json | New strings for progress/info + publish success w/ emails. |
| apps/admin/locale/he.json | New strings for progress/info + publish success w/ emails. |
| apps/admin/locale/pl.json | New strings for progress/info + publish success w/ emails. |
Comments suppressed due to low confidence (1)
apps/backend/src/routers/integrations/sendgrid/publish.ts:95
publishEventResultsreferencesapiKeybutapiKeyis no longer defined in this scope (it was moved insidesendEmailToContact). This will fail TypeScript compilation. Either reintroduceconst apiKey = process.env.SENDGRID_API_KEYinpublishEventResults(and pass it down), or remove this check and make the missing-key behavior consistent withsendEmailToContact.
if (!settings) {
throw new Error('Missing integration settings');
}
if (!apiKey) {
throw new Error('SendGrid API key not configured');
}
| await new Promise<void>((resolve, reject) => { | ||
| fileStream!.on('finish', resolve); | ||
| fileStream!.on('error', reject); | ||
| archive!.on('error', reject); | ||
| archive!.pipe(fileStream!); | ||
| archive!.finalize(); | ||
| }); | ||
|
|
||
| archive.pipe(res); | ||
| await archive.finalize(); | ||
| const token = storeTempFile(tempPath, fileName); | ||
| emitter.sendSuccess({ token }); |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Description
Added SSE for async api operations in the admin app
Type of change
Please delete options that are not relevant.
Checklist