Open source CapCut alternative.
TypeScript
feat(app): keep the resting notch chin to one line
David Le4222eb9788a4
diff --git a/apps/Donkey/Sources/Donkey/UserQueryOverlayController.swift b/apps/Donkey/Sources/Donkey/UserQueryOverlayController.swiftindex 705f2a1b..a5fc6e31 100644--- a/apps/Donkey/Sources/Donkey/UserQueryOverlayController.swift+++ b/apps/Donkey/Sources/Donkey/UserQueryOverlayController.swift@@ -1034,21 +1034,18 @@ final class UserQueryOverlayController {/// On a no-notch display the collapsed line renders inline in the top row (a real notch routes it into/// the chin band instead). It shows the same rotating surfaced-conversation line the chin does, so size the- /// pill to the tallest line that can rotate through — the max wrapped-line count across the surfaced- /// conversations, or the headline fallback when nothing is surfaced — and grow by one line-height when that is- /// two lines. The text width subtracts the pill's pointer lane and gutter, measured narrow so the+ /// pill to the tallest surfaced line that can rotate through — the max wrapped-line count across the+ /// surfaced (active or unacknowledged) conversations — and grow by one line-height when that is two lines.+ /// The idle headline, shown when nothing is surfaced, always reads on one row, so the resting pill never+ /// grows. The text width subtracts the pill's pointer lane and gutter, measured narrow so the/// prediction never under-counts and clips. A real notch returns 0 — its second line lives in/// `statusChinHeight`.private func statusCollapsedTopRowExtraHeight(collapsedWidth: CGFloat, hasNotch: Bool) -> CGFloat {guard !hasNotch else { return 0 }let textWidth = collapsedWidth - Self.statusCollapsedTopRowHorizontalReserve- let headline = UserQueryNotchStatusView.collapsedHeadline(- conversations: model.notchConversations,- state: model.promptState- )- let lines = model.notchSurfacedConversations.reduce(- Self.chinLineCount(for: headline, width: textWidth)- ) { partial, conversation in+ // A surfaced conversation — active or unacknowledged — can grow the row to a second line; the idle+ // headline (shown when nothing is surfaced) always reads on one, so the resting pill stays a single row.+ let lines = model.notchSurfacedConversations.reduce(1) { partial, conversation inmax(partial, Self.chinLineCount(for: conversation.chinDisplayText, width: textWidth))}return lines >= 2 ? Self.statusChinLineHeight : 0@@ -1060,6 +1057,9 @@ final class UserQueryOverlayController {/// there), keeping the bottom margin constant. Real notch only.private func statusChinHeight(textWidth: CGFloat) -> CGFloat {let surfaced = model.notchSurfacedConversations+ // A surfaced conversation is active or unacknowledged (running, waiting, or a terminal line the+ // user hasn't dismissed); those get up to two lines. An idle notch has nothing surfaced, so the+ // chin collapses to no line at all.guard !surfaced.isEmpty else { return 0 }// Cache by the surfaced chin text + width: `notchMetrics()` runs every frame, but the wrapped-line// Core Text measurement only needs to rerun when the text or available width actually changes.diff --git a/apps/Donkey/Sources/DonkeyUI/UserQueryNotchStatusView.swift b/apps/Donkey/Sources/DonkeyUI/UserQueryNotchStatusView.swiftindex 23f3e2b9..1da4fffb 100644--- a/apps/Donkey/Sources/DonkeyUI/UserQueryNotchStatusView.swift+++ b/apps/Donkey/Sources/DonkeyUI/UserQueryNotchStatusView.swift@@ -389,9 +389,9 @@ public struct UserQueryNotchStatusView: View {private var fullWidthCollapsedContent: some View {// A no-notch display has no camera void to route around, so the line lives inline here rather// than in a chin band — but it reads the very same rotating line the chin does (the surfaced- // conversation's latest line), so both layouts narrate identically. It gets the same two-line- // budget; the pill grows by a line (see the controller's `statusCollapsedTopRowExtraHeight`)- // when that line wraps.+ // conversation's latest line), so both layouts narrate identically. It gets the same one-line+ // budget at rest, growing to a second line (see the controller's `statusCollapsedTopRowExtraHeight`)+ // only while the line it shows is a surfaced one — active or unacknowledged.TimelineView(.periodic(from: Self.chinRotationAnchor, by: Self.chinRotationInterval)) { context inlet speaker = rotatingChinConversation(at: context.date)HStack(spacing: 7) {@@ -403,7 +403,7 @@ public struct UserQueryNotchStatusView: View {Text(collapsedTopRowText(speaker: speaker)).font(.system(size: 12, weight: .regular)).foregroundStyle(Color.white.opacity(0.92))- .lineLimit(2)+ .lineLimit(chinLineLimit(speaker: speaker)).truncationMode(.tail)Spacer(minLength: 0)@@ -471,7 +471,7 @@ public struct UserQueryNotchStatusView: View {Text(chinText(for: conversation)).font(.system(size: Self.chinFontSize, weight: .regular)).foregroundStyle(Color.white.opacity(0.72))- .lineLimit(2)+ .lineLimit(chinLineLimit(speaker: conversation)).truncationMode(.tail)}@@ -479,6 +479,17 @@ public struct UserQueryNotchStatusView: View {conversation.chinDisplayText}+ /// How many lines the collapsed chin gives the line it is currently narrating. A surfaced conversation+ /// — one that is active or unacknowledged (running, waiting on the user, or a terminal line not yet+ /// dismissed) — gets a second line. An idle line (the most-recent settled conversation shown as the+ /// fallback, or no speaker at all) reads on one, so the resting notch stays a single line. Matches the+ /// two-line budget the controller reserves (`statusChinHeight` / `statusCollapsedTopRowExtraHeight`),+ /// so the band height and the rendered line agree.+ private func chinLineLimit(speaker: UserQueryConversation?) -> Int {+ guard let speaker, surfacedConversations.contains(where: { $0.id == speaker.id }) else { return 1 }+ return 2+ }+private func rotatingChinConversation(at date: Date) -> UserQueryConversation? {Self.collapsedChinConversation(conversations: conversations,diff --git a/docs/guides/notch.md b/docs/guides/notch.mdindex 5551e783..58a7cf98 100644--- a/docs/guides/notch.md+++ b/docs/guides/notch.md@@ -15,7 +15,7 @@ COLLAPSED (real notch — reference frame 253 × 32, 14px bottom corners)┌─ left ──┐┌──── notch void ─────┐┌─ right ──┐│ ◤ ││ (hardware notch) ││ 12m 3s │ ← notch row, 32px└─────────┘└──────────────────────┘└──────────┘- │ Comparing the top options… │ ← chin, ~20px, only while streaming+ │ Comparing the top options… │ ← chin, one line idle, two while a task is liveEXPANDED (reference frame 604 × 312, 14px corners)┌──────────────────────────── notch window ───────────────┐@@ -41,11 +41,13 @@ The collapsed notch is three zones across one row. The middle is the **void**| Void | The hardware notch. Always empty. | Empty. || Right gutter | One status only: the running clock, or a single notification icon. | One app-level action button (see Notifications). |-A display with no hardware notch uses a free-floating pill: no void, square top corners, rounded bottom, and the streaming message inline (two lines) instead of a separate chin.+A display with no hardware notch uses a free-floating pill: no void, square top corners, rounded bottom, and the current line inline instead of a separate chin, growing its row by a line under the same one-or-two-line rule below.## Chin-The chin is the strip that drops below the real notch while a task is streaming. It shows a single line of the current update in small text, with an ellipsis if it overflows. It exists only while something is streaming and only while collapsed; expanding hides it.+The chin is the strip that drops below the real notch to carry a task's latest line in small text, with an ellipsis if it overflows. It exists only while collapsed; expanding hides it.++**One line at rest, two while a task is live.** The chin shows a single line whenever the notch is idle — the line it carries is then a settled task the user has already acknowledged. It grows to a second line only while the line it is showing belongs to a *surfaced* task: one that is active or unacknowledged — running, waiting on the user, or finished-but-not-yet-dismissed. When the user expands the notch to acknowledge a finished task, it leaves the surfaced set and the chin drops back to one line. The second line is a budget, not a guarantee: it appears only when the text is long enough to wrap.## Streaming and the Queue