Skip to content
This repository was archived by the owner on Jun 1, 2026. It is now read-only.

feat(support): add support-chat domain models#1162

Open
DRadmir wants to merge 3 commits into
mainfrom
support-models
Open

feat(support): add support-chat domain models#1162
DRadmir wants to merge 3 commits into
mainfrom
support-models

Conversation

@DRadmir
Copy link
Copy Markdown
Contributor

@DRadmir DRadmir commented May 26, 2026

What

TypeShare models for the upcoming device support-chat API (Chatwoot-proxied):
SupportConversation, SupportMessage, SupportAgent, and status enums.

Models only — no backend.

Chatwoot mappings the API must handle

  • Direction is FLIPPED (we're user-POV, Chatwoot is agent-POV):
    Chatwoot message_type: 0 (contact) → our outgoing; 1 (agent) → our incoming.
    Filter out message_type: 2/3 (activity/template).
  • Status: Chatwoot pending/snoozedopen; resolvedresolved.
  • Filter: private: true notes, non-text content_type.
  • delivery_status: Chatwoot sent/delivered/readsent. sending is client-only.
  • first_message = first user message (title); last_message = last message (preview); unread_count = user POV (based on contact_last_seen_at).
  • IDs: Chatwoot integers → strings.

TypeShare types for the upcoming device support-chat API:
SupportConversation, SupportMessage, SupportAgent, and status enums.
Models only — no backend logic.
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support-related primitives, including structs and enums for agents, conversations, and messages. The reviewer pointed out inconsistencies where several structs (SupportAgent, SupportConversation, and SupportMessage) are marked with Swift typeshare attributes indicating they are equatable, but their Rust definitions do not derive PartialEq or Eq. Suggestions were provided to add these derives to ensure consistency and support testing.

Comment thread crates/primitives/src/support.rs Outdated
Failed,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The SupportAgent struct is marked with #[typeshare(swift = "Sendable, Equatable")], indicating it should be equatable. However, the Rust struct does not derive PartialEq or Eq. To ensure consistency between the Rust models and the generated Swift models, and to allow equality comparisons in Rust (especially useful for testing), please derive PartialEq and Eq.

Suggested change
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]

Comment thread crates/primitives/src/support.rs Outdated
pub avatar_url: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The SupportConversation struct is marked with #[typeshare(swift = "Sendable, Equatable, Hashable, Identifiable")], but it does not derive PartialEq or Eq in Rust. To align with the Swift typeshare attributes and enable equality comparisons in Rust, please derive PartialEq and Eq.

Suggested change
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]

Comment thread crates/primitives/src/support.rs Outdated
pub unread_count: i32,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The SupportMessage struct is marked with #[typeshare(swift = "Sendable, Equatable")], but it does not derive PartialEq or Eq in Rust. Please derive PartialEq and Eq to ensure consistency with the Swift typeshare definitions and to support equality assertions in Rust tests.

Suggested change
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]

Comment thread crates/primitives/src/support.rs Outdated
pub direction: SupportMessageDirection,
pub delivery_status: SupportMessageDeliveryStatus,
#[serde(skip_serializing_if = "Option::is_none")]
pub agent: Option<SupportAgent>,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

let's do non optional

DRadmir and others added 2 commits May 26, 2026 23:02
… type

Per review: agent shouldn't be optional. New `SupportMessageSender { User,
Agent(SupportAgent) }` ties agent info to the agent case; `SupportMessageDirection`
is removed (sender encodes direction).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants