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:
shumeiko.it
2026-10-15 19:31:50 +02:00
parent 369d8269c1
commit fe2eb0f648
117 changed files with 342 additions and 6424 deletions

View File

@@ -505,9 +505,6 @@ const CommandCenter = ({ open, onClose, onNavigate, onExecute, workspaceId, cata
if (res.ok) {
toast({ title: 'Done', description: action.label });
onClose();
} else if (res.status === 403) {
// The global adapter handler already raised the UpgradeModal — just close.
onClose();
} else {
toast({ title: 'Action failed', description: action.label, variant: 'destructive' });
}
@@ -521,13 +518,6 @@ const CommandCenter = ({ open, onClose, onNavigate, onExecute, workspaceId, cata
// ── Tier 1: dispatch a resolved intent onto the existing execution paths. ──
const handleResolvedAction = useCallback((res: InterpretResult) => {
if (res.kind === 'tier_gated') {
window.dispatchEvent(new CustomEvent('waggle:tier-insufficient', {
detail: { required: res.requiredTier, actual: res.actualTier, message: res.message },
}));
onClose();
return;
}
if (res.kind !== 'action' || !res.action) return;
const action = res.action;
if (action.navigate) {
@@ -636,7 +626,7 @@ const CommandCenter = ({ open, onClose, onNavigate, onExecute, workspaceId, cata
{/* ── Tier 1: Ask Waggle (NL intent) — sits above Tier 0 results,
never replacing them. Renders interpreting / resolved action /
clarify / upgrade / decline. ── */}
clarify / decline. ── */}
{(interpreting || interpret) && (
<CommandGroup
heading={
@@ -656,27 +646,6 @@ const CommandCenter = ({ open, onClose, onNavigate, onExecute, workspaceId, cata
<ResultRow result={actionToResult(interpret.action)} onSelect={() => handleResolvedAction(interpret)} />
)}
{!interpreting && interpret?.kind === 'tier_gated' && (
<CommandItem
value="__intent_tier__"
onSelect={() => handleResolvedAction(interpret)}
className="flex items-center gap-3 rounded-lg px-3 py-2 text-sm aria-selected:bg-[var(--honey-glow,rgba(229,160,0,0.08))]"
>
<Sparkles className="h-4 w-4 shrink-0" style={{ color: 'var(--honey-500)' }} />
<div className="min-w-0 flex-1 text-left">
<span className="block truncate font-display" style={{ color: 'var(--hive-100)' }}>
Upgrade to {interpret.requiredTier} to do this
</span>
<span className="block truncate text-xs" style={{ color: 'var(--hive-400)' }}>
{interpret.capability}
</span>
</div>
<span className="shrink-0 rounded-full px-1.5 py-0.5 text-[10px]" style={{ backgroundColor: 'rgba(167,139,250,0.15)', color: '#a78bfa' }}>
{interpret.requiredTier}
</span>
</CommandItem>
)}
{!interpreting && interpret?.kind === 'clarify' && (
<div className="px-3 py-2" data-testid="intent-clarify">
<p className="mb-2 text-sm" style={{ color: 'var(--hive-100)' }}>{interpret.question}</p>

View File

@@ -13,13 +13,10 @@ import { PERSONAS } from '@/lib/personas';
import { motion, AnimatePresence, useDragControls } from 'framer-motion';
import { adapter } from '@/lib/adapter';
import { useWorkspaces } from '@/hooks/useWorkspaces';
import { useShell } from '@/providers/ShellContext';
import { canCreateWorkspaceAtTier } from '@/lib/workspace-limit';
import LockedFeature from '@/components/os/LockedFeature';
import { buildBreadcrumbs } from '@/lib/browse-breadcrumbs';
import { useFocusTrap } from '@/hooks/useFocusTrap';
import type { StorageType, WorkspaceTemplate, TemplateCategory } from '@/lib/types';
import { TIER_CAPABILITIES, type ConnectorDefinition } from '@waggle/shared';
import type { ConnectorDefinition } from '@waggle/shared';
/** Use native OS folder picker when running inside Tauri, falls back to custom browse modal. */
async function pickFolderNative(): Promise<string | null> {
@@ -729,12 +726,6 @@ function TemplateCreatorModal({ open, onClose, onCreated, availableConnectors, e
const CreateWorkspaceDialog = ({ open, onClose, onCreate }: CreateWorkspaceDialogProps) => {
const { workspaces } = useWorkspaces();
const { billingTier } = useShell();
// Gate off the SAME canonical rule the server enforces (tiers.ts
// workspaceLimit), not the retired onboarding-complexity flag that blocked
// Solo at workspace #2 while the backend would have allowed unlimited. Client
// and server now agree by construction.
const canCreateWorkspace = canCreateWorkspaceAtTier(billingTier, workspaces.length);
const [name, setName] = useState('');
const [group, setGroup] = useState('Personal');
@@ -856,28 +847,6 @@ const CreateWorkspaceDialog = ({ open, onClose, onCreate }: CreateWorkspaceDialo
if (!open) return null;
if (!canCreateWorkspace) {
return (
<AnimatePresence>
<motion.div initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }}
className="fixed inset-0 z-[100] flex items-center justify-center" onClick={onClose}>
<div className="absolute inset-0 bg-black/50 backdrop-blur-sm" />
<motion.div initial={{ opacity: 0, scale: 0.95 }} animate={{ opacity: 1, scale: 1 }}
exit={{ opacity: 0, scale: 0.95 }}
className="relative w-full max-w-sm glass-strong rounded-2xl shadow-2xl overflow-hidden"
onClick={e => e.stopPropagation()}>
<div className="p-6">
{/* The gate now matches the server (tiers.ts workspaceLimit), so
the count is finally safe to quote: this paywall only fires once
a FREE user has actually reached the limit. */}
<LockedFeature featureName="Multiple Workspaces" upgradePrompt={`Upgrade for unlimited workspaces. The Free plan includes ${TIER_CAPABILITIES.FREE.workspaceLimit}.`} />
</div>
</motion.div>
</motion.div>
</AnimatePresence>
);
}
const virtualPath = defaultVirtualPath(name);
// Non-blocking dup-name warning: two "Research Hub"s are indistinguishable in

View File

@@ -1,129 +0,0 @@
import { motion, AnimatePresence } from 'framer-motion';
import { Crown, Users, Check, X, ArrowRight } from 'lucide-react';
import { useFocusTrap } from '@/hooks/useFocusTrap';
interface TrialExpiredModalProps {
open: boolean;
onDismiss: () => void;
onUpgrade: (tier: 'TEAMS') => void;
}
// Solo (free) keeps every personal capability — the trial only ever gated the
// collaboration/governance layer, so those are the only things "lost".
const KEEP_FEATURES = [
'Memory & Harvest — unlimited, forever',
'Unlimited workspaces & connectors',
'Marketplace skills & connectors',
'Self-evolving skills',
'All built-in agents',
'PDF & advanced exports',
];
const LOSE_FEATURES = [
'Shared team workspaces',
'Sync across devices',
'Team skill library',
'Team governance & audit',
'SSO & role-based access',
];
export default function TrialExpiredModal({ open, onDismiss, onUpgrade }: TrialExpiredModalProps) {
// A11y (WCAG 2.1.1/2.4.3): Escape closes, Tab is trapped, focus moves in on
// open and restores on close. Replaces the prior Escape-only handler.
const dialogRef = useFocusTrap<HTMLDivElement>(open, onDismiss);
return (
<AnimatePresence>
{open && (
<motion.div
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
className="fixed inset-0 z-[210] flex items-center justify-center"
>
<div className="absolute inset-0 bg-black/60 backdrop-blur-sm" aria-hidden="true" />
<motion.div
ref={dialogRef}
initial={{ opacity: 0, scale: 0.95, y: 16 }}
animate={{ opacity: 1, scale: 1, y: 0 }}
exit={{ opacity: 0, scale: 0.95, y: 16 }}
transition={{ type: 'spring', damping: 25, stiffness: 300 }}
role="dialog"
aria-modal="true"
aria-labelledby="trial-expired-title"
tabIndex={-1}
className="relative w-full max-w-lg glass-strong rounded-2xl shadow-2xl overflow-hidden focus:outline-none"
onClick={e => e.stopPropagation()}
>
<button
type="button"
onClick={onDismiss}
aria-label="Close trial expired dialog"
className="absolute top-4 right-4 p-1.5 rounded-lg text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors"
>
<X className="w-4 h-4" />
</button>
<div className="p-6 pb-2 text-center">
<div className="inline-flex p-3 rounded-2xl bg-primary/10 mb-4">
<Crown className="w-8 h-8 text-honey" />
</div>
<h2 id="trial-expired-title" className="text-xl font-display font-bold text-foreground">
Your 15-day trial has ended
</h2>
<p className="text-sm text-muted-foreground mt-2">
Upgrade to Team to keep the collaboration features you've been using, or continue free with Solo.
</p>
</div>
<div className="px-6 py-4 grid grid-cols-2 gap-4">
<div>
<h3 className="text-xs font-display font-semibold text-[var(--text-2)] uppercase tracking-wider mb-2">
You keep
</h3>
<ul className="space-y-1.5">
{KEEP_FEATURES.map(f => (
<li key={f} className="flex items-start gap-2 text-[13px] text-foreground">
<Check className="w-3.5 h-3.5 text-[var(--healthy)] mt-0.5 shrink-0" />
{f}
</li>
))}
</ul>
</div>
<div>
<h3 className="text-xs font-display font-semibold text-[var(--text-2)] uppercase tracking-wider mb-2">
You lose
</h3>
<ul className="space-y-1.5">
{LOSE_FEATURES.map(f => (
<li key={f} className="flex items-start gap-2 text-[13px] text-muted-foreground">
<X className="w-3.5 h-3.5 text-[var(--risk)] mt-0.5 shrink-0" />
{f}
</li>
))}
</ul>
</div>
</div>
<div className="px-6 pb-6 pt-2 space-y-2">
<button
onClick={() => onUpgrade('TEAMS')}
className="w-full flex items-center justify-center gap-2 px-4 py-3 rounded-xl bg-primary text-primary-foreground font-display text-sm font-semibold hover:bg-primary/90 transition-colors"
>
<Users className="w-4 h-4" />
Upgrade to Team — $49/seat/mo
<ArrowRight className="w-4 h-4" />
</button>
<button
onClick={onDismiss}
className="w-full px-4 py-2 text-center text-xs text-muted-foreground hover:text-foreground transition-colors"
>
Continue free with Solo
</button>
</div>
</motion.div>
</motion.div>
)}
</AnimatePresence>
);
}

View File

@@ -1,170 +0,0 @@
import { useState, useEffect, useCallback } from 'react';
import { motion, AnimatePresence } from 'framer-motion';
import { Zap, X, Check, Users } from 'lucide-react';
import { TIER_CAPABILITIES } from '@waggle/shared';
import { useFocusTrap } from '@/hooks/useFocusTrap';
interface TierEvent {
required: string;
actual: string;
message: string;
}
type CapKey = keyof typeof TIER_CAPABILITIES.FREE;
// Trimmed to the caps that DIFFER between Solo (free) and Team — an honest
// "what Team adds" comparison, not a full feature dump (decision 11). Every
// personal capability is already free on Solo, so it doesn't belong here.
const FEATURE_ROWS: Array<{ label: string; key: CapKey; format: (v: unknown) => string }> = [
{ label: 'Shared Workspaces', key: 'sharedWorkspaces', format: v => v ? 'Yes' : '—' },
{ label: 'Team Members', key: 'teamMembersLimit', format: v => (v as number) === -1 ? 'Unlimited' : String(v) },
{ label: 'Sync Across Devices', key: 'cloudSync', format: v => v ? 'Yes' : '—' },
{ label: 'Team Skill Library', key: 'teamSkillLibrary', format: v => v ? 'Yes' : '—' },
{ label: 'Team Governance', key: 'adminPanel', format: v => v ? 'Yes' : '—' },
{ label: 'Audit Log', key: 'auditLog', format: v => {
if (v === 'none') return '—';
return String(v).charAt(0).toUpperCase() + String(v).slice(1);
}},
];
function CellValue({ value, isBool }: { value: string; isBool: boolean }) {
if (value === 'Yes' && isBool) return <Check className="w-4 h-4 text-honey mx-auto" />;
if (value === '—') return <span className="text-muted-foreground/40">—</span>;
return <span className="text-foreground">{value}</span>;
}
interface UpgradeModalProps {
onStartTrial?: () => void;
onUpgrade?: (tier: 'TEAMS') => void;
/** F5: report open/close so the shell can suppress coach-marks while this
* event-driven modal (invisible to AppShell otherwise) is up. */
onOpenChange?: (open: boolean) => void;
}
export default function UpgradeModal({ onStartTrial, onUpgrade, onOpenChange }: UpgradeModalProps) {
const [event, setEvent] = useState<TierEvent | null>(null);
const handleTierInsufficient = useCallback((e: Event) => {
setEvent((e as CustomEvent<TierEvent>).detail);
onOpenChange?.(true);
}, [onOpenChange]);
useEffect(() => {
window.addEventListener('waggle:tier-insufficient', handleTierInsufficient);
return () => window.removeEventListener('waggle:tier-insufficient', handleTierInsufficient);
}, [handleTierInsufficient]);
const close = useCallback(() => { setEvent(null); onOpenChange?.(false); }, [onOpenChange]);
// A11y (WCAG 2.1.1/2.4.3): Escape closes, Tab is trapped within the dialog,
// focus moves in on open and restores on close. Replaces the prior hand-rolled
// Escape-only handler (no trap, no focus restore).
const dialogRef = useFocusTrap<HTMLDivElement>(!!event, close);
const free = TIER_CAPABILITIES.FREE;
const teams = TIER_CAPABILITIES.TEAMS;
return (
<AnimatePresence>
{event && (
<motion.div
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
className="fixed inset-0 z-[200] flex items-center justify-center"
onClick={close}
>
<div className="absolute inset-0 bg-black/50 backdrop-blur-sm" aria-hidden="true" />
<motion.div
ref={dialogRef}
initial={{ opacity: 0, scale: 0.95, y: 10 }}
animate={{ opacity: 1, scale: 1, y: 0 }}
exit={{ opacity: 0, scale: 0.95, y: 10 }}
role="dialog"
aria-modal="true"
aria-labelledby="upgrade-modal-title"
tabIndex={-1}
className="relative w-full max-w-2xl glass-strong rounded-2xl shadow-2xl overflow-hidden focus:outline-none"
onClick={e => e.stopPropagation()}
>
<button
type="button"
onClick={close}
aria-label="Close upgrade dialog"
className="absolute top-4 right-4 p-1.5 rounded-lg text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors"
>
<X className="w-4 h-4" />
</button>
<div className="p-6 pb-4">
<div className="flex items-center gap-3 mb-1">
<div className="p-2 rounded-xl bg-primary/10">
<Zap className="w-5 h-5 text-honey" />
</div>
<h2 id="upgrade-modal-title" className="text-lg font-display font-bold text-foreground">
Upgrade to unlock this feature
</h2>
</div>
<p className="text-sm text-muted-foreground mt-2">
{event.message}
</p>
</div>
<div className="px-6 pb-4">
<div className="rounded-xl border border-border/50 overflow-hidden">
<table className="w-full text-sm">
<thead>
<tr className="border-b border-border/50">
<th className="text-left p-3 text-muted-foreground font-medium">Feature</th>
<th className="text-center p-3 text-foreground font-medium w-28">Solo</th>
<th className="text-center p-3 font-medium w-28">
<span className="text-foreground flex items-center justify-center gap-1">
<Users className="w-3.5 h-3.5" /> Team
</span>
</th>
</tr>
</thead>
<tbody>
{FEATURE_ROWS.map(row => {
const freeVal = row.format(free[row.key]);
const teamsVal = row.format(teams[row.key]);
const isBool = typeof free[row.key] === 'boolean';
return (
<tr key={row.key} className="border-b border-border/30 last:border-0">
<td className="p-3 text-foreground">{row.label}</td>
<td className="p-3 text-center text-muted-foreground"><CellValue value={freeVal} isBool={isBool} /></td>
<td className="p-3 text-center"><CellValue value={teamsVal} isBool={isBool} /></td>
</tr>
);
})}
{/* Memory row — always free, hardcoded as marketing highlight */}
<tr className="border-b border-border/30 last:border-0">
<td className="p-3 text-foreground">Memory & Harvest</td>
<td className="p-3 text-center text-muted-foreground">Unlimited</td>
<td className="p-3 text-center"><span className="text-foreground">Unlimited</span></td>
</tr>
</tbody>
</table>
</div>
</div>
<div className="px-6 pb-6 flex items-center gap-3">
<button
onClick={() => { onStartTrial?.(); close(); }}
className="flex-1 px-4 py-2.5 rounded-xl border border-primary/30 text-honey font-display text-sm font-semibold hover:bg-primary/10 transition-colors"
>
Start 15-day Team trial
</button>
<button
onClick={() => { onUpgrade?.('TEAMS'); close(); }}
className="flex-1 px-4 py-2.5 rounded-xl bg-primary text-primary-foreground font-display text-sm font-semibold hover:bg-primary/90 transition-colors"
>
Upgrade to Team — $49/seat
</button>
</div>
</motion.div>
</motion.div>
)}
</AnimatePresence>
);
}

View File

@@ -135,11 +135,10 @@ export function getPersonasForTemplate(templateId: string): readonly OnboardingP
];
}
// QW-5: display labels renamed to avoid collision with billing tiers
// (billing uses "Pro $19/mo", "Teams $49/seat"). Dock tiers describe how
// many icons appear — they are UI layout, not billing. Internal enum
// values ('simple' / 'professional' / 'power') stay the same so stored
// user preferences keep working without migration.
// QW-5: display labels for the dock tiers. Dock tiers describe how many
// icons appear — they are UI layout. Internal enum values ('simple' /
// 'professional' / 'power') stay the same so stored user preferences keep
// working without migration.
export const TIER_OPTIONS: readonly TierOption[] = [
{
id: 'simple' as UserTier,