A1: macOS readiness: setup guide, cargo xtask mac-report, unix/macOS fixes

- docs/macos.md: step-by-step setup for a fresh Apple Silicon Mac (Xcode
  CLT, Homebrew, git, PHP, Composer, Node 22, pnpm, rustup, clone from
  Forgejo), the machine report, Gatekeeper notes, macOS differences and
  what Windows cannot check.
- cargo xtask mac-report: versions, the gate steps, the bundled-UI desktop
  build and a self-check over the control channel (project, file,
  Phpactor, hover, git.status, terminal, screenshot, quit); every step
  times out and runs in a lutra_proc group; one report.md to send back.
- Fixes: macOS native menu (system menus only; Cmd+W stays buffer.close,
  Cmd+Q runs app.quit), xcap screenshot region in points on macOS
  (Retina), login shell (-l, /bin/zsh fallback) and LANG for the
  terminal on macOS, PHP lookup in Homebrew/MacPorts dirs for Finder
  starts, case-insensitive LSP path mapping on macOS, rendezvous file
  mode re-set to 0600, CLI-started desktop in its own process group.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
danny 2026-10-31 14:47:45 +01:00
parent da58c83158
commit 1bf69ded55
18 changed files with 1795 additions and 36 deletions

View file

@ -291,8 +291,8 @@ pub fn locations(state: &State, root: &Path, value: &Value) -> Vec<NavLocation>
}
/// `path` (absolute, from the server) relative to the project, or `None`
/// outside it. Windows paths compare without regard to case, as the file
/// system does, and `..` never escapes. A path that resolves through a
/// outside it. Windows and macOS paths compare without regard to case, as
/// their default file systems (NTFS, APFS) do, and `..` never escapes. A path that resolves through a
/// symbolic link to a place outside the project counts as outside.
pub fn project_relative(state: &State, root: &Path, path: &Path) -> Option<PathBuf> {
let rel = match state
@ -301,7 +301,7 @@ pub fn project_relative(state: &State, root: &Path, path: &Path) -> Option<PathB
.and_then(|w| w.project.relative(path))
{
Some(rel) => rel,
None => windows_relative(root, path)?,
None => case_insensitive_relative(root, path)?,
};
if rel.components().any(|c| !matches!(c, Component::Normal(_))) {
return None;
@ -316,9 +316,10 @@ pub fn project_relative(state: &State, root: &Path, path: &Path) -> Option<PathB
Some(rel)
}
/// The case-insensitive fallback of [`project_relative`] on Windows.
fn windows_relative(root: &Path, path: &Path) -> Option<PathBuf> {
if !cfg!(windows) {
/// The case-insensitive fallback of [`project_relative`] on Windows and
/// macOS.
fn case_insensitive_relative(root: &Path, path: &Path) -> Option<PathBuf> {
if !cfg!(any(windows, target_os = "macos")) {
return None;
}
let root_text = root.to_str()?.trim_end_matches(['\\', '/']);

View file

@ -152,7 +152,7 @@ impl Command for Create {
label: "New Terminal",
menu_path: None,
default_shortcut: None,
params: "{ cwd? (project-relative or absolute directory, default the project root), shell? (program name or path; default pwsh, then powershell, then cmd on Windows, $SHELL or /bin/sh elsewhere), cols, rows (1..=1000) }; returns { terminalId }, then events terminalOutput { terminalId, data } and terminalExited { terminalId, code }; at most 16 terminals",
params: "{ cwd? (project-relative or absolute directory, default the project root), shell? (program name or path; default pwsh, then powershell, then cmd on Windows, the login shell $SHELL -l (else /bin/zsh) on macOS, $SHELL or /bin/sh elsewhere), cols, rows (1..=1000) }; returns { terminalId }, then events terminalOutput { terminalId, data } and terminalExited { terminalId, code }; at most 16 terminals",
}
}

View file

@ -971,13 +971,14 @@ fn clear_diagnostics(state: &mut State) {
}
}
/// `path` relative to `root`; `None` outside it. Windows paths compare
/// without regard to case, as the file system does.
/// `path` relative to `root`; `None` outside it. Windows and macOS paths
/// compare without regard to case, as their default file systems (NTFS,
/// APFS) do.
fn relative(root: &Path, path: &Path) -> Option<PathBuf> {
if let Ok(rel) = path.strip_prefix(root) {
return Some(rel.to_path_buf());
}
if !cfg!(windows) {
if !cfg!(any(windows, target_os = "macos")) {
return None;
}
let root_text = root.to_str()?.trim_end_matches(['\\', '/']);
@ -1119,6 +1120,13 @@ mod tests {
Some(PathBuf::from("b.php"))
);
}
if cfg!(target_os = "macos") {
assert_eq!(
relative(&root, Path::new("/WORK/Demo/b.php")),
Some(PathBuf::from("b.php"))
);
assert_eq!(relative(&root, Path::new("/WORK/Demo2/b.php")), None);
}
}
#[test]