Feat:Add application output code configuration
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.
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 Componentpackages/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 Payloadpackages/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
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
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.
🪧 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
@coderabbitin a new review comment at the desired location with your query. - PR comments: Tag
@coderabbitin 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 ignoreor@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbit summaryor@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitor@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile 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.