feat: org switching
This commit is contained in:
parent
746d71324e
commit
e9e4c9dd91
4 changed files with 39 additions and 3 deletions
23
package-lock.json
generated
23
package-lock.json
generated
|
|
@ -44,6 +44,7 @@
|
|||
"posthog-node": "^5.6.0",
|
||||
"react": "^19.1.0",
|
||||
"readline-sync": "^1.4.10",
|
||||
"swr": "^2.3.4",
|
||||
"turndown": "^7.2.0",
|
||||
"typescript": "^5.8.3",
|
||||
"uuid": "^9.0.1",
|
||||
|
|
@ -17838,6 +17839,19 @@
|
|||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/swr": {
|
||||
"version": "2.3.4",
|
||||
"resolved": "https://registry.npmjs.org/swr/-/swr-2.3.4.tgz",
|
||||
"integrity": "sha512-bYd2lrhc+VarcpkgWclcUi92wYCpOgMws9Sd1hG1ntAu0NEy+14CbotuFjshBU2kt9rYj9TSmDcybpxpeTU1fg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"dequal": "^2.0.3",
|
||||
"use-sync-external-store": "^1.4.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^16.11.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/symbol-tree": {
|
||||
"version": "3.2.4",
|
||||
"resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz",
|
||||
|
|
@ -18537,6 +18551,15 @@
|
|||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/use-sync-external-store": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.5.0.tgz",
|
||||
"integrity": "sha512-Rb46I4cGGVBmjamjphe8L/UnvJD+uPPtTkNvX5mZgqdbavhI4EbgIWJiIHXJ8bc/i9EQGPRh4DwEURJ552Do0A==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/util-deprecate": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@
|
|||
"posthog-node": "^5.6.0",
|
||||
"react": "^19.1.0",
|
||||
"readline-sync": "^1.4.10",
|
||||
"swr": "^2.3.4",
|
||||
"turndown": "^7.2.0",
|
||||
"typescript": "^5.8.3",
|
||||
"uuid": "^9.0.1",
|
||||
|
|
|
|||
|
|
@ -5,7 +5,9 @@ import * as path from "path";
|
|||
import { Box, Text, useInput } from "ink";
|
||||
import open from "open";
|
||||
import React, { useState } from "react";
|
||||
import useSWR from "swr";
|
||||
|
||||
import { listUserOrganizations } from "../auth/workos.js";
|
||||
import { env } from "../env.js";
|
||||
import { isValidAnthropicApiKey, getApiKeyValidationError } from "../util/apiKeyValidation.js";
|
||||
import { updateAnthropicModelInYaml } from "../util/yamlConfigUpdater.js";
|
||||
|
|
@ -18,7 +20,6 @@ interface FreeTrialTransitionUIProps {
|
|||
onFullReload?: () => void;
|
||||
onShowConfigSelector?: () => void;
|
||||
onShowOrgSelector?: () => void;
|
||||
hasOrganizations?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -45,7 +46,6 @@ const FreeTrialTransitionUI: React.FC<FreeTrialTransitionUIProps> = ({
|
|||
onFullReload,
|
||||
onShowConfigSelector,
|
||||
onShowOrgSelector,
|
||||
hasOrganizations = false,
|
||||
}) => {
|
||||
const [currentStep, setCurrentStep] = useState<
|
||||
"choice" | "enterApiKey" | "processing" | "success" | "error"
|
||||
|
|
@ -55,6 +55,19 @@ const FreeTrialTransitionUI: React.FC<FreeTrialTransitionUIProps> = ({
|
|||
const [errorMessage, setErrorMessage] = useState("");
|
||||
const [successMessage, setSuccessMessage] = useState("");
|
||||
const [wasModelsSetup, setWasModelsSetup] = useState(false);
|
||||
|
||||
// Fetch organizations using SWR
|
||||
const { data: organizations } = useSWR(
|
||||
"organizations",
|
||||
listUserOrganizations,
|
||||
{
|
||||
revalidateOnFocus: false,
|
||||
revalidateOnReconnect: false,
|
||||
shouldRetryOnError: false,
|
||||
}
|
||||
);
|
||||
|
||||
const hasOrganizations = organizations && organizations.length > 0;
|
||||
|
||||
useInput((input, key) => {
|
||||
if (currentStep === "choice") {
|
||||
|
|
|
|||
|
|
@ -378,7 +378,6 @@ const TUIChat: React.FC<TUIChatProps> = ({
|
|||
onFullReload={handleFreeTrialFullReload}
|
||||
onShowConfigSelector={handleFreeTrialShowConfigSelector}
|
||||
onShowOrgSelector={handleFreeTrialShowOrgSelector}
|
||||
hasOrganizations={services?.auth?.hasOrganizations || false}
|
||||
/>
|
||||
)}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue