Skip to content

Conversation

@lichunn
Copy link
Collaborator

@lichunn lichunn commented Aug 29, 2025

English | 简体中文

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • Built its own designer, fully self-validated

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

Background and solution

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • New Features
    • Added an option to override app code generation via toolbar configuration, enabling custom generation logic without changing the UI.
  • Bug Fixes
    • Improved reliability and compatibility of file writing when exporting or generating files, reducing potential write failures in certain environments or browsers.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 29, 2025

Walkthrough

The Vue component now accepts props in setup and conditionally uses a provided generateAppCode override. The filesystem utility changes the write payload to an object { type: 'write', data } when writing via FileSystemWritableFileStream. No exported signatures changed except setup(props) in Main.vue.

Changes

Cohort / File(s) Summary
Generate Code Toolbar Component
packages/toolbars/generate-code/src/Main.vue
Updated setup to setup(props); generation flow now checks props.options?.generateAppCode and calls it with appSchema if present, otherwise uses the existing generateAppCode(appSchema).
FS Utils Write Stream Payload
packages/utils/src/fs/index.ts
In writeFile, changed writable.write(fileContent) to writable.write({ type: 'write', data: fileContent }). Other logic and public signatures unchanged.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor U as User
  participant V as Main.vue
  participant D as Default generateAppCode
  participant O as Override generateAppCode (props.options)

  U->>V: Trigger code generation
  alt Override provided
    V->>O: generate(appSchema)
    O-->>V: result
  else No override
    V->>D: generate(appSchema)
    D-->>V: result
  end
  V-->>U: Display/generated output
Loading
sequenceDiagram
  autonumber
  participant FS as writeFile()
  participant H as File Handle
  participant W as FileSystemWritableFileStream

  FS->>H: getFile() / createWritable()
  FS->>W: write({ type: 'write', data: fileContent })
  W-->>FS: ack
  FS->>W: close()
  W-->>FS: closed
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I thump my paws on lines so neat,
An override hop—how swift, discreet!
Streams now nibble structured byte,
With type and data, just right.
Carrots compiled, code takes flight—
Another dawn, another write. 🥕✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbit in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbit in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbit gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbit read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbit help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbit ignore or @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbit summary or @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbit or @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the enhancement New feature or request label Aug 29, 2025
Copy link
Contributor

@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: 1

🧹 Nitpick comments (1)
packages/toolbars/generate-code/src/Main.vue (1)

45-45: Type the props to catch invalid overrides at compile time

Annotate setup’s props (or the props.options declaration) so the expected generateAppCode(appSchema) signature is enforced and icon shape is clear.

-  setup(props) {
+  setup(props: { options?: { generateAppCode?: (appSchema: any) => Promise<any> | any; icon?: any } }) {

Optionally, strengthen the props declaration:

// additionally (outside this hunk)
import type { PropType } from 'vue'

props: {
  options: {
    type: Object as PropType<{
      generateAppCode?: (appSchema: unknown) => Promise<{ genResult?: any[] }> | { genResult?: any[] }
      icon?: { default?: unknown } | unknown
    }>,
    default: () => ({})
  }
}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 7cce9b6 and 5ebdc88.

📒 Files selected for processing (2)
  • packages/toolbars/generate-code/src/Main.vue (2 hunks)
  • packages/utils/src/fs/index.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
packages/utils/src/fs/index.ts (1)
scripts/updateTemplate.mjs (1)
  • fileContent (122-122)
⏰ 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: push-check
🔇 Additional comments (1)
packages/toolbars/generate-code/src/Main.vue (1)

167-169: Configurable generateAppCode override — LGTM

The conditional fallback to the service implementation is clean and keeps existing behavior intact.

@hexqi hexqi modified the milestone: v2.9.0 Sep 15, 2025
}
const res = await generateAppCode(appSchema)
const res = await (props.options?.generateAppCode
Copy link
Collaborator

@hexqi hexqi Sep 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const { getAllNestedBlocksSchema, generateAppCode } = getMetaApi('engine.service.generateCode')
generateAppCode是generateCode服务导出的方法,这里可以通过开发一个新的出码的MetaService,实现新的generateCode来实现,应该不需要这个配置也可以做到

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants