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(kit): open the tapped routine on iPhone instead of a blank form

leepokai303bd75c0e98
diff --git a/kit/Sources/CodyncUI/Routines/RoutineEditorView.swift b/kit/Sources/CodyncUI/Routines/RoutineEditorView.swift
index 3a424b2e..4c21625b 100644
--- a/kit/Sources/CodyncUI/Routines/RoutineEditorView.swift
+++ b/kit/Sources/CodyncUI/Routines/RoutineEditorView.swift
@@ -21,6 +21,8 @@ struct RoutineEditorView: View {
@State private var checkedSchedule: RoutineScheduleDraft?
@State private var confirmDelete = false
@State private var started = false
+ /// Any text field is being edited; cleared on save so nothing sits under the keyboard.
+ @FocusState private var typing: Bool
/// Schedule or webhook, as in Claude Code routines. Anything else the bot set up
/// (a one-off time, an interval, events, several triggers) stays as it is until replaced.
@@ -51,7 +53,7 @@ struct RoutineEditorView: View {
// The card fits the form; it scrolls only when taller than the window allows.
ViewThatFits(in: .vertical) { form; ScrollView { form } }
#else
- ScrollView { form }
+ ScrollView { form }.scrollDismissesKeyboard(.interactively)
#endif
}
.disabled(busy || !loaded)
@@ -91,11 +93,11 @@ struct RoutineEditorView: View {
VStack(alignment: .leading, spacing: 24) {
VStack(alignment: .leading, spacing: 14) {
Field("Name") {
- TextField("Name", text: $name, prompt: Text("e.g. Morning summary").foregroundStyle(Palette.secondary)).routineInput()
+ TextField("Name", text: $name, prompt: Text("e.g. Morning summary").foregroundStyle(Palette.secondary)).routineInput().focused($typing)
}
Field("Instruction") {
TextField("Instruction", text: $instruction, prompt: Text("Describe what this bot should do each time it runs.").foregroundStyle(Palette.secondary), axis: .vertical)
- .lineLimit(3...8).routineInput()
+ .lineLimit(3...8).routineInput().focused($typing)
}
}
VStack(alignment: .leading, spacing: 14) {
@@ -124,7 +126,7 @@ struct RoutineEditorView: View {
.buttonStyle(.plain)
.accessibilityValue(advanced ? "Expanded" : "Collapsed")
if advanced {
- Field("Timeout (seconds)") { TextField("3600", text: $timeout).routineInput() }
+ Field("Timeout (seconds)") { TextField("3600", text: $timeout).routineInput().focused($typing) }
Text("A run is stopped after this long. 1 second to 24 hours.")
.font(.caption).foregroundStyle(Palette.secondary).padding(.leading, 4)
}
@@ -198,7 +200,7 @@ struct RoutineEditorView: View {
private var expressionField: some View {
Field("Cron") {
TextField("Cron", text: $schedule.expression, prompt: Text("0 9 * * 1-5").foregroundStyle(Palette.secondary))
- .font(.body.monospaced()).autocorrectionDisabled().routineInput()
+ .font(.body.monospaced()).autocorrectionDisabled().routineInput().focused($typing)
.frame(minWidth: 220)
}
}
@@ -206,7 +208,7 @@ struct RoutineEditorView: View {
private var zoneField: some View {
Field("Time zone") {
TextField("Time zone", text: $schedule.zone, prompt: Text("Asia/Taipei").foregroundStyle(Palette.secondary))
- .autocorrectionDisabled().routineInput()
+ .autocorrectionDisabled().routineInput().focused($typing)
}
}
@@ -306,6 +308,8 @@ struct RoutineEditorView: View {
private func save() {
guard let client = model.client, canSave else { return }
+ // Saving ends editing (a new webhook routine stays open on its URL and key, not under the keyboard).
+ typing = false
busy = true
error = nil
Task {
diff --git a/kit/Sources/CodyncUI/Routines/RoutineWebhookPanel.swift b/kit/Sources/CodyncUI/Routines/RoutineWebhookPanel.swift
index 7794b7ca..81005686 100644
--- a/kit/Sources/CodyncUI/Routines/RoutineWebhookPanel.swift
+++ b/kit/Sources/CodyncUI/Routines/RoutineWebhookPanel.swift
@@ -21,7 +21,7 @@ struct RoutineWebhookPanel: View {
value(webhook.url ?? webhook.localUrl, copy: "url")
}
Field("Key") {
- value(showKey ? webhook.key : String(repeating: "•", count: 24), copy: "key") {
+ value(showKey ? webhook.key : String(repeating: "•", count: 16), copy: "key") {
IconButton(showKey ? "Hide key" : "Show key", systemImage: showKey ? "eye.slash" : "eye") {
withAnimation(Motion.reduced(Motion.hover, reduceMotion)) { showKey.toggle() }
}
diff --git a/kit/Sources/CodyncUI/Routines/RoutinesView.swift b/kit/Sources/CodyncUI/Routines/RoutinesView.swift
index 3146c6f2..8d9fccf3 100644
--- a/kit/Sources/CodyncUI/Routines/RoutinesView.swift
+++ b/kit/Sources/CodyncUI/Routines/RoutinesView.swift
@@ -10,12 +10,11 @@ struct RoutinesView: View {
@Environment(\.accessibilityReduceMotion) private var reduceMotion
@State private var routines: [Routine] = []
@State private var runs: [RoutineRun] = []
- /// The routine the editor is open on; nil with `showEditor` sets up a new one.
- @State private var editingId: String?
+ /// The open editor: on a routine, or (`routineId` nil) setting up a new one.
+ @State private var editing: EditorTarget?
@State private var loaded = false
@State private var busy = false
@State private var error: String?
- @State private var showEditor = false
@State private var loadError: String?
var body: some View {
@@ -44,16 +43,16 @@ struct RoutinesView: View {
do { try await Task.sleep(for: .seconds(3)) } catch { break }
} while !Task.isCancelled
}
- .codyncSheet(isPresented: $showEditor) {
- RoutineEditorView(botId: botId, routine: routines.first { $0.id == editingId }) { saved in
- let created = editingId == nil
+ // Item-based, so the editor always gets the routine it was opened on.
+ .codyncSheet(item: $editing) { 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) }
// A new webhook routine stays open: its URL and key exist only now.
- if created, let saved, saved.triggers.contains(where: { $0.type == "webhook" }) {
- animate { editingId = saved.id }
+ if target.routineId == nil, let saved, saved.triggers.contains(where: { $0.type == "webhook" }) {
+ editing = EditorTarget(id: target.id, routineId: saved.id)
} else {
- animate { showEditor = false }
+ animate { editing = nil }
}
Task { await load() }
}
@@ -135,7 +134,7 @@ struct RoutinesView: View {
}
private func animate(_ change: () -> Void) { withAnimation(Motion.reduced(Motion.layout, reduceMotion), change) }
- private func open(_ id: String?) { animate { editingId = id; showEditor = true } }
+ private func open(_ id: String?) { animate { editing = EditorTarget(id: UUID().uuidString, routineId: id) } }
private func edit(_ text: String) {
animate {
model.routineDrafts[botId] = text
@@ -165,3 +164,9 @@ struct RoutinesView: View {
} catch is CancellationError {} catch { self.loadError = error.localizedDescription }
}
}
+
+private 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?
+}