Skip to content

Conversation

@lichunn
Copy link
Collaborator

@lichunn lichunn commented Oct 23, 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

  • Bug Fixes

    • Schema updates are now properly applied and persisted when processing responses.
  • Improvements

    • Builder responses now include images from fetched resources.
    • Custom prompt options are now respected when provided.

@github-actions github-actions bot added the enhancement New feature or request label Oct 23, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 23, 2025

Walkthrough

The setup() function now accepts props to enable prop access within setup scope. getSendSeesionProcess() is refactored to async, fetching additional resources for Builder type and constructing an image string injected into the first message. Schema updates are now persisted via setSchema(result). sendStreamRequest() properly awaits the async process.

Changes

Cohort / File(s) Summary
Async refactoring and prop integration
packages/plugins/robot/src/Main.vue
setup() now accepts props; getSendSeesionProcess() converted to async with conditional resource fetching for Builder aiType; image string construction from fetched URLs injected into message; prompt selection uses props.options.prompts with PROMPTS fallback; sendStreamRequest() now awaits async result; schema updates applied via setSchema(result) during Builder response handling

Sequence Diagram(s)

sequenceDiagram
    participant Component as Main Component
    participant Session as getSendSeesionProcess()
    participant Resources as Resource Fetch
    participant Stream as Stream Request
    participant Schema as Schema Update

    Component->>Session: await getSendSeesionProcess(props)
    
    alt aiType === Builder
        Session->>Resources: Fetch additional resources
        Resources-->>Session: Resource URLs
        Session->>Session: Construct imageStr
        Session->>Session: Inject into message
    end
    
    Session->>Session: Resolve prompts from props or PROMPTS
    Session-->>Component: Return prepared session data
    
    Component->>Stream: await sendStreamRequest(...)
    Stream-->>Component: Response received
    
    alt Builder response processing
        Component->>Schema: Compute new schema (JSON patches)
        Schema->>Schema: setSchema(result)
        Schema-->>Component: Schema persisted
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

The diff involves async refactoring requiring careful verification of error handling and promise resolution, conditional Builder-specific logic necessitating mental model tracking, and new schema persistence operations. Changes are confined to a single file with clear structural intent, but the interplay between async flows and conditional branching demands focused attention.

Poem

🐰 Async hops through Builder's door,
Props now dance forevermore,
Schemas bloom where resources gleam,
A rabbit's code—a developer's dream! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "feat:AI builds a system to add image resources to dialogues" is directly related to the primary change in the changeset. The raw summary confirms that the main modifications involve making getSendSeesionProcess asynchronous to fetch image resources when aiType is Builder, constructing an imageStr from fetched resource URLs, and injecting this into the first message content. The title accurately captures this core functionality addition of incorporating image resources into AI dialogues. While the phrasing "AI builds a system" is slightly unconventional, the title remains clear and specific enough for a teammate to understand the primary feature being added.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • 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

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

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: 2

🧹 Nitpick comments (1)
packages/plugins/robot/src/Main.vue (1)

269-271: Consider caching resource list to reduce redundant API calls.

The resource list is fetched on every message send in Builder mode, even within the same session. If the resource list doesn't change frequently, consider caching it to improve performance.

Example approach:

// Add at component level (line ~220)
const cachedResources = ref<string[]>([])
const resourcesFetched = ref(false)

// Then in getSendSeesionProcess:
if (aiType.value === AI_MODES['Builder']) {
  let imageStr = ''
  try {
    if (!resourcesFetched.value) {
      const res = await getMetaApi(META_SERVICE.Http).get('/material-center/api/resource/list')
      if (Array.isArray(res)) {
        cachedResources.value = res.map((item) => item?.resourceUrl).filter(Boolean)
        resourcesFetched.value = true
      }
    }
    imageStr = cachedResources.value.length ? `[图片资源] ${cachedResources.value}` : ''
  } catch (error) {
    console.error('Failed to fetch resources:', error)
  }
  // ... rest of the code
}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c27e843 and 80dd6b5.

📒 Files selected for processing (1)
  • packages/plugins/robot/src/Main.vue (4 hunks)
⏰ 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 (3)
packages/plugins/robot/src/Main.vue (3)

189-189: LGTM!

Adding props parameter to setup() is correct and enables accessing props.options?.prompts on line 275.


275-277: LGTM!

The prompt construction properly uses optional chaining for props.options?.prompts, provides a fallback to PROMPTS, and correctly includes all required context (instructions, knowledge, schema, and image resources).


365-365: LGTM!

Correctly awaits the now-async getSendSeesionProcess() function, ensuring proper sequencing of session data preparation before streaming begins.

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.

1 participant