Skip to content
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

feat: reset remote browser recording state #314

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
Open

Conversation

RohitR311
Copy link
Collaborator

@RohitR311 RohitR311 commented Jan 2, 2025

Functionality to reset remote browser recording environment state

Maxun._.Open.Source.No.Code.Web.Data.Extraction.Platform.-.Brave.2025-01-03.19-54-16.mp4

Summary by CodeRabbit

  • New Features

    • Added reset functionality to browser recording
    • Introduced new reset button in the right panel
    • Enhanced localization support for reset actions across multiple languages (German, English, Spanish, Japanese, Chinese)
  • Localization

    • Updated translation files with new reset-related messages and confirmations
    • Added consistent reset terminology across different languages
  • User Experience

    • Improved user feedback with new notifications about environment and capture resets
    • Added confirmation modals for reset actions

@RohitR311 RohitR311 marked this pull request as draft January 2, 2025 18:59
Copy link

coderabbitai bot commented Jan 2, 2025

Walkthrough

The pull request introduces a comprehensive update to the application's localization and functionality, focusing on adding reset capabilities across multiple language files (German, English, Spanish, Japanese, and Chinese). The changes include new localization entries for reset buttons, confirmation messages, and notifications. Corresponding updates to components like BrowserRecordingSave, RecordingsTable, RightSidePanel, and context files enhance the application's state management and user interaction flow, particularly around recording and resetting browser environments.

Changes

