Files
zeekay 82120531a1 fix(debrand): read the TypeScript import graph before dropping a product
drop_closure exists to refuse a drop that is really a refactor: if code we
keep still imports a product, deleting it is a ModuleNotFoundError waiting
for the next boot. It only ever read Python, so half the dependency graph was
invisible to it and five products whose TypeScript the core still imports were
dropped anyway — 21 files left importing 25 specifiers that resolve to
nothing, including lib/api.ts, which 760 files import, and seven lazy scene
imports in productScenes.tsx.

Django booted past it and the bundle did not, which is why the Python-only
rule looked like it was working.

The closure now reads both module systems through one table of
(extensions, pattern) pairs, so a third one is a row rather than a branch. The
TypeScript pattern is anchored on the import keyword rather than on the path,
because jest's testPathIgnorePatterns and oxlint's ignore list quote a product
path precisely because it is NOT built; matching those would hold desktop, the
4,797-file product the drop is mostly for.

integrations, wizard, platform_features, visual_review and ai_gateway come
back with their Django apps and workspace entries, since the closure now
spares them. desktop, field_notes, ingestion and support stay dropped.
2026-08-01 22:17:05 -07:00

81 lines
3.0 KiB
TypeScript

import { useActions, useValues } from 'kea'
import { Banner, Button, Input, Modal, Tag } from '@hanzo/elements'
import { humanFriendlyCurrency } from 'lib/utils/numbers'
import { aiGatewayLogic } from './aiGatewayLogic'
const TOP_UP_PRESETS_USD = [25, 50, 100, 250]
// The gateway has no balance endpoint yet (products/ai_gateway/backend/routes.py is an empty
// stub), so the balance is shown as a Preview placeholder until that lands.
export function GatewayBalanceCard(): JSX.Element {
const { openTopUpModal } = useActions(aiGatewayLogic)
return (
<div className="border rounded p-4 min-w-48 flex-1 flex items-center justify-between gap-4">
<div>
<div className="text-secondary text-xs uppercase flex items-center gap-1.5">
Balance
<Tag type="warning">Preview</Tag>
</div>
<div className="text-2xl font-semibold">—</div>
</div>
<Button type="primary" onClick={openTopUpModal}>
Top up
</Button>
</div>
)
}
export function GatewayTopUpModal(): JSX.Element {
const { isTopUpModalOpen, topUpAmountUsd } = useValues(aiGatewayLogic)
const { closeTopUpModal, setTopUpAmount, confirmTopUp } = useActions(aiGatewayLogic)
return (
<Modal
isOpen={isTopUpModalOpen}
onClose={closeTopUpModal}
title="Top up balance"
description="Add funds to cover gateway usage — you're billed at cost, no markup on tokens."
footer={
<>
<Button type="secondary" onClick={closeTopUpModal}>
Cancel
</Button>
<Button
type="primary"
onClick={confirmTopUp}
disabledReason={topUpAmountUsd <= 0 ? 'Enter an amount' : undefined}
>
Top up {humanFriendlyCurrency(topUpAmountUsd)}
</Button>
</>
}
>
<div className="flex flex-col gap-3 max-w-md">
<Banner type="info">Preview only — billing isn't wired up yet.</Banner>
<div className="flex gap-2 flex-wrap">
{TOP_UP_PRESETS_USD.map((amount) => (
<Button
key={amount}
type={topUpAmountUsd === amount ? 'primary' : 'secondary'}
onClick={() => setTopUpAmount(amount)}
>
{humanFriendlyCurrency(amount, 0)}
</Button>
))}
</div>
<Input
type="number"
value={topUpAmountUsd}
onChange={(value) => setTopUpAmount(value ?? 0)}
prefix={<span className="text-secondary">$</span>}
min={0}
/>
</div>
</Modal>
)
}