forked from Shinonome/dots-hyprland
ai message: add null checks
This commit is contained in:
@@ -109,17 +109,17 @@ Rectangle {
|
|||||||
Item {
|
Item {
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
implicitWidth: messageData.role == 'assistant' ? modelIcon.width : roleIcon.implicitWidth
|
implicitWidth: messageData?.role == 'assistant' ? modelIcon.width : roleIcon.implicitWidth
|
||||||
implicitHeight: messageData.role == 'assistant' ? modelIcon.height : roleIcon.implicitHeight
|
implicitHeight: messageData?.role == 'assistant' ? modelIcon.height : roleIcon.implicitHeight
|
||||||
|
|
||||||
CustomIcon {
|
CustomIcon {
|
||||||
id: modelIcon
|
id: modelIcon
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
visible: messageData.role == 'assistant' && Ai.models[messageData.model].icon
|
visible: messageData?.role == 'assistant' && Ai.models[messageData?.model].icon
|
||||||
width: Appearance.font.pixelSize.large
|
width: Appearance.font.pixelSize.large
|
||||||
height: Appearance.font.pixelSize.large
|
height: Appearance.font.pixelSize.large
|
||||||
source: messageData.role == 'assistant' ? Ai.models[messageData.model].icon :
|
source: messageData?.role == 'assistant' ? Ai.models[messageData?.model].icon :
|
||||||
messageData.role == 'user' ? 'linux-symbolic' : 'desktop-symbolic'
|
messageData?.role == 'user' ? 'linux-symbolic' : 'desktop-symbolic'
|
||||||
}
|
}
|
||||||
ColorOverlay {
|
ColorOverlay {
|
||||||
visible: modelIcon.visible
|
visible: modelIcon.visible
|
||||||
@@ -134,9 +134,9 @@ Rectangle {
|
|||||||
visible: !modelIcon.visible
|
visible: !modelIcon.visible
|
||||||
iconSize: Appearance.font.pixelSize.larger
|
iconSize: Appearance.font.pixelSize.larger
|
||||||
color: Appearance.m3colors.m3onSecondaryContainer
|
color: Appearance.m3colors.m3onSecondaryContainer
|
||||||
text: messageData.role == 'user' ? 'person' :
|
text: messageData?.role == 'user' ? 'person' :
|
||||||
messageData.role == 'interface' ? 'settings' :
|
messageData?.role == 'interface' ? 'settings' :
|
||||||
messageData.role == 'assistant' ? 'neurology' :
|
messageData?.role == 'assistant' ? 'neurology' :
|
||||||
'computer'
|
'computer'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -149,8 +149,8 @@ Rectangle {
|
|||||||
font.pixelSize: Appearance.font.pixelSize.normal
|
font.pixelSize: Appearance.font.pixelSize.normal
|
||||||
font.weight: Font.DemiBold
|
font.weight: Font.DemiBold
|
||||||
color: Appearance.m3colors.m3onSecondaryContainer
|
color: Appearance.m3colors.m3onSecondaryContainer
|
||||||
text: messageData.role == 'assistant' ? Ai.models[messageData.model].name :
|
text: messageData?.role == 'assistant' ? Ai.models[messageData?.model].name :
|
||||||
(messageData.role == 'user' && SystemInfo.username) ? SystemInfo.username :
|
(messageData?.role == 'user' && SystemInfo.username) ? SystemInfo.username :
|
||||||
qsTr("Interface")
|
qsTr("Interface")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -158,7 +158,7 @@ Rectangle {
|
|||||||
|
|
||||||
Button { // Not visible to model
|
Button { // Not visible to model
|
||||||
id: modelVisibilityIndicator
|
id: modelVisibilityIndicator
|
||||||
visible: messageData.role == 'interface'
|
visible: messageData?.role == 'interface'
|
||||||
implicitWidth: 16
|
implicitWidth: 16
|
||||||
implicitHeight: 30
|
implicitHeight: 30
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
@@ -185,7 +185,7 @@ Rectangle {
|
|||||||
buttonIcon: activated ? "inventory" : "content_copy"
|
buttonIcon: activated ? "inventory" : "content_copy"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
Hyprland.dispatch(`exec wl-copy '${StringUtils.shellSingleQuoteEscape(root.messageData.content)}'`)
|
Hyprland.dispatch(`exec wl-copy '${StringUtils.shellSingleQuoteEscape(root.messageData?.content)}'`)
|
||||||
copyButton.activated = true
|
copyButton.activated = true
|
||||||
copyIconTimer.restart()
|
copyIconTimer.restart()
|
||||||
}
|
}
|
||||||
@@ -205,7 +205,7 @@ Rectangle {
|
|||||||
AiMessageControlButton {
|
AiMessageControlButton {
|
||||||
id: editButton
|
id: editButton
|
||||||
activated: root.editing
|
activated: root.editing
|
||||||
enabled: root.messageData.done
|
enabled: root.messageData?.done
|
||||||
buttonIcon: "edit"
|
buttonIcon: "edit"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
root.editing = !root.editing
|
root.editing = !root.editing
|
||||||
@@ -247,7 +247,7 @@ Rectangle {
|
|||||||
spacing: 0
|
spacing: 0
|
||||||
Repeater {
|
Repeater {
|
||||||
model: ScriptModel {
|
model: ScriptModel {
|
||||||
values: StringUtils.splitMarkdownBlocks(root.messageData.content)
|
values: StringUtils.splitMarkdownBlocks(root.messageData?.content)
|
||||||
}
|
}
|
||||||
delegate: Loader {
|
delegate: Loader {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
@@ -258,8 +258,8 @@ Rectangle {
|
|||||||
property var editing: root.editing
|
property var editing: root.editing
|
||||||
property var renderMarkdown: root.renderMarkdown
|
property var renderMarkdown: root.renderMarkdown
|
||||||
property var enableMouseSelection: root.enableMouseSelection
|
property var enableMouseSelection: root.enableMouseSelection
|
||||||
property bool thinking: root.messageData.thinking
|
property bool thinking: root.messageData?.thinking
|
||||||
property bool done: root.messageData.done
|
property bool done: root.messageData?.done
|
||||||
property bool completed: modelData.completed ?? false
|
property bool completed: modelData.completed ?? false
|
||||||
|
|
||||||
source: modelData.type === "code" ? "MessageCodeBlock.qml" :
|
source: modelData.type === "code" ? "MessageCodeBlock.qml" :
|
||||||
@@ -278,7 +278,7 @@ Rectangle {
|
|||||||
Layout.alignment: Qt.AlignLeft
|
Layout.alignment: Qt.AlignLeft
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
model: root.messageData.annotationSources
|
model: root.messageData?.annotationSources
|
||||||
delegate: AnnotationSourceButton {
|
delegate: AnnotationSourceButton {
|
||||||
id: annotationButton
|
id: annotationButton
|
||||||
faviconDownloadPath: root.faviconDownloadPath
|
faviconDownloadPath: root.faviconDownloadPath
|
||||||
|
|||||||
Reference in New Issue
Block a user