fix(virtual-mcp): prune homeTile/homeTiles when their connection is removed - #6704
Merged
Conversation
…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.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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":
Why a maintainer wants this
cleanOrphanedPinnedViews(called both when an agent's connection list is updated and when a connection is deleted) only strippedmetadata.ui.pinnedViewsreferencing the removed connection.homeTile/homeTilescarry the identicalconnectionIdfield and are just as reachable fromremoveConnectionReferences— 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 prunespinnedViews, the legacy singlehomeTile, and thehomeTilesarray together.cleanOrphanedPinnedViewscalls it instead of hand-rolling the pinnedViews-only filter. Net: -17/+10 invirtual.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, nullspinnedViewsonce empty, nulls a matching legacyhomeTile, drops a matchinghomeTilesentry, no-op when nothing references the connection, and ahomeTilewith noconnectionIdis left untouched (was previously untestable —cleanOrphanedPinnedViewswas a private DB-coupled method with zero existing coverage).To verify
bun test apps/api/src/storage/prune-orphaned-ui-refs.test.tsChecks run locally
bun run fmtcd apps/api && bunx tsc --noEmit— cleanbun test apps/api/src/storage/prune-orphaned-ui-refs.test.ts— 6/6 passbunx oxlinton all three touched files — 0 warnings/errorsFull CI (integration/e2e) validates the DB-coupled
cleanOrphanedPinnedViewswiring, which needs Postgres and isn't exercised here.Summary by cubic
Prunes
homeTile/homeTilesfrom agent UI metadata when their connection is removed. Previously onlypinnedViewswere cleaned up, leaving home-board tiles stranded with no UI path to remove them.pruneOrphanedUiRefshelper with unit tests forpinnedViews,homeTile, andhomeTiles.pinnedViewsbehavior is unchanged; empty arrays still collapse tonull.Written for commit b38f883. Summary will update on new commits.