Skip to content

fix(acp): preserve debug session cwd#1552

Merged
zerob13 merged 1 commit intodevfrom
acp-healthcheck
Apr 28, 2026
Merged

fix(acp): preserve debug session cwd#1552
zerob13 merged 1 commit intodevfrom
acp-healthcheck

Conversation

@zhangmo8
Copy link
Copy Markdown
Collaborator

@zhangmo8 zhangmo8 commented Apr 28, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Fixed debug session request handling to properly validate and apply working directory and server configuration parameters.
    • Corrected debug dialog behavior to only include working directory settings when explicitly provided.
  • Tests

    • Added test coverage for debug session initialization with explicit configuration parameters.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 28, 2026

📝 Walkthrough

Walkthrough

The changes refactor how ACP debug sessions handle payload overrides for cwd, mcpServers, and _meta fields. Instead of shallow-merging all payload fields, the code now selectively applies only valid non-empty overrides (non-empty trimmed cwd strings, arrays for mcpServers, plain objects for _meta) while preserving session defaults. A test was added to verify this behavior.

Changes

Cohort / File(s) Summary
ACP Provider Logic
src/main/presenter/llmProviderPresenter/providers/acpProvider.ts
Modified newSession debug action to build session request from defaults, then apply selective overrides from payload with input validation (non-empty cwd, array-type mcpServers, plain object _meta).
Debug UI Dialog
src/renderer/settings/components/AcpDebugDialog.vue
Updated payload construction for newSession and loadSession actions to conditionally include cwd only when workdirPath.value is truthy, avoiding undefined values.
Test Coverage
test/main/presenter/acpProvider.test.ts
Added unit test verifying that runDebugAction respects resolved workdir even when payload contains cwd: undefined.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 Defaults stand firm, overrides must earn their keep,
Empty promises are swept away so deep,
Only valid values get a say,
Sessions stay true, come what may!
Validation guards the workdir way. 🌲

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(acp): preserve debug session cwd' accurately describes the main change: the pull request modifies how the ACP provider handles the current working directory (cwd) in debug sessions by implementing selective overrides that preserve defaults when payload values are invalid.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch acp-healthcheck

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/main/presenter/llmProviderPresenter/providers/acpProvider.ts (1)

665-676: Consider sharing cwd validation logic with loadSession for consistency.

newSession now blocks empty/whitespace cwd, but loadSession still accepts any string override. A shared helper would prevent behavior drift.

♻️ Suggested refactor
+const resolvePayloadCwd = (value: unknown): string | undefined =>
+  typeof value === 'string' && value.trim() ? value : undefined
+
 // in newSession
-            if (typeof request.payload.cwd === 'string' && request.payload.cwd.trim()) {
-              body.cwd = request.payload.cwd
-            }
+            const payloadCwd = resolvePayloadCwd(request.payload.cwd)
+            if (payloadCwd) {
+              body.cwd = payloadCwd
+            }

 // in loadSession
-            if (typeof payloadOverrides.cwd === 'string') {
-              body.cwd = payloadOverrides.cwd
-            }
+            const payloadCwd = resolvePayloadCwd(payloadOverrides.cwd)
+            if (payloadCwd) {
+              body.cwd = payloadCwd
+            }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/presenter/llmProviderPresenter/providers/acpProvider.ts` around
lines 665 - 676, The cwd validation in newSession is stricter than loadSession;
extract the logic into a shared helper (e.g., validateOrNormalizeCwd) and call
it from both newSession and loadSession so both reject or normalize
empty/whitespace-only cwd the same way; update the places that set body.cwd (the
body construction in newSession and the analogous assignment in loadSession) to
use this helper and preserve existing type checks (isPlainObject/request.payload
checks) and behavior for mcpServers and _meta.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/main/presenter/llmProviderPresenter/providers/acpProvider.ts`:
- Around line 665-676: The cwd validation in newSession is stricter than
loadSession; extract the logic into a shared helper (e.g.,
validateOrNormalizeCwd) and call it from both newSession and loadSession so both
reject or normalize empty/whitespace-only cwd the same way; update the places
that set body.cwd (the body construction in newSession and the analogous
assignment in loadSession) to use this helper and preserve existing type checks
(isPlainObject/request.payload checks) and behavior for mcpServers and _meta.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c86ac910-ebac-41b2-8684-0b3bb0abce0a

📥 Commits

Reviewing files that changed from the base of the PR and between d770406 and 255d305.

📒 Files selected for processing (3)
  • src/main/presenter/llmProviderPresenter/providers/acpProvider.ts
  • src/renderer/settings/components/AcpDebugDialog.vue
  • test/main/presenter/acpProvider.test.ts

@zerob13 zerob13 merged commit 2e98773 into dev Apr 28, 2026
3 checks passed
@zhangmo8 zhangmo8 deleted the acp-healthcheck branch April 28, 2026 05:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants