Open source CapCut alternative.
TypeScript
fix(app): keep the notch chin on the conversation's latest line
David Leeda2f47fc2a3
diff --git a/apps/Donkey/Sources/Donkey/UserQueryOverlayModel.swift b/apps/Donkey/Sources/Donkey/UserQueryOverlayModel.swiftindex e3c41a9e..ac28d249 100644--- a/apps/Donkey/Sources/Donkey/UserQueryOverlayModel.swift+++ b/apps/Donkey/Sources/Donkey/UserQueryOverlayModel.swift@@ -973,8 +973,9 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {activeAgentIDs.insert(conversationID)lastActiveConversationID = conversationID- // The live line falls back to the running activity ("Thinking"); the record logs "Resuming".- announceLifecycle(conversationID: conversationID, UserQueryActivity(kind: .resumed), status: .running, liveDetail: "")+ // Show the live "Resuming" line until the first step narrates; an empty detail would let the chin+ // fall back to the title (the original prompt), which is the stale line a resume must not resurface.+ announceLifecycle(conversationID: conversationID, UserQueryActivity(kind: .resumed), status: .running)updateSpawn(id: spawnStates.first { $0.conversationID == conversationID }?.id, resumesWork: true)promptState.leadingSignalLevel = .thinkingpromptState.promptText = conversation.title@@ -1112,7 +1113,6 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {conversationID: conversationID,UserQueryActivity(kind: .resumed),status: .running,- liveDetail: "",metadata: [:])if let turn = liveTurn, turn.conversationID == conversationID {@@ -1128,9 +1128,10 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {activeAgentIDs.insert(conversationID)lastActiveConversationID = conversationID- // After approval the conversation simply resumes; the live line falls back to the running activity- // ("Thinking") rather than narrating an internal "approving permission" step.- announceLifecycle(conversationID: conversationID, UserQueryActivity(kind: .resumed), status: .running, liveDetail: "")+ // After approval the conversation resumes on the live "Resuming" line until the first step narrates;+ // an empty detail would let the chin fall back to the title (the original prompt), the stale line the+ // user sees "reappear" after granting a gate.+ announceLifecycle(conversationID: conversationID, UserQueryActivity(kind: .resumed), status: .running)promptState.leadingSignalLevel = .thinkingpromptState.promptText = conversation.titlesyncPrimaryConversationPausedFlag()diff --git a/apps/Donkey/Sources/DonkeyContracts/UserQueryConversationContracts.swift b/apps/Donkey/Sources/DonkeyContracts/UserQueryConversationContracts.swiftindex 2440670d..9ed3fe70 100644--- a/apps/Donkey/Sources/DonkeyContracts/UserQueryConversationContracts.swift+++ b/apps/Donkey/Sources/DonkeyContracts/UserQueryConversationContracts.swift@@ -38,7 +38,20 @@ public enum UserQueryConversationOrigin: String, Codable, Equatable, Sendable {public struct UserQueryConversation: Codable, Equatable, Identifiable, Sendable {public var id: Stringpublic var title: String- public var detail: String+ /// The conversation's latest line — the one thing the collapsed chin renders (see `chinDisplayText`).+ /// It is MONOTONIC by construction: once it holds a real line, any write that would blank it+ /// self-reverts, so the chin can never regress to the `title` fallback (the original prompt) after the+ /// conversation has moved on. This is the structural guarantee behind "always show the latest text" —+ /// enforced here, in the data model, so no call site (a stray empty `liveDetail`, a cleared stream,+ /// a future writer) can reintroduce the stale-prompt bug. Empty survives ONLY as the value set in+ /// `init` — the genuine "no line yet" bootstrap, where `title` IS the latest line.+ public var detail: String {+ didSet {+ if detail.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {+ detail = oldValue+ }+ }+ }public var commandText: Stringpublic var status: UserQueryConversationStatuspublic var accentIndex: Int@@ -84,9 +97,11 @@ public extension UserQueryConversation {/// conversation. `detail` is the one field that carries it: the user's message the instant they send/// it, the agent's live step narration while it works, then the agent's reply. Each of those writes/// `detail` at its own source (see `UserQueryOverlayModel`), so the chin never reconstructs "what's- /// newest" from the prompt, title, and status — it just renders this. `title` (the first prompt) is- /// only a fallback for a task that has no line yet. The chin renderer and the chin-band height- /// measurement both read this, so the band is always sized to the exact line it renders.+ /// newest" from the prompt, title, and status — it just renders this. Because `detail` is monotonic+ /// (it never blanks once set — see its declaration), this only reads `title` for a task that has no+ /// line yet, where `title` IS the latest line; it can never resurface the original prompt after the+ /// conversation has moved on. The chin renderer and the chin-band height measurement both read this,+ /// so the band is always sized to the exact line it renders.var chinDisplayText: String {detail.isEmpty ? title : detail}diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/UserQueryChinDisplayTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/UserQueryChinDisplayTests.swiftindex 90d09c12..bca543d4 100644--- a/apps/Donkey/Tests/DonkeyRuntimeTests/UserQueryChinDisplayTests.swift+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/UserQueryChinDisplayTests.swift@@ -48,4 +48,36 @@ struct UserQueryChinDisplayTests {func chinFallsBackToTitleOnlyWhenThereIsNoLineYet() {#expect(task(title: "hi", detail: "", status: .running).chinDisplayText == "hi")}++ @Test+ func detailIsMonotonicSoTheChinCanNeverRevertToTheOriginalPrompt() {+ // The structural guarantee the user asked never to revisit: once `detail` holds a real line, ANY+ // write that would blank it is refused by the model itself — so no call site (a stray empty+ // `liveDetail`, a cleared stream, a future writer) can drop the chin back to the title (the+ // original prompt). This makes the stale-prompt bug impossible, not merely unlikely.+ var conversation = task(title: "original prompt", detail: "agent's latest line", status: .running)+ conversation.detail = "" // a stray blank write…+ #expect(conversation.detail == "agent's latest line") // …is refused, the latest line stands+ conversation.detail = " \n " // whitespace counts as blank…+ #expect(conversation.detail == "agent's latest line")+ #expect(conversation.chinDisplayText == "agent's latest line")+ #expect(conversation.chinDisplayText != "original prompt")+ // A real newer line still moves it forward — monotonic means forward-only, not frozen.+ conversation.detail = "newer line"+ #expect(conversation.chinDisplayText == "newer line")+ }++ @Test+ func resumeLineIsNeverEmptySoTheChinDoesNotRevertToTheStalePrompt() {+ // A resume (gate approval / tap-Resume) announces `.resumed` with no per-call detail, so the chin+ // shows that line until the first step narrates. The line must be non-empty: an empty `detail`+ // makes `chinDisplayText` fall back to `title` — the original prompt the user already sent. The+ // exact bug this guards: after approving a permission gate the chin "reappeared" the opening+ // request instead of live progress.+ let resumeLine = UserQueryActivity(kind: .resumed).displayText+ #expect(!resumeLine.isEmpty)+ let resumed = task(title: "original prompt", detail: resumeLine, status: .running)+ #expect(resumed.chinDisplayText == resumeLine)+ #expect(resumed.chinDisplayText != "original prompt")+ }}