Feat/poll template content
Summary
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
[!Tip] Close issue syntax:
Fixes #<issue number>orResolves #<issue number>, see documentation for more details.
Impact Areas
Please check the areas this PR affects:
- [ ] Multi-threaded Dialogues
- [ ] AI-Powered Capabilities (Web Search, Knowledge Base Search, Question Recommendations)
- [ ] Context Memory & References
- [ ] Knowledge Base Integration & RAG
- [ ] Quotes & Citations
- [ ] AI Document Editing & WYSIWYG
- [ ] Free-form Canvas Interface
- [ ] Other
Screenshots/Videos
| Before | After |
|---|---|
| ... | ... |
Checklist
[!IMPORTANT]
Please review the checklist below before submitting your pull request.
- [ ] This change requires a documentation update, included: Refly Documentation
- [x] I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
- [x] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
- [x] I've updated the documentation accordingly.
- [x] I ran
dev/reformat(backend) andcd web && npx lint-staged(frontend) to appease the lint gods
Summary by CodeRabbit
Release Notes
- New Features
- Added template generation status tracking with real-time monitoring (idle, pending, generating, completed, failed states)
- New endpoint to query template generation progress and retrieve generated template content
- Introduced visual loading indicators and status messages during template generation
- Added real-time status updates with automatic polling capabilities
βοΈ Tip: You can customize this high-level summary in your review settings.
Walkthrough
Adds template-generation status tracking end-to-end: new WorkflowApp DB fields, a GET API to read status, backend status-update logic during generation, client polling hook + UI integration, type/schema updates, and translations.
Changes
| Cohort / File(s) | Summary |
|---|---|
Database Schema apps/api/prisma/schema.prisma |
Added templateGenerationStatus (default "idle") and templateGenerationError fields on WorkflowApp; added index on templateShareId. |
API Controller & Service apps/api/src/modules/workflow-app/workflow-app.controller.ts, apps/api/src/modules/workflow-app/workflow-app.service.ts |
New GET /v1/workflow-app/template-status endpoint (JwtAuthGuard) and getTemplateGenerationStatus(user, appId) service method; service writes/normalizes status (idle/pending/generating/completed/failed) and returns status, content, error, timestamps. |
Processor / Generation Flow apps/api/src/modules/workflow-app/workflow-app.processor.ts |
Added private updateGenerationStatus(appId, status, error?), set 'generating' early, update status/error on validation, success, and catch paths; added guarded appId checks and richer logging. |
Share / Public Selects apps/api/src/modules/share/share-creation.service.ts |
Extended Prisma select for WorkflowApp to include templateGenerationStatus and templateGenerationError. |
API Types & Clients packages/request/src/requests/types.gen.ts, packages/openapi-schema/src/types.gen.ts, packages/ai-workspace-common/src/requests/types.gen.ts |
Added TemplateGenerationStatus union and GetTemplateGenerationStatus{Data,Response,Error} types across generated type files (some duplicated in diffs). |
OpenAPI / Schema packages/openapi-schema/schema.yml, packages/openapi-schema/src/schemas.gen.ts, packages/openapi-schema/src/services.gen.ts |
Added GET /workflow-app/template-status operation and schemas: TemplateGenerationStatus enum and GetTemplateGenerationStatusResponse. |
API Client Functions packages/request/src/requests/services.gen.ts, packages/ai-workspace-common/src/requests/services.gen.ts |
Added getTemplateGenerationStatus client function calling /workflow-app/template-status. |
Query / React-Query Utilities packages/request/src/queries/*, packages/ai-workspace-common/src/queries/* (common, ensureQueryData, prefetch, queries, suspense, prefetch.ts) |
Added query keys, types, ensure/prefetch helpers, hooks useGetTemplateGenerationStatus and suspense variant, and related typings. |
Frontend Hook packages/web-core/src/hooks/useTemplateGenerationStatus.ts |
New polling hook that fetches status with configurable interval/maxAttempts/enabled; exposes status, templateContent, polling state, attempts, isInitialized, and stopPolling. |
Workflow App Form UI packages/web-core/src/pages/workflow-app/workflow-app-form.tsx |
Integrated polling hook; introduced effectiveTemplateContent, skeleton/editor/form rendering branches, toast notifications on status transitions, and run/init flows using polled content when available. |
Skeleton Component packages/web-core/src/pages/workflow-app/template-editor-skeleton.tsx |
Added TemplateEditorSkeleton memoized component for loading state. |
Frontend Types packages/web-core/src/utils/templateStatus.ts |
Added TemplateGenerationStatus type and TemplateStatusResponse interface for frontend usage. |
Translations packages/i18n/src/en-US/ui.ts, packages/i18n/src/zh-Hans/ui.ts |
Added template.updating translation entries (en-US and zh-Hans). |
Sequence Diagram(s)
sequenceDiagram
autonumber
participant UI as Web UI (workflow-app-form)
participant Hook as useTemplateGenerationStatus
participant API as API Server (/workflow-app/template-status)
participant DB as Database (WorkflowApp)
UI->>Hook: start polling (appId)
Hook->>API: GET /workflow-app/template-status?appId=...
API->>DB: SELECT templateGenerationStatus, templateContent, templateGenerationError, timestamps
DB-->>API: row {status, templateContent, error, updatedAt, createdAt}
API-->>Hook: 200 {status, templateContent, error, updatedAt, createdAt}
Hook-->>UI: update state (status, content)
alt status == generating
UI->>UI: show skeleton / toast
else status in [completed, idle, failed]
UI->>UI: show editor or form with effectiveTemplateContent
end
Estimated code review effort
π― 3 (Moderate) | β±οΈ ~25 minutes
- Files needing extra attention:
apps/api/src/modules/workflow-app/workflow-app.service.tsβ status decision logic, initialization and normalization (idle/pending/generating/completed/failed) and templateContent reset pathsapps/api/src/modules/workflow-app/workflow-app.processor.tsβ multiple status-update calls, guarded appId usage, and error handling pathspackages/web-core/src/hooks/useTemplateGenerationStatus.tsβ polling termination, cleanup on unmount, and enabled=false one-shot behaviorpackages/web-core/src/pages/workflow-app/workflow-app-form.tsxβ large UI changes: correct priority between polled content and local form state, toast logic, and run/init handling- Generated type files across packages β verify there are no unintended duplicate/contradictory type declarations
Possibly related PRs
- refly-ai/refly#1465 β modifies workflow-app service/template-content handling; likely intersects with status/state decisions and persistence.
- refly-ai/refly#1716 β touches workflow-app processor/service and share creation paths; may overlap status-update and select changes.
- refly-ai/refly#1558 β modifies workflow-app form UI and run logic; may conflict with the new polling/integration in the form.
Poem
π°
I hop and poll through day and night,
Watching templates find their light,
From idle naps to generating cheer,
A completed draft appears β oh dear! β
Hooray, the app now shows it clear. π₯β¨
Pre-merge checks and finishing touches
β Passed checks (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | β Passed | Check skipped - CodeRabbitβs high-level summary is enabled. |
| Title check | β Passed | The title 'feat: add workflow template generation status tracking' clearly and specifically summarizes the main change: adding status tracking capability for template generation in workflows. |
| Docstring Coverage | β Passed | Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. |
β¨ Finishing touches
- [ ] π Generate docstrings
π§ͺ Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
- [ ] Commit unit tests in branch
feat/poll-template-content
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.