Skip to content

Conversation

@richardshiue
Copy link
Contributor

@richardshiue richardshiue commented Jan 8, 2026

Description


Checklist

General

  • I've included relevant documentation or comments for the changes introduced.
  • I've tested the changes in multiple environments (e.g., different browsers, operating systems).

Testing

  • I've added or updated tests to validate the changes introduced for AppFlowy Web.

Feature-Specific

  • For feature additions, I've added a preview (video, screenshot, or demo) in the "Feature Preview" section.
  • I've verified that this feature integrates seamlessly with existing functionality.

Summary by Sourcery

Bug Fixes:

  • Ensure deep links into the native client are opened when appropriate and prevent repeated or missed openings by correctly managing the open-client state flag.

@sourcery-ai
Copy link

sourcery-ai bot commented Jan 8, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts the OpenClient effect logic to trigger the native app deep link based on an internal flag and tab visibility rather than directly on the openClient prop, ensuring the deep link fires correctly and only once per trigger.

Sequence diagram for triggering native deep link from OpenClient effect

sequenceDiagram
  actor User
  participant WebApp
  participant OpenClientEffect
  participant Browser
  participant NativeApp

  User->>WebApp: Click open_in_app_button
  WebApp->>WebApp: Set openClient_prop true
  WebApp->>OpenClientEffect: Render with openClient true

  OpenClientEffect->>OpenClientEffect: prevOpenClientRef.current set to true

  rect rgb(230,230,230)
    OpenClientEffect->>Browser: Listen for tab visibility changes
  end

  Browser-->>OpenClientEffect: Tab becomes visible (isTabVisible true)
  WebApp-->>OpenClientEffect: currentUser available

  OpenClientEffect->>OpenClientEffect: Check isTabVisible && currentUser && prevOpenClientRef.current
  OpenClientEffect->>Browser: window.open(appflowy_flutter_deep_link, _self)
  Browser->>NativeApp: Open appflowy_flutter://open-page
  NativeApp-->>User: Display requested workspace and view

  OpenClientEffect->>OpenClientEffect: prevOpenClientRef.current = false (prevent repeat)
Loading

Flow diagram for updated OpenClient deep link effect logic

flowchart TD
  A[Effect triggered
  dependencies:
  currentWorkspaceId,
  viewId,
  currentUser,
  openClient,
  rowId,
  isTabVisible] --> B{isTabVisible?}
  B -->|No| H[Do nothing]
  B -->|Yes| C{currentUser exists?}
  C -->|No| H
  C -->|Yes| D{prevOpenClientRef.current is true?}
  D -->|No| H
  D -->|Yes| E[Construct appflowy_flutter deep link
  with workspace_id,
  view_id,
  email,
  optional row_id]
  E --> F["window.open(deep_link, _self)"]
  F --> G[Set prevOpenClientRef.current = false
  to prevent repeat trigger]
  G --> H
Loading

File-Level Changes

Change Details Files
Refactor OpenClient useEffect to use an internal ref flag as the trigger for opening the native app deep link and reset it after use.
  • Change the effect condition to require tab visibility, a current user, and the internal ref flag instead of the openClient prop.
  • Always call window.open for the deep link when the ref flag is set, then reset the flag to false to prevent repeated opens.
  • Remove the assignment that mirrored openClient into the ref so that the ref can be controlled externally as a one-shot trigger.
src/components/app/components/AppContextConsumer.tsx

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • The effect dependency array still includes openClient, but the variable is no longer used inside the effect; consider removing it from the dependency list to avoid unnecessary re-renders or confusion.
  • Previously prevOpenClientRef was explicitly synchronized with openClient, but now it’s only set to false; if this ref is still intended to reflect openClient state, you may want to reintroduce that synchronization or rename the ref to better reflect its new purpose.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The effect dependency array still includes `openClient`, but the variable is no longer used inside the effect; consider removing it from the dependency list to avoid unnecessary re-renders or confusion.
- Previously `prevOpenClientRef` was explicitly synchronized with `openClient`, but now it’s only set to `false`; if this ref is still intended to reflect `openClient` state, you may want to reintroduce that synchronization or rename the ref to better reflect its new purpose.

## Individual Comments

### Comment 1
<location> `src/components/app/components/AppContextConsumer.tsx:90` </location>
<code_context>
     }
-
-    prevOpenClientRef.current = openClient;
   }, [currentWorkspaceId, viewId, currentUser, openClient, rowId, isTabVisible]);

   return <></>;
</code_context>

<issue_to_address>
**suggestion:** `openClient` is still in the dependency array but no longer used in the effect body.

Since `openClient` is no longer used in the effect, keeping it in the dependency array causes avoidable re-renders and makes the dependencies misleading. Please either remove it from the array or reintroduce it into the effect if it’s still intended to influence this logic.

```suggestion
  }, [currentWorkspaceId, viewId, currentUser, rowId, isTabVisible]);
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@richardshiue richardshiue force-pushed the fix/deep-link-not-working branch from c814c72 to 84b69ac Compare January 8, 2026 08:23
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