feat: wire all remaining API endpoints
- src/api/keys.ts: QK singleton for all 20+ query key patterns
- src/api/queries.ts: rewritten with QK + full mutation coverage:
deleteWorkspace, updateWorkspace, scheduleDream,
updatePeer, setPeerCard, searchPeer,
deleteSession, updateSession, cloneSession, searchSession,
createMessages, updateMessage,
useSessionPeers, addPeersToSession, setSessionPeers,
removePeersFromSession, setPeerConfig,
createConclusion, deleteConclusion,
useWebhooks, createWebhook, deleteWebhook, testWebhook,
createKey
Shared primitives (just-in-time):
- ConfirmDialog: animated modal with keyboard/click-out dismiss
- FormModal: reusable modal shell
- InlineEditor: click-to-edit with commit/cancel
New surfaces:
- WorkspaceDetail: delete + schedule dream buttons
- ScheduleDreamModal: Zod-validated observer/session form
- WebhookManager: full CRUD + test emit (new /webhooks route)
- SessionDetail: delete, clone, session search, peer membership tab
- PeerDetail: editable peer card, semantic search tab
- ConclusionBrowser: create conclusion modal (Zod), per-row delete
2026-04-24 11:25:19 -05:00
|
|
|
import { useState } from "react";
|
|
|
|
|
import { z } from "zod";
|
|
|
|
|
import type { UseMutationResult } from "@tanstack/react-query";
|
|
|
|
|
import { FormModal } from "@/components/shared/FormModal";
|
2026-04-24 13:56:13 -05:00
|
|
|
import { Button } from "@/components/ui/button";
|
|
|
|
|
import { Input } from "@/components/ui/input";
|
|
|
|
|
import { Label } from "@/components/ui/label";
|
|
|
|
|
import { Caption } from "@/components/ui/typography";
|
|
|
|
|
import { COLOR } from "@/lib/constants";
|
feat: wire all remaining API endpoints
- src/api/keys.ts: QK singleton for all 20+ query key patterns
- src/api/queries.ts: rewritten with QK + full mutation coverage:
deleteWorkspace, updateWorkspace, scheduleDream,
updatePeer, setPeerCard, searchPeer,
deleteSession, updateSession, cloneSession, searchSession,
createMessages, updateMessage,
useSessionPeers, addPeersToSession, setSessionPeers,
removePeersFromSession, setPeerConfig,
createConclusion, deleteConclusion,
useWebhooks, createWebhook, deleteWebhook, testWebhook,
createKey
Shared primitives (just-in-time):
- ConfirmDialog: animated modal with keyboard/click-out dismiss
- FormModal: reusable modal shell
- InlineEditor: click-to-edit with commit/cancel
New surfaces:
- WorkspaceDetail: delete + schedule dream buttons
- ScheduleDreamModal: Zod-validated observer/session form
- WebhookManager: full CRUD + test emit (new /webhooks route)
- SessionDetail: delete, clone, session search, peer membership tab
- PeerDetail: editable peer card, semantic search tab
- ConclusionBrowser: create conclusion modal (Zod), per-row delete
2026-04-24 11:25:19 -05:00
|
|
|
|
|
|
|
|
const schema = z.object({
|
|
|
|
|
observer: z.string().min(1, "Observer peer ID is required"),
|
|
|
|
|
observed: z.string().optional(),
|
|
|
|
|
session_id: z.string().optional(),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
|
open: boolean;
|
|
|
|
|
workspaceId: string;
|
|
|
|
|
onClose: () => void;
|
|
|
|
|
mutation: UseMutationResult<
|
|
|
|
|
void,
|
|
|
|
|
Error,
|
|
|
|
|
{ observer: string; observed?: string | null; dream_type: "omni"; session_id?: string | null }
|
|
|
|
|
>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function ScheduleDreamModal({ open, onClose, mutation }: Props) {
|
|
|
|
|
const [observer, setObserver] = useState("");
|
|
|
|
|
const [observed, setObserved] = useState("");
|
|
|
|
|
const [sessionId, setSessionId] = useState("");
|
|
|
|
|
const [validationError, setValidationError] = useState("");
|
|
|
|
|
|
|
|
|
|
const reset = () => {
|
|
|
|
|
setObserver("");
|
|
|
|
|
setObserved("");
|
|
|
|
|
setSessionId("");
|
|
|
|
|
setValidationError("");
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleSubmit = async (e: React.SyntheticEvent<HTMLFormElement>) => {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
const result = schema.safeParse({ observer, observed: observed || undefined, session_id: sessionId || undefined });
|
|
|
|
|
if (!result.success) {
|
|
|
|
|
setValidationError(result.error.errors[0].message);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
await mutation.mutateAsync({
|
|
|
|
|
observer: result.data.observer,
|
|
|
|
|
observed: result.data.observed ?? null,
|
|
|
|
|
dream_type: "omni",
|
|
|
|
|
session_id: result.data.session_id ?? null,
|
|
|
|
|
});
|
|
|
|
|
reset();
|
|
|
|
|
onClose();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<FormModal open={open} title="Schedule Dream" onClose={() => { reset(); onClose(); }}>
|
|
|
|
|
<form onSubmit={handleSubmit} className="space-y-4">
|
|
|
|
|
<div>
|
2026-04-24 13:56:13 -05:00
|
|
|
<Label className="mb-1.5">
|
|
|
|
|
Observer peer ID <span style={{ color: COLOR.destructive }}>*</span>
|
|
|
|
|
</Label>
|
|
|
|
|
<Input
|
feat: wire all remaining API endpoints
- src/api/keys.ts: QK singleton for all 20+ query key patterns
- src/api/queries.ts: rewritten with QK + full mutation coverage:
deleteWorkspace, updateWorkspace, scheduleDream,
updatePeer, setPeerCard, searchPeer,
deleteSession, updateSession, cloneSession, searchSession,
createMessages, updateMessage,
useSessionPeers, addPeersToSession, setSessionPeers,
removePeersFromSession, setPeerConfig,
createConclusion, deleteConclusion,
useWebhooks, createWebhook, deleteWebhook, testWebhook,
createKey
Shared primitives (just-in-time):
- ConfirmDialog: animated modal with keyboard/click-out dismiss
- FormModal: reusable modal shell
- InlineEditor: click-to-edit with commit/cancel
New surfaces:
- WorkspaceDetail: delete + schedule dream buttons
- ScheduleDreamModal: Zod-validated observer/session form
- WebhookManager: full CRUD + test emit (new /webhooks route)
- SessionDetail: delete, clone, session search, peer membership tab
- PeerDetail: editable peer card, semantic search tab
- ConclusionBrowser: create conclusion modal (Zod), per-row delete
2026-04-24 11:25:19 -05:00
|
|
|
value={observer}
|
|
|
|
|
onChange={(e) => { setObserver(e.target.value); setValidationError(""); }}
|
|
|
|
|
placeholder="peer_id"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
2026-04-24 13:56:13 -05:00
|
|
|
<Label className="mb-1.5">
|
|
|
|
|
Observed peer ID <Caption as="span"> (optional, defaults to observer)</Caption>
|
|
|
|
|
</Label>
|
|
|
|
|
<Input
|
feat: wire all remaining API endpoints
- src/api/keys.ts: QK singleton for all 20+ query key patterns
- src/api/queries.ts: rewritten with QK + full mutation coverage:
deleteWorkspace, updateWorkspace, scheduleDream,
updatePeer, setPeerCard, searchPeer,
deleteSession, updateSession, cloneSession, searchSession,
createMessages, updateMessage,
useSessionPeers, addPeersToSession, setSessionPeers,
removePeersFromSession, setPeerConfig,
createConclusion, deleteConclusion,
useWebhooks, createWebhook, deleteWebhook, testWebhook,
createKey
Shared primitives (just-in-time):
- ConfirmDialog: animated modal with keyboard/click-out dismiss
- FormModal: reusable modal shell
- InlineEditor: click-to-edit with commit/cancel
New surfaces:
- WorkspaceDetail: delete + schedule dream buttons
- ScheduleDreamModal: Zod-validated observer/session form
- WebhookManager: full CRUD + test emit (new /webhooks route)
- SessionDetail: delete, clone, session search, peer membership tab
- PeerDetail: editable peer card, semantic search tab
- ConclusionBrowser: create conclusion modal (Zod), per-row delete
2026-04-24 11:25:19 -05:00
|
|
|
value={observed}
|
|
|
|
|
onChange={(e) => setObserved(e.target.value)}
|
|
|
|
|
placeholder="peer_id"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
2026-04-24 13:56:13 -05:00
|
|
|
<Label className="mb-1.5">
|
|
|
|
|
Session ID <Caption as="span"> (optional)</Caption>
|
|
|
|
|
</Label>
|
|
|
|
|
<Input
|
feat: wire all remaining API endpoints
- src/api/keys.ts: QK singleton for all 20+ query key patterns
- src/api/queries.ts: rewritten with QK + full mutation coverage:
deleteWorkspace, updateWorkspace, scheduleDream,
updatePeer, setPeerCard, searchPeer,
deleteSession, updateSession, cloneSession, searchSession,
createMessages, updateMessage,
useSessionPeers, addPeersToSession, setSessionPeers,
removePeersFromSession, setPeerConfig,
createConclusion, deleteConclusion,
useWebhooks, createWebhook, deleteWebhook, testWebhook,
createKey
Shared primitives (just-in-time):
- ConfirmDialog: animated modal with keyboard/click-out dismiss
- FormModal: reusable modal shell
- InlineEditor: click-to-edit with commit/cancel
New surfaces:
- WorkspaceDetail: delete + schedule dream buttons
- ScheduleDreamModal: Zod-validated observer/session form
- WebhookManager: full CRUD + test emit (new /webhooks route)
- SessionDetail: delete, clone, session search, peer membership tab
- PeerDetail: editable peer card, semantic search tab
- ConclusionBrowser: create conclusion modal (Zod), per-row delete
2026-04-24 11:25:19 -05:00
|
|
|
value={sessionId}
|
|
|
|
|
onChange={(e) => setSessionId(e.target.value)}
|
|
|
|
|
placeholder="session_id"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
{validationError && (
|
2026-04-24 13:56:13 -05:00
|
|
|
<Caption as="p" style={{ color: COLOR.destructive }}>{validationError}</Caption>
|
feat: wire all remaining API endpoints
- src/api/keys.ts: QK singleton for all 20+ query key patterns
- src/api/queries.ts: rewritten with QK + full mutation coverage:
deleteWorkspace, updateWorkspace, scheduleDream,
updatePeer, setPeerCard, searchPeer,
deleteSession, updateSession, cloneSession, searchSession,
createMessages, updateMessage,
useSessionPeers, addPeersToSession, setSessionPeers,
removePeersFromSession, setPeerConfig,
createConclusion, deleteConclusion,
useWebhooks, createWebhook, deleteWebhook, testWebhook,
createKey
Shared primitives (just-in-time):
- ConfirmDialog: animated modal with keyboard/click-out dismiss
- FormModal: reusable modal shell
- InlineEditor: click-to-edit with commit/cancel
New surfaces:
- WorkspaceDetail: delete + schedule dream buttons
- ScheduleDreamModal: Zod-validated observer/session form
- WebhookManager: full CRUD + test emit (new /webhooks route)
- SessionDetail: delete, clone, session search, peer membership tab
- PeerDetail: editable peer card, semantic search tab
- ConclusionBrowser: create conclusion modal (Zod), per-row delete
2026-04-24 11:25:19 -05:00
|
|
|
)}
|
|
|
|
|
{mutation.error && (
|
2026-04-24 13:56:13 -05:00
|
|
|
<Caption as="p" style={{ color: COLOR.destructive }}>{mutation.error.message}</Caption>
|
feat: wire all remaining API endpoints
- src/api/keys.ts: QK singleton for all 20+ query key patterns
- src/api/queries.ts: rewritten with QK + full mutation coverage:
deleteWorkspace, updateWorkspace, scheduleDream,
updatePeer, setPeerCard, searchPeer,
deleteSession, updateSession, cloneSession, searchSession,
createMessages, updateMessage,
useSessionPeers, addPeersToSession, setSessionPeers,
removePeersFromSession, setPeerConfig,
createConclusion, deleteConclusion,
useWebhooks, createWebhook, deleteWebhook, testWebhook,
createKey
Shared primitives (just-in-time):
- ConfirmDialog: animated modal with keyboard/click-out dismiss
- FormModal: reusable modal shell
- InlineEditor: click-to-edit with commit/cancel
New surfaces:
- WorkspaceDetail: delete + schedule dream buttons
- ScheduleDreamModal: Zod-validated observer/session form
- WebhookManager: full CRUD + test emit (new /webhooks route)
- SessionDetail: delete, clone, session search, peer membership tab
- PeerDetail: editable peer card, semantic search tab
- ConclusionBrowser: create conclusion modal (Zod), per-row delete
2026-04-24 11:25:19 -05:00
|
|
|
)}
|
|
|
|
|
<div className="flex justify-end gap-2 pt-2">
|
2026-04-24 13:56:13 -05:00
|
|
|
<Button
|
feat: wire all remaining API endpoints
- src/api/keys.ts: QK singleton for all 20+ query key patterns
- src/api/queries.ts: rewritten with QK + full mutation coverage:
deleteWorkspace, updateWorkspace, scheduleDream,
updatePeer, setPeerCard, searchPeer,
deleteSession, updateSession, cloneSession, searchSession,
createMessages, updateMessage,
useSessionPeers, addPeersToSession, setSessionPeers,
removePeersFromSession, setPeerConfig,
createConclusion, deleteConclusion,
useWebhooks, createWebhook, deleteWebhook, testWebhook,
createKey
Shared primitives (just-in-time):
- ConfirmDialog: animated modal with keyboard/click-out dismiss
- FormModal: reusable modal shell
- InlineEditor: click-to-edit with commit/cancel
New surfaces:
- WorkspaceDetail: delete + schedule dream buttons
- ScheduleDreamModal: Zod-validated observer/session form
- WebhookManager: full CRUD + test emit (new /webhooks route)
- SessionDetail: delete, clone, session search, peer membership tab
- PeerDetail: editable peer card, semantic search tab
- ConclusionBrowser: create conclusion modal (Zod), per-row delete
2026-04-24 11:25:19 -05:00
|
|
|
type="button"
|
2026-04-24 13:56:13 -05:00
|
|
|
variant="surface"
|
|
|
|
|
size="sm"
|
feat: wire all remaining API endpoints
- src/api/keys.ts: QK singleton for all 20+ query key patterns
- src/api/queries.ts: rewritten with QK + full mutation coverage:
deleteWorkspace, updateWorkspace, scheduleDream,
updatePeer, setPeerCard, searchPeer,
deleteSession, updateSession, cloneSession, searchSession,
createMessages, updateMessage,
useSessionPeers, addPeersToSession, setSessionPeers,
removePeersFromSession, setPeerConfig,
createConclusion, deleteConclusion,
useWebhooks, createWebhook, deleteWebhook, testWebhook,
createKey
Shared primitives (just-in-time):
- ConfirmDialog: animated modal with keyboard/click-out dismiss
- FormModal: reusable modal shell
- InlineEditor: click-to-edit with commit/cancel
New surfaces:
- WorkspaceDetail: delete + schedule dream buttons
- ScheduleDreamModal: Zod-validated observer/session form
- WebhookManager: full CRUD + test emit (new /webhooks route)
- SessionDetail: delete, clone, session search, peer membership tab
- PeerDetail: editable peer card, semantic search tab
- ConclusionBrowser: create conclusion modal (Zod), per-row delete
2026-04-24 11:25:19 -05:00
|
|
|
onClick={() => { reset(); onClose(); }}
|
|
|
|
|
>
|
|
|
|
|
Cancel
|
2026-04-24 13:56:13 -05:00
|
|
|
</Button>
|
|
|
|
|
<Button
|
feat: wire all remaining API endpoints
- src/api/keys.ts: QK singleton for all 20+ query key patterns
- src/api/queries.ts: rewritten with QK + full mutation coverage:
deleteWorkspace, updateWorkspace, scheduleDream,
updatePeer, setPeerCard, searchPeer,
deleteSession, updateSession, cloneSession, searchSession,
createMessages, updateMessage,
useSessionPeers, addPeersToSession, setSessionPeers,
removePeersFromSession, setPeerConfig,
createConclusion, deleteConclusion,
useWebhooks, createWebhook, deleteWebhook, testWebhook,
createKey
Shared primitives (just-in-time):
- ConfirmDialog: animated modal with keyboard/click-out dismiss
- FormModal: reusable modal shell
- InlineEditor: click-to-edit with commit/cancel
New surfaces:
- WorkspaceDetail: delete + schedule dream buttons
- ScheduleDreamModal: Zod-validated observer/session form
- WebhookManager: full CRUD + test emit (new /webhooks route)
- SessionDetail: delete, clone, session search, peer membership tab
- PeerDetail: editable peer card, semantic search tab
- ConclusionBrowser: create conclusion modal (Zod), per-row delete
2026-04-24 11:25:19 -05:00
|
|
|
type="submit"
|
2026-04-24 13:56:13 -05:00
|
|
|
variant="accent"
|
|
|
|
|
size="sm"
|
feat: wire all remaining API endpoints
- src/api/keys.ts: QK singleton for all 20+ query key patterns
- src/api/queries.ts: rewritten with QK + full mutation coverage:
deleteWorkspace, updateWorkspace, scheduleDream,
updatePeer, setPeerCard, searchPeer,
deleteSession, updateSession, cloneSession, searchSession,
createMessages, updateMessage,
useSessionPeers, addPeersToSession, setSessionPeers,
removePeersFromSession, setPeerConfig,
createConclusion, deleteConclusion,
useWebhooks, createWebhook, deleteWebhook, testWebhook,
createKey
Shared primitives (just-in-time):
- ConfirmDialog: animated modal with keyboard/click-out dismiss
- FormModal: reusable modal shell
- InlineEditor: click-to-edit with commit/cancel
New surfaces:
- WorkspaceDetail: delete + schedule dream buttons
- ScheduleDreamModal: Zod-validated observer/session form
- WebhookManager: full CRUD + test emit (new /webhooks route)
- SessionDetail: delete, clone, session search, peer membership tab
- PeerDetail: editable peer card, semantic search tab
- ConclusionBrowser: create conclusion modal (Zod), per-row delete
2026-04-24 11:25:19 -05:00
|
|
|
disabled={mutation.isPending}
|
|
|
|
|
>
|
|
|
|
|
{mutation.isPending ? "Scheduling..." : "Schedule"}
|
2026-04-24 13:56:13 -05:00
|
|
|
</Button>
|
feat: wire all remaining API endpoints
- src/api/keys.ts: QK singleton for all 20+ query key patterns
- src/api/queries.ts: rewritten with QK + full mutation coverage:
deleteWorkspace, updateWorkspace, scheduleDream,
updatePeer, setPeerCard, searchPeer,
deleteSession, updateSession, cloneSession, searchSession,
createMessages, updateMessage,
useSessionPeers, addPeersToSession, setSessionPeers,
removePeersFromSession, setPeerConfig,
createConclusion, deleteConclusion,
useWebhooks, createWebhook, deleteWebhook, testWebhook,
createKey
Shared primitives (just-in-time):
- ConfirmDialog: animated modal with keyboard/click-out dismiss
- FormModal: reusable modal shell
- InlineEditor: click-to-edit with commit/cancel
New surfaces:
- WorkspaceDetail: delete + schedule dream buttons
- ScheduleDreamModal: Zod-validated observer/session form
- WebhookManager: full CRUD + test emit (new /webhooks route)
- SessionDetail: delete, clone, session search, peer membership tab
- PeerDetail: editable peer card, semantic search tab
- ConclusionBrowser: create conclusion modal (Zod), per-row delete
2026-04-24 11:25:19 -05:00
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
</FormModal>
|
|
|
|
|
);
|
|
|
|
|
}
|