Skip to content

fix(robot): optimized the example and added sessions and UI adjustment. #3484

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 5, 2025

Conversation

shenjunjian
Copy link
Collaborator

@shenjunjian shenjunjian commented Jun 5, 2025

PR

fix(robot): 完善示例,增加会话及UI调整,loading, drawer

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

    • Introduced a global toggle button to show or hide the robot chat panel, improving accessibility.
    • Added dynamic body class changes based on robot chat visibility for enhanced UI feedback.
  • Enhancements

    • Switched SSE proxy connections to use HTTPS for improved security.
    • Updated prompt icons and descriptions in the robot chat for clearer communication.
    • Improved chat streaming by tracking conversation context and message loading status.
  • Bug Fixes

    • Simplified and unified robot chat state management across components, reducing inconsistencies.
  • Chores

    • Updated dependencies for robot-related packages to newer versions.

Copy link

coderabbitai bot commented Jun 5, 2025

Walkthrough

The changes update dependency versions, enhance AI chat features, and refactor visibility control for the robot chat component. Conversation history management is removed, global state is introduced for chat visibility, and conversation context is integrated into streaming requests. UI adjustments simplify the chat interface and add a toggle button for chat activation.

Changes

File(s) Change Summary
examples/sites/demos/pc/app/grid/ai-agent/basic-usage.vue Changed SSE URL from HTTP to HTTPS.
examples/sites/package.json Updated three dependencies to version 0.2.1.
packages/vue/package.json Removed trailing newline.
examples/sites/src/tools/appData.js Added showTinyRobot property; added watcher to toggle a CSS class on the body based on this property.
examples/sites/src/views/components-doc/common.vue Switched robot chat visibility from local to global state; removed local show logic and body class toggle.
examples/sites/src/views/components-doc/composition/DifyModelProvider.ts Added _messages ref; included conversation context in chat stream requests.
examples/sites/src/views/components-doc/composition/useTinyRobot.ts Removed conversation history management; consolidated provider instance; updated prompt items.
examples/sites/src/views/components-doc/composition/utils.ts Updated handleSSEStream to accept messages ref; added loading state updates and global conversation tracking.
examples/sites/src/views/components-doc/tiny-robot-chat.vue Refactored to use global visibility state; removed session/history UI; added toggle button; updated styles.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ToggleButton
    participant appData
    participant RobotChat

    User->>ToggleButton: Click "Show Robot" button
    ToggleButton->>appData: set showTinyRobot = true
    appData-->>RobotChat: showTinyRobot changes
    RobotChat->>User: Display chat UI
Loading
sequenceDiagram
    participant User
    participant RobotChat
    participant DifyModelProvider
    participant handleSSEStream
    participant globalConversation

    User->>RobotChat: Send message
    RobotChat->>DifyModelProvider: chatStream(message)
    DifyModelProvider->>handleSSEStream: Start SSE stream (includes conversation_id)
    handleSSEStream->>globalConversation: Update id on workflow_started
    handleSSEStream->>DifyModelProvider: Update messages, set loading states
    DifyModelProvider->>RobotChat: Update chat messages
Loading

Poem

A toggle appears, the robot awakes,
With global state, a clean path it takes.
No more history clutter, just chat and reply,
HTTPS whispers as messages fly.
Dependencies fresh, the bunny hops on—
Simpler, sleeker, the chat is strong!
🐇✨

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/demos/pc/app/grid/ai-agent/basic-usage.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.

examples/sites/src/tools/appData.js

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.

  • 4 others
✨ 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 5, 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: 8

🔭 Outside diff range comments (1)
examples/sites/src/views/components-doc/common.vue (1)

14-14: ⚠️ Potential issue

Remove unused reference to show variable.

The template still references a show variable in the class binding, but this variable no longer exists after switching to global state management.

Apply this diff to fix the class binding:

-    :class="{ 'docs-on-robot-show': show }"
+    :class="{ 'docs-on-robot-show': appData.showTinyRobot }"
🧹 Nitpick comments (3)
examples/sites/src/views/components-doc/composition/DifyModelProvider.ts (1)

