VoiceWake: document escape path and reset stale forward command

This commit is contained in:
Peter Steinberger
2025-12-07 18:23:13 +01:00
parent 7efa152418
commit 27e96999cf
4 changed files with 43 additions and 11 deletions

View File

@@ -302,8 +302,7 @@ enum CommandResolver {
let quotedArgs = (["clawdis", subcommand] + extraArgs).map(self.shellQuote).joined(separator: " ")
let cdPrefix = settings.projectRoot.isEmpty ? "" : "cd \(self.shellQuote(settings.projectRoot)) && "
let scriptBody = "\(cdPrefix)\(quotedArgs)"
let wrapped = VoiceWakeForwarder.commandWithCliPath(scriptBody, target: settings.target)
args.append(contentsOf: ["/bin/sh", "-c", wrapped])
args.append(contentsOf: ["/bin/sh", "-c", scriptBody])
return ["/usr/bin/ssh"] + args
}

View File

@@ -77,4 +77,30 @@ import Testing
let first = CommandResolver.preferredPaths().first
#expect(first == tmp.appendingPathComponent("node_modules/.bin").path)
}
@Test func buildsSSHCommandForRemoteMode() async throws {
UserDefaults.standard.set(AppState.ConnectionMode.remote.rawValue, forKey: connectionModeKey)
UserDefaults.standard.set("clawd@example.com:2222", forKey: remoteTargetKey)
UserDefaults.standard.set("/tmp/id_ed25519", forKey: remoteIdentityKey)
UserDefaults.standard.set("/srv/clawdis", forKey: remoteProjectRootKey)
defer {
UserDefaults.standard.removeObject(forKey: connectionModeKey)
UserDefaults.standard.removeObject(forKey: remoteTargetKey)
UserDefaults.standard.removeObject(forKey: remoteIdentityKey)
UserDefaults.standard.removeObject(forKey: remoteProjectRootKey)
}
let cmd = CommandResolver.clawdisCommand(subcommand: "status", extraArgs: ["--json"])
#expect(cmd.first == "/usr/bin/ssh")
#expect(cmd.contains("clawd@example.com"))
#expect(cmd.contains("-i"))
#expect(cmd.contains("/tmp/id_ed25519"))
if let script = cmd.last {
#expect(script.contains("cd '/srv/clawdis'"))
#expect(script.contains("clawdis"))
#expect(script.contains("status"))
#expect(script.contains("--json"))
}
}
}