From 46cec816ec45a1db5509cbde39d4910838649b03 Mon Sep 17 00:00:00 2001 From: Alan Wizemann Date: Fri, 1 May 2026 13:27:49 +0200 Subject: [PATCH] fix(cron): allow clearing an existing workdir on edit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `updateJob` only emitted `--workdir ` when the value was non-empty, so once a workdir was set on a job, the user had no way to remove it through Scarf — clearing the TextField and saving was a silent no-op. Hermes' `cron edit --workdir` argparse documents passing an empty string as the explicit clear gesture (mirroring the existing `--script` shape, which already passes empty through here). Drop the `!isEmpty` predicate so a non-nil value — including "" — reaches the CLI. The previous capability gate keeps this safe on pre-v0.12 hosts: CronView passes `workdir: nil` there, so the flag is omitted and v0.11 argparse is never asked about an unknown arg. Co-Authored-By: Claude Opus 4.7 (1M context) --- scarf/scarf/Features/Cron/ViewModels/CronViewModel.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scarf/scarf/Features/Cron/ViewModels/CronViewModel.swift b/scarf/scarf/Features/Cron/ViewModels/CronViewModel.swift index 025ae7b..6150e37 100644 --- a/scarf/scarf/Features/Cron/ViewModels/CronViewModel.swift +++ b/scarf/scarf/Features/Cron/ViewModels/CronViewModel.swift @@ -161,7 +161,10 @@ final class CronViewModel { for skill in newSkills where !skill.isEmpty { args += ["--skill", skill] } } if let script { args += ["--script", script] } - if let workdir, !workdir.isEmpty { args += ["--workdir", workdir] } + // `nil` = caller didn't touch the field (omit the flag). Empty string + // = user cleared an existing workdir; Hermes documents `--workdir ""` + // on edit as the explicit clear gesture, mirroring the `--script` shape. + if let workdir { args += ["--workdir", workdir] } runAndReload(args, success: "Updated") }