Skip to content

fix(openshell): reuse existing provider with the same name#2157

Open
feloy wants to merge 1 commit into
openkaiden:mainfrom
feloy:provider-exists
Open

fix(openshell): reuse existing provider with the same name#2157
feloy wants to merge 1 commit into
openkaiden:mainfrom
feloy:provider-exists

Conversation

@feloy

@feloy feloy commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

When creating a workspace, if an OpenShell provider with the same name already exists, reuse it instead of failing or creating a duplicate.

Type comparison against the list output is intentionally omitted: the CLI normalises the type string on storage (e.g. "claude" becomes "claude-code"), so the value in options.type and the value returned by "openshell provider list" can differ even for the same provider.

Fixes #2154

When creating a workspace, if an OpenShell provider with the same name
already exists, reuse it instead of failing or creating a duplicate.

Type comparison against the list output is intentionally omitted: the
CLI normalises the type string on storage (e.g. "claude" becomes
"claude-code"), so the value in options.type and the value returned by
"openshell provider list" can differ even for the same provider.

Fixes openkaiden#2154

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Philippe Martin <phmartin@redhat.com>
@feloy feloy requested a review from a team as a code owner June 12, 2026 12:54
@feloy feloy requested review from fbricon and jeffmaury and removed request for a team June 12, 2026 12:54
@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

OpenshellSecretAdapter.createSecret now checks for existing OpenShell providers by name before creating a new one. If a matching provider is found, the method returns early without calling createProvider. Unit tests verify provider reuse behavior, and integration tests are updated to mock the listProviders call appropriately.

Changes

OpenShell Provider Reuse

Layer / File(s) Summary
Provider existence check in createSecret
packages/main/src/plugin/secret-manager/openshell-secret-adapter.ts
createSecret calls listProviders to check for an existing provider with matching options.name, and returns early if found instead of always calling createProvider.
Unit and integration tests for provider reuse
packages/main/src/plugin/secret-manager/openshell-secret-adapter.spec.ts, packages/main/src/plugin/secret-manager/secret-manager.spec.ts
Unit tests verify that existing providers are reused when listProviders returns a matching provider and that createProvider is not called; integration tests mock listProviders to return an empty array in the affected test scenarios.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • openkaiden/kaiden#2101: Directly builds on this PR's addition of the OpenShell secret-manager backend and adapter behavior.

Suggested reviewers

  • jeffmaury
  • fbricon
  • gastoner
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately describes the main change: reusing existing OpenShell providers with the same name instead of creating duplicates.
Description check ✅ Passed The description is clearly related to the changeset, explaining the provider reuse logic and CLI normalization behavior with sufficient detail.
Linked Issues check ✅ Passed The PR implementation matches the linked issue #2154 requirements: it reuses existing providers by name and prevents workspace creation failures due to existing providers.
Out of Scope Changes check ✅ Passed All changes are focused and directly address the issue of reusing existing OpenShell providers; no out-of-scope modifications are present.
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.


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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@packages/main/src/plugin/secret-manager/openshell-secret-adapter.ts`:
- Around line 53-59: The current provider reuse logic in
openshell-secret-adapter (the block calling this.openshellCli.listProviders()
and returning { name: options.name }) reuses by name only; change it to compare
the existing provider's configuration/credentials/settings with the incoming
options (e.g., compare provider.settings or provider.config against
options.settings/options.config) and only reuse if they match exactly; if a
provider with the same name has different settings, do not return that
name—generate a new unique provider name (append a suffix or increment) and
proceed to create a new provider instead; update the create/ensure flow in the
adapter method that calls listProviders() and any tests that assumed name-only
reuse to assert the new behavior.
🪄 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: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: c606553a-6494-48fc-a003-cf4bf1b8dc16

📥 Commits

Reviewing files that changed from the base of the PR and between 3aada4d and fedde11.

📒 Files selected for processing (3)
  • packages/main/src/plugin/secret-manager/openshell-secret-adapter.spec.ts
  • packages/main/src/plugin/secret-manager/openshell-secret-adapter.ts
  • packages/main/src/plugin/secret-manager/secret-manager.spec.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: typecheck
  • GitHub Check: linter, formatters
  • GitHub Check: smoke-e2e-tests (dev) / ubuntu-24.04 (ollama)
  • GitHub Check: smoke-e2e-tests (prod) / ubuntu-24.04 (ollama)
  • GitHub Check: unit tests / windows-2022
  • GitHub Check: macOS
  • GitHub Check: unit tests / ubuntu-24.04
  • GitHub Check: unit tests / macos-15
  • GitHub Check: Windows
  • GitHub Check: Linux
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use /@/ path aliases instead of relative paths for imports outside the current directory's module group; use relative imports only for sibling modules within the same directory

Files:

  • packages/main/src/plugin/secret-manager/openshell-secret-adapter.ts
  • packages/main/src/plugin/secret-manager/secret-manager.spec.ts
  • packages/main/src/plugin/secret-manager/openshell-secret-adapter.spec.ts
packages/main/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

packages/main/src/**/*.{ts,tsx}: Use ipcHandle() to expose handlers in the main process with naming convention <registry-name>:<action> (e.g., container-provider-registry:listContainers)
Use apiSender.send() to send events from main process to renderer for real-time updates
Long-running operations should use TaskManager.createTask() with title and action configuration

Files:

  • packages/main/src/plugin/secret-manager/openshell-secret-adapter.ts
  • packages/main/src/plugin/secret-manager/secret-manager.spec.ts
  • packages/main/src/plugin/secret-manager/openshell-secret-adapter.spec.ts
packages/{main,renderer,preload}/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Container operations must include engineId parameter to identify the container engine

Files:

  • packages/main/src/plugin/secret-manager/openshell-secret-adapter.ts
  • packages/main/src/plugin/secret-manager/secret-manager.spec.ts
  • packages/main/src/plugin/secret-manager/openshell-secret-adapter.spec.ts
**/*.spec.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.spec.{ts,tsx,js,jsx}: Use test() instead of it() for test cases in Vitest unit tests
Use vi.mock(import('...')) for auto-mocking modules in unit tests; avoid manual mock factories when possible
Use vi.resetAllMocks() in beforeEach hooks instead of vi.clearAllMocks() for resetting mocks between tests
When an auto-mocked function or class method needs a real implementation, use vi.mocked(...) with the prototype pattern for class methods: vi.mocked(MyClass.prototype.myMethod).mockImplementation(...)

Files:

  • packages/main/src/plugin/secret-manager/secret-manager.spec.ts
  • packages/main/src/plugin/secret-manager/openshell-secret-adapter.spec.ts
🧠 Learnings (2)
📚 Learning: 2026-03-09T08:47:09.657Z
Learnt from: benoitf
Repo: kortex-hub/kortex PR: 1077
File: packages/main/src/plugin/skill/skill-manager.ts:80-109
Timestamp: 2026-03-09T08:47:09.657Z
Learning: In the kortex-hub/kortex repository, IPC handlers (via ipcHandle()) may be registered directly inside feature manager/service classes (e.g., SkillManager in packages/main/src/plugin/skill/skill-manager.ts) rather than exclusively in packages/main/src/plugin/index.ts. Treat this as an accepted design pattern for files under the plugin directory. Reviewers should not require centralization in index.ts; allow IPC registration proximity to the feature that owns the handler. When reviewing code, accept direct ipcHandle() registrations inside feature managers and ensure the pattern is consistently applied across similar feature-manager modules.

Applied to files:

  • packages/main/src/plugin/secret-manager/openshell-secret-adapter.ts
  • packages/main/src/plugin/secret-manager/secret-manager.spec.ts
  • packages/main/src/plugin/secret-manager/openshell-secret-adapter.spec.ts
📚 Learning: 2026-05-12T17:14:02.153Z
Learnt from: MarsKubeX
Repo: openkaiden/kaiden PR: 1850
File: packages/renderer/src/lib/agent-workspaces/AgentWorkspaceList.svelte:66-70
Timestamp: 2026-05-12T17:14:02.153Z
Learning: When reviewing code that uses `AgentWorkspaceSummaryUI.runtime`, treat it as a required, non-null `string` per the `openkaiden/kdn-api` 0.12.0 schema. Therefore, code like `a.runtime.localeCompare(b.runtime)` is safe and should not trigger warnings about possible `undefined`/`null` values or suggestions to use nullish coalescing/optional chaining for `runtime` (unless the current local types still mark `runtime` as optional, indicating a schema/version mismatch).

Applied to files:

  • packages/main/src/plugin/secret-manager/openshell-secret-adapter.ts
  • packages/main/src/plugin/secret-manager/secret-manager.spec.ts
  • packages/main/src/plugin/secret-manager/openshell-secret-adapter.spec.ts

Comment thread packages/main/src/plugin/secret-manager/openshell-secret-adapter.ts
@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@feloy

feloy commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai help

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

CodeRabbit commands

These commands are invoked using PR/Issue comments.

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai rate limit to show your current review rate limit status.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai evaluate custom pre-merge check --instructions <custom-checks-instructions> --name <custom-checks-title> [--mode <error|warning>] to validate the custom pre-merge checks instructions. Defaults to error when --mode is omitted.
  • @coderabbitai ignore pre-merge checks to override pre-merge checks and get an approval on PR.
  • @coderabbitai run pre-merge checks to run pre-merge checks on the pull request.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai emit path instructions to emit generated path-specific review instructions for this repository.
  • @coderabbitai resolve merge conflict to automatically resolve merge conflicts.
  • @coderabbitai autofix to automatically fix issues identified in unresolved review comments.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai generate configuration to create a PR that adds the current resolved configuration as .coderabbit.yaml (or show it if already present).
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit configuration file (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, support, documentation and community

  • Visit our status page to check the current availability of CodeRabbit.
  • Create a ticket on our support page for assistance with any issues or questions.
  • Visit our documentation site for detailed information on how to use CodeRabbit.
  • Join our Discord community to connect with other users and get help from the community.
  • Follow us on X/Twitter for updates and announcements.

@feloy

feloy commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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.

existing openshell provider is not re-used

1 participant