import QtQuick import QtQuick.Controls import QtQuick.Layouts // The input line: multiline, Enter sends, the button changes with the turn // state. Sized for a thumb as much as for a mouse, and it asks the platform // keyboard not to autocorrect what is usually code or a path. Rectangle { id: root objectName: "composer" property bool running: false property bool compact: false property alias text: input.text signal submitted(string text) function submit() { const t = input.text.trim() if (!t.length || running) return input.text = "" submitted(t) } radius: Theme.radius color: Theme.surface border.width: 1 border.color: input.activeFocus ? Theme.accentDim : Theme.border implicitHeight: layout.implicitHeight + Theme.pad ColumnLayout { id: layout anchors { left: parent.left right: parent.right top: parent.top margins: Theme.pad } spacing: 6 RowLayout { Layout.fillWidth: true spacing: Theme.gap TextArea { id: input objectName: "composerInput" Layout.fillWidth: true Layout.preferredHeight: Math.min(root.compact ? 120 : 170, Math.max(56, contentHeight + 12)) placeholderText: root.running ? "the turn is running — Esc stops it" : (root.compact ? "Ask for something…" : "Ask for something (Enter sends, Shift+Enter for a new line)") placeholderTextColor: Theme.textFaint color: Theme.text font.pixelSize: Theme.bodySize wrapMode: TextArea.Wrap selectByMouse: true selectionColor: Theme.accentDim inputMethodHints: Qt.ImhMultiLine | Qt.ImhNoPredictiveText | Qt.ImhNoAutoUppercase background: Rectangle { color: "transparent" } enabled: !root.running Keys.onPressed: function (ev) { if (ev.key === Qt.Key_Return || ev.key === Qt.Key_Enter) { if (!(ev.modifiers & Qt.ShiftModifier)) { root.submit() ev.accepted = true } } } } Button { id: action objectName: "sendButton" Layout.alignment: Qt.AlignBottom implicitWidth: root.compact ? 68 : 88 implicitHeight: Theme.touchTarget + 4 text: root.running ? "Stop" : "Send" enabled: root.running || input.text.trim().length > 0 onClicked: root.running ? agent.cancel() : root.submit() background: Rectangle { radius: Theme.radiusSm color: !action.enabled ? Theme.surfaceAlt : root.running ? (action.hovered ? "#e05666" : Theme.err) : (action.hovered ? "#5cc0f0" : Theme.accent) } contentItem: Text { text: action.text color: action.enabled ? "#12161a" : Theme.textFaint font.pixelSize: Theme.bodySize font.bold: true horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter } } } // On a narrow window the hint would wrap into the editor's space. Text { Layout.fillWidth: true visible: !root.compact text: root.running ? "working — Esc cancels the turn" : "Enter sends · Shift+Enter newline · Esc stops · every change asks first" color: Theme.textFaint font.pixelSize: Theme.smallSize } } }