Files
PaperClipAI/packages/shared/src
DottaandClaude Opus 5.5 8de6686739 fix(apps): save action choices when the provider no longer offers some actions (#22877)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Connections give agents actions in other apps, and the Permissions
page controls which actions agents can use
> - A managed Google Workspace connection moved from Paperclip's REST
tools to Google's MCP servers (#22815)
> - Google's MCP servers do not list two Gmail actions, so the catalog
refresh marked them as removed (`disabled`, `mcp_tool_removed`)
> - The Permissions page still sent these two actions as enabled, and
the server refused every save that contained them, except on remote MCP
aggregators
> - An admin could not release the 34 held actions, so the connection
stayed unusable
> - This pull request makes the server accept a removed action for every
connection kind, and makes the UI stop sending disabled or removed
actions
> - The benefit is that an admin can always save the review after a
provider removes actions, and a disabled action still cannot be turned
on

## Linked Issues or Issue Description

Refs #22815

**What happened?**

On a managed Google Workspace connection that runs on Google's MCP
servers, the Permissions page showed "Review 34 new actions". After
"Turn all on" and "Save choices", the save failed with the message
"Couldn't save that — Disabled actions cannot be enabled". The held
actions stayed held.

**What did you expect to happen?**

The save releases the reviewed actions. Actions that Google no longer
offers stay off and do not block the save.

**Steps to reproduce**

1. Connect Google Workspace with the managed method while the transport
is Paperclip REST. Keep all actions on.
2. Move the connection to Google's MCP servers (#22815). The refresh
holds the actions for review, and Google's listing does not include
`gmail__list_threads` and `gmail__search_messages`.
3. Open the connection's Permissions page. Select "Review 34 new
actions", then "Turn all on", then "Save choices".
4. See the error "Disabled actions cannot be enabled".

**Cause**

- `useConnectionPermissionSave.ts` sent `enabledCatalogEntryIds:
[...next.enabled]`. This set came from the saved profile and still
contained the two removed actions.
- `finishGalleryAppConnection` in `server/src/services/tool-access.ts`
refused an enabled row with `status === "disabled"`. It accepted a
removed row (`quarantineReason === "mcp_tool_removed"`) only for remote
MCP aggregators (`isRemoteMcpConnectorMethod`). The catalog refresh
writes `mcp_tool_removed` also for Google Workspace and plugin
connections, so these connections did not get the same exception.

## What Changed

- Server: `finishGalleryAppConnection` accepts a row that the provider's
listing removed (`mcp_tool_removed`) for every connection kind. Only the
catalog refresh writes this marker, and only when the provider's listing
no longer has the action. This is the same behavior that remote MCP
aggregators already had. Any other disabled row is still refused with
"Disabled actions cannot be enabled". A removed row is not active, so
the gateway does not offer it to agents.
- Shared: `@paperclipai/shared` has three named predicates in
`tool-catalog-availability.ts`. `isCatalogEntryOffered` is true for
active and held actions. `isCatalogEntryRemovedByProvider` is true for
`removed` rows and for `disabled` rows with `mcp_tool_removed`.
`isCatalogEntryBlocked` is true for every other disabled row. The server
and the UI use these predicates, so the rule is in one place.
- Server: the review coverage check ignores a reviewed id that the
provider removed after the page loaded. Before this change, that save
failed with "Action review decisions must cover every currently
quarantined action exactly once".
- Server: a save no longer sets a `removed` row back to active.
- UI: a new `withoutUnavailableActions` helper drops catalog entries
that are not offered (`isCatalogEntryOffered` is false) from an enabled
list.
- UI: the Permissions page save (`finishAppPermissions` in
`useConnectionPermissionSave.ts`) sends only available actions as
enabled or Ask first. The page already showed and counted only active
and held actions, so the removed actions do not show, count, or toggle.
The page has no existing pattern for removed actions, so this change
adds no new text.
- UI: the setup flow (`ConnectionSetupFlow.tsx`, which also serves
task-hosted setup) and the pasted-config flow (`PasteConfigTab.tsx`)
also drop disabled actions before they finish a connection. Before this
change, a provider-blocked action (for example a Gmail write action on a
read-only method) could make the first save fail the same way.
`RemoteMcpProductionSetup.tsx` already sends only active actions.
`QuarantinedActionsReview` in `SetupPanel.tsx` selects only from held
actions.

## Verification

- Red, then green:
`server/src/__tests__/google-workspace-mcp-transport.test.ts` → "saves
the review when Google no longer offers actions that were on, and still
refuses a disabled action". The test saves a managed Google Workspace
connection on REST, moves it to Google's MCP servers while Google does
not list `list_threads` and `search_messages`, then saves the review
with the removed actions in the enabled list. Before the fix it failed
with "Disabled actions cannot be enabled". After the fix it passes. The
same test makes sure that a disabled action without the removal marker
is still refused, and that agents are not offered the removed actions.
- Red, then green:
`ui/src/pages/apps/app-detail/action-permissions.test.ts` →
"finishAppPermissions never asks to turn on an action Google no longer
offers or a disabled action". Without the filter, the test fails.
- `packages/shared/src/tool-catalog-availability.test.ts` covers the
three predicates.
- The transport test also sends the removed ids in
`reviewedCatalogEntryIds`. Without the coverage fix it fails with
"Action review decisions must cover every currently quarantined action
exactly once". It also makes sure that the removed rows stay disabled
after the save.
- Local runs: `google-workspace-mcp-transport.test.ts` and
`tool-access-service.test.ts` (542 passed). UI tests in `app-detail`,
`features/connections` and `pages/tools` (143 passed).
- `pnpm verify` selected the full server suite (1520 files) because
`tool-access.ts` is a shared service. On this machine, under load from
other sessions, 31 of 33876 tests failed. The run output did not keep
the names of the failed tests. The touched test files pass when run
alone, and the CI server shards run the full suite on the final head.
- `tsc --noEmit` for `server` and for `ui/src`.

## Risks

- Low risk. The security rule stays: a disabled action that the provider
did not remove cannot be turned on.
- Behavior change: Google Workspace and plugin connections now accept a
removed action in the enabled list, as remote MCP aggregators already
did. The UI no longer sends removed actions, so after a save from the
page a removed action stays off if the provider lists it again.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, used through Claude
Code with tool use (shell, file edits, test runs).

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [ ] I will address all Greptile and reviewer comments before
requesting merge

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 04:32:26 -06:00
..
…