Skip to content

Fix/inbox fetch error state - #1211

Open
baokimho wants to merge 3 commits into
ChatbotXIO:mainfrom
baokimho:fix/inbox-fetch-error-state
Open

baokimho wants to merge 3 commits into
ChatbotXIO:mainfrom
baokimho:fix/inbox-fetch-error-state

Conversation

@baokimho

Copy link
Copy Markdown

Summary

Addresses #1158 for the Flow Editor by distinguishing an unavailable inbox fetch from a successful empty inbox result.

Previously, Flow Editor only consumed inboxes, so these states were indistinguishable:

  • inboxes have not finished initializing
  • inboxes are loading
  • inbox fetch failed
  • inbox fetch succeeded with no inboxes

This could make inbox-dependent Flow Editor actions silently look unavailable when the fetch had actually failed.

Changes

  • Added useInboxesState() to expose:

    • inboxes
    • error
    • loading
    • initialized
  • Added inboxesUnavailable to Flow Editor menu data.

  • Treat inbox data as unavailable when:

    • initialization has not completed
    • inboxes are loading
    • inbox fetching failed
  • Keep nodeConfig.menus(...) available during inbox loading/failure instead of suppressing the entire node menu.

  • Gate only the menu entries that actually depend on inbox data:

    • sendTemplateMessage
    • whatsappFlow
  • Keep inbox-independent actions available, including:

    • text/media/file actions
    • whatsappOptionList
    • perform-action entries
  • Scope the inbox error alert to send-message contexts that actually expose inbox-dependent actions.

  • Preserve the existing successful-empty behavior (noTemplatesAvailable).

Tests

Added/updated focused regression coverage for:

  • WhatsApp inbox-unavailable behavior
  • Messenger inbox-unavailable behavior
  • Omnichannel inbox-unavailable behavior
  • inbox-independent actions remaining available
  • whatsappOptionList remaining independent from inbox availability
  • TikTok remaining unaffected
  • successful empty inbox fetch preserving noTemplatesAvailable
  • store-level distinction between successful empty fetch and failed fetch

Validation

  • Flow menu tests: 15 passed
  • Inbox store tests: 9 passed
  • git diff --check: passed

The repository still emits existing TypeScript configuration warnings related to workspace configuration, unrelated to this change.

Out of scope

  • workspace ID/provider lifecycle behavior
  • other inbox consumers outside the Flow Editor
  • retries or changes to inbox store initialization semantics

Copilot AI lite review requested due to automatic review settings September 17, 2026 12:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

It introduces a user-facing error tooltip that surfaces an unlocalized/raw error string without a translated wrapper, which should be adjusted before approval.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

This PR improves the Flow Editor’s handling of inbox fetch failures by exposing richer inbox-store state (error, loading, initialized) and using it to treat inbox-backed Flow menu actions as unavailable when inbox data can’t be trusted—while keeping inbox-independent actions available.

Changes:

  • Added useInboxesState() to expose inbox store state beyond inboxes alone.
  • Introduced inboxesUnavailable in Flow menu data and used it to gate only inbox-dependent menu entries (sendTemplateMessage, whatsappFlow) rather than suppressing menus entirely.
  • Added regression tests ensuring inbox-unavailable scenarios preserve independent actions and that successful-empty fetch remains distinct from failed fetch.
File summaries
File Description
apps/builder/src/features/inboxes/provider/inbox-hook.ts Adds useInboxesState() to expose inboxes + error/loading/initialized for consumers.
apps/builder/src/features/inboxes/provider/tests/inbox-store.test.ts Adds a test ensuring “successful empty” fetch stays distinct from a failed fetch.
apps/builder/src/features/flows/react-flow/nodes/types.ts Extends MenuData with optional inboxesUnavailable flag.
apps/builder/src/features/flows/react-flow/nodes/send-message/menu.tsx Filters out inbox-dependent send-message menu items when inboxesUnavailable is true.
apps/builder/src/features/flows/react-flow/nodes/send-message/tests/menu.test.ts Adds coverage for inbox-unavailable behavior across WhatsApp/Messenger/Omnichannel and TikTok unaffectedness.
apps/builder/src/features/flows/react-flow/nodes/editor.tsx Uses useInboxesState(), computes inboxesUnavailable, passes it into menu builders, and shows an error alert in relevant send-message contexts.
Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread apps/builder/src/features/flows/react-flow/nodes/editor.tsx
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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