@tangle-network/sandbox-ui 0.3.6 → 0.3.10

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.
Files changed (41) hide show
  1. package/dist/active-sessions-store-CeOmXgv5.d.ts +85 -0
  2. package/dist/artifact-pane-Bh45Ssco.d.ts +24 -0
  3. package/dist/{chat-container-C8eHLw8z.d.ts → chat-container-Dn1jWtWo.d.ts} +20 -3
  4. package/dist/chat.d.ts +17 -4
  5. package/dist/chat.js +6 -2
  6. package/dist/{chunk-4F2GJRGU.js → chunk-6H3EFUUC.js} +196 -77
  7. package/dist/{chunk-WUR652Y3.js → chunk-72UEKFZ2.js} +113 -89
  8. package/dist/{chunk-TXI4MZAZ.js → chunk-CSIXZEKN.js} +152 -1
  9. package/dist/{chunk-5LV6DZZF.js → chunk-FOQTE67I.js} +278 -21
  10. package/dist/chunk-MGCVTFKB.js +10910 -0
  11. package/dist/chunk-OEX7NZE3.js +321 -0
  12. package/dist/chunk-Q56BYXQF.js +61 -0
  13. package/dist/{chunk-QGI5E7JD.js → chunk-RQOX5JRR.js} +541 -76
  14. package/dist/{chunk-PDV7W4NY.js → chunk-SULQQJPB.js} +1 -56
  15. package/dist/chunk-W4LM3QYZ.js +54 -0
  16. package/dist/{chunk-JF6E2DS5.js → chunk-ZYGWTIWO.js} +171 -155
  17. package/dist/document-editor-pane-Bk-9MQmw.d.ts +116 -0
  18. package/dist/document-editor-pane-GRIQOJHB.js +11 -0
  19. package/dist/editor.d.ts +7 -84
  20. package/dist/editor.js +18 -699
  21. package/dist/{expanded-tool-detail-BDi_h_dZ.d.ts → expanded-tool-detail-DM5M_T9h.d.ts} +10 -2
  22. package/dist/{file-tabs-CmaoDVBI.d.ts → file-tabs-BLfxfmAH.d.ts} +1 -22
  23. package/dist/files.d.ts +25 -3
  24. package/dist/files.js +2 -1
  25. package/dist/hooks.d.ts +3 -1
  26. package/dist/hooks.js +6 -1
  27. package/dist/index.d.ts +13 -7
  28. package/dist/index.js +26 -9
  29. package/dist/pages.js +4 -2
  30. package/dist/primitives.d.ts +45 -1
  31. package/dist/primitives.js +9 -3
  32. package/dist/run.d.ts +1 -1
  33. package/dist/run.js +1 -1
  34. package/dist/sdk-hooks.d.ts +32 -1
  35. package/dist/sdk-hooks.js +6 -1
  36. package/dist/stores.d.ts +1 -0
  37. package/dist/stores.js +60 -1
  38. package/dist/types.d.ts +2 -0
  39. package/dist/workspace.d.ts +84 -6
  40. package/dist/workspace.js +10 -4
  41. package/package.json +17 -6
@@ -0,0 +1,321 @@
1
+ // src/stores/active-sessions-store.ts
2
+ import { useStore } from "@nanostores/react";
3
+ import { atom } from "nanostores";
4
+ import { useMemo } from "react";
5
+ var INITIAL_STATE = {
6
+ sessions: {},
7
+ lastUpdatedAt: 0
8
+ };
9
+ var STATUS_PRIORITY = {
10
+ running: 0,
11
+ error: 1,
12
+ "attention-needed": 2,
13
+ idle: 3
14
+ };
15
+ var DEFAULT_RECORD = {
16
+ status: "idle",
17
+ isRunning: false,
18
+ isForeground: false,
19
+ needsAttention: false,
20
+ connectionState: "disconnected",
21
+ reconnectState: "idle",
22
+ transportMode: null,
23
+ lastError: null,
24
+ lastEventAt: null
25
+ };
26
+ var activeSessionsAtom = atom(INITIAL_STATE);
27
+ var foregroundSessionId = null;
28
+ function createRecord(options, now) {
29
+ return {
30
+ sessionId: options.sessionId,
31
+ projectId: options.projectId ?? null,
32
+ projectLabel: options.projectLabel,
33
+ title: options.title,
34
+ href: options.href,
35
+ registeredAt: now,
36
+ lastActivityAt: now,
37
+ metadata: options.metadata,
38
+ ...DEFAULT_RECORD,
39
+ isForeground: options.sessionId === foregroundSessionId
40
+ };
41
+ }
42
+ function resolveStatus(session) {
43
+ if (session.isRunning) return "running";
44
+ if (session.lastError || session.reconnectState === "failed") return "error";
45
+ if (session.needsAttention) return "attention-needed";
46
+ return "idle";
47
+ }
48
+ function normalizeSession(session) {
49
+ return {
50
+ ...session,
51
+ status: resolveStatus(session)
52
+ };
53
+ }
54
+ function updateSession(sessionId, updater) {
55
+ const current = activeSessionsAtom.get();
56
+ const existing = current.sessions[sessionId];
57
+ if (!existing) return;
58
+ const now = Date.now();
59
+ activeSessionsAtom.set({
60
+ sessions: {
61
+ ...current.sessions,
62
+ [sessionId]: normalizeSession(updater(existing, now))
63
+ },
64
+ lastUpdatedAt: now
65
+ });
66
+ }
67
+ function registerActiveSession(options) {
68
+ const now = Date.now();
69
+ const current = activeSessionsAtom.get();
70
+ const existing = current.sessions[options.sessionId];
71
+ activeSessionsAtom.set({
72
+ sessions: {
73
+ ...current.sessions,
74
+ [options.sessionId]: normalizeSession(
75
+ existing ? {
76
+ ...existing,
77
+ projectId: existing.projectId ?? options.projectId ?? null,
78
+ projectLabel: options.projectLabel ?? existing.projectLabel,
79
+ title: options.title ?? existing.title,
80
+ href: options.href ?? existing.href,
81
+ metadata: options.metadata ?? existing.metadata,
82
+ lastActivityAt: now,
83
+ isForeground: options.sessionId === foregroundSessionId || existing.isForeground
84
+ } : createRecord(options, now)
85
+ )
86
+ },
87
+ lastUpdatedAt: now
88
+ });
89
+ }
90
+ function unregisterActiveSession(sessionId) {
91
+ const current = activeSessionsAtom.get();
92
+ if (!current.sessions[sessionId]) return;
93
+ const { [sessionId]: _removed, ...remaining } = current.sessions;
94
+ if (foregroundSessionId === sessionId) {
95
+ foregroundSessionId = null;
96
+ }
97
+ activeSessionsAtom.set({
98
+ sessions: remaining,
99
+ lastUpdatedAt: Date.now()
100
+ });
101
+ }
102
+ function setForegroundActiveSession(sessionId) {
103
+ foregroundSessionId = sessionId;
104
+ const current = activeSessionsAtom.get();
105
+ const now = Date.now();
106
+ let changed = false;
107
+ const sessions = Object.fromEntries(
108
+ Object.entries(current.sessions).map(([id, session]) => {
109
+ const isForeground = id === sessionId;
110
+ if (session.isForeground !== isForeground) {
111
+ changed = true;
112
+ }
113
+ return [
114
+ id,
115
+ {
116
+ ...session,
117
+ isForeground,
118
+ lastActivityAt: isForeground ? now : session.lastActivityAt
119
+ }
120
+ ];
121
+ })
122
+ );
123
+ if (!changed) return;
124
+ activeSessionsAtom.set({
125
+ sessions,
126
+ lastUpdatedAt: now
127
+ });
128
+ }
129
+ function updateActiveSessionMeta(sessionId, meta) {
130
+ updateSession(sessionId, (session, now) => ({
131
+ ...session,
132
+ ...meta,
133
+ lastActivityAt: now
134
+ }));
135
+ }
136
+ function setActiveSessionConnection(sessionId, options) {
137
+ updateSession(sessionId, (session, now) => ({
138
+ ...session,
139
+ connectionState: options.connectionState,
140
+ reconnectState: options.reconnectState ?? session.reconnectState,
141
+ transportMode: options.transportMode ?? session.transportMode,
142
+ lastError: options.lastError === void 0 ? session.lastError : options.lastError,
143
+ lastEventAt: options.lastEventAt ?? session.lastEventAt,
144
+ lastActivityAt: now
145
+ }));
146
+ }
147
+ function setActiveSessionRunning(sessionId, isRunning, options) {
148
+ updateSession(sessionId, (session, now) => ({
149
+ ...session,
150
+ isRunning,
151
+ needsAttention: isRunning ? false : session.needsAttention,
152
+ lastError: isRunning ? null : session.lastError,
153
+ lastEventAt: options?.lastEventAt ?? session.lastEventAt,
154
+ lastActivityAt: now
155
+ }));
156
+ }
157
+ function setActiveSessionAttention(sessionId, needsAttention, options) {
158
+ updateSession(sessionId, (session, now) => ({
159
+ ...session,
160
+ needsAttention,
161
+ isRunning: needsAttention ? false : session.isRunning,
162
+ lastEventAt: options?.lastEventAt ?? session.lastEventAt,
163
+ lastActivityAt: now
164
+ }));
165
+ }
166
+ function setActiveSessionError(sessionId, error) {
167
+ updateSession(sessionId, (session, now) => ({
168
+ ...session,
169
+ isRunning: false,
170
+ needsAttention: false,
171
+ lastError: error,
172
+ reconnectState: error ? "failed" : "idle",
173
+ connectionState: error ? "error" : session.connectionState,
174
+ lastEventAt: now,
175
+ lastActivityAt: now
176
+ }));
177
+ }
178
+ function bumpActiveSessionActivity(sessionId, options) {
179
+ updateSession(sessionId, (session, now) => ({
180
+ ...session,
181
+ lastEventAt: options?.lastEventAt ?? session.lastEventAt ?? now,
182
+ lastActivityAt: now
183
+ }));
184
+ }
185
+ function resetActiveSessions() {
186
+ foregroundSessionId = null;
187
+ activeSessionsAtom.set(INITIAL_STATE);
188
+ }
189
+ function getAllActiveSessions(state) {
190
+ return Object.values(state.sessions);
191
+ }
192
+ function getActiveSession(state, sessionId) {
193
+ return state.sessions[sessionId] ?? null;
194
+ }
195
+ function getSessionsForProject(state, projectId) {
196
+ return Object.values(state.sessions).filter((session) => session.projectId === projectId);
197
+ }
198
+ function getSessionsForNavbar(state, projectId) {
199
+ const sessions = projectId == null ? Object.values(state.sessions) : getSessionsForProject(state, projectId);
200
+ return [...sessions].sort((left, right) => {
201
+ if (left.isForeground !== right.isForeground) {
202
+ return Number(right.isForeground) - Number(left.isForeground);
203
+ }
204
+ const statusDiff = STATUS_PRIORITY[left.status] - STATUS_PRIORITY[right.status];
205
+ if (statusDiff !== 0) {
206
+ return statusDiff;
207
+ }
208
+ return right.lastActivityAt - left.lastActivityAt;
209
+ });
210
+ }
211
+ function getSessionsByActivity(state) {
212
+ return [...Object.values(state.sessions)].sort(
213
+ (left, right) => right.lastActivityAt - left.lastActivityAt
214
+ );
215
+ }
216
+ function getTotalRunningSessionCount(state) {
217
+ return Object.values(state.sessions).filter((session) => session.isRunning).length;
218
+ }
219
+ function hasBackgroundRunningSessions(state) {
220
+ return Object.values(state.sessions).some(
221
+ (session) => session.isRunning && !session.isForeground
222
+ );
223
+ }
224
+ function getAllProjectActivity(state) {
225
+ const grouped = /* @__PURE__ */ new Map();
226
+ for (const session of Object.values(state.sessions)) {
227
+ if (session.projectId == null) continue;
228
+ const existing = grouped.get(session.projectId);
229
+ if (existing) {
230
+ existing.activeSessionCount += 1;
231
+ existing.lastActivityAt = Math.max(existing.lastActivityAt, session.lastActivityAt);
232
+ if (session.isRunning) {
233
+ existing.runningSessionIds.push(session.sessionId);
234
+ }
235
+ if (!existing.projectLabel && session.projectLabel) {
236
+ existing.projectLabel = session.projectLabel;
237
+ }
238
+ continue;
239
+ }
240
+ grouped.set(session.projectId, {
241
+ projectId: session.projectId,
242
+ projectLabel: session.projectLabel,
243
+ activeSessionCount: 1,
244
+ runningSessionIds: session.isRunning ? [session.sessionId] : [],
245
+ lastActivityAt: session.lastActivityAt
246
+ });
247
+ }
248
+ return [...grouped.values()].sort((left, right) => right.lastActivityAt - left.lastActivityAt);
249
+ }
250
+ function useActiveSessionsState() {
251
+ return useStore(activeSessionsAtom);
252
+ }
253
+ function useActiveSessions() {
254
+ const state = useStore(activeSessionsAtom);
255
+ return useMemo(() => getAllActiveSessions(state), [state]);
256
+ }
257
+ function useActiveSession(sessionId) {
258
+ const state = useStore(activeSessionsAtom);
259
+ return useMemo(
260
+ () => sessionId ? getActiveSession(state, sessionId) : null,
261
+ [sessionId, state]
262
+ );
263
+ }
264
+ function useProjectSessions(projectId) {
265
+ const state = useStore(activeSessionsAtom);
266
+ return useMemo(
267
+ () => projectId == null ? [] : getSessionsForProject(state, projectId),
268
+ [projectId, state]
269
+ );
270
+ }
271
+ function useNavbarSessions(projectId) {
272
+ const state = useStore(activeSessionsAtom);
273
+ return useMemo(() => getSessionsForNavbar(state, projectId), [projectId, state]);
274
+ }
275
+ function useSessionsByActivity() {
276
+ const state = useStore(activeSessionsAtom);
277
+ return useMemo(() => getSessionsByActivity(state), [state]);
278
+ }
279
+ function useProjectActivity() {
280
+ const state = useStore(activeSessionsAtom);
281
+ return useMemo(() => getAllProjectActivity(state), [state]);
282
+ }
283
+ function useTotalRunningSessions() {
284
+ const state = useStore(activeSessionsAtom);
285
+ return useMemo(() => getTotalRunningSessionCount(state), [state]);
286
+ }
287
+ function useHasBackgroundRunningSessions() {
288
+ const state = useStore(activeSessionsAtom);
289
+ return useMemo(() => hasBackgroundRunningSessions(state), [state]);
290
+ }
291
+
292
+ export {
293
+ activeSessionsAtom,
294
+ registerActiveSession,
295
+ unregisterActiveSession,
296
+ setForegroundActiveSession,
297
+ updateActiveSessionMeta,
298
+ setActiveSessionConnection,
299
+ setActiveSessionRunning,
300
+ setActiveSessionAttention,
301
+ setActiveSessionError,
302
+ bumpActiveSessionActivity,
303
+ resetActiveSessions,
304
+ getAllActiveSessions,
305
+ getActiveSession,
306
+ getSessionsForProject,
307
+ getSessionsForNavbar,
308
+ getSessionsByActivity,
309
+ getTotalRunningSessionCount,
310
+ hasBackgroundRunningSessions,
311
+ getAllProjectActivity,
312
+ useActiveSessionsState,
313
+ useActiveSessions,
314
+ useActiveSession,
315
+ useProjectSessions,
316
+ useNavbarSessions,
317
+ useSessionsByActivity,
318
+ useProjectActivity,
319
+ useTotalRunningSessions,
320
+ useHasBackgroundRunningSessions
321
+ };
@@ -0,0 +1,61 @@
1
+ import {
2
+ cn
3
+ } from "./chunk-RQHJBTEU.js";
4
+
5
+ // src/primitives/tabs.tsx
6
+ import * as TabsPrimitive from "@radix-ui/react-tabs";
7
+ import * as React from "react";
8
+ import { jsx } from "react/jsx-runtime";
9
+ var Tabs = TabsPrimitive.Root;
10
+ var TabsList = React.forwardRef(({ className, variant = "default", ...props }, ref) => {
11
+ const variants = {
12
+ default: "inline-flex h-10 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",
13
+ pills: "inline-flex items-center gap-2",
14
+ underline: "inline-flex items-center gap-4 border-b border-border"
15
+ };
16
+ return /* @__PURE__ */ jsx(
17
+ TabsPrimitive.List,
18
+ {
19
+ ref,
20
+ className: cn(variants[variant], className),
21
+ ...props
22
+ }
23
+ );
24
+ });
25
+ TabsList.displayName = TabsPrimitive.List.displayName;
26
+ var TabsTrigger = React.forwardRef(({ className, variant = "default", ...props }, ref) => {
27
+ const variants = {
28
+ default: "inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",
29
+ pills: "inline-flex items-center justify-center whitespace-nowrap rounded-full px-4 py-2 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-primary data-[state=active]:text-primary-foreground data-[state=inactive]:text-muted-foreground data-[state=inactive]:hover:bg-muted",
30
+ underline: "inline-flex items-center justify-center whitespace-nowrap pb-3 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:text-foreground data-[state=inactive]:text-muted-foreground"
31
+ };
32
+ return /* @__PURE__ */ jsx(
33
+ TabsPrimitive.Trigger,
34
+ {
35
+ ref,
36
+ className: cn(variants[variant], className),
37
+ ...props
38
+ }
39
+ );
40
+ });
41
+ TabsTrigger.displayName = TabsPrimitive.Trigger.displayName;
42
+ var TabsContent = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
43
+ TabsPrimitive.Content,
44
+ {
45
+ ref,
46
+ className: cn(
47
+ "mt-4 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
48
+ "data-[state=active]:fade-in-0 data-[state=active]:slide-in-from-bottom-2 data-[state=active]:animate-in",
49
+ className
50
+ ),
51
+ ...props
52
+ }
53
+ ));
54
+ TabsContent.displayName = TabsPrimitive.Content.displayName;
55
+
56
+ export {
57
+ Tabs,
58
+ TabsList,
59
+ TabsTrigger,
60
+ TabsContent
61
+ };