@agent-native/toolkit 0.198.8 → 0.199.0-nightly-20261001064935
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/agentkit/react/components.d.ts.map +1 -1
- package/dist/app/agentkit/react/components.js +142 -56
- package/dist/app/agentkit/react/components.js.map +1 -1
- package/dist/app/chat/AgentKitAssistantChat.d.ts.map +1 -1
- package/dist/app/chat/AgentKitAssistantChat.js +34 -27
- package/dist/app/chat/AgentKitAssistantChat.js.map +1 -1
- package/dist/app/chat/AgentPanel.d.ts +2 -1
- package/dist/app/chat/AgentPanel.d.ts.map +1 -1
- package/dist/app/chat/AgentPanel.js +7 -4
- package/dist/app/chat/AgentPanel.js.map +1 -1
- package/dist/app/chat/MultiTabAssistantChat.d.ts.map +1 -1
- package/dist/app/chat/MultiTabAssistantChat.js +21 -4
- package/dist/app/chat/MultiTabAssistantChat.js.map +1 -1
- package/dist/app/chat/chat/run-recovery.d.ts +2 -1
- package/dist/app/chat/chat/run-recovery.d.ts.map +1 -1
- package/dist/app/chat/chat/run-recovery.js +13 -9
- package/dist/app/chat/chat/run-recovery.js.map +1 -1
- package/dist/app/i18n/catalogs/ar-SA.d.ts.map +1 -1
- package/dist/app/i18n/catalogs/ar-SA.js +24 -2
- package/dist/app/i18n/catalogs/ar-SA.js.map +1 -1
- package/dist/app/i18n/catalogs/de-DE.d.ts.map +1 -1
- package/dist/app/i18n/catalogs/de-DE.js +24 -2
- package/dist/app/i18n/catalogs/de-DE.js.map +1 -1
- package/dist/app/i18n/catalogs/en-US.d.ts +24 -2
- package/dist/app/i18n/catalogs/en-US.d.ts.map +1 -1
- package/dist/app/i18n/catalogs/en-US.js +24 -2
- package/dist/app/i18n/catalogs/en-US.js.map +1 -1
- package/dist/app/i18n/catalogs/es-ES.d.ts.map +1 -1
- package/dist/app/i18n/catalogs/es-ES.js +24 -2
- package/dist/app/i18n/catalogs/es-ES.js.map +1 -1
- package/dist/app/i18n/catalogs/fr-FR.d.ts.map +1 -1
- package/dist/app/i18n/catalogs/fr-FR.js +24 -2
- package/dist/app/i18n/catalogs/fr-FR.js.map +1 -1
- package/dist/app/i18n/catalogs/hi-IN.d.ts.map +1 -1
- package/dist/app/i18n/catalogs/hi-IN.js +24 -2
- package/dist/app/i18n/catalogs/hi-IN.js.map +1 -1
- package/dist/app/i18n/catalogs/ja-JP.d.ts.map +1 -1
- package/dist/app/i18n/catalogs/ja-JP.js +24 -2
- package/dist/app/i18n/catalogs/ja-JP.js.map +1 -1
- package/dist/app/i18n/catalogs/ko-KR.d.ts.map +1 -1
- package/dist/app/i18n/catalogs/ko-KR.js +24 -2
- package/dist/app/i18n/catalogs/ko-KR.js.map +1 -1
- package/dist/app/i18n/catalogs/pt-BR.d.ts.map +1 -1
- package/dist/app/i18n/catalogs/pt-BR.js +24 -2
- package/dist/app/i18n/catalogs/pt-BR.js.map +1 -1
- package/dist/app/i18n/catalogs/zh-CN.d.ts.map +1 -1
- package/dist/app/i18n/catalogs/zh-CN.js +24 -2
- package/dist/app/i18n/catalogs/zh-CN.js.map +1 -1
- package/dist/app/i18n/catalogs/zh-TW.d.ts.map +1 -1
- package/dist/app/i18n/catalogs/zh-TW.js +24 -2
- package/dist/app/i18n/catalogs/zh-TW.js.map +1 -1
- package/dist/app/labs/LabsSettings.d.ts.map +1 -1
- package/dist/app/labs/LabsSettings.js +10 -2
- package/dist/app/labs/LabsSettings.js.map +1 -1
- package/dist/app/org/OrgSwitcher.d.ts.map +1 -1
- package/dist/app/org/OrgSwitcher.js +51 -9
- package/dist/app/org/OrgSwitcher.js.map +1 -1
- package/dist/app/settings/SettingsPanel.d.ts.map +1 -1
- package/dist/app/settings/SettingsPanel.js +4 -145
- package/dist/app/settings/SettingsPanel.js.map +1 -1
- package/dist/app/settings/SettingsTabsPage.d.ts.map +1 -1
- package/dist/app/settings/SettingsTabsPage.js +27 -16
- package/dist/app/settings/SettingsTabsPage.js.map +1 -1
- package/dist/app/settings/model/ChatGPTSubscriptionRow.d.ts +24 -2
- package/dist/app/settings/model/ChatGPTSubscriptionRow.d.ts.map +1 -1
- package/dist/app/settings/model/ChatGPTSubscriptionRow.js +97 -26
- package/dist/app/settings/model/ChatGPTSubscriptionRow.js.map +1 -1
- package/dist/app/settings/model/ModelSettingsPage.d.ts.map +1 -1
- package/dist/app/settings/model/ModelSettingsPage.js +73 -22
- package/dist/app/settings/model/ModelSettingsPage.js.map +1 -1
- package/dist/app/settings/model/model-page-state.d.ts +12 -2
- package/dist/app/settings/model/model-page-state.d.ts.map +1 -1
- package/dist/app/settings/model/model-page-state.js +14 -1
- package/dist/app/settings/model/model-page-state.js.map +1 -1
- package/dist/app/settings/shell/bridge.d.ts +1 -1
- package/dist/app/settings/shell/bridge.d.ts.map +1 -1
- package/dist/app/settings/shell/bridge.js +1 -4
- package/dist/app/settings/shell/bridge.js.map +1 -1
- package/dist/app/settings/usage/UsagePage.d.ts.map +1 -1
- package/dist/app/settings/usage/UsagePage.js +3 -2
- package/dist/app/settings/usage/UsagePage.js.map +1 -1
- package/dist/composer/TiptapComposer.d.ts +1 -0
- package/dist/composer/TiptapComposer.d.ts.map +1 -1
- package/dist/composer/TiptapComposer.js +10 -4
- package/dist/composer/TiptapComposer.js.map +1 -1
- package/dist/composer/runtime-adapters.d.ts +1 -0
- package/dist/composer/runtime-adapters.d.ts.map +1 -1
- package/dist/composer/runtime-adapters.js.map +1 -1
- package/package.json +4 -4
- package/src/app/agentkit/react/components.tsx +295 -98
- package/src/app/agentkit/react/lifecycle.spec.tsx +758 -17
- package/src/app/chat/AgentKitAssistantChat.spec.tsx +116 -7
- package/src/app/chat/AgentKitAssistantChat.tsx +100 -45
- package/src/app/chat/AgentPanel.header.spec.ts +9 -0
- package/src/app/chat/AgentPanel.tsx +10 -1
- package/src/app/chat/MultiTabAssistantChat.spec.tsx +115 -1
- package/src/app/chat/MultiTabAssistantChat.tsx +24 -4
- package/src/app/chat/chat/run-recovery.spec.tsx +31 -0
- package/src/app/chat/chat/run-recovery.tsx +22 -5
- package/src/app/i18n/catalogs/ar-SA.ts +31 -2
- package/src/app/i18n/catalogs/de-DE.ts +33 -2
- package/src/app/i18n/catalogs/en-US.ts +33 -2
- package/src/app/i18n/catalogs/es-ES.ts +34 -2
- package/src/app/i18n/catalogs/fr-FR.ts +33 -2
- package/src/app/i18n/catalogs/hi-IN.ts +34 -2
- package/src/app/i18n/catalogs/ja-JP.ts +31 -2
- package/src/app/i18n/catalogs/ko-KR.ts +31 -2
- package/src/app/i18n/catalogs/pt-BR.ts +33 -2
- package/src/app/i18n/catalogs/zh-CN.ts +32 -2
- package/src/app/i18n/catalogs/zh-TW.ts +32 -2
- package/src/app/labs/LabsSettings.tsx +13 -3
- package/src/app/org/OrgSwitcher.spec.tsx +75 -0
- package/src/app/org/OrgSwitcher.tsx +104 -34
- package/src/app/settings/SettingsPanel.connections.spec.tsx +25 -5
- package/src/app/settings/SettingsPanel.tsx +3 -286
- package/src/app/settings/SettingsTabsPage.spec.tsx +110 -17
- package/src/app/settings/SettingsTabsPage.tsx +36 -20
- package/src/app/settings/model/ChatGPTSubscriptionRow.tsx +316 -60
- package/src/app/settings/model/ModelSettingsPage.spec.tsx +599 -20
- package/src/app/settings/model/ModelSettingsPage.tsx +114 -25
- package/src/app/settings/model/model-page-state.spec.ts +46 -0
- package/src/app/settings/model/model-page-state.ts +27 -2
- package/src/app/settings/shell/bridge.spec.ts +3 -13
- package/src/app/settings/shell/bridge.ts +2 -5
- package/src/app/settings/shell/pages/app-group-pages.spec.tsx +50 -2
- package/src/app/settings/usage/UsagePage.spec.tsx +25 -1
- package/src/app/settings/usage/UsagePage.tsx +21 -1
- package/src/composer/PromptComposer.context.spec.tsx +22 -3
- package/src/composer/TiptapComposer.tsx +13 -4
- package/src/composer/runtime-adapters.tsx +1 -0
|
@@ -16,9 +16,11 @@ const state = vi.hoisted(() => ({
|
|
|
16
16
|
listing: undefined as unknown,
|
|
17
17
|
models: undefined as unknown,
|
|
18
18
|
chatgpt: undefined as unknown,
|
|
19
|
+
chatgptLabEnabled: true,
|
|
20
|
+
chatgptStatusError: false,
|
|
21
|
+
chatgptStatusRefetch: vi.fn(),
|
|
19
22
|
modelsError: false,
|
|
20
23
|
modelsRefetch: vi.fn(),
|
|
21
|
-
lab: false,
|
|
22
24
|
builder: {} as Record<string, unknown>,
|
|
23
25
|
header: null as { action?: unknown } | null,
|
|
24
26
|
loop: {
|
|
@@ -33,6 +35,7 @@ const state = vi.hoisted(() => ({
|
|
|
33
35
|
},
|
|
34
36
|
}));
|
|
35
37
|
const callActionMock = vi.hoisted(() => vi.fn());
|
|
38
|
+
const popupMock = vi.hoisted(() => vi.fn());
|
|
36
39
|
const navigateMock = vi.hoisted(() => vi.fn());
|
|
37
40
|
const dialogProps = vi.hoisted(() => ({ last: null as unknown }));
|
|
38
41
|
const loopMock = vi.hoisted(() => ({ save: vi.fn() }));
|
|
@@ -48,8 +51,18 @@ vi.mock("@agent-native/core/client/hooks", () => ({
|
|
|
48
51
|
: name === "get-chatgpt-subscription-status"
|
|
49
52
|
? state.chatgpt
|
|
50
53
|
: undefined,
|
|
51
|
-
isError:
|
|
52
|
-
|
|
54
|
+
isError:
|
|
55
|
+
name === "get-provider-models"
|
|
56
|
+
? state.modelsError
|
|
57
|
+
: name === "get-chatgpt-subscription-status"
|
|
58
|
+
? state.chatgptStatusError
|
|
59
|
+
: false,
|
|
60
|
+
refetch:
|
|
61
|
+
name === "get-provider-models"
|
|
62
|
+
? state.modelsRefetch
|
|
63
|
+
: name === "get-chatgpt-subscription-status"
|
|
64
|
+
? state.chatgptStatusRefetch
|
|
65
|
+
: vi.fn(),
|
|
53
66
|
}),
|
|
54
67
|
callAction: callActionMock,
|
|
55
68
|
}));
|
|
@@ -59,18 +72,16 @@ vi.mock("@agent-native/core/client/org", () => ({
|
|
|
59
72
|
}));
|
|
60
73
|
|
|
61
74
|
vi.mock("@agent-native/core/client/labs/use-lab", () => ({
|
|
62
|
-
useLabState: () => ({
|
|
63
|
-
enabled: state.lab,
|
|
64
|
-
isLoading: false,
|
|
65
|
-
isError: false,
|
|
66
|
-
isSuccess: true,
|
|
67
|
-
}),
|
|
75
|
+
useLabState: () => ({ enabled: state.chatgptLabEnabled }),
|
|
68
76
|
}));
|
|
69
77
|
|
|
70
78
|
vi.mock("../useBuilderStatus.js", () => ({
|
|
71
79
|
useBuilderConnectFlow: () => state.builder,
|
|
72
|
-
isPopupClosed: () =>
|
|
73
|
-
|
|
80
|
+
isPopupClosed: (popup: { closed?: boolean } | null) => popup?.closed === true,
|
|
81
|
+
}));
|
|
82
|
+
|
|
83
|
+
vi.mock("@agent-native/core/client/oauth-popup", () => ({
|
|
84
|
+
openOAuthPopup: popupMock,
|
|
74
85
|
}));
|
|
75
86
|
|
|
76
87
|
vi.mock("../deferred-builder-connect-popover.js", () => ({
|
|
@@ -244,9 +255,56 @@ function prominence(element: HTMLElement): string[] {
|
|
|
244
255
|
});
|
|
245
256
|
}
|
|
246
257
|
|
|
258
|
+
const ACCOUNT = {
|
|
259
|
+
id: "siwc_test-account",
|
|
260
|
+
email: "person@example.test",
|
|
261
|
+
label: "person@example.test",
|
|
262
|
+
connected: true,
|
|
263
|
+
reconnectRequired: false,
|
|
264
|
+
planUsageEnabled: true,
|
|
265
|
+
active: true,
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
function connectedChatGPT(accounts: Array<typeof ACCOUNT> = [ACCOUNT]) {
|
|
269
|
+
return {
|
|
270
|
+
supported: true,
|
|
271
|
+
supportReason: null,
|
|
272
|
+
connected: true,
|
|
273
|
+
reconnectRequired: false,
|
|
274
|
+
activeAccountId: accounts[0]!.id,
|
|
275
|
+
activeAccount: accounts[0],
|
|
276
|
+
accounts,
|
|
277
|
+
legacyRegistrationCleanupAvailable: false,
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function pointerDown(element: Element | null | undefined) {
|
|
282
|
+
if (!element) throw new Error("Nothing to open");
|
|
283
|
+
element.dispatchEvent(
|
|
284
|
+
new PointerEvent("pointerdown", {
|
|
285
|
+
bubbles: true,
|
|
286
|
+
button: 0,
|
|
287
|
+
pointerType: "mouse",
|
|
288
|
+
}),
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function chatgptMenuTrigger(): HTMLElement {
|
|
293
|
+
return row("chatgpt-subscription").querySelector(
|
|
294
|
+
'button[aria-label="Manage"]',
|
|
295
|
+
) as HTMLElement;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
function listed(selector: string): string[] {
|
|
299
|
+
return [...document.body.querySelectorAll(selector)].map(
|
|
300
|
+
(element) => element.textContent?.trim() ?? "",
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
|
|
247
304
|
describe("ModelSettingsPage", () => {
|
|
248
305
|
let container: HTMLDivElement;
|
|
249
306
|
let root: Root;
|
|
307
|
+
let queryClient: QueryClient;
|
|
250
308
|
|
|
251
309
|
beforeEach(() => {
|
|
252
310
|
vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true);
|
|
@@ -254,12 +312,25 @@ describe("ModelSettingsPage", () => {
|
|
|
254
312
|
state.models = models();
|
|
255
313
|
state.modelsError = false;
|
|
256
314
|
state.modelsRefetch = vi.fn();
|
|
257
|
-
state.
|
|
258
|
-
state.
|
|
315
|
+
state.chatgptStatusError = false;
|
|
316
|
+
state.chatgptStatusRefetch = vi.fn();
|
|
317
|
+
state.chatgptLabEnabled = true;
|
|
318
|
+
state.chatgpt = {
|
|
319
|
+
supported: true,
|
|
320
|
+
supportReason: null,
|
|
321
|
+
connected: false,
|
|
322
|
+
reconnectRequired: false,
|
|
323
|
+
activeAccountId: null,
|
|
324
|
+
activeAccount: null,
|
|
325
|
+
accounts: [],
|
|
326
|
+
};
|
|
259
327
|
state.builder = builderFlow();
|
|
260
328
|
state.header = null;
|
|
329
|
+
queryClient = new QueryClient();
|
|
261
330
|
state.loop = { ...state.loop, canUpdate: true };
|
|
262
331
|
callActionMock.mockReset();
|
|
332
|
+
callActionMock.mockResolvedValue({ engines: [] });
|
|
333
|
+
popupMock.mockReset();
|
|
263
334
|
navigateMock.mockReset();
|
|
264
335
|
loopMock.save.mockReset();
|
|
265
336
|
container = document.createElement("div");
|
|
@@ -277,7 +348,7 @@ describe("ModelSettingsPage", () => {
|
|
|
277
348
|
async function render() {
|
|
278
349
|
await act(async () => {
|
|
279
350
|
root.render(
|
|
280
|
-
<QueryClientProvider client={
|
|
351
|
+
<QueryClientProvider client={queryClient}>
|
|
281
352
|
<ModelSettingsPage
|
|
282
353
|
pageId="model"
|
|
283
354
|
sub={null}
|
|
@@ -622,7 +693,10 @@ describe("ModelSettingsPage", () => {
|
|
|
622
693
|
expect(empty.textContent).toContain("Add a model provider");
|
|
623
694
|
expect(empty.textContent).toContain("Ask an owner or admin to add one.");
|
|
624
695
|
expect(buttons(empty)).toEqual([]);
|
|
625
|
-
expect(
|
|
696
|
+
expect(row("personal-providers")).toBeTruthy();
|
|
697
|
+
expect(buttons(row("chatgpt-subscription"))).toEqual([
|
|
698
|
+
"Continue with ChatGPT",
|
|
699
|
+
]);
|
|
626
700
|
});
|
|
627
701
|
|
|
628
702
|
it("makes Add provider the empty state's primary when Builder.io can't be connected", async () => {
|
|
@@ -697,13 +771,518 @@ describe("ModelSettingsPage", () => {
|
|
|
697
771
|
expect(row("provider-org-builder")).toBeTruthy();
|
|
698
772
|
});
|
|
699
773
|
|
|
700
|
-
it("
|
|
701
|
-
state.lab = true;
|
|
774
|
+
it("shows official local ChatGPT plan access when its Lab is enabled", async () => {
|
|
702
775
|
await render();
|
|
703
776
|
const chatgpt = row("chatgpt-subscription");
|
|
704
|
-
expect(chatgpt.textContent).toContain("ChatGPT
|
|
705
|
-
expect(chatgpt.textContent).toContain("Labs");
|
|
706
|
-
expect(buttons(chatgpt)).toEqual(["
|
|
777
|
+
expect(chatgpt.textContent).toContain("ChatGPT plan access");
|
|
778
|
+
expect(chatgpt.textContent).not.toContain("Labs");
|
|
779
|
+
expect(buttons(chatgpt)).toEqual(["Continue with ChatGPT"]);
|
|
780
|
+
});
|
|
781
|
+
|
|
782
|
+
it("hides ChatGPT and its models while the Lab is off", async () => {
|
|
783
|
+
state.listing = listing({ canManageOrg: true, canUpdateDefault: true });
|
|
784
|
+
state.chatgpt = connectedChatGPT();
|
|
785
|
+
state.chatgptLabEnabled = false;
|
|
786
|
+
await render();
|
|
787
|
+
|
|
788
|
+
expect(document.getElementById("chatgpt-subscription")).toBeNull();
|
|
789
|
+
expect(callActionMock).not.toHaveBeenCalledWith("manage-agent-engine", {
|
|
790
|
+
action: "list",
|
|
791
|
+
});
|
|
792
|
+
});
|
|
793
|
+
|
|
794
|
+
it("keeps a connected ChatGPT plan personal when choosing the organization default", async () => {
|
|
795
|
+
state.listing = listing(
|
|
796
|
+
{
|
|
797
|
+
canManageOrg: true,
|
|
798
|
+
canUpdateDefault: true,
|
|
799
|
+
defaultModel: null,
|
|
800
|
+
},
|
|
801
|
+
{
|
|
802
|
+
anthropic: {
|
|
803
|
+
org: { scope: "org", masked: "••••1234", updatedAt: 1 },
|
|
804
|
+
},
|
|
805
|
+
},
|
|
806
|
+
);
|
|
807
|
+
state.builder = builderFlow({
|
|
808
|
+
configured: false,
|
|
809
|
+
grants: { org: null, personal: null },
|
|
810
|
+
canConnect: { org: true, personal: true },
|
|
811
|
+
});
|
|
812
|
+
state.chatgpt = connectedChatGPT();
|
|
813
|
+
callActionMock.mockImplementation(async (name: string) =>
|
|
814
|
+
name === "manage-agent-engine"
|
|
815
|
+
? {
|
|
816
|
+
engines: [
|
|
817
|
+
{
|
|
818
|
+
name: "chatgpt-subscription",
|
|
819
|
+
label: "ChatGPT plan access",
|
|
820
|
+
supportedModels: ["gpt-5.5", "gpt-5.4"],
|
|
821
|
+
modelDisplayNames: { "gpt-5.5": "GPT-5.5" },
|
|
822
|
+
},
|
|
823
|
+
],
|
|
824
|
+
}
|
|
825
|
+
: {},
|
|
826
|
+
);
|
|
827
|
+
await render();
|
|
828
|
+
|
|
829
|
+
expect(container.textContent).not.toContain("Add a model provider");
|
|
830
|
+
expect(state.header?.action).toBeTruthy();
|
|
831
|
+
expect(
|
|
832
|
+
row("personal-providers").contains(row("chatgpt-subscription")),
|
|
833
|
+
).toBe(true);
|
|
834
|
+
expect(row("chatgpt-subscription").textContent).toContain(
|
|
835
|
+
"ChatGPT plan access",
|
|
836
|
+
);
|
|
837
|
+
const defaultRow = row("default-model");
|
|
838
|
+
expect(defaultRow.textContent).not.toContain(
|
|
839
|
+
"Add a provider to choose a default model.",
|
|
840
|
+
);
|
|
841
|
+
const select = await vi.waitFor(() => {
|
|
842
|
+
const found =
|
|
843
|
+
defaultRow.querySelector<HTMLButtonElement>('[role="combobox"]');
|
|
844
|
+
if (!found) throw new Error("no select yet");
|
|
845
|
+
return found;
|
|
846
|
+
});
|
|
847
|
+
expect(select.disabled).toBe(false);
|
|
848
|
+
await act(async () => pointerDown(select));
|
|
849
|
+
expect(listed('[role="option"]')).toEqual([
|
|
850
|
+
"model-a · Anthropic",
|
|
851
|
+
"model-b · Anthropic",
|
|
852
|
+
]);
|
|
853
|
+
expect(
|
|
854
|
+
listed('[role="option"]').some((option) => option.includes("ChatGPT")),
|
|
855
|
+
).toBe(false);
|
|
856
|
+
expect(defaultRow.querySelector("[data-default-model-loading]")).toBeNull();
|
|
857
|
+
expect(callActionMock).not.toHaveBeenCalledWith("manage-agent-engine", {
|
|
858
|
+
action: "list",
|
|
859
|
+
});
|
|
860
|
+
});
|
|
861
|
+
|
|
862
|
+
it("keeps ChatGPT status errors scoped to its personal row for org defaults", async () => {
|
|
863
|
+
state.listing = listing({ canManageOrg: true, canUpdateDefault: true });
|
|
864
|
+
state.chatgpt = undefined;
|
|
865
|
+
state.chatgptStatusError = true;
|
|
866
|
+
await render();
|
|
867
|
+
|
|
868
|
+
const defaultRow = row("default-model");
|
|
869
|
+
expect(defaultRow.querySelector('[role="combobox"]')).not.toBeNull();
|
|
870
|
+
expect(defaultRow.querySelector('[role="alert"]')).toBeNull();
|
|
871
|
+
expect(
|
|
872
|
+
row("chatgpt-subscription").querySelector('[role="alert"]')?.textContent,
|
|
873
|
+
).toContain("Couldn't load this setting.");
|
|
874
|
+
expect(callActionMock).not.toHaveBeenCalledWith("manage-agent-engine", {
|
|
875
|
+
action: "list",
|
|
876
|
+
});
|
|
877
|
+
});
|
|
878
|
+
|
|
879
|
+
it("says the ChatGPT models couldn't load instead of leaving the default empty", async () => {
|
|
880
|
+
state.listing = listing({
|
|
881
|
+
hasOrganization: false,
|
|
882
|
+
canUpdateDefault: true,
|
|
883
|
+
defaultModel: null,
|
|
884
|
+
});
|
|
885
|
+
state.builder = builderFlow({
|
|
886
|
+
configured: false,
|
|
887
|
+
grants: { org: null, personal: null },
|
|
888
|
+
canConnect: { org: true, personal: true },
|
|
889
|
+
});
|
|
890
|
+
state.chatgpt = connectedChatGPT();
|
|
891
|
+
callActionMock.mockImplementation(async (name: string) => {
|
|
892
|
+
if (name === "manage-agent-engine") {
|
|
893
|
+
return {
|
|
894
|
+
engines: [
|
|
895
|
+
{
|
|
896
|
+
name: "chatgpt-subscription",
|
|
897
|
+
supportedModels: [],
|
|
898
|
+
configuredError: "OpenAI ChatGPT model listing failed",
|
|
899
|
+
},
|
|
900
|
+
],
|
|
901
|
+
};
|
|
902
|
+
}
|
|
903
|
+
return {};
|
|
904
|
+
});
|
|
905
|
+
await render();
|
|
906
|
+
|
|
907
|
+
const defaultRow = row("default-model");
|
|
908
|
+
await vi.waitFor(() => {
|
|
909
|
+
expect(defaultRow.querySelector('[role="alert"]')?.textContent).toContain(
|
|
910
|
+
"Couldn't load this setting.",
|
|
911
|
+
);
|
|
912
|
+
});
|
|
913
|
+
expect(defaultRow.querySelector('[role="combobox"]')).not.toBeNull();
|
|
914
|
+
});
|
|
915
|
+
|
|
916
|
+
it("keeps ChatGPT status unknown when its read fails", async () => {
|
|
917
|
+
state.listing = listing({ hasOrganization: false });
|
|
918
|
+
state.builder = builderFlow({
|
|
919
|
+
configured: false,
|
|
920
|
+
grants: null,
|
|
921
|
+
canConnect: { org: false, personal: false },
|
|
922
|
+
});
|
|
923
|
+
state.chatgpt = undefined;
|
|
924
|
+
state.chatgptStatusError = true;
|
|
925
|
+
await render();
|
|
926
|
+
|
|
927
|
+
expect(container.textContent).not.toContain("Add a model provider");
|
|
928
|
+
expect(
|
|
929
|
+
row("default-model").querySelector('[role="alert"]')?.textContent,
|
|
930
|
+
).toContain("Couldn't load this setting.");
|
|
931
|
+
expect(callActionMock).not.toHaveBeenCalledWith("manage-agent-engine", {
|
|
932
|
+
action: "list",
|
|
933
|
+
});
|
|
934
|
+
});
|
|
935
|
+
|
|
936
|
+
it("loads a fresh ChatGPT catalog after switching accounts", async () => {
|
|
937
|
+
state.listing = listing({
|
|
938
|
+
hasOrganization: false,
|
|
939
|
+
canUpdateDefault: true,
|
|
940
|
+
defaultModel: null,
|
|
941
|
+
});
|
|
942
|
+
state.builder = builderFlow({
|
|
943
|
+
configured: false,
|
|
944
|
+
grants: { org: null, personal: null },
|
|
945
|
+
canConnect: { org: true, personal: true },
|
|
946
|
+
});
|
|
947
|
+
const second = {
|
|
948
|
+
...ACCOUNT,
|
|
949
|
+
id: "siwc_second",
|
|
950
|
+
label: "second@example.test",
|
|
951
|
+
};
|
|
952
|
+
let activeAccountId = ACCOUNT.id;
|
|
953
|
+
state.chatgpt = connectedChatGPT([ACCOUNT, second]);
|
|
954
|
+
callActionMock.mockImplementation(async (name: string) =>
|
|
955
|
+
name === "manage-agent-engine"
|
|
956
|
+
? {
|
|
957
|
+
engines: [
|
|
958
|
+
{
|
|
959
|
+
name: "chatgpt-subscription",
|
|
960
|
+
supportedModels:
|
|
961
|
+
activeAccountId === ACCOUNT.id ? ["gpt-5.5"] : ["gpt-5.4"],
|
|
962
|
+
},
|
|
963
|
+
],
|
|
964
|
+
}
|
|
965
|
+
: {},
|
|
966
|
+
);
|
|
967
|
+
|
|
968
|
+
await render();
|
|
969
|
+
const defaultRow = row("default-model");
|
|
970
|
+
const select = await vi.waitFor(() => {
|
|
971
|
+
const found =
|
|
972
|
+
defaultRow.querySelector<HTMLButtonElement>('[role="combobox"]');
|
|
973
|
+
if (!found) throw new Error("No default model selector yet");
|
|
974
|
+
return found;
|
|
975
|
+
});
|
|
976
|
+
await act(async () => pointerDown(select));
|
|
977
|
+
await vi.waitFor(() => {
|
|
978
|
+
expect(listed('[role="option"]')).toContain("gpt-5.5 · ChatGPT");
|
|
979
|
+
});
|
|
980
|
+
await act(async () => {
|
|
981
|
+
select.dispatchEvent(
|
|
982
|
+
new KeyboardEvent("keydown", { key: "Escape", bubbles: true }),
|
|
983
|
+
);
|
|
984
|
+
});
|
|
985
|
+
const firstAccountFetches = callActionMock.mock.calls.filter(
|
|
986
|
+
([name]) => name === "manage-agent-engine",
|
|
987
|
+
).length;
|
|
988
|
+
|
|
989
|
+
activeAccountId = second.id;
|
|
990
|
+
state.chatgpt = {
|
|
991
|
+
...connectedChatGPT([ACCOUNT, second]),
|
|
992
|
+
activeAccountId: second.id,
|
|
993
|
+
activeAccount: second,
|
|
994
|
+
};
|
|
995
|
+
await render();
|
|
996
|
+
const updatedSelect = await vi.waitFor(() => {
|
|
997
|
+
const found =
|
|
998
|
+
row("default-model").querySelector<HTMLButtonElement>(
|
|
999
|
+
'[role="combobox"]',
|
|
1000
|
+
);
|
|
1001
|
+
if (!found) throw new Error("No default model selector after switch");
|
|
1002
|
+
return found;
|
|
1003
|
+
});
|
|
1004
|
+
await act(async () => pointerDown(updatedSelect));
|
|
1005
|
+
await vi.waitFor(() => {
|
|
1006
|
+
expect(
|
|
1007
|
+
callActionMock.mock.calls.filter(
|
|
1008
|
+
([name]) => name === "manage-agent-engine",
|
|
1009
|
+
).length,
|
|
1010
|
+
).toBeGreaterThan(firstAccountFetches);
|
|
1011
|
+
expect(listed('[role="option"]')).toContain("gpt-5.4 · ChatGPT");
|
|
1012
|
+
});
|
|
1013
|
+
expect(listed('[role="option"]')).not.toContain("gpt-5.5 · ChatGPT");
|
|
1014
|
+
});
|
|
1015
|
+
|
|
1016
|
+
it("doesn't flash the empty state before the ChatGPT status answers", async () => {
|
|
1017
|
+
state.builder = builderFlow({
|
|
1018
|
+
configured: false,
|
|
1019
|
+
grants: { org: null, personal: null },
|
|
1020
|
+
canConnect: { org: false, personal: false },
|
|
1021
|
+
});
|
|
1022
|
+
state.chatgpt = undefined;
|
|
1023
|
+
await render();
|
|
1024
|
+
expect(container.textContent).not.toContain("Add a model provider");
|
|
1025
|
+
});
|
|
1026
|
+
|
|
1027
|
+
it("shows only Continue with ChatGPT when signed out, even with saved accounts", async () => {
|
|
1028
|
+
const saved = { ...ACCOUNT, connected: false, active: false };
|
|
1029
|
+
state.chatgpt = {
|
|
1030
|
+
...connectedChatGPT([saved, { ...saved, id: "siwc_other" }]),
|
|
1031
|
+
connected: false,
|
|
1032
|
+
activeAccountId: null,
|
|
1033
|
+
activeAccount: null,
|
|
1034
|
+
};
|
|
1035
|
+
await render();
|
|
1036
|
+
const chatgpt = row("chatgpt-subscription");
|
|
1037
|
+
expect(buttons(chatgpt)).toEqual(["Continue with ChatGPT"]);
|
|
1038
|
+
expect(chatgpt.querySelector('[role="combobox"]')).toBeNull();
|
|
1039
|
+
});
|
|
1040
|
+
|
|
1041
|
+
it("acknowledges Continue with ChatGPT at once and recovers if the window is closed", async () => {
|
|
1042
|
+
vi.useFakeTimers();
|
|
1043
|
+
try {
|
|
1044
|
+
const popup = { closed: false };
|
|
1045
|
+
popupMock.mockReturnValue(popup);
|
|
1046
|
+
await render();
|
|
1047
|
+
const chatgpt = row("chatgpt-subscription");
|
|
1048
|
+
await act(async () => {
|
|
1049
|
+
(chatgpt.querySelector("button") as HTMLElement).click();
|
|
1050
|
+
});
|
|
1051
|
+
const pending = chatgpt.querySelector("button") as HTMLButtonElement;
|
|
1052
|
+
expect(pending.textContent).toContain("Connecting…");
|
|
1053
|
+
expect(pending.disabled).toBe(true);
|
|
1054
|
+
|
|
1055
|
+
popup.closed = true;
|
|
1056
|
+
await act(async () => {
|
|
1057
|
+
vi.advanceTimersByTime(600);
|
|
1058
|
+
});
|
|
1059
|
+
expect(buttons(chatgpt)).toEqual(["Continue with ChatGPT"]);
|
|
1060
|
+
} finally {
|
|
1061
|
+
vi.useRealTimers();
|
|
1062
|
+
}
|
|
1063
|
+
});
|
|
1064
|
+
|
|
1065
|
+
it("says when the browser blocked the ChatGPT sign-in window", async () => {
|
|
1066
|
+
popupMock.mockReturnValue(null);
|
|
1067
|
+
await render();
|
|
1068
|
+
const chatgpt = row("chatgpt-subscription");
|
|
1069
|
+
await act(async () => {
|
|
1070
|
+
(chatgpt.querySelector("button") as HTMLElement).click();
|
|
1071
|
+
});
|
|
1072
|
+
expect(chatgpt.querySelector('[role="alert"]')?.textContent).toBe(
|
|
1073
|
+
"Allow pop-ups for this site, then try again.",
|
|
1074
|
+
);
|
|
1075
|
+
expect(buttons(chatgpt)).toEqual(["Continue with ChatGPT"]);
|
|
1076
|
+
});
|
|
1077
|
+
|
|
1078
|
+
it("shows a connected account's email with one menu for the rest", async () => {
|
|
1079
|
+
state.chatgpt = connectedChatGPT();
|
|
1080
|
+
await render();
|
|
1081
|
+
const chatgpt = row("chatgpt-subscription");
|
|
1082
|
+
expect(chatgpt.textContent).toContain("person@example.test");
|
|
1083
|
+
expect(buttons(chatgpt)).toEqual([""]);
|
|
1084
|
+
expect(chatgpt.querySelector('[role="combobox"]')).toBeNull();
|
|
1085
|
+
|
|
1086
|
+
await act(async () => pointerDown(chatgptMenuTrigger()));
|
|
1087
|
+
expect(listed('[role="menuitem"]')).toEqual([
|
|
1088
|
+
"Add another account",
|
|
1089
|
+
"Disconnect",
|
|
1090
|
+
]);
|
|
1091
|
+
});
|
|
1092
|
+
|
|
1093
|
+
it("switches between connected accounts only", async () => {
|
|
1094
|
+
const second = {
|
|
1095
|
+
...ACCOUNT,
|
|
1096
|
+
id: "siwc_second",
|
|
1097
|
+
label: "second@example.test",
|
|
1098
|
+
};
|
|
1099
|
+
const signedOut = {
|
|
1100
|
+
...ACCOUNT,
|
|
1101
|
+
id: "siwc_old",
|
|
1102
|
+
label: "old@example.test",
|
|
1103
|
+
connected: false,
|
|
1104
|
+
};
|
|
1105
|
+
state.chatgpt = connectedChatGPT([ACCOUNT, second, signedOut]);
|
|
1106
|
+
callActionMock.mockResolvedValue({});
|
|
1107
|
+
await render();
|
|
1108
|
+
const chatgpt = row("chatgpt-subscription");
|
|
1109
|
+
await act(async () =>
|
|
1110
|
+
pointerDown(chatgpt.querySelector('[role="combobox"]')),
|
|
1111
|
+
);
|
|
1112
|
+
expect(listed('[role="option"]')).toEqual([
|
|
1113
|
+
"person@example.test",
|
|
1114
|
+
"second@example.test",
|
|
1115
|
+
]);
|
|
1116
|
+
await act(async () => {
|
|
1117
|
+
(
|
|
1118
|
+
[...document.body.querySelectorAll('[role="option"]')].find(
|
|
1119
|
+
(option) => option.textContent === "second@example.test",
|
|
1120
|
+
) as HTMLElement
|
|
1121
|
+
).click();
|
|
1122
|
+
});
|
|
1123
|
+
expect(callActionMock).toHaveBeenCalledWith(
|
|
1124
|
+
"select-chatgpt-subscription-account",
|
|
1125
|
+
{ accountId: "siwc_second" },
|
|
1126
|
+
);
|
|
1127
|
+
});
|
|
1128
|
+
|
|
1129
|
+
it("confirms before disconnecting and says where to revoke access afterwards", async () => {
|
|
1130
|
+
state.chatgpt = connectedChatGPT();
|
|
1131
|
+
callActionMock.mockResolvedValue({ remoteRevocationConfirmed: false });
|
|
1132
|
+
await render();
|
|
1133
|
+
|
|
1134
|
+
await act(async () => pointerDown(chatgptMenuTrigger()));
|
|
1135
|
+
await act(async () => {
|
|
1136
|
+
(
|
|
1137
|
+
[...document.body.querySelectorAll('[role="menuitem"]')].find(
|
|
1138
|
+
(item) => item.textContent === "Disconnect",
|
|
1139
|
+
) as HTMLElement
|
|
1140
|
+
).click();
|
|
1141
|
+
});
|
|
1142
|
+
const dialog = document.body.querySelector('[role="alertdialog"]');
|
|
1143
|
+
expect(dialog?.textContent).toContain("Disconnect ChatGPT?");
|
|
1144
|
+
expect(dialog?.textContent).toContain(
|
|
1145
|
+
"person@example.test will be signed out of this app and the agent will stop using your ChatGPT plan.",
|
|
1146
|
+
);
|
|
1147
|
+
expect(callActionMock).not.toHaveBeenCalledWith(
|
|
1148
|
+
"disconnect-chatgpt-subscription",
|
|
1149
|
+
expect.anything(),
|
|
1150
|
+
);
|
|
1151
|
+
|
|
1152
|
+
await act(async () => {
|
|
1153
|
+
(
|
|
1154
|
+
[...(dialog?.querySelectorAll("button") ?? [])].find(
|
|
1155
|
+
(button) => button.textContent === "Disconnect",
|
|
1156
|
+
) as HTMLElement
|
|
1157
|
+
).click();
|
|
1158
|
+
});
|
|
1159
|
+
expect(callActionMock).toHaveBeenCalledWith(
|
|
1160
|
+
"disconnect-chatgpt-subscription",
|
|
1161
|
+
{ accountId: ACCOUNT.id },
|
|
1162
|
+
);
|
|
1163
|
+
expect(document.body.querySelector('[role="alertdialog"]')).toBeNull();
|
|
1164
|
+
|
|
1165
|
+
const chatgpt = row("chatgpt-subscription");
|
|
1166
|
+
expect(chatgpt.textContent).toContain(
|
|
1167
|
+
"Disconnected here. Access may remain active in ChatGPT.",
|
|
1168
|
+
);
|
|
1169
|
+
const manageAccess = chatgpt.querySelector(
|
|
1170
|
+
'a[href="https://chatgpt.com/settings/usage"]',
|
|
1171
|
+
) as HTMLAnchorElement;
|
|
1172
|
+
expect(manageAccess.textContent).toBe("Manage in ChatGPT");
|
|
1173
|
+
});
|
|
1174
|
+
|
|
1175
|
+
it("leaves the account connected when the disconnect is cancelled", async () => {
|
|
1176
|
+
state.chatgpt = connectedChatGPT();
|
|
1177
|
+
await render();
|
|
1178
|
+
|
|
1179
|
+
await act(async () => pointerDown(chatgptMenuTrigger()));
|
|
1180
|
+
await act(async () => {
|
|
1181
|
+
(
|
|
1182
|
+
[...document.body.querySelectorAll('[role="menuitem"]')].find(
|
|
1183
|
+
(item) => item.textContent === "Disconnect",
|
|
1184
|
+
) as HTMLElement
|
|
1185
|
+
).click();
|
|
1186
|
+
});
|
|
1187
|
+
await act(async () => {
|
|
1188
|
+
(
|
|
1189
|
+
[
|
|
1190
|
+
...(document.body
|
|
1191
|
+
.querySelector('[role="alertdialog"]')
|
|
1192
|
+
?.querySelectorAll("button") ?? []),
|
|
1193
|
+
].find((button) => button.textContent === "Cancel") as HTMLElement
|
|
1194
|
+
).click();
|
|
1195
|
+
});
|
|
1196
|
+
expect(document.body.querySelector('[role="alertdialog"]')).toBeNull();
|
|
1197
|
+
expect(callActionMock).not.toHaveBeenCalledWith(
|
|
1198
|
+
"disconnect-chatgpt-subscription",
|
|
1199
|
+
expect.anything(),
|
|
1200
|
+
);
|
|
1201
|
+
});
|
|
1202
|
+
|
|
1203
|
+
it("shows why a disconnect failed instead of closing silently", async () => {
|
|
1204
|
+
state.chatgpt = connectedChatGPT();
|
|
1205
|
+
callActionMock.mockRejectedValue(
|
|
1206
|
+
new Error("ChatGPT account was not found."),
|
|
1207
|
+
);
|
|
1208
|
+
await render();
|
|
1209
|
+
|
|
1210
|
+
await act(async () => pointerDown(chatgptMenuTrigger()));
|
|
1211
|
+
await act(async () => {
|
|
1212
|
+
(
|
|
1213
|
+
[...document.body.querySelectorAll('[role="menuitem"]')].find(
|
|
1214
|
+
(item) => item.textContent === "Disconnect",
|
|
1215
|
+
) as HTMLElement
|
|
1216
|
+
).click();
|
|
1217
|
+
});
|
|
1218
|
+
await act(async () => {
|
|
1219
|
+
(
|
|
1220
|
+
[
|
|
1221
|
+
...(document.body
|
|
1222
|
+
.querySelector('[role="alertdialog"]')
|
|
1223
|
+
?.querySelectorAll("button") ?? []),
|
|
1224
|
+
].find((button) => button.textContent === "Disconnect") as HTMLElement
|
|
1225
|
+
).click();
|
|
1226
|
+
});
|
|
1227
|
+
expect(
|
|
1228
|
+
row("chatgpt-subscription").querySelector('[role="alert"]')?.textContent,
|
|
1229
|
+
).toBe("ChatGPT account was not found.");
|
|
1230
|
+
});
|
|
1231
|
+
|
|
1232
|
+
it("offers explicit removal of an unusable legacy ChatGPT sign-in", async () => {
|
|
1233
|
+
state.chatgpt = {
|
|
1234
|
+
supported: true,
|
|
1235
|
+
supportReason: null,
|
|
1236
|
+
connected: false,
|
|
1237
|
+
reconnectRequired: false,
|
|
1238
|
+
activeAccountId: null,
|
|
1239
|
+
activeAccount: null,
|
|
1240
|
+
accounts: [],
|
|
1241
|
+
legacyRegistrationCleanupAvailable: true,
|
|
1242
|
+
};
|
|
1243
|
+
callActionMock.mockResolvedValue({
|
|
1244
|
+
removed: true,
|
|
1245
|
+
remoteRevocationConfirmed: false,
|
|
1246
|
+
});
|
|
1247
|
+
await render();
|
|
1248
|
+
|
|
1249
|
+
const chatgpt = row("chatgpt-subscription");
|
|
1250
|
+
expect(chatgpt.textContent).toContain(
|
|
1251
|
+
"An older ChatGPT sign-in is saved here. The official flow cannot use it.",
|
|
1252
|
+
);
|
|
1253
|
+
await act(async () => {
|
|
1254
|
+
const remove = [...chatgpt.querySelectorAll("button")].find(
|
|
1255
|
+
(button) => button.textContent === "Remove old sign-in",
|
|
1256
|
+
) as HTMLElement;
|
|
1257
|
+
remove.click();
|
|
1258
|
+
});
|
|
1259
|
+
|
|
1260
|
+
expect(callActionMock).toHaveBeenCalledWith(
|
|
1261
|
+
"disconnect-chatgpt-subscription",
|
|
1262
|
+
{ removeLegacyCredential: true },
|
|
1263
|
+
);
|
|
1264
|
+
expect(chatgpt.textContent).toContain(
|
|
1265
|
+
"Disconnected here. Access may remain active in ChatGPT.",
|
|
1266
|
+
);
|
|
1267
|
+
});
|
|
1268
|
+
|
|
1269
|
+
it("explains hosted ChatGPT approval needs without a request link", async () => {
|
|
1270
|
+
state.chatgpt = {
|
|
1271
|
+
supported: false,
|
|
1272
|
+
supportReason: "requires_local_loopback",
|
|
1273
|
+
connected: false,
|
|
1274
|
+
reconnectRequired: false,
|
|
1275
|
+
activeAccountId: null,
|
|
1276
|
+
activeAccount: null,
|
|
1277
|
+
accounts: [],
|
|
1278
|
+
};
|
|
1279
|
+
await render();
|
|
1280
|
+
const chatgpt = row("chatgpt-subscription");
|
|
1281
|
+
expect(chatgpt.textContent).toContain(
|
|
1282
|
+
"Open-source apps are self-serve when run locally with a loopback callback; no partner application is needed. Hosted apps on *.agent-native.com need operator approval and a hosted callback.",
|
|
1283
|
+
);
|
|
1284
|
+
expect(chatgpt.querySelector("a")).toBeNull();
|
|
1285
|
+
expect(buttons(chatgpt)).toEqual([]);
|
|
707
1286
|
});
|
|
708
1287
|
|
|
709
1288
|
it("saves Max iterations for admins and refuses a value out of range", async () => {
|