Skip to content

fix(robot): add the role message markdown and upgrade the tiny-robot version #3471

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

Merged
merged 1 commit into from
Jun 3, 2025

Conversation

shenjunjian
Copy link
Collaborator

@shenjunjian shenjunjian commented Jun 3, 2025

PR

fix(robot): 增加角色消息为markdown, 升级tiny-robot 的版本

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)

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:

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

    • Assistant responses now explicitly support markdown formatting.
    • The robot chat container is displayed on any route containing 'grid-ai-agent' in the path, improving accessibility.
    • Added visible notification in chat when a workflow is started.
  • Chores

    • Updated dependencies for robot-related packages to the latest version.

Copy link

coderabbitai bot commented Jun 3, 2025

Walkthrough

This update modifies dependency versions in the package configuration, adjusts route matching logic for displaying a chat container, adds a content type property for the assistant role, and enhances SSE stream handling to support a new "workflow_started" event with a corresponding message.

Changes

File(s) Change Summary
examples/sites/package.json Updated dependency versions for three packages from 0.2.0-alpha.7 to 0.2.0-alpha.8.
examples/sites/src/views/components-doc/common.vue Changed chat container display logic to use substring match on route path instead of hash.
examples/sites/src/views/components-doc/composition/useTinyRobot.ts Added type: 'markdown' property to the assistant role configuration.
examples/sites/src/views/components-doc/composition/utils.ts Enhanced SSE stream handling to support and process "workflow_started" events.

Sequence Diagram(s)

sequenceDiagram
    participant SSE Server
    participant handleSSEStream
    participant Handler (onData)

    SSE Server->>handleSSEStream: Send SSE event ("workflow_started")
    handleSSEStream->>Handler (onData): Call with message {role: assistant, content: "**Workflow started** \r\n", ...}
Loading

Poem

A hop and a skip, new versions in tow,
The robot now speaks in markdown’s flow.
With workflows that start, a message appears—
“Workflow started!” for all bunny peers.
The chat container peeks when the path is just right,
Hopping through updates, coding delight!
🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

examples/sites/src/views/components-doc/composition/utils.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-vue".

