-
Notifications
You must be signed in to change notification settings - Fork 437
fix: template content generation #1716
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughBackend now sources workflow variables from CanvasService, adds fingerprinting and template validation to decide generation, and synchronizes updated templateContent/variables to shared object storage; frontend stops extracting variables from templateContent and uses the full canvas variable set for template editing. Changes
Sequence Diagram(s)sequenceDiagram
participant Frontend as Web UI
participant API as WorkflowAppService / Processor
participant Canvas as CanvasService
participant DB as Database
participant OSS as ObjectStorageService
participant Share as ShareCreationService
Frontend->>API: createWorkflowApp / update request
API->>Canvas: getWorkflowVariables(canvasId, user)
Canvas-->>API: workflow variables (JSON)
API->>API: build fingerprints (variables, skill responses)
API->>DB: load stored workflow app (previous record)
DB-->>API: stored app + templateContent (maybe)
API->>API: validateTemplateContentMatchesVariables(templateContent, variables)
alt template invalid or changed
API->>DB: enqueue template generation / persist updated app (omit invalid templateContent)
else template valid and unchanged
API->>DB: persist without regeneration (keep templateContent)
end
API->>Share: find shares for appId
loop per share
Share->>OSS: download shared JSON
OSS-->>Share: shared JSON
Share->>Share: validate structure & update templateContent, variables
Share->>OSS: write updated JSON
OSS-->>Share: write OK
end
Frontend->>API: request templateVariables
API->>Canvas: getWorkflowVariables(canvasId)
Canvas-->>API: variables
API-->>Frontend: return full workflow variables
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (5)
apps/api/src/modules/share/share-creation.service.ts (1)
1289-1293: Approve fetching variables from CanvasService.This aligns with the PR's goal of centralizing variable retrieval. However, the
?? '[]'fallback is unnecessary sinceJSON.stringify([])already returns'[]'when the array is empty, andJSON.stringify(undefined)returnsundefined(not null). IfgetWorkflowVariablescan returnundefined, the nullish coalescing should be applied before stringify:- workflowApp.variables = JSON.stringify(variables) ?? '[]'; + workflowApp.variables = JSON.stringify(variables ?? []);apps/api/src/modules/workflow-app/workflow-app.processor.ts (2)
133-146: Add null check before parsing downloaded buffer.If
downloadFilereturnsnullorundefined(e.g., file doesn't exist), callingtoString()will throw. While this is caught by the outer try-catch, a clearer early return would improve clarity:// Download the existing JSON file from object storage const existingBuffer = await this.miscService.downloadFile({ storageKey: shareRecord.storageKey, visibility: 'public', }); + if (!existingBuffer) { + this.logger.log( + `[${QUEUE_WORKFLOW_APP_TEMPLATE}] No existing storage file found for appId=${appId}, skip update`, + ); + return; + } + const existingData = JSON.parse(existingBuffer.toString('utf-8'));
107-112: Consider adding type annotation foruserparameter.The
userparameter is typed asany, but since it's used withmiscService.uploadBuffer, it should match the expectedUsertype for consistency and type safety:private async updateSharedAppStorage( - user: any, + user: { uid: string }, appId: string, templateContent: string | null | undefined, variables: any, ): Promise<void> {apps/api/src/modules/workflow-app/workflow-app.service.ts (2)
167-170: Consider cleaner type handling forincludescheck.The
as nevertype assertion is a workaround but is unusual. A cleaner approach:// Check if every variable has a corresponding placeholder return safeVars.every((v) => { const varName = v?.name ?? ''; - return placeholders.includes(`{{${varName}}}` as never); + const expectedPlaceholder = `{{${varName}}}`; + return placeholders.some((p) => p === expectedPlaceholder); });Alternatively, convert
placeholdersto a Set for O(1) lookups if performance matters.
344-344: Simplify conditional spread pattern.The double spread is redundant:
- ...{ ...(isTemplateContentValid ? {} : { templateContent: null }) }, + ...(isTemplateContentValid ? {} : { templateContent: null }),This achieves the same result with cleaner syntax.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
apps/api/src/modules/share/share-creation.service.ts(1 hunks)apps/api/src/modules/variable-extraction/app-publish-prompt.ts(8 hunks)apps/api/src/modules/workflow-app/workflow-app.processor.ts(4 hunks)apps/api/src/modules/workflow-app/workflow-app.service.ts(4 hunks)packages/web-core/src/pages/workflow-app/workflow-app-form.tsx(1 hunks)
🧰 Additional context used
📓 Path-based instructions (20)
**/*.{jsx,tsx}
📄 CodeRabbit inference engine (.cursorrules)
**/*.{jsx,tsx}: Always use tailwind css to style the component
Always wrap pure components with React.memo to prevent unnecessary re-renders
Always use useMemo for expensive computations or complex object creation
Always use useCallback for function props to maintain referential equality
Always specify proper dependency arrays in useEffect to prevent infinite loops
Always avoid inline object/array creation in render to prevent unnecessary re-renders
Always use proper key props when rendering lists
Always split nested components with closures into separate components to avoid performance issues and improve code maintainability
**/*.{jsx,tsx}: Always wrap pure components with React.memo to prevent unnecessary re-renders
Always use useMemo for expensive computations or complex object creation in React
Always use useCallback for function props to maintain referential equality in React
Always specify proper dependency arrays in useEffect to prevent infinite loops in React
Always avoid inline object/array creation in render to prevent unnecessary re-renders in React
Always use proper key props when rendering lists in React (avoid using index when possible)
Always split nested components with closures into separate components in React
Use lazy loading for components that are not immediately needed in React
Debounce handlers for events that might fire rapidly (resize, scroll, input) in React
Implement fallback UI for components that might fail in React
Use error boundaries to catch and handle runtime errors in React
**/*.{jsx,tsx}: Place each attribute on a new line when a component has multiple attributes in JSX
Use self-closing tags for elements without children in JSX
Keep JSX expressions simple, extract complex logic to variables
Put closing brackets for multi-line JSX on a new line
**/*.{jsx,tsx}: Component file names should match the component name
Organize function components in order: imports, type definitions, constants, component function, hook calls, e...
Files:
packages/web-core/src/pages/workflow-app/workflow-app-form.tsx
**/*.{js,ts,jsx,tsx}
📄 CodeRabbit inference engine (.cursorrules)
**/*.{js,ts,jsx,tsx}: Always use optional chaining (?.) when accessing object properties
Always use nullish coalescing (??) or default values for potentially undefined values
Always check array existence before using array methods
Always validate object properties before destructuring
Always use single quotes for string literals in JavaScript/TypeScript code
**/*.{js,ts,jsx,tsx}: Use semicolons at the end of statements
Include spaces around operators (e.g.,a + binstead ofa+b)
Always use curly braces for control statements
Place opening braces on the same line as their statement
**/*.{js,ts,jsx,tsx}: Group import statements in order: React/framework libraries, third-party libraries, internal modules, relative path imports, type imports, style imports
Sort imports alphabetically within each import group
Leave a blank line between import groups
Extract complex logic into custom hooks
Use functional updates for state (e.g.,setCount(prev => prev + 1))
Split complex state into multiple state variables rather than single large objects
Use useReducer for complex state logic instead of multiple useState calls
Files:
packages/web-core/src/pages/workflow-app/workflow-app-form.tsxapps/api/src/modules/share/share-creation.service.tsapps/api/src/modules/workflow-app/workflow-app.processor.tsapps/api/src/modules/workflow-app/workflow-app.service.tsapps/api/src/modules/variable-extraction/app-publish-prompt.ts
**/*.{js,ts,tsx,jsx,py,java,cpp,c,cs,rb,go,rs,php,swift,kt,scala,r,m,mm,sql}
📄 CodeRabbit inference engine (.cursor/rules/00-language-priority.mdc)
**/*.{js,ts,tsx,jsx,py,java,cpp,c,cs,rb,go,rs,php,swift,kt,scala,r,m,mm,sql}: All code comments MUST be written in English
All variable names, function names, class names, and other identifiers MUST use English words
Comments should be concise and explain 'why' rather than 'what'
Use proper grammar and punctuation in comments
Keep comments up-to-date when code changes
Document complex logic, edge cases, and important implementation details
Use clear, descriptive names that indicate purpose
Avoid abbreviations unless they are universally understood
Files:
packages/web-core/src/pages/workflow-app/workflow-app-form.tsxapps/api/src/modules/share/share-creation.service.tsapps/api/src/modules/workflow-app/workflow-app.processor.tsapps/api/src/modules/workflow-app/workflow-app.service.tsapps/api/src/modules/variable-extraction/app-publish-prompt.ts
**/*.{js,ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/00-language-priority.mdc)
Use JSDoc style comments for functions and classes in JavaScript/TypeScript
Files:
packages/web-core/src/pages/workflow-app/workflow-app-form.tsxapps/api/src/modules/share/share-creation.service.tsapps/api/src/modules/workflow-app/workflow-app.processor.tsapps/api/src/modules/workflow-app/workflow-app.service.tsapps/api/src/modules/variable-extraction/app-publish-prompt.ts
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/01-code-style.mdc)
**/*.{js,jsx,ts,tsx}: Use single quotes for string literals in TypeScript/JavaScript
Always use optional chaining (?.) when accessing object properties in TypeScript/JavaScript
Always use nullish coalescing (??) or default values for potentially undefined values in TypeScript/JavaScript
Always check array existence before using array methods in TypeScript/JavaScript
Validate object properties before destructuring in TypeScript/JavaScript
Use ES6+ features like arrow functions, destructuring, and spread operators in TypeScript/JavaScript
Avoid magic numbers and strings - use named constants in TypeScript/JavaScript
Use async/await instead of raw promises for asynchronous code in TypeScript/JavaScript
Files:
packages/web-core/src/pages/workflow-app/workflow-app-form.tsxapps/api/src/modules/share/share-creation.service.tsapps/api/src/modules/workflow-app/workflow-app.processor.tsapps/api/src/modules/workflow-app/workflow-app.service.tsapps/api/src/modules/variable-extraction/app-publish-prompt.ts
**/*.{jsx,tsx,css}
📄 CodeRabbit inference engine (.cursor/rules/01-code-style.mdc)
**/*.{jsx,tsx,css}: Use Tailwind CSS for styling components
Follow the utility-first approach with Tailwind CSS
Group related utility classes together in Tailwind CSS
Prefer Tailwind utilities over custom CSS when possible
Files:
packages/web-core/src/pages/workflow-app/workflow-app-form.tsx
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/03-typescript-guidelines.mdc)
**/*.{ts,tsx}: Avoid usinganytype whenever possible - useunknowntype instead with proper type guards
Always define explicit return types for functions, especially for public APIs
Prefer extending existing types over creating entirely new types
Use TypeScript utility types (Partial<T>,Pick<T, K>,Omit<T, K>,Readonly<T>,Record<K, T>) to derive new types
Use union types and intersection types to combine existing types
Always import types explicitly using theimport typesyntax
Group type imports separately from value imports
Minimize creating local type aliases for imported types
Files:
packages/web-core/src/pages/workflow-app/workflow-app-form.tsxapps/api/src/modules/share/share-creation.service.tsapps/api/src/modules/workflow-app/workflow-app.processor.tsapps/api/src/modules/workflow-app/workflow-app.service.tsapps/api/src/modules/variable-extraction/app-publish-prompt.ts
**/*.{js,ts,jsx,tsx,css,json}
📄 CodeRabbit inference engine (.cursor/rules/04-code-formatting.mdc)
Maximum line length of 100 characters
Files:
packages/web-core/src/pages/workflow-app/workflow-app-form.tsxapps/api/src/modules/share/share-creation.service.tsapps/api/src/modules/workflow-app/workflow-app.processor.tsapps/api/src/modules/workflow-app/workflow-app.service.tsapps/api/src/modules/variable-extraction/app-publish-prompt.ts
**/*.{js,ts,jsx,tsx,css,json,yml,yaml}
📄 CodeRabbit inference engine (.cursor/rules/04-code-formatting.mdc)
Use 2 spaces for indentation, no tabs
Files:
packages/web-core/src/pages/workflow-app/workflow-app-form.tsxapps/api/src/modules/share/share-creation.service.tsapps/api/src/modules/workflow-app/workflow-app.processor.tsapps/api/src/modules/workflow-app/workflow-app.service.tsapps/api/src/modules/variable-extraction/app-publish-prompt.ts
**/*.{js,ts,jsx,tsx,css,json,yml,yaml,md}
📄 CodeRabbit inference engine (.cursor/rules/04-code-formatting.mdc)
No trailing whitespace at the end of lines
Files:
packages/web-core/src/pages/workflow-app/workflow-app-form.tsxapps/api/src/modules/share/share-creation.service.tsapps/api/src/modules/workflow-app/workflow-app.processor.tsapps/api/src/modules/workflow-app/workflow-app.service.tsapps/api/src/modules/variable-extraction/app-publish-prompt.ts
**/*.{jsx,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/05-code-organization.mdc)
Each component file should contain only one main component
Files:
packages/web-core/src/pages/workflow-app/workflow-app-form.tsx
**/*.tsx
📄 CodeRabbit inference engine (.cursor/rules/05-code-organization.mdc)
Explicitly type props with interfaces or types in React components
Files:
packages/web-core/src/pages/workflow-app/workflow-app-form.tsx
**/*.{css,scss,sass,less,js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/09-design-system.mdc)
**/*.{css,scss,sass,less,js,jsx,ts,tsx}: Primary color (#155EEF) should be used for main brand color in buttons, links, and accents
Error color (#F04438) should be used for error states and destructive actions
Success color (#12B76A) should be used for success states and confirmations
Warning color (#F79009) should be used for warnings and important notifications
Info color (#0BA5EC) should be used for informational elements
Files:
packages/web-core/src/pages/workflow-app/workflow-app-form.tsxapps/api/src/modules/share/share-creation.service.tsapps/api/src/modules/workflow-app/workflow-app.processor.tsapps/api/src/modules/workflow-app/workflow-app.service.tsapps/api/src/modules/variable-extraction/app-publish-prompt.ts
**/*.{tsx,ts}
📄 CodeRabbit inference engine (.cursor/rules/09-i18n-guidelines.mdc)
**/*.{tsx,ts}: Use the translation wrapper component and useTranslation hook in components
Ensure all user-facing text is translatable
Files:
packages/web-core/src/pages/workflow-app/workflow-app-form.tsxapps/api/src/modules/share/share-creation.service.tsapps/api/src/modules/workflow-app/workflow-app.processor.tsapps/api/src/modules/workflow-app/workflow-app.service.tsapps/api/src/modules/variable-extraction/app-publish-prompt.ts
**/*.{tsx,ts,json}
📄 CodeRabbit inference engine (.cursor/rules/09-i18n-guidelines.mdc)
Support dynamic content with placeholders in translations
Files:
packages/web-core/src/pages/workflow-app/workflow-app-form.tsxapps/api/src/modules/share/share-creation.service.tsapps/api/src/modules/workflow-app/workflow-app.processor.tsapps/api/src/modules/workflow-app/workflow-app.service.tsapps/api/src/modules/variable-extraction/app-publish-prompt.ts
**/*.{tsx,ts,jsx,js,vue,css,scss,less}
📄 CodeRabbit inference engine (.cursor/rules/11-ui-design-patterns.mdc)
**/*.{tsx,ts,jsx,js,vue,css,scss,less}: Use the primary blue (#155EEF) for main UI elements, CTAs, and active states
Use red (#F04438) only for errors, warnings, and destructive actions
Use green (#12B76A) for success states and confirmations
Use orange (#F79009) for warning states and important notifications
Use blue (#0BA5EC) for informational elements
Primary buttons should be solid with the primary color
Secondary buttons should have a border with transparent or light background
Danger buttons should use the error color
Use consistent padding, border radius, and hover states for all buttons
Follow fixed button sizes based on their importance and context
Use consistent border radius (rounded-lg) for all cards
Apply light shadows (shadow-sm) for card elevation
Maintain consistent padding inside cards (p-4orp-6)
Use subtle borders for card separation
Ensure proper spacing between card elements
Apply consistent styling to all form inputs
Use clear visual indicators for focus, hover, and error states in form elements
Apply proper spacing between elements using 8px, 16px, 24px increments
Ensure proper alignment of elements (left, center, or right)
Use responsive layouts that work across different device sizes
Maintain a minimum contrast ratio of 4.5:1 for text
Files:
packages/web-core/src/pages/workflow-app/workflow-app-form.tsxapps/api/src/modules/share/share-creation.service.tsapps/api/src/modules/workflow-app/workflow-app.processor.tsapps/api/src/modules/workflow-app/workflow-app.service.tsapps/api/src/modules/variable-extraction/app-publish-prompt.ts
**/*.{tsx,ts,jsx,js,vue}
📄 CodeRabbit inference engine (.cursor/rules/11-ui-design-patterns.mdc)
**/*.{tsx,ts,jsx,js,vue}: Include appropriate loading states for async actions in buttons
Group related form elements with appropriate spacing
Provide clear validation feedback for forms
Ensure proper labeling and accessibility for form elements
Ensure all interactive elements are keyboard accessible
Include appropriate ARIA attributes for complex components
Provide alternative text for images and icons
Support screen readers with semantic HTML elements
Files:
packages/web-core/src/pages/workflow-app/workflow-app-form.tsxapps/api/src/modules/share/share-creation.service.tsapps/api/src/modules/workflow-app/workflow-app.processor.tsapps/api/src/modules/workflow-app/workflow-app.service.tsapps/api/src/modules/variable-extraction/app-publish-prompt.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/08-contributing-guidelines.mdc)
**/*.{ts,tsx,js,jsx}: Follow the TypeScript/JavaScript style guidelines
Ensure code is well-tested and documented
Files:
packages/web-core/src/pages/workflow-app/workflow-app-form.tsxapps/api/src/modules/share/share-creation.service.tsapps/api/src/modules/workflow-app/workflow-app.processor.tsapps/api/src/modules/workflow-app/workflow-app.service.tsapps/api/src/modules/variable-extraction/app-publish-prompt.ts
**/*.{tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/08-contributing-guidelines.mdc)
Use React best practices for frontend code
Files:
packages/web-core/src/pages/workflow-app/workflow-app-form.tsx
apps/api/src/**/*.{controller,service}.ts
📄 CodeRabbit inference engine (.cursor/rules/06-api-structure.mdc)
Implement proper error handling in API modules
Files:
apps/api/src/modules/share/share-creation.service.tsapps/api/src/modules/workflow-app/workflow-app.service.ts
🧠 Learnings (3)
📚 Learning: 2025-09-10T02:51:12.184Z
Learnt from: mrcfps
Repo: refly-ai/refly PR: 1348
File: apps/api/src/modules/workflow-app/workflow-app.service.ts:88-101
Timestamp: 2025-09-10T02:51:12.184Z
Learning: In the WorkflowApp model in apps/api/prisma/schema.prisma, the `appId` field is a unique selector, making `findUnique` the correct Prisma method to use when querying by appId.
Applied to files:
apps/api/src/modules/workflow-app/workflow-app.processor.ts
📚 Learning: 2025-09-10T02:51:12.185Z
Learnt from: mrcfps
Repo: refly-ai/refly PR: 1348
File: apps/api/src/modules/workflow-app/workflow-app.service.ts:88-101
Timestamp: 2025-09-10T02:51:12.185Z
Learning: In the WorkflowApp model in apps/api/prisma/schema.prisma, the `appId` field has a `unique` constraint, making `findUnique` the correct and preferred Prisma method when querying by appId alone.
Applied to files:
apps/api/src/modules/workflow-app/workflow-app.processor.ts
📚 Learning: 2025-11-25T03:05:15.932Z
Learnt from: CR
Repo: refly-ai/refly PR: 0
File: .cursor/rules/16-language-guidelines.mdc:0-0
Timestamp: 2025-11-25T03:05:15.932Z
Learning: All code-related content must follow critical English requirements
Applied to files:
apps/api/src/modules/variable-extraction/app-publish-prompt.ts
🧬 Code graph analysis (2)
apps/api/src/modules/workflow-app/workflow-app.processor.ts (1)
apps/api/src/utils/const.ts (1)
QUEUE_WORKFLOW_APP_TEMPLATE(34-34)
apps/api/src/modules/workflow-app/workflow-app.service.ts (5)
packages/openapi-schema/src/types.gen.ts (6)
RawCanvasData(2583-2604)CanvasNode(6850-6889)type(760-760)WorkflowVariable(7241-7286)User(474-483)CreateWorkflowAppRequest(7050-7087)packages/request/src/requests/types.gen.ts (6)
RawCanvasData(2579-2600)CanvasNode(6856-6895)type(756-756)WorkflowVariable(7243-7288)User(474-483)CreateWorkflowAppRequest(7056-7093)apps/api/src/modules/pages/pages.dto.ts (1)
CanvasNode(25-32)apps/api/src/modules/variable-extraction/variable-extraction.dto.ts (2)
CanvasNode(87-92)WorkflowVariable(4-4)apps/api/src/modules/tool/sandbox/scalebox.dto.ts (1)
error(214-220)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build / Build
🔇 Additional comments (8)
packages/web-core/src/pages/workflow-app/workflow-app-form.tsx (1)
343-347: Approve simplified template variable initialization.The change removes client-side placeholder extraction and filtering, now relying on the backend to provide the complete, validated set of workflow variables. This aligns with the new server-side validation logic in
workflow-app.service.tsthat ensures template content matches variables before persisting.The effect correctly depends on both
templateContentandworkflowVariables, ensuring re-initialization when either changes.apps/api/src/modules/variable-extraction/app-publish-prompt.ts (3)
489-508: LGTM on enhancedbuildNodesTextwith query extraction.The function now safely extracts query content from nested metadata paths using optional chaining and nullish coalescing. The safe access pattern
(node?.data as any)?.metadata?.structuredData?.queryhandles missing properties gracefully.
556-575: LGTM on newbuildVariablesTableTexthelper.The function provides a clean markdown table format for variables with proper null handling. The table structure with numbered rows and backtick-wrapped variable names improves readability in the prompt.
60-92: Prompt improvements for variable name exact matching look comprehensive.The added examples covering abbreviation, case sensitivity, typos, and special character preservation provide clear guidance. The bilingual annotations (English with Chinese) will help with multi-language LLM understanding.
apps/api/src/modules/workflow-app/workflow-app.processor.ts (1)
51-54: Approve migration to CanvasService for variable retrieval.This change aligns with the broader PR goal of centralizing workflow variable handling through CanvasService, ensuring consistency across the processor, share-creation service, and main workflow-app service.
apps/api/src/modules/workflow-app/workflow-app.service.ts (3)
105-132: LGTM onbuildSkillResponsesFingerprintimplementation.The method correctly:
- Filters for skillResponse nodes only
- Extracts stable fields (type, title, query) that affect prompt generation
- Uses a composite sort key for deterministic ordering
- Returns a JSON string fingerprint for comparison
The null safety with optional chaining and nullish coalescing is thorough.
229-300: Approve comprehensive skip-generation logic.The stable mode comparison effectively uses multiple fingerprints (title, description, skill responses, variables) and template content validation to determine if regeneration is needed. The error handling at lines 263-270 gracefully falls back to triggering regeneration when previous canvas data cannot be loaded.
194-197: Approve centralized variable retrieval from CanvasService.This change aligns with the PR's architectural goal of having a single source of truth for workflow variables, ensuring consistency between the service, processor, and share-creation flows.
…t duplicate staticFile entries - Use direct putObject instead of uploadBuffer to avoid creating duplicate staticFile records - Update all share records (regular share + template share) instead of only the latest one - Add JSON data validation to prevent invalid structure updates - Improve error logging with stack trace for better debugging - Add independent error handling for each share record
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
apps/api/src/modules/workflow-app/workflow-app.processor.ts (2)
68-74: Avoidanytype and simplify validation logic.The validation logic has several concerns:
- The
(v: any)type annotation violates the coding guidelines that recommend usingunknownwith proper type guards instead ofany.- The
variables?.every?.()pattern is unnecessary—ifArray.isArray(variables)is true,everyis guaranteed to exist.- The fallback to
truewhenvariablesis not an array allows potentially invalid data through validation.Consider defining a type for workflow variables and simplifying:
+interface WorkflowVariable { + name: string; + // add other fields as needed +} const isValid = !!templateResult?.templateContent && - (Array.isArray(variables) - ? placeholders?.length === variables?.length && - (variables?.every?.((v: any) => placeholders?.includes?.(`{{${v?.name ?? ''}}}`)) ?? - false) - : true); + Array.isArray(variables) && + placeholders.length === variables.length && + variables.every((v: WorkflowVariable) => placeholders.includes(`{{${v.name ?? ''}}}`));As per coding guidelines, avoid using
anytype whenever possible.
109-113: Consider using a specific type instead ofanyfor thevariablesparameter.The
variablesparameter is typed asany, which reduces type safety. Consider using a more specific type that matches the expected structure fromCanvasService.getWorkflowVariables.+interface WorkflowVariable { + name: string; + // add other fields as needed +} private async updateSharedAppStorage( appId: string, templateContent: string | null | undefined, - variables: any, + variables: WorkflowVariable[] | unknown, ): Promise<void> {As per coding guidelines, avoid using
anytype whenever possible.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/api/src/modules/workflow-app/workflow-app.processor.ts(4 hunks)
🧰 Additional context used
📓 Path-based instructions (14)
**/*.{js,ts,jsx,tsx}
📄 CodeRabbit inference engine (.cursorrules)
**/*.{js,ts,jsx,tsx}: Always use optional chaining (?.) when accessing object properties
Always use nullish coalescing (??) or default values for potentially undefined values
Always check array existence before using array methods
Always validate object properties before destructuring
Always use single quotes for string literals in JavaScript/TypeScript code
**/*.{js,ts,jsx,tsx}: Use semicolons at the end of statements
Include spaces around operators (e.g.,a + binstead ofa+b)
Always use curly braces for control statements
Place opening braces on the same line as their statement
**/*.{js,ts,jsx,tsx}: Group import statements in order: React/framework libraries, third-party libraries, internal modules, relative path imports, type imports, style imports
Sort imports alphabetically within each import group
Leave a blank line between import groups
Extract complex logic into custom hooks
Use functional updates for state (e.g.,setCount(prev => prev + 1))
Split complex state into multiple state variables rather than single large objects
Use useReducer for complex state logic instead of multiple useState calls
Files:
apps/api/src/modules/workflow-app/workflow-app.processor.ts
**/*.{js,ts,tsx,jsx,py,java,cpp,c,cs,rb,go,rs,php,swift,kt,scala,r,m,mm,sql}
📄 CodeRabbit inference engine (.cursor/rules/00-language-priority.mdc)
**/*.{js,ts,tsx,jsx,py,java,cpp,c,cs,rb,go,rs,php,swift,kt,scala,r,m,mm,sql}: All code comments MUST be written in English
All variable names, function names, class names, and other identifiers MUST use English words
Comments should be concise and explain 'why' rather than 'what'
Use proper grammar and punctuation in comments
Keep comments up-to-date when code changes
Document complex logic, edge cases, and important implementation details
Use clear, descriptive names that indicate purpose
Avoid abbreviations unless they are universally understood
Files:
apps/api/src/modules/workflow-app/workflow-app.processor.ts
**/*.{js,ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/00-language-priority.mdc)
Use JSDoc style comments for functions and classes in JavaScript/TypeScript
Files:
apps/api/src/modules/workflow-app/workflow-app.processor.ts
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/01-code-style.mdc)
**/*.{js,jsx,ts,tsx}: Use single quotes for string literals in TypeScript/JavaScript
Always use optional chaining (?.) when accessing object properties in TypeScript/JavaScript
Always use nullish coalescing (??) or default values for potentially undefined values in TypeScript/JavaScript
Always check array existence before using array methods in TypeScript/JavaScript
Validate object properties before destructuring in TypeScript/JavaScript
Use ES6+ features like arrow functions, destructuring, and spread operators in TypeScript/JavaScript
Avoid magic numbers and strings - use named constants in TypeScript/JavaScript
Use async/await instead of raw promises for asynchronous code in TypeScript/JavaScript
Files:
apps/api/src/modules/workflow-app/workflow-app.processor.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/03-typescript-guidelines.mdc)
**/*.{ts,tsx}: Avoid usinganytype whenever possible - useunknowntype instead with proper type guards
Always define explicit return types for functions, especially for public APIs
Prefer extending existing types over creating entirely new types
Use TypeScript utility types (Partial<T>,Pick<T, K>,Omit<T, K>,Readonly<T>,Record<K, T>) to derive new types
Use union types and intersection types to combine existing types
Always import types explicitly using theimport typesyntax
Group type imports separately from value imports
Minimize creating local type aliases for imported types
Files:
apps/api/src/modules/workflow-app/workflow-app.processor.ts
**/*.{js,ts,jsx,tsx,css,json}
📄 CodeRabbit inference engine (.cursor/rules/04-code-formatting.mdc)
Maximum line length of 100 characters
Files:
apps/api/src/modules/workflow-app/workflow-app.processor.ts
**/*.{js,ts,jsx,tsx,css,json,yml,yaml}
📄 CodeRabbit inference engine (.cursor/rules/04-code-formatting.mdc)
Use 2 spaces for indentation, no tabs
Files:
apps/api/src/modules/workflow-app/workflow-app.processor.ts
**/*.{js,ts,jsx,tsx,css,json,yml,yaml,md}
📄 CodeRabbit inference engine (.cursor/rules/04-code-formatting.mdc)
No trailing whitespace at the end of lines
Files:
apps/api/src/modules/workflow-app/workflow-app.processor.ts
**/*.{css,scss,sass,less,js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/09-design-system.mdc)
**/*.{css,scss,sass,less,js,jsx,ts,tsx}: Primary color (#155EEF) should be used for main brand color in buttons, links, and accents
Error color (#F04438) should be used for error states and destructive actions
Success color (#12B76A) should be used for success states and confirmations
Warning color (#F79009) should be used for warnings and important notifications
Info color (#0BA5EC) should be used for informational elements
Files:
apps/api/src/modules/workflow-app/workflow-app.processor.ts
**/*.{tsx,ts}
📄 CodeRabbit inference engine (.cursor/rules/09-i18n-guidelines.mdc)
**/*.{tsx,ts}: Use the translation wrapper component and useTranslation hook in components
Ensure all user-facing text is translatable
Files:
apps/api/src/modules/workflow-app/workflow-app.processor.ts
**/*.{tsx,ts,json}
📄 CodeRabbit inference engine (.cursor/rules/09-i18n-guidelines.mdc)
Support dynamic content with placeholders in translations
Files:
apps/api/src/modules/workflow-app/workflow-app.processor.ts
**/*.{tsx,ts,jsx,js,vue,css,scss,less}
📄 CodeRabbit inference engine (.cursor/rules/11-ui-design-patterns.mdc)
**/*.{tsx,ts,jsx,js,vue,css,scss,less}: Use the primary blue (#155EEF) for main UI elements, CTAs, and active states
Use red (#F04438) only for errors, warnings, and destructive actions
Use green (#12B76A) for success states and confirmations
Use orange (#F79009) for warning states and important notifications
Use blue (#0BA5EC) for informational elements
Primary buttons should be solid with the primary color
Secondary buttons should have a border with transparent or light background
Danger buttons should use the error color
Use consistent padding, border radius, and hover states for all buttons
Follow fixed button sizes based on their importance and context
Use consistent border radius (rounded-lg) for all cards
Apply light shadows (shadow-sm) for card elevation
Maintain consistent padding inside cards (p-4orp-6)
Use subtle borders for card separation
Ensure proper spacing between card elements
Apply consistent styling to all form inputs
Use clear visual indicators for focus, hover, and error states in form elements
Apply proper spacing between elements using 8px, 16px, 24px increments
Ensure proper alignment of elements (left, center, or right)
Use responsive layouts that work across different device sizes
Maintain a minimum contrast ratio of 4.5:1 for text
Files:
apps/api/src/modules/workflow-app/workflow-app.processor.ts
**/*.{tsx,ts,jsx,js,vue}
📄 CodeRabbit inference engine (.cursor/rules/11-ui-design-patterns.mdc)
**/*.{tsx,ts,jsx,js,vue}: Include appropriate loading states for async actions in buttons
Group related form elements with appropriate spacing
Provide clear validation feedback for forms
Ensure proper labeling and accessibility for form elements
Ensure all interactive elements are keyboard accessible
Include appropriate ARIA attributes for complex components
Provide alternative text for images and icons
Support screen readers with semantic HTML elements
Files:
apps/api/src/modules/workflow-app/workflow-app.processor.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/08-contributing-guidelines.mdc)
**/*.{ts,tsx,js,jsx}: Follow the TypeScript/JavaScript style guidelines
Ensure code is well-tested and documented
Files:
apps/api/src/modules/workflow-app/workflow-app.processor.ts
🧠 Learnings (2)
📚 Learning: 2025-09-10T02:51:12.184Z
Learnt from: mrcfps
Repo: refly-ai/refly PR: 1348
File: apps/api/src/modules/workflow-app/workflow-app.service.ts:88-101
Timestamp: 2025-09-10T02:51:12.184Z
Learning: In the WorkflowApp model in apps/api/prisma/schema.prisma, the `appId` field is a unique selector, making `findUnique` the correct Prisma method to use when querying by appId.
Applied to files:
apps/api/src/modules/workflow-app/workflow-app.processor.ts
📚 Learning: 2025-09-10T02:51:12.185Z
Learnt from: mrcfps
Repo: refly-ai/refly PR: 1348
File: apps/api/src/modules/workflow-app/workflow-app.service.ts:88-101
Timestamp: 2025-09-10T02:51:12.185Z
Learning: In the WorkflowApp model in apps/api/prisma/schema.prisma, the `appId` field has a `unique` constraint, making `findUnique` the correct and preferred Prisma method when querying by appId alone.
Applied to files:
apps/api/src/modules/workflow-app/workflow-app.processor.ts
🧬 Code graph analysis (1)
apps/api/src/modules/workflow-app/workflow-app.processor.ts (1)
apps/api/src/utils/const.ts (1)
QUEUE_WORKFLOW_APP_TEMPLATE(34-34)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build / Build
🔇 Additional comments (3)
apps/api/src/modules/workflow-app/workflow-app.processor.ts (3)
1-25: LGTM!The imports are properly organized and the constructor correctly injects the new dependencies using NestJS dependency injection patterns. The
@Inject(OSS_EXTERNAL)decorator properly injects the external object storage service.
27-56: LGTM!The input validation is thorough with proper early returns and warning logs. The shift to sourcing variables from
CanvasService.getWorkflowVariablesaligns with the PR's objective to use the canvas as the single source of truth for workflow variables.
132-180: Good resilience pattern with per-record error handling.The per-record try-catch ensures that a failure to update one share record doesn't prevent updates to other records. This is a sound pattern for batch operations. The approach of:
- Logging per-record failures with stack traces
- Continuing to the next record on error
- Not throwing from the outer method to avoid failing the entire job
...provides good observability while maintaining system stability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/api/src/modules/variable-extraction/app-publish-prompt.ts (1)
490-531: Fix unsafenode.dataaccess and broaden query sources infilterUsedVariablesIn
filterUsedVariables, Line 502 dereferences(node.data as any).metadatawithout optional chaining. If anyCanvasNodeinskillResponseshasdataundefined, this will throw at runtime. Also, unlikebuildNodesText, you only look atmetadata.structuredData.queryand ignoremetadata.queryand theinput.originalQueryfield defined onCanvasNode.Consider tightening this up as follows:
- for (const node of skillResponses) { - const originalQuery = (node.data as any).metadata?.structuredData?.query || ''; - if (originalQuery) { - const variableRefs = extractVariableReferences(originalQuery); - for (const name of variableRefs) { - usedVariableNames.add(name); - } - } - } + for (const node of skillResponses) { + const originalQuery = + (node.data as any)?.metadata?.structuredData?.query ?? + (node.data as any)?.metadata?.query ?? + node.input?.originalQuery ?? + ''; + + if (typeof originalQuery === 'string' && originalQuery) { + const variableRefs = extractVariableReferences(originalQuery); + for (const name of variableRefs) { + usedVariableNames.add(name); + } + } + }This avoids a potential TypeError on nodes without
data, stays consistent withbuildNodesText, and leverages theinput.originalQueryfield defined inCanvasNode.
🧹 Nitpick comments (3)
apps/api/src/modules/variable-extraction/app-publish-prompt.ts (3)
1-6: Useimport typefor DTO types and keep value imports separate
WorkflowVariable,CanvasContext,HistoricalData, andCanvasContentItemare only used as types, so you can make this explicit and keep them out of the runtime dependency graph by switching toimport typeand grouping them separately from value imports:-import { - WorkflowVariable, - CanvasContext, - HistoricalData, - CanvasContentItem, -} from './variable-extraction.dto'; - -// Import examples for reference and testing -import { APP_PUBLISH_EXAMPLES } from './examples'; +import type { + WorkflowVariable, + CanvasContext, + HistoricalData, + CanvasContentItem, +} from './variable-extraction.dto'; + +// Import examples for reference and testing +import { APP_PUBLISH_EXAMPLES } from './examples';Also applies to: 9-9
49-52: Align the “Filter variables” comment with the actual behaviorThe comment on Line 49 says variables are filtered to those used in canvas nodes, but
usedVariablesis currently justcanvasData?.variables || [](no filtering), andfilterUsedVariablesis not used here.Either:
- Update the comment and variable name to reflect “all workflow variables”, or
- Call
filterUsedVariables(canvasData.variables, canvasData.skillResponses)if you do want this prompt to only reflect actually referenced variables.
533-552: Handle missingvariableTypegracefully inbuildVariablesTableTextRight now the table prints
${v.variableType}, which will showundefinedwhenvariableTypeis absent on aWorkflowVariable. You already defaultdescriptionto'N/A'; doing the same for type keeps the Markdown output clean:function buildVariablesTableText(variables: WorkflowVariable[]): string { if (!variables?.length) { return ''; } const tableHeader = `| # | Variable Name | Type | Description | |---|--------------|------|-------------|`; const tableRows = variables .map((v, idx) => { - const description = v.description || 'N/A'; - return `| ${idx + 1} | \`{{${v.name}}}\` | ${v.variableType} | ${description} |`; + const type = v.variableType ?? 'unknown'; + const description = v.description || 'N/A'; + return `| ${idx + 1} | \`{{${v.name}}}\` | ${type} | ${description} |`; }) .join('\n'); return `${tableHeader}\n${tableRows}`; }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/api/src/modules/variable-extraction/app-publish-prompt.ts(10 hunks)
🧰 Additional context used
📓 Path-based instructions (14)
**/*.{js,ts,jsx,tsx}
📄 CodeRabbit inference engine (.cursorrules)
**/*.{js,ts,jsx,tsx}: Always use optional chaining (?.) when accessing object properties
Always use nullish coalescing (??) or default values for potentially undefined values
Always check array existence before using array methods
Always validate object properties before destructuring
Always use single quotes for string literals in JavaScript/TypeScript code
**/*.{js,ts,jsx,tsx}: Use semicolons at the end of statements
Include spaces around operators (e.g.,a + binstead ofa+b)
Always use curly braces for control statements
Place opening braces on the same line as their statement
**/*.{js,ts,jsx,tsx}: Group import statements in order: React/framework libraries, third-party libraries, internal modules, relative path imports, type imports, style imports
Sort imports alphabetically within each import group
Leave a blank line between import groups
Extract complex logic into custom hooks
Use functional updates for state (e.g.,setCount(prev => prev + 1))
Split complex state into multiple state variables rather than single large objects
Use useReducer for complex state logic instead of multiple useState calls
Files:
apps/api/src/modules/variable-extraction/app-publish-prompt.ts
**/*.{js,ts,tsx,jsx,py,java,cpp,c,cs,rb,go,rs,php,swift,kt,scala,r,m,mm,sql}
📄 CodeRabbit inference engine (.cursor/rules/00-language-priority.mdc)
**/*.{js,ts,tsx,jsx,py,java,cpp,c,cs,rb,go,rs,php,swift,kt,scala,r,m,mm,sql}: All code comments MUST be written in English
All variable names, function names, class names, and other identifiers MUST use English words
Comments should be concise and explain 'why' rather than 'what'
Use proper grammar and punctuation in comments
Keep comments up-to-date when code changes
Document complex logic, edge cases, and important implementation details
Use clear, descriptive names that indicate purpose
Avoid abbreviations unless they are universally understood
Files:
apps/api/src/modules/variable-extraction/app-publish-prompt.ts
**/*.{js,ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/00-language-priority.mdc)
Use JSDoc style comments for functions and classes in JavaScript/TypeScript
Files:
apps/api/src/modules/variable-extraction/app-publish-prompt.ts
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/01-code-style.mdc)
**/*.{js,jsx,ts,tsx}: Use single quotes for string literals in TypeScript/JavaScript
Always use optional chaining (?.) when accessing object properties in TypeScript/JavaScript
Always use nullish coalescing (??) or default values for potentially undefined values in TypeScript/JavaScript
Always check array existence before using array methods in TypeScript/JavaScript
Validate object properties before destructuring in TypeScript/JavaScript
Use ES6+ features like arrow functions, destructuring, and spread operators in TypeScript/JavaScript
Avoid magic numbers and strings - use named constants in TypeScript/JavaScript
Use async/await instead of raw promises for asynchronous code in TypeScript/JavaScript
Files:
apps/api/src/modules/variable-extraction/app-publish-prompt.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/03-typescript-guidelines.mdc)
**/*.{ts,tsx}: Avoid usinganytype whenever possible - useunknowntype instead with proper type guards
Always define explicit return types for functions, especially for public APIs
Prefer extending existing types over creating entirely new types
Use TypeScript utility types (Partial<T>,Pick<T, K>,Omit<T, K>,Readonly<T>,Record<K, T>) to derive new types
Use union types and intersection types to combine existing types
Always import types explicitly using theimport typesyntax
Group type imports separately from value imports
Minimize creating local type aliases for imported types
Files:
apps/api/src/modules/variable-extraction/app-publish-prompt.ts
**/*.{js,ts,jsx,tsx,css,json}
📄 CodeRabbit inference engine (.cursor/rules/04-code-formatting.mdc)
Maximum line length of 100 characters
Files:
apps/api/src/modules/variable-extraction/app-publish-prompt.ts
**/*.{js,ts,jsx,tsx,css,json,yml,yaml}
📄 CodeRabbit inference engine (.cursor/rules/04-code-formatting.mdc)
Use 2 spaces for indentation, no tabs
Files:
apps/api/src/modules/variable-extraction/app-publish-prompt.ts
**/*.{js,ts,jsx,tsx,css,json,yml,yaml,md}
📄 CodeRabbit inference engine (.cursor/rules/04-code-formatting.mdc)
No trailing whitespace at the end of lines
Files:
apps/api/src/modules/variable-extraction/app-publish-prompt.ts
**/*.{css,scss,sass,less,js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/09-design-system.mdc)
**/*.{css,scss,sass,less,js,jsx,ts,tsx}: Primary color (#155EEF) should be used for main brand color in buttons, links, and accents
Error color (#F04438) should be used for error states and destructive actions
Success color (#12B76A) should be used for success states and confirmations
Warning color (#F79009) should be used for warnings and important notifications
Info color (#0BA5EC) should be used for informational elements
Files:
apps/api/src/modules/variable-extraction/app-publish-prompt.ts
**/*.{tsx,ts}
📄 CodeRabbit inference engine (.cursor/rules/09-i18n-guidelines.mdc)
**/*.{tsx,ts}: Use the translation wrapper component and useTranslation hook in components
Ensure all user-facing text is translatable
Files:
apps/api/src/modules/variable-extraction/app-publish-prompt.ts
**/*.{tsx,ts,json}
📄 CodeRabbit inference engine (.cursor/rules/09-i18n-guidelines.mdc)
Support dynamic content with placeholders in translations
Files:
apps/api/src/modules/variable-extraction/app-publish-prompt.ts
**/*.{tsx,ts,jsx,js,vue,css,scss,less}
📄 CodeRabbit inference engine (.cursor/rules/11-ui-design-patterns.mdc)
**/*.{tsx,ts,jsx,js,vue,css,scss,less}: Use the primary blue (#155EEF) for main UI elements, CTAs, and active states
Use red (#F04438) only for errors, warnings, and destructive actions
Use green (#12B76A) for success states and confirmations
Use orange (#F79009) for warning states and important notifications
Use blue (#0BA5EC) for informational elements
Primary buttons should be solid with the primary color
Secondary buttons should have a border with transparent or light background
Danger buttons should use the error color
Use consistent padding, border radius, and hover states for all buttons
Follow fixed button sizes based on their importance and context
Use consistent border radius (rounded-lg) for all cards
Apply light shadows (shadow-sm) for card elevation
Maintain consistent padding inside cards (p-4orp-6)
Use subtle borders for card separation
Ensure proper spacing between card elements
Apply consistent styling to all form inputs
Use clear visual indicators for focus, hover, and error states in form elements
Apply proper spacing between elements using 8px, 16px, 24px increments
Ensure proper alignment of elements (left, center, or right)
Use responsive layouts that work across different device sizes
Maintain a minimum contrast ratio of 4.5:1 for text
Files:
apps/api/src/modules/variable-extraction/app-publish-prompt.ts
**/*.{tsx,ts,jsx,js,vue}
📄 CodeRabbit inference engine (.cursor/rules/11-ui-design-patterns.mdc)
**/*.{tsx,ts,jsx,js,vue}: Include appropriate loading states for async actions in buttons
Group related form elements with appropriate spacing
Provide clear validation feedback for forms
Ensure proper labeling and accessibility for form elements
Ensure all interactive elements are keyboard accessible
Include appropriate ARIA attributes for complex components
Provide alternative text for images and icons
Support screen readers with semantic HTML elements
Files:
apps/api/src/modules/variable-extraction/app-publish-prompt.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/08-contributing-guidelines.mdc)
**/*.{ts,tsx,js,jsx}: Follow the TypeScript/JavaScript style guidelines
Ensure code is well-tested and documented
Files:
apps/api/src/modules/variable-extraction/app-publish-prompt.ts
🧠 Learnings (2)
📚 Learning: 2025-11-25T03:05:15.932Z
Learnt from: CR
Repo: refly-ai/refly PR: 0
File: .cursor/rules/16-language-guidelines.mdc:0-0
Timestamp: 2025-11-25T03:05:15.932Z
Learning: Maintain a professional tone in Chinese content
Applied to files:
apps/api/src/modules/variable-extraction/app-publish-prompt.ts
📚 Learning: 2025-11-25T03:05:15.932Z
Learnt from: CR
Repo: refly-ai/refly PR: 0
File: .cursor/rules/16-language-guidelines.mdc:0-0
Timestamp: 2025-11-25T03:05:15.932Z
Learning: All code-related content must follow critical English requirements
Applied to files:
apps/api/src/modules/variable-extraction/app-publish-prompt.ts
🧬 Code graph analysis (1)
apps/api/src/modules/variable-extraction/app-publish-prompt.ts (4)
packages/openapi-schema/src/types.gen.ts (1)
WorkflowVariable(7241-7286)packages/ai-workspace-common/src/requests/types.gen.ts (1)
WorkflowVariable(7243-7288)packages/request/src/requests/types.gen.ts (1)
WorkflowVariable(7243-7288)apps/api/src/modules/variable-extraction/variable-extraction.dto.ts (1)
WorkflowVariable(4-4)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build / Build
🔇 Additional comments (2)
apps/api/src/modules/variable-extraction/app-publish-prompt.ts (2)
60-92: Exact-name guidance, examples, and checklist text look coherentThe new prompt sections around:
- CRITICAL exact variable-name matching (Lines 60–92),
- Natural-flow and language-bridge requirements (Lines 191–224),
- “Common Mistakes” catalog (Lines 255–298), and
- The CRITICAL validation checklist / mandatory requirements (Lines 333–415)
are internally consistent and strongly reinforce the invariant that every variable appears exactly once with an exact name match. No issues from my side on the wording or the way you interpolate
usedVariablesinto these sections.Also applies to: 191-224, 255-298, 333-415
457-485: Node description and query extraction enhancement looks solidThe updated
buildNodesText:
- Safely derives
nodeTypeandnodeTitlewith sensible fallbacks.- Extracts
queryfrommetadata.structuredData.queryormetadata.queryusing optional chaining.- Only appends the
Query:line when there is non-empty content.This should give the LLM much richer context for each node without risking crashes when metadata is missing.
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:
Screenshots/Videos
Checklist
Important
Please review the checklist below before submitting your pull request.
dev/reformat(backend) andcd web && npx lint-staged(frontend) to appease the lint godsSummary by CodeRabbit
New Features
Bug Fixes / Validation
UI
✏️ Tip: You can customize this high-level summary in your review settings.