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

[do not merge] isTyping example with bridge quote state update #3035

Merged
merged 6 commits into from
Aug 19, 2024

Conversation

bigboydiamonds
Copy link
Collaborator

@bigboydiamonds bigboydiamonds commented Aug 16, 2024

Copy link
Contributor

coderabbitai bot commented Aug 16, 2024

Important

Review skipped

Ignore keyword(s) in the title.

Ignored keywords (2)
  • WIP
  • DO NOT MERGE

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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

cloudflare-workers-and-pages bot commented Aug 16, 2024

Deploying sanguine-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: adb8a66
Status: ✅  Deploy successful!
Preview URL: https://3525a36a.sanguine-fe.pages.dev
Branch Preview URL: https://fe-is-typing-replica.sanguine-fe.pages.dev

View logs

Copy link

codecov bot commented Aug 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 25.29346%. Comparing base (e27f2e0) to head (adb8a66).
Report is 1 commits behind head on fe/bridgeQuote-state.

Additional details and impacted files
@@                      Coverage Diff                       @@
##           fe/bridgeQuote-state       #3035         +/-   ##
==============================================================
+ Coverage              20.71326%   25.29346%   +4.58020%     
==============================================================
  Files                       490         781        +291     
  Lines                     42509       56908      +14399     
  Branches                     82          82                 
==============================================================
+ Hits                       8805       14394       +5589     
- Misses                    32769       41027       +8258     
- Partials                    935        1487        +552     
Flag Coverage Δ
packages 90.55118% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

cloudflare-workers-and-pages bot commented Aug 16, 2024

Deploying sanguine with  Cloudflare Pages  Cloudflare Pages

Latest commit: adb8a66
Status: ✅  Deploy successful!
Preview URL: https://83a0b2fb.sanguine.pages.dev
Branch Preview URL: https://fe-is-typing-replica.sanguine.pages.dev

View logs

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This pull request introduces significant changes to the Synapse bridge functionality, focusing on improving state management, input handling, and bridge quote processing. Here are the key points:

  1. Introduced a new bridgeQuote slice in Redux, separating quote-related state from general bridge state for better organization and performance.

  2. Implemented a new isTyping state and debounce mechanism in the InputContainer component to optimize UI updates during user input.

  3. Added new custom hooks: useBridgeSelections, useBridgeValidations, and useIsBridgeApproved for improved code organization and reusability.

  4. Refactored the bridge quote fetching logic into a separate Redux thunk, enhancing error handling and quote processing.

  5. Removed the entire teaser page functionality, including components like FauxBridge, Hero, and ValueProps, suggesting a significant change in the application's structure or presentation.

26 file(s) reviewed, 7 comment(s)
Edit PR Review Bot Settings

dataTestId="bridge-origin-token"
selectedItem={fromToken}
isOrigin={true}
placeholder="Out"
Copy link

Choose a reason for hiding this comment

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

logic: placeholder 'Out' seems incorrect for origin token selector

Comment on lines 1 to 5
import { setFromToken } from '@/slices/bridge/reducer'
import { TokenSelector } from '@/components/ui/TokenSelector'
import { useBridgeState } from '@/slices/bridge/hooks'
import { useFromTokenListArray } from './hooks/useFromTokenListArray'
import { useWalletState } from '@/slices/wallet/hooks'
Copy link

Choose a reason for hiding this comment

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

style: consider grouping imports by external and internal dependencies

Comment on lines 89 to 91
const isBridgeFeeGreaterThanInput = useMemo(() => {
return bridgeQuote.feeAmount === 0n && debouncedFromValueBigInt > 0n
}, [bridgeQuote.feeAmount, debouncedFromValueBigInt])
Copy link

Choose a reason for hiding this comment

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

logic: The logic for isBridgeFeeGreaterThanInput seems incorrect. It returns true when the fee is 0 and the input is greater than 0, which is the opposite of what the name suggests.

Comment on lines 23 to 26
const debouncedSetIsTyping = useCallback(
debounce((value: boolean) => setIsTyping?.(value), 1200),
[setIsTyping]
)
Copy link

Choose a reason for hiding this comment

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

style: Consider moving debouncedSetIsTyping outside the component to avoid recreating it on every render

Comment on lines +28 to +32
const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
setIsTyping?.(true)
debouncedSetIsTyping(false)
handleFromValueChange?.(event)
}
Copy link

Choose a reason for hiding this comment

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

logic: setIsTyping is called immediately with true, then debounced to false. This might lead to unnecessary state updates


const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
setIsTyping?.(true)
debouncedSetIsTyping(false)
Copy link

Choose a reason for hiding this comment

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

style: debouncedSetIsTyping is always called with false. Consider passing the negation of the current typing state instead

)) /
BigInt(originQuery.minAmountOut)

const isUnsupported = AcceptedChainId[fromChainId] ? false : true
Copy link

Choose a reason for hiding this comment

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

style: This could be simplified to const isUnsupported = !AcceptedChainId[fromChainId]

@abtestingalpha abtestingalpha changed the base branch from master to fe/bridgeQuote-state August 16, 2024 21:16
@bigboydiamonds bigboydiamonds marked this pull request as draft August 16, 2024 23:16
Copy link

codecov bot commented Aug 19, 2024

Bundle Report

Changes will increase total bundle size by 6.15kB ⬆️

Bundle name Size Change
sdk-router-@synapsecns/sdk-router-cjs 526.89kB 0 bytes
sdk-router-@synapsecns/sdk-router-esm 254.83kB 0 bytes
synapse-interface-server-cjs 1.33MB 512 bytes ⬆️
synapse-interface-edge-server-array-push 83 bytes 0 bytes
synapse-interface-client-array-push 7.41MB 5.64kB ⬆️
widget-esm-cjs 278.2kB 0 bytes
widget-cjs-esm 276.24kB 0 bytes

@abtestingalpha abtestingalpha marked this pull request as ready for review August 19, 2024 15:08
@abtestingalpha abtestingalpha merged commit ed1d896 into fe/bridgeQuote-state Aug 19, 2024
36 checks passed
@abtestingalpha abtestingalpha deleted the fe/is-typing-replica branch August 19, 2024 15:09
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

(updates since last review)

This PR further refines the implementation of the 'isTyping' state in the bridge and swap components, building upon the changes introduced in the previous review. Key updates include:

  • Increased debounce delay in InputContainer from 300ms to 400ms for updating 'fromValue', potentially improving performance but slightly delaying user feedback.
  • Added 'isTyping' state to SwapInputContainer, including a debounced function for updating swap input value to reduce unnecessary state updates and API calls.
  • Modified SwapTransactionButton to use 'isTyping' as a condition for disabling the button, preventing premature submissions during user input.
  • Reduced AmountInput's setIsTyping debounce delay from 1200ms to 600ms, making the typing state update more responsive.
  • Integrated 'isTyping' state into the StateManagedSwap component, passing it to relevant child components for improved user experience.

These changes aim to enhance the overall responsiveness and user experience of the bridge and swap functionalities while optimizing performance.

5 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings

Comment on lines 104 to +105
setShowValue(swapFromValueString)
debouncedUpdateSwapFromValue(swapFromValueString)
Copy link

Choose a reason for hiding this comment

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

style: setShowValue is called before the debounced update, which may cause a slight UI flicker. Consider updating both simultaneously

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

Successfully merging this pull request may close these issues.

2 participants