maxun icon indicating copy to clipboard operation
maxun copied to clipboard

feat: retrain robot

Open RohitR311 opened this issue 9 months ago • 2 comments

What this PR does?

Adds the functionality to retrain an existing robot.

Closes: #519

Summary by CodeRabbit

  • New Features
    • Introduced a retraining option within the recordings interface, enabling users to initiate robot retraining directly from the menu.
    • Enhanced session management during the retraining process for improved user experience.
    • Updated event handling to support the retrieval and management of robot records based on specific identifiers.
    • Added state management for retraining robot identifiers in the global context.
    • Improved session storage handling in the recordings page for better data management.
    • Added communication enhancements to clear session data when navigating to the main menu.
    • Expanded localization support for the retraining feature in multiple languages, including German, English, Spanish, Japanese, and Chinese.

RohitR311 avatar Apr 09 '25 14:04 RohitR311

Walkthrough

The changes introduce a new robot retraining functionality within the RecordingsTable component. New methods for handling retraining (handleRetrainRobot and startRetrainRecording) are added. The OptionsButton component is updated to include a retrain option, and the event listener now clears specific session storage items upon receiving a designated message. Additionally, the WorkflowGenerator class is modified to handle an optional robotId in the saveNewWorkflow method, and the GlobalInfo context is enhanced with new properties for managing retrain IDs. The localization files are updated to include translations for the retraining action in multiple languages.

Changes

File Change Summary
src/components/robot/RecordingsTable.tsx - Added methods: handleRetrainRobot and startRetrainRecording
- Updated OptionsButton to include a retrain option and modified its props
- Enhanced message event listener to clear session storage items
server/src/workflow-management/classes/Generator.ts - Updated saveNewWorkflow method to accept an optional robotId
- Modified registerEventHandlers to extract robotId from incoming data and pass it to saveNewWorkflow
src/context/globalInfo.tsx - Added properties: retrainRobotId and setRetrainRobotId to GlobalInfo
- Initialized retrainRobotId in GlobalInfoStore
- Updated GlobalInfoProvider to manage new state variables
src/pages/RecordingPage.tsx - Updated state management to include setRecordingName and setRetrainRobotId
- Enhanced logic in handleRecording to manage session storage items related to robot name and ID
src/components/browser/BrowserRecordingSave.tsx - Added postMessage call to clear session data in goToMainMenu function
public/locales/de.json - New key added: "retrain": "Neu trainieren"
- New keys added: "retrain_success": "Roboter erfolgreich neu trainiert", "save_error": "Fehler beim Speichern des Roboters"
- Modified existing key: "save_success" (trailing comma added)
public/locales/en.json - New key added: "retrain": "Retrain"
- New keys added: "retrain_success": "Robot retrained successfully", "save_error": "Error saving robot"
- Modified existing key: "save_success" (trailing comma added)
public/locales/es.json - New entry added: "retrain": "Reentrenar"
- Updated existing key: "save_success" (changed to "Robot guardado correctamente")
- New keys added: "retrain_success": "Robot reentrenado correctamente", "save_error": "Error al guardar el robot"
public/locales/ja.json - New entry added: "retrain": "再学習"
- Updated existing key: "save_success" (changed to "ロボットの保存に成功しました")
- New keys added: "retrain_success": "ロボットの再トレーニングに成功しました", "save_error": "ロボットの保存中にエラーが発生しました"
public/locales/zh.json - New entry added: "retrain": "重新训练"
- New keys added: "retrain_success": "机器人重新训练成功", "save_error": "保存机器人时出错"
src/components/recorder/SaveRecording.tsx - Variable renamed: recordingName to saveRecordingName
- Added retrainRobotId variable from global store
- Updated exitRecording method signature

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant RT as RecordingsTable
    participant OB as OptionsButton
    participant SS as Session Storage

    U->>OB: Select "Retrain" option
    OB->>RT: Call handleRetrainRobot(id, name)
    RT->>SS: Retrieve active browser ID & workflow info
    alt Valid target URL exists
        RT->>SS: Update session storage state
        RT->>U: Initiate retraining via startRetrainRecording(id, name, url)
    else No active browser ID
        RT->>U: Display warning modal
    end
    Note over RT, SS: Listens for 'session-data-clear' messages to clear session data

Poem

Oh, hops and tweaks within the code,
A rabbit sings on this bright road.
Retrain the bots with joyful flair,
Session cleared with utmost care.
Bugs and errors now away—hip, hop, hooray!
🐰 Happy coding across the day!


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 489845cd70a4318e35f595731f5e4a9d14a4bb61 and fca4db4ba182ca041ebb0e260b15b7cdde5c1d98.

📒 Files selected for processing (7)
  • public/locales/de.json (2 hunks)
  • public/locales/en.json (2 hunks)
  • public/locales/es.json (2 hunks)
  • public/locales/ja.json (2 hunks)
  • public/locales/zh.json (2 hunks)
  • server/src/workflow-management/classes/Generator.ts (2 hunks)
  • src/components/robot/RecordingsTable.tsx (9 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • public/locales/zh.json
  • public/locales/en.json
  • public/locales/ja.json
  • public/locales/de.json
  • src/components/robot/RecordingsTable.tsx

[!NOTE]

🎁 Summarized by CodeRabbit Free

Your organization has reached its limit of developer seats under the Pro Plan. For new users, CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please add seats to your subscription by visiting https://app.coderabbit.ai/login.If you believe this is a mistake and have available seats, please assign one to the pull request author through the subscription management page using the link above.

🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

coderabbitai[bot] avatar Apr 09 '25 14:04 coderabbitai[bot]

https://github.com/user-attachments/assets/ad50323a-78a5-416a-a667-ac2c0aaeece1

RohitR311 avatar Apr 11 '25 13:04 RohitR311