<?xml version="1.0" encoding="utf-8"?>
<odoo>

    <!-- Conversation List View -->
    <record id="view_ai_conversation_list" model="ir.ui.view">
        <field name="name">fusion.clock.ai.conversation.list</field>
        <field name="model">fusion.clock.ai.conversation</field>
        <field name="arch" type="xml">
            <list string="AI Conversations" default_order="create_date desc" create="false">
                <field name="title"/>
                <field name="user_id"/>
                <field name="conversation_type"/>
                <field name="create_date"/>
            </list>
        </field>
    </record>

    <!-- Conversation Form View -->
    <record id="view_ai_conversation_form" model="ir.ui.view">
        <field name="name">fusion.clock.ai.conversation.form</field>
        <field name="model">fusion.clock.ai.conversation</field>
        <field name="arch" type="xml">
            <form string="AI Conversation" create="false" edit="false">
                <sheet>
                    <group>
                        <group>
                            <field name="title"/>
                            <field name="user_id"/>
                        </group>
                        <group>
                            <field name="conversation_type"/>
                            <field name="create_date"/>
                        </group>
                    </group>

                    <separator string="Messages"/>
                    <field name="message_ids" nolabel="1">
                        <list create="false" delete="false">
                            <field name="role" decoration-info="role == 'user'"
                                   decoration-success="role == 'assistant'"
                                   decoration-muted="role == 'system'" widget="badge"/>
                            <field name="content"/>
                            <field name="create_date"/>
                        </list>
                    </field>
                </sheet>
            </form>
        </field>
    </record>

    <!-- Conversation Search View -->
    <record id="view_ai_conversation_search" model="ir.ui.view">
        <field name="name">fusion.clock.ai.conversation.search</field>
        <field name="model">fusion.clock.ai.conversation</field>
        <field name="arch" type="xml">
            <search string="Search Conversations">
                <field name="title"/>
                <field name="user_id"/>
                <filter name="manager_query" string="Manager Queries"
                        domain="[('conversation_type', '=', 'manager_query')]"/>
                <filter name="employee_chat" string="Employee Chats"
                        domain="[('conversation_type', '=', 'employee_chat')]"/>
                <filter name="config" string="Configuration"
                        domain="[('conversation_type', '=', 'config')]"/>
                <separator/>
                <filter name="group_type" string="Type"
                        context="{'group_by': 'conversation_type'}"/>
                <filter name="group_user" string="User"
                        context="{'group_by': 'user_id'}"/>
            </search>
        </field>
    </record>

    <!-- Conversation Action -->
    <record id="action_ai_conversation" model="ir.actions.act_window">
        <field name="name">Chat History</field>
        <field name="res_model">fusion.clock.ai.conversation</field>
        <field name="view_mode">list,form</field>
        <field name="search_view_id" ref="view_ai_conversation_search"/>
        <field name="help" type="html">
            <p class="o_view_nocontent_smiling_face">
                No AI conversations yet
            </p>
            <p>
                Conversations with the AI assistant will appear here.
            </p>
        </field>
    </record>

</odoo>