52-52: Handle empty conversation ID gracefully.

The code directly uses globalConversation.id without checking if it's empty. For new conversations, this will send an empty string which might not be the intended behavior.

Consider this improvement:

-          conversation_id: globalConversation.id
+          ...(globalConversation.id && { conversation_id: globalConversation.id })

This will only include the conversation_id field when it has a value, allowing the API to create a new conversation when needed.

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

451-452: Consider making the route detection more configurable.

The route detection is hardcoded to check for 'grid-ai-agent'. This might make it difficult to extend robot functionality to other routes in the future.

Consider extracting the route pattern to a configuration:

-  const hasRobot = router.currentRoute.value.fullPath.includes('grid-ai-agent')
+  const robotRoutes = ['grid-ai-agent'] // Could be moved to config
+  const hasRobot = robotRoutes.some(route => router.currentRoute.value.fullPath.includes(route))
examples/sites/src/views/components-doc/tiny-robot-chat.vue (1)

87-88: Consider avoiding !important declaration.

The CSS changes look appropriate for positioning, but consider whether the !important declaration is necessary. If possible, increase specificity instead of using !important to maintain better CSS maintainability.

-.tr-container {
-  top: 64px !important;
+.tr-container {
+  top: 64px;

If !important is required due to external style conflicts, consider adding a comment explaining why it's necessary.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between fe25484 and 9b882e2.

📒 Files selected for processing (9)
  • examples/sites/demos/pc/app/grid/ai-agent/basic-usage.vue (1 hunks)
  • examples/sites/package.json (1 hunks)
  • examples/sites/src/tools/appData.js (3 hunks)
  • examples/sites/src/views/components-doc/common.vue (3 hunks)
  • examples/sites/src/views/components-doc/composition/DifyModelProvider.ts (3 hunks)
  • examples/sites/src/views/components-doc/composition/useTinyRobot.ts (4 hunks)
  • examples/sites/src/views/components-doc/composition/utils.ts (5 hunks)
  • examples/sites/src/views/components-doc/tiny-robot-chat.vue (5 hunks)
  • packages/vue/package.json (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
examples/sites/src/views/components-doc/composition/DifyModelProvider.ts (1)
examples/sites/src/views/components-doc/composition/utils.ts (2)
  • globalConversation (10-12)
  • handleSSEStream (18-153)
🔇 Additional comments (11)
packages/vue/package.json (1)

240-240: LGTM! Minor formatting improvement.

Removing the trailing newline is a good formatting practice for consistency.

examples/sites/src/tools/appData.js (2)

1-1: LGTM! Proper import update for watch functionality.

Adding the watch import is necessary for the new robot visibility watcher.


12-12: LGTM! Good global state management approach.

Adding showTinyRobot to the global reactive state centralizes robot chat visibility control, which is a good architectural decision.

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

45-45: Fix will be needed after DifyModelProvider initialization is corrected.

This assignment will work correctly once the _messages property in DifyModelProvider is properly initialized as a ref(). Currently, it's trying to assign a Vue ref to a plain array.

This is related to the issue identified in DifyModelProvider.ts line 18. Ensure that fix is applied first, then this assignment will work correctly.


14-17: Good architectural improvement with provider reuse.

Creating a single DifyModelProvider instance and reusing it is a better approach than creating new instances. This improves performance and enables proper state management integration.


31-31: Icon rendering improvements are clean.

The changes to use h('span', ...) for rendering emoji icons with explicit font sizes is a good improvement for consistent styling.

Also applies to: 36-36, 66-66, 71-71

examples/sites/src/views/components-doc/tiny-robot-chat.vue (5)

42-48: LGTM! Clean toggle button implementation.

The toggle button implementation is well-structured with proper conditional rendering and clean event handling. The SVG icon and accessibility attributes (title) are good additions.


52-52: LGTM! Necessary import addition.

The addition of TrSuggestionPills to the imports is correct and required for the component used in the template.


55-55: LGTM! Required import for global state.

The import of appData is necessary for the global state management functionality introduced in this PR.


3-3:

✅ Verification successful

Verify global state management consistency.

The change to use appData.showTinyRobot for visibility control aligns with the global state management approach. Ensure that this global state is properly synchronized across all components that use it.


🏁 Script executed:

#!/bin/bash
# Verify that appData.showTinyRobot is consistently used across components
rg -A 3 -B 3 "showTinyRobot" --type vue --type js --type ts

Length of output: 87


🏁 Script executed:

#!/bin/bash
# Retry searching for usages of appData.showTinyRobot across .vue, .js, and .ts files
rg -n "showTinyRobot" -g '*.vue' -g '*.js' -g '*.ts'

Length of output: 707


Global showTinyRobot state usage is consistent and correctly wired

Verified that:

  • showTinyRobot is defined in examples/sites/src/tools/appData.js
  • It’s referenced in common.vue (v-show and assignment) and in tiny-robot-chat.vue (v-model:show and toggle)
  • No missing or conflicting usages detected

No further changes needed.


20-20:

❓ Verification inconclusive

Verify that removing markdown type doesn't affect message rendering.

The removal of type="markdown" from <tr-bubble-list> may change how messages are displayed. Ensure that this change is intentional and doesn't break existing message formatting.


🏁 Script executed:

#!/bin/bash
# Check if markdown rendering is still needed elsewhere or if this affects message display
ast-grep --pattern 'tr-bubble-list'
rg -A 5 -B 5 "type.*markdown" --type vue

Length of output: 106


🏁 Script executed:

#!/bin/bash
# Locate the tr-bubble-list component file(s)
fd --extension vue tr-bubble-list

# Inspect prop definitions and default values in the component
rg -n "props\s*:" -C 5 -g "*tr-bubble-list.vue"

# Also look for defineProps usage (Vue 3 <script setup>)
rg -n "defineProps" -C 5 -g "*tr-bubble-list.vue"

Length of output: 433


Verify markdown rendering in tr-bubble-list
I couldn’t locate the tr-bubble-list component source in this repo (it’s likely imported from an external package), so please confirm that removing type="markdown" won’t break message formatting. Especially ensure that markdown parsing is still enabled by default or handled elsewhere.

@@ -87,7 +87,7 @@ export default {
await client.connect(clientTransport)
const { sessionId } = await createSseProxy({
client,
url: 'http://39.108.160.245/sse'
url: 'https://39.108.160.245/sse'
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

❓ Verification inconclusive

Good security improvement by switching to HTTPS.

The change from HTTP to HTTPS enhances security by encrypting the SSE connection. However, please verify that the endpoint is accessible via HTTPS and consider externalizing this URL to a configuration file for better maintainability.


🏁 Script executed:

#!/bin/bash
# Verify the HTTPS endpoint is accessible
curl -I https://39.108.160.245/sse --connect-timeout 10

Length of output: 698


HTTPS endpoint fails certificate verification

The switch to HTTPS is a great security improvement, but curl -I https://39.108.160.245/sse is failing with an SSL error indicating a self-signed certificate. Please address this before merging:

  • Replace the self-signed certificate with a valid, CA-signed certificate so clients can verify it out of the box.
  • If a self-signed cert is required (e.g., for internal testing), ensure the client trusts it (e.g., import the cert or configure your HTTP client accordingly).
  • Externalize the SSE URL (and any related cert-trust settings) into a configuration file or environment variable instead of hard-coding the IP.
🤖 Prompt for AI Agents
In examples/sites/demos/pc/app/grid/ai-agent/basic-usage.vue at line 90, the SSE
URL is hardcoded with an HTTPS endpoint using a self-signed certificate that
fails SSL verification. To fix this, replace the self-signed certificate on the
server with a valid CA-signed certificate to ensure proper SSL validation.
Additionally, externalize the SSE URL into a configuration file or environment
variable to improve maintainability and allow easier updates without code
changes. If a self-signed certificate must be used, configure the client to
trust it explicitly by importing the certificate or adjusting the HTTP client
settings accordingly.

Comment on lines +32 to +34
"@opentiny/tiny-robot": "0.2.1",
"@opentiny/tiny-robot-kit": "0.2.1",
"@opentiny/tiny-robot-svgs": "0.2.1",
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Good dependency updates from alpha to stable versions.

The consistent update of all tiny-robot packages from alpha versions to stable 0.2.1 indicates improved stability and bug fixes.


🌐 Web query:

What is the latest version of @opentiny/tiny-robot package on npm?

💡 Result:

I couldn't find a package named @opentiny/tiny-robot on npm. It's possible there might be a typo or the package is listed under a different name. However, there is a related package called @opentiny/tiny-engine-plugin-robot, which is currently at version 2.0.0-rc.2. (libraries.io)

If this isn't the package you're referring to, could you please provide more details or verify the package name? That would help me assist you more effectively.

Citations:


Verify package names and published versions

The packages @opentiny/tiny-robot, @opentiny/tiny-robot-kit, and @opentiny/tiny-robot-svgs at version 0.2.1 could not be found on the public npm registry. Please confirm that:

  • The package names are correct and match your published artifacts.
  • Version 0.2.1 has been published (either publicly or to your private registry).
  • If these are private packages, ensure your CI/npm config points to the correct registry.

Once confirmed or corrected, the dependency bump from alpha to stable can be finalized.

🤖 Prompt for AI Agents
In examples/sites/package.json around lines 32 to 34, the dependencies
"@opentiny/tiny-robot", "@opentiny/tiny-robot-kit", and
"@opentiny/tiny-robot-svgs" at version "0.2.1" do not appear to exist on the
public npm registry. Verify that these package names are correct and correspond
to your published packages. Also confirm that version "0.2.1" is published
either publicly or in your private registry. If these are private packages,
ensure your npm configuration points to the correct registry. Update the package
names or versions accordingly to reflect valid and accessible dependencies.

Comment on lines +32 to +37
watch(
() => appData.showTinyRobot,
(value) => {
document.body.classList.toggle('docs-on-robot-show', value)
}
)
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add safety checks for DOM manipulation.

The watcher implementation is good for centralizing the robot visibility side effects, but consider adding safety checks for SSR compatibility and document availability.

 watch(
   () => appData.showTinyRobot,
   (value) => {
-    document.body.classList.toggle('docs-on-robot-show', value)
+    if (typeof document !== 'undefined' && document.body) {
+      document.body.classList.toggle('docs-on-robot-show', value)
+    }
   }
 )
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
watch(
() => appData.showTinyRobot,
(value) => {
document.body.classList.toggle('docs-on-robot-show', value)
}
)
watch(
() => appData.showTinyRobot,
(value) => {
if (typeof document !== 'undefined' && document.body) {
document.body.classList.toggle('docs-on-robot-show', value)
}
}
)
🤖 Prompt for AI Agents
In examples/sites/src/tools/appData.js around lines 32 to 37, the watcher
toggles a class on document.body without checking if the document object is
available, which can cause issues during server-side rendering (SSR). Add a
safety check to ensure that the code only runs if the document and document.body
exist before attempting to toggle the class. This will prevent errors in
environments where the DOM is not present.

@@ -14,6 +15,8 @@ import { handleSSEStream } from './utils.js'
* });
*/
export class DifyModelProvider extends BaseModelProvider {
_messages: Ref<ChatCompletionRequest['messages']> = []
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix the _messages property initialization.

The _messages property is incorrectly initialized as an empty array instead of a proper Vue Ref. This will cause runtime errors when the SSE handler tries to access .value.

Apply this diff to fix the initialization:

-  _messages: Ref<ChatCompletionRequest['messages']> = []
+  _messages: Ref<ChatCompletionRequest['messages']> = ref([])

Note: You'll also need to import ref from Vue.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In examples/sites/src/views/components-doc/composition/DifyModelProvider.ts at
line 18, the _messages property is initialized as a plain empty array instead of
a Vue Ref, which will cause runtime errors when accessing .value. Fix this by
importing ref from Vue and initializing _messages using ref([]) to create a
proper reactive reference.

Comment on lines +10 to +12
export const globalConversation = {
id: ''
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider thread safety for global conversation state.

The globalConversation object is a shared global state that could lead to race conditions if multiple chat sessions are active simultaneously.

Consider one of these approaches:

  1. Pass conversation context through function parameters instead of global state
  2. Use a Map to track multiple conversations by session ID
  3. Add proper synchronization mechanisms

Example for approach 1:

export async function handleSSEStream(
  response: Response,
  handler: StreamHandler,
  message: Ref<ChatCompletionRequest['messages']>,
  conversationContext: { id: string },
  signal?: AbortSignal
): Promise<void>
🤖 Prompt for AI Agents
In examples/sites/src/views/components-doc/composition/utils.ts around lines 10
to 12, the globalConversation object is a shared global state that risks race
conditions with concurrent chat sessions. To fix this, avoid using this global
object by passing the conversation context explicitly through function
parameters, or alternatively use a Map keyed by session IDs to manage multiple
conversations separately. Implement one of these approaches to ensure thread
safety and prevent state conflicts.

},
finish_reason: null
}
],
object: '',
model: ''
})
message.value.slice(-1)[0].loading = true
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add safety checks for message array access.

The code directly accesses the last message in the array without checking if the array is empty, which could cause runtime errors.

Apply this diff to add safety checks:

-            message.value.slice(-1)[0].loading = true
+            const lastMessage = message.value.slice(-1)[0]
+            if (lastMessage) {
+              lastMessage.loading = true
+            }

Apply similar fixes to lines 118 and 137 where loading = false is set.

Also applies to: 118-118, 137-137

🤖 Prompt for AI Agents
In examples/sites/src/views/components-doc/composition/utils.ts at lines 95,
118, and 137, the code accesses the last element of the message array without
checking if the array is empty, which can cause runtime errors. Add safety
checks to ensure the message array is not empty before accessing its last
element and setting the loading property. Use conditional checks to verify the
array length is greater than zero before performing these operations.

Comment on lines +134 to +157
.tr-toggle {
position: absolute;
cursor: pointer;
right: 30px;
top: 50%;
transform: translateX(50%) translateY(-50%);
z-index: 9;
width: 24px;
height: 24px;
border-radius: 50%;
font-size: 18px;
line-height: 18px;
background-color: var(--tv-TreeMenu-toggle-button-background-color);
box-shadow: 0 2px 4px 0px rgba(0, 0, 0, 0.12);
border: 1px solid var(--tv-TreeMenu-border-color);
transform: translateX(100%) translateY(-50%);
border-top-right-radius: 0;
border-bottom-right-radius: 0;

svg {
margin-top: 2px;
fill: #808080;
}
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix duplicate transform declarations.

The toggle button styling is well-implemented with good use of CSS custom properties for theming. However, there are duplicate transform declarations that need to be consolidated.

.tr-toggle {
  position: absolute;
  cursor: pointer;
  right: 30px;
  top: 50%;
-  transform: translateX(50%) translateY(-50%);
  z-index: 9;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 18px;
  line-height: 18px;
  background-color: var(--tv-TreeMenu-toggle-button-background-color);
  box-shadow: 0 2px 4px 0px rgba(0, 0, 0, 0.12);
  border: 1px solid var(--tv-TreeMenu-border-color);
  transform: translateX(100%) translateY(-50%);
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;

The second transform declaration (line 149) will override the first one (line 139), making the first declaration redundant.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.tr-toggle {
position: absolute;
cursor: pointer;
right: 30px;
top: 50%;
transform: translateX(50%) translateY(-50%);
z-index: 9;
width: 24px;
height: 24px;
border-radius: 50%;
font-size: 18px;
line-height: 18px;
background-color: var(--tv-TreeMenu-toggle-button-background-color);
box-shadow: 0 2px 4px 0px rgba(0, 0, 0, 0.12);
border: 1px solid var(--tv-TreeMenu-border-color);
transform: translateX(100%) translateY(-50%);
border-top-right-radius: 0;
border-bottom-right-radius: 0;
svg {
margin-top: 2px;
fill: #808080;
}
}
.tr-toggle {
position: absolute;
cursor: pointer;
right: 30px;
top: 50%;
z-index: 9;
width: 24px;
height: 24px;
border-radius: 50%;
font-size: 18px;
line-height: 18px;
background-color: var(--tv-TreeMenu-toggle-button-background-color);
box-shadow: 0 2px 4px 0px rgba(0, 0, 0, 0.12);
border: 1px solid var(--tv-TreeMenu-border-color);
transform: translateX(100%) translateY(-50%);
border-top-right-radius: 0;
border-bottom-right-radius: 0;
svg {
margin-top: 2px;
fill: #808080;
}
}
🤖 Prompt for AI Agents
In examples/sites/src/views/components-doc/tiny-robot-chat.vue between lines 134
and 157, there are two conflicting transform declarations in the .tr-toggle CSS
class. Remove the first transform declaration on line 139 and keep only the
second one on line 149 to avoid redundancy and ensure the intended styling is
applied.


messageManager,
createConversation,
computedMessages,
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify that computedMessages is properly defined and used.

The change to computedMessages suggests a refactor in message handling. Ensure that this computed property is properly defined in the useTinyRobot composable and provides the expected functionality.


🏁 Script executed:

#!/bin/bash
# Check the definition and usage of computedMessages
ast-grep --pattern 'computedMessages'
rg -A 5 -B 5 "computedMessages" --type ts --type js

Length of output: 906


🏁 Script executed:

#!/bin/bash
# Locate useTinyRobot composable file(s) and inspect computedMessages definition
echo "Searching for useTinyRobot definitions..."
composable_files=$(rg -l "export function useTinyRobot" -t ts -t js)

if [ -z "$composable_files" ]; then
  echo "No useTinyRobot composable found."
  exit 1
fi

echo "Found composables:"
echo "$composable_files"

for file in $composable_files; do
  echo
  echo "== $file =="
  rg -n "computedMessages" -C3 "$file" || echo "No computedMessages reference in $file"
done

Length of output: 1007


Implement and Export computedMessages in useTinyRobot

The component at examples/sites/src/views/components-doc/tiny-robot-chat.vue (line 63) now references computedMessages, but our useTinyRobot composable (examples/sites/src/views/components-doc/composition/useTinyRobot.ts) does not define or return it. You should either:

  • Add and return a computedMessages computed property in the composable, for example:
    import { computed, ref } from 'vue';
    
    export function useTinyRobot() {
      const messages = ref<Message[]>([]);
      // … other logic …
    
      const computedMessages = computed(() => messages.value);
      return {
        // … existing exports …
        computedMessages,
      };
    }
  • Or update the component to use the existing messages ref (or whatever reactive value you intend) instead of computedMessages.

Locations needing attention:

  • examples/sites/src/views/components-doc/composition/useTinyRobot.ts: define and return computedMessages
  • examples/sites/src/views/components-doc/tiny-robot-chat.vue (line 63): ensure the destructured property matches the composable

Please make these changes to restore reactivity and avoid undefined references.

🤖 Prompt for AI Agents
In examples/sites/src/views/components-doc/composition/useTinyRobot.ts, define a
computed property named computedMessages that returns the current messages array
(or equivalent reactive data), then export it from the useTinyRobot function. In
examples/sites/src/views/components-doc/tiny-robot-chat.vue at line 63, ensure
that the destructured property matches this computedMessages export from the
composable to maintain reactivity and avoid undefined references.

@zzcr zzcr merged commit 7045fa1 into dev Jun 5, 2025
11 of 16 checks passed
@zzcr zzcr deleted the shen/update-site-robot-6.5 branch June 5, 2025 07:32
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