Skip to content

Reset bridge form values on disconnect #35

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

alecande11
Copy link
Contributor

@alecande11 alecande11 commented Jun 27, 2025

https://linear.app/initia-labs/issue/FE-1358/bridge-chainasset-selection-input-need-to-be-reset-when-wallet

Summary by CodeRabbit

  • New Features
    • Bridge form values are now automatically reset when disconnecting from the widget, ensuring previous form data is cleared for improved privacy and user experience.

@alecande11 alecande11 requested a review from simcheolhwan as a code owner June 27, 2025 13:38
Copy link

coderabbitai bot commented Jun 27, 2025

Walkthrough

A new utility function, resetBridgeFormValues, has been introduced to clear specific bridge form data from localStorage. The WidgetHeader component now calls this function when the disconnect button is clicked, ensuring stored bridge form values are reset upon user disconnection.

Changes

File(s) Change Summary
.../src/public/data/storage.ts Added resetBridgeFormValues function to clear bridge-related keys from localStorage.
.../src/public/app/WidgetHeader.tsx Imported and invoked resetBridgeFormValues in the disconnect button's click handler.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant WidgetHeader
    participant Storage (localStorage)

    User->>WidgetHeader: Clicks Disconnect Button
    WidgetHeader->>WidgetHeader: closeWidget()
    WidgetHeader->>WidgetHeader: disconnect()
    WidgetHeader->>Storage: resetBridgeFormValues()
    Storage-->>WidgetHeader: Bridge form values cleared
Loading

Poem

When you click to disconnect and go,
The widget sweeps up crumbs in tow.
Bridge form values, now erased,
A tidy state, all data replaced.
With every hop and every click,
The code stays clean—now isn’t that slick?
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.

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)
packages/widget-react/src/public/data/storage.ts (1)

3-12: ```shell
#!/bin/bash

Locate the file defining LocalStorageKey

FILE=$(rg -l "export enum LocalStorageKey")
echo "Found LocalStorageKey enum in: $FILE"

Show its definition (first 200 lines)

sed -n '1,200p' "$FILE"

Search for usages of the potentially missing keys

echo "--- Usages of BRIDGE_SLIPPAGE_PERCENT ---"
rg -n "BRIDGE_SLIPPAGE_PERCENT"
echo "--- Usages of BRIDGE_HISTORY ---"
rg -n "BRIDGE_HISTORY"


</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

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


<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 7a2f8df0588a4cabe47176828c9e8e9075c22d0c and 2dfe45bb9182393c4f2b4585b044803a684e510b.

</details>

<details>
<summary>📒 Files selected for processing (2)</summary>

* `packages/widget-react/src/public/app/WidgetHeader.tsx` (2 hunks)
* `packages/widget-react/src/public/data/storage.ts` (1 hunks)

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>🧬 Code Graph Analysis (2)</summary>

<details>
<summary>packages/widget-react/src/public/data/storage.ts (1)</summary><blockquote>

<details>
<summary>packages/widget-react/src/data/constants.ts (1)</summary>

* `LocalStorageKey` (3-26)

</details>

</blockquote></details>
<details>
<summary>packages/widget-react/src/public/app/WidgetHeader.tsx (1)</summary><blockquote>

<details>
<summary>packages/widget-react/src/public/data/storage.ts (1)</summary>

* `resetBridgeFormValues` (3-12)

</details>

</blockquote></details>

</details>

</details>

<details>
<summary>🔇 Additional comments (2)</summary><blockquote>

<details>
<summary>packages/widget-react/src/public/app/WidgetHeader.tsx (2)</summary>

`9-9`: **LGTM! Clean import integration.**

The import path is correct and follows the expected file structure.

---

`42-46`: **LGTM! Proper integration in disconnect flow.**

The function is appropriately called after the core disconnect logic (`closeWidget()` and `disconnect()`), ensuring form values are cleared as part of the complete disconnect process. This addresses the PR objective effectively.

</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant