import QtQuick import QtQuick.Layouts import ZShell.Config import ZShell.Llm import qs.Components import qs.Services CustomRect { id: root required property Item chatItem property alias layout: layout required property ChatSession modelData color: Colors.tPalette.m3surfaceContainer implicitHeight: layout.implicitHeight + layout.anchors.topMargin + layout.anchors.bottomMargin MaterialIcon { id: chatIcon anchors.left: parent.left anchors.leftMargin: Tokens.padding.large anchors.verticalCenter: parent.verticalCenter color: root.chatItem.ListView.isCurrentItem ? Colors.palette.m3onPrimary : Colors.palette.m3onSurface font.pointSize: Tokens.font.size.extraLarge text: root.modelData.icon || "check" } ColumnLayout { id: layout anchors.bottom: parent.bottom anchors.bottomMargin: Tokens.padding.small anchors.left: chatIcon.right anchors.leftMargin: Tokens.padding.medium anchors.right: parent.right anchors.rightMargin: Tokens.padding.medium anchors.top: parent.top anchors.topMargin: Tokens.padding.small spacing: Tokens.spacing.extraSmall CustomRect { id: titleContainer readonly property bool enoughSpace: width > title.implicitWidth + timeSep.implicitWidth + timeSep.anchors.leftMargin + timestamp.implicitWidth + timestamp.anchors.leftMargin Layout.fillWidth: true implicitHeight: enoughSpace ? title.implicitHeight : title.implicitHeight + timestamp.implicitHeight + timestamp.anchors.topMargin CustomText { id: title color: root.chatItem.ListView.isCurrentItem ? Colors.palette.m3onPrimary : Colors.palette.m3onSurface text: root.modelData.title } CustomText { id: timeSep anchors.left: title.right anchors.leftMargin: Tokens.spacing.small anchors.verticalCenter: title.verticalCenter color: root.chatItem.ListView.isCurrentItem ? Qt.alpha(Colors.palette.m3onPrimary, 0.9) : Colors.palette.m3onSurfaceVariant text: "•" visible: titleContainer.enoughSpace } CustomText { id: timestamp anchors.left: titleContainer.enoughSpace ? timeSep.right : parent.left anchors.leftMargin: titleContainer.enoughSpace ? Tokens.spacing.small : 0 anchors.top: titleContainer.enoughSpace ? undefined : title.bottom anchors.topMargin: Tokens.spacing.extraSmall anchors.verticalCenter: titleContainer.enoughSpace ? title.verticalCenter : undefined color: root.chatItem.ListView.isCurrentItem ? Qt.alpha(Colors.palette.m3onPrimary, 0.9) : Colors.palette.m3onSurfaceVariant font.pointSize: Tokens.font.size.small text: root.modelData.updatedAt.toLocaleString(Qt.locale("en_US"), "MMM d, yyyy - h:mm AP") } } CustomText { Layout.fillWidth: true color: root.chatItem.ListView.isCurrentItem ? Qt.alpha(Colors.palette.m3onPrimary, 0.9) : Colors.palette.m3onSurfaceVariant elide: Text.ElideRight font.pointSize: Tokens.font.size.small maximumLineCount: 1 text: root.modelData.messages[root.modelData.messages.length - 1]?.content.replace(/\s+/g, " ").trim() ?? "" } } }