Repository navigation
fix(composer): replace execFileSync with async execFile to prevent main-process hang - #2227
Conversation
扩展桥接只修改运行时公开值,Pi Agent 仍携带旧档位。同步更新请求状态,保留模型能力校验,避免 getter 和实际 reasoning 参数不一致。 Refs vastsa#1974
主线已合入停止失败时保留运行状态的修复。保留独立问题的行为说明和新增停止场景,使共享分支继续包含当前主线且不改写历史。
3d001e7 to
5f69a28
Compare
…in-process hang The Windows paste-image path used spawnSync to probe the clipboard, which blocks the main process. On machines where PowerShell startup exceeds the 2s timeout, this manifests as a hard freeze on paste. Switch to async execFile with a Promise wrapper so the probe no longer holds up the main process, regardless of paste type. nativeClipboardPaths and readComposerClipboardDirectories are now async, so their existing callers and tests await the result. Two regression tests cover a probe slower than the former 2s bound and a failing probe, and both assert the event loop keeps running. closes vastsa#2220
5f69a28 to
c870341
Compare
Exercise the production async child-process boundary with controlled output and failure events. This guards the Windows clipboard probe against blocking the main process while preserving its process timeout and output bounds.
Write the Finder property list to plutil through the child stdin stream. The asynchronous execFile API does not support the synchronous input option, so keep the macOS paste path functional without blocking the main process.
…rshell-timeout-regression
A never-shown window throttles animation frames to roughly 1 Hz and then stops them, so the probe helpers wait on requestAnimationFrame forever and the suite is killed after 45 s with no output. Show the window, as the other frame-dependent suites already do.
fix(runtime): 扩展思考强度调整同步到实际请求
vastsa
left a comment
There was a problem hiding this comment.
The async direction addresses a real blocking call, but the production adapter currently crashes on macOS. Independently ran node --test apps/desktop/test/composer-clipboard-directories.test.mjs on macOS after a normal integration with main 036dfa0: 12 pass, 1 FAIL. The real plutil case throws uncaught ERR_INVALID_ARG_TYPE at Buffer.concat([stdout, chunk]): chunk is a string, because execFile defaults to utf8 encoding. The simulated children emit Buffers and therefore hide this production failure. The same helper serves Windows too.
Please explicitly select buffer encoding (encoding: null) or consistently handle string chunks, and retain a real child-process regression that exercises the default encoding boundary. Ensure asynchronous stream errors reject the Promise rather than escaping the event handler. Re-run native Finder decoding and Composer acceptance before landing; current macOS regression prevents approval.
execFile decodes stdout to utf8 strings by default, so Buffer.concat threw ERR_INVALID_ARG_TYPE from inside the data handler and escaped as an uncaught Main-process error. Pin the buffer encoding, accept string chunks defensively, and reject on stream errors. The mocked child processes emitted Buffers, which is why the macOS run failed while the suite passed. A regression now reads a real child process so the default-encoding boundary is exercised.
|
Fixed in Changes:
Coverage added in
Verification on this host (Windows):
I cannot re-run the native Finder decode on macOS: I have no Apple hardware, so that case is still covered only by the simulated child process, and Composer acceptance on macOS is not verified here. If you can run the suite on macOS, that remains the missing evidence. |
|
Rechecked the author fix on macOS against current main 036dfa0. The previously reproduced stdout decoding crash is resolved: the real child-process regression and native Finder plutil decode both pass. Clipboard/directory/paste suites: 42/42 pass; Desktop tsc --noEmit: pass. After building the candidate preload, the real Composer Electron suite passes all four draft-race scenarios, the full paste probe (directories, images, gallery/focus, session changes and scratch bytes), and restart persistence. The initial local attempts lacked dependency links/preload output; those were corrected, and are not counted as product failures. No native Windows PowerShell execution was performed. Merged latest main into the branch with an ordinary push, preserving contributor commits. Validated head c63e7c0; actual GitHub merge ref bda93eb has the same tree 8d0756526041ae0f4174dcdd76b34770a409fbde and current main/head parents. Fresh CI was awaiting external-contributor workflow approval; workflow files are unchanged and both runs have now been approved to execute. Waiting for the required checks before final approval/merge. |
vastsa
left a comment
There was a problem hiding this comment.
The previously reproduced real-child stdout decoding crash is fixed. Independent macOS validation recorded above passed 42 clipboard/directory/paste tests, Desktop typecheck, and the full Composer Electron paste/draft/restart suite. The async subprocess boundary removes the synchronous Main-process wait while retaining timeout and output bounds. No native Windows PowerShell execution is claimed. Fresh five reported CI checks are now SUCCESS. Re-fetched current main 036dfa0 and actual merge ref bda93eb: parents match current main and head c63e7c0, and tree 8d0756526041ae0f4174dcdd76b34770a409fbde matches the validated candidate. Approving for merge.
Summary
plutilthrough stdin when reading macOS clipboard files.Tests
node --test apps/desktop/test/composer-clipboard-directories.test.mjs: 12 passed, 1 skipped (macOS-only).plutilstdin path is exercised with a simulated child process on Windows. No macOS hardware validation was performed.pnpm build:js: passed.pnpm --filter @pi-desktop/desktop typecheck: passed.E2E: NOT RUN (blocked by a pre-existing defect)
pnpm test:e2e:composer-pastepasses its 4 draft-race scenarios, then stops atcancel did not close and restore attachment focus.restoreFocusreturns focus to the image chip and then unconditionally restores the previously captured text range inside the contenteditable. Chromium moves focus back to the editor, so the assertion fails.restoreFocus(b6648d1e6,abfe50a5a) and the assertion (78a073a5b) are all inupstream/main, and replacing this branch's product file with theupstream/mainversion reproduces the identical failure.test:e2e:composer-pasteis not part of CI, which is why the existing focus defect went unnoticed.