Skip to content

Conversation

@anthhub
Copy link
Contributor

@anthhub anthhub commented Dec 3, 2025

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> or Resolves #<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
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

Summary by CodeRabbit

  • New Features

    • Workflow variables are now included with shared workflow apps and synchronized to shared storage.
    • Template generation now more intelligently skips or enqueues by validating previous templates against current variables and structure.
  • Bug Fixes / Validation

    • Enforced strict, exact (case-sensitive) variable-name matching with clearer guidance, examples, and validation checklist.
  • UI

    • Template editor now uses the full set of workflow variables for editing and validation.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 3, 2025

Walkthrough

Backend 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

Cohort / File(s) Summary
Backend: share creation
apps/api/src/modules/share/share-creation.service.ts
Populate workflowApp.variables by fetching workflow variables from CanvasService (serialized JSON) before computing credit usage.
Backend: workflow-app processing & storage sync
apps/api/src/modules/workflow-app/workflow-app.processor.ts
Inject CanvasService, MiscService, and external ObjectStorageService; replace DB variable fetch with CanvasService.getWorkflowVariables; add updateSharedAppStorage() to download, validate, update, and write per-share JSON in object storage with per-record error handling.
Backend: template validation & fingerprinting
apps/api/src/modules/workflow-app/workflow-app.service.ts
Add buildSkillResponsesFingerprint() and validateTemplateContentMatchesVariables(); compute fingerprints and detailed comparisons (title, description, variables, skill responses, template validation) to decide whether to skip/enqueue template generation; only persist templateContent when valid.
Prompt / variable guidance
apps/api/src/modules/variable-extraction/app-publish-prompt.ts
Add strict "Variable Name Exact Matching" guidance, buildVariablesTableText() helper, include node query content in node descriptions, and expand validation checklist, examples, and copy-paste references.
Frontend: template variable handling
packages/web-core/src/pages/workflow-app/workflow-app-form.tsx
Remove extraction/filtering of {{...}} placeholders; when templateContent exists, set templateVariables to the full workflowVariables list instead of a filtered subset.

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
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

  • Areas needing extra attention:
    • apps/api/src/modules/workflow-app/workflow-app.service.ts — fingerprinting, validation logic, and correctness of equality/skip conditions.
    • apps/api/src/modules/workflow-app/workflow-app.processor.ts — service injections and updateSharedAppStorage() concurrency/error handling.
    • apps/api/src/modules/share/share-creation.service.ts — serialization of variables and integration with existing credit usage logic.
    • apps/api/src/modules/variable-extraction/app-publish-prompt.ts — large prompt text changes and helper output formatting.

Possibly related PRs

Suggested reviewers

  • mrcfps
  • lefarcen
  • CH1111

Poem

