Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions app/src/lib/plugins/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,17 @@ export const pluginKeys = {
export type PluginConnection = {
serverId: string;
/**
* Whether the credential behind this row has been withdrawn or deleted, present only on a HELD
* row — a brokered one keeps no secret here, so it has no equivalent question.
* Whether the credential behind this row has been withdrawn or deleted. On a brokered row, whether
* the app's account behind it is expired or gone at the vendor, as a Bot's call or the vendor's own
* listing found: the row stands, and the app reads Reconnect rather than Connected.
*
* A ROW IS NOT ACCESS. Revoking a credential leaves this row pointing at it, and reconnecting
* moves `credential_id` and `updated_at` without touching `connected_at`, so the presence of a
* row says nothing about whether the app can be used and nothing visible changes when it can be
* again. Anything drawing the word "connected" has to read this; anything listing the apps
* somebody has ever connected does not.
*
* Undefined on a brokered row and on any shape written before this existed, and the absence
* reads as not revoked.
* Undefined on any shape written before this existed, and the absence reads as not revoked.
*/
revoked?: boolean;
/** What the vendor actually granted, which is not always what was asked for. Empty for brokered. */
Expand Down Expand Up @@ -259,16 +259,21 @@ export type PluginConnections = {

/**
* One of the person's own connections as listConnections answers it, in the shape the screens
* read: a held row carries `revoked`, a row the app keeps carries what its last check found.
* read: every row carries `revoked`, and a row the app keeps carries what its last check found.
*
* `revoked` ON A BROKERED ROW TOO. It is how the server says the app's account is expired or gone
* at the vendor. Dropped here for a brokered row, Apps read Connected over an account the vendor
* called EXPIRED (reported in dogfooding), with the Reconnect card in the conversation beside it.
*/
function personalRow(connection: Connection): PluginConnection {
export function personalRow(connection: Connection): PluginConnection {
return {
serverId: connection.appId,
scope: connection.scope ?? "",
connectedAt: connection.connectedAt,
holder: "person",
revoked: connection.revoked,
...(connection.check === null
? { revoked: connection.revoked }
? {}
: {
verified: connection.check.verified,
verifiedAt: connection.check.verifiedAt,
Expand Down
64 changes: 62 additions & 2 deletions app/tests/connection-rows.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { expect, test } from "bun:test";
import { connectionRows } from "@/lib/connections/rows";
import type { Connection } from "@/lib/api/generated/model/connection";
import { connectionRows, needsReconnecting } from "@/lib/connections/rows";
import type { LinkedAccount } from "@/lib/identity/queries";
import type { CatalogueItem } from "@/lib/plugins/queries";
import {
type CatalogueItem,
personalConnections,
personalRow,
} from "@/lib/plugins/queries";
import { appBody, type TodayServer } from "./apps-api";

/**
Expand Down Expand Up @@ -148,6 +153,61 @@ test("and the same for Arcade's GitHub app, which is the same vendor through the
).toEqual(["arcade-gmail", "github"]);
});

/**
* AN APP ACCOUNT THE VENDOR CALLS EXPIRED READS RECONNECT, NOT CONNECTED. Reported in dogfooding:
* a Bot's Google Sheets call found the account expired, and Apps said Connected. The server says so
* on the person's connection (`revoked: true` on a brokered row, beside what its last check found);
* read here exactly as the Apps page reads it, the server's own answer through `personalRow`,
* `personalConnections` and `needsReconnecting`, the tile says Reconnect.
*/
test("a brokered app whose account the vendor lost asks to be reconnected", () => {
// The connections API's answer, as the server sent it for the expired Google Sheets account.
const answered: Connection[] = [
{
appId: "composio-googlesheets",
connectedAt: "2026-12-03T20:08:56.178Z",
revoked: true,
scope: null,
check: {
verified: true,
verifiedAt: "2026-12-03T20:08:56.177Z",
checkedAction: null,
checkable: true,
},
canAddAccount: true,
},
{
appId: "composio-gmail",
connectedAt: "2026-12-01T09:00:00.000Z",
revoked: false,
scope: null,
check: {
verified: true,
verifiedAt: "2026-12-01T09:00:00.000Z",
checkedAction: null,
checkable: true,
},
canAddAccount: true,
},
];
const mine = personalConnections(answered.map(personalRow));
const rows = connectionRows({
...none,
brokered: [
app("composio-googlesheets", "Google Sheets"),
app("composio-gmail", "Gmail"),
],
connected: new Set(mine.map((row) => row.serverId)),
reconnect: new Set(
mine.filter(needsReconnecting).map((row) => row.serverId),
),
});
expect(rows.map((row) => [row.key, row.state])).toEqual([
["composio-googlesheets", "needs_reconnect"],
["composio-gmail", "connected"],
]);
});

/**
* A key app's tile says it takes a key before anybody opens it, so the form on its page is no
* surprise. Reported from OpenBot Desktop 0.3.3, where every key app read as one more sign-in.
Expand Down