* Pre-launch app for browser UI test on headless CI runners
XCUIApplication.launch() blocks ~60s then fails on headless WarpBuild
runners because foreground activation requires a GUI login session.
Apply the same pre-launch strategy used for the display resolution test:
- CI shell launches the app with env vars before running xcodebuild
- Test detects pre-launched app via manifest, uses activate() instead of
launch() to avoid killing and relaunching the app
- Falls back to clicking the window for focus via accessibility framework
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Revert "Pre-launch app for browser UI test on headless CI runners"
This reverts commit a540e2fd99aaa1395b91a8d50caa797cdd7551b8.
* feat: cmux.json for custom commands
* tests: add cmux json tests
* fix: pr review feedback: validation, translations, input handling, and palette improvements
- Fix Danish ("Overfladedef inition") and Norwegian ("rotmapp") translation typos
- Add empty-string check for baseCwd fallback in command palette handlers
- Coalesce \r\n into single Return keypress in sendInput
- Redact command text from timeout log to prevent secret leakage
- Add decode-time validation: reject hybrid/empty commands, ambiguous layout
nodes, wrong split children count, and empty pane surfaces
- Namespace custom command IDs with "cmux.config.command." prefix
- Forward command description to palette subtitle when available
- Update tests for new validation rules and ID prefix
* fix: address PR review feedback — per-window config isolation, blank validation, ancestor walk,
palette sanitization
* fix: fallback to current dir cmux.json watching if no any cmux.json found in full acesor walk
* ci: trigger CI for fork PR
* Add directory trust for cmux.json command confirmation
The confirm dialog now shows the actual command text and has an "Always
trust commands from this folder" checkbox. When checked, future confirm
commands from that directory skip the dialog.
Trust is scoped to the git repo root if the cmux.json is inside a repo,
so trusting once covers all subdirectories. Non-git directories are
trusted by exact path. Global config is always trusted.
Trusted directories are persisted in ~/Library/Application Support/cmux/
trusted-directories.json.
* Add trusted directories section to Settings
Shows all trusted directories with per-directory revoke buttons and a
Clear All option. Placed in a "Custom Commands" section between
Automation and Browser in Settings.
* Replace trusted directories list with editable textarea
One path per line, with a Save button that activates on changes.
Users can add, remove, or edit paths directly.
* Auto-save trusted directories on edit, remove Save button
Matches the behavior of other textarea settings (browser host
whitelist, external URL patterns) which auto-save via @AppStorage.
* Sanitize command text in confirm dialog against BiDi attacks
Strip zero-width and BiDi override characters from the command preview
so the dialog shows exactly what will be executed.
---------
Co-authored-by: austinpower1258 <austinwang115@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Lawrence Chen <lawrencecchen@users.noreply.github.com>
112 lines
3.8 KiB
Swift
112 lines
3.8 KiB
Swift
import Foundation
|
|
|
|
/// Manages trusted directories for cmux.json command execution.
|
|
/// When a directory (or its git repo root) is trusted, `confirm: true` commands
|
|
/// from that directory's cmux.json skip the confirmation dialog.
|
|
/// Global config (~/.config/cmux/cmux.json) is always trusted.
|
|
final class CmuxDirectoryTrust {
|
|
static let shared = CmuxDirectoryTrust()
|
|
|
|
private let storePath: String
|
|
private var trustedPaths: Set<String>
|
|
|
|
private init() {
|
|
let appSupport = FileManager.default.urls(
|
|
for: .applicationSupportDirectory, in: .userDomainMask
|
|
).first!.appendingPathComponent("cmux")
|
|
storePath = appSupport.appendingPathComponent("trusted-directories.json").path
|
|
|
|
let fm = FileManager.default
|
|
if !fm.fileExists(atPath: appSupport.path) {
|
|
try? fm.createDirectory(atPath: appSupport.path, withIntermediateDirectories: true)
|
|
}
|
|
|
|
if let data = fm.contents(atPath: storePath),
|
|
let paths = try? JSONDecoder().decode([String].self, from: data) {
|
|
trustedPaths = Set(paths)
|
|
} else {
|
|
trustedPaths = []
|
|
}
|
|
}
|
|
|
|
/// Check if a cmux.json path is trusted.
|
|
/// Global config is always trusted. For local configs, check the git repo root
|
|
/// (or the cmux.json parent directory if not in a git repo).
|
|
func isTrusted(configPath: String, globalConfigPath: String) -> Bool {
|
|
if configPath == globalConfigPath { return true }
|
|
let trustKey = Self.trustKey(for: configPath)
|
|
return trustedPaths.contains(trustKey)
|
|
}
|
|
|
|
/// Trust the directory containing a cmux.json. If the cmux.json is inside a git
|
|
/// repo, trusts the repo root (covering all subdirectories).
|
|
func trust(configPath: String) {
|
|
let trustKey = Self.trustKey(for: configPath)
|
|
trustedPaths.insert(trustKey)
|
|
save()
|
|
}
|
|
|
|
/// Remove trust for a directory.
|
|
func revokeTrust(configPath: String) {
|
|
let trustKey = Self.trustKey(for: configPath)
|
|
trustedPaths.remove(trustKey)
|
|
save()
|
|
}
|
|
|
|
/// Remove trust by the trust key directly (as stored/displayed in settings).
|
|
func revokeTrustByPath(_ path: String) {
|
|
trustedPaths.remove(path)
|
|
save()
|
|
}
|
|
|
|
/// All currently trusted paths.
|
|
var allTrustedPaths: [String] {
|
|
Array(trustedPaths).sorted()
|
|
}
|
|
|
|
/// Replace all trusted paths (used by Settings textarea save).
|
|
func replaceAll(with paths: [String]) {
|
|
trustedPaths = Set(paths)
|
|
save()
|
|
}
|
|
|
|
/// Clear all trusted directories.
|
|
func clearAll() {
|
|
trustedPaths.removeAll()
|
|
save()
|
|
}
|
|
|
|
// MARK: - Private
|
|
|
|
/// Resolve the trust key for a cmux.json path: git repo root if inside a repo,
|
|
/// otherwise the cmux.json's parent directory.
|
|
static func trustKey(for configPath: String) -> String {
|
|
let configDir = (configPath as NSString).deletingLastPathComponent
|
|
if let gitRoot = findGitRoot(from: configDir) {
|
|
return gitRoot
|
|
}
|
|
return configDir
|
|
}
|
|
|
|
/// Walk up from `directory` looking for a `.git` directory or file.
|
|
private static func findGitRoot(from directory: String) -> String? {
|
|
let fm = FileManager.default
|
|
var current = directory
|
|
while true {
|
|
let gitPath = (current as NSString).appendingPathComponent(".git")
|
|
if fm.fileExists(atPath: gitPath) {
|
|
return current
|
|
}
|
|
let parent = (current as NSString).deletingLastPathComponent
|
|
if parent == current { break }
|
|
current = parent
|
|
}
|
|
return nil
|
|
}
|
|
|
|
private func save() {
|
|
let sorted = trustedPaths.sorted()
|
|
guard let data = try? JSONEncoder().encode(sorted) else { return }
|
|
FileManager.default.createFile(atPath: storePath, contents: data)
|
|
}
|
|
}
|