Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(pipedream_mcp): turn an app on when it is connected again (#9747)

Wolf Mermelsteinf5aef6e266ac
diff --git a/crates/pipedream_mcp/AGENTS.md b/crates/pipedream_mcp/AGENTS.md
index d4030fcc8c..2048eaaac2 100644
--- a/crates/pipedream_mcp/AGENTS.md
+++ b/crates/pipedream_mcp/AGENTS.md
@@ -69,6 +69,9 @@ listings, and calls all go through Connect, with no Pipedream fallback.
and records nothing; the app polls `/pipedream/mcp/connect/complete`, which
trusts only Connect's own connection list.
+- Completing a connection (Pipedream, its recovery, or Connect) turns the app
+ on, even over a row the user disabled: the app reads a disabled result as a
+ failed connect, and agent discovery reports a disabled app as unconnected.
- A Macro Connect grant outranks an overlay: the store returns it, and
status checks read it before the overlay's native connection.
- Overlaying an app hides its Pipedream grant from every reader, including
diff --git a/crates/pipedream_mcp/src/domain/service/connect.rs b/crates/pipedream_mcp/src/domain/service/connect.rs
index ca94804fd0..2cc3192b86 100644
--- a/crates/pipedream_mcp/src/domain/service/connect.rs
+++ b/crates/pipedream_mcp/src/domain/service/connect.rs
@@ -41,8 +41,9 @@ pub enum PipedreamConnectError {
///
/// Confirms with Pipedream that `account_id` exists and belongs to `user_id`
/// (accounts are minted for our user IDs via the Connect token), then
-/// upserts the app record. Reconnecting an app the user already has simply
-/// points its record at the new account.
+/// upserts the app record. Reconnecting an app the user already has points
+/// its record at the new account and turns it on: connecting is how a user
+/// asks to use the app, and the app reports a disabled result as a failure.
///
/// An overlaid app is refused and its new Pipedream account deleted, so no
/// Pipedream grant for it outlives the attempt.
@@ -96,7 +97,7 @@ where
.or_else(|| existing.as_ref().map(|r| r.server_name.clone()))
.unwrap_or(account.app_name),
account_id: account.id,
- enabled: existing.as_ref().is_none_or(|r| r.enabled),
+ enabled: true,
provider: ConnectionProvider::Pipedream,
};
@@ -260,8 +261,9 @@ where
/// `app_slug`.
///
/// Nothing the browser reports is trusted: Connect itself must list an
-/// active connection for this user before a record is written. A Pipedream
-/// grant the record replaces is revoked, so only one backend holds the app.
+/// active connection for this user before a record is written. The record
+/// is turned on, as for [`complete_pipedream_connection`]. A Pipedream grant
+/// the record replaces is revoked, so only one backend holds the app.
#[tracing::instrument(skip(store, backends), err)]
pub async fn complete_connect_connection<S, P>(
store: &S,
@@ -294,7 +296,7 @@ where
.or_else(|| existing.as_ref().map(|r| r.server_name.clone()))
.unwrap_or(app.name),
account_id: app.app_id,
- enabled: existing.as_ref().is_none_or(|r| r.enabled),
+ enabled: true,
provider: ConnectionProvider::Connect,
};
store.save(&record).await.map_err(anyhow::Error::from)?;
diff --git a/crates/pipedream_mcp/src/domain/service/connect/test.rs b/crates/pipedream_mcp/src/domain/service/connect/test.rs
index a887388501..33a28b7314 100644
--- a/crates/pipedream_mcp/src/domain/service/connect/test.rs
+++ b/crates/pipedream_mcp/src/domain/service/connect/test.rs
@@ -306,7 +306,7 @@ async fn completing_rejects_unknown_accounts() {
}
#[tokio::test]
-async fn reconnecting_keeps_name_and_enabled_state_but_swaps_the_account() {
+async fn reconnecting_keeps_the_name_turns_the_app_on_and_swaps_the_account() {
let store = FakeStore::default();
store
.save(&PipedreamConnection {
@@ -339,7 +339,10 @@ async fn reconnecting_keeps_name_and_enabled_state_but_swaps_the_account() {
assert_eq!(record.server_name, "My Linear", "explicit name preserved");
assert_eq!(record.account_id, "apn_new");
- assert!(!record.enabled, "user's disabled state preserved");
+ assert!(
+ record.enabled,
+ "connecting again turns a disabled app back on"
+ );
}
#[tokio::test]
@@ -678,7 +681,10 @@ async fn completing_through_connect_revokes_the_pipedream_grant_it_replaces() {
.unwrap();
assert_eq!(record.server_name, "My Linear");
- assert!(!record.enabled);
+ assert!(
+ record.enabled,
+ "connecting again turns a disabled app back on"
+ );
assert_eq!(record.provider, ConnectionProvider::Connect);
assert_eq!(*pd.deleted.lock().unwrap(), vec!["apn_1".to_owned()]);
}