Add SaaS frontend code (#5879)

# Description of Changes
Adds the code for the SaaS frontend as proprietary code to the OSS repo.
This version of the code is adapted from 22/1/2026, which was the last
SaaS version based on the 'V2' design. This will move us closer to being
able to have the OSS products understand whether the user has a SaaS
account, and provide the correct UI in those cases.
This commit is contained in:
James Brunton
2026-03-11 11:53:54 +00:00
committed by GitHub
parent 8bc37bf5ae
commit fa8c52b2be
114 changed files with 12408 additions and 99 deletions
@@ -121,13 +121,11 @@ export const useToolOperation = <TParams>(
? config.endpoint(params)
: config.endpoint;
// Credit check for cloud operations (desktop SaaS mode only, no-op in web builds)
if (willUseCloud && endpoint) {
const creditError = await checkCredits();
if (creditError !== null) {
actions.setError(creditError);
return;
}
// Credit check — no-op in core builds, real check in desktop/SaaS versions
const creditError = await checkCredits();
if (creditError !== null) {
actions.setError(creditError);
return;
}
// Backend readiness check (will skip for SaaS-routed endpoints)
@@ -0,0 +1,6 @@
/**
* Core stub — config button uses the default settings icon.
*/
export function useConfigButtonIcon(): React.ReactNode {
return null;
}
@@ -0,0 +1,26 @@
import { useEffect } from 'react';
/**
* Core implementation: sets up the jwt-available event listener for OSS JWT auth,
* and detects auth pages where config fetch should be skipped.
*/
export function useJwtConfigSync(fetchConfig: (force?: boolean) => void): { isAuthPage: boolean } {
const currentPath = window.location.pathname;
const isAuthPage =
currentPath.includes('/login') ||
currentPath.includes('/signup') ||
currentPath.includes('/auth/callback') ||
currentPath.includes('/invite/');
useEffect(() => {
const handleJwtAvailable = () => {
console.debug('[AppConfig] JWT available event - refetching config');
fetchConfig(true);
};
window.addEventListener('jwt-available', handleJwtAvailable);
return () => window.removeEventListener('jwt-available', handleJwtAvailable);
}, [fetchConfig]);
return { isAuthPage };
}