(The package "eslint-plugin-vue" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-vue@latest --save-dev

The plugin "eslint-plugin-vue" was referenced from the config file in ".eslintrc.js » @antfu/eslint-config » @antfu/eslint-config-vue".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

examples/sites/src/views/components-doc/composition/useTinyRobot.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-vue".

(The package "eslint-plugin-vue" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-vue@latest --save-dev

The plugin "eslint-plugin-vue" was referenced from the config file in ".eslintrc.js » @antfu/eslint-config » @antfu/eslint-config-vue".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

examples/sites/src/views/components-doc/common.vue

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-vue".

(The package "eslint-plugin-vue" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-vue@latest --save-dev

The plugin "eslint-plugin-vue" was referenced from the config file in ".eslintrc.js » @antfu/eslint-config » @antfu/eslint-config-vue".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

✨ Finishing Touches
  • 📝 Generate Docstrings

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.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai 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:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @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

Documentation and Community

  • 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 bug Something isn't working label Jun 3, 2025
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 (1)
examples/sites/src/views/components-doc/composition/utils.ts (1)

67-84: Good implementation! Consider standardizing line endings.

The implementation of workflow_started event handling follows the established pattern well and correctly integrates with the existing message flow.

Consider using consistent line endings:

-                    content: '**Workflow started** \r\n'
+                    content: '**Workflow started**\n'

The \r\n (CRLF) line ending might be inconsistent with other parts of the codebase that likely use \n (LF). This ensures consistent line ending handling across different platforms.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cfe8e98 and 47a4555.

📒 Files selected for processing (4)
  • examples/sites/package.json (1 hunks)
  • examples/sites/src/views/components-doc/common.vue (1 hunks)
  • examples/sites/src/views/components-doc/composition/useTinyRobot.ts (1 hunks)
  • examples/sites/src/views/components-doc/composition/utils.ts (1 hunks)
🔇 Additional comments (3)
examples/sites/package.json (1)

32-34:

✅ Verification successful

Verify the updated package versions are valid and secure.

The three robot-related packages have been consistently updated to version 0.2.0-alpha.8. Since these are alpha versions, please ensure these versions exist on the registry and are free from known vulnerabilities.


🏁 Script executed:

#!/bin/bash
# Description: Verify the updated package versions exist and check for security advisories

echo "Checking package versions on npm registry..."

# Check if the versions exist
for package in "@opentiny/tiny-robot" "@opentiny/tiny-robot-kit" "@opentiny/tiny-robot-svgs"; do
  echo "Checking $package@0.2.0-alpha.8..."
  npm view "$package@0.2.0-alpha.8" version 2>/dev/null || echo "Version 0.2.0-alpha.8 not found for $package"
done

# Check for security advisories using GitHub CLI
echo "Checking for security advisories..."
for package in "tiny-robot" "tiny-robot-kit" "tiny-robot-svgs"; do
  gh api graphql -f query="
  {
    securityVulnerabilities(first: 5, ecosystem: NPM, package: \"@opentiny/$package\") {
      nodes {
        advisory {
          summary
          severity
          publishedAt
        }
        vulnerableVersionRange
        firstPatchedVersion {
          identifier
        }
      }
    }
  }" 2>/dev/null || echo "Could not check advisories for @opentiny/$package"
done

Length of output: 2358


Package versions validated and secure

  • The updates in examples/sites/package.json (lines 32–34) to @opentiny/tiny-robot, @opentiny/tiny-robot-kit, and @opentiny/tiny-robot-svgs @ 0.2.0-alpha.8 are confirmed to exist on npm.
  • No known security advisories were found for these packages in the GitHub Advisory Database.
examples/sites/src/views/components-doc/composition/useTinyRobot.ts (1)

155-155: LGTM! Content type specification enhances message rendering.

Adding the type: 'markdown' property to the assistant role configuration is a good practice that explicitly defines how assistant messages should be rendered, enabling proper markdown formatting support.

examples/sites/src/views/components-doc/common.vue (1)

451-451:

✅ Verification successful

Consider more precise route matching to avoid unintended behavior.

The change from exact hash matching (=== '#grid-ai-agent') to substring matching (includes('grid-ai-agent')) on the full path makes the robot chat more flexible but could potentially cause it to appear on unintended routes.

Consider using a more precise matching approach:

-  const hasRobot = router.currentRoute.value.fullPath.includes('grid-ai-agent')
+  const hasRobot = router.currentRoute.value.fullPath.includes('grid-ai-agent') || 
+                   router.currentRoute.value.hash === '#grid-ai-agent'

Or if you specifically want path-based matching, consider using a regex for more control:

-  const hasRobot = router.currentRoute.value.fullPath.includes('grid-ai-agent')
+  const hasRobot = /\/grid-ai-agent(?:\/|$|\?)/.test(router.currentRoute.value.fullPath)

🏁 Script executed:

#!/bin/bash
# Description: Check for existing routes that might match the new pattern

echo "Searching for route definitions that might contain 'grid-ai-agent'..."
rg -A 3 -B 3 "grid-ai-agent" --type js --type ts --type vue

Length of output: 242


🏁 Script executed:

#!/bin/bash
echo "Searching for references to 'grid-ai-agent' in .js, .ts, and .vue files..."
rg -A3 -B3 "grid-ai-agent" -g "*.{js,ts,vue}"

Length of output: 2514


Route matching validation: no unintended “grid-ai-agent” occurrences found

We searched across all .js, .ts, and .vue files for the substring grid-ai-agent and found references only in the intended demo context:

  • examples/sites/src/views/components-doc/common.vue (the hasRobot check)
  • examples/sites/demos/pc/menus.js (menu key for the AI agent demo)
  • examples/sites/demos/pc/app/grid/webdoc/grid-ai-agent.js (demo definition)

No other route paths, query parameters, or hash fragments include this segment. Substring matching on fullPath will therefore only trigger in the intended demo page.

If you anticipate future dynamic routes or query parameters that might inadvertently include grid-ai-agent, you can refine the check (for example, using a regex or combining it with a hash check). Otherwise, this change is safe as-is.

@zzcr zzcr merged commit 8cfe037 into dev Jun 3, 2025
11 checks passed
@zzcr zzcr deleted the shen/update-site-robot branch June 3, 2025 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants