fix(acp): guard invalid workdirs#1620
Conversation
Add universal new-thread directory validation, ACP-only send/draft blocking, explicit ACP cwd validation, npx cache repair retry, and ACP initialization diagnostics. Tests: pnpm run format; pnpm run i18n; pnpm run lint; pnpm run typecheck:node; pnpm run typecheck:web; focused NewThreadPage and AcpProcessManager vitest suites.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
✅ Files skipped from review due to trivial changes (3)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughThis PR adds traced ACP JSON‑RPC protocol logging and initialization diagnostics (including npx-cache single-retry repair and spawn cwd validation), emits summarized session/prompt debug events, implements renderer-side workdir validation with UI warnings and send gating, adds i18n keys, and includes tests for these behaviors. ChangesACP Initialization Logging & Workdir Validation
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/main/presenter/llmProviderPresenter/acp/acpProcessManager.ts`:
- Around line 759-772: The code may return and cache a dead child handle because
the child process can exit after initialization but before readyHandle is
assigned; update the logic in the routine that creates/returns the handle
(reference symbols: handleProcessExit, readyHandle, child,
removeHandleReferences, clearSessionsForAgent) to perform a final liveness check
on child.pid (or child.killed/exit code) immediately before assigning/returning
readyHandle and caching it, and if the child is not alive, run the cleanup path
(call removeHandleReferences and clearSessionsForAgent) and retry or throw so a
dead handle is never stored; apply the same final liveness check to the
analogous block around the code referenced at the second location (the block
around lines 985-993).
In `@src/renderer/src/i18n/fa-IR/chat.json`:
- Line 27: The key "workspaceUnavailableTooltip" in
src/renderer/src/i18n/fa-IR/chat.json contains an English message; replace its
value with a Persian translation while preserving the {path} placeholder exactly
(e.g., "فهرست وجود ندارد یا قابل دسترسی نیست: {path}" or similar) so the tooltip
is fully localized for fa-IR users.
In `@src/renderer/src/i18n/he-IL/chat.json`:
- Line 27: Replace the English message for the key workspaceUnavailableTooltip
with a Hebrew translation while keeping the {path} placeholder exactly as-is;
for example use: "התיקייה אינה קיימת או לא ניתנת לגישה: {path}" and update the
value in src/renderer/src/i18n/he-IL/chat.json for the
workspaceUnavailableTooltip entry.
In `@src/renderer/src/i18n/ru-RU/chat.json`:
- Line 27: The key workspaceUnavailableTooltip in the ru-RU locale is still
English; replace its value with a proper Russian translation preserving the
{path} placeholder (e.g., "Каталог не существует или недоступен: {path}"),
updating the string for functionally identical formatting and keeping the
placeholder intact so code referencing workspaceUnavailableTooltip continues to
work.
In `@test/main/presenter/llmProviderPresenter/acp/acpProcessManager.test.ts`:
- Line 461: Replace the direct reassignment of fs.renameSync (currently done via
type-cast assignment) with a vi.spyOn(fs, 'renameSync').mockImplementation(...)
in each test that mocks it (e.g., the tests around the current failing
assertions), and ensure the spy is restored after the test by calling
spy.mockRestore() in a finally block (or use afterEach to restore all spies);
also stop using mockReset() alone since it does not restore the original
function—use mockRestore() to return fs.renameSync to its original
implementation.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 29568071-5124-445a-956b-eb0aee5f08b5
📒 Files selected for processing (24)
docs/issues/acp-initialization-logging/plan.mddocs/issues/acp-initialization-logging/spec.mddocs/issues/acp-initialization-logging/tasks.mddocs/issues/acp-workdir-npx-recovery/plan.mddocs/issues/acp-workdir-npx-recovery/spec.mddocs/issues/acp-workdir-npx-recovery/tasks.mdsrc/main/presenter/llmProviderPresenter/acp/acpProcessManager.tssrc/main/presenter/llmProviderPresenter/acp/acpSessionManager.tssrc/main/presenter/llmProviderPresenter/providers/acpProvider.tssrc/renderer/src/i18n/da-DK/chat.jsonsrc/renderer/src/i18n/en-US/chat.jsonsrc/renderer/src/i18n/fa-IR/chat.jsonsrc/renderer/src/i18n/fr-FR/chat.jsonsrc/renderer/src/i18n/he-IL/chat.jsonsrc/renderer/src/i18n/ja-JP/chat.jsonsrc/renderer/src/i18n/ko-KR/chat.jsonsrc/renderer/src/i18n/pt-BR/chat.jsonsrc/renderer/src/i18n/ru-RU/chat.jsonsrc/renderer/src/i18n/zh-CN/chat.jsonsrc/renderer/src/i18n/zh-HK/chat.jsonsrc/renderer/src/i18n/zh-TW/chat.jsonsrc/renderer/src/pages/NewThreadPage.vuetest/main/presenter/llmProviderPresenter/acp/acpProcessManager.test.tstest/renderer/components/NewThreadPage.test.ts
Summary
Tests
Summary by CodeRabbit
New Features
Localization
Documentation
Tests