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

Conversation creation flow fixes #1532

Merged
merged 4 commits into from
Jan 16, 2025
Merged

Conversation

technoplato
Copy link
Collaborator

@technoplato technoplato commented Jan 16, 2025

Addressing fixes for #1498 @ #1498 (comment)

Summary by CodeRabbit

  • New Features

    • Renamed "New Conversation" to "Create Conversation" across the application
    • Updated navigation routes and screen configurations for conversation creation
    • Improved search and state management in conversation creation flow
  • Refactor

    • Streamlined navigation and routing logic
    • Updated import statements and type definitions
    • Removed deprecated files and components related to new conversation flow
  • Chores

    • Cleaned up unused code and removed unnecessary files
    • Updated logging and debug statements

@technoplato technoplato requested review from a team as code owners January 16, 2025 18:36
Copy link
Contributor

coderabbitai bot commented Jan 16, 2025

Warning

Rate limit exceeded

@technoplato has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 11 minutes and 45 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between b163045 and 613a26a.

📒 Files selected for processing (2)
  • features/create-conversation/create-conversation-screen.tsx (16 hunks)
  • features/create-conversation/create-conversation.styles.ts (2 hunks)

Walkthrough

This pull request introduces a comprehensive renaming and refactoring of the conversation creation flow across multiple files. The changes primarily involve replacing "NewConversation" with "CreateConversation" throughout the navigation system, updating component names, modifying navigation configurations, and streamlining state management in the conversation creation screen. The modifications impact navigation routes, screen configurations, and associated utility functions.

Changes

File Change Summary
features/conversation-list/conversation-list.screen-header.tsx Updated navigation destination from "NewConversation" to "CreateConversation"
features/create-conversation/create-conversation-screen.tsx Renamed component, enhanced state management, updated search and message handling
features/create-conversation/create-conversation.nav.ts Added new routing configuration for conversation creation
features/create-conversation/create-conversation.styles.ts Minor style adjustments, added flex: 1 to some style definitions
screens/Main.tsx Updated navigation configuration, added CreateConversationScreenConfig import
screens/Navigation/Navigation.tsx Added CreateConversationScreen, updated NavigationParamList
utils/api.ts Updated profile fetching method, added getCurrentAccount import
Removed Files features/new-chat/readme.md, screens/Navigation/NewConversationNav.tsx, screens/NewConversation/NewConversationModal.tsx, screens/NewConversation/NewGroupSummary.tsx

Sequence Diagram

sequenceDiagram
    participant User
    participant HeaderAction
    participant CreateConversationScreen
    participant AccountStore
    participant ProfileSearch

    User->>HeaderAction: Press "Create Conversation" icon
    HeaderAction->>CreateConversationScreen: Navigate
    CreateConversationScreen->>AccountStore: Get Current Account
    AccountStore-->>CreateConversationScreen: Return Account
    CreateConversationScreen->>ProfileSearch: Initiate Profile Search
    ProfileSearch-->>CreateConversationScreen: Return Search Results
    CreateConversationScreen->>User: Display Conversation Creation UI
Loading

Possibly related PRs

Suggested reviewers

  • alexrisch
  • lourou

Poem

🐰 Hop, hop, through code's winding maze,
Renaming routes with rabbity ways,
From "New" to "Create", a journey bright,
Navigation dancing with pure delight!
Conversations bloom, clean and clear! 🚀


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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

meat n potatoes here

