Skip to content

feat(remote-control): improve ACP agent alias resolution and add work…#1694

Merged
zhangmo8 merged 1 commit into
devfrom
remote-acp
May 28, 2026
Merged

feat(remote-control): improve ACP agent alias resolution and add work…#1694
zhangmo8 merged 1 commit into
devfrom
remote-acp

Conversation

@zhangmo8
Copy link
Copy Markdown
Collaborator

@zhangmo8 zhangmo8 commented May 28, 2026

…dir error handling

close #1693

e06ce4aef65de437f6cd023559ed83ff 9d3a1126c400892a13e0b40d6f01222b

Summary by CodeRabbit

  • Bug Fixes

    • Fixed persistence of ACP default agent selections to properly resolve legacy alias IDs to canonical agent identifiers, eliminating "ghost" option display issues.
    • Improved error resilience when refreshing remote agent status to prevent one channel failure from blocking others.
  • New Features

    • Added localized validation messaging requiring users to select a default local work directory for ACP agents before saving settings.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 28, 2026

📝 Walkthrough

Walkthrough

This PR fixes "Remote ACP Default Agent Flicker" by moving ACP alias resolution into shared utilities, updating main-side sanitizeDefaultAgentId to return canonical agent IDs instead of alias-flattened ones, and reconciling legacy alias IDs in the renderer UI. It includes comprehensive i18n messaging and test coverage.

Changes

Core Fix: Alias Resolution & Agent ID Normalization

Layer / File(s) Summary
Issue Documentation & Plan
docs/issues/remote-acp-default-agent-flicker/*
Specification, plan, and task checklist document the flicker problem, acceptance criteria, implementation approach, and completed work including alias utility extraction, sanitization refactoring, renderer option reconciliation, and test coverage.
Shared Utilities & Error Contracts
src/shared/utils/acpAgentAlias.ts, src/shared/contracts/remoteControlErrors.ts
New acpAgentAlias exports ACP_LEGACY_AGENT_ID_ALIASES mapping and resolveAcpAgentAlias function for legacy-to-modern ID resolution; new remoteControlErrors contract defines REMOTE_CONTROL_ERROR_MESSAGES.acpDefaultWorkdirRequired and isAcpDefaultWorkdirRequiredError checker.
Main-side Agent ID Sanitization
src/main/presenter/remoteControlPresenter/index.ts, src/main/presenter/configPresenter/acpRegistryConstants.ts
sanitizeDefaultAgentId now derives per-channel defaults, normalizes candidate IDs via resolveAcpAgentAlias, matches enabled agents by raw or resolved ID, and falls back to channel default or first enabled agent; imports standardized error message and re-exports alias utilities from acpRegistryConstants.
IPC Handler Error Handling
src/main/presenter/index.ts
remoteControlPresenter:call handler refactored to standardize error responses via handlePresenterCallError and improve control flow for workload scheduling vs. direct execution.

Renderer: Agent Option Reconciliation & Error Feedback

Layer / File(s) Summary
Default Agent Option & Error Handling
src/renderer/settings/components/RemoteSettings.vue
Imports ACP alias utilities and error checker; remoteControlPresenter uses safeCall: false; defaultAgentOptions resolves legacy alias IDs to their enabled equivalents; refreshStatus wrapped in try/catch to log warnings instead of failing; toastSaveError detects and displays ACP workdir requirement with channel-specific destructive toast.
Internationalization for ACP Workdir Requirement
src/renderer/src/i18n/*/settings.json (24 languages)
Localized UI text added across all supported languages (en-US, de-DE, es-ES, fr-FR, it-IT, ja-JP, ko-KR, pt-BR, ru-RU, zh-CN, zh-HK, zh-TW, and 12 others) indicating ACP agents require selecting a default local work directory before saving.

Test Coverage for Alias Resolution & Reconciliation

Layer / File(s) Summary
Main-side Sanitization Tests
test/main/presenter/remoteControlPresenter/remoteControlPresenter.test.ts
Three new unit tests verify saveTelegramSettings() maps legacy claude-code-acp alias to canonical claude-acp ID, preserves IDs already matching the SQLite agent, and falls back to channel default when no alias-equivalent agent exists.
Renderer Option Reconciliation Test
test/renderer/components/RemoteSettings.test.ts
New test ensures legacy ACP defaultAgentId values render with the enabled agent's formatted alias label (e.g., Claude (ACP)) instead of showing the legacy raw ID.

🎯 3 (Moderate) | ⏱️ ~20 minutes

🐰 A flicker fixed with grace,
Aliases now in their proper place,
Agent IDs canonicalized and true,
Translations span the world anew,
Tests ensure the fix stays tight—
Remote ACP defaults now display right! ✨

🚥 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 accurately describes the primary changes: improving ACP agent alias resolution and adding workdir error handling.
Linked Issues check ✅ Passed The PR successfully implements support for ACP agents in the remote subsystem by refactoring alias resolution, enhancing agent sanitization, and adding workdir validation.
Out of Scope Changes check ✅ Passed All changes are focused on ACP remote support: alias utilities reorganization, default agent handling, workdir error messaging, and related localization updates.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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 remote-acp

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
docs/issues/remote-acp-default-agent-flicker/plan.md (1)

6-6: 💤 Low value

Optional: Consider simplifying wording.

The phrase "exact same" could be simplified to just "same" for conciseness.

✍️ Suggested simplification
-- Promote `resolveAcpAgentAlias` and `ACP_LEGACY_AGENT_ID_ALIASES` to `src/shared/utils/acpAgentAlias.ts` so renderer code can reuse the exact same alias table that main relies on. `src/main/presenter/configPresenter/acpRegistryConstants.ts` re-exports them to keep all current `import` sites working.
+- Promote `resolveAcpAgentAlias` and `ACP_LEGACY_AGENT_ID_ALIASES` to `src/shared/utils/acpAgentAlias.ts` so renderer code can reuse the same alias table that main relies on. `src/main/presenter/configPresenter/acpRegistryConstants.ts` re-exports them to keep all current `import` sites working.
🤖 Prompt for 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.

In `@docs/issues/remote-acp-default-agent-flicker/plan.md` at line 6, Update the
wording in the plan sentence that mentions the alias export: replace "exact same
alias table" with "same alias table" to be more concise; ensure the sentence
still references the exported symbols (resolveAcpAgentAlias and
ACP_LEGACY_AGENT_ID_ALIASES) and that the surrounding sentence about
re-exporting from src/main/presenter/configPresenter/acpRegistryConstants.ts
remains unchanged.
🤖 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/renderer/src/i18n/fa-IR/settings.json`:
- Around line 2026-2027: Update the two i18n keys acpDefaultWorkdirRequiredTitle
and acpDefaultWorkdirRequiredDescription to use the same Persian term as the
surrounding labels (change "شاخه" to "پوشه") so terminology for workdir is
consistent across the ACP section; edit the values for
acpDefaultWorkdirRequiredTitle and acpDefaultWorkdirRequiredDescription
accordingly.

---

Nitpick comments:
In `@docs/issues/remote-acp-default-agent-flicker/plan.md`:
- Line 6: Update the wording in the plan sentence that mentions the alias
export: replace "exact same alias table" with "same alias table" to be more
concise; ensure the sentence still references the exported symbols
(resolveAcpAgentAlias and ACP_LEGACY_AGENT_ID_ALIASES) and that the surrounding
sentence about re-exporting from
src/main/presenter/configPresenter/acpRegistryConstants.ts remains unchanged.
🪄 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: 44774f50-e1ac-4c41-b558-adfe62553716

📥 Commits

Reviewing files that changed from the base of the PR and between 3ec3eaa and d208932.

📒 Files selected for processing (31)
  • docs/issues/remote-acp-default-agent-flicker/plan.md
  • docs/issues/remote-acp-default-agent-flicker/spec.md
  • docs/issues/remote-acp-default-agent-flicker/tasks.md
  • src/main/presenter/configPresenter/acpRegistryConstants.ts
  • src/main/presenter/index.ts
  • src/main/presenter/remoteControlPresenter/index.ts
  • src/renderer/settings/components/RemoteSettings.vue
  • src/renderer/src/i18n/da-DK/settings.json
  • src/renderer/src/i18n/de-DE/settings.json
  • src/renderer/src/i18n/en-US/settings.json
  • src/renderer/src/i18n/es-ES/settings.json
  • src/renderer/src/i18n/fa-IR/settings.json
  • src/renderer/src/i18n/fr-FR/settings.json
  • src/renderer/src/i18n/he-IL/settings.json
  • src/renderer/src/i18n/id-ID/settings.json
  • src/renderer/src/i18n/it-IT/settings.json
  • src/renderer/src/i18n/ja-JP/settings.json
  • src/renderer/src/i18n/ko-KR/settings.json
  • src/renderer/src/i18n/ms-MY/settings.json
  • src/renderer/src/i18n/pl-PL/settings.json
  • src/renderer/src/i18n/pt-BR/settings.json
  • src/renderer/src/i18n/ru-RU/settings.json
  • src/renderer/src/i18n/tr-TR/settings.json
  • src/renderer/src/i18n/vi-VN/settings.json
  • src/renderer/src/i18n/zh-CN/settings.json
  • src/renderer/src/i18n/zh-HK/settings.json
  • src/renderer/src/i18n/zh-TW/settings.json
  • src/shared/contracts/remoteControlErrors.ts
  • src/shared/utils/acpAgentAlias.ts
  • test/main/presenter/remoteControlPresenter/remoteControlPresenter.test.ts
  • test/renderer/components/RemoteSettings.test.ts

Comment thread src/renderer/src/i18n/fa-IR/settings.json
@zhangmo8 zhangmo8 merged commit 7c62924 into dev May 28, 2026
3 checks passed
@zhangmo8 zhangmo8 deleted the remote-acp branch May 29, 2026 05:44
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.

[Feature] remote supports acp agent

1 participant