Skip to content

Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.

fix(ios): open a routine from a chat link only once it is listed

leepokaicfdbdfd5e838
diff --git a/apps/ios/Kit/Sources/CodyncUI/Routines/RoutinesView.swift b/apps/ios/Kit/Sources/CodyncUI/Routines/RoutinesView.swift
index 618eb3ff..1b0e9c64 100644
--- a/apps/ios/Kit/Sources/CodyncUI/Routines/RoutinesView.swift
+++ b/apps/ios/Kit/Sources/CodyncUI/Routines/RoutinesView.swift
@@ -46,8 +46,8 @@ struct RoutinesView: View {
do { try await Task.sleep(for: .seconds(3)) } catch { break }
} while !Task.isCancelled
}
- // Item-based, so the editor always gets the routine it was opened on.
- .codyncSheet(item: $editing) { target in
+ // Item-based, so the editor always gets the routine it was opened on; it opens once that routine is listed.
+ .codyncSheet(item: Binding(get: { editing.flatMap { $0.isReady(in: routines) ? $0 : nil } }, set: { editing = $0 })) { target in
RoutineEditorView(botId: botId, routine: routines.first { $0.id == target.routineId }) { saved in
if let i = routines.firstIndex(where: { $0.id == saved?.id }), let saved { routines[i] = saved }
else if let saved { routines.append(saved) }
@@ -164,8 +164,14 @@ struct RoutinesView: View {
}
}
-private struct EditorTarget: Identifiable {
+struct EditorTarget: Identifiable {
/// One per opening; kept when a new routine is saved and the editor stays on it.
let id: String
let routineId: String?
+
+ /// A routine's editor waits until the routine is listed: a chat link can name one before the
+ /// first load (or the next poll), and an empty form would save defaults over it.
+ func isReady(in routines: [Routine]) -> Bool {
+ routineId == nil || routines.contains { $0.id == routineId }
+ }
}
diff --git a/apps/ios/Kit/Tests/CodyncUITests/RoutineEditorTests.swift b/apps/ios/Kit/Tests/CodyncUITests/RoutineEditorTests.swift
new file mode 100644
index 00000000..d69cfe8b
--- /dev/null
+++ b/apps/ios/Kit/Tests/CodyncUITests/RoutineEditorTests.swift
@@ -0,0 +1,12 @@
+import CodyncKit
+import Foundation
+import Testing
+@testable import CodyncUI
+
+@Test func routineEditorWaitsForItsRoutineToBeListed() throws {
+ let listing = try JSONDecoder().decode(RoutineListing.self, from: Data(#"{"routines":[{"id":"r","botId":"b","name":"Check","instruction":"Check","triggers":[],"enabled":false,"createdAt":0,"updatedAt":0,"triggerDescriptions":[]}],"runs":[]}"#.utf8))
+ #expect(!EditorTarget(id: "1", routineId: "r").isReady(in: []))
+ #expect(EditorTarget(id: "1", routineId: "r").isReady(in: listing.routines))
+ #expect(!EditorTarget(id: "1", routineId: "other").isReady(in: listing.routines))
+ #expect(EditorTarget(id: "1", routineId: nil).isReady(in: []))
+}