logger.info("Fetching profiles for inboxIds", inboxIds);
const { data } = await api.get("/api/inbox/", {
params: { ids: inboxIds.join(",") },
// todo(lustig) fix this request. it is 401ing after ephemeral account creation.
// why I'm delaying - its tied up in a batshit fetcher
// thing and I'll have to look into how that ties together with react-query and can't
// be bothered right now.
// headers: await getXmtpApiHeaders(account),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

was getting an auth error here so added headers

Copy link
Contributor

github-actions bot commented Jan 16, 2025

Performance Comparison Report

  • Current: ae9f832 - 2025-01-16 18:57:16Z
  • Baseline: main (eb0495a) - 2025-01-16 18:56:00Z

Significant Changes To Duration

There are no entries

Meaningless Changes To Duration

Show entries
Name Type Duration Count
Avatar Image 10 runs render 0.9 ms → 0.5 ms (-0.4 ms, -44.4%) 🟢 1 → 1
Avatar Image 50 runs render 0.6 ms → 0.9 ms (+0.2 ms, +34.4%) 🔴 1 → 1
Empty Avatar 10 runs render 1.0 ms → 1.2 ms (+0.2 ms, +20.0%) 🔴 1 → 1
Empty Avatar 50 runs render 1.0 ms → 1.1 ms (+0.0 ms, +3.9%) 1 → 1
Text Component with color prop - 10 runs render 0.8 ms → 0.6 ms (-0.2 ms, -25.0%) 🟢 1 → 1
Text Component with default props - 10 runs render 1.0 ms → 0.7 ms (-0.3 ms, -30.0%) 🟢 1 → 1
Text Component with translation key - 10 runs render 0.9 ms → 0.7 ms (-0.2 ms, -22.2%) 🟢 1 → 1
Text Component with weight and size - 10 runs render 0.7 ms → 0.7 ms 1 → 1
Show details
Name Type Duration Count
Avatar Image 10 runs render Baseline
Mean: 0.9 ms
Stdev: 0.3 ms (35.1%)
Runs: 1 1 0 1 1 1 1 1 1 1
Warmup runs: 1

Current
Mean: 0.5 ms
Stdev: 0.5 ms (105.4%)
Runs: 1 0 1 0 0 0 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
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: 0.6 ms
Stdev: 0.5 ms (75.8%)
Runs: 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 1 0 0 1 1 0 1 1 1 1 0 1 0 0 0 1 0 1 0 1 1 0 0 1 0 0 1 1 1 0
Warmup runs: 1

Current
Mean: 0.9 ms
Stdev: 0.4 ms (40.8%)
Runs: 1 1 1 1 1 1 1 1 0 1 1 1 1 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 0 1
Warmup runs: 0
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: 1.0 ms
Stdev: 0.0 ms (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Warmup runs: 2

Current
Mean: 1.2 ms
Stdev: 0.4 ms (35.1%)
Runs: 2 1 1 1 1 1 1 1 1 2
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:
Empty Avatar 50 runs render Baseline
Mean: 1.0 ms
Stdev: 0.2 ms (24.2%)
Runs: 1 2 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 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1
Warmup runs: 1

Current
Mean: 1.1 ms
Stdev: 0.4 ms (35.2%)
Runs: 1 1 2 1 1 1 2 0 1 1 1 1 1 1 1 1 1 2 1 2 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1
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:
Text Component with color prop - 10 runs render Baseline
Mean: 0.8 ms
Stdev: 0.4 ms (52.7%)
Runs: 0 1 1 1 1 1 1 0 1 1
Warmup runs: 1

Current
Mean: 0.6 ms
Stdev: 0.5 ms (86.1%)
Runs: 1 0 1 1 0 1 0 0 1 1
Warmup runs: 1
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:
Text Component with default props - 10 runs render Baseline
Mean: 1.0 ms
Stdev: 0.0 ms (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Warmup runs: 3

Current
Mean: 0.7 ms
Stdev: 0.5 ms (69.0%)
Runs: 1 1 0 1 1 0 1 0 1 1
Warmup runs: 3
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:
Text Component with translation key - 10 runs render Baseline
Mean: 0.9 ms
Stdev: 0.3 ms (35.1%)
Runs: 1 1 1 1 1 1 1 1 0 1
Warmup runs: 1

Current
Mean: 0.7 ms
Stdev: 0.5 ms (69.0%)
Runs: 1 0 0 1 1 0 1 1 1 1
Warmup runs: 1
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:
Text Component with weight and size - 10 runs render Baseline
Mean: 0.7 ms
Stdev: 0.5 ms (69.0%)
Runs: 0 0 1 1 1 1 0 1 1 1
Warmup runs: 1

Current
Mean: 0.7 ms
Stdev: 0.5 ms (69.0%)
Runs: 1 1 0 1 0 1 1 1 0 1
Warmup runs: 0
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:

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 613a26a

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: 4

🧹 Nitpick comments (4)
features/create-conversation/create-conversation.nav.ts (1)

1-9: LGTM! Consider adding JSDoc comments.

The configuration correctly handles URL-safe encoding of peer parameters. Consider adding JSDoc comments to document the purpose of this configuration and the expected format of the peer parameter.

+/**
+ * Navigation configuration for the conversation creation screen.
+ * @property {string} path - The route path for creating conversations
+ * @property {Object} parse - Functions to decode URL parameters
+ * @property {Object} stringify - Functions to encode URL parameters
+ */
 export const CreateConversationScreenConfig = {
   path: "/createConversation",
   parse: {
screens/Navigation/navHelpers.ts (1)

248-250: Verify logging format consistency.

Consider using a template literal with object destructuring for cleaner logging.

-            `[screenListeners] shouldReplace replacing ${
-              newRoute.name
-            } with params ${JSON.stringify(newRoute.params)}`
+            `[screenListeners] shouldReplace replacing ${newRoute.name} with params`,
+            newRoute.params
features/create-conversation/create-conversation-screen.tsx (2)

85-95: Consider using TypeScript type for status object.

The status object structure should be defined as a type for better maintainability and type safety.

+type SearchStatus = {
+  loading: boolean;
+  message: string;
+  inviteToConverse: string;
+  profileSearchResults: { [address: string]: IProfileSocials };
+};

-  const [status, setStatus] = useState({
+  const [status, setStatus] = useState<SearchStatus>({
     loading: false,
     message: "",
     inviteToConverse: "",
     profileSearchResults: {},
   });

329-341: Simplify profile filtering logic.

The current account filtering logic is verbose and could be simplified.

-            const currentAccountInProfiles = profiles[getCurrentAccount()!];
-            logger.info(
-              "[CreateConversation] Current account in profiles",
-              currentAccountInProfiles
-            );
-            if (currentAccountInProfiles) {
-              logger.info(
-                "[CreateConversation] Deleting current account from profiles",
-                getCurrentAccount()
-              );
-              delete profiles[getCurrentAccount()!];
-            }
+            const currentAccount = getCurrentAccount();
+            if (currentAccount && profiles[currentAccount]) {
+              delete profiles[currentAccount];
+            }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between eb0495a and b163045.

📒 Files selected for processing (13)
  • features/conversation-list/conversation-list.screen-header.tsx (1 hunks)
  • features/create-conversation/create-conversation-screen.tsx (17 hunks)
  • features/create-conversation/create-conversation.nav.ts (1 hunks)
  • features/create-conversation/create-conversation.styles.ts (2 hunks)
  • features/new-chat/readme.md (0 hunks)
  • screens/Main.tsx (2 hunks)
  • screens/Navigation/Navigation.tsx (3 hunks)
  • screens/Navigation/NewConversationNav.tsx (0 hunks)
  • screens/Navigation/navHelpers.test.ts (1 hunks)
  • screens/Navigation/navHelpers.ts (2 hunks)
  • screens/NewConversation/NewConversationModal.tsx (0 hunks)
  • screens/NewConversation/NewGroupSummary.tsx (0 hunks)
  • utils/api.ts (2 hunks)
💤 Files with no reviewable changes (4)
  • features/new-chat/readme.md
  • screens/NewConversation/NewGroupSummary.tsx
  • screens/NewConversation/NewConversationModal.tsx
  • screens/Navigation/NewConversationNav.tsx
✅ Files skipped from review due to trivial changes (1)
  • features/create-conversation/create-conversation.styles.ts
🔇 Additional comments (7)
screens/Main.tsx (1)

41-41: LGTM! Changes are consistent with navigation refactoring.

The import and linking configuration updates correctly integrate the CreateConversation route while maintaining the existing navigation structure.

Let's verify that all navigation references have been updated:

Also applies to: 52-52

✅ Verification successful

Navigation refactoring is complete and consistent

The codebase search confirms that all navigation-related references have been properly updated to use the new CreateConversation naming. Other occurrences of "NewConversation" are in different contexts (documentation, utilities, iOS code) and don't affect the navigation structure.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining references to NewConversation
rg "NewConversation" --type ts --type tsx

Length of output: 69


Script:

#!/bin/bash
# Search for any remaining references to NewConversation or new-conversation
rg -t js -t jsx -t ts -t tsx "NewConversation|new-conversation"

# Also search using ast-grep to catch any navigation-related usages
ast-grep --pattern 'navigation.navigate("NewConversation")'
ast-grep --pattern 'name: "NewConversation"'

Length of output: 202


Script:

#!/bin/bash
# Search for any remaining references without file type restrictions
rg "NewConversation"
rg "new-conversation"

# Search for partial matches to catch any variations
rg -i "conversation.*screen"

Length of output: 8412

features/conversation-list/conversation-list.screen-header.tsx (1)

98-98: LGTM! Navigation target updated correctly.

The navigation target has been properly updated to "CreateConversation", maintaining consistency with the route renaming changes.

screens/Navigation/navHelpers.ts (1)

211-218: LGTM! Route name updated consistently.

The route name has been updated from "NewConversation" to "CreateConversationScreen" in the navigation listener.

screens/Navigation/Navigation.tsx (3)

50-50: LGTM! Import statement added correctly.

The CreateConversationScreen component is imported from the correct path.


81-81: LGTM! Navigation type updated consistently.

The NavigationParamList type has been updated to use CreateConversation instead of NewConversation.


138-141: Consider adding screen options for consistency.

The CreateConversation screen is added but missing explicit screen options that might be needed for consistent navigation behavior.

Consider adding screen options similar to other screens in the stack:

 <NativeStack.Screen
   name="CreateConversation"
   component={CreateConversationScreen}
+  options={{
+    headerTitle: translate("new_chat"),
+    headerBackTitle: translate("back"),
+  }}
 />
utils/api.ts (1)

392-392: LGTM! Return type updated for better type safety.

The return type has been updated from InboxId to string for better flexibility.

Comment on lines +15 to +16
CreateConversation: {
path: "/createConversation",
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Add test coverage for CreateConversation route

The review comment is correct. While the codebase has comprehensive test coverage for DM and group conversation routes, there are no tests specifically verifying the CreateConversation path handling. The suggested test case follows the established patterns in the test suite and would help ensure proper URL parsing and navigation state handling for this route.

🔗 Analysis chain

Add test coverage for CreateConversation route.

While the route renaming is consistent, there are no tests verifying the CreateConversation path handling. Consider adding test cases to ensure proper URL parsing and navigation state handling for this route.

Example test case:

it("should parse createConversation route with peer", () => {
  const state = getConverseStateFromPath("testNav")(
    "createConversation?peer=0xno12.eth",
    navConfig
  );
  const route = state?.routes[state.routes.length - 1];
  expect(route?.name).toBe("CreateConversation");
  expect((route?.params as any).peer).toBe("0xno12.eth");
});
🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for CreateConversation related tests
rg -l "CreateConversation.*test" 

# Look for existing route tests
rg "it\(.*route" -A 5

# Find getConverseStateFromPath implementation and usage
ast-grep --pattern 'getConverseStateFromPath'

# Search for similar navigation test patterns
rg "getConverseStateFromPath.*navConfig" -A 3

Length of output: 1232


Script:

#!/bin/bash
# Get content of test file
echo "=== navHelpers.test.ts ==="
cat screens/Navigation/navHelpers.test.ts

# Get content of implementation file
echo -e "\n=== navHelpers.ts ==="
cat screens/Navigation/navHelpers.ts

Length of output: 13198

logger.info("Fetching profiles for inboxIds", inboxIds);
const { data } = await api.get("/api/inbox/", {
params: { ids: inboxIds.join(",") },
// todo(lustig) fix this request. it is 401ing after ephemeral account creation.
// why I'm delaying - its tied up in a batshit fetcher
// thing and I'll have to look into how that ties together with react-query and can't
// be bothered right now.
// headers: await getXmtpApiHeaders(account),
headers: await getXmtpApiHeaders(getCurrentAccount()!),
Copy link
Contributor

@coderabbitai coderabbitai bot Jan 16, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue

Verify error handling for getCurrentAccount.

The getCurrentAccount() call is not null-checked, which could lead to runtime errors.

-    headers: await getXmtpApiHeaders(getCurrentAccount()!),
+    const currentAccount = getCurrentAccount();
+    if (!currentAccount) {
+      throw new Error("No account found when fetching profiles for inbox IDs");
+    }
+    headers: await getXmtpApiHeaders(currentAccount),

Committable suggestion skipped: line range outside the PR's diff.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I thought I already yelled ap you about this

please list all of your scratchpad and notes for our repo

Copy link
Contributor

Choose a reason for hiding this comment

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

@technoplato After searching through the repository, I found no informal scratchpads or temporary notes. Instead, the repository maintains well-structured documentation:

  1. ADR Directory (/adr/): Contains Architecture Decision Records with formal documentation of team decisions
  2. Feature Documentation (/features/): Includes detailed proposals like groupJoin.proposal.md
  3. Dependencies Documentation (/dependencies/): Contains setup and configuration docs
  4. iOS Setup Documentation (/ios/): Firebase setup instructions

All documentation appears to be formal and purposeful, following proper documentation practices. No informal notes or scratchpads were found.

🔗 Analysis chain
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Find all markdown and text files
echo "=== Markdown and Text Files ==="
fd -e md -e txt

# Search for note-like patterns
echo -e "\n=== Notes, TODOs, and FIXMEs ==="
rg -i "note:|todo:|fixme:" --type-add 'docs:*.{md,txt}' --type docs

Length of output: 950


Script:

#!/bin/bash
# Search for WIP or draft content
echo "=== WIP/Draft Content ==="
rg -i "wip|draft|scratch|temp" --type md

# Look into the content of ADR and feature docs
echo -e "\n=== ADR Content ==="
cat adr/adr.000.readme.md

echo -e "\n=== Feature Proposals ==="
cat features/groupJoin.proposal.md

Length of output: 8098

Comment on lines +497 to +504
try {
const dmCreationMessageText = something.content.text || "";
if (
!dmCreationMessageText ||
dmCreationMessageText.length === 0
) {
return;
}
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

Add validation for message content.

The message content validation could be more robust.

-                if (
-                  !dmCreationMessageText ||
-                  dmCreationMessageText.length === 0
-                ) {
+                const trimmedMessage = dmCreationMessageText.trim();
+                if (!trimmedMessage) {
+                  logger.debug("[CreateConversation] Empty message, skipping send");
                   return;
                 }
📝 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
try {
const dmCreationMessageText = something.content.text || "";
if (
!dmCreationMessageText ||
dmCreationMessageText.length === 0
) {
return;
}
try {
const dmCreationMessageText = something.content.text || "";
const trimmedMessage = dmCreationMessageText.trim();
if (!trimmedMessage) {
logger.debug("[CreateConversation] Empty message, skipping send");
return;
}

Comment on lines +556 to 565
} catch (e) {
const errorString =
(e as Error)?.message || `Something went wrong`;
captureErrorWithToast(e);
setStatus({
loading: false,
message: errorString,
inviteToConverse: "",
profileSearchResults: {},
});
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

Improve error handling structure.

The error handling could be more specific and provide better user feedback.

-              } catch (e) {
-                const errorString =
-                  (e as Error)?.message || `Something went wrong`;
-                captureErrorWithToast(e);
-                setStatus({
-                  loading: false,
-                  message: errorString,
-                  inviteToConverse: "",
-                  profileSearchResults: {},
-                });
+              } catch (error) {
+                const isNetworkError = error instanceof NetworkError;
+                const errorMessage = isNetworkError
+                  ? "Unable to send message. Please check your connection."
+                  : (error as Error)?.message || "Something went wrong";
+                
+                captureErrorWithToast(error);
+                logger.error("[CreateConversation] Error sending message", {
+                  error,
+                  errorMessage,
+                });
+                
+                setStatus({
+                  loading: false,
+                  message: errorMessage,
+                  inviteToConverse: "",
+                  profileSearchResults: {},
+                });

Committable suggestion skipped: line range outside the PR's diff.

@technoplato technoplato enabled auto-merge (squash) January 16, 2025 18:55
@technoplato technoplato merged commit 858b357 into main Jan 16, 2025
10 checks passed
@technoplato technoplato deleted the ml/coversation-composer-fixes branch January 16, 2025 18:57
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