File Change Summary
public/locales/*.json Added localization entries for reset functionality across DE, EN, ES, JA, and ZH languages
src/components/molecules/BrowserRecordingSave.tsx Added reset modal, new state variables, and performReset method
src/components/molecules/RecordingsTable.tsx Added setInitialUrl and setBrowserRecordingUrl methods
src/components/organisms/RightSidePanel.tsx Removed local workflow state, now managed through context
src/context/browserActions.tsx Added workflow, pagination, and limit options to context
src/context/globalInfo.tsx Added initialUrl state management

Sequence Diagram

sequenceDiagram
    participant User
    participant UI
    participant BrowserRecording
    participant GlobalState

    User->>UI: Click Reset Button
    UI->>BrowserRecording: Open Reset Modal
    BrowserRecording-->>User: Display Confirmation
    User->>BrowserRecording: Confirm Reset
    BrowserRecording->>GlobalState: Reset Workflow
    GlobalState->>BrowserRecording: Clear Environment
    BrowserRecording-->>UI: Show Reset Notification
    UI-->>User: Return to Home Page
Loading

Poem

🐰 A Rabbit's Reset Rhyme 🔄

With buttons shiny and new,
Reset the world, start anew!
Captures cleared, path unfurled,
A digital dance, a rabbit's twirled!
Hop back home, adventure complete! 🚀


🪧 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

@RohitR311 RohitR311 marked this pull request as ready for review January 3, 2025 14:27
@RohitR311 RohitR311 requested a review from amhsirak January 3, 2025 14:27
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 (6)
src/components/molecules/BrowserRecordingSave.tsx (3)

49-91: performReset function is robust.
This function systematically resets global states, ends actions, clears data, and updates the UI. However:

  1. Consider adding error handling in case any asynchronous call inside fails.
  2. Review if calling socket.emit('new-recording') in all scenarios is always desired.

133-149: Discard Confirmation Modal
Including a dedicated confirm/cancel step is good UX. Consider adding a short explanation of what data is lost upon disposal.


150-168: Reset Confirmation Modal
The textual prompts and button labels appear user-friendly. Check if you want to reinforce that all workflow steps will be cleared.

src/context/browserActions.tsx (1)

45-45: [workflow, setWorkflow]
Providing a default of emptyWorkflow ensures consistent initialization. Consider potential concurrency issues if multiple components modify workflow simultaneously.

src/components/molecules/RecordingsTable.tsx (1)

145-148: setBrowserRecordingUrl helper
This local function updates both initialUrl and recordingUrl. This keeps them in sync effectively. Watch for edge cases where the user empties the URL or sets invalid protocols.

src/components/organisms/RightSidePanel.tsx (1)

51-52: Commented-out states
showPaginationOptions and showLimitOptions are commented out—likely replaced by context-based states. Remove these lines if they’re no longer needed.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9394fc3 and 014bce0.

📒 Files selected for processing (10)
  • 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)
  • src/components/molecules/BrowserRecordingSave.tsx (3 hunks)
  • src/components/molecules/RecordingsTable.tsx (3 hunks)
  • src/components/organisms/RightSidePanel.tsx (2 hunks)
  • src/context/browserActions.tsx (5 hunks)
  • src/context/globalInfo.tsx (4 hunks)
🔇 Additional comments (34)
src/components/molecules/BrowserRecordingSave.tsx (11)

1-1: Consider consistent import grouping.
The new import from React is fine, but consider grouping React imports together for clarity.


5-6: Great addition for better context usage.
Imports for useActionContext and useBrowserSteps enhance modular state management.


11-12: Neat constant usage.
Using emptyWorkflow and useSocketStore fosters consistent app-wide state and clarity.


16-17: Modal states are well-introduced.
Adding separate states for the discard and reset modals improves readability.


18-18: Verify all destructured properties.
Be sure each property is used. If any remain unused, consider removing them to keep context usage clean.


21-21: Socket usage is clear.
Extracting socket from useSocketStore is straightforward and consistent with the rest of the code.


23-36: Comprehensive destructuring.
All the action context properties are neatly destructured. Keep track of any potential concurrency or race conditions when simultaneously stopping multiple actions.


38-38: Browser steps reference.
Ensure that repeated calls to deleteBrowserStep in different parts of your code do not cause race conditions or inconsistent states.


109-115: Discard button logic is clear.
Users can confirm or cancel discarding the recording. Check if additional cleanup is necessary when discarding extensive data to prevent stale states.


118-131: Reset button integration.
A separate reset button with a distinct modal fosters a clear user flow. The code is easy to read and maintain.


178-178: Export statement
Exporting the component with a default name matches your existing pattern.

src/context/globalInfo.tsx (4)

23-24: New properties for initialUrl management
Storing an initialUrl and its setter in the global context is a solid addition. Verify usage across all components to avoid confusion between initialUrl and recordingUrl.
[approve]


54-54: Default initialUrl
Initializing initialUrl with 'https://' is sensible. Revisit this default if an empty value becomes more practical.


78-78: Stateful context
Using useState<string>(globalInfoStore.initialUrl) ensures the provider picks up the stored default. Double-check that any dynamic updates remain synchronized.
[approve]


126-127: Context value now includes initialUrl
Including initialUrl and setInitialUrl in the context provider is valuable for cross-component usage. Excellent approach to centralizing URL state.

src/context/browserActions.tsx (4)

3-4: Imports for workflow constants
Importing WorkflowFile from maxun-core & emptyWorkflow from shared constants is well-structured.


18-25: Extended action context properties
You’ve added workflow, showPaginationOptions, showLimitOptions, and their setters. This is a beneficial expansion, but ensure components that rely on these states handle them correctly to avoid partial updates or re-renders at unexpected times.


55-56: Flags for pagination & limit
Managing showPaginationOptions and showLimitOptions in context streamlines their usage. Confirm that resetting them is done whenever the user restarts or discards a process.


108-115: Exposed states in the Provider
Exposing new states and setter methods is well done. Keep an eye on debugging logs to ensure your app transitions remain intuitive.

src/components/molecules/RecordingsTable.tsx (2)

88-88: Context destructuring expanded
Including setInitialUrl ensures initial and final recording URLs remain synced. Check thoroughly for potential confusion if a user sets one but not the other.


315-315: Modal onChange referencing
Calling setBrowserRecordingUrl on change is apt. Ensure you sanitize or validate user input if you plan to store or re-emit this URL in any external calls.

src/components/organisms/RightSidePanel.tsx (2)

62-62: Increased reliance on context
Fully destructuring context properties (showPaginationOptions, showLimitOptions, etc.) centralizes logic. Verify that side effects remain minimal.


70-70: Effect dependencies
Replacing prior dependencies with [] avoids unintentional re-renders. Confirm this effect’s behavior if workflowHandler or id changes.

public/locales/zh.json (3)

166-166: LGTM! Reset button text added.

The Chinese translation "重置" is accurate and commonly used for "Reset" functionality.


230-232: LGTM! Reset confirmation modal messages added.

The translations are accurate and maintain consistency:

  • Confirmation prompt: "您确定要重置吗?"
  • Warning message clearly explains the reset behavior

235-237: LGTM! Reset notification messages added.

The translations accurately convey the state changes:

  • Recording termination
  • Environment reset
  • Successful reset confirmation
public/locales/ja.json (3)

166-166: LGTM! Reset button text added.

The Japanese translation "リセット" is accurate and commonly used for "Reset" functionality.


230-232: LGTM! Reset confirmation modal messages added.

The translations are accurate and maintain consistency:

  • Confirmation prompt: "リセットしてもよろしいですか?"
  • Warning message clearly explains the reset behavior

235-237: LGTM! Reset notification messages added.

The translations accurately convey the state changes:

  • Recording termination
  • Environment reset
  • Successful reset confirmation
public/locales/en.json (3)

164-164: LGTM! Reset button texts added.

Added both "Reset" and "Confirm" button texts for the reset functionality.

Also applies to: 167-167


231-233: LGTM! Reset confirmation modal messages added.

The messages are clear and informative:

  • Confirmation prompt is straightforward
  • Warning message clearly explains the consequences of resetting

236-238: LGTM! Reset notification messages added.

The notifications provide clear feedback about:

  • Recording termination
  • Environment reset status
  • Successful reset confirmation
public/locales/es.json (1)

166-166: LGTM! Spanish translations are accurate and well-structured.

The Spanish translations for the reset functionality are semantically correct and maintain natural language flow:

  • "Reiniciar" is the appropriate translation for the reset button
  • Modal messages clearly communicate the reset action and its consequences
  • Notification messages provide clear feedback about the reset operations

Also applies to: 230-232, 235-237

public/locales/de.json (1)

165-165: LGTM! German translations are accurate and well-structured.

The German translations for the reset functionality are semantically correct and maintain natural language flow:

  • "Zurücksetzen" is the appropriate translation for the reset button
  • Modal messages clearly communicate the reset action and its consequences
  • Notification messages provide clear feedback about the reset operations
  • Consistently uses the formal "Sie" form, which is appropriate for business software

Also applies to: 229-232, 234-236

@RohitR311 RohitR311 added the Type: Feature New features label Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature New features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants