On this page

Admin list → thread

Giữ danh tính, kênh và state AI rõ ràng khi nhân viên chuyển hội thoại.

Copy page as MarkdownRead Markdown ↗

Key rules

  • Admin: mỗi hàng InboxConversationItem hiện avatar kèm icon kênh, tên, preview, thời gian và chấm chưa đọc.
  • Admin: chiều cao hàng cố định theo ROW_HEIGHT để vị trí cuộn của list được giữ chính xác khi list cập nhật.
  • Admin: hàng là button có aria-label bằng tên hiển thị; Enter và Space mở hội thoại, mũi tên chưa chuyển hàng (xem Target).
  • Admin: thread đang nạp hiện LoadingSkeleton và đánh dấu aria-busy.
On this page

Use when / Avoid

Dùng khi nhân viên xử lý nhiều hội thoại liên tục và cần chọn đúng khách rồi quay lại đúng vị trí list. Chỉ một hàng cho mỗi hội thoại; state AI hiện bằng icon trên avatar.

Use instead

Component Use when
InboxConversationList Danh sách hội thoại ảo hóa, giữ vị trí cuộn.
InboxConversationItem Một hàng hội thoại với avatar, tên, preview và thời gian.

Entry points

Surface Owner
Admin InboxConversationList render InboxConversationItem cho từng hàng ảo hóa.

Flow

Surface Step Trigger UI shown Component Copy + i18n key Timing
Admin Tải list listLoading hoặc loadingFilter Lớp phủ mờ cùng Spinner Spinner Không có chuỗi Đến khi cờ tải tắt
Admin Chọn hàng Click, hoặc Enter / Space trên hàng Hội thoại mở, hàng được đánh dấu selected Listbox Tên hiển thị của khách Đồng bộ
Admin Cuộn tới hàng convoId đổi Hàng đang chọn cuộn mượt vào giữa rowVirtualizer Không có chuỗi Cuộn smooth
Admin Nạp thread adapterLoading bật Skeleton thay cho tin nhắn, vùng thread aria-busy LoadingSkeleton Loading messages Đến khi adapterLoading tắt

Edge cases

Surface Case Behaviour
Admin List rỗng isEmpty: có lỗi thì ConversationListError, còn lại EmptyConversationList.
Admin List cập nhật realtime Hàng trên cùng được ghim lại, scrollTop chỉ đổi khi lệch hơn 0.5.
Admin Chọn nhiều isBulkMode: checkbox hiện, hàng role listitem, menu hành động ẩn.
Admin Có bản nháp Preview hiện [Draft] thay cho tin cuối.
Admin Mobile Badge kênh hiện cạnh tên và không có menu hành động.

Live preview

Admin

Standard
LightDarkDesktopMobile

Danh sách 24 hội thoại và thread đúng khổ Admin. Chọn hàng để nạp thread; New conversation arrives giữ vị trí hàng đang xem. Mobile dùng Back để về đúng hàng. Mũi tên chưa chuyển hàng.

Show code
chatty-pattern-admin-list-thread.element.jsWrap code linesCopy
import '@avada/chatty-ui/tokens/admin.css';
import {IconChevronLeft, EmailIcon} from '@avada/chatty-ui/elements/icon-glyphs.js';
import {html, render} from 'lit';
import {ref} from 'lit/directives/ref.js';
import {IconClose, IconMessage} from '@avada/chatty-ui/elements/icon-glyphs.js';
import '@avada/chatty-ui/elements/surface.js';
import '@avada/chatty-ui/elements/avatar.js';
import '@avada/chatty-ui/elements/badge.js';
import '@avada/chatty-ui/elements/icon-button.js';
import '@avada/chatty-ui/elements/launcher.js';
import '@avada/chatty-ui/elements/button.js';
import {sameGroup} from '@avada/chatty-ui/behaviors/messages.js';

// Reference viewport: 1280 × 900 desktop, 390 × 900 mobile.
const sizes = {
  classic: {width: 400, height: 700},
  'ai-mode': {width: 820, height: 657},
  admin: {width: 527, height: 842}
};
const question = {
  id: 'question',
  senderType: 'customer',
  text: 'Can you help me?',
  createdAt: '2026-01-15T10:00:00Z'
};

/** Viewport-relative sizing survives the initial hidden iframe layout. */
function widgetSize(surface) {
  const mode = new URLSearchParams(location.search).get('mobile');
  const isMobile = mode === null ? innerWidth < 900 : mode === 'true';
  const width = `min(${sizes[surface].width}px, max(0px, 100vw - 40px))`;
  const height = isMobile
    ? `min(${surface === 'admin' ? 848 : 888}px, round(down, calc(${width} * 2.2), 1px))`
    : `${sizes[surface].height}px`;
  return {...sizes[surface], height, mobile: isMobile};
}

/** Local immutable message state with real subscriptions for live previews. */
function fixtureStore(initial) {
  let state = {messages: initial};
  const listeners = new Set();
  return {
    getState: () => state,
    subscribe(listener) {
      listeners.add(listener);
      return () => listeners.delete(listener);
    },
    setMessages(messages) {
      state = {messages};
      listeners.forEach(listener => listener());
    }
  };
}

/** Appends the viewer message without replacing the existing conversation. */
function appendViewer(store, surface, text) {
  const message = {
    id: `viewer-${store.getState().messages.length}`,
    senderType: surface === 'admin' ? 'agent' : 'customer',
    senderMeta: {name: surface === 'admin' ? 'Alex' : 'You'},
    text,
    createdAt: new Date().toISOString()
  };
  store.setMessages([...store.getState().messages, message]);
}

/**
 * One shell owns surface sizing, header, thread and composer for every pattern.
 * @param {string} surface
 * @param {Object} store
 * @param {Object} strings
 * @param {Object} content
 * @param {Function} renderMessage
 * @param {Function} onSend
 * @param {Object} registry
 * @param {boolean} composerHidden
 * @param {string} title
 * @param {Object} headerStart
 * @param {Object} headerActions
 * @param {boolean} sheet
 * @param {string | null} status
 * @returns {Object}
 */
function patternShell({
  surface,
  store,
  strings = {header: 'Store assistant', message: 'Message', send: 'Send'},
  content,
  renderMessage,
  onSend,
  registry,
  title,
  headerStart,
  headerActions,
  status = 'online',
  sheet = false,
  composerHidden = false
}) {
  const size = widgetSize(surface);
  const mobileSheet = sheet && size.mobile;
  if (mobileSheet) {
    size.width = 'none';
    size.height = 'calc(100dvh - 12px)';
  }
  const toggle = (event, closed) => {
    const frame = event.currentTarget.closest('[data-pattern-frame]');
    const panel = frame.querySelector('chatty-surface');
    const launcher = frame.querySelector('[data-pattern-launcher]');
    panel.hidden = closed;
    frame.dataset.closed = String(closed);
    const background = frame.querySelector('[data-sheet-page]');
    if (background) background.inert = !closed && surface === 'ai-mode';
    launcher.hidden = !closed;
    if (closed) {
      launcher.style.insetBlockEnd = `${Math.max(surface === 'ai-mode' ? 40 : 16, frame.getBoundingClientRect().bottom - innerHeight + 20)}px`;
      launcher.focus({preventScroll: true});
    } else {
      const composer = panel.querySelector('chatty-composer');
      const input = !composer.hidden
        ? composer.renderRoot.querySelector('textarea')
        : (panel
            .querySelector('chatty-contact-form:not([hidden])')
            ?.renderRoot.querySelector('chatty-text-field') ??
          panel.querySelector('form chatty-text-field') ??
          panel.querySelector('[data-welcome-invitation]:not([hidden]) chatty-button') ??
          panel
            .querySelector('chatty-pre-chat:not([hidden])')
            ?.renderRoot.querySelector('chatty-button'));
      input?.focus({preventScroll: true});
    }
  };
  const sender = message => {
    const content = renderMessage?.(message) ?? {};
    const messages = store.getState().messages;
    const previous = messages[messages.indexOf(message) - 1];
    if (message.senderType !== 'bot' || sameGroup(message, previous)) return content;
    return {
      ...content,
      sender: html`<span style="display:inline-flex;align-items:center;gap:6px"
        ><chatty-avatar size="sm" label="Assistant">A</chatty-avatar
        >${content.sender ?? message.senderName ?? message.senderMeta?.name ?? 'Assistant'}</span
      >`
    };
  };
  return html`<style>
      [data-pattern-frame] {
        display: flex;
        position: relative;
        justify-content: center;
        inline-size: 100%;
        min-inline-size: 0;
      }
      [data-pattern-frame='classic'] {
        justify-content: flex-end;
      }
      [data-pattern-frame] chatty-surface::part(header) {
        padding: 0;
      }
      [data-pattern-frame='classic'] chatty-surface::part(header),
      [data-pattern-frame='ai-mode'] chatty-surface::part(header) {
        border-bottom-width: 0;
      }
      [data-pattern-frame] [hidden] {
        display: none !important;
      }
      [data-pattern-header] {
        display: flex;
        align-items: center;
        gap: 10px;
        box-sizing: border-box;
        min-inline-size: 0;
        block-size: 52px;
        padding: 0 16px;
      }
      [data-pattern-frame='classic'] [data-pattern-header] {
        block-size: 56px;
        background: var(--chatty-color-accent);
        color: var(--chatty-color-on-accent);
      }
      [data-pattern-frame='classic'] [data-pattern-header] chatty-icon-button {
        --chatty-color-border-focus: var(--chatty-color-on-accent);
      }
      [data-pattern-frame='admin'] [data-pattern-header] {
        block-size: 68px;
        padding: 8px 12px;
      }
      [data-pattern-header] chatty-avatar {
        --chatty-avatar-size: 32px;
      }
      [data-pattern-frame='classic'] [data-pattern-header] chatty-avatar {
        --chatty-avatar-background: #fff;
      }
      [data-pattern-frame='classic'] [data-pattern-header] chatty-avatar::part(base) {
        color: #303030;
        border: 1px solid #767676;
      }
      [data-pattern-actions] {
        display: flex;
        align-items: center;
        gap: 8px;
      }
      [data-pattern-title] {
        flex: 1;
        min-inline-size: 0;
        display: flex;
        flex-direction: column;
      }
      [data-pattern-frame='admin'] [data-pattern-title] {
        gap: 4px;
      }
      [data-pattern-frame='admin'] [data-pattern-title] strong {
        display: flex;
        align-items: center;
        min-block-size: 28px;
        font: var(--p-font-weight-semibold, 650) var(--p-text-heading-md-font-size, 14px) /
          var(--p-text-heading-md-font-line-height, 20px) var(--p-font-family-sans, system-ui);
      }
      [data-pattern-title] strong {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      [data-pattern-header] chatty-icon-button {
        --chatty-icon-button-size: 32px;
        --chatty-icon-button-color: currentColor;
      }
      @media (max-width: 899px), (pointer: coarse) {
        [data-pattern-header] chatty-icon-button {
          --chatty-icon-button-size: 44px;
        }
      }
      [data-pattern-launcher] {
        position: absolute;
        inset-inline-end: 0;
        inset-block-end: 0;
      }
      [data-pattern-frame='ai-mode'] [data-pattern-launcher] {
        inset-inline-end: auto;
        inset-inline-start: 50%;
        transform: translateX(-50%);
      }
      [data-pattern-frame='classic'] [data-pattern-launcher] {
        --chatty-icon-button-size: 56px;
        border-radius: 50%;
        background: var(--chatty-color-accent);
        --chatty-icon-button-color: var(--chatty-color-on-accent);
      }
      [data-sheet-mobile='true'] {
        position: fixed;
        inset: 0;
        inline-size: 100vw;
      }
      [data-sheet-mobile='true'] chatty-surface::part(base) {
        border-radius: 16px 16px 0 0;
      }
      [data-sheet-mobile='true'] chatty-surface {
        position: relative;
        z-index: 2;
        margin-block-start: 12px;
      }
      [data-sheet-page],
      [data-sheet-scrim] {
        position: absolute;
        inset: 0;
        box-sizing: border-box;
      }
      [data-sheet-page] {
        padding: 20px;
        background: var(--chatty-color-bg-surface);
        color: var(--chatty-color-text);
      }
      [data-sheet-scrim] {
        z-index: 1;
        border: 0;
        background: rgb(0 0 0 / 40%);
        animation: sheet-scrim 400ms ease;
      }
      [data-sheet-mobile='true'][data-closed='true'] [data-sheet-scrim] {
        display: none;
      }
      [data-sheet-mobile='true'] [data-pattern-launcher] {
        z-index: 3;
      }
      @keyframes sheet-scrim {
        from {
          opacity: 0;
        }
        to {
          opacity: 1;
        }
      }
      @media (prefers-reduced-motion: reduce) {
        [data-sheet-scrim] {
          animation: none;
        }
      }
    </style>
    <div
      data-pattern-frame=${surface}
      data-sheet-mobile=${String(mobileSheet)}
      data-closed="false"
      style=${`block-size:calc(${size.height} + ${mobileSheet ? 12 : 0}px)`}
    >
      ${
        mobileSheet
          ? html`<div data-sheet-page .inert=${surface === 'ai-mode'}>
                <p>Example storefront</p>
                <chatty-button
                  variant="secondary"
                  type="button"
                  @click=${event => {
                    event.currentTarget.textContent = 'Products opened';
                  }}
                >
                  Browse products
                </chatty-button>
              </div>
              ${surface === 'ai-mode' ? html`<button type="button" data-sheet-scrim tabindex="-1" aria-label="Close chat background" @click=${event => toggle(event, true)}></button>` : ''}`
          : ''
      }
      <chatty-surface
        data-chatty-surface=${surface}
        data-chatty-theme=${surface === 'admin' ? 'light' : (document.documentElement.dataset.chattyTheme ?? document.documentElement.dataset.theme ?? 'light')}
        style=${`inline-size:100%;max-inline-size:${mobileSheet ? 'none' : `${size.width}px`};--chatty-surface-height:${size.height}`}
        .store=${store}
        .registry=${registry ?? null}
        viewer-type=${surface === 'admin' ? 'agent' : 'customer'}
        .selfTypes=${surface === 'admin' ? ['agent', 'bot'] : null}
        .renderMessage=${sender}
      >
        <div slot="header" data-pattern-header>
          ${headerStart ?? ''}
          ${surface === 'admin' ? '' : html`<chatty-avatar label="Store" .status=${status}>S</chatty-avatar>`}
          <span data-pattern-title
            ><strong
              >${title ?? (surface === 'admin' ? 'Customer conversation' : strings.header)}</strong
            >${surface === 'admin' ? html`<chatty-badge size="sm" variant="secondary" style="align-self:flex-start">Customer</chatty-badge>` : status == null ? '' : html`<small data-pattern-status>${status === 'online' ? 'Open' : 'Closed'}</small>`}</span
          >
          <span data-pattern-actions>${headerActions ?? ''}</span>
          ${
            surface === 'admin'
              ? ''
              : html`<chatty-icon-button label="Close panel" @click=${event => toggle(event, true)}
                  >${IconClose()}</chatty-icon-button
                >`
          }
        </div>
        <chatty-thread .strings=${{bot: 'Assistant', ...strings}}></chatty-thread>${content ?? ''}
        <chatty-composer
          slot="footer"
          ?hidden=${composerHidden}
          .label=${strings.message}
          .sendLabel=${strings.send}
          @chatty-send=${event => {
            appendViewer(store, surface, event.detail.text);
            if (onSend) onSend(event.detail.text, event.currentTarget);
            else if (surface !== 'admin')
              store.setMessages([
                ...store.getState().messages,
                {
                  id: `fixture-${store.getState().messages.length}`,
                  senderType: 'bot',
                  text: `You asked: “${event.detail.text}”. I can help with that.`,
                  hasEventTime: false
                }
              ]);
          }}
        ></chatty-composer> </chatty-surface
      >${
        surface === 'admin'
          ? ''
          : surface === 'ai-mode'
            ? html`<chatty-launcher
                data-pattern-launcher
                hidden
                label="Open chat"
                @chatty-open=${event => toggle(event, false)}
                >${IconMessage({size: 20, slot: 'icon'})}Ask a question</chatty-launcher
              >`
            : html`<chatty-icon-button
                data-pattern-launcher
                hidden
                size="lg"
                label="Open chat"
                @click=${event => toggle(event, false)}
                >${IconMessage({size: 24})}</chatty-icon-button
              >`
      }
    </div>`;
}

import '@avada/chatty-ui/elements/skeleton.js';
import '@avada/chatty-ui/elements/icon.js';
export function Standard() {
  const store = fixtureStore([question]);
  const mode = new URLSearchParams(location.search).get('mobile');
  const mobile = mode === null ? innerWidth < 768 : mode === 'true';
  let rows = Array.from({length: 24}, (_, i) => ({
    id: i + 1,
    name: i ? `Customer ${i + 1}` : 'Alex Morgan',
    unread: i > 0 && i % 3 === 0,
    ai: i % 4 === 0
  }));
  let selected = 1;
  let owner;
  let request = 0;
  let listAnchor = null;
  const conversations = new Map();
  const recordAnchor = () => {
    const top = owner.querySelector('[data-conversation-list]').scrollTop;
    if (top <= 0.5) return null;
    return {id: rows[Math.floor(top / 64)]?.id, delta: top % 64};
  };
  const restoreAnchor = anchor => {
    const index = anchor ? rows.findIndex(row => row.id === anchor.id) : 0;
    owner.querySelector('[data-conversation-list]').scrollTop =
      Math.max(0, index) * 64 + (anchor?.delta ?? 0);
  };
  const drawList = () =>
    render(
      html`${rows.map(
        row =>
          html` <button
            type="button"
            data-conversation=${row.id}
            aria-label=${row.name}
            aria-description=${[row.unread ? 'Unread' : 'Read', row.ai ? 'AI processing' : ''].filter(Boolean).join(', ')}
            aria-current=${String(selected === row.id)}
            @click=${() => open(row)}
          >
            <span data-row-avatar
              ><chatty-avatar label=${row.name}>${row.name[0]}</chatty-avatar>
              <span data-channel aria-hidden="true">${EmailIcon({size: 12})}</span>
              ${
                row.ai
                  ? html`<chatty-icon size="sm" label="AI processing"
                      ><svg
                        width="20"
                        height="20"
                        fill="currentColor"
                        aria-hidden="true"
                        viewBox="0 0 20 20"
                      >
                        <path
                          d="M5.702 4.253a.625.625 0 0 1 1.096 0l.196.358c.207.378.517.688.895.895l.358.196a.625.625 0 0 1 0 1.097l-.358.196a2.25 2.25 0 0 0-.895.894l-.196.359a.625.625 0 0 1-1.096 0l-.196-.359a2.25 2.25 0 0 0-.895-.894l-.358-.196a.625.625 0 0 1 0-1.097l.358-.196a2.25 2.25 0 0 0 .895-.895l.196-.358Z"
                        />
                        <path
                          fill-rule="evenodd"
                          d="M12.948 7.89c-.18-1.167-1.852-1.19-2.064-.029l-.03.164a3.756 3.756 0 0 1-3.088 3.031c-1.15.189-1.173 1.833-.03 2.054l.105.02a3.824 3.824 0 0 1 3.029 3.029l.032.165c.233 1.208 1.963 1.208 2.196 0l.025-.129a3.836 3.836 0 0 1 3.077-3.045c1.184-.216 1.12-1.928-.071-2.107a3.789 3.789 0 0 1-3.18-3.154Zm-.944 6.887a5.34 5.34 0 0 1 2.542-2.647 5.305 5.305 0 0 1-2.628-2.548 5.262 5.262 0 0 1-2.488 2.508 5.329 5.329 0 0 1 2.574 2.687Z"
                        /></svg
                    ></chatty-icon>`
                  : ''
              }
            </span>
            <span data-row-text><strong>${row.name}</strong><span>Where is my order?</span></span>
            <span data-row-time
              >10:42<span data-unread ?hidden=${!row.unread} aria-label="Unread"></span
            ></span>
          </button>`
      )}`,
      owner.querySelector('[data-conversation-list]')
    );
  const open = row => {
    const surface = owner.querySelector('chatty-surface');
    const composer = surface.querySelector('chatty-composer');
    if (!surface.inert)
      conversations.set(selected, {messages: store.getState().messages, draft: composer.value});
    if (!mobile || owner.dataset.threadOpen !== 'true') listAnchor = recordAnchor();
    const conversation = conversations.get(row.id) ?? {
      messages: [{...question, text: `Hello, I am ${row.name}. Where is my order?`}],
      draft: ''
    };
    composer.value = conversation.draft;
    selected = row.id;
    rows = rows.map(item => (item.id === row.id ? {...item, unread: false} : item));
    drawList();
    owner.dataset.threadOpen = 'true';
    owner.querySelector('[data-pattern-title] strong').textContent = row.name;
    surface.setAttribute('aria-busy', 'true');
    surface.inert = true;
    store.setMessages([]);
    const current = ++request;
    setTimeout(() => {
      if (!owner.isConnected || current !== request) return;
      store.setMessages(conversation.messages);
      surface.removeAttribute('aria-busy');
      surface.inert = false;
      if (mobile) owner.querySelector('[data-admin-back]').focus({preventScroll: true});
    }, 450);
  };
  return html`<style>
      [data-admin-list] {
        display: flex;
        gap: 6px;
        max-inline-size: 793px;
        inline-size: 100%;
        margin: auto;
        min-inline-size: 0;
      }
      [data-admin-list] [hidden] {
        display: none !important;
      }
      [data-conversation-list] {
        box-sizing: border-box;
        flex: 0 0 260px;
        height: 842px;
        overflow: auto;
        overflow-anchor: none;
        padding: 4px;
        background: #fff;
        border: 1px solid #e3e3e3;
        scrollbar-gutter: stable;
      }
      [data-conversation-list] button {
        box-sizing: border-box;
        display: flex;
        align-items: center;
        gap: 8px;
        width: 100%;
        height: 64px;
        padding: 8px;
        border: 0;
        border-radius: 6px;
        background: #fff;
        text-align: left;
        color: #303030;
        font: 13px/20px system-ui;
        cursor: pointer;
      }
      [data-conversation-list] button[aria-current='true'] {
        background: #ebebeb;
      }
      [data-conversation-list] button:focus-visible {
        outline: 2px solid #005bd3;
        outline-offset: -2px;
      }
      [data-row-avatar] {
        position: relative;
        flex-shrink: 0;
      }
      [data-row-avatar] chatty-icon {
        position: absolute;
        left: -2px;
        top: -2px;
        background: white;
        border-radius: 50%;
        color: #616161;
      }
      [data-channel] {
        position: absolute;
        right: -2px;
        bottom: -2px;
        background: white;
        border-radius: 50%;
        font-size: 12px;
        line-height: 16px;
      }
      [data-row-text] {
        min-width: 0;
        display: grid;
        flex: 1;
      }
      [data-row-text] strong,
      [data-row-text] > span {
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
      }
      [data-row-text] > span,
      [data-row-time] {
        color: #616161;
        font-size: 12px;
      }
      [data-row-time] {
        align-self: flex-start;
        display: grid;
        justify-items: end;
        gap: 8px;
      }
      [data-unread] {
        height: 7px;
        width: 7px;
        border-radius: 50%;
        background: #005bd3;
      }
      [data-admin-list] [data-admin-thread] {
        flex: 1;
        min-width: 0;
      }
      [data-admin-list][data-mobile='true'] [data-conversation-list] {
        flex: 1;
        height: 770px;
      }
      [data-admin-list][data-mobile='true'][data-thread-open='false'] [data-admin-thread],
      [data-admin-list][data-mobile='true'][data-thread-open='true'] [data-conversation-list] {
        display: none;
      }
    </style>
    <div
      data-admin-list
      @new-conversation=${() => {
        const hiddenList = mobile && owner.dataset.threadOpen === 'true';
        const anchor = hiddenList ? listAnchor : recordAnchor();
        rows = [
          {id: rows.length + 1, name: `New customer ${rows.length + 1}`, unread: true, ai: false},
          ...rows
        ];
        drawList();
        listAnchor = anchor;
        if (!hiddenList) restoreAnchor(anchor);
      }}
      data-mobile=${String(mobile)}
      data-thread-open="false"
      ${ref(node => {
        if (node) {
          owner = node;
          queueMicrotask(drawList);
        }
      })}
    >
      <nav data-conversation-list aria-label="Conversations"></nav>
      <div data-admin-thread>
        ${patternShell({
          surface: 'admin',
          store,
          title: 'Alex Morgan',
          headerStart: mobile
            ? html`<chatty-icon-button
                data-admin-back
                label="Back"
                @click=${() => {
                  owner.dataset.threadOpen = 'false';
                  restoreAnchor(listAnchor);
                  owner
                    .querySelector(`[data-conversation="${selected}"]`)
                    .focus({preventScroll: true});
                }}
                >${IconChevronLeft()}</chatty-icon-button
              >`
            : '',
          content: html`<div
            slot="empty"
            role="status"
            aria-label="Loading messages"
            style="display:grid;gap:16px;padding:16px"
          >
            <chatty-skeleton></chatty-skeleton><chatty-skeleton></chatty-skeleton
            ><chatty-skeleton></chatty-skeleton>
          </div>`
        })}
      </div>
    </div>`;
}

Import / element

InboxConversationList

Component / element Import / file Scope root
InboxConversationList import InboxConversationList from '@assets/pages/InboxManagement/Parts/InboxConversationList.js'; Polaris Listbox trong cột list

InboxConversationItem

Component / element Import / file Scope root
InboxConversationItem import InboxConversationItem from '@assets/pages/InboxManagement/Parts/InboxConversationItem.js'; Hàng trong Polaris Listbox của list

Anatomy

InboxConversationList

Part Element
1 Lớp phủ trắng mờ cùng Spinner khi list đang tải hoặc lọc.
2 Polaris Listbox bọc vùng cuộn parentRef.
3 Hàng div có role button, mỗi hàng chứa một InboxConversationItem.
4 Trạng thái rỗng hoặc lỗi thay cho danh sách.

InboxConversationItem

Part Element
1 Checkbox chọn hội thoại, ẩn trừ khi isBulkMode.
2 Avatar CustomerAvatar kèm chấm online, icon kênh và icon AI.
3 Tên hiển thị bằng Polaris Text headingSm, kèm Badge Ticket và tên người phụ trách.
4 Menu hành động ba chấm, chỉ trên desktop và ngoài chế độ chọn nhiều.
5 Preview tin cuối hoặc bản nháp, bodyMd subdued.
6 Thời gian kèm chấm chưa đọc.

Placement / order

InboxConversationList

Context Order
Cột list Spinner phủ lên, sau đó Listbox, rồi các hàng ảo hóa theo thứ tự filteredConversations.
Hàng đang chọn Được cuộn vào giữa vùng nhìn khi convoId đổi.

InboxConversationItem

Context Order
Hàng Checkbox, avatar, rồi khối tên và preview trong InboxListRow.
Dòng preview Preview trước, thời gian và chấm chưa đọc sau.

Props

InboxConversationList

Prop Type Values Default Notes
conversations App.ChatConversation[] Danh sách hội thoại Bắt buộc Bỏ hội thoại proactive_chat chưa có tin nhắn.
shops object Map theo shopId null Dùng để hiện badge shop trên hàng.
listLoading boolean true / false false Bật lớp phủ Spinner.
onLoadMore function Callback Không có Tải thêm khi cuộn gần cuối.
hasActiveFilter boolean true / false false Truyền cho trạng thái rỗng.

InboxConversationItem

Prop Type Values Default Notes
item App.ChatConversation Hội thoại của hàng Bắt buộc Nguồn của tên, kênh, tin cuối, isRead và isChatBot.
convoId string Id hội thoại đang mở Không có Đặt selected khi khớp item.id và không ở isBulkMode.
draftMessages object Bản nháp theo id {} Có nháp thì preview hiện [Draft].
isMobile boolean true / false Không có Mobile hiện Badge kênh cạnh tên và bỏ menu hành động.
shop object Thông tin shop null Có nhãn thì hiện badge shop.

Sizes

InboxConversationList

Size Height Padding Gap Radius Font role (px/rem) Hit target Breakpoint / mechanism
Hàng ROW_HEIGHT 64, áp thành height inline của hàng Theo InboxConversationItem Không khai báo Không khai báo Theo InboxConversationItem Cả hàng là một button Không có breakpoint riêng

InboxConversationItem

Size Height Padding Gap Radius Font role (px/rem) Hit target Breakpoint / mechanism
Chấm online 12px Không khai báo Không khai báo 50% Không có text Không tương tác Không có breakpoint riêng
Icon kênh 18px Không khai báo Không khai báo 50% Icon Polaris 20px Không tương tác Không có breakpoint riêng
Icon AI 16px Không khai báo Không khai báo 50% Icon Polaris 14px Không tương tác Không có breakpoint riêng
Chấm chưa đọc 8px Không khai báo Không khai báo 50% Không có text Không tương tác Không có breakpoint riêng
Preview Theo nội dung Không khai báo 8px Không khai báo bodyMd subdued; font-size 13px Cả hàng Không có breakpoint riêng
Thời gian Theo nội dung Không khai báo 5px Không khai báo bodyMd subdued; font-size 12px Theo token; font-size 12px Không có breakpoint riêng

Tokens

InboxConversationList

Part Token Light Dark
Lớp phủ tải Không có token rgba(255, 255, 255, 0.7) No Dark skin

InboxConversationItem

Part Token Light Dark
Chấm online Không có token #22c55e No Dark skin
Nền icon kênh Không có token #fff No Dark skin
Nền icon AI Không có token #f3e8ff No Dark skin
Chấm chưa đọc Không có token #0066cc No Dark skin
Tên Không có token #303030 No Dark skin
Preview, thời gian Không có token #6b7280 No Dark skin

States

InboxConversationList

State Trigger Visual change (values) ARIA/attribute
Đang tải listLoading, loadingFilter hoặc isLocating Lớp phủ rgba(255, 255, 255, 0.7) cùng Spinner Không có ARIA riêng trên lớp phủ
Rỗng isEmpty ConversationListError khi có lỗi, còn lại EmptyConversationList Không có ARIA riêng
Chọn nhiều isBulkMode Vùng chứa role list, mỗi hàng role listitem role list, listitem

InboxConversationItem

State Trigger Visual change (values) ARIA/attribute
Chưa đọc isRead sai Class is-unread, tên theo --chatty-classic-name-unread-weight, hiện chấm chưa đọc Không có ARIA riêng
Đã đọc isRead đúng Tên dùng --chatty-classic-name-weight Không có ARIA riêng
Đang chọn convoId khớp item.id Listbox.Option nhận selected Do Polaris Listbox cấp
Online isOnline Chấm online 12px Không có ARIA riêng
AI isChatBot Icon MagicIcon trong vòng 16px, tooltip AI processing Tooltip Polaris
Ticket helpdeskTicketId Badge Ticket tone attention, size small Không có ARIA riêng
Bản nháp isShowDraftMessage Preview bắt đầu bằng [Draft] màu #005BD3 Không có ARIA riêng

Behaviour

InboxConversationList

Interaction Result
Click hàng Gọi handleConvoSelected với id hội thoại.
Enter hoặc Space Chỉ khi focus nằm trên chính hàng; gọi handleConvoSelected sau preventDefault.
Phím mũi tên enableKeyboardControl tắt nên Listbox không điều hướng bằng mũi tên.
Cập nhật realtime Ghi nhớ hàng trên cùng và offset, rồi đặt lại scrollTop để không nhảy; chỉ chỉnh cuộn, không đổi list.
Đổi hội thoại Cuộn mượt hàng đang chọn vào giữa (align: center).

InboxConversationItem

Interaction Result
Chọn nhiều Click vào checkbox gọi selectFromEntry kèm shiftKey và dừng lan truyền.
Menu hành động Ẩn bằng visibility: hidden theo mặc định.
Tên và preview dài Cắt bằng text-overflow: ellipsis, không xuống dòng.
Thời gian Tooltip hiện ngày giờ đầy đủ, vị trí below.

Copy

InboxConversationList

String i18n key Where
Not available Not available List không sở hữu chuỗi cố định; trạng thái rỗng và lỗi thuộc component riêng.

InboxConversationItem

String i18n key Where
AI processing Không có i18n key Tooltip của icon AI
Ticket Không có i18n key Nội dung Badge
[Draft] Không có i18n key Tiền tố preview khi có bản nháp
Select conversation Select conversation Nhãn ẩn của checkbox qua i18n
New conversation New conversation Preview khi chưa có nội dung, qua i18n

Source

InboxConversationList

File Evidence
Chiều cao hàng
Giữ vị trí cuộn
Cấu trúc list, hàng và phím

InboxConversationItem

File Evidence
Cấu trúc hàng
Kiểu avatar, tên, preview và thời gian

Do / Don't

Accessibility

Surface Role / name Keyboard / focus Live region Contrast pair / ratio
Admin Hàng có role button (listitem khi chọn nhiều) và aria-label bằng tên hiển thị. tabIndex 0 trên mỗi hàng; Enter và Space mở hội thoại; chưa có mũi tên next/prev. Không có live region trong list. Không đo: nền hàng do Polaris Listbox cấp
Admin Vùng thread có aria-busy và inert khi đang nạp. Không focus được trong lúc inert; banner kết nối có button Retry. Banner kết nối có role status. Không áp dụng: skeleton không có chữ

Target