refactor: remove the billing tier model (P0.1)
The community edition has no monetization (ADR-0001). Remove the tier model (packages/shared/src/tiers.ts), the requireTier middleware and every tier gate, GET/PATCH /api/tier and the trial start, and the Stripe integration, which depends on the tier model. Personal features a tier used to limit are open to everyone: unlimited workspaces and connectors, every embedding provider including LiteLLM, per-workspace costs, Approvals. The workspace session cap is one constant (100). Team and enterprise surfaces are hidden instead of unlocked (team dock zone, Settings Team/Enterprise/Plan tabs, workspace Team tab); cloud sync reports unavailable, as it did for free users. The sidecar ignores the tier keys in config.json but does not delete them: both editions may still share ~/.waggle. Web billing UI is deleted: plan cards, upgrade and trial modals, payment success route, the KVARK sales block, tier 403 handling.
This commit is contained in:
@@ -4,9 +4,9 @@
|
||||
* Owns: BootScreen gate (FR #23 sequencing ported from the retired
|
||||
* pages/Index.tsx), the §3.3 window-state migration boot (one-shot, before the
|
||||
* first canvas render), onboarding takeover (§1.2 — wizard renders INSTEAD of
|
||||
* nav+canvas), left nav (same getDockForTier/filterByBillingTier data the dock
|
||||
* consumed, §1.3), StatusBar, global overlays (the old Desktop.tsx mount block
|
||||
* relocated), the `waggle:open-app` shim (§2.3), the keep-alive ChatHost
|
||||
* nav+canvas), left nav (same getDockForTier data the dock consumed, §1.3),
|
||||
* StatusBar, global overlays (the old Desktop.tsx mount block relocated),
|
||||
* the `waggle:open-app` shim (§2.3), the keep-alive ChatHost
|
||||
* (§4.2), and `<Outlet/>` as the single canvas.
|
||||
*
|
||||
* Stage C (the flip): this IS the live shell — App.tsx mounts it as the `/`
|
||||
@@ -23,7 +23,6 @@ import StatusBar from './StatusBar';
|
||||
import RouteTransition from './RouteTransition';
|
||||
import Sidebar, { type SidebarNavItem } from './Sidebar';
|
||||
import AppErrorBoundary from './ErrorBoundary';
|
||||
import UpgradeModal from './overlays/UpgradeModal';
|
||||
import { adapter } from '@/lib/adapter';
|
||||
import { stashDeepLink } from '@/lib/app-deeplink';
|
||||
import { writeLoginBriefingDismissed, writeLoginBriefingLastDismissedAt, readLoginBriefingDismissed, readSkipBriefingParam } from '@/lib/login-briefing';
|
||||
@@ -33,8 +32,7 @@ import { resolveReturningUserOnboarding, isOnboardingStatusKnownSync } from '@/h
|
||||
import { shouldShowCoachMarks, readOnboardedThisSession, readForceTour, clearForceTour } from '@/lib/coach-marks-gate';
|
||||
import { matchNavRoute, queryString, routeFor, routeForSearchResult } from '@/lib/routes';
|
||||
import { bootWindowStateMigration, indexLandingRoute } from '@/lib/window-state-migration';
|
||||
import { getDockForTier, BILLING_TIER_ORDER, type AppId, type DockEntry } from '@/lib/dock-tiers';
|
||||
import { TIER_LABELS } from '@waggle/shared';
|
||||
import { getDockForTier, type AppId, type DockEntry } from '@/lib/dock-tiers';
|
||||
import { buildCommandCatalog, type CatalogCommand } from '@/lib/command-catalog';
|
||||
import { ShellProvider, useShell } from '@/providers/ShellContext';
|
||||
import { seedChat, useChatWidgetState } from '@/hooks/useChatWidgetState';
|
||||
@@ -58,7 +56,6 @@ const OnboardingWizard = lazy(() => import('./overlays/OnboardingWizard'));
|
||||
const OnboardingTooltips = lazy(() => import('./overlays/OnboardingTooltips'));
|
||||
const LoginBriefing = lazy(() => import('./overlays/LoginBriefing'));
|
||||
const ContextRail = lazy(() => import('./overlays/ContextRail'));
|
||||
const TrialExpiredModal = lazy(() => import('./overlays/TrialExpiredModal'));
|
||||
|
||||
const deferredShellElement = (element: ReactNode) => (
|
||||
<Suspense fallback={null}>{element}</Suspense>
|
||||
@@ -74,7 +71,7 @@ const deferredShellElement = (element: ReactNode) => (
|
||||
*/
|
||||
const WORKSPACE_TAB_LABELS: Record<string, string> = {
|
||||
overview: 'Overview', chat: 'Chat', memory: 'Memory',
|
||||
artifacts: 'Artifacts', files: 'Files', team: 'Team', tasks: 'Tasks',
|
||||
artifacts: 'Artifacts', files: 'Files', tasks: 'Tasks',
|
||||
};
|
||||
|
||||
/** Flatten zone-parents so nav active-state/title lookups see every app entry. */
|
||||
@@ -124,7 +121,7 @@ const ShellLayout = () => {
|
||||
workspaces, activeWorkspace, activeWorkspaceId,
|
||||
selectWorkspace, createWorkspace, patchWorkspace, refreshWorkspaces, workspacesError,
|
||||
workspacesLoading,
|
||||
currentTier, billingTier, trialInfo, refreshTier, showTrialExpired, setShowTrialExpired,
|
||||
currentTier,
|
||||
notifications, unreadCount, markRead, markAllRead,
|
||||
onboardingState, updateOnboarding, completeOnboarding,
|
||||
offline, agentStatus,
|
||||
@@ -197,9 +194,6 @@ const ShellLayout = () => {
|
||||
// call can race the session-token attach and 401 → name:null. Falls back to
|
||||
// "Account" in the row when unconfigured.
|
||||
const [userName, setUserName] = useState<string | null>(null);
|
||||
// F5: the UpgradeModal self-opens on a window event, so the shell can't see
|
||||
// its open state without this. Feeds `anyModalOpen` so coach-marks hide under it.
|
||||
const [upgradeOpen, setUpgradeOpen] = useState(false);
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
const loadIdentity = () => {
|
||||
@@ -299,10 +293,7 @@ const ShellLayout = () => {
|
||||
// Onboarding completion handlers (relocated from Desktop.tsx:290-313).
|
||||
const handleOnboardingComplete = useCallback((_serverBaseUrl: string) => {
|
||||
completeOnboarding();
|
||||
// Atomic start. 409 (trial already started) is fine — refresh state
|
||||
// either way so the StatusBar countdown picks up the existing timestamp.
|
||||
adapter.startTrial().then(refreshTier).catch(refreshTier);
|
||||
}, [completeOnboarding, refreshTier]);
|
||||
}, [completeOnboarding]);
|
||||
|
||||
const handleOnboardingFinish = useCallback((workspaceId: string, workspaceName: string, firstMessage?: string, personaId?: string) => {
|
||||
selectWorkspace(workspaceId);
|
||||
@@ -332,7 +323,7 @@ const ShellLayout = () => {
|
||||
// everything else lives one keystroke away in ⌘K. The StatusBar breadcrumb
|
||||
// still derives from the full dock route table — every route is now reachable
|
||||
// via ⌘K regardless of tier, so the label map must cover them all.
|
||||
const labelEntries = useMemo(() => flattenAppEntries(getDockForTier('power', billingTier)), [billingTier]);
|
||||
const labelEntries = useMemo(() => flattenAppEntries(getDockForTier('power')), []);
|
||||
const activeRoute = useMemo(
|
||||
() => matchNavRoute(location.pathname, labelEntries.map(e => e.route).filter((r): r is string => !!r)),
|
||||
[location.pathname, labelEntries],
|
||||
@@ -385,7 +376,6 @@ const ShellLayout = () => {
|
||||
// Agents & tasks badge surfaces unacknowledged coordination signals for now;
|
||||
// PR3 refines it to the real pending-approvals/tasks count.
|
||||
const isPro = currentTier === 'power' || currentTier === 'admin';
|
||||
const billingRank = BILLING_TIER_ORDER[billingTier] ?? 0;
|
||||
const spine: SidebarNavItem[] = useMemo(() => [
|
||||
{ key: 'home', label: 'Home', icon: Home, to: '/home', match: ['/home'] },
|
||||
// Chat resolves to the active workspace's chat tab; with no real workspace,
|
||||
@@ -407,27 +397,17 @@ const ShellLayout = () => {
|
||||
], [effectiveActiveWorkspaceId, navigateToActiveChat, waggleUnacknowledged]);
|
||||
const pinned: SidebarNavItem[] = useMemo(() => {
|
||||
if (!isPro) return [];
|
||||
const items: SidebarNavItem[] = [
|
||||
return [
|
||||
{ key: 'swarm', label: 'Agent swarm', icon: Network, to: '/waggle-dance', match: ['/waggle-dance'] },
|
||||
{ key: 'connectors', label: 'Connectors', icon: Plug, to: '/connectors', match: ['/connectors'] },
|
||||
{ key: 'approvals', label: 'Approvals', icon: Shield, to: '/approvals', match: ['/approvals'] },
|
||||
];
|
||||
// Approvals is a TEAMS-tier surface (parity with dock-tiers minBillingTier).
|
||||
if (billingRank >= BILLING_TIER_ORDER.TEAMS) items.push({ key: 'approvals', label: 'Approvals', icon: Shield, to: '/approvals', match: ['/approvals'] });
|
||||
return items;
|
||||
}, [isPro, billingRank]);
|
||||
|
||||
// Plan label for the user row (e.g. "Trial · 9d", "Solo", "Team").
|
||||
const tierLabel = useMemo(() => {
|
||||
if (billingTier === 'TRIAL' || (trialInfo.trialDaysRemaining > 0 && !trialInfo.trialExpired)) {
|
||||
return trialInfo.trialDaysRemaining > 0 ? `Trial · ${trialInfo.trialDaysRemaining}d` : 'Trial';
|
||||
}
|
||||
return TIER_LABELS[billingTier];
|
||||
}, [billingTier, trialInfo.trialDaysRemaining, trialInfo.trialExpired]);
|
||||
}, [isPro]);
|
||||
|
||||
// ⌘K curated catalog (Jump to / Do / Power tools + Pro "Pinned") → real routes.
|
||||
const commandCatalog = useMemo(
|
||||
() => buildCommandCatalog({ chatHref: routeFor('chat', { activeWorkspaceId: effectiveActiveWorkspaceId }), isPro, billingRank }),
|
||||
[effectiveActiveWorkspaceId, isPro, billingRank],
|
||||
() => buildCommandCatalog({ chatHref: routeFor('chat', { activeWorkspaceId: effectiveActiveWorkspaceId }), isPro }),
|
||||
[effectiveActiveWorkspaceId, isPro],
|
||||
);
|
||||
const handleCatalogSelect = useCallback((cmd: CatalogCommand) => {
|
||||
if (cmd.action === 'spawn') { ov.setShowSpawnAgent(true); return; }
|
||||
@@ -455,12 +435,11 @@ const ShellLayout = () => {
|
||||
}
|
||||
|
||||
// F5: any shell overlay open ⇒ suppress the coach-mark carousel (hide-but-keep
|
||||
// tour state, per OnboardingTooltips' `suppressed` contract). Includes the
|
||||
// event-driven UpgradeModal (via upgradeOpen) and the trial paywall.
|
||||
// tour state, per OnboardingTooltips' `suppressed` contract).
|
||||
const anyModalOpen =
|
||||
ov.showGlobalSearch || ov.showCreateWorkspace || ov.showPersonaSwitcher ||
|
||||
ov.showWorkspaceSwitcher || ov.showNotifications || ov.showKeyboardHelp ||
|
||||
ov.showSpawnAgent || showTrialExpired || upgradeOpen;
|
||||
ov.showSpawnAgent;
|
||||
|
||||
return (
|
||||
<div className="relative w-screen h-screen overflow-hidden select-none">
|
||||
@@ -475,7 +454,6 @@ const ShellLayout = () => {
|
||||
model={effectiveActiveWorkspace?.model ?? (agentStatus.model !== 'unknown' ? agentStatus.model : undefined)}
|
||||
tokensUsed={agentStatus.tokensUsed} costUsd={agentStatus.costUsd} offline={offline}
|
||||
unreadNotifications={unreadCount}
|
||||
trialDaysRemaining={trialInfo.trialDaysRemaining} trialExpired={trialInfo.trialExpired}
|
||||
onSearchClick={() => ov.setShowGlobalSearch(true)} onNotificationClick={ov.toggleNotifications} />
|
||||
|
||||
<div className="absolute inset-x-0 top-8 bottom-0 flex">
|
||||
@@ -489,7 +467,6 @@ const ShellLayout = () => {
|
||||
onOpenCommand={() => ov.setShowGlobalSearch(true)}
|
||||
onSpawnAgent={() => ov.setShowSpawnAgent(true)}
|
||||
userName={userName}
|
||||
tierLabel={tierLabel}
|
||||
/>
|
||||
|
||||
{/* Single canvas (§2.1 rule 1). Route wrappers bring their own
|
||||
@@ -616,38 +593,6 @@ const ShellLayout = () => {
|
||||
{contextRailTarget && deferredShellElement(
|
||||
<ContextRail target={contextRailTarget} onClose={() => setContextRailTarget(null)} />
|
||||
)}
|
||||
|
||||
<UpgradeModal
|
||||
onOpenChange={setUpgradeOpen}
|
||||
onStartTrial={() => {
|
||||
adapter.startTrial().then(refreshTier).catch(refreshTier);
|
||||
}}
|
||||
onUpgrade={(tier) => {
|
||||
// PR7a: navigate to hosted Stripe Checkout (the URL was previously
|
||||
// discarded — a dead happy path). Same-tab assign rather than a deferred
|
||||
// window.open: the open happens after an awaited round-trip, outside the
|
||||
// user-gesture window, so a popup blocker / Tauri WebView could swallow it.
|
||||
// Hosted Checkout redirects back to /payment-success on completion.
|
||||
adapter.createCheckoutSession(tier)
|
||||
.then(({ url }) => { if (url) window.location.assign(url); })
|
||||
.catch(() => { navigate('/settings?tab=billing'); });
|
||||
}}
|
||||
/>
|
||||
|
||||
{showTrialExpired && deferredShellElement(
|
||||
<TrialExpiredModal
|
||||
open
|
||||
onDismiss={() => setShowTrialExpired(false)}
|
||||
onUpgrade={(tier) => {
|
||||
setShowTrialExpired(false);
|
||||
// PR7a: same-tab navigate to hosted Checkout (avoids the deferred-popup
|
||||
// blocker; redirects back to /payment-success). Plan-tab fallback on failure.
|
||||
adapter.createCheckoutSession(tier)
|
||||
.then(({ url }) => { if (url) window.location.assign(url); })
|
||||
.catch(() => { navigate('/settings?tab=billing'); });
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user