Commit Graph
5 Commits
Author SHA1 Message Date
yetoneandggbdpq 8820646f7c library, agent: the gone-agent tests pass on Windows, with or without the Codex app installed, and no package's tests read the machine's Store apps (#2254, ggbdpq)
ggbdpq found TestTargetsLeaveGoneAgentsOut and TestGoneAgentKeepsWhatItHas
(from e413512d8) red on a Windows machine with the Codex desktop app.
Their patch (ggbdpq/magpie fix-2254-gone-test, ddd44c36) skipped the
tests when HasApp said so, which proves nothing on such machines, and set
a PATH of the test's own. This takes their hermes fixture fix and makes
the rest hermetic instead:

- agent: windowsStorePackages reads none of the machine's AppX registry
  in a test binary testenv isolated (proc.Isolated), as SystemDirs already
  keeps the machine's folders out. Only agent's own TestMain stood in for
  it before, so library's tests (and any other package's) saw a real
  Codex app, and codex's CLI was never gone there.
- library: the hermes fixture goes where Hermes reads it
  (appdir.HermesHome: %LOCALAPPDATA%\hermes on Windows). In ~/.hermes
  hermes was never detected there, and Takes refused nothing.
- library: TestGoneAgentKeepsWhatItHas uses Pi, which goes on every
  system. On Windows a ~\.codex whose CLI isn't found is never taken for
  a leftover (#1482, by design), so the test with codex failed on every
  Windows machine, Codex app or not. The PATH change in the patch made
  no difference to that.
- TestRTKLeavesGoneAgentsOut keeps codex; it already skips on Windows
  (its fake rtk is a shell script).

Run:
- Windows 11 box, test binaries cross-built (amd64): old main had
  TestTargetsLeaveGoneAgentsOut and TestGoneAgentKeepsWhatItHas FAIL
  (Takes(hermes) <nil>; codex a target), new both PASS. Full library and
  agent packages there: new fails only what old fails too (library:
  TestAgentsSkillsFolders, TestHooksCodexTrustMovesWithTheGroups, filed as
  #2275; TestCheckKeepsToolNames and agent's 10 are from running a test
  .exe away from its source: testdata, ../gui, go and bash not there).
- Broken by hand: TestStorePackagesNotTheMachinesInTests without the
  Isolated check reads the box's 152 Store packages and goes red; with
  Targets' CLIMissing filter removed, both library tests go red on macOS.
- macOS: go test of agent, proc, library; gofmt -l; go vet -tags nogui
  for darwin, linux, windows on the three packages.

Full suite: SUITE_LINE

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-10-15 23:08:01 +08:00
yetone 55213c1b4d agent: the Windows Codex app's version comes from its main Store package only, and agent tests never read the machine's AppX registry (#1334)
Review follow-up to 46e4107 (AwadYoo).

What:
- storeAppVersion counts only the main package (empty resource id). The
  Windows box's AppX registry key keeps a resource package that Get-AppxPackage
  no longer lists (Clipchamp.Clipchamp_4.6.10420.0_neutral_split.scale-125_…
  beside the installed 4.7.10020.0_x64__…). A stale entry like that is no sign
  the app is installed, and a newer-numbered one would win "newest".
- internal/agent's TestMain stubs windowsStorePackages, as it already does
  for nodeModulesOf and the other machine readers (#1823's rule): on a
  Windows box with the Codex app installed, tests read nothing of it.
- the doc comment for storeAppVersion had a blank line in the middle of it.
  It is joined, and windowsStorePackages has its own comment.

Run (go1.26.8, sandbox HOME, private GOCACHE):
- Windows box (Win 11 x64): installed the real Store app (winget
  9PLM9XGG6VKS, "ChatGPT", OpenAI.Codex_26.1007.2314.0_x64__2p2nqsd0c76g0).
  A probe built from origin/main printed AppVersion="" HasApp=false; built
  from this series: AppVersion="26.1007.2314.0" HasApp=true, and CLI()
  ok=true App="26.1007.2314.0" with no codex CLI on PATH.
- break checks: the resource-id filter put back to len(fields) < 3 ->
  TestCodexWindowsStoreAppVersion FAIL `Codex Store app: "27.0.0.0"`;
  AppVersion without the Store read -> FAIL `Codex Store app: ""`.
  Restored: pass on darwin and on the Windows box (test binary built with
  GOOS=windows GOARCH=amd64, run there with the real app installed).
2026-10-13 05:48:39 +08:00
尤贺雨 4697ff2324 agent: the Agents page shows the Windows Codex app's version, read from the Microsoft Store package registered for the user (#1334, laacmilan)
On Windows the Codex app is the Store package OpenAI.Codex
(C:\Program Files\WindowsApps\OpenAI.Codex_26.1002.7124.0_x64__2p2nqsd0c76g0
in the report), which magpie didn't read: only %LOCALAPPDATA%\Programs was
looked in. The version now comes from the package full names under the
current user's AppX repository key (HKCU\...\AppModel\Repository\Packages),
which needs no access to the protected WindowsApps folder and starts no
PowerShell. The newest OpenAI.Codex package with publisher id 2p2nqsd0c76g0
wins.

Test: TestCodexWindowsStoreAppVersion (picks the newest, skips a bad
version and another publisher, and a WSL twin shows none).

[Message rewritten at review to say what and why; the code is AwadYoo's. The
conflict with 2221b63f9 (macAppFolders) was resolved by keeping both.]
2026-10-13 05:48:39 +08:00
yetone 2221b63f93 agent, provider: tests no longer read the machine's /Applications or Program Files, so a Mac with DeepSeek Harness.app installed keeps TestAsideOfflineDisconnectRestoresWithoutDaemon green (#1823)
What: every place magpie looks for installed apps outside the home folder
now goes through proc.SystemDirs, which in a test binary testenv isolated
puts the path under the test's home (as it already does for Homebrew's
bin, #1525):
- agent: a new macAppFolders(home) (/Applications via SystemDirs, plus
  ~/Applications) is used by appFolders (desktop apps: Codex, dsh),
  pencilApp, t3App and reasonixDetected;
- cursorLocalRoots: macOS through macAppFolders, Windows' ProgramFiles and
  Linux's /opt, /usr/share, /usr/lib through SystemDirs;
- zedAppPath's /Applications/Zed*.app, npmGlobalPrefix's ProgramFiles npm
  fallback, and provider's /Applications/ZCode.app builtin config.
Production behaviour is unchanged: SystemDirs returns paths as they are
outside a sandboxed test.

Why: HasApp/AppVersion read the real /Applications, so on a Mac with
DeepSeek Harness.app the dsh fixture's CLI was never "missing" and the test
failed every time; CI has no such app, so nobody else saw it. The same
shape was in five other readers.

Test: TestAppFoldersStayInTheTestHome checks every app folder lies under
testenv's home (all OSes), and on macOS that an app installed in the
sandbox's /Applications is the one found.

Run (go1.26.8, sandbox HOME, private GOCACHE):
- repro on old code: appFolders pointed at a temp folder holding a fake
  "DeepSeek Harness.app/Contents/Info.plist" (com.deepseek.dsh) ->
  TestAsideOfflineDisconnectRestoresWithoutDaemon FAIL "native fixture must
  report missing CLI".
- break check: macAppFolders put back to the literal /Applications ->
  TestAppFoldersStayInTheTestHome FAIL (appFolders, macAppFolders,
  cursorLocalRoots look in /Applications; sandbox app not found). Restored:
  pass.
- gofmt -l clean; go vet ./... (darwin), GOOS=linux go vet -tags nogui
  ./..., GOOS=windows go vet ./...: clean.
- go test -tags nogui ./internal/agent ./internal/proc ./internal/provider: ok.
- -race -count=5 on the touched agent tests: ok.
Not run: the full go test ./...; Windows and Linux test runs (vet only);
reasonix's Windows registry lookup and Zed's mdfind fallback still ask
the machine (not folder paths) and are left as they are.

Reported-by: mdwsk88
2026-10-12 23:56:20 +08:00
yetone ae24bcfcfb agent, gui: Codex's row on the Agents page shows its desktop app's version beside its CLI's ("CLI 0.130.0", "App 26.930.31730"), and the app's alone where no CLI is on PATH (#1334, laacmilan)
The app's version is read from /Applications or ~/Applications
ChatGPT.app (or Codex.app) Contents/Info.plist, taken only when its bundle
id is com.openai.codex, so the ChatGPT chat app (com.openai.chat) isn't
taken for it. macOS only: the Windows Store package isn't read yet. The
app chip's tooltip says it reads the same settings as the CLI, so
connecting Codex connects both. At narrow widths the chip ellipsizes, and
below 250px it gives way so the name keeps its room.

Verified: TestCodexAppVersion fails without the CLI() change ("the app
alone, no CLI"); agent-app-version.test.cjs fails 12/16 without the app.js
change and passes 16/16 with it, Chromium and WebKit, en/zh/ja/de, at 980,
560 and 440px. agent-cli-missing, agent-connect, agent-field-names,
agent-layout, agent-update-all, cli-update, click-scroll, gui-ja, gui-de,
i18n-keys pass in both engines. internal/agent passes in Linux Docker
(non-root); full ./... on macOS; vet darwin/linux/windows. Read
26.930.51102 from the real /Applications/ChatGPT.app on this Mac. Not
tried on the reporter's machine.
2026-10-09 00:02:40 +08:00