package store

import "encoding/json"

// ── Tree Types (v0.29.0) ────────────────────
// Moved from treepath package to store so MessageStore methods can
// return enriched path/sibling data without import cycles.
// treepath aliases these types for backward compatibility.

// PathMessage represents a single message in an active path, enriched
// with sibling metadata for the frontend branch indicator.
type PathMessage struct {
	ID              string           `json:"id"`
	ParentID        *string          `json:"parent_id"`
	Role            string           `json:"role"`
	Content         string           `json:"content"`
	Model           *string          `json:"model"`
	TokensUsed      *int             `json:"tokens_used,omitempty"`
	ToolCalls       *json.RawMessage `json:"tool_calls,omitempty"`
	Metadata        *json.RawMessage `json:"metadata,omitempty"`
	SiblingCount    int              `json:"sibling_count"`
	SiblingIndex    int              `json:"sibling_index"`
	ParticipantType string           `json:"participant_type,omitempty"`
	ParticipantID   string           `json:"participant_id,omitempty"`
	SenderName      *string          `json:"sender_name,omitempty"`
	SenderAvatar    *string          `json:"sender_avatar,omitempty"`
	CreatedAt       string           `json:"created_at"`
}

// SiblingInfo is a lightweight entry for the siblings listing endpoint.
type SiblingInfo struct {
	ID           string  `json:"id"`
	Role         string  `json:"role"`
	Model        *string `json:"model,omitempty"`
	SiblingIndex int     `json:"sibling_index"`
	Preview      string  `json:"preview"` // first ~80 chars of content
	CreatedAt    string  `json:"created_at"`
}

// MentionResult is the outcome of resolving an @mention token.
// Exactly one of PersonaID, UserID, or ModelID will be non-empty.
type MentionResult struct {
	ModelID          string // resolved model ID (for @model mentions)
	ProviderConfigID string // provider config for model-based mentions
	PersonaID        string // matched persona ID
	PersonaName      string // persona display name (for logging)
	UserID           string // matched user ID (for @user mentions)
}

// UserDisplayInfo holds name + avatar for sender resolution in paths.
type UserDisplayInfo struct {
	Name   string
	Avatar string
}
