A tiny friend in your Mac's notch and on your iPhone that keeps an eye on your AI coding agents: Claude Code, Codex, Cursor, Gemini CLI, Antigravity and more. Approve from the notch or your Lock Screen.
Swift ai-agentsanthropicantigravityclaudeclaude-codecodexcursordynamic-islandgemini-cliiosiphonlinuxmacosmacos-appmenubar-appnotchopen-sourceswiftswiftuiwindows
fix: revert FinishedView overflow, first-paragraph toOneLine (#179)
Louisd5d0e49c07a5
diff --git a/NotchBuddy/Sources/App/AppState.swift b/NotchBuddy/Sources/App/AppState.swiftindex 9ef42b48..1b989da2 100644--- a/NotchBuddy/Sources/App/AppState.swift+++ b/NotchBuddy/Sources/App/AppState.swift@@ -320,19 +320,6 @@ final class AppState: ObservableObject {// nextDiffId intentionally NOT reset — ids remain unique across sessions}- /// Unique touched files for a pill, in first-touch order, with summed totals.- func touchedFiles(for pillId: String) -> [(path: String, added: Int, removed: Int)] {- guard let diffs = sessionDiffs[pillId] else { return [] }- var seen: [String: (added: Int, removed: Int)] = [:]- var order: [String] = []- for d in diffs {- if seen[d.path] == nil { order.append(d.path) }- let p = seen[d.path] ?? (0, 0)- seen[d.path] = (p.added + d.added, p.removed + d.removed)- }- return order.map { path in let t = seen[path]!; return (path, t.added, t.removed) }- }-private func resetSessionDiffTimer(for pillId: String) {sessionDiffTimers[pillId]?.cancel()let work = DispatchWorkItem { [weak self] indiff --git a/NotchBuddy/Sources/App/DiffEngine.swift b/NotchBuddy/Sources/App/DiffEngine.swiftindex d7164bc2..2b71f00c 100644--- a/NotchBuddy/Sources/App/DiffEngine.swift+++ b/NotchBuddy/Sources/App/DiffEngine.swift@@ -218,23 +218,54 @@ enum DiffEngine {// MARK: - toOneLine/// Converts a possibly multi-line, markdown-formatted string to a single line of plain text.- /// Strips `**`, `__`, backticks and leading `#` chars from each line, collapses whitespace.+ /// Uses only the first non-empty paragraph (stops at blank line, horizontal rule, or table row).+ /// Strips `**`, `__`, backticks, leading `#`, and leading bullet markers.static func toOneLine(_ text: String, maxChars: Int = 200) -> String {- var s = text- s = s.replacingOccurrences(of: "**", with: "")- s = s.replacingOccurrences(of: "__", with: "")- s = s.replacingOccurrences(of: "`", with: "")- let processed: [String] = s.components(separatedBy: "\n").compactMap { line in- var l = line- while l.hasPrefix("#") { l = String(l.dropFirst()) }- let trimmed = l.trimmingCharacters(in: .whitespaces)- return trimmed.isEmpty ? nil : trimmed+ let lines = text.components(separatedBy: "\n")++ // Split into paragraphs. Separators: blank line, HR (3+ repeated -/*/_ chars), table row (starts with |).+ var paragraphs: [[String]] = []+ var current: [String] = []+ for line in lines {+ let trimmed = line.trimmingCharacters(in: .whitespaces)+ let isHR = trimmed.count >= 3 && (trimmed.allSatisfy { $0 == "-" } ||+ trimmed.allSatisfy { $0 == "*" } ||+ trimmed.allSatisfy { $0 == "_" })+ let isSep = trimmed.isEmpty || isHR || trimmed.hasPrefix("|")+ if isSep {+ if !current.isEmpty { paragraphs.append(current); current = [] }+ } else {+ current.append(line)+ }+ }+ if !current.isEmpty { paragraphs.append(current) }++ // Find first paragraph that yields non-empty text after cleaning.+ for paraLines in paragraphs {+ var s = paraLines.joined(separator: "\n")+ s = s.replacingOccurrences(of: "**", with: "")+ s = s.replacingOccurrences(of: "__", with: "")+ s = s.replacingOccurrences(of: "`", with: "")+ let processed: [String] = s.components(separatedBy: "\n").compactMap { line in+ var l = line+ while l.hasPrefix("#") { l = String(l.dropFirst()) }+ l = l.trimmingCharacters(in: .whitespaces)+ // Strip leading bullet markers: -, *, •, or N. (ordered list)+ if l.hasPrefix("- ") || l.hasPrefix("* ") || l.hasPrefix("• ") {+ l = String(l.dropFirst(2))+ } else if let m = l.range(of: #"^\d+\.\s+"#, options: .regularExpression) {+ l = String(l[m.upperBound...])+ }+ let trimmed = l.trimmingCharacters(in: .whitespaces)+ return trimmed.isEmpty ? nil : trimmed+ }+ let joined = processed.joined(separator: " ")+ let collapsed = joined.components(separatedBy: .whitespaces)+ .filter { !$0.isEmpty }+ .joined(separator: " ")+ if !collapsed.isEmpty { return String(collapsed.prefix(maxChars)) }}- let joined = processed.joined(separator: " ")- let collapsed = joined.components(separatedBy: .whitespaces)- .filter { !$0.isEmpty }- .joined(separator: " ")- return String(collapsed.prefix(maxChars))+ return ""}}diff --git a/NotchBuddy/Sources/App/IslandViewContent.swift b/NotchBuddy/Sources/App/IslandViewContent.swiftindex 40335816..6068cbf7 100644--- a/NotchBuddy/Sources/App/IslandViewContent.swift+++ b/NotchBuddy/Sources/App/IslandViewContent.swift@@ -527,89 +527,42 @@ struct ErrorView: View {struct FinishedView: View {@ObservedObject var state: AppState- @State private var showingDiff: FileDiff? = nilvar body: some View {ZStack {CardBackground(wash: .green)- if let diff = showingDiff {- DiffCardView(diff: diff, onDismiss: { showingDiff = nil })- .transition(.opacity)- } else {- VStack(alignment: .leading, spacing: 5) {- AgentWho(task: state.focusTask, label: "Claude Code finished")- Text({- if let fl = state.focusTask?.finalLine { return fl }- if let s = state.focusTask?.steps.last(where: { !$0.isDiffStep }) { return s }- return "Session finished"- }())- .font(.system(size: 15, weight: .semibold))- HStack(spacing: 8) {- #if !APPSTORE- PrimaryButton("Open terminal") {- let terminalBundleIds = ["com.apple.Terminal", "com.googlecode.iterm2", "net.kovidgoyal.kitty", "com.mitchellh.ghostty"]- let activated = terminalBundleIds.compactMap { id in- NSWorkspace.shared.runningApplications.first { $0.bundleIdentifier == id }- }.first.map { $0.activate(options: .activateIgnoringOtherApps) }- if activated == nil {- NSWorkspace.shared.open(URL(fileURLWithPath: "/System/Applications/Utilities/Terminal.app"))- }- NotificationCenter.default.post(name: .islandCollapse, object: nil)- }- #endif- SecondaryButton("OK") {- NotificationCenter.default.post(name: .islandCollapse, object: nil)+ VStack(alignment: .leading, spacing: 5) {+ AgentWho(task: state.focusTask, label: "Claude Code finished")+ Text({+ if let fl = state.focusTask?.finalLine { return fl }+ if let s = state.focusTask?.steps.last(where: { !$0.isDiffStep }) { return s }+ return "Session finished"+ }())+ .font(.system(size: 15, weight: .semibold))+ .lineLimit(1)+ .truncationMode(.tail)+ HStack(spacing: 8) {+ #if !APPSTORE+ PrimaryButton("Open terminal") {+ let terminalBundleIds = ["com.apple.Terminal", "com.googlecode.iterm2", "net.kovidgoyal.kitty", "com.mitchellh.ghostty"]+ let activated = terminalBundleIds.compactMap { id in+ NSWorkspace.shared.runningApplications.first { $0.bundleIdentifier == id }+ }.first.map { $0.activate(options: .activateIgnoringOtherApps) }+ if activated == nil {+ NSWorkspace.shared.open(URL(fileURLWithPath: "/System/Applications/Utilities/Terminal.app"))}+ NotificationCenter.default.post(name: .islandCollapse, object: nil)}- // Touched files (up to 4)- let files = state.touchedFiles(for: state.focusTask?.id ?? "")- if !files.isEmpty {- let shown = Array(files.prefix(4))- VStack(alignment: .leading, spacing: 2) {- ForEach(shown.indices, id: \.self) { i in- let f = shown[i]- Button(action: {- withAnimation(.easeIn(duration: 0.16)) {- if let taskId = state.focusTask?.id,- let diffs = state.sessionDiffs[taskId],- let last = diffs.last(where: { $0.path == f.path }) {- showingDiff = last- }- }- }) {- HStack(spacing: 4) {- Text(URL(fileURLWithPath: f.path).lastPathComponent)- .font(.system(size: 10.5))- .foregroundColor(Color(hex: "#9398A1"))- .lineLimit(1).truncationMode(.middle)- if f.added > 0 {- Text("+\(f.added)")- .font(.system(size: 9, weight: .medium).monospaced())- .foregroundColor(Color(hex: "#22C55E"))- }- if f.removed > 0 {- Text("−\(f.removed)")- .font(.system(size: 9, weight: .medium).monospaced())- .foregroundColor(Color(hex: "#F4505E"))- }- }- }- .buttonStyle(.plain)- }- if files.count > 4 {- Text("+ \(files.count - 4) more")- .font(.system(size: 10))- .foregroundColor(Color(hex: "#6B7079"))- }- }+ #endif+ SecondaryButton("OK") {+ NotificationCenter.default.post(name: .islandCollapse, object: nil)}}- .padding(.leading, 116)- .padding(.trailing, 16)- .padding(.vertical, 4)- .frame(maxWidth: .infinity, alignment: .leading)- .transition(.opacity)}+ .padding(.leading, 116)+ .padding(.trailing, 16)+ .padding(.vertical, 4)+ .frame(maxWidth: .infinity, alignment: .leading)}}}diff --git a/docs/INTEGRATIONS.md b/docs/INTEGRATIONS.mdindex 8eed56de..75318f67 100644--- a/docs/INTEGRATIONS.md+++ b/docs/INTEGRATIONS.md@@ -133,7 +133,7 @@ Sur `PostToolUse` pour `Edit`, `MultiEdit` et `Write` (Claude Code, Cursor), l'a- Lignes en monospace 10,5 pt, fond vert ou rouge à 12 %, symbole +/− en marge, 3 lignes de contexte- Défilement vertical ; Échap ou clic sur l'en-tête pour revenir au fil-**Vue Terminé (FinishedView)** — liste les fichiers touchés (nom + bilan, 4 au plus, puis "+ N more"). Un clic affiche la carte diff du dernier diff connu pour ce fichier.+**Vue Terminé (FinishedView)** — affiche la dernière ligne utile de la session (`finalLine` → dernière étape non-diff → "Session finished"), sur une ligne (`.lineLimit(1).truncationMode(.tail)`). Pas de liste de fichiers.---diff --git a/docs/SPEC.md b/docs/SPEC.mdindex b35fd8b2..75d89106 100644--- a/docs/SPEC.md+++ b/docs/SPEC.md@@ -90,7 +90,7 @@ Centre vertical du bonhomme : 36 + (hauteur − 46) / 2, sauf `result` (y = 86).### Diff en direct-Quand une étape du fil est une modification de fichier (préfixe interne `\u{E001}`), elle s'affiche avec le nom du fichier et le bilan `+N −M` en couleur. Un clic sur la ligne courante ou la ligne précédente ouvre la carte diff (voir DiffCardView) dans la carte gauche de la vue principale, en remplacement du fil — que la pastille soit intégrée (integration_claude, agent_cursor…) ou non. Échap ou le bouton ← de l'en-tête ferme la carte. La vue Terminé liste les fichiers touchés. En fin de tâche (Stop), la ligne courante du fil passe en texte statique (couleur `#C9CDD4`, sans brillance) tant que la tâche n'est pas relancée ; elle est construite à partir du dernier message de l'assistant (champ `last_assistant_message` de l'événement Stop, nettoyé du Markdown par `DiffEngine.toOneLine`).+Quand une étape du fil est une modification de fichier (préfixe interne `\u{E001}`), elle s'affiche avec le nom du fichier et le bilan `+N −M` en couleur. Un clic sur la ligne courante ou la ligne précédente ouvre la carte diff (voir DiffCardView) dans la carte gauche de la vue principale, en remplacement du fil — que la pastille soit intégrée (integration_claude, agent_cursor…) ou non. Échap ou le bouton ← de l'en-tête ferme la carte. En fin de tâche (Stop), la ligne courante du fil passe en texte statique (couleur `#C9CDD4`, sans brillance) tant que la tâche n'est pas relancée ; elle est construite à partir du dernier message de l'assistant (champ `last_assistant_message` de l'événement Stop, nettoyé du Markdown par `DiffEngine.toOneLine` — premier paragraphe utile uniquement).### Pastilles (overview)- 132 × 34, rayon 17, fond couleur de l'agent à 13 %, bord à 32 %, mini-bonhomme Ø 24 centré à 17 pt du bord gauche, libellé 12 pt couleur de l'agent éclaircie de 25 %. Deux colonnes, écart 8, centrées verticalement dans la carte droite (qui commence à x = 342).diff --git a/tests/DiffEngineTests.swift b/tests/DiffEngineTests.swiftindex d5cb223f..bff589c6 100644--- a/tests/DiffEngineTests.swift+++ b/tests/DiffEngineTests.swift@@ -175,6 +175,39 @@ enum DiffEngineTests {// truncationlet long = DiffEngine.toOneLine(String(repeating: "x ", count: 200), maxChars: 10)checkTrue("truncated to maxChars", long.count <= 10)++ // stop at blank line+ checkTrue("blank line → first para only",+ DiffEngine.toOneLine("First para.\n\nSecond para.") == "First para.")++ // stop at --- separator+ checkTrue("--- separator → first para only",+ DiffEngine.toOneLine("Done. Single commit 450a657 on github-pulse.\n\n---\n\nFiles touched (7)…")+ == "Done. Single commit 450a657 on github-pulse.")++ // stop at *** separator+ checkTrue("*** separator → first para only",+ DiffEngine.toOneLine("Summary line.\n***\nMore details.") == "Summary line.")++ // stop at table row (|)+ checkTrue("table row → first para only",+ DiffEngine.toOneLine("Result:\n| Col1 | Col2 |\n|---|---|\n| A | B |") == "Result:")++ // strip leading bullet -+ checkTrue("strip bullet -",+ DiffEngine.toOneLine("- item one\n- item two") == "item one item two")++ // strip leading bullet *+ checkTrue("strip bullet *",+ DiffEngine.toOneLine("* first\n* second") == "first second")++ // strip ordered list+ checkTrue("strip ordered list",+ DiffEngine.toOneLine("1. step one\n2. step two") == "step one step two")++ // first paragraph empty → fall through to next+ checkTrue("empty first para → next",+ DiffEngine.toOneLine("\n\nActual content.") == "Actual content.")}// ── finish ─────────────────────────────────────────────────────────────