Skip to content

Conversation

@appflowy
Copy link
Contributor

@appflowy appflowy commented Dec 2, 2025

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

Handle workspace access errors more granularly and surface detailed no-access information in the request access flow.

Bug Fixes:

  • Ensure unauthorized (invalid token) errors redirect users to the login page instead of showing the request access screen.

Enhancements:

  • Replace the boolean request-access state with a structured error object to carry error code and message through the workspace context.
  • Propagate request access error details into landing and shared request access components so the UI can display more specific access error information.

@sourcery-ai
Copy link

sourcery-ai bot commented Dec 2, 2025

Reviewer's Guide

Refactors workspace access handling to distinguish unauthorized tokens from no-access errors and plumbs detailed access error information through the app context into the RequestAccess UI so it can display backend-provided error messages.

Sequence diagram for workspace access error handling and routing

sequenceDiagram
  actor User
  participant AppShell
  participant useWorkspaceData
  participant BackendAPI
  participant AuthInternal
  participant Router

  User->>AppShell: Open workspace
  AppShell->>useWorkspaceData: initialize_hook
  useWorkspaceData->>BackendAPI: fetchAppOutline()
  BackendAPI-->>useWorkspaceData: error(code, message)

  alt Unauthorized_token_1024
    useWorkspaceData->>AuthInternal: invalidToken()
    useWorkspaceData->>Router: navigate(/login)
    Router-->>User: Show_login_page
  else No_access_1012
    useWorkspaceData->>useWorkspaceData: setRequestAccessError(code, message)
    useWorkspaceData-->>AppShell: requestAccessError_in_state
    AppShell->>AppShell: render_AppContextConsumer_with_error
    AppShell->>User: Show_RequestAccess_page_with_error_message
  else Other_error
    useWorkspaceData->>useWorkspaceData: log_error_and_fallback
    AppShell->>User: Show_generic_error_or_fallback
  end
Loading

Class diagram for updated workspace access error handling

classDiagram
  class RequestAccessError {
    +number code
    +string message
  }

  class useWorkspaceData {
    -View[] outline
    -View[] favoriteViews
    -View[] recentViews
    -View[] trashList
    -DatabaseRelations workspaceDatabases
    -RequestAccessError requestAccessError
    +loadOutline()
    +loadFavoriteViews()
    +loadRecentViews()
    +loadTrashViews()
  }

  class AppBusinessLayer {
    -RequestAccessError requestAccessError
    +AppBusinessLayer(children)
  }

  class AppContextConsumerProps {
    +ReactNode children
    +RequestAccessError requestAccessError
    +string openModalViewId
    +setOpenModalViewId(id)
    +Record_awarenessMap awarenessMap
  }

  class AppContextConsumer {
    +AppContextConsumer(props)
  }

  class RequestAccessProps {
    +RequestAccessError error
  }

  class RequestAccess {
    +RequestAccess(props)
  }

  class RequestAccessContentProps {
    +string viewId
    +string workspaceId
    +RequestAccessError error
  }

  class RequestAccessContent {
    +RequestAccessContent(props)
  }

  useWorkspaceData --> RequestAccessError : uses
  AppBusinessLayer --> useWorkspaceData : consumes_hook
  AppBusinessLayer --> AppContextConsumer : passes_requestAccessError
  AppContextConsumer --> RequestAccess : renders_with_error
  RequestAccess --> RequestAccessContent : passes_error
  RequestAccessContent --> RequestAccessError : reads_error_details
  AppContextConsumer ..> AppContextConsumerProps : props_type
  RequestAccess ..> RequestAccessProps : props_type
  RequestAccessContent ..> RequestAccessContentProps : props_type
Loading

File-Level Changes

Change Details Files
Refine workspace loading error handling to separate unauthorized token errors from no-access errors and store detailed error info.
  • Replace boolean request-access state with a RequestAccessError object or null in the workspace data hook
  • Introduce separate constants for unauthorized (1024) and no-access (1012) error codes
  • On unauthorized errors, invalidate the token and redirect the user to the login page
  • On no-access errors, capture the backend error code and message into RequestAccessError state
src/components/app/hooks/useWorkspaceData.ts
Propagate RequestAccessError through the app’s context and business layer instead of a simple boolean flag.
  • Update AppContextConsumer props to accept a RequestAccessError instead of a boolean
  • Render the RequestAccess page when a RequestAccessError is present, passing the error object through
  • Pass RequestAccessError through AppBusinessLayer to AppContextConsumer
src/components/app/components/AppContextConsumer.tsx
src/components/app/layers/AppBusinessLayer.tsx
Extend the RequestAccess UI components so they can receive and eventually display detailed error data.
  • Define a RequestAccessError-aware prop type for the RequestAccess landing page and forward the error into RequestAccessContent
  • Extend RequestAccessContent props to accept an optional RequestAccessError argument (currently unused, but plumbed through)
src/components/app/landing-pages/RequestAccess.tsx
src/components/app/share/RequestAccessContent.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 there - I've reviewed your changes - here's some feedback:

  • In RequestAccessContent, the error prop is accepted and renamed to _error but never used; either consume the error to drive UI/state or remove the prop to avoid dead code and confusion.
  • The RequestAccessError interface is defined in useWorkspaceData but consumed across multiple UI components; consider moving this type to a shared types/module file to avoid tight coupling of hooks and presentation layers.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `RequestAccessContent`, the `error` prop is accepted and renamed to `_error` but never used; either consume the error to drive UI/state or remove the prop to avoid dead code and confusion.
- The `RequestAccessError` interface is defined in `useWorkspaceData` but consumed across multiple UI components; consider moving this type to a shared types/module file to avoid tight coupling of hooks and presentation layers.

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.

@appflowy appflowy merged commit 88c4347 into main Dec 2, 2025
10 of 12 checks passed
@appflowy appflowy deleted the display_no_access_error branch December 2, 2025 12:29
josue693 pushed a commit to josue693/AppFlowy-Web that referenced this pull request Dec 21, 2025
* chore: display no access error

* chore: add storybook

* chore: fix test
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