Skip to content

fix(virtual-mcp): prune homeTile/homeTiles when their connection is removed - #6704

Merged
pedrofrxncx merged 1 commit into
mainfrom
fix/prune-orphaned-home-tiles
Aug 28, 2026
Merged

fix(virtual-mcp): prune homeTile/homeTiles when their connection is removed#6704
pedrofrxncx merged 1 commit into
mainfrom
fix/prune-orphaned-home-tiles

Conversation

@pedrofrxncx

@pedrofrxncx pedrofrxncx commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Source

Follow-up to #6674 (merged, fixes #6673's orphaned pinned-view tab). That PR's own body flagged this exact gap under "Not in scope":

metadata.ui.homeTiles / homeTile have the same orphan class and are not pruned by cleanOrphanedPinnedViews in apps/api/src/storage/virtual.ts either. No reported breakage, left for a follow-up.

Why a maintainer wants this

cleanOrphanedPinnedViews (called both when an agent's connection list is updated and when a connection is deleted) only stripped metadata.ui.pinnedViews referencing the removed connection. homeTile/homeTiles carry the identical connectionId field and are just as reachable from removeConnectionReferences — a deleted or detached connection can leave a stranded home-board tile the same way it left the stranded pinned-view tab in #6673, with no UI path to remove it (the home-tile editor also only lists live/attached connections).

What changed

Extracted the pinned-view filtering into a pure pruneOrphanedUiRefs(ui, removedConnectionId) (apps/api/src/storage/prune-orphaned-ui-refs.ts) that now prunes pinnedViews, the legacy single homeTile, and the homeTiles array together. cleanOrphanedPinnedViews calls it instead of hand-rolling the pinnedViews-only filter. Net: -17/+10 in virtual.ts, +2 new files (helper + test).

Behavior-preserving for the existing pinnedViews path — same filter predicate, same null-vs-empty-array handling, same field wiring in the callers (updateVirtualMCP, removeConnectionReferences).

Regression test

apps/api/src/storage/prune-orphaned-ui-refs.test.ts — 6 cases: drops a pinned view for the removed connection, nulls pinnedViews once empty, nulls a matching legacy homeTile, drops a matching homeTiles entry, no-op when nothing references the connection, and a homeTile with no connectionId is left untouched (was previously untestable — cleanOrphanedPinnedViews was a private DB-coupled method with zero existing coverage).

To verify

bun test apps/api/src/storage/prune-orphaned-ui-refs.test.ts

Checks run locally

  • bun run fmt
  • cd apps/api && bunx tsc --noEmit — clean
  • bun test apps/api/src/storage/prune-orphaned-ui-refs.test.ts — 6/6 pass
  • bunx oxlint on all three touched files — 0 warnings/errors

Full CI (integration/e2e) validates the DB-coupled cleanOrphanedPinnedViews wiring, which needs Postgres and isn't exercised here.


Summary by cubic

Prunes homeTile/homeTiles from agent UI metadata when their connection is removed. Previously only pinnedViews were cleaned up, leaving home-board tiles stranded with no UI path to remove them.

  • Extracts the pruning into a pure pruneOrphanedUiRefs helper with unit tests for pinnedViews, homeTile, and homeTiles.
  • Existing pinnedViews behavior is unchanged; empty arrays still collapse to null.

Written for commit b38f883. Summary will update on new commits.

Review in cubic

…emoved

cleanOrphanedPinnedViews only pruned metadata.ui.pinnedViews when a connection
left an agent's aggregation. homeTile/homeTiles carry the identical
connectionId shape and were explicitly called out as a known gap in #6674
('Not in scope ... left for a follow-up'): a home-board tile pointing at a
removed connection is stranded the same way #6673's pinned-view tab was.

Extracted the filtering into a pure pruneOrphanedUiRefs() so pinnedViews,
homeTile, and homeTiles are pruned together, unit-tested without a database.
@pedrofrxncx
pedrofrxncx merged commit d6454a4 into main Aug 28, 2026
34 checks passed
@pedrofrxncx
pedrofrxncx deleted the fix/prune-orphaned-home-tiles branch August 28, 2026 17:06
decocms Bot pushed a commit that referenced this pull request Aug 28, 2026
PR: #6704 fix(virtual-mcp): prune homeTile/homeTiles when their connection is removed
Bump type: patch

- decocms (apps/api/package.json): 4.295.0 -> 4.295.1
- @decocms/native (apps/native/package.json): 4.295.0 -> 4.295.1

Deploy-Scope: server
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.

[Bug]: orphaned pinned view renders a permanent agent tab that cannot be removed

1 participant