Skip to content

Open source CapCut alternative.

TypeScript

feat(site): surface an out-of-credits notice in the prototype notch

David Lea96a9c793e8a
diff --git a/site/src/app/prototype/_components/App.tsx b/site/src/app/prototype/_components/App.tsx
index 46e29be7..ea287cda 100644
--- a/site/src/app/prototype/_components/App.tsx
+++ b/site/src/app/prototype/_components/App.tsx
@@ -29,6 +29,8 @@ export default function App() {
// App-update notification is detected once on launch; the prototype seeds it on.
const [updateAvailable, setUpdateAvailable] = useState(true);
const [missingPermissions, setMissingPermissions] = useState(false);
+ // Out of credits gates the notch into a reload call-to-action; the prototype seeds it off.
+ const [outOfCredits, setOutOfCredits] = useState(false);
// Logged out gates the notch into a login call-to-action; the prototype seeds it off.
const [loggedOut, setLoggedOut] = useState(false);
const [liveTasks, setLiveTasks] = useState<LiveTask[]>(INITIAL_LIVE_TASKS);
@@ -265,6 +267,8 @@ export default function App() {
onRestart={() => setUpdateAvailable(false)}
missingPermissions={missingPermissions}
onReviewPermissions={() => setMissingPermissions(false)}
+ outOfCredits={outOfCredits}
+ onReloadCredits={() => setOutOfCredits(false)}
notchExpanded={isNotchExpanded}
setNotchExpanded={setNotchExpanded}
composerVisible={composerVisible}
@@ -293,6 +297,8 @@ export default function App() {
setUpdateAvailable={setUpdateAvailable}
missingPermissions={missingPermissions}
setMissingPermissions={setMissingPermissions}
+ outOfCredits={outOfCredits}
+ setOutOfCredits={setOutOfCredits}
loggedOut={loggedOut}
setLoggedOut={setLoggedOut}
activeTaskId={activeTaskId}
diff --git a/site/src/app/prototype/_components/DemoControls.tsx b/site/src/app/prototype/_components/DemoControls.tsx
index e154e707..1a5b207e 100644
--- a/site/src/app/prototype/_components/DemoControls.tsx
+++ b/site/src/app/prototype/_components/DemoControls.tsx
@@ -14,6 +14,8 @@ type Props = {
setUpdateAvailable: (available: boolean) => void;
missingPermissions: boolean;
setMissingPermissions: (missing: boolean) => void;
+ outOfCredits: boolean;
+ setOutOfCredits: (out: boolean) => void;
activeTaskId: TaskId;
setActiveTaskId: (id: TaskId) => void;
onTriggerAuthError: () => void;
@@ -49,6 +51,8 @@ export function DemoControls({
setUpdateAvailable,
missingPermissions,
setMissingPermissions,
+ outOfCredits,
+ setOutOfCredits,
activeTaskId,
setActiveTaskId,
onTriggerAuthError,
@@ -58,6 +62,7 @@ export function DemoControls({
const [notificationsOpen, setNotificationsOpen] = useState(false);
const notifications = [
+ { label: 'Out of Credits', on: outOfCredits, toggle: () => setOutOfCredits(!outOfCredits) },
{ label: 'Update Available', on: updateAvailable, toggle: () => setUpdateAvailable(!updateAvailable) },
{ label: 'Missing Permissions', on: missingPermissions, toggle: () => setMissingPermissions(!missingPermissions) },
];
diff --git a/site/src/app/prototype/_components/MacDesktop.tsx b/site/src/app/prototype/_components/MacDesktop.tsx
index 8cd947e2..b98c8524 100644
--- a/site/src/app/prototype/_components/MacDesktop.tsx
+++ b/site/src/app/prototype/_components/MacDesktop.tsx
@@ -11,6 +11,8 @@ type Props = {
onRestart: () => void;
missingPermissions: boolean;
onReviewPermissions: () => void;
+ outOfCredits: boolean;
+ onReloadCredits: () => void;
notchExpanded: boolean;
setNotchExpanded: (expanded: boolean) => void;
composerVisible: boolean;
@@ -51,6 +53,8 @@ export function MacDesktop({
onRestart,
missingPermissions,
onReviewPermissions,
+ outOfCredits,
+ onReloadCredits,
notchExpanded,
setNotchExpanded,
composerVisible,
@@ -115,6 +119,8 @@ export function MacDesktop({
onRestart={onRestart}
missingPermissions={missingPermissions}
onReviewPermissions={onReviewPermissions}
+ outOfCredits={outOfCredits}
+ onReloadCredits={onReloadCredits}
expanded={notchExpanded}
setExpanded={setNotchExpanded}
liveTasks={liveTasks}
diff --git a/site/src/app/prototype/_components/Notch.tsx b/site/src/app/prototype/_components/Notch.tsx
index 8673e928..d4004291 100644
--- a/site/src/app/prototype/_components/Notch.tsx
+++ b/site/src/app/prototype/_components/Notch.tsx
@@ -1,4 +1,4 @@
-import { ArrowUp, CloudSync, MessageCircleWarning, Shield } from 'lucide-react';
+import { ArrowUp, CloudSync, Coins, MessageCircleWarning, Shield } from 'lucide-react';
import { type FormEvent, type KeyboardEvent, useEffect, useLayoutEffect, useRef, useState } from 'react';
import { DonkeyCursor } from '@/app/prototype/_components/DonkeyCursor';
@@ -13,6 +13,8 @@ type Props = {
onRestart: () => void;
missingPermissions: boolean;
onReviewPermissions: () => void;
+ outOfCredits: boolean;
+ onReloadCredits: () => void;
expanded: boolean;
setExpanded: (expanded: boolean) => void;
liveTasks: LiveTask[];
@@ -99,6 +101,8 @@ export function Notch({
onRestart,
missingPermissions,
onReviewPermissions,
+ outOfCredits,
+ onReloadCredits,
expanded,
setExpanded,
liveTasks,
@@ -162,12 +166,22 @@ export function Notch({
}, [message]);
const chinHeight = METRICS.chinBaseHeight + (chinLines - 1) * METRICS.chinLineHeight;
- // App-level notices share a single slot; permissions outranks update since it blocks functionality.
- const appNotice: 'permissions' | 'update' | null = missingPermissions
- ? 'permissions'
- : updateAvailable
- ? 'update'
- : null;
+ // App-level notices share a single slot. Out of credits outranks everything — nothing can run
+ // without a balance; permissions then outranks an update since it blocks functionality.
+ const appNotice: 'credits' | 'permissions' | 'update' | null = outOfCredits
+ ? 'credits'
+ : missingPermissions
+ ? 'permissions'
+ : updateAvailable
+ ? 'update'
+ : null;
+ // Each notice's collapsed glyph and expanded label + CTA. Out of credits points the user to reload.
+ const noticeContent = {
+ credits: { Icon: Coins, label: 'Out of Credits', action: 'Reload', onAction: onReloadCredits },
+ permissions: { Icon: Shield, label: 'Missing Permissions', action: 'Review', onAction: onReviewPermissions },
+ update: { Icon: CloudSync, label: 'Update Available', action: 'Restart', onAction: onRestart },
+ } as const;
+ const notice = appNotice ? noticeContent[appNotice] : null;
const showChin = variant === 'real' && message !== '';
const isSimulatedExpandedMessage = variant === 'simulated' && message !== '';
@@ -478,17 +492,13 @@ export function Notch({
>
{collapsedTime}
</div>
- ) : appNotice ? (
- // Shield = missing permissions; cloud-sync = app update available (detected on launch).
+ ) : notice ? (
+ // Coins = out of credits; shield = missing permissions; cloud-sync = app update available.
<div
className="absolute right-0 top-0 grid place-items-center text-white/[0.85]"
style={{ width: METRICS.contentAreaWidth, height: contentRowHeight }}
>
- {appNotice === 'permissions' ? (
- <Shield size={15} strokeWidth={1.9} />
- ) : (
- <CloudSync size={15} strokeWidth={1.9} />
- )}
+ <notice.Icon size={15} strokeWidth={1.9} />
</div>
) : null}
@@ -546,8 +556,9 @@ export function Notch({
)}
</div>
- {/* Expanded right gutter — the only content on the notch row: an app-level action (update / permissions). */}
- {appNotice && (
+ {/* Expanded right gutter — the only content on the notch row: an app-level action (reload
+ credits / review permissions / restart to update). */}
+ {notice && (
<div
className="absolute right-0 top-0 z-10 flex items-center justify-end gap-2"
style={{
@@ -558,15 +569,13 @@ export function Notch({
transition: expanded ? 'opacity 300ms ease-out 150ms' : 'opacity 100ms ease-out',
}}
>
- <span className="whitespace-nowrap text-[11px] leading-none text-white/[0.7]">
- {appNotice === 'permissions' ? 'Missing Permissions' : 'Update Available'}
- </span>
+ <span className="whitespace-nowrap text-[11px] leading-none text-white/[0.7]">{notice.label}</span>
<button
type="button"
- onClick={appNotice === 'permissions' ? onReviewPermissions : onRestart}
+ onClick={notice.onAction}
className="flex items-center rounded bg-white px-2 py-1 text-[11px] font-medium leading-none text-black/[0.82] transition hover:bg-white/[0.92]"
>
- {appNotice === 'permissions' ? 'Review' : 'Restart'}
+ {notice.action}
</button>
</div>
)}