@schemavaults/ui 0.118.0 → 0.120.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ui/agent-sessions/agent-sessions-context.d.ts +72 -0
- package/dist/components/ui/agent-sessions/agent-sessions-context.js +41 -0
- package/dist/components/ui/agent-sessions/agent-sessions-context.js.map +1 -0
- package/dist/components/ui/agent-sessions/agent-sessions-dialog-context.d.ts +10 -0
- package/dist/components/ui/agent-sessions/agent-sessions-dialog-context.js +16 -0
- package/dist/components/ui/agent-sessions/agent-sessions-dialog-context.js.map +1 -0
- package/dist/components/ui/agent-sessions/agent-sessions-dialog.d.ts +61 -0
- package/dist/components/ui/agent-sessions/agent-sessions-dialog.js +113 -0
- package/dist/components/ui/agent-sessions/agent-sessions-dialog.js.map +1 -0
- package/dist/components/ui/agent-sessions/agent-sessions-draft-store.d.ts +20 -0
- package/dist/components/ui/agent-sessions/agent-sessions-draft-store.js +38 -0
- package/dist/components/ui/agent-sessions/agent-sessions-draft-store.js.map +1 -0
- package/dist/components/ui/agent-sessions/agent-sessions-list.d.ts +126 -0
- package/dist/components/ui/agent-sessions/agent-sessions-list.js +191 -0
- package/dist/components/ui/agent-sessions/agent-sessions-list.js.map +1 -0
- package/dist/components/ui/agent-sessions/agent-sessions-main.d.ts +93 -0
- package/dist/components/ui/agent-sessions/agent-sessions-main.js +67 -0
- package/dist/components/ui/agent-sessions/agent-sessions-main.js.map +1 -0
- package/dist/components/ui/agent-sessions/agent-sessions-model.d.ts +103 -0
- package/dist/components/ui/agent-sessions/agent-sessions-model.js +176 -0
- package/dist/components/ui/agent-sessions/agent-sessions-model.js.map +1 -0
- package/dist/components/ui/agent-sessions/agent-sessions-prompt-input.d.ts +37 -0
- package/dist/components/ui/agent-sessions/agent-sessions-prompt-input.js +49 -0
- package/dist/components/ui/agent-sessions/agent-sessions-prompt-input.js.map +1 -0
- package/dist/components/ui/agent-sessions/agent-sessions-sidebar.d.ts +84 -0
- package/dist/components/ui/agent-sessions/agent-sessions-sidebar.js +148 -0
- package/dist/components/ui/agent-sessions/agent-sessions-sidebar.js.map +1 -0
- package/dist/components/ui/agent-sessions/agent-sessions-start.d.ts +63 -0
- package/dist/components/ui/agent-sessions/agent-sessions-start.js +49 -0
- package/dist/components/ui/agent-sessions/agent-sessions-start.js.map +1 -0
- package/dist/components/ui/agent-sessions/agent-sessions.d.ts +71 -0
- package/dist/components/ui/agent-sessions/agent-sessions.js +201 -0
- package/dist/components/ui/agent-sessions/agent-sessions.js.map +1 -0
- package/dist/components/ui/agent-sessions/index.d.ts +20 -0
- package/dist/components/ui/agent-sessions/index.js +11 -0
- package/dist/components/ui/agent-sessions/index.js.map +1 -0
- package/dist/components/ui/agent-sessions/local-day.d.ts +8 -0
- package/dist/components/ui/agent-sessions/local-day.js +17 -0
- package/dist/components/ui/agent-sessions/local-day.js.map +1 -0
- package/dist/components/ui/agent-sessions/merge-refs.d.ts +6 -0
- package/dist/components/ui/agent-sessions/merge-refs.js +17 -0
- package/dist/components/ui/agent-sessions/merge-refs.js.map +1 -0
- package/dist/components/ui/aspect-ratio/aspect-ratio.d.ts +1 -1
- package/dist/components/ui/chip/chip.d.ts +1 -1
- package/dist/components/ui/countdown/countdown.d.ts +3 -3
- package/dist/components/ui/index.d.ts +4 -0
- package/dist/components/ui/index.js +2 -0
- package/dist/components/ui/index.js.map +1 -1
- package/dist/components/ui/mark/mark.d.ts +1 -1
- package/dist/components/ui/onboarding-checklist/index.d.ts +3 -0
- package/dist/components/ui/onboarding-checklist/index.js +3 -0
- package/dist/components/ui/onboarding-checklist/index.js.map +1 -0
- package/dist/components/ui/onboarding-checklist/onboarding-checklist.d.ts +71 -0
- package/dist/components/ui/onboarding-checklist/onboarding-checklist.js +93 -0
- package/dist/components/ui/onboarding-checklist/onboarding-checklist.js.map +1 -0
- package/dist/components/ui/pagination/pagination.d.ts +1 -1
- package/dist/components/ui/relative-time/relative-time.d.ts +1 -1
- package/dist/components/ui/ribbon/ribbon.d.ts +1 -1
- package/dist/components/ui/segmented-bar/segmented-bar.d.ts +1 -1
- package/dist/components/ui/uptime-bar/uptime-bar.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React-free helpers behind `<AgentSessions>`: the session summary shape,
|
|
3
|
+
* search, recency sorting and grouping. Kept free of React so they can be
|
|
4
|
+
* unit tested and reused on the server (e.g. to pre-group a session list).
|
|
5
|
+
*/
|
|
6
|
+
import { toTimestamp, } from "../relative-time/format-relative-time";
|
|
7
|
+
import { startOfLocalDay } from "./local-day";
|
|
8
|
+
/* ------------------------------------------------------------------ */
|
|
9
|
+
/* Session summary */
|
|
10
|
+
/* ------------------------------------------------------------------ */
|
|
11
|
+
export const agentSessionStatusIds = [
|
|
12
|
+
"idle",
|
|
13
|
+
"running",
|
|
14
|
+
"awaiting-input",
|
|
15
|
+
"completed",
|
|
16
|
+
"failed",
|
|
17
|
+
];
|
|
18
|
+
/** Screen-reader labels for each status, read after the session title. */
|
|
19
|
+
export const agentSessionStatusLabels = {
|
|
20
|
+
idle: "Idle",
|
|
21
|
+
running: "Running",
|
|
22
|
+
"awaiting-input": "Awaiting input",
|
|
23
|
+
completed: "Completed",
|
|
24
|
+
failed: "Failed",
|
|
25
|
+
};
|
|
26
|
+
/** `updatedAt` in epoch ms, or `null` when it is missing or unparseable. */
|
|
27
|
+
export function getAgentSessionTimestamp(session) {
|
|
28
|
+
if (session.updatedAt === undefined)
|
|
29
|
+
return null;
|
|
30
|
+
const ms = toTimestamp(session.updatedAt);
|
|
31
|
+
return Number.isFinite(ms) ? ms : null;
|
|
32
|
+
}
|
|
33
|
+
/* ------------------------------------------------------------------ */
|
|
34
|
+
/* Sorting */
|
|
35
|
+
/* ------------------------------------------------------------------ */
|
|
36
|
+
/**
|
|
37
|
+
* Most recently updated first. Sessions without a usable `updatedAt` go
|
|
38
|
+
* last; ties keep their input order (the sort is stable).
|
|
39
|
+
*/
|
|
40
|
+
export function sortAgentSessionsByRecency(sessions) {
|
|
41
|
+
return sessions
|
|
42
|
+
.map((session, index) => ({
|
|
43
|
+
session,
|
|
44
|
+
index,
|
|
45
|
+
time: getAgentSessionTimestamp(session),
|
|
46
|
+
}))
|
|
47
|
+
.sort((a, b) => {
|
|
48
|
+
if (a.time === b.time)
|
|
49
|
+
return a.index - b.index;
|
|
50
|
+
if (a.time === null)
|
|
51
|
+
return 1;
|
|
52
|
+
if (b.time === null)
|
|
53
|
+
return -1;
|
|
54
|
+
return b.time - a.time;
|
|
55
|
+
})
|
|
56
|
+
.map((entry) => entry.session);
|
|
57
|
+
}
|
|
58
|
+
/* ------------------------------------------------------------------ */
|
|
59
|
+
/* Search */
|
|
60
|
+
/* ------------------------------------------------------------------ */
|
|
61
|
+
/**
|
|
62
|
+
* Case-insensitive match of every whitespace-separated term in `query`
|
|
63
|
+
* against the session's title and preview. An empty query matches all.
|
|
64
|
+
*/
|
|
65
|
+
export function matchesAgentSessionQuery(session, query) {
|
|
66
|
+
const terms = query
|
|
67
|
+
.trim()
|
|
68
|
+
.toLocaleLowerCase()
|
|
69
|
+
.split(/\s+/)
|
|
70
|
+
.filter((term) => term.length > 0);
|
|
71
|
+
if (terms.length === 0)
|
|
72
|
+
return true;
|
|
73
|
+
const haystack = `${session.title}\n${session.preview ?? ""}`.toLocaleLowerCase();
|
|
74
|
+
return terms.every((term) => haystack.includes(term));
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The sessions `matches` accepts for `query`, in their input order. The
|
|
78
|
+
* matcher runs even for an empty query, so a custom one can also filter on
|
|
79
|
+
* other state (a status or project filter, say).
|
|
80
|
+
*/
|
|
81
|
+
export function filterAgentSessions(sessions, query, matches = matchesAgentSessionQuery) {
|
|
82
|
+
return sessions.filter((session) => matches(session, query));
|
|
83
|
+
}
|
|
84
|
+
const UNGROUPED = { id: "", label: "" };
|
|
85
|
+
/**
|
|
86
|
+
* Buckets `sessions` by `getGroup`, keeping each group's sessions in input
|
|
87
|
+
* order. Groups listed in `order` come first, in that order; every other
|
|
88
|
+
* group follows in order of first appearance. Empty groups are dropped.
|
|
89
|
+
*/
|
|
90
|
+
export function groupAgentSessions(sessions, getGroup, order = []) {
|
|
91
|
+
const groups = new Map();
|
|
92
|
+
for (const session of sessions) {
|
|
93
|
+
const raw = getGroup(session);
|
|
94
|
+
const key = raw === null || raw === undefined
|
|
95
|
+
? UNGROUPED
|
|
96
|
+
: typeof raw === "string"
|
|
97
|
+
? { id: raw, label: raw }
|
|
98
|
+
: raw;
|
|
99
|
+
let group = groups.get(key.id);
|
|
100
|
+
if (group === undefined) {
|
|
101
|
+
group = { id: key.id, label: key.label, sessions: [] };
|
|
102
|
+
groups.set(key.id, group);
|
|
103
|
+
}
|
|
104
|
+
group.sessions.push(session);
|
|
105
|
+
}
|
|
106
|
+
const ordered = [];
|
|
107
|
+
for (const id of order) {
|
|
108
|
+
const group = groups.get(id);
|
|
109
|
+
if (group !== undefined) {
|
|
110
|
+
ordered.push(group);
|
|
111
|
+
groups.delete(id);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return [...ordered, ...groups.values()];
|
|
115
|
+
}
|
|
116
|
+
/* ------------------------------------------------------------------ */
|
|
117
|
+
/* Recency groups */
|
|
118
|
+
/* ------------------------------------------------------------------ */
|
|
119
|
+
export const agentSessionRecencyGroupIds = [
|
|
120
|
+
"pinned",
|
|
121
|
+
"today",
|
|
122
|
+
"yesterday",
|
|
123
|
+
"previous-7-days",
|
|
124
|
+
"previous-30-days",
|
|
125
|
+
"older",
|
|
126
|
+
];
|
|
127
|
+
export const agentSessionRecencyGroupLabels = {
|
|
128
|
+
pinned: "Pinned",
|
|
129
|
+
today: "Today",
|
|
130
|
+
yesterday: "Yesterday",
|
|
131
|
+
"previous-7-days": "Previous 7 days",
|
|
132
|
+
"previous-30-days": "Previous 30 days",
|
|
133
|
+
older: "Older",
|
|
134
|
+
};
|
|
135
|
+
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
136
|
+
/**
|
|
137
|
+
* Which calendar-day bucket a session falls in, in the viewer's local time
|
|
138
|
+
* zone. Pinned sessions are always `pinned`; sessions without a usable
|
|
139
|
+
* `updatedAt` are `older`; future timestamps count as `today`.
|
|
140
|
+
*/
|
|
141
|
+
export function getAgentSessionRecencyGroup(session, now = Date.now()) {
|
|
142
|
+
if (session.pinned === true)
|
|
143
|
+
return "pinned";
|
|
144
|
+
const time = getAgentSessionTimestamp(session);
|
|
145
|
+
if (time === null)
|
|
146
|
+
return "older";
|
|
147
|
+
const today = startOfLocalDay(toTimestamp(now));
|
|
148
|
+
if (time >= today)
|
|
149
|
+
return "today";
|
|
150
|
+
// Rounding absorbs the 23- and 25-hour days around DST changes.
|
|
151
|
+
const daysAgo = Math.round((today - startOfLocalDay(time)) / DAY_MS);
|
|
152
|
+
if (daysAgo <= 1)
|
|
153
|
+
return "yesterday";
|
|
154
|
+
if (daysAgo <= 7)
|
|
155
|
+
return "previous-7-days";
|
|
156
|
+
if (daysAgo <= 30)
|
|
157
|
+
return "previous-30-days";
|
|
158
|
+
return "older";
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Groups sessions into Pinned / Today / Yesterday / Previous 7 days /
|
|
162
|
+
* Previous 30 days / Older, in that order. Sessions keep their input order
|
|
163
|
+
* within a group — sort them first (see `sortAgentSessionsByRecency`).
|
|
164
|
+
*/
|
|
165
|
+
export function groupAgentSessionsByRecency(sessions, options = {}) {
|
|
166
|
+
const now = options.now ?? Date.now();
|
|
167
|
+
const labels = {
|
|
168
|
+
...agentSessionRecencyGroupLabels,
|
|
169
|
+
...options.labels,
|
|
170
|
+
};
|
|
171
|
+
return groupAgentSessions(sessions, (session) => {
|
|
172
|
+
const id = getAgentSessionRecencyGroup(session, now);
|
|
173
|
+
return { id, label: labels[id] };
|
|
174
|
+
}, agentSessionRecencyGroupIds);
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=agent-sessions-model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-sessions-model.js","sourceRoot":"","sources":["../../../../src/components/ui/agent-sessions/agent-sessions-model.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,WAAW,GAEZ,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,wEAAwE;AACxE,wEAAwE;AACxE,wEAAwE;AAExE,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,MAAM;IACN,SAAS;IACT,gBAAgB;IAChB,WAAW;IACX,QAAQ;CAC4B,CAAC;AAQvC,0EAA0E;AAC1E,MAAM,CAAC,MAAM,wBAAwB,GAEjC;IACF,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;IAClB,gBAAgB,EAAE,gBAAgB;IAClC,SAAS,EAAE,WAAW;IACtB,MAAM,EAAE,QAAQ;CACjB,CAAC;AA8BF,4EAA4E;AAC5E,MAAM,UAAU,wBAAwB,CAAC,OAAqB;IAC5D,IAAI,OAAO,CAAC,SAAS,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACjD,MAAM,EAAE,GAAW,WAAW,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAClD,OAAO,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACzC,CAAC;AAED,wEAAwE;AACxE,wEAAwE;AACxE,wEAAwE;AAExE;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CACxC,QAAsB;IAEtB,OAAO,QAAQ;SACZ,GAAG,CAAC,CAAC,OAAU,EAAE,KAAa,EAAE,EAAE,CAAC,CAAC;QACnC,OAAO;QACP,KAAK;QACL,IAAI,EAAE,wBAAwB,CAAC,OAAO,CAAC;KACxC,CAAC,CAAC;SACF,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAU,EAAE;QACrB,IAAI,CAAC,C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B,CAAC;IAC3C,IAAI,OAAO,IAAI,EAAE;QAAE,OAAO,kBAAkB,CAAC;IAC7C,OAAO,OAAO,CAAC;AACjB,CAAC;AASD;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CACzC,QAAsB,EACtB,UAA8C,EAAE;IAEhD,MAAM,GAAG,GAAsB,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;IACzD,MAAM,MAAM,GAA+C;QACzD,GAAG,8BAA8B;QACjC,GAAG,OAAO,CAAC,MAAM;KAClB,CAAC;IACF,OAAO,kBAAkB,CACvB,QAAQ,EACR,CAAC,OAAU,EAAwB,EAAE;QACnC,MAAM,EAAE,GAA+B,2BAA2B,CAChE,OAAO,EACP,GAAG,CACJ,CAAC;QACF,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC;IACnC,CAAC,EACD,2BAA2B,CAC5B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type ReactElement } from "react";
|
|
2
|
+
import { type PromptInputProps } from "../prompt-input/prompt-input";
|
|
3
|
+
import type { AgentSession } from "./agent-sessions-model";
|
|
4
|
+
export interface AgentSessionsSubmitDetails<TSession extends AgentSession = AgentSession> {
|
|
5
|
+
/** The session the prompt was sent in, or `null` from the new-session screen. */
|
|
6
|
+
sessionId: string | null;
|
|
7
|
+
/** That session's summary, if it is in `sessions`. */
|
|
8
|
+
session: TSession | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Switch to a session — e.g. to the one you just created from the
|
|
11
|
+
* new-session screen, when `activeSessionId` is uncontrolled.
|
|
12
|
+
*/
|
|
13
|
+
selectSession: (sessionId: string) => void;
|
|
14
|
+
}
|
|
15
|
+
export interface AgentSessionsPromptInputProps<TSession extends AgentSession = AgentSession> extends Omit<PromptInputProps, "value" | "defaultValue" | "onSubmit"> {
|
|
16
|
+
/**
|
|
17
|
+
* Fires on Enter or the submit button with the (trimmed) prompt, plus
|
|
18
|
+
* which session it was sent in. From the new-session screen, create the
|
|
19
|
+
* session here and switch to it.
|
|
20
|
+
*/
|
|
21
|
+
onSubmit?: (value: string, details: AgentSessionsSubmitDetails<TSession>) => void;
|
|
22
|
+
/** Empty the draft once the prompt is submitted. Default: true. */
|
|
23
|
+
clearOnSubmit?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* `PromptInput`, wired to the session it is shown in: it keeps a separate
|
|
27
|
+
* draft for every session (and for the new-session screen) so switching
|
|
28
|
+
* away and back never loses what was typed, and `onSubmit` says which
|
|
29
|
+
* session the prompt belongs to. Compose it exactly like `PromptInput` —
|
|
30
|
+
* `PromptInputTextarea`, `PromptInputToolbar`, your own actions and
|
|
31
|
+
* inputs, `PromptInputSubmit`.
|
|
32
|
+
*/
|
|
33
|
+
declare function AgentSessionsPromptInput<TSession extends AgentSession = AgentSession>({ onSubmit, onValueChange, clearOnSubmit, children, ...props }: AgentSessionsPromptInputProps<TSession>): ReactElement;
|
|
34
|
+
declare namespace AgentSessionsPromptInput {
|
|
35
|
+
var displayName: string;
|
|
36
|
+
}
|
|
37
|
+
export { AgentSessionsPromptInput };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback, useEffect } from "react";
|
|
4
|
+
import { PromptInput, usePromptInput, } from "../prompt-input/prompt-input";
|
|
5
|
+
import { useAgentSessionDraft, useAgentSessionsContext, } from "./agent-sessions-context";
|
|
6
|
+
/** Hands the prompt's textarea to `focusComposer()`. Renders nothing. */
|
|
7
|
+
function AgentSessionsComposerRegistration() {
|
|
8
|
+
const { textareaRef } = usePromptInput();
|
|
9
|
+
const { composerTextareaRef } = useAgentSessionsContext("AgentSessionsPromptInput");
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
composerTextareaRef.current = textareaRef;
|
|
12
|
+
return () => {
|
|
13
|
+
if (composerTextareaRef.current === textareaRef) {
|
|
14
|
+
composerTextareaRef.current = null;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}, [composerTextareaRef, textareaRef]);
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* `PromptInput`, wired to the session it is shown in: it keeps a separate
|
|
22
|
+
* draft for every session (and for the new-session screen) so switching
|
|
23
|
+
* away and back never loses what was typed, and `onSubmit` says which
|
|
24
|
+
* session the prompt belongs to. Compose it exactly like `PromptInput` —
|
|
25
|
+
* `PromptInputTextarea`, `PromptInputToolbar`, your own actions and
|
|
26
|
+
* inputs, `PromptInputSubmit`.
|
|
27
|
+
*/
|
|
28
|
+
function AgentSessionsPromptInput({ onSubmit, onValueChange, clearOnSubmit = true, children, ...props }) {
|
|
29
|
+
const ctx = useAgentSessionsContext("AgentSessionsPromptInput");
|
|
30
|
+
const [value, setValue] = useAgentSessionDraft();
|
|
31
|
+
const { activeSessionId, activeSession, selectSession } = ctx;
|
|
32
|
+
const handleValueChange = useCallback((next) => {
|
|
33
|
+
setValue(next);
|
|
34
|
+
onValueChange?.(next);
|
|
35
|
+
}, [onValueChange, setValue]);
|
|
36
|
+
const handleSubmit = useCallback((submitted) => {
|
|
37
|
+
if (clearOnSubmit)
|
|
38
|
+
setValue("");
|
|
39
|
+
onSubmit?.(submitted, {
|
|
40
|
+
sessionId: activeSessionId,
|
|
41
|
+
session: activeSession,
|
|
42
|
+
selectSession,
|
|
43
|
+
});
|
|
44
|
+
}, [activeSession, activeSessionId, clearOnSubmit, onSubmit, selectSession, setValue]);
|
|
45
|
+
return (_jsxs(PromptInput, { "data-session-id": activeSessionId ?? undefined, value: value, onValueChange: handleValueChange, onSubmit: handleSubmit, ...props, children: [_jsx(AgentSessionsComposerRegistration, {}), children] }));
|
|
46
|
+
}
|
|
47
|
+
AgentSessionsPromptInput.displayName = "AgentSessionsPromptInput";
|
|
48
|
+
export { AgentSessionsPromptInput };
|
|
49
|
+
//# sourceMappingURL=agent-sessions-prompt-input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-sessions-prompt-input.js","sourceRoot":"","sources":["../../../../src/components/ui/agent-sessions/agent-sessions-prompt-input.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,WAAW,EAAE,SAAS,EAAqB,MAAM,OAAO,CAAC;AAElE,OAAO,EACL,WAAW,EACX,cAAc,GAEf,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,0BAA0B,CAAC;AAiClC,yEAAyE;AACzE,SAAS,iCAAiC;IACxC,MAAM,EAAE,WAAW,EAAE,GAAG,cAAc,EAAE,CAAC;IACzC,MAAM,EAAE,mBAAmB,EAAE,GAAG,uBAAuB,CACrD,0BAA0B,CAC3B,CAAC;IACF,SAAS,CAAC,GAAiB,EAAE;QAC3B,mBAAmB,CAAC,OAAO,GAAG,WAAW,CAAC;QAC1C,OAAO,GAAS,EAAE;YAChB,IAAI,mBAAmB,CAAC,OAAO,KAAK,WAAW,EAAE,CAAC;gBAChD,mBAAmB,CAAC,OAAO,GAAG,IAAI,CAAC;YACrC,CAAC;QACH,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,mBAAmB,EAAE,WAAW,CAAC,CAAC,CAAC;IACvC,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,wBAAwB,CAA+C,EAC9E,QAAQ,EACR,aAAa,EACb,aAAa,GAAG,IAAI,EACpB,QAAQ,EACR,GAAG,KAAK,EACgC;IACxC,MAAM,GAAG,GAAG,uBAAuB,CAAW,0BAA0B,CAAC,CAAC;IAC1E,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,oBAAoB,EAAE,CAAC;IACjD,MAAM,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,GAAG,GAAG,CAAC;IAE9D,MAAM,iBAAiB,GAAG,WAAW,CACnC,CAAC,IAAY,EAAQ,EAAE;QACrB,QAAQ,CAAC,IAAI,CAAC,CAAC;QACf,aAAa,EAAE,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC,EACD,CAAC,aAAa,EAAE,QAAQ,CAAC,CAC1B,CAAC;IAEF,MAAM,YAAY,GAAG,WAAW,CAC9B,CAAC,SAAiB,EAAQ,EAAE;QAC1B,IAAI,aAAa;YAAE,QAAQ,CAAC,EAAE,CAAC,CAAC;QAChC,QAAQ,EAAE,CAAC,SAAS,EAAE;YACpB,SAAS,EAAE,eAAe;YAC1B,OAAO,EAAE,aAAa;YACtB,aAAa;SACd,CAAC,CAAC;IACL,CAAC,EACD,CAAC,aAAa,EAAE,eAAe,EAAE,aAAa,EAAE,QAAQ,EAAE,aAAa,EAAE,QAAQ,CAAC,CACnF,CAAC;IAEF,OAAO,CACL,MAAC,WAAW,uBACO,eAAe,IAAI,SAAS,EAC7C,KAAK,EAAE,KAAK,EACZ,aAAa,EAAE,iBAAiB,EAChC,QAAQ,EAAE,YAAY,KAClB,KAAK,aAET,KAAC,iCAAiC,KAAG,EACpC,QAAQ,IACG,CACf,CAAC;AACJ,CAAC;AACD,wBAAwB,CAAC,WAAW,GAAG,0BAA0B,CAAC;AAElE,OAAO,EAAE,wBAAwB,EAAE,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { type HTMLAttributes, type InputHTMLAttributes, type ReactElement, type ReactNode, type Ref } from "react";
|
|
2
|
+
import { type ButtonProps } from "../button/button";
|
|
3
|
+
export interface AgentSessionsSidebarProps extends HTMLAttributes<HTMLElement> {
|
|
4
|
+
/**
|
|
5
|
+
* The sidebar's contents. Omit for the default: a header with a
|
|
6
|
+
* new-session button and search, above the session list.
|
|
7
|
+
*/
|
|
8
|
+
children?: ReactNode;
|
|
9
|
+
/** Accessible name of the sidebar landmark. Default: "Sessions". */
|
|
10
|
+
"aria-label"?: string;
|
|
11
|
+
/** Class for the overlay-mode scrim behind the drawer. */
|
|
12
|
+
scrimClassName?: string;
|
|
13
|
+
ref?: Ref<HTMLElement>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The session list's container. Inline, it is a column the toggle collapses
|
|
17
|
+
* to nothing; as an overlay, it is a drawer over the conversation that
|
|
18
|
+
* Escape, a click on the scrim, or picking a session closes. While the
|
|
19
|
+
* drawer is open the conversation is `inert`, so focus stays in it.
|
|
20
|
+
*/
|
|
21
|
+
declare function AgentSessionsSidebar({ children, className, scrimClassName, "aria-label": ariaLabel, ref, ...props }: AgentSessionsSidebarProps): ReactElement;
|
|
22
|
+
declare namespace AgentSessionsSidebar {
|
|
23
|
+
var displayName: string;
|
|
24
|
+
}
|
|
25
|
+
export interface AgentSessionsSidebarSectionProps extends HTMLAttributes<HTMLDivElement> {
|
|
26
|
+
ref?: Ref<HTMLDivElement>;
|
|
27
|
+
}
|
|
28
|
+
/** Top of the sidebar: new-session button, search, filters — your call. */
|
|
29
|
+
declare function AgentSessionsSidebarHeader({ className, ref, ...props }: AgentSessionsSidebarSectionProps): ReactElement;
|
|
30
|
+
declare namespace AgentSessionsSidebarHeader {
|
|
31
|
+
var displayName: string;
|
|
32
|
+
}
|
|
33
|
+
/** The scrolling middle of the sidebar. Put `<AgentSessionsList>` here. */
|
|
34
|
+
declare function AgentSessionsSidebarContent({ className, ref, ...props }: AgentSessionsSidebarSectionProps): ReactElement;
|
|
35
|
+
declare namespace AgentSessionsSidebarContent {
|
|
36
|
+
var displayName: string;
|
|
37
|
+
}
|
|
38
|
+
/** Bottom of the sidebar, e.g. the signed-in user or a settings link. */
|
|
39
|
+
declare function AgentSessionsSidebarFooter({ className, ref, ...props }: AgentSessionsSidebarSectionProps): ReactElement;
|
|
40
|
+
declare namespace AgentSessionsSidebarFooter {
|
|
41
|
+
var displayName: string;
|
|
42
|
+
}
|
|
43
|
+
export interface AgentSessionsSidebarToggleProps extends ButtonProps {
|
|
44
|
+
/** Accessible label while the sidebar is hidden. Default: "Show sessions". */
|
|
45
|
+
openLabel?: string;
|
|
46
|
+
/** Accessible label while the sidebar is shown. Default: "Hide sessions". */
|
|
47
|
+
closeLabel?: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Shows and hides the sidebar. Call `event.preventDefault()` in `onClick`
|
|
51
|
+
* to skip the toggle. Default content: a panel icon.
|
|
52
|
+
*/
|
|
53
|
+
declare function AgentSessionsSidebarToggle({ className, children, onClick, openLabel, closeLabel, variant, size, ...props }: AgentSessionsSidebarToggleProps): ReactElement;
|
|
54
|
+
declare namespace AgentSessionsSidebarToggle {
|
|
55
|
+
var displayName: string;
|
|
56
|
+
}
|
|
57
|
+
export interface AgentSessionsNewSessionButtonProps extends ButtonProps {
|
|
58
|
+
/** Leading icon. Default: a pen-on-square. Pass `null` for none. */
|
|
59
|
+
icon?: ReactNode;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Switches to the new-session screen. Call `event.preventDefault()` in
|
|
63
|
+
* `onClick` to run your own flow instead. Default label: "New session".
|
|
64
|
+
*/
|
|
65
|
+
declare function AgentSessionsNewSessionButton({ className, children, icon, onClick, variant, size, ...props }: AgentSessionsNewSessionButtonProps): ReactElement;
|
|
66
|
+
declare namespace AgentSessionsNewSessionButton {
|
|
67
|
+
var displayName: string;
|
|
68
|
+
}
|
|
69
|
+
export interface AgentSessionsSearchProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "value" | "defaultValue" | "type"> {
|
|
70
|
+
/** Class for the wrapper around the input, icon and clear button. */
|
|
71
|
+
wrapperClassName?: string;
|
|
72
|
+
/** Accessible label of the clear button. Default: "Clear search". */
|
|
73
|
+
clearLabel?: string;
|
|
74
|
+
ref?: Ref<HTMLInputElement>;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Filters `<AgentSessionsList>` by the sessions' titles and previews (or by
|
|
78
|
+
* your own `filter`). Bound to the `searchQuery` of `<AgentSessions>`.
|
|
79
|
+
*/
|
|
80
|
+
declare function AgentSessionsSearch({ className, wrapperClassName, placeholder, "aria-label": ariaLabel, clearLabel, onChange, ref, ...props }: AgentSessionsSearchProps): ReactElement;
|
|
81
|
+
declare namespace AgentSessionsSearch {
|
|
82
|
+
var displayName: string;
|
|
83
|
+
}
|
|
84
|
+
export { AgentSessionsSidebar, AgentSessionsSidebarHeader, AgentSessionsSidebarContent, AgentSessionsSidebarFooter, AgentSessionsSidebarToggle, AgentSessionsNewSessionButton, AgentSessionsSearch, };
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, } from "react";
|
|
4
|
+
import { PanelLeftClose, PanelLeftOpen, Search, SquarePen, X } from "lucide-react";
|
|
5
|
+
import { cn } from "../../../lib/utils";
|
|
6
|
+
import { Button } from "../button/button";
|
|
7
|
+
import { useAgentSessionsContext } from "./agent-sessions-context";
|
|
8
|
+
import { AgentSessionsList } from "./agent-sessions-list";
|
|
9
|
+
import { mergeRefs } from "./merge-refs";
|
|
10
|
+
/**
|
|
11
|
+
* The session list's container. Inline, it is a column the toggle collapses
|
|
12
|
+
* to nothing; as an overlay, it is a drawer over the conversation that
|
|
13
|
+
* Escape, a click on the scrim, or picking a session closes. While the
|
|
14
|
+
* drawer is open the conversation is `inert`, so focus stays in it.
|
|
15
|
+
*/
|
|
16
|
+
function AgentSessionsSidebar({ children, className, scrimClassName, "aria-label": ariaLabel = "Sessions", ref, ...props }) {
|
|
17
|
+
const ctx = useAgentSessionsContext("AgentSessionsSidebar");
|
|
18
|
+
const isOverlay = ctx.sidebarMode === "overlay";
|
|
19
|
+
const open = ctx.sidebarOpen;
|
|
20
|
+
const sidebarRef = useRef(null);
|
|
21
|
+
const mergedRef = useMemo(() => mergeRefs(sidebarRef, ref), [ref]);
|
|
22
|
+
// The sidebar's layout can change without anyone opening or closing it:
|
|
23
|
+
// the first measurement turns the unmeasured inline guess into a closed
|
|
24
|
+
// drawer (in a small dialog, say), and resizing across `overlayBelowPx`
|
|
25
|
+
// swaps modes. Apply such a change with transitions off, so the drawer
|
|
26
|
+
// does not visibly slide shut as the dialog opens; only real opens and
|
|
27
|
+
// closes animate.
|
|
28
|
+
const layoutKey = `${ctx.isMeasured ? "measured" : "unmeasured"}:${ctx.sidebarMode}`;
|
|
29
|
+
const [settledLayoutKey, setSettledLayoutKey] = useState(layoutKey);
|
|
30
|
+
const settlingLayout = settledLayoutKey !== layoutKey;
|
|
31
|
+
useLayoutEffect(() => {
|
|
32
|
+
if (!settlingLayout)
|
|
33
|
+
return;
|
|
34
|
+
// Have the browser compute the new layout's styles while transitions are
|
|
35
|
+
// still off. Turning them back on before it has would animate the change
|
|
36
|
+
// anyway, from whatever style it last computed.
|
|
37
|
+
const sidebar = sidebarRef.current;
|
|
38
|
+
if (sidebar !== null)
|
|
39
|
+
void window.getComputedStyle(sidebar).transform;
|
|
40
|
+
setSettledLayoutKey(layoutKey);
|
|
41
|
+
}, [layoutKey, settlingLayout]);
|
|
42
|
+
// Opening the drawer moves focus into it (onto the active session if it
|
|
43
|
+
// is listed); closing it hands focus back to whatever opened it.
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (!isOverlay || !open)
|
|
46
|
+
return undefined;
|
|
47
|
+
const sidebar = sidebarRef.current;
|
|
48
|
+
if (sidebar === null)
|
|
49
|
+
return undefined;
|
|
50
|
+
// The opener sits in the (now inert) conversation, so the browser may
|
|
51
|
+
// already have dropped focus from it; fall back to the sidebar toggle.
|
|
52
|
+
const opener = document.activeElement;
|
|
53
|
+
const previouslyFocused = opener !== null && opener !== document.body
|
|
54
|
+
? opener
|
|
55
|
+
: document.querySelector(`[aria-controls="${CSS.escape(sidebar.id)}"]`);
|
|
56
|
+
const target = sidebar.querySelector('[data-slot="agent-sessions-list-item-button"][aria-current="true"]') ?? sidebar;
|
|
57
|
+
target.focus({ preventScroll: true });
|
|
58
|
+
return () => {
|
|
59
|
+
const active = document.activeElement;
|
|
60
|
+
const focusIsLost = active === null || active === document.body || sidebar.contains(active);
|
|
61
|
+
if (focusIsLost && previouslyFocused instanceof HTMLElement) {
|
|
62
|
+
previouslyFocused.focus({ preventScroll: true });
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}, [isOverlay, open]);
|
|
66
|
+
const closeSidebar = useCallback(() => ctx.setSidebarOpen(false), [ctx]);
|
|
67
|
+
return (_jsxs(_Fragment, { children: [isOverlay ? (
|
|
68
|
+
// Keyboard users close the drawer with Escape; the scrim is only a
|
|
69
|
+
// pointer target, so it is hidden from assistive technology.
|
|
70
|
+
_jsx("div", { role: "presentation", "aria-hidden": "true", "data-slot": "agent-sessions-sidebar-scrim", "data-state": open ? "open" : "closed", onClick: closeSidebar, className: cn("absolute inset-0 z-20 bg-black/40 transition-opacity duration-200 motion-reduce:transition-none", open ? "opacity-100" : "pointer-events-none opacity-0", scrimClassName) })) : null, _jsx("nav", { ref: mergedRef, id: ctx.sidebarId, "aria-label": ariaLabel, tabIndex: -1, inert: !open, "data-slot": "agent-sessions-sidebar", "data-mode": ctx.sidebarMode, "data-state": open ? "open" : "closed", "data-settling": settlingLayout ? "true" : undefined, className: cn("flex shrink-0 flex-col overflow-hidden bg-muted/40 outline-none motion-reduce:transition-none", isOverlay
|
|
71
|
+
? cn("absolute inset-y-0 left-0 z-30 w-[min(var(--agent-sessions-sidebar-width),85%)] border-r bg-background shadow-xl transition-[transform,box-shadow] duration-200 ease-out", open ? "translate-x-0" : "-translate-x-full shadow-none")
|
|
72
|
+
: cn("relative transition-[width] duration-200 ease-out", open
|
|
73
|
+
? "w-[var(--agent-sessions-sidebar-width)] border-r"
|
|
74
|
+
: "w-0"),
|
|
75
|
+
// Until the component has been measured (the server render), `auto`
|
|
76
|
+
// cannot know it will be an overlay; fall back to the viewport so a
|
|
77
|
+
// phone does not flash an inline sidebar.
|
|
78
|
+
!ctx.isMeasured && "max-md:hidden", className, settlingLayout && "transition-none"), ...props, children: _jsx("div", { className: cn("flex h-full min-h-0 flex-col", isOverlay ? "w-full" : "w-[var(--agent-sessions-sidebar-width)]"), children: children ?? (_jsxs(_Fragment, { children: [_jsxs(AgentSessionsSidebarHeader, { children: [_jsx(AgentSessionsNewSessionButton, {}), _jsx(AgentSessionsSearch, {})] }), _jsx(AgentSessionsSidebarContent, { children: _jsx(AgentSessionsList, {}) })] })) }) })] }));
|
|
79
|
+
}
|
|
80
|
+
AgentSessionsSidebar.displayName = "AgentSessionsSidebar";
|
|
81
|
+
/** Top of the sidebar: new-session button, search, filters — your call. */
|
|
82
|
+
function AgentSessionsSidebarHeader({ className, ref, ...props }) {
|
|
83
|
+
return (_jsx("div", { ref: ref, "data-slot": "agent-sessions-sidebar-header", className: cn("flex shrink-0 flex-col gap-2 p-2", className), ...props }));
|
|
84
|
+
}
|
|
85
|
+
AgentSessionsSidebarHeader.displayName = "AgentSessionsSidebarHeader";
|
|
86
|
+
/** The scrolling middle of the sidebar. Put `<AgentSessionsList>` here. */
|
|
87
|
+
function AgentSessionsSidebarContent({ className, ref, ...props }) {
|
|
88
|
+
return (_jsx("div", { ref: ref, "data-slot": "agent-sessions-sidebar-content", className: cn("min-h-0 flex-1 overflow-y-auto overscroll-contain px-2 pb-2", className), ...props }));
|
|
89
|
+
}
|
|
90
|
+
AgentSessionsSidebarContent.displayName = "AgentSessionsSidebarContent";
|
|
91
|
+
/** Bottom of the sidebar, e.g. the signed-in user or a settings link. */
|
|
92
|
+
function AgentSessionsSidebarFooter({ className, ref, ...props }) {
|
|
93
|
+
return (_jsx("div", { ref: ref, "data-slot": "agent-sessions-sidebar-footer", className: cn("flex shrink-0 flex-col gap-2 border-t p-2", className), ...props }));
|
|
94
|
+
}
|
|
95
|
+
AgentSessionsSidebarFooter.displayName = "AgentSessionsSidebarFooter";
|
|
96
|
+
/**
|
|
97
|
+
* Shows and hides the sidebar. Call `event.preventDefault()` in `onClick`
|
|
98
|
+
* to skip the toggle. Default content: a panel icon.
|
|
99
|
+
*/
|
|
100
|
+
function AgentSessionsSidebarToggle({ className, children, onClick, openLabel = "Show sessions", closeLabel = "Hide sessions", variant = "ghost", size = "icon", ...props }) {
|
|
101
|
+
const ctx = useAgentSessionsContext("AgentSessionsSidebarToggle");
|
|
102
|
+
const open = ctx.sidebarOpen;
|
|
103
|
+
const handleClick = (event) => {
|
|
104
|
+
onClick?.(event);
|
|
105
|
+
if (!event.defaultPrevented)
|
|
106
|
+
ctx.toggleSidebar();
|
|
107
|
+
};
|
|
108
|
+
return (_jsx(Button, { type: "button", variant: variant, size: size, "data-slot": "agent-sessions-sidebar-toggle", "data-state": open ? "open" : "closed", "aria-controls": ctx.sidebarId, "aria-expanded": open, "aria-label": open ? closeLabel : openLabel, className: cn(size === "icon" && "h-8 w-8 shrink-0", className), onClick: handleClick, ...props, children: children ??
|
|
109
|
+
(open ? (_jsx(PanelLeftClose, { "aria-hidden": "true", className: "size-4" })) : (_jsx(PanelLeftOpen, { "aria-hidden": "true", className: "size-4" }))) }));
|
|
110
|
+
}
|
|
111
|
+
AgentSessionsSidebarToggle.displayName = "AgentSessionsSidebarToggle";
|
|
112
|
+
/**
|
|
113
|
+
* Switches to the new-session screen. Call `event.preventDefault()` in
|
|
114
|
+
* `onClick` to run your own flow instead. Default label: "New session".
|
|
115
|
+
*/
|
|
116
|
+
function AgentSessionsNewSessionButton({ className, children, icon, onClick, variant = "outline", size = "sm", ...props }) {
|
|
117
|
+
const ctx = useAgentSessionsContext("AgentSessionsNewSessionButton");
|
|
118
|
+
const handleClick = (event) => {
|
|
119
|
+
onClick?.(event);
|
|
120
|
+
if (!event.defaultPrevented)
|
|
121
|
+
ctx.startNewSession();
|
|
122
|
+
};
|
|
123
|
+
const iconNode = icon === undefined ? (_jsx(SquarePen, { "aria-hidden": "true", className: "size-4" })) : (icon);
|
|
124
|
+
return (_jsxs(Button, { type: "button", variant: variant, size: size, "data-slot": "agent-sessions-new-session-button", "data-active": ctx.view === "new" ? "true" : "false", className: cn(size !== "icon" && "w-full justify-start gap-2", className), onClick: handleClick, ...props, children: [iconNode, children ?? (size === "icon" ? null : "New session")] }));
|
|
125
|
+
}
|
|
126
|
+
AgentSessionsNewSessionButton.displayName = "AgentSessionsNewSessionButton";
|
|
127
|
+
/**
|
|
128
|
+
* Filters `<AgentSessionsList>` by the sessions' titles and previews (or by
|
|
129
|
+
* your own `filter`). Bound to the `searchQuery` of `<AgentSessions>`.
|
|
130
|
+
*/
|
|
131
|
+
function AgentSessionsSearch({ className, wrapperClassName, placeholder = "Search sessions", "aria-label": ariaLabel = "Search sessions", clearLabel = "Clear search", onChange, ref, ...props }) {
|
|
132
|
+
const ctx = useAgentSessionsContext("AgentSessionsSearch");
|
|
133
|
+
const inputRef = useRef(null);
|
|
134
|
+
const mergedRef = useMemo(() => mergeRefs(inputRef, ref), [ref]);
|
|
135
|
+
const handleChange = (event) => {
|
|
136
|
+
onChange?.(event);
|
|
137
|
+
if (!event.defaultPrevented)
|
|
138
|
+
ctx.setSearchQuery(event.target.value);
|
|
139
|
+
};
|
|
140
|
+
const clear = () => {
|
|
141
|
+
ctx.setSearchQuery("");
|
|
142
|
+
inputRef.current?.focus();
|
|
143
|
+
};
|
|
144
|
+
return (_jsxs("div", { "data-slot": "agent-sessions-search", className: cn("relative flex items-center", wrapperClassName), children: [_jsx(Search, { "aria-hidden": "true", className: "pointer-events-none absolute left-2.5 size-4 text-muted-foreground" }), _jsx("input", { ref: mergedRef, type: "search", value: ctx.searchQuery, onChange: handleChange, placeholder: placeholder, "aria-label": ariaLabel, className: cn("h-9 w-full rounded-md border border-input bg-background pl-8 pr-8 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&::-webkit-search-cancel-button]:appearance-none", className), ...props }), ctx.searchQuery.length > 0 ? (_jsx("button", { type: "button", "aria-label": clearLabel, onClick: clear, className: "absolute right-1.5 inline-flex size-6 items-center justify-center rounded-sm text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", children: _jsx(X, { "aria-hidden": "true", className: "size-3.5" }) })) : null] }));
|
|
145
|
+
}
|
|
146
|
+
AgentSessionsSearch.displayName = "AgentSessionsSearch";
|
|
147
|
+
export { AgentSessionsSidebar, AgentSessionsSidebarHeader, AgentSessionsSidebarContent, AgentSessionsSidebarFooter, AgentSessionsSidebarToggle, AgentSessionsNewSessionButton, AgentSessionsSearch, };
|
|
148
|
+
//# sourceMappingURL=agent-sessions-sidebar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-sessions-sidebar.js","sourceRoot":"","sources":["../../../../src/components/ui/agent-sessions/agent-sessions-sidebar.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EACL,WAAW,EACX,SAAS,EACT,eAAe,EACf,OAAO,EACP,MAAM,EACN,QAAQ,GAQT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,EAAE,MAAM,cAAc,CAAC;AAEnF,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,MAAM,EAAoB,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAmBzC;;;;;GAKG;AACH,SAAS,oBAAoB,CAAC,EAC5B,QAAQ,EACR,SAAS,EACT,cAAc,EACd,YAAY,EAAE,SAAS,GAAG,UAAU,EACpC,GAAG,EACH,GAAG,KAAK,EACkB;IAC1B,MAAM,GAAG,GAAG,uBAAuB,CAAC,sBAAsB,CAAC,CAAC;IAC5D,MAAM,SA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,CAAC,CAAC;IACtE,CAAC,CAAC;IAEF,MAAM,KAAK,GAAG,GAAS,EAAE;QACvB,GAAG,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;QACvB,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC,CAAC;IAEF,OAAO,CACL,4BACY,uBAAuB,EACjC,SAAS,EAAE,EAAE,CAAC,4BAA4B,EAAE,gBAAgB,CAAC,aAE7D,KAAC,MAAM,mBACO,MAAM,EAClB,SAAS,EAAC,oEAAoE,GAC9E,EACF,gBACE,GAAG,EAAE,SAAS,EACd,IAAI,EAAC,QAAQ,EACb,KAAK,EAAE,GAAG,CAAC,WAAW,EACtB,QAAQ,EAAE,YAAY,EACtB,WAAW,EAAE,WAAW,gBACZ,SAAS,EACrB,SAAS,EAAE,EAAE,CACX,0UAA0U,EAC1U,SAAS,CACV,KACG,KAAK,GACT,EACD,GAAG,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAC5B,iBACE,IAAI,EAAC,QAAQ,gBACD,UAAU,EACtB,OAAO,EAAE,KAAK,EACd,SAAS,EAAC,yNAAyN,YAEnO,KAAC,CAAC,mBAAa,MAAM,EAAC,SAAS,EAAC,UAAU,GAAG,GACtC,CACV,CAAC,CAAC,CAAC,IAAI,IACJ,CACP,CAAC;AACJ,CAAC;AACD,mBAAmB,CAAC,WAAW,GAAG,qBAAqB,CAAC;AAExD,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,2BAA2B,EAC3B,0BAA0B,EAC1B,0BAA0B,EAC1B,6BAA6B,EAC7B,mBAAmB,GACpB,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { ButtonHTMLAttributes, HTMLAttributes, ReactElement, ReactNode, Ref } from "react";
|
|
2
|
+
export interface AgentSessionsStartProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
/** Class for the centred column inside the scroll area. */
|
|
4
|
+
contentClassName?: string;
|
|
5
|
+
ref?: Ref<HTMLDivElement>;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The new-session screen, shown instead of the conversation while no
|
|
9
|
+
* session is active. A roomy, centred column for a bigger prompt —
|
|
10
|
+
* usually an `<AgentSessionsStartHeader>`, an `<AgentSessionsPromptInput>`
|
|
11
|
+
* with more rows and your own inputs (model, repository, mode…), and
|
|
12
|
+
* `<AgentSessionsSuggestions>`. Scrolls when it outgrows the space.
|
|
13
|
+
*/
|
|
14
|
+
declare function AgentSessionsStart({ className, contentClassName, children, ref, ...props }: AgentSessionsStartProps): ReactElement | null;
|
|
15
|
+
declare namespace AgentSessionsStart {
|
|
16
|
+
var displayName: string;
|
|
17
|
+
}
|
|
18
|
+
export interface AgentSessionsStartHeaderProps extends Omit<HTMLAttributes<HTMLDivElement>, "title"> {
|
|
19
|
+
/** Shown in a tinted tile above the title. */
|
|
20
|
+
icon?: ReactNode;
|
|
21
|
+
/** Default: "Start a new session". */
|
|
22
|
+
title?: ReactNode;
|
|
23
|
+
description?: ReactNode;
|
|
24
|
+
ref?: Ref<HTMLDivElement>;
|
|
25
|
+
}
|
|
26
|
+
/** The greeting above the new-session prompt. Extra children go below it. */
|
|
27
|
+
declare function AgentSessionsStartHeader({ icon, title, description, className, children, ref, ...props }: AgentSessionsStartHeaderProps): ReactElement;
|
|
28
|
+
declare namespace AgentSessionsStartHeader {
|
|
29
|
+
var displayName: string;
|
|
30
|
+
}
|
|
31
|
+
export interface AgentSessionsSuggestionsProps extends HTMLAttributes<HTMLDivElement> {
|
|
32
|
+
/** Accessible name of the group. Default: "Suggestions". */
|
|
33
|
+
"aria-label"?: string;
|
|
34
|
+
ref?: Ref<HTMLDivElement>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* A grid of `<AgentSessionsSuggestion>`s that reflows to the space it has
|
|
38
|
+
* (container-sized, so it also suits a narrow dialog).
|
|
39
|
+
*/
|
|
40
|
+
declare function AgentSessionsSuggestions({ className, "aria-label": ariaLabel, ref, ...props }: AgentSessionsSuggestionsProps): ReactElement;
|
|
41
|
+
declare namespace AgentSessionsSuggestions {
|
|
42
|
+
var displayName: string;
|
|
43
|
+
}
|
|
44
|
+
export interface AgentSessionsSuggestionProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
45
|
+
/**
|
|
46
|
+
* Prompt to put in the current view's draft on click (the prompt is then
|
|
47
|
+
* focused, ready to edit or send). Omit to only run `onClick`.
|
|
48
|
+
*/
|
|
49
|
+
prompt?: string;
|
|
50
|
+
icon?: ReactNode;
|
|
51
|
+
/** Second, muted line under the label. */
|
|
52
|
+
description?: ReactNode;
|
|
53
|
+
ref?: Ref<HTMLButtonElement>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* A starter prompt. Clicking it fills the prompt with `prompt`; call
|
|
57
|
+
* `event.preventDefault()` in `onClick` to do something else instead.
|
|
58
|
+
*/
|
|
59
|
+
declare function AgentSessionsSuggestion({ prompt, icon, description, className, children, onClick, type, ref, ...props }: AgentSessionsSuggestionProps): ReactElement;
|
|
60
|
+
declare namespace AgentSessionsSuggestion {
|
|
61
|
+
var displayName: string;
|
|
62
|
+
}
|
|
63
|
+
export { AgentSessionsStart, AgentSessionsStartHeader, AgentSessionsSuggestions, AgentSessionsSuggestion, };
|