Make the message box collapsible and solidify the Other… field

This commit is contained in:
Ian Gulliver
2026-10-20 08:45:01 -07:00
parent 289c58d778
commit 224a0d5a4b
4 changed files with 55 additions and 11 deletions
+7
View File
@@ -372,6 +372,13 @@ final class ChatModel {
return groups.first.map(flagged)
}
var composerHiddenByDefault: Bool {
guard let taskId, let task = store.findTask(taskId) else {
return false
}
return task.status != .active || store.inbox.contains(where: { $0.taskId == taskId })
}
func showStatus(_ s: ChatStatus) {
if let g = s.group {
cycle(g)
+46 -10
View File
@@ -283,8 +283,30 @@ struct ComposerView: View {
@ViewState private var text = ""
@ViewState private var pick: String?
@ViewState private var targeted = false
@ViewState private var shownOverride: Bool?
@FocusState private var focused: Bool
private var shown: Bool {
shownOverride ?? !chat.composerHiddenByDefault
}
private func reveal() {
shownOverride = true
focused = true
}
private func takeFocus() {
let asked = chat.taskId != nil && store.composerFocus == chat.taskId
if !chat.takeFocus() {
return
}
if asked {
reveal()
} else if shown {
focused = true
}
}
private var draftKey: String {
"message:\(key)"
}
@@ -317,7 +339,7 @@ struct ComposerView: View {
let lost = store.drafts?.lostImageCount(draftKey) ?? 0
VStack(alignment: .leading, spacing: 8) {
if lost > 0 {
if shown && lost > 0 {
HStack(spacing: 8) {
Text("\(lost == 1 ? "1 image" : "\(lost) images") from before the reload need re-attaching.")
.font(Fonts.font(12))
@@ -333,10 +355,21 @@ struct ComposerView: View {
.background(Palette.warnTint, in: RoundedRectangle(cornerRadius: 6))
.overlay(RoundedRectangle(cornerRadius: 6).stroke(Palette.border))
}
Thumbnails(key: draftKey)
editor
if shown {
Thumbnails(key: draftKey)
editor
}
HStack(spacing: 8) {
HStack(spacing: 8) {
Button(shown ? "⌄" : "⌃") {
if shown {
shownOverride = false
} else {
reveal()
}
}
.buttonStyle(WebButtonStyle())
.help(shown ? "Hide the message box" : "Show the message box")
if !chat.team {
Picker("", selection: Binding(get: { selected }, set: { v in
pick = v
@@ -370,6 +403,7 @@ struct ComposerView: View {
submit(modelState())
}
.buttonStyle(WebButtonStyle())
.disabled(!shown)
}
.frame(maxWidth: .infinity, alignment: .trailing)
}
@@ -382,14 +416,16 @@ struct ComposerView: View {
}
.onAppear {
text = store.drafts?.composerText(draftKey) ?? ""
if chat.takeFocus() {
focused = true
}
takeFocus()
}
.onChange(of: store.composerFocus) {
if chat.takeFocus() {
focused = true
}
takeFocus()
}
.onChange(of: chat.composerHiddenByDefault) {
shownOverride = nil
}
.onChange(of: key) {
shownOverride = nil
}
.onChange(of: text) {
store.drafts?.setComposerText(draftKey, text)
@@ -409,7 +445,7 @@ struct ComposerView: View {
}
.onChange(of: overlays.leadFocus) {
if chat.kind == .lead {
focused = true
reveal()
}
}
.onChange(of: focused) {
+1
View File
@@ -570,6 +570,7 @@ private struct TextEntry: View {
.padding(.horizontal, 10)
.padding(.vertical, 4)
.frame(maxWidth: .infinity, alignment: .leading)
.background(Palette.raised, in: RoundedRectangle(cornerRadius: 6))
.overlay(RoundedRectangle(cornerRadius: 6).stroke(hover || focused ? Palette.accent : Palette.border))
.overlay {
if focused {