cleanup folders and events, and condense changes
This commit is contained in:
@@ -20,9 +20,8 @@ import { ScreenSourcePicker } from '@/components/screen-source-picker';
|
||||
import { KeyHint } from '@/components/key-hint';
|
||||
import { TextComposeStep } from '@/features/compose/text-compose-step';
|
||||
import { TaskComposeStep } from '@/features/compose/task-compose-step';
|
||||
import { EventComposeStep } from '@/features/compose/event-compose-step';
|
||||
import { ConfigureContainerStep } from '@/features/compose/configure-container-step';
|
||||
import type { TaskProperties, EventProperties } from '@/api/types';
|
||||
import type { TaskProperties } from '@/api/types';
|
||||
import { apiClient } from '@/api/client';
|
||||
import { useMediaSettingsStore } from '@/stores/media-settings-store';
|
||||
import { useMediaDevicesStore } from '@/stores/media-devices-store';
|
||||
@@ -44,15 +43,13 @@ export type ComposeStep =
|
||||
| 'reviewing'
|
||||
| 'typing'
|
||||
| 'task'
|
||||
| 'event'
|
||||
| 'configuring'
|
||||
| 'submitting';
|
||||
|
||||
type RecordingSource = 'media' | 'screen';
|
||||
|
||||
type PendingArtifact =
|
||||
| { type: 'task'; properties: TaskProperties }
|
||||
| { type: 'event'; properties: EventProperties };
|
||||
| { type: 'task'; properties: TaskProperties };
|
||||
|
||||
interface ComposeOverlayProps {
|
||||
networkId: string;
|
||||
@@ -106,8 +103,7 @@ export function ComposeOverlay({
|
||||
const recordStartRef = useRef(0);
|
||||
const quotaExhaustedRef = useRef(quotaExhausted);
|
||||
const recordingSourceRef = useRef(recordingSource);
|
||||
// Task/event captured by their compose steps, created on submit. A ref (not
|
||||
// state) so submit handlers can set it and create in the same tick.
|
||||
|
||||
const pendingArtifactRef = useRef<PendingArtifact | null>(null);
|
||||
useEffect(() => {
|
||||
quotaExhaustedRef.current = quotaExhausted;
|
||||
@@ -501,12 +497,8 @@ export function ComposeOverlay({
|
||||
setStepSync('task');
|
||||
}, [guardIdle, setStepSync]);
|
||||
|
||||
const handleEventIntent = useCallback(() => {
|
||||
if (!guardIdle()) return;
|
||||
setStepSync('event');
|
||||
}, [guardIdle, setStepSync]);
|
||||
|
||||
// Task/event submit: capture the artifact, then reuse the standard flow —
|
||||
// Artifact submit: capture the artifact, then reuse the standard flow —
|
||||
// reply mode creates it under targetPath, root mode configures a stream
|
||||
// that will hold it as its first child.
|
||||
const handleArtifactSubmit = useCallback(
|
||||
@@ -577,9 +569,6 @@ export function ComposeOverlay({
|
||||
case 'task':
|
||||
handleTaskIntent();
|
||||
break;
|
||||
case 'event':
|
||||
handleEventIntent();
|
||||
break;
|
||||
case 'stop':
|
||||
handleStopIntent();
|
||||
break;
|
||||
@@ -596,7 +585,6 @@ export function ComposeOverlay({
|
||||
handleRecordIntent,
|
||||
handleTextIntent,
|
||||
handleTaskIntent,
|
||||
handleEventIntent,
|
||||
handleStopIntent,
|
||||
handleCancelIntent,
|
||||
handleSendIntent,
|
||||
@@ -612,7 +600,6 @@ export function ComposeOverlay({
|
||||
if (
|
||||
currentStep === 'typing' ||
|
||||
currentStep === 'task' ||
|
||||
currentStep === 'event' ||
|
||||
currentStep === 'configuring' ||
|
||||
currentStep === 'picking'
|
||||
) {
|
||||
@@ -649,9 +636,6 @@ export function ComposeOverlay({
|
||||
} else if (e.key === 'd' || e.key === 'D') {
|
||||
e.preventDefault();
|
||||
handleTaskIntent();
|
||||
} else if (e.key === 'e' || e.key === 'E') {
|
||||
e.preventDefault();
|
||||
handleEventIntent();
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -720,7 +704,6 @@ export function ComposeOverlay({
|
||||
handleRecordIntent,
|
||||
handleTextIntent,
|
||||
handleTaskIntent,
|
||||
handleEventIntent,
|
||||
handleStopIntent,
|
||||
handleCancelIntent,
|
||||
handleSendIntent,
|
||||
@@ -838,14 +821,6 @@ export function ComposeOverlay({
|
||||
}
|
||||
/>
|
||||
)}
|
||||
{step === 'event' && (
|
||||
<EventComposeStep
|
||||
onCancel={cancel}
|
||||
onSubmit={(properties) =>
|
||||
handleArtifactSubmit({ type: 'event', properties })
|
||||
}
|
||||
/>
|
||||
)}
|
||||
{!targetPath && step === 'configuring' && (
|
||||
<ConfigureContainerStep
|
||||
networkId={networkId}
|
||||
|
||||
@@ -1,126 +0,0 @@
|
||||
import { useCallback, useState } from 'react';
|
||||
import type { EventProperties } from '@/api/types';
|
||||
import { metaKey } from '@/lib/platform';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Label } from '@/components/ui/label';
|
||||
import { Textarea } from '@/components/ui/textarea';
|
||||
import { KeyHint } from '@/components/key-hint';
|
||||
import { toDatetimeLocalValue } from '@/features/particles/event-particle-view';
|
||||
|
||||
interface EventComposeStepProps {
|
||||
onCancel: () => void;
|
||||
onSubmit: (properties: EventProperties) => void;
|
||||
}
|
||||
|
||||
function nextFullHour(): Date {
|
||||
const date = new Date();
|
||||
date.setMinutes(0, 0, 0);
|
||||
date.setHours(date.getHours() + 1);
|
||||
return date;
|
||||
}
|
||||
|
||||
const dateInputClass =
|
||||
'w-full rounded-md border border-white/10 bg-white/5 px-3 py-1.5 text-sm text-white outline-none [color-scheme:dark] focus:border-white/30';
|
||||
|
||||
export function EventComposeStep({
|
||||
onCancel,
|
||||
onSubmit,
|
||||
}: EventComposeStepProps) {
|
||||
const [title, setTitle] = useState('');
|
||||
const [startAt, setStartAt] = useState(() =>
|
||||
toDatetimeLocalValue(nextFullHour()),
|
||||
);
|
||||
const [endAt, setEndAt] = useState('');
|
||||
const [notes, setNotes] = useState('');
|
||||
|
||||
const handleSubmit = useCallback(() => {
|
||||
const trimmed = title.trim();
|
||||
if (!trimmed || !startAt) return;
|
||||
onSubmit({
|
||||
title: trimmed,
|
||||
start_at: new Date(startAt),
|
||||
...(endAt && { end_at: new Date(endAt) }),
|
||||
...(notes.trim() && { notes: notes.trim() }),
|
||||
});
|
||||
}, [title, startAt, endAt, notes, onSubmit]);
|
||||
|
||||
const handleKeyDown = useCallback(
|
||||
(e: React.KeyboardEvent) => {
|
||||
if (e.key === 'Escape') {
|
||||
e.preventDefault();
|
||||
onCancel();
|
||||
} else if (e.key === 'Enter' && (e.metaKey || e.ctrlKey)) {
|
||||
e.preventDefault();
|
||||
handleSubmit();
|
||||
}
|
||||
},
|
||||
[onCancel, handleSubmit],
|
||||
);
|
||||
|
||||
return (
|
||||
<div
|
||||
className="absolute inset-0 z-50 flex flex-col bg-black/90 pt-16"
|
||||
onKeyDown={handleKeyDown}
|
||||
tabIndex={-1}
|
||||
>
|
||||
<div className="mx-auto w-full max-w-sm space-y-4 px-6">
|
||||
<div>
|
||||
<Label className="mb-1 text-xs text-white/50">Event</Label>
|
||||
<Input
|
||||
type="text"
|
||||
autoFocus
|
||||
value={title}
|
||||
onChange={(e) => setTitle(e.target.value)}
|
||||
placeholder="What's happening?"
|
||||
className="border-white/10 bg-white/5 text-white placeholder-white/30 focus-visible:border-white/30 focus-visible:ring-0"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="flex gap-3">
|
||||
<div className="flex-1">
|
||||
<Label className="mb-1 text-xs text-white/50">Starts</Label>
|
||||
<input
|
||||
type="datetime-local"
|
||||
value={startAt}
|
||||
onChange={(e) => setStartAt(e.target.value)}
|
||||
className={dateInputClass}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex-1">
|
||||
<Label className="mb-1 text-xs text-white/50">Ends</Label>
|
||||
<input
|
||||
type="datetime-local"
|
||||
value={endAt}
|
||||
min={startAt}
|
||||
onChange={(e) => setEndAt(e.target.value)}
|
||||
className={dateInputClass}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<Label className="mb-1 text-xs text-white/50">Notes</Label>
|
||||
<Textarea
|
||||
value={notes}
|
||||
onChange={(e) => setNotes(e.target.value)}
|
||||
placeholder="Optional details…"
|
||||
className="min-h-20 border-white/10 bg-white/5 text-white placeholder:text-white/30 focus-visible:border-white/30 focus-visible:ring-0 dark:bg-white/5"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="absolute bottom-8 left-0 right-0 flex items-center justify-center gap-4 text-sm text-white/50">
|
||||
<KeyHint keys="Esc" onClick={onCancel} title="Cancel (or press Esc)">
|
||||
cancel
|
||||
</KeyHint>
|
||||
<KeyHint
|
||||
keys={`${metaKey}+Enter`}
|
||||
onClick={handleSubmit}
|
||||
title={`Create event (or press ${metaKey}+Enter)`}
|
||||
>
|
||||
create
|
||||
</KeyHint>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user