qwen-code/packages/cli
lamb 5a43efcae4
fix(editor): detect Zed.app on macOS when CLI is not in PATH (#3303)
* fix(editor): detect Zed.app on macOS when CLI is not in PATH

On macOS, Zed editor is typically installed via Homebrew or direct download,
but the CLI command 'zed' is not automatically added to PATH.

This fix adds detection for Zed.app bundle at:
- /Applications/Zed.app
- ~/Applications/Zed.app

When the CLI is not found but the app bundle exists, the code now falls back
to using the CLI inside the app bundle at Contents/MacOS/zed.

Fixes #3287

* fix(editor): use shared getEditorExecutable in useLaunchEditor

- Export getEditorExecutable() from editor.ts for use by both getDiffCommand and useLaunchEditor
- Updated useLaunchEditor.ts to use getEditorExecutable instead of its own implementation
- Updated tests to be platform-agnostic for macOS app bundle path testing
- Fixes: Zed on macOS is now detected when installed via app bundle (not just CLI in PATH)

* fix(editor): use correct Zed CLI path (Contents/MacOS/cli)

- Changed from Contents/MacOS/zed (GUI binary) to Contents/MacOS/cli (actual CLI)
- The GUI binary does not support --wait/--diff flags
- Updated tests to verify correct CLI path with regex matching for cross-platform

* style(editor): fix prettier trailing whitespace issues

Trailing spaces and array line-wrapping in zed macOS detection code.

* fix(editor): return null when editor not found + remove unused var

- getEditorExecutable now returns null (not fallback string) so
  useLaunchEditor error handling actually works
- remove unused getAppBundleCliPath in test file (typecheck fix)

* fix: add vitest globals to eslint config for test files

* fix: remove duplicate empty test with orphan toEqual call

* fix: resolve ESLint errors in editor.test.ts (arrow-body-style, no-useless-escape)

* chore: remove debug script check_braces.js

* fix: sync checkHasEditorType with getEditorExecutable, remove pr-body.md

- Replace zedAppExists() check in checkHasEditorType with
  getEditorExecutable() !== null, keeping availability detection
  and execution in sync (fixes partial install false positive)
- Remove unused zedAppExists() function
- Remove scratch file pr-body.md

* fix(editor): defer os.homedir() call to avoid breaking tests with incomplete node:os mocks

The zedMacOsPaths constant was calling homedir() at module initialization
time, which caused 'homedir is not a function' errors in CLI test files
(systemInfo.test.ts, shellCommandProcessor.test.ts) that mock node:os
without providing a homedir mock.

Fix: convert zedMacOsPaths from a constant to a lazy function
getZedAppPaths() that computes the paths only when called.

---------

Co-authored-by: lamb <906276457@qq.com>
2026-04-21 17:06:58 +08:00
..
src fix(editor): detect Zed.app on macOS when CLI is not in PATH (#3303) 2026-04-21 17:06:58 +08:00
index.ts feat(core): detect tool validation retry loops and inject stop directive (#3178) 2026-04-18 10:24:46 +08:00
package.json chore(release): bump version to 0.14.5 (#3298) 2026-04-15 22:43:29 +08:00
test-setup.ts fix: prevent bogus shell permission rules in tests 2026-03-20 17:55:33 +08:00
tsconfig.json Merge pull request #2428 from qqqys/feat/mcp_reconnect_error 2026-04-01 16:53:36 +08:00
vitest.config.ts refactor(core): Unify package exports and improve dev experience 2026-02-01 11:59:05 +08:00