[GH-ISSUE #1807] Restore connection secret handling and storage invariants #885

Closed
opened 2026-10-21 05:22:57 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @Xelvanis on GitHub (Jun 1, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1807

Originally assigned to: @cha1latte on GitHub.

Summary

The refactor connections surface preserves much of the legacy editor behavior, but the storage layer dropped several legacy invariants around secrets, default flags, and folders.

Regressions

1. API keys are persisted as plaintext while the UI says they are encrypted

Refactor evidence:

  • src/features/shell/connections/components/ConnectionEditor.tsx still tells users their key is encrypted at rest.
  • src/features/catalog/connections/hooks/use-connections.ts sends create/update data through generic storage.
  • src-tauri/crates/storage/src/lib.rs persists the record as provided.
  • src-tauri/src/commands/storage/llm.rs reads the raw apiKey field back from the connection record.

Legacy behavior:

  • packages/server/src/services/storage/connections.storage.ts encrypted apiKey on create/update and returned masked keys through read paths.

Impact:

  • Provider credentials can be written directly into app storage and exposed through generic connection read/export paths.

Expected:

  • Stored connection secrets are encrypted or otherwise protected.
  • List/get/export paths do not expose raw secrets.
  • Blank-key updates preserve the existing secret.
  • Local-auth providers can still clear irrelevant secret fields intentionally.

2. Duplicating a connection preserves default flags

Refactor evidence:

  • src/features/catalog/connections/hooks/use-connections.ts calls generic duplicate for connections.
  • src-tauri/src/commands/storage/shared.rs copies the record, removes only the id, and appends Copy to the name.
  • Default runtime and agent selection later choose the first matching isDefault / defaultForAgents connection.

Legacy behavior:

  • packages/server/src/services/storage/connections.storage.ts reset isDefault and defaultForAgents to false when duplicating.

Impact:

  • Duplicating a default connection can create multiple defaults and silently route runtime, agent, or image generation through whichever record is found first.

Expected:

  • Duplicating a connection resets isDefault and defaultForAgents.
  • Existing default exclusivity behavior remains intact.

3. Connection folder operations use generic storage and miss legacy invariants

Refactor evidence:

  • src/features/catalog/connections/hooks/use-connection-folders.ts creates, deletes, and reorders folders through generic storage calls.
  • src/features/shell/connections/components/ConnectionsPanel.tsx assumes folder records have sortOrder and tells users deleted-folder contents move to Unfiled.
  • Generic folder delete does not clear child connection folderId values.

Legacy behavior:

  • packages/server/src/services/storage/connection-folders.storage.ts created folders with default sortOrder / collapsed, shifted existing sort order, unfiled children on delete, and reordered transactionally.

Impact:

  • New folder records can miss expected fields.
  • Deleted folders can leave stale folderId values in connection records.
  • Reorder can partially apply if one update fails.

Expected:

  • Folder create initializes required fields consistently.
  • Folder delete clears or migrates child connection folderId values.
  • Folder reorder is applied as one validated operation.

Product divergence to confirm

The legacy Connections panel included a Local Model sidecar card. The refactor no longer has that card, and src-tauri/src/commands/storage/prompts.rs explicitly reports legacy sidecar embeddings as retired. This looks intentional, but it removes the legacy setup path for local-model connection/status handling.

Refactor behavior to preserve

  • Connection delete now checks references before removal through src-tauri/src/connection_refs.rs.
  • Local-auth providers clear irrelevant API/base URL fields more cleanly in ConnectionEditor.tsx.
  • Connection tests/model lookup now surface provider warnings and fallback details.

Acceptance criteria

  • Connection API keys are not stored or returned as plaintext.
  • Existing plaintext connection secrets are migrated or handled safely.
  • Duplicate connection resets default flags.
  • Connection folder create/delete/reorder match legacy storage invariants.
  • Local Model sidecar removal is either confirmed intentional or tracked as separate product work.
Originally created by @Xelvanis on GitHub (Jun 1, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1807 Originally assigned to: @cha1latte on GitHub. ## Summary The refactor connections surface preserves much of the legacy editor behavior, but the storage layer dropped several legacy invariants around secrets, default flags, and folders. ## Regressions ### 1. API keys are persisted as plaintext while the UI says they are encrypted Refactor evidence: - `src/features/shell/connections/components/ConnectionEditor.tsx` still tells users their key is encrypted at rest. - `src/features/catalog/connections/hooks/use-connections.ts` sends create/update data through generic storage. - `src-tauri/crates/storage/src/lib.rs` persists the record as provided. - `src-tauri/src/commands/storage/llm.rs` reads the raw `apiKey` field back from the connection record. Legacy behavior: - `packages/server/src/services/storage/connections.storage.ts` encrypted `apiKey` on create/update and returned masked keys through read paths. Impact: - Provider credentials can be written directly into app storage and exposed through generic connection read/export paths. Expected: - Stored connection secrets are encrypted or otherwise protected. - List/get/export paths do not expose raw secrets. - Blank-key updates preserve the existing secret. - Local-auth providers can still clear irrelevant secret fields intentionally. ### 2. Duplicating a connection preserves default flags Refactor evidence: - `src/features/catalog/connections/hooks/use-connections.ts` calls generic duplicate for `connections`. - `src-tauri/src/commands/storage/shared.rs` copies the record, removes only the id, and appends `Copy` to the name. - Default runtime and agent selection later choose the first matching `isDefault` / `defaultForAgents` connection. Legacy behavior: - `packages/server/src/services/storage/connections.storage.ts` reset `isDefault` and `defaultForAgents` to false when duplicating. Impact: - Duplicating a default connection can create multiple defaults and silently route runtime, agent, or image generation through whichever record is found first. Expected: - Duplicating a connection resets `isDefault` and `defaultForAgents`. - Existing default exclusivity behavior remains intact. ### 3. Connection folder operations use generic storage and miss legacy invariants Refactor evidence: - `src/features/catalog/connections/hooks/use-connection-folders.ts` creates, deletes, and reorders folders through generic storage calls. - `src/features/shell/connections/components/ConnectionsPanel.tsx` assumes folder records have `sortOrder` and tells users deleted-folder contents move to Unfiled. - Generic folder delete does not clear child connection `folderId` values. Legacy behavior: - `packages/server/src/services/storage/connection-folders.storage.ts` created folders with default `sortOrder` / `collapsed`, shifted existing sort order, unfiled children on delete, and reordered transactionally. Impact: - New folder records can miss expected fields. - Deleted folders can leave stale `folderId` values in connection records. - Reorder can partially apply if one update fails. Expected: - Folder create initializes required fields consistently. - Folder delete clears or migrates child connection `folderId` values. - Folder reorder is applied as one validated operation. ## Product divergence to confirm The legacy Connections panel included a Local Model sidecar card. The refactor no longer has that card, and `src-tauri/src/commands/storage/prompts.rs` explicitly reports legacy sidecar embeddings as retired. This looks intentional, but it removes the legacy setup path for local-model connection/status handling. ## Refactor behavior to preserve - Connection delete now checks references before removal through `src-tauri/src/connection_refs.rs`. - Local-auth providers clear irrelevant API/base URL fields more cleanly in `ConnectionEditor.tsx`. - Connection tests/model lookup now surface provider warnings and fallback details. ## Acceptance criteria - Connection API keys are not stored or returned as plaintext. - Existing plaintext connection secrets are migrated or handled safely. - Duplicate connection resets default flags. - Connection folder create/delete/reorder match legacy storage invariants. - Local Model sidecar removal is either confirmed intentional or tracked as separate product work.
Author
Owner

@cha1latte commented on GitHub (Jun 1, 2026):

Fixed in #1843

<!-- gh-comment-id:4595918414 --> @cha1latte commented on GitHub (Jun 1, 2026): Fixed in #1843
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#885
No description provided.