Unify attention cards

This commit is contained in:
Ian Gulliver
2026-10-21 07:20:16 -07:00
parent 0d3ed1fdd3
commit e05165723d
5 changed files with 256 additions and 269 deletions
+13 -4
View File
@@ -662,14 +662,14 @@ private struct LineCommentBox: View {
let anchor: LineAnchor
@Environment(Store.self) private var store
@FocusState private var focused: Bool
@ViewState private var text = ""
var body: some View {
let text = Binding(get: { drafts.lineComment(taskId, anchor)?.text ?? "" }, set: { drafts.setLineComment(taskId, anchor, $0) })
let key = lineCommentImageKey(taskId, anchor)
VStack(alignment: .trailing, spacing: 4) {
Thumbnails(key: key)
.frame(maxWidth: .infinity, alignment: .leading)
TextEditor(text: text)
TextEditor(text: $text)
.font(Fonts.font(12))
.scrollContentBackground(.hidden)
.writingToolsBehavior(.disabled)
@@ -679,7 +679,7 @@ private struct LineCommentBox: View {
.frame(height: 64)
.background(Palette.surface, in: RoundedRectangle(cornerRadius: 6))
.overlay(alignment: .topLeading) {
if text.wrappedValue.isEmpty {
if text.isEmpty {
Text("Comment on line \(anchor.line)…")
.foregroundStyle(Palette.muted)
.padding(.horizontal, 10)
@@ -696,9 +696,18 @@ private struct LineCommentBox: View {
.buttonStyle(SmallLinkButtonStyle())
}
.onAppear {
if text.wrappedValue.isEmpty {
text = drafts.lineComment(taskId, anchor)?.text ?? ""
if text.isEmpty {
focused = true
}
}
.onChange(of: text) {
drafts.setLineComment(taskId, anchor, text)
}
.onChange(of: drafts.lineComment(taskId, anchor)?.text) { _, new in
if let new, new != text {
text = new
}
}
}
}