Share the composer and attention reply editor

This commit is contained in:
Ian Gulliver
2026-10-21 10:57:08 -07:00
parent bcf2556e35
commit 01edc09385
2 changed files with 49 additions and 56 deletions
+2 -28
View File
@@ -78,35 +78,9 @@ private struct OtherEntry: View {
if otherOpen(store, key) {
VStack(alignment: .leading, spacing: 6) {
Thumbnails(key: key)
TextEditor(text: $text)
.font(Fonts.font(13))
.scrollContentBackground(.hidden)
.writingToolsBehavior(.disabled)
.focused($editing)
AgentEditor(text: $text, placeholder: placeholder, key: key, height: 66,
focus: $editing, border: editing ? Palette.accent : Palette.border, send: send)
.disabled(busy)
.onKeyPress(.return, phases: .down) { press in
let marked = (NSApp.keyWindow?.firstResponder as? NSTextView)?.hasMarkedText() ?? false
if press.modifiers.contains(.shift) || marked {
return .ignored
}
send()
return .handled
}
.padding(.horizontal, 5)
.padding(.vertical, 6)
.frame(height: 66)
.background(Palette.raised, in: RoundedRectangle(cornerRadius: 6))
.overlay(alignment: .topLeading) {
if text.isEmpty {
Text(placeholder)
.foregroundStyle(Palette.muted)
.padding(.horizontal, 10)
.padding(.vertical, 6)
.allowsHitTesting(false)
}
}
.overlay(RoundedRectangle(cornerRadius: 6).stroke(editing ? Palette.accent : Palette.border))
.imageInput(key)
}
.onChange(of: editing) {
if !editing {
+47 -28
View File
@@ -309,6 +309,48 @@ private struct ThumbRemove: View {
}
}
struct AgentEditor: View {
@Binding var text: String
let placeholder: String
let key: String
let height: CGFloat
var focus: FocusState<Bool>.Binding
let border: Color
var borderWidth: CGFloat = 1
let send: () -> Void
var body: some View {
TextEditor(text: $text)
.font(Fonts.font(13))
.scrollContentBackground(.hidden)
.writingToolsBehavior(.disabled)
.focused(focus)
.onKeyPress(.return, phases: .down) { press in
let marked = (NSApp.keyWindow?.firstResponder as? NSTextView)?.hasMarkedText() ?? false
if press.modifiers.contains(.shift) || marked {
return .ignored
}
send()
return .handled
}
.padding(.horizontal, 5)
.padding(.vertical, 6)
.frame(height: height)
.background(Palette.raised, in: RoundedRectangle(cornerRadius: 6))
.overlay(alignment: .topLeading) {
if text.isEmpty {
Text(placeholder)
.foregroundStyle(Palette.muted)
.padding(.horizontal, 10)
.padding(.vertical, 6)
.allowsHitTesting(false)
}
}
.overlay(RoundedRectangle(cornerRadius: 6).stroke(border, lineWidth: borderWidth))
.imageInput(key)
}
}
struct ComposerView: View {
let chat: ChatModel
let key: String
@@ -497,34 +539,11 @@ struct ComposerView: View {
}
private var editor: some View {
TextEditor(text: $text)
.font(Fonts.font(13))
.scrollContentBackground(.hidden)
.writingToolsBehavior(.disabled)
.focused($focused)
.onKeyPress(.return, phases: .down) { press in
let marked = (NSApp.keyWindow?.firstResponder as? NSTextView)?.hasMarkedText() ?? false
if press.modifiers.contains(.shift) || marked {
return .ignored
}
submit(modelState())
return .handled
}
.padding(.horizontal, 5)
.padding(.vertical, 6)
.frame(height: 104)
.background(Palette.raised, in: RoundedRectangle(cornerRadius: 6))
.overlay(alignment: .topLeading) {
if text.isEmpty {
Text(chat.placeholder)
.foregroundStyle(Palette.muted)
.padding(.horizontal, 10)
.padding(.vertical, 6)
.allowsHitTesting(false)
}
}
.overlay(RoundedRectangle(cornerRadius: 6).stroke(inRightPane ? accent : focused ? Palette.accent : Palette.border, lineWidth: inRightPane && focused ? 2 : 1))
.imageInput(draftKey)
AgentEditor(text: $text, placeholder: chat.placeholder, key: draftKey, height: 104,
focus: $focused, border: inRightPane ? accent : focused ? Palette.accent : Palette.border,
borderWidth: inRightPane && focused ? 2 : 1) {
submit(modelState())
}
}
private func reportDraft() {