🐰 I hopped to Canvas, fetched each name,
Fingerprints matched and kept the flame.
Templates tidy, shared JSON bright,
Rabbits nibble bugs away at night.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is incomplete; it contains only the template with no actual content filled in. The 'Summary' section is empty, no issue is linked, motivation/context is missing, and no impact areas are checked. Fill in the Summary section with details about what was fixed and why, link the related issue using 'Fixes #' syntax, check relevant impact areas, and provide context about the changes.
✅ Passed checks (2 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Title check ✅ Passed The title 'fix: template content generation' is directly related to the main changes, which involve improvements to template content generation across multiple services (share-creation, app-publish-prompt, workflow-app, and workflow-app-form).
✨ 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 fix/template-content-generation

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a 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 since JSON.stringify([]) already returns '[]' when the array is empty, and JSON.stringify(undefined) returns undefined (not null). If getWorkflowVariables can return undefined, 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 downloadFile returns null or undefined (e.g., file doesn't exist), calling toString() 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 for user parameter.

The user parameter is typed as any, but since it's used with miscService.uploadBuffer, it should match the expected User type 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 for includes check.

The as never type 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 placeholders to 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

📥 Commits

Reviewing files that changed from the base of the PR and between 51b4050 and a5788b1.

📒 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 + b instead of a+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.tsx
  • apps/api/src/modules/share/share-creation.service.ts
  • apps/api/src/modules/workflow-app/workflow-app.processor.ts
  • apps/api/src/modules/workflow-app/workflow-app.service.ts
  • 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:

  • packages/web-core/src/pages/workflow-app/workflow-app-form.tsx
  • apps/api/src/modules/share/share-creation.service.ts
  • apps/api/src/modules/workflow-app/workflow-app.processor.ts
  • apps/api/src/modules/workflow-app/workflow-app.service.ts
  • 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:

  • packages/web-core/src/pages/workflow-app/workflow-app-form.tsx
  • apps/api/src/modules/share/share-creation.service.ts
  • apps/api/src/modules/workflow-app/workflow-app.processor.ts
  • apps/api/src/modules/workflow-app/workflow-app.service.ts
  • 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:

  • packages/web-core/src/pages/workflow-app/workflow-app-form.tsx
  • apps/api/src/modules/share/share-creation.service.ts
  • apps/api/src/modules/workflow-app/workflow-app.processor.ts
  • apps/api/src/modules/workflow-app/workflow-app.service.ts
  • apps/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 using any type whenever possible - use unknown type 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 the import type syntax
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.tsx
  • apps/api/src/modules/share/share-creation.service.ts
  • apps/api/src/modules/workflow-app/workflow-app.processor.ts
  • apps/api/src/modules/workflow-app/workflow-app.service.ts
  • 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:

  • packages/web-core/src/pages/workflow-app/workflow-app-form.tsx
  • apps/api/src/modules/share/share-creation.service.ts
  • apps/api/src/modules/workflow-app/workflow-app.processor.ts
  • apps/api/src/modules/workflow-app/workflow-app.service.ts
  • 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:

  • packages/web-core/src/pages/workflow-app/workflow-app-form.tsx
  • apps/api/src/modules/share/share-creation.service.ts
  • apps/api/src/modules/workflow-app/workflow-app.processor.ts
  • apps/api/src/modules/workflow-app/workflow-app.service.ts
  • 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:

  • packages/web-core/src/pages/workflow-app/workflow-app-form.tsx
  • apps/api/src/modules/share/share-creation.service.ts
  • apps/api/src/modules/workflow-app/workflow-app.processor.ts
  • apps/api/src/modules/workflow-app/workflow-app.service.ts
  • apps/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.tsx
  • apps/api/src/modules/share/share-creation.service.ts
  • apps/api/src/modules/workflow-app/workflow-app.processor.ts
  • apps/api/src/modules/workflow-app/workflow-app.service.ts
  • 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:

  • packages/web-core/src/pages/workflow-app/workflow-app-form.tsx
  • apps/api/src/modules/share/share-creation.service.ts
  • apps/api/src/modules/workflow-app/workflow-app.processor.ts
  • apps/api/src/modules/workflow-app/workflow-app.service.ts
  • 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:

  • packages/web-core/src/pages/workflow-app/workflow-app-form.tsx
  • apps/api/src/modules/share/share-creation.service.ts
  • apps/api/src/modules/workflow-app/workflow-app.processor.ts
  • apps/api/src/modules/workflow-app/workflow-app.service.ts
  • 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-4 or p-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.tsx
  • apps/api/src/modules/share/share-creation.service.ts
  • apps/api/src/modules/workflow-app/workflow-app.processor.ts
  • apps/api/src/modules/workflow-app/workflow-app.service.ts
  • 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:

  • packages/web-core/src/pages/workflow-app/workflow-app-form.tsx
  • apps/api/src/modules/share/share-creation.service.ts
  • apps/api/src/modules/workflow-app/workflow-app.processor.ts
  • apps/api/src/modules/workflow-app/workflow-app.service.ts
  • 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:

  • packages/web-core/src/pages/workflow-app/workflow-app-form.tsx
  • apps/api/src/modules/share/share-creation.service.ts
  • apps/api/src/modules/workflow-app/workflow-app.processor.ts
  • apps/api/src/modules/workflow-app/workflow-app.service.ts
  • apps/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.ts
  • apps/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.ts that ensures template content matches variables before persisting.

The effect correctly depends on both templateContent and workflowVariables, ensuring re-initialization when either changes.

apps/api/src/modules/variable-extraction/app-publish-prompt.ts (3)

489-508: LGTM on enhanced buildNodesText with 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?.query handles missing properties gracefully.


556-575: LGTM on new buildVariablesTableText helper.

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 on buildSkillResponsesFingerprint implementation.

The method correctly:

  1. Filters for skillResponse nodes only
  2. Extracts stable fields (type, title, query) that affect prompt generation
  3. Uses a composite sort key for deterministic ordering
  4. 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
Copy link

@coderabbitai coderabbitai bot left a 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: Avoid any type and simplify validation logic.

The validation logic has several concerns:

  1. The (v: any) type annotation violates the coding guidelines that recommend using unknown with proper type guards instead of any.
  2. The variables?.every?.() pattern is unnecessary—if Array.isArray(variables) is true, every is guaranteed to exist.
  3. The fallback to true when variables is 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 any type whenever possible.


109-113: Consider using a specific type instead of any for the variables parameter.

The variables parameter is typed as any, which reduces type safety. Consider using a more specific type that matches the expected structure from CanvasService.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 any type whenever possible.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a5788b1 and cc5e90c.

📒 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 + b instead of a+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 using any type whenever possible - use unknown type 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 the import type syntax
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-4 or p-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.getWorkflowVariables aligns 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.

Copy link

@coderabbitai coderabbitai bot left a 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 unsafe node.data access and broaden query sources in filterUsedVariables

In filterUsedVariables, Line 502 dereferences (node.data as any).metadata without optional chaining. If any CanvasNode in skillResponses has data undefined, this will throw at runtime. Also, unlike buildNodesText, you only look at metadata.structuredData.query and ignore metadata.query and the input.originalQuery field defined on CanvasNode.

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 with buildNodesText, and leverages the input.originalQuery field defined in CanvasNode.

🧹 Nitpick comments (3)
apps/api/src/modules/variable-extraction/app-publish-prompt.ts (3)

1-6: Use import type for DTO types and keep value imports separate

WorkflowVariable, CanvasContext, HistoricalData, and CanvasContentItem are only used as types, so you can make this explicit and keep them out of the runtime dependency graph by switching to import type and 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 behavior

The comment on Line 49 says variables are filtered to those used in canvas nodes, but usedVariables is currently just canvasData?.variables || [] (no filtering), and filterUsedVariables is 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 missing variableType gracefully in buildVariablesTableText

Right now the table prints ${v.variableType}, which will show undefined when variableType is absent on a WorkflowVariable. You already default description to '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

📥 Commits

Reviewing files that changed from the base of the PR and between cc5e90c and 392872b.

📒 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 + b instead of a+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 using any type whenever possible - use unknown type 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 the import type syntax
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-4 or p-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 coherent

The 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 usedVariables into these sections.

Also applies to: 191-224, 255-298, 333-415


457-485: Node description and query extraction enhancement looks solid

The updated buildNodesText:

  • Safely derives nodeType and nodeTitle with sensible fallbacks.
  • Extracts query from metadata.structuredData.query or metadata.query using 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.

@mrcfps mrcfps changed the title Fix/template content generation fix: template content generation Dec 4, 2025
@mrcfps mrcfps merged commit 7b2757a into main Dec 4, 2025
2 checks passed
@mrcfps mrcfps deleted the fix/template-content-generation branch December 4, 2025 03:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants