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

Fabri QA for frames & deeplinks #1098

Merged
merged 3 commits into from
Oct 25, 2024
Merged

Fabri QA for frames & deeplinks #1098

merged 3 commits into from
Oct 25, 2024

Conversation

nmalzieu
Copy link
Contributor

@nmalzieu nmalzieu commented Oct 25, 2024

More deeplink issues fixes

  • if already on the Screen of a convo, do not navigate twice to another convo via deeplink (i.e. avoid showing twice the Alert "Identity not found"
  • re-enable the page Convo not found / Group not found => it was not appearing anymore due to conversationTopic being removed from the context at this commit cc @alexrisch
  • allow characters ' and " to be at around a clickable ENS

Summary by CodeRabbit

  • New Features

    • Enhanced group chat placeholder messaging based on conversation topics.
    • Added conversation topic context to improve child component interactions.
  • Bug Fixes

    • Refined conversation initialization logic for better handling of peer conversations.
  • Chores

    • Updated regular expressions for improved string evaluations related to URLs and patterns.

@nmalzieu nmalzieu requested a review from a team as a code owner October 25, 2024 10:07
Copy link
Contributor

coderabbitai bot commented Oct 25, 2024

Walkthrough

The changes in this pull request involve modifications to three components: GroupChatPlaceholder, Conversation, and regex patterns in utils/regex. The GroupChatPlaceholder component now incorporates a topic-based conditional rendering for displaying messages when no conversation exists. The Conversation component introduces a new topic property to its context, refining conversation initialization logic. Additionally, regex patterns in utils/regex have been updated to enhance boundary conditions for string evaluations.

Changes

File Change Summary
components/Chat/ChatPlaceholder/GroupChatPlaceholder.tsx Added import for isGroupTopic, updated conditional rendering for placeholder text based on topic, and modified ActivityIndicator visibility. Introduced const topic variable.
screens/Conversation.tsx Added topic to conversationContextValue, refined conditions for opening conversations, and updated useEffect hooks for better state management.
utils/regex.ts Updated BOUNDARY_START_LOOKBEHIND and BOUNDARY_END_LOOKAHEAD regex patterns to include additional characters for more comprehensive matching.

Possibly related PRs

  • fix: Render Frame on initial send #1067: The changes in GroupChatPlaceholder.tsx regarding the handling of conversation topics may relate to the updates in Conversation.tsx, where a new topic property is added to the conversation context, enhancing the management of conversation topics.
  • fix: URL Crash  #1084: The modifications in Chat.tsx for handling frames and message rendering could be relevant as they may interact with the logic for displaying messages in GroupChatPlaceholder.tsx, especially in scenarios where conversation topics involve frames.

Suggested labels

2.0.7

Suggested reviewers

  • alexrisch
  • thierryskoda

Poem

In the chat where rabbits play,
Topics hop and dance away.
A placeholder for friends to find,
Conversations intertwined.
With regex tweaks, we’re set to go,
Let’s chat and let the good times flow! 🐇✨


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>, 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 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
Contributor

Performance Comparison Report

  • Current: efa3c83 - 2024-10-25 10:11:17Z
  • Baseline: main (9839dcf) - 2024-10-25 10:10:39Z

Significant Changes To Duration

There are no entries

Meaningless Changes To Duration

Show entries
Name Type Duration Count
Avatar Image 10 runs render 1.4 ms → 1.4 ms 1 → 1
Avatar Image 50 runs render 1.2 ms → 1.0 ms (-0.2 ms, -13.3%) 1 → 1
Empty Avatar 10 runs render 0.9 ms → 1.0 ms (+0.1 ms, +11.1%) 1 → 1
Empty Avatar 50 runs render 0.7 ms → 0.7 ms (-0.0 ms, -5.7%) 1 → 1
Show details
Name Type Duration Count
Avatar Image 10 runs render Baseline
Mean: 1.4 ms
Stdev: 0.5 ms (36.9%)
Runs: 1 2 1 1 2 1 2 2 1 1
Warmup runs: 3

Current
Mean: 1.4 ms
Stdev: 0.5 ms (36.9%)
Runs: 1 2 1 1 1 2 2 2 1 1
Warmup runs: 2
Baseline
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:

Current
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:
Avatar Image 50 runs render Baseline
Mean: 1.2 ms
Stdev: 0.4 ms (33.7%)
Runs: 2 1 1 1 2 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 2 1 1 1 2 1 1 2 1 1 1 1 1 1 1 2 1 1 2 1 1 2 1 1 1 1 1 1 1 2
Warmup runs: 1

Current
Mean: 1.0 ms
Stdev: 0.3 ms (27.2%)
Runs: 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 0 2 1 1 1 1 1 1 1 1 1
Warmup runs: 2
Baseline
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Render issues:

Current
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Render issues:
Empty Avatar 10 runs render Baseline
Mean: 0.9 ms
Stdev: 0.6 ms (63.1%)
Runs: 1 1 1 0 1 0 1 1 1 2
Warmup runs: 70

Current
Mean: 1.0 ms
Stdev: 0.0 ms (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Warmup runs: 8
Baseline
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:

Current
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:
Empty Avatar 50 runs render Baseline
Mean: 0.7 ms
Stdev: 0.5 ms (66.1%)
Runs: 1 1 1 1 1 1 0 0 1 1 1 1 0 1 0 0 1 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 1 1 0 1 1 0 0 0 1 1 0 0 1 0 0
Warmup runs: 0

Current
Mean: 0.7 ms
Stdev: 0.5 ms (72.5%)
Runs: 0 1 1 1 0 0 0 1 0 1 1 1 0 1 1 1 1 1 1 0 1 1 0 1 0 1 1 1 0 1 1 0 1 1 0 0 1 1 0 1 0 0 1 1 1 1 1 1 1 0
Warmup runs: 1
Baseline
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Render issues:

Current
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Render issues:

Render Count Changes

There are no entries

Render Issues

There are no entries

Added Scenarios

There are no entries

Removed Scenarios

There are no entries

Generated by 🚫 dangerJS against c55753b

Copy link
Contributor

@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: 1

🧹 Outside diff range and nitpick comments (3)
utils/regex.ts (1)

3-4: LGTM: Boundary end pattern correctly updated.

The end boundary pattern properly mirrors the start boundary changes, maintaining consistency in quote handling.

Consider grouping similar characters in the regex for better readability:

-const BOUNDARY_END_LOOKAHEAD = /(\s|\)|$|\.|!|\?|\r\n|\r|\n|"|')/.source;
+const BOUNDARY_END_LOOKAHEAD = /(\s|\)|"|'|$|\.|!|\?|\r\n|\r|\n)/.source;
components/Chat/ChatPlaceholder/GroupChatPlaceholder.tsx (1)

79-79: Use defined style instead of inline style

The component has a defined activitySpinner style that should be used instead of the inline style for better maintainability.

-            {!topic && <ActivityIndicator style={{ marginBottom: 20 }} />}
+            {!topic && <ActivityIndicator style={styles.activitySpinner} />}
screens/Conversation.tsx (1)

118-119: LGTM! Consider adding a comment for clarity.

This change correctly prevents duplicate navigation when already in a conversation, addressing the issue with duplicate alerts. Consider adding a comment to explain the purpose:

+      // Prevent opening main conversation if already in a conversation
      !openedMainConvo.current &&
      !conversationTopicRef.current
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 9839dcf and c55753b.

📒 Files selected for processing (3)
  • components/Chat/ChatPlaceholder/GroupChatPlaceholder.tsx (3 hunks)
  • screens/Conversation.tsx (3 hunks)
  • utils/regex.ts (1 hunks)
🔇 Additional comments (5)
utils/regex.ts (2)

1-2: LGTM: Boundary start pattern correctly updated.

The addition of quote characters to the lookbehind pattern properly implements the requirement to allow quotes around clickable links.


Line range hint 7-11: Verify the boundary changes work correctly for all domain patterns.

The boundary pattern changes affect all domain-specific regex patterns. Let's verify the changes work as expected.

Also applies to: 19-27

✅ Verification successful

Let's examine the actual implementation before verifying the pattern changes. The previous test had issues with regex syntax in ripgrep, so we'll first understand how these patterns are actually defined and used in the codebase.


The boundary pattern changes are correctly implemented for all domain patterns

The code inspection reveals that:

  • All domain patterns (LENS_REGEX, ETH_REGEX, FARCASTER_REGEX, CB_ID_REGEX, UNS_REGEX) consistently use the getDomainExpression function
  • The boundary patterns are well-defined with proper handling of:
    • Start boundaries: spaces, parentheses, quotes (both single and double), and line start
    • End boundaries: spaces, parentheses, quotes, line endings, and common punctuation
    • Word content: correctly excludes problematic characters like spaces, slashes, and parentheses
  • The implementation ensures uniform behavior across all domain-specific patterns through the shared getDomainExpression function

The changes work correctly for all domain patterns as they share the same boundary handling logic through the centralized implementation.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Test the updated regex patterns with various quote combinations

# Create a test file with various domain formats
cat << 'EOF' > test_domains.txt
normal.eth
"test.eth"
'test.eth'
(test.eth)
test.lens
"test.lens"
'test.fc'
(test.cb.id)
EOF

# Use ripgrep to verify the patterns match correctly
echo "Testing ETH domains:"
rg "(\s|\(|\"|')([^()/\s]*\.eth)(\s|\)|\$|\.|!|\?|\r\n|\r|\n|\"|')" test_domains.txt

echo -e "\nTesting LENS domains:"
rg "(\s|\(|\"|')([^()/\s]*\.lens)(\s|\)|\$|\.|!|\?|\r\n|\r|\n|\"|')" test_domains.txt

echo -e "\nTesting Farcaster domains:"
rg "(\s|\(|\"|')([^()/\s]*\.fc)(\s|\)|\$|\.|!|\?|\r\n|\r|\n|\"|')" test_domains.txt

Length of output: 1030


Script:

#!/bin/bash
# Let's examine the actual regex patterns in the codebase first
echo "Searching for regex pattern definitions:"
rg "(?:const|let|var).*(?:LENS_REGEX|ETH_REGEX|FC_REGEX)" -A 3

echo -e "\nSearching for getDomainExpression usage:"
rg "getDomainExpression" -A 2

echo -e "\nLooking for boundary constants:"
rg "(?:const|let|var).*(?:BOUNDARY_START|BOUNDARY_END|WORD_CONTENT)" -A 1

Length of output: 2109

components/Chat/ChatPlaceholder/GroupChatPlaceholder.tsx (2)

6-6: LGTM: Clean implementation of topic-based error handling

The addition of isGroupTopic import and topic context usage effectively supports the PR objective of re-enabling the "Convo not found" and "Group not found" pages.

Also applies to: 29-29


Line range hint 29-85: Verify integration with deeplink navigation

While the error page implementation looks correct, we should verify that this component properly integrates with the deeplink navigation fix mentioned in the PR objectives.

✅ Verification successful

Let me analyze the navigation integration with a different approach. The previous command failed due to file type specification, so I've broadened the search with correct file extensions and also focused on the component's directory for navigation-related code.


I see navigation-related code in various Chat components, but I need to verify specifically how the deeplink navigation interacts with the GroupChatPlaceholder component. Let's search for deeplink handlers and the navigation setup related to this component.


Based on the search results, I can now generate a final response as we have sufficient information about the deeplink navigation implementation and its interaction with the component.

The GroupChatPlaceholder component correctly integrates with deeplink navigation

The implementation properly supports the deeplink navigation fix through:

  • The component's error states align with the navigation system's group deeplink handling (group?groupId=...)
  • The placeholder's topic-based rendering (isGroupTopic(topic)) matches the group navigation state parsing in navHelpers.ts
  • Error messages are correctly displayed while the navigation state is being processed (opening_conversation during loading)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for deeplink handling logic that might interact with this component
rg -l "deeplink|navigation" --type tsx

Length of output: 68


Script:

#!/bin/bash
# Search for deeplink handling logic that might interact with this component, using broader file extensions
rg -l "deeplink|navigation" --type ts --type tsx --type jsx --type js

# Also search for any routing or navigation related imports/usage in the component's directory
rg -A 3 "import.*[Nn]avigation|useNavigation|deeplink" ./components/Chat

Length of output: 6525


Script:

#!/bin/bash
# Let's check the navigation implementation in the screens directory and any potential deeplink handlers
rg -A 5 "deeplink|Deeplink" .

# Also check for the specific navigation setup that might handle the group chat routing
rg -A 5 "GroupChatPlaceholder|ChatPlaceholder" ./screens

Length of output: 3990

screens/Conversation.tsx (1)

Line range hint 290-305: LGTM! Verify GroupChatPlaceholder usage.

The addition of topic to the conversation context correctly restores the functionality for error pages. This change aligns with React best practices and properly maintains the dependency array.

Let's verify the GroupChatPlaceholder component is correctly consuming this context:

✅ Verification successful

Based on the search results, I can now generate the final response since I have found sufficient evidence about how the topic is being consumed in GroupChatPlaceholder:

Topic is correctly consumed in GroupChatPlaceholder using useConversationContext

The GroupChatPlaceholder component is properly consuming the topic from ConversationContext using the useConversationContext hook:

// components/Chat/ChatPlaceholder/GroupChatPlaceholder.tsx
const topic = useConversationContext("topic");

This implementation correctly uses the context selector pattern to access the topic value that was added to the conversation context.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify GroupChatPlaceholder uses the topic from context
# Expected: Find usage of topic from ConversationContext in GroupChatPlaceholder

ast-grep --pattern 'const { topic } = useContext(ConversationContext)' 

Length of output: 72


Script:

#!/bin/bash
# Let's try a broader search for GroupChatPlaceholder component and its context usage
rg -A 5 "GroupChatPlaceholder" 

# Also search for any usage of ConversationContext
rg -A 5 "ConversationContext"

# And specifically look for topic usage in components
ast-grep --pattern 'useContext($context)' 

Length of output: 35689

Comment on lines +81 to +85
{topic
? isGroupTopic(topic)
? translate("group_not_found")
: translate("conversation_not_found")
: translate("opening_conversation")}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider extracting placeholder text logic for better readability

While the logic correctly implements the error message requirements, the nested ternary operators could be simplified for better maintainability.

+            const getPlaceholderText = () => {
+              if (!topic) return translate("opening_conversation");
+              return isGroupTopic(topic)
+                ? translate("group_not_found")
+                : translate("conversation_not_found");
+            };
             <Text style={styles.chatPlaceholderText}>
-              {topic
-                ? isGroupTopic(topic)
-                  ? translate("group_not_found")
-                  : translate("conversation_not_found")
-                : translate("opening_conversation")}
+              {getPlaceholderText()}
             </Text>
📝 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
{topic
? isGroupTopic(topic)
? translate("group_not_found")
: translate("conversation_not_found")
: translate("opening_conversation")}
const getPlaceholderText = () => {
if (!topic) return translate("opening_conversation");
return isGroupTopic(topic)
? translate("group_not_found")
: translate("conversation_not_found");
};
<Text style={styles.chatPlaceholderText}>
{getPlaceholderText()}
</Text>

<Text style={styles.chatPlaceholderText}>
{translate("opening_conversation")}
{topic
? isGroupTopic(topic)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should always be a group topic as it's in the GroupChatPlaceholder

Copy link
Contributor Author

@nmalzieu nmalzieu Oct 25, 2024

Choose a reason for hiding this comment

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

@alexrisch The check to display ChatPlaceholder or GroupChatPlaceholder is currently on conversation?.isGroup so it only works if the conversation was found. Do you wanna change it to isGroupTopic(conversationTopic) ?

@alexrisch alexrisch merged commit 393cff8 into main Oct 25, 2024
6 checks passed
@alexrisch alexrisch deleted the noe/fix-more-deeplinks branch October 25, 2024 15:51
technoplato pushed a commit that referenced this pull request Dec 17, 2024
* Fabri QA for frames & deeplinks

* also allow ' & " at beginning

* comments
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.

2 participants