Skip to content

Open source CapCut alternative.

TypeScript

Align prototype pointer UI with Swift overlay

David Le17437a38defe
diff --git a/site/src/app/prototype/_components/ActivityBars.tsx b/site/src/app/prototype/_components/ActivityBars.tsx
index 8c2addda..a539547b 100644
--- a/site/src/app/prototype/_components/ActivityBars.tsx
+++ b/site/src/app/prototype/_components/ActivityBars.tsx
@@ -1,23 +1,20 @@
type Props = {
color?: string;
+ height?: number;
};
-export function ActivityBars({ color = '#fff' }: Props) {
+const BAR_SCALES = [0.44, 0.82, 0.58] as const;
+
+export function ActivityBars({ color = '#fff', height = 18 }: Props) {
return (
- <>
- <style>{`
- @keyframes ab1 { 0%,100%{height:7px;opacity:1} 50%{height:3px;opacity:0.5} }
- @keyframes ab2 { 0%,100%{height:4px;opacity:0.6} 50%{height:9px;opacity:1} }
- @keyframes ab3 { 0%,100%{height:9px;opacity:1} 50%{height:5px;opacity:0.7} }
- .ab1 { animation: ab1 1.1s ease-in-out infinite; }
- .ab2 { animation: ab2 1.1s ease-in-out infinite; }
- .ab3 { animation: ab3 1.1s ease-in-out infinite; }
- `}</style>
- <div className="flex gap-[2px] items-center flex-shrink-0">
- <div className="w-[2px] rounded-sm ab1" style={{ background: color }} />
- <div className="w-[2px] rounded-sm ab2" style={{ background: color }} />
- <div className="w-[2px] rounded-sm ab3" style={{ background: color }} />
- </div>
- </>
+ <div className="flex w-[18px] flex-shrink-0 items-center justify-center gap-[3px]" style={{ height }}>
+ {BAR_SCALES.map((scale) => (
+ <span
+ key={scale}
+ className="w-[3px] rounded-full"
+ style={{ height: height * scale, background: color }}
+ />
+ ))}
+ </div>
);
}
diff --git a/site/src/app/prototype/_components/App.tsx b/site/src/app/prototype/_components/App.tsx
index 8e527d98..ed8f53ad 100644
--- a/site/src/app/prototype/_components/App.tsx
+++ b/site/src/app/prototype/_components/App.tsx
@@ -9,6 +9,28 @@ import type { DesktopSize, NotchState, Spawn, SpawnPhase, TaskId } from '@/app/p
const COMPOSER_TEXT_MIN_HEIGHT = 19.2;
const COMPOSER_TEXT_MAX_HEIGHT = 134.4;
+const COLLAPSED_NOTCH_VISIBLE_HEIGHT = 32;
+const SPAWN_FALLBACK_VERTICAL_OFFSET = 250;
+const SPAWN_SCREEN_INSET = 36;
+const SPAWN_NOTCH_CUE_DURATION_MS = 260;
+const SPAWN_TRAVEL_DURATION_MS = 820;
+
+function clampedSpawnPoint(x: number, y: number, desktopSize: DesktopSize) {
+ return {
+ x: Math.min(Math.max(x, SPAWN_SCREEN_INSET), Math.max(SPAWN_SCREEN_INSET, desktopSize.w - SPAWN_SCREEN_INSET)),
+ y: Math.min(Math.max(y, SPAWN_SCREEN_INSET), Math.max(SPAWN_SCREEN_INSET, desktopSize.h - SPAWN_SCREEN_INSET)),
+ };
+}
+
+function fallbackSpawnTarget(desktopSize: DesktopSize, spawnIndex: number) {
+ const stagger = ((spawnIndex % 5) - 2) * 18;
+
+ return clampedSpawnPoint(
+ desktopSize.w / 2 + stagger,
+ COLLAPSED_NOTCH_VISIBLE_HEIGHT + SPAWN_FALLBACK_VERTICAL_OFFSET,
+ desktopSize,
+ );
+}
export default function App() {
const [state, setState] = useState<NotchState>('running-single');
@@ -17,6 +39,8 @@ export default function App() {
const [promptText, setPromptText] = useState('');
const [promptTextHeight, setPromptTextHeight] = useState(COMPOSER_TEXT_MIN_HEIGHT);
const [spawns, setSpawns] = useState<Spawn[]>([]);
+ const [selectedSpawnId, setSelectedSpawnId] = useState<string | null>(null);
+ const [editingSpawnId, setEditingSpawnId] = useState<string | null>(null);
const [desktopSize, setDesktopSize] = useState<DesktopSize>({ w: 1280, h: 720 });
const promptInputRef = useRef<HTMLTextAreaElement | null>(null);
const desktopRef = useRef<HTMLElement | null>(null);
@@ -72,32 +96,51 @@ export default function App() {
}, [advanceSpawn]);
const handleSpawn = useCallback((taskText: string) => {
+ const spawnIndex = spawnCounterRef.current;
spawnCounterRef.current += 1;
const id = `spawn-${spawnCounterRef.current}-${Date.now()}`;
- const color = TASK_COLORS[spawnCounterRef.current % TASK_COLORS.length];
- const label = taskText.slice(0, 40);
- const padding = 60;
- const targetX = padding + Math.random() * Math.max(1, desktopSize.w - padding * 2);
- const targetY = 90 + Math.random() * Math.max(1, desktopSize.h - 160);
- const curveSide = Math.random() > 0.5 ? 1 : -1;
+ const color = TASK_COLORS[spawnIndex % TASK_COLORS.length];
+ const target = fallbackSpawnTarget(desktopSize, spawnIndex);
setSpawns((current) => [
...current,
{
id,
+ taskId: id,
color,
- label,
- target: { x: targetX, y: targetY },
- phase: 'travel',
- curveSide,
+ label: taskText,
+ target,
+ phase: 'notch-cue',
+ notchCueAngleDegrees: 90,
startedAt: Date.now(),
},
]);
-
- scheduleSpawnPhase(id, 'shake-left', 900);
- scheduleSpawnPhase(id, 'shake-right', 1250);
- scheduleSpawnPhase(id, 'working', 1600);
- }, [desktopSize.h, desktopSize.w, scheduleSpawnPhase]);
+ setSelectedSpawnId(id);
+ setEditingSpawnId(null);
+
+ scheduleSpawnPhase(id, 'traveling', SPAWN_NOTCH_CUE_DURATION_MS);
+ scheduleSpawnPhase(id, 'holding', SPAWN_NOTCH_CUE_DURATION_MS + SPAWN_TRAVEL_DURATION_MS);
+ }, [desktopSize, scheduleSpawnPhase]);
+
+ const handleSpawnFollowUp = useCallback((spawnId: string, text: string) => {
+ const label = text.trim();
+ if (!label) return;
+
+ setSpawns((current) =>
+ current.map((spawn) =>
+ spawn.id === spawnId
+ ? {
+ ...spawn,
+ label,
+ phase: 'holding',
+ startedAt: Date.now(),
+ }
+ : spawn,
+ ),
+ );
+ setSelectedSpawnId(spawnId);
+ setEditingSpawnId(null);
+ }, []);
const handleSubmit = useCallback((event: FormEvent<HTMLFormElement>) => {
event.preventDefault();
@@ -128,6 +171,11 @@ export default function App() {
desktopRef={desktopRef}
desktopSize={desktopSize}
spawns={spawns}
+ selectedSpawnId={selectedSpawnId}
+ editingSpawnId={editingSpawnId}
+ setSelectedSpawnId={setSelectedSpawnId}
+ setEditingSpawnId={setEditingSpawnId}
+ onSpawnFollowUp={handleSpawnFollowUp}
onRequestSpawn={handleSpawn}
/>
<DemoControls
@@ -136,7 +184,11 @@ export default function App() {
activeTaskId={activeTaskId}
setActiveTaskId={setActiveTaskId}
spawnCount={spawns.length}
- onClearSpawns={() => setSpawns([])}
+ onClearSpawns={() => {
+ setSpawns([]);
+ setSelectedSpawnId(null);
+ setEditingSpawnId(null);
+ }}
/>
</div>
);
diff --git a/site/src/app/prototype/_components/DonkeyCursor.tsx b/site/src/app/prototype/_components/DonkeyCursor.tsx
index 8ad7ac10..48a80672 100644
--- a/site/src/app/prototype/_components/DonkeyCursor.tsx
+++ b/site/src/app/prototype/_components/DonkeyCursor.tsx
@@ -4,31 +4,25 @@ type Props = {
};
export function DonkeyCursor({ color, size = 28 }: Props) {
- // The SVG's natural tip is at (~83, 5) in its 100x100 viewBox space (upper-right).
- // We position the SVG so that tip lands at the container's (0,0). That way, when
- // this element is placed on an offset-path or rotated, the TIP is the anchor.
- const tipX = 83 * (size / 100);
- const tipY = 5 * (size / 100);
-
return (
- <div className="relative" style={{ width: 0, height: 0 }}>
+ <div className="relative" style={{ width: size, height: size }}>
<svg
- viewBox="-5 -10 110 135"
+ viewBox="0 0 100 100"
width={size}
height={size}
style={{
position: 'absolute',
- left: -tipX,
- top: -tipY,
- filter: 'drop-shadow(0 2px 4px rgba(0,0,0,0.4))',
+ left: 0,
+ top: 0,
+ filter: 'drop-shadow(0 2px 4px rgba(0,0,0,0.34))',
overflow: 'visible',
}}
>
<path
d="m83.086 5.6406-72.633 29.043c-7.6016 3.0391-7.1445 13.949 0.67969 16.344l24.562 7.5195c2.7539 0.84375 4.9102 3 5.7539 5.7539l7.5195 24.562c2.3984 7.8281 13.305 8.2812 16.344 0.67969l29.043-72.633c2.832-7.0781-4.1953-14.102-11.273-11.273z"
fill={color}
- stroke="white"
- strokeWidth="6"
+ stroke="rgba(255,255,255,0.92)"
+ strokeWidth="5.36"
strokeLinejoin="round"
/>
</svg>
diff --git a/site/src/app/prototype/_components/MacDesktop.tsx b/site/src/app/prototype/_components/MacDesktop.tsx
index 44a35a6c..11b2e34f 100644
--- a/site/src/app/prototype/_components/MacDesktop.tsx
+++ b/site/src/app/prototype/_components/MacDesktop.tsx
@@ -1,4 +1,5 @@
-import type { FormEvent, RefObject } from 'react';
+import { ArrowUp, Mic } from 'lucide-react';
+import type { FormEvent, PointerEvent, RefObject } from 'react';
import { Notch } from '@/app/prototype/_components/Notch';
import { SpawnedCursor } from '@/app/prototype/_components/SpawnedCursor';
@@ -18,6 +19,11 @@ type Props = {
desktopRef: RefObject<HTMLElement | null>;
desktopSize: DesktopSize;
spawns: Spawn[];
+ selectedSpawnId: string | null;
+ editingSpawnId: string | null;
+ setSelectedSpawnId: (id: string | null) => void;
+ setEditingSpawnId: (id: string | null) => void;
+ onSpawnFollowUp: (spawnId: string, text: string) => void;
onRequestSpawn: (taskText: string) => void;
};
@@ -30,10 +36,14 @@ const LAYOUT = {
composerCornerRadius: 22,
composerInputMinimumHeight: 66,
composerInputLeadingContentPadding: 20,
- composerInputTrailingContentPadding: 8,
+ composerInputTrailingContentPadding: 14.6,
composerWaveformWidth: 54,
composerWaveformHeight: 28,
- composerWrappingTextWidth: 482,
+ composerMicrophoneIconSize: 28,
+ composerSendButtonSize: 36.8,
+ composerTrailingControlsSpacing: 16,
+ composerTrailingControlsWidth: 80.8,
+ composerWrappingTextWidth: 449,
composerExpandedTextWidth: 528,
composerExpandedTextTopPadding: 18,
composerExpandedTextHorizontalPadding: 24,
@@ -41,12 +51,6 @@ const LAYOUT = {
composerExpandedMinimumHeight: 156,
} as const;
-const WAVEFORM_LEVELS = [0.12, 0.2, 0.34, 0.5, 0.34, 0.2, 0.12] as const;
-
-function waveformHeight(level: number) {
- return 5 + level * 24;
-}
-
export function MacDesktop({
state,
activeTaskId,
@@ -61,6 +65,11 @@ export function MacDesktop({
desktopRef,
desktopSize,
spawns,
+ selectedSpawnId,
+ editingSpawnId,
+ setSelectedSpawnId,
+ setEditingSpawnId,
+ onSpawnFollowUp,
onRequestSpawn,
}: Props) {
const composerHeight = promptExpanded
@@ -70,13 +79,25 @@ export function MacDesktop({
)
: LAYOUT.composerInputMinimumHeight;
const hostHeight = LAYOUT.stageVerticalPadding * 2 + composerHeight + LAYOUT.contentExtraHeight;
- const spawnOrigin = { x: desktopSize.w / 2, y: -36 };
+ const activeSpawnCue = [...spawns].reverse().find((spawn) => spawn.phase === 'notch-cue') ?? null;
+ const hasPromptText = promptText.trim().length > 0;
+
+ const handleDesktopPointerDown = (event: PointerEvent<HTMLElement>) => {
+ if (!editingSpawnId) return;
+
+ const target = event.target;
+ if (!(target instanceof Element)) return;
+ if (target.closest('[data-spawn-interactive="true"]')) return;
+
+ setEditingSpawnId(null);
+ };
return (
<main
ref={desktopRef}
className="relative min-h-screen overflow-hidden bg-[#121419] text-white"
style={{ fontFamily: '-apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif' }}
+ onPointerDown={handleDesktopPointerDown}
>
<div
className="absolute inset-0"
@@ -114,11 +135,26 @@ export function MacDesktop({
activeTaskId={activeTaskId}
expanded={notchExpanded}
setExpanded={setNotchExpanded}
+ spawnCue={activeSpawnCue}
onRequestSpawn={onRequestSpawn}
/>
- {spawns.map((spawn) => (
- <SpawnedCursor key={spawn.id} spawn={spawn} spawnOrigin={spawnOrigin} />
+ {spawns.map((spawn, index) => (
+ <SpawnedCursor
+ key={spawn.id}
+ spawn={spawn}
+ spawnOrigin={{ x: desktopSize.w / 2 + ((index % 5) - 2) * 18, y: -24 }}
+ desktopSize={desktopSize}
+ selected={selectedSpawnId === spawn.id}
+ editing={editingSpawnId === spawn.id}
+ onSelect={() => setSelectedSpawnId(spawn.id)}
+ onBeginEditing={() => {
+ setSelectedSpawnId(spawn.id);
+ setEditingSpawnId(spawn.id);
+ }}
+ onCancelEditing={() => setEditingSpawnId(null)}
+ onSubmitFollowUp={(text) => onSpawnFollowUp(spawn.id, text)}
+ />
))}
<section
@@ -175,26 +211,45 @@ export function MacDesktop({
}}
/>
<div
- className="absolute flex items-center justify-center gap-1"
+ className="absolute flex items-center justify-end"
style={{
right: promptExpanded
? LAYOUT.composerExpandedTextHorizontalPadding
: LAYOUT.composerInputTrailingContentPadding,
top: promptExpanded
- ? composerHeight - LAYOUT.composerExpandedToolbarHeight + (LAYOUT.composerExpandedToolbarHeight - LAYOUT.composerWaveformHeight) / 2
- : (LAYOUT.composerInputMinimumHeight - LAYOUT.composerWaveformHeight) / 2,
- width: LAYOUT.composerWaveformWidth,
- height: LAYOUT.composerWaveformHeight,
+ ? composerHeight - LAYOUT.composerExpandedToolbarHeight + (LAYOUT.composerExpandedToolbarHeight - LAYOUT.composerSendButtonSize) / 2
+ : (LAYOUT.composerInputMinimumHeight - LAYOUT.composerSendButtonSize) / 2,
+ width: LAYOUT.composerTrailingControlsWidth,
+ height: LAYOUT.composerSendButtonSize,
+ gap: LAYOUT.composerTrailingControlsSpacing,
}}
- aria-hidden="true"
>
- {WAVEFORM_LEVELS.map((level, index) => (
- <span
- key={`${level}-${index}`}
- className="w-1 rounded-full bg-white"
- style={{ height: waveformHeight(level) }}
- />
- ))}
+ <button
+ type="button"
+ className="grid place-items-center rounded-full transition"
+ style={{
+ width: LAYOUT.composerMicrophoneIconSize,
+ height: LAYOUT.composerMicrophoneIconSize,
+ color: hasPromptText ? 'rgba(255,255,255,0.42)' : 'rgba(255,255,255,0.78)',
+ }}
+ aria-label="Voice input"
+ >
+ <Mic size={24} strokeWidth={1.15} />
+ </button>
+ <button
+ type="submit"
+ className="grid place-items-center rounded-full transition disabled:cursor-default"
+ style={{
+ width: LAYOUT.composerSendButtonSize,
+ height: LAYOUT.composerSendButtonSize,
+ background: hasPromptText ? 'rgba(255,255,255,0.94)' : 'rgba(255,255,255,0.68)',
+ color: hasPromptText ? 'rgba(0,0,0,0.78)' : 'rgba(0,0,0,0.42)',
+ }}
+ disabled={!hasPromptText}
+ aria-label="Send"
+ >
+ <ArrowUp size={18} strokeWidth={2.25} />
+ </button>
</div>
</form>
</section>
diff --git a/site/src/app/prototype/_components/Notch.tsx b/site/src/app/prototype/_components/Notch.tsx
index febe9b11..650f6f22 100644
--- a/site/src/app/prototype/_components/Notch.tsx
+++ b/site/src/app/prototype/_components/Notch.tsx
@@ -1,15 +1,17 @@
-import { ArrowUp, Check, CircleAlert, Pause, Play } from 'lucide-react';
+import { ArrowUp, Check, MessageCircle, Pause, Play } from 'lucide-react';
import type { FormEvent } from 'react';
+import { ActivityBars } from '@/app/prototype/_components/ActivityBars';
import { TaskArrow } from '@/app/prototype/_components/TaskArrow';
import { TASKS } from '@/app/prototype/_components/tasks';
-import type { NotchState, TaskId } from '@/app/prototype/_components/types';
+import type { NotchState, Spawn, TaskId } from '@/app/prototype/_components/types';
type Props = {
state: NotchState;
activeTaskId: TaskId;
expanded: boolean;
setExpanded: (expanded: boolean) => void;
+ spawnCue: Spawn | null;
onRequestSpawn: (taskText: string) => void;
};
@@ -78,9 +80,21 @@ function collapsedStatusText(state: NotchState) {
return 'Run';
}
-export function Notch({ state, activeTaskId, expanded, setExpanded, onRequestSpawn }: Props) {
+function spawnCueExitTransform(angleDegrees: number) {
+ const radians = (angleDegrees * Math.PI) / 180;
+ const distance = 28;
+
+ return {
+ x: Math.cos(radians) * distance,
+ y: Math.sin(radians) * distance,
+ };
+}
+
+export function Notch({ state, activeTaskId, expanded, setExpanded, spawnCue, onRequestSpawn }: Props) {
const rows = taskRowsForState(state, activeTaskId);
const activeColor = rows[0]?.color ?? 'rgb(29,158,117)';
+ const isResting = state === 'idle' && rows.length === 0;
+ const spawnCueOffset = spawnCue ? spawnCueExitTransform(spawnCue.notchCueAngleDegrees) : null;
const handleFollowUpSubmit = (event: FormEvent<HTMLFormElement>) => {
event.preventDefault();
@@ -94,6 +108,36 @@ export function Notch({ state, activeTaskId, expanded, setExpanded, onRequestSpa
form.reset();
};
+ const spawnCueArrow = spawnCue && spawnCueOffset && (
+ <>
+ <style>{`
+ @keyframes notchSpawnCue-${spawnCue.id} {
+ 0%, 30% {
+ transform: translate(-50%, -50%) rotate(-45deg);
+ opacity: 1;
+ }
+ 100% {
+ transform: translate(calc(-50% + ${spawnCueOffset.x}px), calc(-50% + ${spawnCueOffset.y}px)) rotate(${spawnCue.notchCueAngleDegrees}deg);
+ opacity: 0;
+ }
+ }
+ `}</style>
+ <div
+ className="absolute z-10"
+ style={{
+ left: 17,
+ top: Math.max(14, METRICS.collapsedHeight / 2),
+ width: 15,
+ height: 15,
+ animation: `notchSpawnCue-${spawnCue.id} 260ms ease-in-out both`,
+ }}
+ aria-hidden="true"
+ >
+ <TaskArrow color={spawnCue.color} size={15} />
+ </div>
+ </>
+ );
+
return (
<section
aria-label="Donkey status"
@@ -129,21 +173,21 @@ export function Notch({ state, activeTaskId, expanded, setExpanded, onRequestSpa
<div
className="absolute inset-0"
style={{
- opacity: expanded ? 0 : 1,
+ opacity: expanded || spawnCue ? 0 : 1,
transition: 'opacity 150ms ease-out',
pointerEvents: 'none',
}}
>
- <TaskArrow
- color={activeColor}
- size={13}
- className="absolute top-[9.5px] left-[10.5px] -rotate-45"
- />
- <span className="absolute right-0 top-0 grid h-8 w-[34px] place-items-center text-[9px] leading-none text-white/[0.72]">
- {collapsedStatusText(state)}
- </span>
+ <TaskArrow color={activeColor} size={13} className="absolute left-[10.5px] top-[9.5px] -rotate-45" />
+ {!isResting && (
+ <span className="absolute right-0 top-0 grid h-8 w-[34px] place-items-center text-[9px] leading-none text-white/[0.72]">
+ {collapsedStatusText(state)}
+ </span>
+ )}
</div>
+ {spawnCueArrow}
+
<div
className="absolute left-0 flex flex-col gap-2"
style={{
@@ -156,48 +200,55 @@ export function Notch({ state, activeTaskId, expanded, setExpanded, onRequestSpa
transition: expanded ? 'opacity 300ms ease-out 150ms' : 'opacity 100ms ease-out',
}}
>
- <div className="min-h-0 flex-1 overflow-hidden pt-2.5">
- <div className="flex flex-col gap-2">
- {rows.map((task) => (
- <article
- key={task.id}
- className="flex h-12 items-center gap-3 rounded-lg bg-white/[0.055] px-3"
- >
- <TaskArrow color={task.color} size={14} className="-rotate-45" />
- <div className="min-w-0 flex-1">
- <h2 className="truncate text-[13px] font-normal leading-4 text-white/[0.9]">{task.title}</h2>
- <p className="mt-1 truncate text-[12px] font-normal leading-[14px] text-white/[0.42]">{task.detail}</p>
- </div>
- {task.status === 'running' ? (
- <div className="flex gap-1.5">
- <button
- type="button"
- className="grid h-6 w-6 place-items-center rounded-full bg-white/[0.055] text-white/[0.3]"
- aria-label="Resume"
- disabled
- >
- <Play size={10} fill="currentColor" />
- </button>
- <button
- type="button"
- className="grid h-6 w-6 place-items-center rounded-full bg-white/[0.12] text-white/[0.88]"
- aria-label="Pause"
- >
- <Pause size={10} fill="currentColor" />
- </button>
+ {rows.length > 0 && (
+ <div className="min-h-0 flex-1 overflow-hidden pt-2.5">
+ <div className="flex flex-col gap-2">
+ {rows.map((task) => (
+ <article
+ key={task.id}
+ className="flex h-12 items-center gap-3 rounded-lg bg-white/[0.055] px-3"
+ >
+ <TaskArrow color={task.color} size={14} className="-rotate-45" />
+ <div className="min-w-0 flex-1">
+ <h2 className="truncate text-[13px] font-normal leading-4 text-white/[0.9]">{task.title}</h2>
+ <p className="mt-1 truncate text-[12px] font-normal leading-[14px] text-white/[0.42]">
+ {task.detail}
+ </p>
</div>
- ) : task.status === 'completed' ? (
- <Check size={18} color={task.color} strokeWidth={1.35} />
- ) : (
- <CircleAlert size={18} color={task.color} strokeWidth={1.35} />
- )}
- </article>
- ))}
+ {task.status === 'running' ? (
+ <div className="flex gap-1.5">
+ <button
+ type="button"
+ className="grid h-6 w-6 place-items-center rounded-full bg-white/[0.055] text-white/[0.3]"
+ aria-label="Resume"
+ disabled
+ >
+ <Play size={10} fill="currentColor" />
+ </button>
+ <button
+ type="button"
+ className="grid h-6 w-6 place-items-center rounded-full bg-white/[0.12] text-white/[0.88]"
+ aria-label="Pause"
+ >
+ <Pause size={10} fill="currentColor" />
+ </button>
+ </div>
+ ) : task.status === 'completed' ? (
+ <Check size={18} color={task.color} strokeWidth={1.35} />
+ ) : task.status === 'needsAttention' ? (
+ <MessageCircle size={18} color={task.color} strokeWidth={1.35} />
+ ) : (
+ <ActivityBars color={task.color} />
+ )}
+ </article>
+ ))}
+ </div>
</div>
- </div>
+ )}
<form
className="relative h-[92px] w-[576px] rounded-[22px] bg-white/[0.085]"
+ style={{ marginTop: rows.length === 0 ? 16 : 0 }}
onSubmit={handleFollowUpSubmit}
>
<label className="sr-only" htmlFor="donkey-follow-up-input">
diff --git a/site/src/app/prototype/_components/SpawnedCursor.tsx b/site/src/app/prototype/_components/SpawnedCursor.tsx
index 3109009f..4c50e837 100644
--- a/site/src/app/prototype/_components/SpawnedCursor.tsx
+++ b/site/src/app/prototype/_components/SpawnedCursor.tsx
@@ -1,183 +1,431 @@
+import { useEffect, useLayoutEffect, useRef, useState } from 'react';
+import type { CSSProperties, KeyboardEvent } from 'react';
+
import { DonkeyCursor } from '@/app/prototype/_components/DonkeyCursor';
-import type { Point, Spawn } from '@/app/prototype/_components/types';
+import type { DesktopSize, Point, Spawn } from '@/app/prototype/_components/types';
type Props = {
spawn: Spawn;
spawnOrigin: Point;
+ desktopSize: DesktopSize;
+ selected: boolean;
+ editing: boolean;
+ onSelect: () => void;
+ onBeginEditing: () => void;
+ onCancelEditing: () => void;
+ onSubmitFollowUp: (text: string) => void;
+};
+
+type MotionPathStyle = CSSProperties & {
+ WebkitOffsetPath?: string;
+ WebkitOffsetRotate?: string;
};
-export function SpawnedCursor({ spawn, spawnOrigin }: Props) {
+const TRAVEL_DURATION_MS = 820;
+const CURSOR_BASE_ROTATION_DEG = 50;
+const COLLAPSED_LABEL_WIDTH = 260;
+const COLLAPSED_LABEL_CONTENT_WIDTH = 240;
+const COLLAPSED_LABEL_BOTTOM_GAP = 22;
+const EXPANDED_LABEL_CONTENT_WIDTH = 480;
+const LABEL_HORIZONTAL_PADDING = 10;
+const LABEL_VERTICAL_PADDING = 5;
+const LABEL_FONT_SIZE = 12;
+const LABEL_LINE_HEIGHT = 14;
+const COLLAPSED_LABEL_APPROX_CHARS_PER_LINE = 40;
+const INLINE_EDITOR_CONTENT_WIDTH = 480;
+const INLINE_EDITOR_INPUT_HEIGHT = 64;
+const INLINE_EDITOR_HORIZONTAL_PADDING = 16;
+const INLINE_EDITOR_VERTICAL_PADDING = 14;
+const INLINE_EDITOR_SPACING = 12;
+const INLINE_EDITOR_MIN_TEXT_HEIGHT = 14;
+const INLINE_EDITOR_MAX_TEXT_HEIGHT = 44;
+const HALO_VERTICAL_OFFSET = 12;
+
+const INPUT_ACCENT_BY_COLOR: Record<string, string> = {
+ '#1D9E75': '#B0DECF',
+ '#EF9F27': '#FADEB3',
+ '#D4537E': '#F0C4D1',
+ '#378ADD': '#BAD6F2',
+ '#7F77DD': '#D4CFF2',
+ '#E15A47': '#F5C4BF',
+ '#3DB0B5': '#BAE3E6',
+ '#A856C9': '#E0C4ED',
+};
+
+function useTypewriterText(text: string, identity: string) {
+ const [visibleText, setVisibleText] = useState('');
+
+ useEffect(() => {
+ const characters = Array.from(text);
+ const resetTimer = window.setTimeout(() => setVisibleText(''), 0);
+ if (characters.length === 0) {
+ return () => window.clearTimeout(resetTimer);
+ }
+
+ const timers = characters.map((_, index) =>
+ window.setTimeout(() => {
+ setVisibleText(characters.slice(0, index + 1).join(''));
+ }, (index + 1) * 26),
+ );
+
+ return () => {
+ window.clearTimeout(resetTimer);
+ timers.forEach((timer) => window.clearTimeout(timer));
+ };
+ }, [identity, text]);
+
+ return visibleText;
+}
+
+function textCharacterCount(text: string) {
+ return Math.max(Array.from(text.trim()).length, 1);
+}
+
+function collapsedLabelNeedsExpansion(text: string) {
+ return text.includes('\n') || textCharacterCount(text) > 78;
+}
+
+function collapsedLabelHeight(text: string) {
+ const lineCount = Math.min(
+ Math.max(Math.ceil(textCharacterCount(text) / COLLAPSED_LABEL_APPROX_CHARS_PER_LINE), 1),
+ 2,
+ );
+
+ return lineCount * LABEL_LINE_HEIGHT + LABEL_VERTICAL_PADDING * 2;
+}
+
+function expandedLabelHeight(text: string) {
+ const lineCount = Math.max(1, Math.ceil(textCharacterCount(text) / 44));
+
+ return Math.max(collapsedLabelHeight(text), lineCount * LABEL_LINE_HEIGHT + LABEL_VERTICAL_PADDING * 2);
+}
+
+function inlineEditorMessageHeight(text: string) {
+ const lineCount = Math.min(Math.max(Math.ceil(textCharacterCount(text) / 64), 1), 3);
+
+ return lineCount * 14 + 6;
+}
+
+function inlineEditorSize(text: string) {
+ return {
+ width: INLINE_EDITOR_CONTENT_WIDTH + INLINE_EDITOR_HORIZONTAL_PADDING * 2,
+ height:
+ inlineEditorMessageHeight(text) +
+ INLINE_EDITOR_SPACING +
+ INLINE_EDITOR_INPUT_HEIGHT +
+ INLINE_EDITOR_VERTICAL_PADDING * 2,
+ };
+}
+
+function pointFits(point: Point, offset: Point, labelSize: { width: number; height: number }, desktopSize: DesktopSize) {
+ const margin = 20;
+ const minX = point.x + offset.x - labelSize.width / 2;
+ const minY = point.y + offset.y - labelSize.height / 2;
+ const maxX = minX + labelSize.width;
+ const maxY = minY + labelSize.height;
+
+ return minX >= margin && minY >= margin && maxX <= desktopSize.w - margin && maxY <= desktopSize.h - margin;
+}
+
+function labelOffset(point: Point, labelSize: { width: number; height: number }, desktopSize: DesktopSize) {
+ const preferred = { x: 0, y: -(labelSize.height / 2 + COLLAPSED_LABEL_BOTTOM_GAP) };
+ const left = { x: -(labelSize.width / 2 + 44), y: 0 };
+ const right = { x: labelSize.width / 2 + 44, y: 0 };
+ const below = { x: 0, y: labelSize.height / 2 + 44 };
+
+ if (pointFits(point, preferred, labelSize, desktopSize)) return preferred;
+ if (pointFits(point, left, labelSize, desktopSize)) return left;
+ if (pointFits(point, right, labelSize, desktopSize)) return right;
+
+ return below;
+}
+
+function inputAccentColor(color: string) {
+ return INPUT_ACCENT_BY_COLOR[color.toUpperCase()] ?? 'rgba(255,255,255,0.72)';
+}
+
+export function SpawnedCursor({
+ spawn,
+ spawnOrigin,
+ desktopSize,
+ selected,
+ editing,
+ onSelect,
+ onBeginEditing,
+ onCancelEditing,
+ onSubmitFollowUp,
+}: Props) {
const { id, color, label, target, phase } = spawn;
+ const [labelHovered, setLabelHovered] = useState(false);
+ const [draftText, setDraftText] = useState('');
+ const [draftTextHeight, setDraftTextHeight] = useState(INLINE_EDITOR_MIN_TEXT_HEIGHT);
+ const editorRef = useRef<HTMLTextAreaElement | null>(null);
+ const visibleLabel = useTypewriterText(label, `${id}:${label}`);
+
+ useEffect(() => {
+ if (!editing) return;
+
+ window.setTimeout(() => editorRef.current?.focus(), 0);
+ }, [editing]);
+
+ useLayoutEffect(() => {
+ if (!editing) return;
+
+ const editor = editorRef.current;
+ if (!editor) return;
+
+ editor.style.height = 'auto';
+ const nextHeight = Math.min(
+ Math.max(Math.ceil(editor.scrollHeight), INLINE_EDITOR_MIN_TEXT_HEIGHT),
+ INLINE_EDITOR_MAX_TEXT_HEIGHT,
+ );
+ editor.style.height = `${nextHeight}px`;
+ setDraftTextHeight(nextHeight);
+ }, [draftText, editing]);
+
+ if (phase === 'notch-cue' || phase === 'fading') {
+ return null;
+ }
const sx = spawnOrigin.x;
const sy = spawnOrigin.y;
const tx = target.x;
const ty = target.y;
- const mx = (sx + tx) / 2;
- const my = (sy + ty) / 2;
const dx = tx - sx;
const dy = ty - sy;
- const len = Math.hypot(dx, dy) || 1;
- const px = -dy / len;
- const py = dx / len;
- const curveAmount = Math.min(80, len * 0.35) * (spawn.curveSide || 1);
- const cx = mx + px * curveAmount;
- const cy = my + py * curveAmount;
- const pathD = `M ${sx},${sy} Q ${cx},${cy} ${tx},${ty}`;
-
- const endAngleDeg = (Math.atan2(ty - cy, tx - cx) * 180) / Math.PI;
-
- const isEmerge = phase === 'emerge';
- const isTravel = phase === 'travel';
- const isShakeL = phase === 'shake-left';
- const isShakeR = phase === 'shake-right';
- const isWorking = phase === 'working';
- const useOffsetPath = isEmerge || isTravel;
- const cursorBaseRotation = 50;
- const labelLength = Math.max(Array.from(label).length, 1);
- const labelTypingDurationMs = Math.min(1300, Math.max(280, labelLength * 38));
- const labelWidth = `${labelLength + 1}ch`;
+ const endAngleDeg = (Math.atan2(dy, dx) * 180) / Math.PI;
+ const pathD = `M ${sx},${sy} L ${tx},${ty}`;
+ const isTraveling = phase === 'traveling';
+ const isHolding = phase === 'holding';
+ const labelIsExpanded = labelHovered && collapsedLabelNeedsExpansion(label);
+ const labelSize = editing
+ ? inlineEditorSize(label)
+ : {
+ width: labelIsExpanded ? EXPANDED_LABEL_CONTENT_WIDTH + LABEL_HORIZONTAL_PADDING * 2 : COLLAPSED_LABEL_WIDTH,
+ height: labelIsExpanded ? expandedLabelHeight(label) : collapsedLabelHeight(label),
+ };
+ const offset = labelOffset(target, labelSize, desktopSize);
+ const cursorStyle: MotionPathStyle = isTraveling
+ ? {
+ left: 0,
+ top: 0,
+ width: 28,
+ height: 28,
+ offsetPath: `path("${pathD}")`,
+ WebkitOffsetPath: `path("${pathD}")`,
+ offsetRotate: `auto ${CURSOR_BASE_ROTATION_DEG}deg`,
+ WebkitOffsetRotate: `auto ${CURSOR_BASE_ROTATION_DEG}deg`,
+ animation: `spawnTravel-${id} ${TRAVEL_DURATION_MS}ms cubic-bezier(0.45, 0.05, 0.3, 1) both`,
+ }
+ : {
+ left: target.x,
+ top: target.y,
+ width: 28,
+ height: 28,
+ transform: `translate(-50%, -50%) rotate(${endAngleDeg + CURSOR_BASE_ROTATION_DEG}deg)`,
+ };
+
+ const submitInlineFollowUp = () => {
+ const text = draftText.trim();
+ if (!text) {
+ onCancelEditing();
+ return;
+ }
+
+ onSubmitFollowUp(text);
+ setDraftText('');
+ };
+
+ const handleEditorKeyDown = (event: KeyboardEvent<HTMLTextAreaElement>) => {
+ if (event.key === 'Escape') {
+ event.preventDefault();
+ onCancelEditing();
+ return;
+ }
+
+ if (event.key === 'Enter' && !event.shiftKey) {
+ event.preventDefault();
+ submitInlineFollowUp();
+ }
+ };
return (
<>
<style>{`
- @keyframes emerge-${id} {
+ @keyframes spawnTravel-${id} {
0% { offset-distance: 0%; opacity: 0; }
- 40% { opacity: 1; }
- 100% { offset-distance: 0%; opacity: 1; }
- }
- @keyframes emergeScale-${id} {
- 0% { transform: rotate(${cursorBaseRotation}deg) scale(0.2); }
- 50% { transform: rotate(${cursorBaseRotation}deg) scale(1.2); }
- 100% { transform: rotate(${cursorBaseRotation}deg) scale(1); }
- }
- @keyframes travel-${id} {
- 0% { offset-distance: 0%; }
- 100% { offset-distance: 100%; }
+ 14% { opacity: 1; }
+ 100% { offset-distance: 100%; opacity: 1; }
}
- @keyframes shakeL-${id} {
- 0%, 100% { transform: rotate(0deg); }
- 25% { transform: rotate(-14deg); }
- 75% { transform: rotate(-7deg); }
+ @keyframes spawnTerminalTail-${id} {
+ 0%, 50%, 100% { transform: rotate(0deg); }
+ 12.5% { transform: rotate(-14deg); }
+ 37.5% { transform: rotate(-7deg); }
+ 62.5% { transform: rotate(14deg); }
+ 87.5% { transform: rotate(7deg); }
}
- @keyframes shakeR-${id} {
- 0%, 100% { transform: rotate(0deg); }
- 25% { transform: rotate(14deg); }
- 75% { transform: rotate(7deg); }
- }
- @keyframes working-${id} {
+ @keyframes spawnWorkingPulse-${id} {
0%, 100% { transform: scale(1); }
50% { transform: scale(1.08); }
}
- @keyframes haloPulse-${id} {
- 0%, 100% { transform: scale(1); opacity: 0.6; }
- 50% { transform: scale(1.15); opacity: 0.2; }
+ @keyframes spawnHaloPulse-${id} {
+ 0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.6; }
+ 50% { transform: translate(-50%, -50%) scale(1.15); opacity: 0.2; }
}
`}</style>
- {isWorking && (
+ {isHolding && (
<div
- className="absolute pointer-events-none"
+ className="absolute pointer-events-none rounded-full"
style={{
- left: target.x - 18,
- top: target.y - 18,
- width: 36,
- height: 36,
- borderRadius: '50%',
+ left: target.x,
+ top: target.y + HALO_VERTICAL_OFFSET,
+ width: 40,
+ height: 40,
border: `1.5px solid ${color}`,
- animation: `haloPulse-${id} 1.6s ease-in-out infinite`,
+ transform: 'translate(-50%, -50%)',
+ animation: `spawnHaloPulse-${id} 1.6s ease-in-out 700ms infinite`,
zIndex: 29,
}}
/>
)}
- <div
- className="absolute pointer-events-none"
- style={{
- left: useOffsetPath ? 0 : target.x,
- top: useOffsetPath ? 0 : target.y,
- ...(useOffsetPath && {
- offsetPath: `path("${pathD}")`,
- WebkitOffsetPath: `path("${pathD}")`,
- offsetRotate: `auto ${cursorBaseRotation}deg`,
- WebkitOffsetRotate: `auto ${cursorBaseRotation}deg`,
- animation: isEmerge
- ? `emerge-${id} 0.5s cubic-bezier(0.32, 1.4, 0.5, 1) forwards`
- : `travel-${id} 0.9s cubic-bezier(0.45, 0.05, 0.3, 1) forwards`,
- }),
- zIndex: 30,
+ <button
+ type="button"
+ data-spawn-interactive="true"
+ className="absolute z-30 cursor-default border-0 bg-transparent p-0"
+ style={cursorStyle}
+ onPointerDown={(event) => {
+ event.stopPropagation();
+ onSelect();
}}
+ aria-label={selected ? 'Selected Donkey agent' : 'Select Donkey agent'}
>
<div
style={{
- transform: useOffsetPath ? 'none' : `rotate(${endAngleDeg + cursorBaseRotation}deg)`,
- transformOrigin: '0 0',
+ transformOrigin: '50% 50%',
+ animation: isHolding ? `spawnTerminalTail-${id} 700ms ease-in-out both` : 'none',
}}
>
<div
style={{
- transformOrigin: '0 0',
- animation: isEmerge
- ? `emergeScale-${id} 0.5s cubic-bezier(0.32, 1.4, 0.5, 1) forwards`
- : isShakeL
- ? `shakeL-${id} 0.35s ease-in-out`
- : isShakeR
- ? `shakeR-${id} 0.35s ease-in-out`
- : isWorking
- ? `working-${id} 1.4s ease-in-out infinite`
- : 'none',
+ transformOrigin: '50% 50%',
+ animation: isHolding ? `spawnWorkingPulse-${id} 1.4s ease-in-out 700ms infinite` : 'none',
}}
>
<DonkeyCursor color={color} />
</div>
</div>
- </div>
-
- {(isShakeL || isShakeR || isWorking) && label && (
- (() => {
- const rad = (endAngleDeg * Math.PI) / 180;
- const dirX = Math.cos(rad);
- const dirY = Math.sin(rad);
- const offsetDist = 34;
- const anchorX = target.x - dirX * offsetDist;
- const anchorY = target.y - dirY * offsetDist;
-
- return (
- <div
- className="absolute inline-flex items-center whitespace-nowrap text-[10px] font-medium text-white px-2 py-0.5 rounded-md pointer-events-none animate-fadein-label"
- style={{
- background: color,
- left: anchorX,
- top: anchorY,
- transform: `translate(${(-50 - dirX * 50)}%, ${(-50 - dirY * 50)}%)`,
- boxShadow: '0 1px 3px rgba(0,0,0,0.3)',
- zIndex: 29,
- }}
- >
- <span
- className="inline-block overflow-hidden whitespace-nowrap"
+ </button>
+
+ {isHolding && (
+ <div
+ data-spawn-interactive="true"
+ className="absolute text-white"
+ style={{
+ left: target.x + offset.x,
+ top: target.y + offset.y,
+ width: labelSize.width,
+ minHeight: labelSize.height,
+ transform: 'translate(-50%, -50%)',
+ zIndex: 29,
+ }}
+ onPointerDown={(event) => event.stopPropagation()}
+ onMouseEnter={() => setLabelHovered(true)}
+ onMouseLeave={() => setLabelHovered(false)}
+ >
+ <div
+ className="overflow-hidden"
+ style={{
+ borderRadius: 8,
+ background: color,
+ boxShadow: selected ? '0 0 0 1px rgba(255,255,255,0.28), 0 4px 14px rgba(0,0,0,0.24)' : 'none',
+ }}
+ >
+ {editing ? (
+ <div
style={{
- maxWidth: labelWidth,
- animation: `typeLabel-${id} ${labelTypingDurationMs}ms steps(${labelLength}, end) both`,
+ width: INLINE_EDITOR_CONTENT_WIDTH + INLINE_EDITOR_HORIZONTAL_PADDING * 2,
+ padding: `${INLINE_EDITOR_VERTICAL_PADDING}px ${INLINE_EDITOR_HORIZONTAL_PADDING}px`,
}}
>
- {label}
- </span>
- </div>
- );
- })()
+ <div
+ className="overflow-hidden text-left font-medium text-white"
+ style={{
+ width: INLINE_EDITOR_CONTENT_WIDTH,
+ maxHeight: 42,
+ fontSize: LABEL_FONT_SIZE,
+ lineHeight: '14px',
+ display: '-webkit-box',
+ WebkitLineClamp: 3,
+ WebkitBoxOrient: 'vertical',
+ }}
+ >
+ {label}
+ </div>
+ <div
+ className="mt-3 overflow-hidden"
+ style={{
+ width: INLINE_EDITOR_CONTENT_WIDTH,
+ height: INLINE_EDITOR_INPUT_HEIGHT,
+ padding: '8px 12px',
+ borderRadius: 7,
+ background: inputAccentColor(color),
+ }}
+ >
+ <textarea
+ ref={editorRef}
+ rows={1}
+ value={draftText}
+ onChange={(event) => setDraftText(event.target.value)}
+ onKeyDown={handleEditorKeyDown}
+ className="block w-full resize-none overflow-hidden border-0 bg-transparent p-0 text-left font-medium outline-none"
+ style={{
+ height: draftTextHeight,
+ color: 'rgba(0,0,0,0.68)',
+ caretColor: 'rgba(0,0,0,0.72)',
+ fontSize: LABEL_FONT_SIZE,
+ lineHeight: '14px',
+ fontVariantLigatures: 'none',
+ }}
+ aria-label="Follow-up"
+ />
+ </div>
+ </div>
+ ) : (
+ <button
+ type="button"
+ className="block w-full border-0 bg-transparent text-left text-white"
+ style={{
+ padding: `${LABEL_VERTICAL_PADDING}px ${LABEL_HORIZONTAL_PADDING}px`,
+ fontSize: LABEL_FONT_SIZE,
+ fontWeight: 500,
+ lineHeight: `${LABEL_LINE_HEIGHT}px`,
+ }}
+ onClick={onBeginEditing}
+ onPointerDown={() => {
+ setDraftText('');
+ setDraftTextHeight(INLINE_EDITOR_MIN_TEXT_HEIGHT);
+ }}
+ >
+ <span
+ className="block overflow-hidden"
+ style={{
+ maxWidth: labelIsExpanded ? EXPANDED_LABEL_CONTENT_WIDTH : COLLAPSED_LABEL_CONTENT_WIDTH,
+ display: labelIsExpanded ? 'block' : '-webkit-box',
+ WebkitLineClamp: labelIsExpanded ? 'unset' : 2,
+ WebkitBoxOrient: 'vertical',
+ whiteSpace: 'pre-wrap',
+ textOverflow: 'ellipsis',
+ }}
+ >
+ {visibleLabel}
+ </span>
+ </button>
+ )}
+ </div>
+ </div>
)}
- <style>{`
- @keyframes typeLabel-${id} {
- from { max-width: 0; }
- to { max-width: ${labelWidth}; }
- }
- @keyframes fadeinLabel-${id} {
- from { opacity: 0; }
- to { opacity: 1; }
- }
- .animate-fadein-label { animation: fadeinLabel-${id} 0.2s ease-out both; }
- `}</style>
</>
);
}
diff --git a/site/src/app/prototype/_components/TaskArrow.tsx b/site/src/app/prototype/_components/TaskArrow.tsx
index 97358a41..c45cd01d 100644
--- a/site/src/app/prototype/_components/TaskArrow.tsx
+++ b/site/src/app/prototype/_components/TaskArrow.tsx
@@ -13,7 +13,7 @@ export function TaskArrow({ color, size = 14, className }: Props) {
aria-hidden="true"
className={`flex-shrink-0 ${className ?? ''}`}
>
- <path d="M3.1 1.1 12 7l-8.9 5.9L5.2 7 3.1 1.1Z" fill={color} />
+ <path d="M2.52 0.84 12.32 7 2.52 13.16 4.76 7 2.52 0.84Z" fill={color} />
</svg>
);
}
diff --git a/site/src/app/prototype/_components/types.ts b/site/src/app/prototype/_components/types.ts
index 06513937..4ceea587 100644
--- a/site/src/app/prototype/_components/types.ts
+++ b/site/src/app/prototype/_components/types.ts
@@ -27,15 +27,16 @@ export type DesktopSize = {
h: number;
};
-export type SpawnPhase = 'emerge' | 'travel' | 'shake-left' | 'shake-right' | 'working';
+export type SpawnPhase = 'notch-cue' | 'traveling' | 'holding' | 'fading';
export type Spawn = {
id: string;
+ taskId: string;
color: string;
label: string;
target: Point;
phase: SpawnPhase;
- curveSide: 1 | -1;
+ notchCueAngleDegrees: number;
startedAt: number;
};