@quillsql/admin 1.8.7 → 1.8.9

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/index.cjs CHANGED
@@ -47,9 +47,11 @@ __export(index_exports, {
47
47
  SecondaryButtonPrimitive: () => SecondaryButtonPrimitive_default,
48
48
  TextInputPrimitive: () => TextInputPrimitive_default,
49
49
  VirtualTableManager: () => VirtualTableManager,
50
+ clearQuillSandboxStorage: () => clearQuillSandboxStorage,
50
51
  exportChatAsMarkdown: () => exportChatAsMarkdown,
51
52
  useAdmin: () => useAdmin,
52
- useAgentChat: () => useAgentChat
53
+ useAgentChat: () => useAgentChat,
54
+ useSandboxSession: () => useSandboxSession
53
55
  });
54
56
  module.exports = __toCommonJS(index_exports);
55
57
 
@@ -8175,32 +8177,140 @@ var import_fast_deep_equal = __toESM(require("fast-deep-equal"), 1);
8175
8177
 
8176
8178
  // src/components/AgentChat/AgentChatContext.tsx
8177
8179
  var import_react24 = require("react");
8178
- var AgentChatContext = (0, import_react24.createContext)(null);
8179
- var WELCOME_MESSAGE = "I'm your Quill BI Agent. I can create dashboards, reports, virtual tables, run queries, and manage environments \u2014 all through conversation.\n\nI'm working in a sandbox copy of your environment, so nothing affects production until you promote your changes.";
8180
- var SESSION_STORAGE_KEY = "quill-agent-session";
8181
- function hydrateSession() {
8180
+
8181
+ // src/utils/sandboxStorage.ts
8182
+ var SANDBOX_STORAGE_KEY = "quill-sandbox-session";
8183
+ var LEGACY_SESSION_STORAGE_KEY = "quill-agent-session";
8184
+ function parsePersistedSandbox(raw) {
8185
+ if (!raw) return null;
8186
+ try {
8187
+ const parsed = JSON.parse(raw);
8188
+ if (parsed?.clerkOrgId && parsed?.sandboxSessionId && parsed?.sandboxClientId && parsed?.session?.sessionId) {
8189
+ return parsed;
8190
+ }
8191
+ } catch {
8192
+ }
8193
+ return null;
8194
+ }
8195
+ function readPersistedSandboxRaw() {
8182
8196
  if (typeof window === "undefined") {
8183
8197
  return null;
8184
8198
  }
8199
+ return parsePersistedSandbox(
8200
+ window.localStorage.getItem(SANDBOX_STORAGE_KEY)
8201
+ );
8202
+ }
8203
+ function readLegacySandboxSession(clerkOrgId) {
8185
8204
  try {
8186
- const raw = window.sessionStorage.getItem(SESSION_STORAGE_KEY);
8187
- if (!raw) return null;
8188
- const parsed = JSON.parse(raw);
8189
- if (parsed?.session?.sessionId && parsed?.session?.sandboxClientId) {
8190
- return parsed.session;
8191
- }
8205
+ const legacyRaw = window.sessionStorage.getItem(LEGACY_SESSION_STORAGE_KEY);
8206
+ if (!legacyRaw) return null;
8207
+ const legacy = JSON.parse(legacyRaw);
8208
+ const session = legacy?.session;
8209
+ if (!session?.sessionId || !session.sandboxClientId) return null;
8210
+ return {
8211
+ clerkOrgId,
8212
+ sandboxParentClientId: session.sourceClientId,
8213
+ sandboxClientId: session.sandboxClientId,
8214
+ sandboxSessionId: session.sessionId,
8215
+ session,
8216
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
8217
+ };
8192
8218
  } catch {
8219
+ return null;
8220
+ }
8221
+ }
8222
+ function resolveSandboxSession(clerkOrgId) {
8223
+ if (typeof window === "undefined") {
8224
+ return null;
8225
+ }
8226
+ const fromLocal = readPersistedSandboxRaw();
8227
+ if (fromLocal) {
8228
+ if (!clerkOrgId || fromLocal.clerkOrgId === clerkOrgId) {
8229
+ return fromLocal;
8230
+ }
8231
+ return null;
8232
+ }
8233
+ if (!clerkOrgId) {
8234
+ return null;
8235
+ }
8236
+ return readLegacySandboxSession(clerkOrgId);
8237
+ }
8238
+ function writeSandboxSession(payload) {
8239
+ if (typeof window === "undefined") return;
8240
+ window.localStorage.setItem(
8241
+ SANDBOX_STORAGE_KEY,
8242
+ JSON.stringify({ ...payload, updatedAt: (/* @__PURE__ */ new Date()).toISOString() })
8243
+ );
8244
+ window.sessionStorage.removeItem(LEGACY_SESSION_STORAGE_KEY);
8245
+ }
8246
+ function clearSandboxSession() {
8247
+ if (typeof window === "undefined") return;
8248
+ window.localStorage.removeItem(SANDBOX_STORAGE_KEY);
8249
+ window.sessionStorage.removeItem(LEGACY_SESSION_STORAGE_KEY);
8250
+ }
8251
+ function clearQuillSandboxStorage() {
8252
+ clearSandboxSession();
8253
+ }
8254
+ function subscribeSandboxSession(onChange) {
8255
+ if (typeof window === "undefined") {
8256
+ return () => {
8257
+ };
8258
+ }
8259
+ const handler = (event) => {
8260
+ if (event.key !== SANDBOX_STORAGE_KEY) return;
8261
+ onChange(parsePersistedSandbox(event.newValue));
8262
+ };
8263
+ window.addEventListener("storage", handler);
8264
+ return () => window.removeEventListener("storage", handler);
8265
+ }
8266
+ function sandboxFieldsFromSession(sessionInfo, resultClient) {
8267
+ return {
8268
+ sandboxParentClientId: String(
8269
+ resultClient?.sandboxParentClientId ?? sessionInfo.sourceClientId
8270
+ ),
8271
+ sandboxClientId: String(sessionInfo.sandboxClientId),
8272
+ sandboxSessionId: String(sessionInfo.sessionId)
8273
+ };
8274
+ }
8275
+ function persistSandboxFromSessionInfo(scopeId, sessionInfo, resultClient) {
8276
+ if (!scopeId) return;
8277
+ const fields = sandboxFieldsFromSession(sessionInfo, resultClient);
8278
+ writeSandboxSession({
8279
+ clerkOrgId: scopeId,
8280
+ ...fields,
8281
+ session: sessionInfo,
8282
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
8283
+ });
8284
+ }
8285
+ function getSandboxStorageScopeId(...candidates) {
8286
+ for (const candidate of candidates) {
8287
+ if (candidate) return candidate;
8193
8288
  }
8194
8289
  return null;
8195
8290
  }
8196
- function useAgentChatRootState() {
8291
+
8292
+ // src/components/AgentChat/AgentChatContext.tsx
8293
+ var AgentChatContext = (0, import_react24.createContext)(null);
8294
+ var WELCOME_MESSAGE = "I'm your Quill BI Agent. I can create dashboards, reports, virtual tables, run queries, and manage environments \u2014 all through conversation.\n\nI'm working in a sandbox copy of your environment, so nothing affects production until you promote your changes.";
8295
+ function hydrateSessionFromStorage(clerkOrgId) {
8296
+ return resolveSandboxSession(clerkOrgId)?.session ?? null;
8297
+ }
8298
+ function useAgentChatRootState(clerkOrgId) {
8197
8299
  const [messages, setMessages] = (0, import_react24.useState)([
8198
8300
  { role: "assistant", content: WELCOME_MESSAGE, isWelcome: true }
8199
8301
  ]);
8200
- const [initialSession] = (0, import_react24.useState)(hydrateSession);
8201
- const [session, setSessionRaw] = (0, import_react24.useState)(initialSession);
8302
+ const [session, setSessionRaw] = (0, import_react24.useState)(
8303
+ () => hydrateSessionFromStorage(clerkOrgId)
8304
+ );
8202
8305
  const [showToolOutputs, setShowToolOutputs] = (0, import_react24.useState)(false);
8203
8306
  const [changelogEntries, setChangelogEntriesState] = (0, import_react24.useState)([]);
8307
+ (0, import_react24.useEffect)(() => {
8308
+ if (!clerkOrgId) return;
8309
+ const stored = resolveSandboxSession(clerkOrgId);
8310
+ if (stored?.session) {
8311
+ setSessionRaw((prev) => prev ?? stored.session);
8312
+ }
8313
+ }, [clerkOrgId]);
8204
8314
  const setChangelogEntries = (0, import_react24.useCallback)((entries) => {
8205
8315
  setChangelogEntriesState(entries);
8206
8316
  }, []);
@@ -8213,17 +8323,6 @@ function useAgentChatRootState() {
8213
8323
  return next;
8214
8324
  });
8215
8325
  }, []);
8216
- (0, import_react24.useEffect)(() => {
8217
- if (typeof window === "undefined") return;
8218
- if (session) {
8219
- window.sessionStorage.setItem(
8220
- SESSION_STORAGE_KEY,
8221
- JSON.stringify({ session })
8222
- );
8223
- } else {
8224
- window.sessionStorage.removeItem(SESSION_STORAGE_KEY);
8225
- }
8226
- }, [session]);
8227
8326
  return {
8228
8327
  messages,
8229
8328
  setMessages,
@@ -8480,7 +8579,7 @@ function AdminProvider({
8480
8579
  onRequestAddVirtualTable,
8481
8580
  hideEnvDropdown
8482
8581
  }) {
8483
- const agentChatState = useAgentChatRootState();
8582
+ const agentChatState = useAgentChatRootState(clerkOrgId);
8484
8583
  const refreshChangelogRef = (0, import_react27.useRef)(null);
8485
8584
  const registerChangelogRefresh = (0, import_react27.useCallback)(
8486
8585
  (fn) => {
@@ -8490,6 +8589,7 @@ function AdminProvider({
8490
8589
  );
8491
8590
  const [clientLoading, setClientLoading] = (0, import_react27.useState)(true);
8492
8591
  const currentFetchingClientRef = (0, import_react27.useRef)(void 0);
8592
+ const previousClerkOrgIdRef = (0, import_react27.useRef)(void 0);
8493
8593
  const [schemaLoading, setSchemaLoading] = (0, import_react27.useState)(false);
8494
8594
  const [error, setError] = (0, import_react27.useState)(null);
8495
8595
  const publicKeyRef = (0, import_react27.useRef)(void 0);
@@ -8564,6 +8664,21 @@ function AdminProvider({
8564
8664
  sandboxSessionId: null
8565
8665
  };
8566
8666
  };
8667
+ const mergeSandboxIntoState = (baseState, orgId) => {
8668
+ const storedSandbox = resolveSandboxSession(
8669
+ orgId ?? clerkOrgId ?? baseState.clerkOrgId
8670
+ );
8671
+ if (!storedSandbox) {
8672
+ return baseState;
8673
+ }
8674
+ return {
8675
+ ...baseState,
8676
+ clerkOrgId: storedSandbox.clerkOrgId || baseState.clerkOrgId,
8677
+ sandboxParentClientId: storedSandbox.sandboxParentClientId,
8678
+ sandboxClientId: storedSandbox.sandboxClientId,
8679
+ sandboxSessionId: storedSandbox.sandboxSessionId
8680
+ };
8681
+ };
8567
8682
  const hydrateStateFromSessionStorage = () => {
8568
8683
  if (typeof window === "undefined") {
8569
8684
  return null;
@@ -8574,7 +8689,8 @@ function AdminProvider({
8574
8689
  );
8575
8690
  if (clerkOrgId && localState?.clerkOrgId === clerkOrgId) {
8576
8691
  const parsedState = parsedSessionStorageAdminState(localState);
8577
- return {
8692
+ const storedSandbox2 = resolveSandboxSession(clerkOrgId);
8693
+ return mergeSandboxIntoState({
8578
8694
  ...parsedState,
8579
8695
  queryEndpoint,
8580
8696
  isSelfHosted: !QUILL_ENDPOINTS.includes(
@@ -8583,10 +8699,14 @@ function AdminProvider({
8583
8699
  queryHeaders: queryHeaders !== void 0 ? queryHeaders : parsedState.queryHeaders,
8584
8700
  withCredentials: withCredentials !== void 0 ? withCredentials : parsedState.withCredentials,
8585
8701
  hideEnvDropdown: hideEnvDropdown !== void 0 ? hideEnvDropdown : parsedState.hideEnvDropdown ?? false,
8586
- sandboxParentClientId: parsedState.sandboxParentClientId ?? null,
8587
- sandboxClientId: parsedState.sandboxClientId ?? null,
8588
- sandboxSessionId: parsedState.sandboxSessionId ?? null
8589
- };
8702
+ sandboxParentClientId: storedSandbox2?.sandboxParentClientId ?? parsedState.sandboxParentClientId ?? null,
8703
+ sandboxClientId: storedSandbox2?.sandboxClientId ?? parsedState.sandboxClientId ?? null,
8704
+ sandboxSessionId: storedSandbox2?.sandboxSessionId ?? parsedState.sandboxSessionId ?? null
8705
+ });
8706
+ }
8707
+ if (clerkOrgId && localState?.clerkOrgId && localState.clerkOrgId !== clerkOrgId) {
8708
+ window.sessionStorage.removeItem("quill-adminState");
8709
+ window.sessionStorage.removeItem("quill-client");
8590
8710
  }
8591
8711
  } catch (error2) {
8592
8712
  console.warn(
@@ -8594,8 +8714,14 @@ function AdminProvider({
8594
8714
  error2
8595
8715
  );
8596
8716
  }
8597
- window.sessionStorage.removeItem("quill-adminState");
8598
- window.sessionStorage.removeItem("quill-client");
8717
+ const storedSandbox = resolveSandboxSession(clerkOrgId);
8718
+ if (storedSandbox) {
8719
+ return mergeSandboxIntoState(buildDefaultState());
8720
+ }
8721
+ const storedWithoutOrg = resolveSandboxSession(null);
8722
+ if (storedWithoutOrg) {
8723
+ return mergeSandboxIntoState(buildDefaultState());
8724
+ }
8599
8725
  return null;
8600
8726
  };
8601
8727
  const initialState = (0, import_react27.useMemo)(() => {
@@ -8639,7 +8765,12 @@ function AdminProvider({
8639
8765
  return;
8640
8766
  }
8641
8767
  const activeClientId = state.client?._id ?? state.client?.id ?? state.client?.publicKey ?? state.client?.clientId;
8642
- if (!forceRefresh && !resetSandbox && activeClientId != null && String(activeClientId) === String(targetClientId)) {
8768
+ const targetClientIdString = String(targetClientId);
8769
+ const sandboxClientId = state.sandboxClientId ? String(state.sandboxClientId) : null;
8770
+ const sandboxParentClientId = state.sandboxParentClientId ? String(state.sandboxParentClientId) : null;
8771
+ const switchingOutsideSandbox = !!state.sandboxSessionId && targetClientIdString !== sandboxClientId && targetClientIdString !== sandboxParentClientId;
8772
+ const shouldResetSandbox = !!resetSandbox || switchingOutsideSandbox;
8773
+ if (!forceRefresh && !shouldResetSandbox && activeClientId != null && String(activeClientId) === String(targetClientId)) {
8643
8774
  return;
8644
8775
  }
8645
8776
  setClientLoading(true);
@@ -8647,7 +8778,7 @@ function AdminProvider({
8647
8778
  targetClientId,
8648
8779
  false,
8649
8780
  preserveSelectedDashboard,
8650
- resetSandbox
8781
+ shouldResetSandbox
8651
8782
  );
8652
8783
  return;
8653
8784
  }
@@ -8784,11 +8915,15 @@ function AdminProvider({
8784
8915
  setClientLoading(true);
8785
8916
  currentFetchingClientRef.current = publicKey2;
8786
8917
  const requestedClientId = String(publicKey2);
8787
- const sandboxClientId = state.sandboxClientId != null ? String(state.sandboxClientId) : null;
8788
- const sandboxParentClientId = state.sandboxParentClientId != null ? String(state.sandboxParentClientId) : null;
8789
- const loadingExistingSandbox = loadSandbox && !resetSandbox && !!sandboxClientId && (requestedClientId === sandboxClientId || requestedClientId === sandboxParentClientId);
8918
+ const storedSandbox = resolveSandboxSession(clerkOrgId ?? state.clerkOrgId);
8919
+ const sandboxClientId = state.sandboxClientId != null ? String(state.sandboxClientId) : storedSandbox?.sandboxClientId ?? null;
8920
+ const sandboxParentClientId = state.sandboxParentClientId != null ? String(state.sandboxParentClientId) : storedSandbox?.sandboxParentClientId ?? null;
8921
+ const sandboxSessionId = state.sandboxSessionId ?? storedSandbox?.sandboxSessionId ?? null;
8922
+ const loadingExistingSandbox = loadSandbox && !resetSandbox && !!sandboxClientId && !!sandboxSessionId && (requestedClientId === sandboxClientId || requestedClientId === sandboxParentClientId);
8923
+ const requestClientId = loadingExistingSandbox ? sandboxParentClientId ?? publicKey2 : publicKey2;
8790
8924
  if (resetSandbox) {
8791
8925
  agentChatState.clearChangelogEntries();
8926
+ clearSandboxSession();
8792
8927
  }
8793
8928
  try {
8794
8929
  const data = await quillFetchWithToken({
@@ -8796,14 +8931,14 @@ function AdminProvider({
8796
8931
  queryEndpoint,
8797
8932
  queryHeaders,
8798
8933
  withCredentials: !!state.withCredentials,
8799
- clientId: publicKey2
8934
+ clientId: requestClientId
8800
8935
  },
8801
8936
  task: "client",
8802
8937
  metadata: {
8803
- clientId: loadingExistingSandbox ? sandboxParentClientId ?? publicKey2 : publicKey2,
8938
+ clientId: loadingExistingSandbox ? sandboxParentClientId ?? requestClientId : requestClientId,
8804
8939
  fetchDefaultDashboard: true,
8805
8940
  sandboxClientId: loadingExistingSandbox ? sandboxClientId : void 0,
8806
- sandboxSessionId: loadingExistingSandbox ? state.sandboxSessionId ?? void 0 : void 0,
8941
+ sandboxSessionId: loadingExistingSandbox ? sandboxSessionId ?? void 0 : void 0,
8807
8942
  ...loadSandbox ? { loadSandbox: true } : {},
8808
8943
  ...resetSandbox ? { resetSandbox: true } : {}
8809
8944
  },
@@ -8837,11 +8972,11 @@ function AdminProvider({
8837
8972
  queryEndpoint,
8838
8973
  queryHeaders,
8839
8974
  withCredentials: !!state.withCredentials,
8840
- clientId: publicKey2
8975
+ clientId: requestClientId
8841
8976
  },
8842
8977
  task: "clients",
8843
8978
  metadata: {
8844
- clientId: publicKey2
8979
+ clientId: requestClientId
8845
8980
  },
8846
8981
  adminMode: true
8847
8982
  }) : Promise.resolve(void 0)
@@ -8860,9 +8995,48 @@ function AdminProvider({
8860
8995
  });
8861
8996
  }
8862
8997
  const sessionInfo = buildSessionInfo(result, publicKey2);
8863
- agentChatState.setSession(sessionInfo);
8998
+ if (sessionInfo) {
8999
+ agentChatState.setSession(sessionInfo);
9000
+ const sandboxFields = sandboxFieldsFromSession(sessionInfo, result.client);
9001
+ dispatch({
9002
+ type: "SET_SANDBOX_FIELDS",
9003
+ payload: sandboxFields
9004
+ });
9005
+ persistSandboxFromSessionInfo(
9006
+ getSandboxStorageScopeId(
9007
+ clerkOrgId,
9008
+ state.clerkOrgId,
9009
+ publicKey2
9010
+ ),
9011
+ sessionInfo,
9012
+ result.client
9013
+ );
9014
+ } else if (resetSandbox) {
9015
+ agentChatState.setSession(null);
9016
+ dispatch({
9017
+ type: "SET_SANDBOX_FIELDS",
9018
+ payload: {
9019
+ sandboxParentClientId: null,
9020
+ sandboxClientId: null,
9021
+ sandboxSessionId: null
9022
+ }
9023
+ });
9024
+ } else {
9025
+ const preservedSandbox = storedSandbox ?? resolveSandboxSession(clerkOrgId ?? state.clerkOrgId);
9026
+ if (preservedSandbox) {
9027
+ dispatch({
9028
+ type: "SET_SANDBOX_FIELDS",
9029
+ payload: {
9030
+ sandboxParentClientId: preservedSandbox.sandboxParentClientId,
9031
+ sandboxClientId: preservedSandbox.sandboxClientId,
9032
+ sandboxSessionId: preservedSandbox.sandboxSessionId
9033
+ }
9034
+ });
9035
+ agentChatState.setSession((prev) => prev ?? preservedSandbox.session);
9036
+ }
9037
+ }
8864
9038
  if (typeof window !== "undefined" && clerkOrgId) {
8865
- const sourceClientId = sessionInfo?.sourceClientId ?? requestedClientId;
9039
+ const sourceClientId = sessionInfo?.sourceClientId ?? storedSandbox?.sandboxParentClientId ?? requestedClientId;
8866
9040
  window.sessionStorage.setItem(
8867
9041
  "quill-client",
8868
9042
  JSON.stringify({
@@ -8871,16 +9045,6 @@ function AdminProvider({
8871
9045
  })
8872
9046
  );
8873
9047
  }
8874
- dispatch({
8875
- type: "SET_SANDBOX_FIELDS",
8876
- payload: {
8877
- sandboxParentClientId: sessionInfo ? String(
8878
- result.client.sandboxParentClientId ?? sessionInfo.sourceClientId
8879
- ) : null,
8880
- sandboxClientId: sessionInfo?.sandboxClientId ?? null,
8881
- sandboxSessionId: sessionInfo?.sessionId ?? null
8882
- }
8883
- });
8884
9048
  setClient({
8885
9049
  ...result.client,
8886
9050
  queryEndpoint: result.client.queryEndpoint ?? queryEndpoint,
@@ -8950,12 +9114,123 @@ function AdminProvider({
8950
9114
  dispatch({ type: "SET_CLERK_ORG_ID", payload: clerkOrgId });
8951
9115
  }
8952
9116
  }, [clerkOrgId]);
9117
+ (0, import_react27.useEffect)(() => {
9118
+ const previousClerkOrgId = previousClerkOrgIdRef.current;
9119
+ const currentClerkOrgId = clerkOrgId ?? null;
9120
+ if (previousClerkOrgId !== void 0 && previousClerkOrgId !== currentClerkOrgId) {
9121
+ clearSandboxSession();
9122
+ agentChatState.setSession(null);
9123
+ agentChatState.clearChangelogEntries();
9124
+ dispatch({
9125
+ type: "SET_SANDBOX_FIELDS",
9126
+ payload: {
9127
+ sandboxParentClientId: null,
9128
+ sandboxClientId: null,
9129
+ sandboxSessionId: null
9130
+ }
9131
+ });
9132
+ }
9133
+ previousClerkOrgIdRef.current = currentClerkOrgId;
9134
+ }, [clerkOrgId, agentChatState.setSession, agentChatState.clearChangelogEntries]);
9135
+ (0, import_react27.useEffect)(() => {
9136
+ if (!clerkOrgId) return;
9137
+ const storedSandbox = resolveSandboxSession(clerkOrgId);
9138
+ if (!storedSandbox) return;
9139
+ if (!state.sandboxSessionId || state.sandboxSessionId !== storedSandbox.sandboxSessionId) {
9140
+ dispatch({
9141
+ type: "SET_SANDBOX_FIELDS",
9142
+ payload: {
9143
+ sandboxParentClientId: storedSandbox.sandboxParentClientId,
9144
+ sandboxClientId: storedSandbox.sandboxClientId,
9145
+ sandboxSessionId: storedSandbox.sandboxSessionId
9146
+ }
9147
+ });
9148
+ }
9149
+ agentChatState.setSession((prev) => prev ?? storedSandbox.session);
9150
+ }, [clerkOrgId]);
9151
+ (0, import_react27.useEffect)(() => {
9152
+ if (!clerkOrgId) return;
9153
+ return subscribeSandboxSession((stored) => {
9154
+ if (!stored || stored.clerkOrgId !== clerkOrgId) {
9155
+ dispatch({
9156
+ type: "SET_SANDBOX_FIELDS",
9157
+ payload: {
9158
+ sandboxParentClientId: null,
9159
+ sandboxClientId: null,
9160
+ sandboxSessionId: null
9161
+ }
9162
+ });
9163
+ agentChatState.setSession(null);
9164
+ agentChatState.clearChangelogEntries();
9165
+ return;
9166
+ }
9167
+ dispatch({
9168
+ type: "SET_SANDBOX_FIELDS",
9169
+ payload: {
9170
+ sandboxParentClientId: stored.sandboxParentClientId,
9171
+ sandboxClientId: stored.sandboxClientId,
9172
+ sandboxSessionId: stored.sandboxSessionId
9173
+ }
9174
+ });
9175
+ agentChatState.setSession(stored.session);
9176
+ });
9177
+ }, [clerkOrgId, agentChatState.setSession, agentChatState.clearChangelogEntries]);
9178
+ (0, import_react27.useEffect)(() => {
9179
+ const scopeId = getSandboxStorageScopeId(
9180
+ clerkOrgId,
9181
+ state.clerkOrgId,
9182
+ publicKey
9183
+ );
9184
+ const session = agentChatState.session;
9185
+ const sessionId = session?.sessionId ?? state.sandboxSessionId;
9186
+ const sandboxClientId = session?.sandboxClientId ?? state.sandboxClientId ?? null;
9187
+ const sourceClientId = session?.sourceClientId ?? state.sandboxParentClientId ?? null;
9188
+ if (!scopeId || !sessionId || !sandboxClientId || !sourceClientId) {
9189
+ return;
9190
+ }
9191
+ const sessionPayload = session ?? {
9192
+ sessionId,
9193
+ sourceClientId,
9194
+ sourceClientName: "",
9195
+ sandboxClientId,
9196
+ sandboxClientName: "",
9197
+ status: "active"
9198
+ };
9199
+ persistSandboxFromSessionInfo(scopeId, sessionPayload, {
9200
+ sandboxParentClientId: sourceClientId
9201
+ });
9202
+ }, [
9203
+ clerkOrgId,
9204
+ publicKey,
9205
+ state.clerkOrgId,
9206
+ state.sandboxParentClientId,
9207
+ state.sandboxClientId,
9208
+ state.sandboxSessionId,
9209
+ agentChatState.session
9210
+ ]);
8953
9211
  (0, import_react27.useEffect)(() => {
8954
9212
  if (typeof window === "undefined") {
8955
9213
  return;
8956
9214
  }
9215
+ const storedSandbox = resolveSandboxSession(clerkOrgId ?? state.clerkOrgId);
9216
+ if (storedSandbox) {
9217
+ if (!state.sandboxSessionId || state.sandboxSessionId !== storedSandbox.sandboxSessionId) {
9218
+ dispatch({
9219
+ type: "SET_SANDBOX_FIELDS",
9220
+ payload: {
9221
+ sandboxParentClientId: storedSandbox.sandboxParentClientId,
9222
+ sandboxClientId: storedSandbox.sandboxClientId,
9223
+ sandboxSessionId: storedSandbox.sandboxSessionId
9224
+ }
9225
+ });
9226
+ }
9227
+ agentChatState.setSession((prev) => prev ?? storedSandbox.session);
9228
+ }
8957
9229
  if (publicKeyRef.current !== publicKey) {
8958
- dispatch({ type: "SET_ALL_STATE", payload: initialState });
9230
+ dispatch({
9231
+ type: "SET_ALL_STATE",
9232
+ payload: storedSandbox ? mergeSandboxIntoState(initialState, clerkOrgId) : initialState
9233
+ });
8959
9234
  publicKeyRef.current = publicKey;
8960
9235
  }
8961
9236
  const client = JSON.parse(
@@ -8965,8 +9240,7 @@ function AdminProvider({
8965
9240
  if (client && client.clerkOrgId === clerkOrgId) {
8966
9241
  overridePublicKey = client.id || client._id || client.publicKey;
8967
9242
  }
8968
- const hydratedClientId = state.sandboxParentClientId || state.client?.id || state.client?._id || state.client?.clientId || state.client?.publicKey;
8969
- const fetchPublicKey = overridePublicKey || hydratedClientId || publicKey;
9243
+ const fetchPublicKey = overridePublicKey || storedSandbox?.sandboxParentClientId || state.sandboxParentClientId || state.client?.id || state.client?._id || state.client?.clientId || state.client?.publicKey || publicKey;
8970
9244
  if (!fetchPublicKey) {
8971
9245
  setClientLoading(false);
8972
9246
  currentFetchingClientRef.current = void 0;
@@ -8974,7 +9248,7 @@ function AdminProvider({
8974
9248
  if (currentFetchingClientRef.current === fetchPublicKey) return;
8975
9249
  fetchClient(fetchPublicKey, true);
8976
9250
  }
8977
- }, [publicKey]);
9251
+ }, [publicKey, clerkOrgId]);
8978
9252
  (0, import_react27.useEffect)(() => {
8979
9253
  if (typeof window === "undefined") {
8980
9254
  return;
@@ -9239,8 +9513,8 @@ async function getClientTenantIds({
9239
9513
  }
9240
9514
 
9241
9515
  // src/public_components/DashboardManager.tsx
9242
- var import_react66 = require("react");
9243
- var import_react67 = require("@quillsql/react");
9516
+ var import_react67 = require("react");
9517
+ var import_react68 = require("@quillsql/react");
9244
9518
 
9245
9519
  // src/Admin.tsx
9246
9520
  var import_react31 = require("react");
@@ -21293,6 +21567,7 @@ function EditEnvironmentModal({
21293
21567
  state,
21294
21568
  dispatch,
21295
21569
  refreshClientsList,
21570
+ setClient,
21296
21571
  getToken,
21297
21572
  quillFetchWithToken,
21298
21573
  eventTracking
@@ -21304,6 +21579,12 @@ function EditEnvironmentModal({
21304
21579
  const [isSubmitTenantLoading, setSubmitTenantLoading] = (0, import_react50.useState)(false);
21305
21580
  const [isSaveEnvironmentLoading, setIsSaveEnvironmentLoading] = (0, import_react50.useState)(false);
21306
21581
  const [isDeleteEnvironmentLoading, setIsDeleteEnvironmentLoading] = (0, import_react50.useState)(false);
21582
+ const [isCreateChildEnvironmentLoading, setIsCreateChildEnvironmentLoading] = (0, import_react50.useState)(false);
21583
+ const [
21584
+ isPromoteChildEnvironmentLoading,
21585
+ setIsPromoteChildEnvironmentLoading
21586
+ ] = (0, import_react50.useState)(false);
21587
+ const [developmentEnvironmentConfirm, setDevelopmentEnvironmentConfirm] = (0, import_react50.useState)(null);
21307
21588
  const [validationError, setValidationError] = (0, import_react50.useState)(
21308
21589
  void 0
21309
21590
  );
@@ -21311,6 +21592,26 @@ function EditEnvironmentModal({
21311
21592
  const connectionDetails = (0, import_react50.useMemo)(() => {
21312
21593
  return getDatabaseConnectionFormat(state.client?.databaseType || "");
21313
21594
  }, [state.client?.databaseType]);
21595
+ const sourceClientId = (0, import_react50.useMemo)(() => {
21596
+ if (state.sandboxParentClientId != null) {
21597
+ return String(state.sandboxParentClientId);
21598
+ }
21599
+ return clientRecordId(state.client);
21600
+ }, [state.sandboxParentClientId, state.client]);
21601
+ const relatedChildEnvironments = (0, import_react50.useMemo)(() => {
21602
+ const parentClientId = state.client?.sandboxParentClientId != null ? String(state.client.sandboxParentClientId) : sourceClientId;
21603
+ if (!parentClientId) return [];
21604
+ return state.clients.filter(
21605
+ (c2) => c2.sandboxParentClientId != null && String(c2.sandboxParentClientId) === parentClientId
21606
+ );
21607
+ }, [state.clients, state.client?.sandboxParentClientId, sourceClientId]);
21608
+ const sourceEnvironmentName = (0, import_react50.useMemo)(() => {
21609
+ if (!sourceClientId) return state.client?.name;
21610
+ const sourceClient = state.clients.find(
21611
+ (c2) => clientRecordId(c2) === sourceClientId
21612
+ );
21613
+ return sourceClient?.name ?? state.client?.name;
21614
+ }, [sourceClientId, state.clients, state.client?.name]);
21314
21615
  const [tenantToEdit, setTenantToEdit] = (0, import_react50.useState)(
21315
21616
  void 0
21316
21617
  );
@@ -21709,6 +22010,104 @@ function EditEnvironmentModal({
21709
22010
  setFetchSchemasLoading(false);
21710
22011
  }
21711
22012
  };
22013
+ const handleCreateChildEnvironment = async () => {
22014
+ if (!sourceClientId) return;
22015
+ setDevelopmentEnvironmentConfirm(null);
22016
+ setIsCreateChildEnvironmentLoading(true);
22017
+ try {
22018
+ const response = await quillFetchWithToken({
22019
+ client: {
22020
+ queryEndpoint: state.queryEndpoint,
22021
+ clientId: sourceClientId,
22022
+ withCredentials: !!state.withCredentials,
22023
+ queryHeaders: state.queryHeaders
22024
+ },
22025
+ task: "create-sandbox",
22026
+ metadata: {
22027
+ clientId: sourceClientId,
22028
+ permanentSandbox: true
22029
+ },
22030
+ adminMode: true
22031
+ });
22032
+ if (response.status === "error") {
22033
+ throw new Error(response.error);
22034
+ }
22035
+ await refreshClientsList(sourceClientId);
22036
+ } catch (e2) {
22037
+ eventTracking?.logError?.({
22038
+ type: "bug",
22039
+ // TODO: determine type
22040
+ severity: "high",
22041
+ message: "Error creating child environment",
22042
+ errorMessage: e2.message,
22043
+ errorStack: e2.stack,
22044
+ errorData: {
22045
+ caller: "EditEnvironmentModal",
22046
+ function: "handleCreateChildEnvironment"
22047
+ }
22048
+ });
22049
+ setValidationError(e2.message);
22050
+ } finally {
22051
+ setIsCreateChildEnvironmentLoading(false);
22052
+ }
22053
+ };
22054
+ const handlePromoteChildEnvironment = async () => {
22055
+ if (developmentEnvironmentConfirm?.action !== "promote") return;
22056
+ const childEnvironmentToPromote = developmentEnvironmentConfirm.environment;
22057
+ const promoteClientId = clientRecordId(childEnvironmentToPromote);
22058
+ if (!promoteClientId) {
22059
+ setValidationError("Cannot promote: missing target environment id.");
22060
+ return;
22061
+ }
22062
+ setDevelopmentEnvironmentConfirm(null);
22063
+ setIsPromoteChildEnvironmentLoading(true);
22064
+ try {
22065
+ const response = await quillFetchWithToken({
22066
+ client: {
22067
+ queryEndpoint: state.queryEndpoint,
22068
+ clientId: promoteClientId,
22069
+ withCredentials: !!state.withCredentials,
22070
+ queryHeaders: state.queryHeaders
22071
+ },
22072
+ task: "promote",
22073
+ metadata: {
22074
+ clientId: promoteClientId,
22075
+ forcePromote: true
22076
+ },
22077
+ adminMode: true
22078
+ });
22079
+ if (response.status === "error" || response.error) {
22080
+ throw new Error(response.error);
22081
+ }
22082
+ const hasActiveSandbox = state.sandboxSessionId != null || state.sandboxClientId != null;
22083
+ if (hasActiveSandbox && sourceClientId) {
22084
+ setClient(
22085
+ { clientId: sourceClientId },
22086
+ true,
22087
+ true,
22088
+ true
22089
+ );
22090
+ }
22091
+ await refreshClientsList(sourceClientId);
22092
+ setIsOpen(false);
22093
+ } catch (e2) {
22094
+ eventTracking?.logError?.({
22095
+ type: "bug",
22096
+ // TODO: determine type
22097
+ severity: "high",
22098
+ message: "Error promoting child environment",
22099
+ errorMessage: e2.message,
22100
+ errorStack: e2.stack,
22101
+ errorData: {
22102
+ caller: "EditEnvironmentModal",
22103
+ function: "handlePromoteChildEnvironment"
22104
+ }
22105
+ });
22106
+ setValidationError(e2.message);
22107
+ } finally {
22108
+ setIsPromoteChildEnvironmentLoading(false);
22109
+ }
22110
+ };
21712
22111
  const handleDeleteEnvironment = async () => {
21713
22112
  if (state.clients.length === 1) {
21714
22113
  alert("You cannot delete the only environment");
@@ -21755,8 +22154,9 @@ function EditEnvironmentModal({
21755
22154
  }
21756
22155
  }
21757
22156
  };
21758
- const isEnvironmentModalLoading = isDeleteEnvironmentLoading || isSaveEnvironmentLoading;
21759
- const environmentLoadingLabel = isDeleteEnvironmentLoading ? "Deleting environment..." : "Saving environment...";
22157
+ const isEnvironmentModalLoading = isDeleteEnvironmentLoading || isSaveEnvironmentLoading || isCreateChildEnvironmentLoading || isPromoteChildEnvironmentLoading;
22158
+ const environmentLoadingLabel = isDeleteEnvironmentLoading ? "Deleting environment..." : isCreateChildEnvironmentLoading ? "Creating child environment..." : isPromoteChildEnvironmentLoading ? "Promoting environment..." : "Saving environment...";
22159
+ const isDevelopmentEnvironmentConfirmLoading = developmentEnvironmentConfirm?.action === "promote" ? isPromoteChildEnvironmentLoading : isCreateChildEnvironmentLoading;
21760
22160
  return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(import_jsx_runtime52.Fragment, { children: [
21761
22161
  /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
21762
22162
  ModalComponent,
@@ -21769,6 +22169,9 @@ function EditEnvironmentModal({
21769
22169
  setSelectedEnvironmentName(state.client.name);
21770
22170
  setIsSaveEnvironmentLoading(false);
21771
22171
  setIsDeleteEnvironmentLoading(false);
22172
+ setIsCreateChildEnvironmentLoading(false);
22173
+ setIsPromoteChildEnvironmentLoading(false);
22174
+ setDevelopmentEnvironmentConfirm(null);
21772
22175
  },
21773
22176
  style: {
21774
22177
  minWidth: "600px"
@@ -21939,38 +22342,115 @@ function EditEnvironmentModal({
21939
22342
  disabled: isEnvironmentModalLoading
21940
22343
  }
21941
22344
  ) }),
21942
- /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(import_jsx_runtime52.Fragment, { children: [
21943
- /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(CardSection, { children: "Danger Zone" }),
21944
- /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
21945
- "div",
21946
- {
21947
- style: {
21948
- display: "flex",
21949
- flexDirection: "column",
21950
- width: "fit-content",
21951
- gap: 16
21952
- },
21953
- children: [
21954
- /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
21955
- SecondaryButtonComponent,
21956
- {
21957
- onClick: () => setIsConnectDatabaseModalOpen(true),
21958
- label: "Edit Database Connection",
21959
- disabled: isEnvironmentModalLoading
21960
- }
21961
- ),
21962
- /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
21963
- SecondaryButtonComponent,
21964
- {
21965
- onClick: handleDeleteEnvironment,
21966
- label: "Delete Environment",
21967
- disabled: isEnvironmentModalLoading
21968
- }
21969
- )
21970
- ]
21971
- }
21972
- )
21973
- ] }),
22345
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(CardSection, { children: "Danger Zone" }),
22346
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
22347
+ "div",
22348
+ {
22349
+ style: {
22350
+ display: "flex",
22351
+ flexDirection: "column",
22352
+ width: "fit-content",
22353
+ gap: 16
22354
+ },
22355
+ children: [
22356
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
22357
+ SecondaryButtonComponent,
22358
+ {
22359
+ onClick: () => setIsConnectDatabaseModalOpen(true),
22360
+ label: "Edit Database Connection",
22361
+ disabled: isEnvironmentModalLoading
22362
+ }
22363
+ ),
22364
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
22365
+ SecondaryButtonComponent,
22366
+ {
22367
+ onClick: handleDeleteEnvironment,
22368
+ label: "Delete Environment",
22369
+ disabled: isEnvironmentModalLoading
22370
+ }
22371
+ )
22372
+ ]
22373
+ }
22374
+ ),
22375
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(CardSection, { children: "Development Environments" }),
22376
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
22377
+ "div",
22378
+ {
22379
+ style: {
22380
+ display: "flex",
22381
+ flexDirection: "column",
22382
+ width: "fit-content",
22383
+ gap: 16
22384
+ },
22385
+ children: [
22386
+ relatedChildEnvironments.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
22387
+ "table",
22388
+ {
22389
+ style: {
22390
+ borderCollapse: "collapse",
22391
+ width: "100%",
22392
+ minWidth: 280,
22393
+ fontFamily: state.theme.fontFamily,
22394
+ fontSize: 14,
22395
+ color: state.theme.primaryTextColor
22396
+ },
22397
+ children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("tbody", { children: relatedChildEnvironments.map((env) => {
22398
+ const envId = clientRecordId(env);
22399
+ const cellBorder = `1px solid ${state.theme.borderColor ?? "#e7e7e7"}`;
22400
+ return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("tr", { children: [
22401
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
22402
+ "td",
22403
+ {
22404
+ style: {
22405
+ border: cellBorder,
22406
+ padding: "8px 12px",
22407
+ fontWeight: 500
22408
+ },
22409
+ children: env.name
22410
+ }
22411
+ ),
22412
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
22413
+ "td",
22414
+ {
22415
+ style: {
22416
+ border: cellBorder,
22417
+ padding: "8px 12px",
22418
+ width: 1,
22419
+ whiteSpace: "nowrap"
22420
+ },
22421
+ children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
22422
+ ButtonComponent,
22423
+ {
22424
+ label: "Promote",
22425
+ onClick: () => setDevelopmentEnvironmentConfirm({
22426
+ action: "promote",
22427
+ environment: env
22428
+ }),
22429
+ disabled: isEnvironmentModalLoading || developmentEnvironmentConfirm != null,
22430
+ style: {
22431
+ height: 32,
22432
+ paddingLeft: 12,
22433
+ paddingRight: 12
22434
+ }
22435
+ }
22436
+ )
22437
+ }
22438
+ )
22439
+ ] }, envId ?? env.name);
22440
+ }) })
22441
+ }
22442
+ ),
22443
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
22444
+ SecondaryButtonComponent,
22445
+ {
22446
+ onClick: () => setDevelopmentEnvironmentConfirm({ action: "create" }),
22447
+ label: "+ Create New",
22448
+ disabled: isEnvironmentModalLoading
22449
+ }
22450
+ ) })
22451
+ ]
22452
+ }
22453
+ ),
21974
22454
  /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { style: { height: 18 } }),
21975
22455
  /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
21976
22456
  "div",
@@ -22209,6 +22689,117 @@ function EditEnvironmentModal({
22209
22689
  )
22210
22690
  }
22211
22691
  ),
22692
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
22693
+ ModalComponent,
22694
+ {
22695
+ isOpen: developmentEnvironmentConfirm != null,
22696
+ onClose: () => {
22697
+ if (isDevelopmentEnvironmentConfirmLoading) return;
22698
+ setDevelopmentEnvironmentConfirm(null);
22699
+ },
22700
+ style: {
22701
+ width: 480
22702
+ },
22703
+ children: /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
22704
+ "div",
22705
+ {
22706
+ style: {
22707
+ display: "flex",
22708
+ flexDirection: "column",
22709
+ gap: 20,
22710
+ width: "100%",
22711
+ padding: 24
22712
+ },
22713
+ children: [
22714
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(CardSection, { children: developmentEnvironmentConfirm?.action === "promote" ? "Promote Environment Changes" : "Create child environment" }),
22715
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
22716
+ "div",
22717
+ {
22718
+ style: {
22719
+ display: "flex",
22720
+ flexDirection: "column",
22721
+ gap: 12,
22722
+ fontFamily: state.theme.fontFamily,
22723
+ fontSize: 14,
22724
+ lineHeight: 1.6,
22725
+ color: state.theme.primaryTextColor
22726
+ },
22727
+ children: [
22728
+ developmentEnvironmentConfirm?.action === "promote" ? /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("p", { style: { margin: 0 }, children: [
22729
+ "Promoting",
22730
+ " ",
22731
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("strong", { children: [
22732
+ developmentEnvironmentConfirm.environment?.name ?? "this environment",
22733
+ "\xA0into\xA0",
22734
+ sourceEnvironmentName ?? "the current environment"
22735
+ ] }),
22736
+ " ",
22737
+ "will replicate the development environment's state into the current environment."
22738
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("p", { style: { margin: 0 }, children: [
22739
+ "Creating a child development environment for",
22740
+ " ",
22741
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("strong", { children: sourceEnvironmentName ?? "the current environment" }),
22742
+ " ",
22743
+ "will create an environment you can use to preview changes before promoting them into the currently active environment."
22744
+ ] }),
22745
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
22746
+ "p",
22747
+ {
22748
+ style: {
22749
+ margin: 0,
22750
+ padding: "12px 14px",
22751
+ borderRadius: 6,
22752
+ border: `1px solid ${state.theme.borderColor ?? "#e7e7e7"}`,
22753
+ backgroundColor: state.theme.hoverBackgroundColor ?? "#f7f7f7",
22754
+ color: "#DC2626"
22755
+ },
22756
+ children: "This is not a sandbox operation and will immediately apply to the live environment. Your current active session will be discarded."
22757
+ }
22758
+ )
22759
+ ]
22760
+ }
22761
+ ),
22762
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
22763
+ "div",
22764
+ {
22765
+ style: {
22766
+ display: "flex",
22767
+ flexDirection: "row",
22768
+ justifyContent: "flex-end",
22769
+ gap: 16,
22770
+ width: "100%"
22771
+ },
22772
+ children: [
22773
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
22774
+ SecondaryButtonComponent,
22775
+ {
22776
+ label: "Cancel",
22777
+ onClick: () => setDevelopmentEnvironmentConfirm(null),
22778
+ disabled: isDevelopmentEnvironmentConfirmLoading
22779
+ }
22780
+ ),
22781
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
22782
+ ButtonComponent,
22783
+ {
22784
+ label: "Confirm",
22785
+ onClick: () => {
22786
+ if (developmentEnvironmentConfirm?.action === "promote") {
22787
+ handlePromoteChildEnvironment();
22788
+ } else if (developmentEnvironmentConfirm?.action === "create") {
22789
+ handleCreateChildEnvironment();
22790
+ }
22791
+ },
22792
+ disabled: isDevelopmentEnvironmentConfirmLoading
22793
+ }
22794
+ )
22795
+ ]
22796
+ }
22797
+ )
22798
+ ]
22799
+ }
22800
+ )
22801
+ }
22802
+ ),
22212
22803
  /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
22213
22804
  ModalComponent,
22214
22805
  {
@@ -22879,7 +23470,8 @@ function SavedQueriesModal({
22879
23470
  ) });
22880
23471
  }
22881
23472
  function SavedQueryTile({ report }) {
22882
- const { state, dispatch, getToken } = useAdmin();
23473
+ const { state, dispatch, getToken, eventTracking } = useAdmin();
23474
+ const { reload } = (0, import_react56.useDashboardInternal)(SAVED_QUERIES_DASHBOARD);
22883
23475
  (0, import_react55.useEffect)(() => {
22884
23476
  async function getIsOpenableByReportBuilder() {
22885
23477
  const hello = await parseQuillReportToQuillReportInternal(
@@ -22904,6 +23496,14 @@ function SavedQueryTile({ report }) {
22904
23496
  payload: report?.queryString
22905
23497
  });
22906
23498
  };
23499
+ const handleDelete = async () => {
23500
+ if (await deleteReport(report.id, state, getToken, eventTracking)) {
23501
+ reload(SAVED_QUERIES_DASHBOARD, true, {
23502
+ report: { id: report.id },
23503
+ action: "delete"
23504
+ });
23505
+ }
23506
+ };
22907
23507
  if (!report.queryString) {
22908
23508
  return null;
22909
23509
  }
@@ -22937,7 +23537,8 @@ function SavedQueryTile({ report }) {
22937
23537
  label: "Open in SQL Editor \u2197",
22938
23538
  onClick: handleOpenReportInSQLEditor
22939
23539
  }
22940
- )
23540
+ ),
23541
+ /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(SecondaryButtonPrimitive_default, { label: "Delete", onClick: handleDelete })
22941
23542
  ]
22942
23543
  }
22943
23544
  );
@@ -26445,11 +27046,42 @@ function DashboardSelectPopover({
26445
27046
  }
26446
27047
 
26447
27048
  // src/components/AgentChat/AgentChatPanel.tsx
26448
- var import_react64 = require("react");
27049
+ var import_react65 = require("react");
26449
27050
  var import_re_resizable2 = require("re-resizable");
26450
27051
 
26451
- // src/components/AgentChat/AgentChat.tsx
27052
+ // src/hooks/useSandboxSession.ts
26452
27053
  var import_react62 = require("react");
27054
+ function useSandboxSession() {
27055
+ const { state } = useAdmin();
27056
+ const { session } = useAgentChat();
27057
+ return (0, import_react62.useMemo)(() => {
27058
+ const sessionId = session?.sessionId ?? state.sandboxSessionId ?? null;
27059
+ const sandboxClientId = session?.sandboxClientId ?? state.sandboxClientId ?? null;
27060
+ const sourceClientId = session?.sourceClientId ?? state.sandboxParentClientId ?? null;
27061
+ const mergedSession = session ?? (sessionId && sandboxClientId && sourceClientId ? {
27062
+ sessionId,
27063
+ sourceClientId,
27064
+ sourceClientName: "",
27065
+ sandboxClientId,
27066
+ sandboxClientName: "",
27067
+ status: "active"
27068
+ } : null);
27069
+ return {
27070
+ sessionId,
27071
+ sandboxClientId,
27072
+ sourceClientId,
27073
+ session: mergedSession
27074
+ };
27075
+ }, [
27076
+ session,
27077
+ state.sandboxSessionId,
27078
+ state.sandboxClientId,
27079
+ state.sandboxParentClientId
27080
+ ]);
27081
+ }
27082
+
27083
+ // src/components/AgentChat/AgentChat.tsx
27084
+ var import_react63 = require("react");
26453
27085
 
26454
27086
  // src/components/AgentChat/agentChatMarkdownCss.ts
26455
27087
  var AGENT_CHAT_MARKDOWN_STYLE_ID = "quillsql-agent-chat-markdown";
@@ -26708,9 +27340,9 @@ async function* streamResponseHandler(response) {
26708
27340
  }
26709
27341
 
26710
27342
  // src/components/AgentChat/AgentChat.tsx
26711
- var import_react63 = require("@quillsql/react");
27343
+ var import_react64 = require("@quillsql/react");
26712
27344
  var import_jsx_runtime62 = require("react/jsx-runtime");
26713
- var MarkdownContent = (0, import_react62.memo)(function MarkdownContent2({
27345
+ var MarkdownContent = (0, import_react63.memo)(function MarkdownContent2({
26714
27346
  content
26715
27347
  }) {
26716
27348
  return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_react_markdown.default, { remarkPlugins: [import_remark_gfm.default], children: content });
@@ -26952,7 +27584,7 @@ function ToolCallBlock({ toolCall }) {
26952
27584
  );
26953
27585
  }
26954
27586
  function ToolCallResult({ content }) {
26955
- const [expanded, setExpanded] = (0, import_react62.useState)(false);
27587
+ const [expanded, setExpanded] = (0, import_react63.useState)(false);
26956
27588
  if (!content) return null;
26957
27589
  const isLong = content.length > 300;
26958
27590
  const displayed = isLong && !expanded ? content.slice(0, 300) + "..." : content;
@@ -27417,7 +28049,7 @@ function AgentChat({
27417
28049
  sourceClientId,
27418
28050
  getToken
27419
28051
  }) {
27420
- (0, import_react62.useEffect)(() => {
28052
+ (0, import_react63.useEffect)(() => {
27421
28053
  ensureAgentChatMarkdownStylesInjected();
27422
28054
  }, []);
27423
28055
  const {
@@ -27431,9 +28063,9 @@ function AgentChat({
27431
28063
  } = useAgentChat();
27432
28064
  const { state, setClient, quillFetchWithToken, refreshClientsList } = useAdmin();
27433
28065
  const { schema: allTableData } = useDatabaseSchema();
27434
- const { allReportsById } = (0, import_react63.useAllReports)();
27435
- const { data: virtualTables } = (0, import_react63.useVirtualTables)();
27436
- const changelogDiffs = (0, import_react62.useMemo)(
28066
+ const { allReportsById } = (0, import_react64.useAllReports)();
28067
+ const { data: virtualTables } = (0, import_react64.useVirtualTables)();
28068
+ const changelogDiffs = (0, import_react63.useMemo)(
27437
28069
  () => changelogEntries.flatMap((entry) => {
27438
28070
  const diff = parseDiffEntry(entry);
27439
28071
  return diff ? [diff] : [];
@@ -27464,17 +28096,17 @@ function AgentChat({
27464
28096
  console.warn("[agent] fetch-changelog-list failed:", err);
27465
28097
  }
27466
28098
  };
27467
- const [input, setInput] = (0, import_react62.useState)("");
27468
- const [inputError, setInputError] = (0, import_react62.useState)("");
27469
- const [isLoading, setIsLoading] = (0, import_react62.useState)(false);
27470
- const [isPromoting, setIsPromoting] = (0, import_react62.useState)(false);
27471
- const [isDiscarding, setIsDiscarding] = (0, import_react62.useState)(false);
27472
- const [confirmAction, setConfirmAction] = (0, import_react62.useState)(null);
27473
- const containerRef = (0, import_react62.useRef)(null);
27474
- const textareaRef = (0, import_react62.useRef)(null);
27475
- const abortControllerRef = (0, import_react62.useRef)(null);
27476
- const lastScrolled = (0, import_react62.useRef)(Date.now());
27477
- (0, import_react62.useEffect)(() => {
28099
+ const [input, setInput] = (0, import_react63.useState)("");
28100
+ const [inputError, setInputError] = (0, import_react63.useState)("");
28101
+ const [isLoading, setIsLoading] = (0, import_react63.useState)(false);
28102
+ const [isPromoting, setIsPromoting] = (0, import_react63.useState)(false);
28103
+ const [isDiscarding, setIsDiscarding] = (0, import_react63.useState)(false);
28104
+ const [confirmAction, setConfirmAction] = (0, import_react63.useState)(null);
28105
+ const containerRef = (0, import_react63.useRef)(null);
28106
+ const textareaRef = (0, import_react63.useRef)(null);
28107
+ const abortControllerRef = (0, import_react63.useRef)(null);
28108
+ const lastScrolled = (0, import_react63.useRef)(Date.now());
28109
+ (0, import_react63.useEffect)(() => {
27478
28110
  const run = async () => {
27479
28111
  if (!sandboxClientId || !agentSessionId) {
27480
28112
  return;
@@ -27483,7 +28115,7 @@ function AgentChat({
27483
28115
  };
27484
28116
  run();
27485
28117
  }, [sandboxClientId, agentSessionId]);
27486
- (0, import_react62.useEffect)(() => {
28118
+ (0, import_react63.useEffect)(() => {
27487
28119
  const delay2 = Math.max(0, 500 - (Date.now() - lastScrolled.current));
27488
28120
  const timer = setTimeout(() => {
27489
28121
  const el = containerRef.current;
@@ -27501,7 +28133,7 @@ function AgentChat({
27501
28133
  abortControllerRef.current = null;
27502
28134
  setIsLoading(false);
27503
28135
  };
27504
- (0, import_react62.useEffect)(() => {
28136
+ (0, import_react63.useEffect)(() => {
27505
28137
  if (!abortControllerRef.current) return;
27506
28138
  abortControllerRef.current.abort();
27507
28139
  abortControllerRef.current = null;
@@ -27517,6 +28149,7 @@ function AgentChat({
27517
28149
  setMessages((prev) => prev.filter((m3) => m3.isWelcome));
27518
28150
  setSession(null);
27519
28151
  clearChangelogEntries();
28152
+ clearSandboxSession();
27520
28153
  const activeClientId = getActiveClientId(state.client);
27521
28154
  const sourceId = sourceClientId || state.sandboxParentClientId || activeClientId || null;
27522
28155
  if (!sourceId) return;
@@ -28264,38 +28897,48 @@ function AgentChatPanel() {
28264
28897
  const {
28265
28898
  messages,
28266
28899
  setMessages,
28267
- session,
28268
28900
  setSession,
28269
28901
  showToolOutputs,
28270
28902
  setShowToolOutputs,
28271
28903
  clearChangelogEntries
28272
28904
  } = useAgentChat();
28273
- const sourceClientId = state.sandboxParentClientId;
28274
- const sandboxClientId = state.sandboxClientId ?? session?.sandboxClientId ?? null;
28275
- const [collapsed, setCollapsed] = (0, import_react64.useState)(false);
28905
+ const {
28906
+ sessionId,
28907
+ sandboxClientId,
28908
+ sourceClientId,
28909
+ session
28910
+ } = useSandboxSession();
28911
+ const [collapsed, setCollapsed] = (0, import_react65.useState)(false);
28276
28912
  const minWidth = typeof window !== "undefined" ? Math.max(DEFAULT_MIN_WIDTH, window.innerWidth * DEFAULT_WIDTH_FRACTION) : 480;
28277
- const [width, setWidth] = (0, import_react64.useState)(
28913
+ const [width, setWidth] = (0, import_react65.useState)(
28278
28914
  () => getInitialWidth(DEFAULT_STORAGE_KEY, minWidth)
28279
28915
  );
28280
28916
  const maxWidth = typeof window !== "undefined" ? window.innerWidth * DEFAULT_MAX_WIDTH_FRACTION : 1200;
28281
- (0, import_react64.useEffect)(() => {
28917
+ (0, import_react65.useEffect)(() => {
28282
28918
  if (typeof window === "undefined") return;
28283
28919
  window.localStorage.setItem(DEFAULT_STORAGE_KEY, String(Math.round(width)));
28284
28920
  }, [width]);
28285
- const prevClientIdRef = (0, import_react64.useRef)(clientId);
28286
- (0, import_react64.useEffect)(() => {
28921
+ const prevClientIdRef = (0, import_react65.useRef)(clientId);
28922
+ (0, import_react65.useEffect)(() => {
28287
28923
  const prev = prevClientIdRef.current;
28288
28924
  prevClientIdRef.current = clientId;
28289
28925
  if (!prev || !clientId || prev === clientId) return;
28290
28926
  if (sandboxClientId && clientId === sandboxClientId) return;
28291
28927
  if (sourceClientId && clientId === sourceClientId) return;
28928
+ if (state.sandboxSessionId && (clientId === state.sandboxClientId || clientId === state.sandboxParentClientId)) {
28929
+ return;
28930
+ }
28292
28931
  setMessages((prev2) => prev2.filter((m3) => m3.isWelcome));
28293
28932
  setSession(null);
28294
28933
  clearChangelogEntries();
28934
+ clearSandboxSession();
28295
28935
  }, [
28296
28936
  clientId,
28297
28937
  sandboxClientId,
28298
28938
  sourceClientId,
28939
+ state.sandboxSessionId,
28940
+ state.sandboxClientId,
28941
+ state.sandboxParentClientId,
28299
28942
  setMessages,
28300
28943
  setSession,
28301
28944
  clearChangelogEntries
@@ -28595,9 +29238,9 @@ function AgentChatPanel() {
28595
29238
  children: clientId && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
28596
29239
  AgentChat,
28597
29240
  {
28598
- agentSessionId: session?.sessionId ?? "",
29241
+ agentSessionId: sessionId ?? "",
28599
29242
  sandboxClientId: sandboxClientId ?? "",
28600
- sourceClientId: session?.sourceClientId ?? sourceClientId ?? "",
29243
+ sourceClientId: sourceClientId ?? "",
28601
29244
  getToken: async () => await getToken() || ""
28602
29245
  }
28603
29246
  )
@@ -28613,13 +29256,13 @@ function AgentChatPanel() {
28613
29256
  }
28614
29257
 
28615
29258
  // src/components/EnvironmentSwitcherWithModals.tsx
28616
- var import_react65 = require("react");
29259
+ var import_react66 = require("react");
28617
29260
  var import_jsx_runtime64 = require("react/jsx-runtime");
28618
29261
  function EnvironmentSwitcherWithModals() {
28619
29262
  const { state, setClient, clientLoading } = useAdmin();
28620
- const envSelectRef = (0, import_react65.useRef)(null);
28621
- const [editEnvironmentModalIsOpen, setEditEnvironmentModalIsOpen] = (0, import_react65.useState)(false);
28622
- const [showCreateEnvironmentModal, setShowCreateEnvironmentModal] = (0, import_react65.useState)(false);
29263
+ const envSelectRef = (0, import_react66.useRef)(null);
29264
+ const [editEnvironmentModalIsOpen, setEditEnvironmentModalIsOpen] = (0, import_react66.useState)(false);
29265
+ const [showCreateEnvironmentModal, setShowCreateEnvironmentModal] = (0, import_react66.useState)(false);
28623
29266
  return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(import_jsx_runtime64.Fragment, { children: [
28624
29267
  /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { ref: envSelectRef, className: "flex flex-col", children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
28625
29268
  EnvSelectPopover,
@@ -28744,14 +29387,14 @@ function DashboardManager({
28744
29387
  quillFetchWithToken,
28745
29388
  eventTracking
28746
29389
  } = useAdmin();
28747
- const parentRef = (0, import_react66.useRef)(null);
28748
- const dashboardSelectPopoverRef = (0, import_react66.useRef)(null);
28749
- const [newDashboardModalIsOpen, setNewDashboardModalIsOpen] = (0, import_react66.useState)(false);
28750
- const [editFilterModalIsOpen, setEditFilterModalIsOpen] = (0, import_react66.useState)(false);
28751
- const [editEnvironmentModalIsOpen, setEditEnvironmentModalIsOpen] = (0, import_react66.useState)(false);
28752
- const [userFilters, setUserFilters] = (0, import_react66.useState)([]);
29390
+ const parentRef = (0, import_react67.useRef)(null);
29391
+ const dashboardSelectPopoverRef = (0, import_react67.useRef)(null);
29392
+ const [newDashboardModalIsOpen, setNewDashboardModalIsOpen] = (0, import_react67.useState)(false);
29393
+ const [editFilterModalIsOpen, setEditFilterModalIsOpen] = (0, import_react67.useState)(false);
29394
+ const [editEnvironmentModalIsOpen, setEditEnvironmentModalIsOpen] = (0, import_react67.useState)(false);
29395
+ const [userFilters, setUserFilters] = (0, import_react67.useState)([]);
28753
29396
  const showCreateEnvironmentModal = state.activeComponent === "CreateEnvironment";
28754
- const setShowCreateEnvironmentModal = (0, import_react66.useCallback)(
29397
+ const setShowCreateEnvironmentModal = (0, import_react67.useCallback)(
28755
29398
  (show) => {
28756
29399
  dispatch({
28757
29400
  type: "SET_ACTIVE_COMPONENT",
@@ -28760,8 +29403,8 @@ function DashboardManager({
28760
29403
  },
28761
29404
  [dispatch]
28762
29405
  );
28763
- const { data: dashboardConfig, reload: reloadDashboard } = (0, import_react67.useDashboardInternal)(state.selectedDashboard, userFilters);
28764
- const { dashboards, isLoading: dashboardsLoading } = (0, import_react67.useDashboards)();
29406
+ const { data: dashboardConfig, reload: reloadDashboard } = (0, import_react68.useDashboardInternal)(state.selectedDashboard, userFilters);
29407
+ const { dashboards, isLoading: dashboardsLoading } = (0, import_react68.useDashboards)();
28765
29408
  useLongLoading(dashboardsLoading, {
28766
29409
  origin: "DashboardManager",
28767
29410
  loadDescription: "Loading dashboards"
@@ -28770,7 +29413,7 @@ function DashboardManager({
28770
29413
  const visibleDashboards = dashboards?.filter(
28771
29414
  (dashboard) => dashboard.name !== SAVED_QUERIES_DASHBOARD
28772
29415
  ) ?? [];
28773
- (0, import_react66.useEffect)(() => {
29416
+ (0, import_react67.useEffect)(() => {
28774
29417
  if (navigateToVirtualTableManager) {
28775
29418
  dispatch({
28776
29419
  type: "SET_NAVIGATE_TO_VIRTUAL_TABLE_BUILDER",
@@ -28780,7 +29423,7 @@ function DashboardManager({
28780
29423
  console.warn("navigateToDashboardBuilder is not defined");
28781
29424
  }
28782
29425
  }, []);
28783
- (0, import_react66.useEffect)(() => {
29426
+ (0, import_react67.useEffect)(() => {
28784
29427
  if (clientLoading || dashboardsLoading) {
28785
29428
  return;
28786
29429
  }
@@ -28821,7 +29464,7 @@ function DashboardManager({
28821
29464
  setSelectedDashboard,
28822
29465
  dispatch
28823
29466
  ]);
28824
- const handleClickReport = (0, import_react66.useCallback)(
29467
+ const handleClickReport = (0, import_react67.useCallback)(
28825
29468
  (elem) => {
28826
29469
  dispatch({ type: "SET_REPORT_ID", payload: elem.id });
28827
29470
  dispatch({
@@ -29527,12 +30170,12 @@ function DashboardManager({
29527
30170
  }
29528
30171
 
29529
30172
  // src/public_components/VirtualTableManager.tsx
29530
- var import_react70 = require("react");
30173
+ var import_react71 = require("react");
29531
30174
  var import_react_dom9 = require("react-dom");
29532
30175
 
29533
30176
  // src/forms/virtual_tables/CreateEditVirtualTable.tsx
29534
- var import_react68 = require("@quillsql/react");
29535
- var import_react69 = require("react");
30177
+ var import_react69 = require("@quillsql/react");
30178
+ var import_react70 = require("react");
29536
30179
 
29537
30180
  // src/modals/TenantFieldModal.tsx
29538
30181
  var import_jsx_runtime67 = require("react/jsx-runtime");
@@ -29740,31 +30383,31 @@ function CreateEditVirtualTable({
29740
30383
  client
29741
30384
  }) {
29742
30385
  const name = initialVirtualTable?.name || "";
29743
- const [editVirtualTableQuery, setEditVirtualTableQuery] = (0, import_react69.useState)(
30386
+ const [editVirtualTableQuery, setEditVirtualTableQuery] = (0, import_react70.useState)(
29744
30387
  initialVirtualTable?.viewQuery || ""
29745
30388
  );
29746
- const [ranVirtualTableQuery, setRanVirtualTableQuery] = (0, import_react69.useState)(
30389
+ const [ranVirtualTableQuery, setRanVirtualTableQuery] = (0, import_react70.useState)(
29747
30390
  initialVirtualTable?.viewQuery || ""
29748
30391
  );
29749
- const [askAIButtonLoading, setAskAIButtonLoading] = (0, import_react69.useState)(false);
29750
- const [aiPrompt, setAIPrompt] = (0, import_react69.useState)("");
29751
- const [virtualTableAddable, setVirtualTableAddable] = (0, import_react69.useState)(false);
29752
- const [virtualTableOwners, setVirtualTableOwners] = (0, import_react69.useState)(
30392
+ const [askAIButtonLoading, setAskAIButtonLoading] = (0, import_react70.useState)(false);
30393
+ const [aiPrompt, setAIPrompt] = (0, import_react70.useState)("");
30394
+ const [virtualTableAddable, setVirtualTableAddable] = (0, import_react70.useState)(false);
30395
+ const [virtualTableOwners, setVirtualTableOwners] = (0, import_react70.useState)(
29753
30396
  initialVirtualTable?.ownerTenantFields ?? client.ownerTenantFields?.filter((f) => f !== SINGLE_TENANT) ?? []
29754
30397
  );
29755
- const [failingTenant, setFailingTenant] = (0, import_react69.useState)(
30398
+ const [failingTenant, setFailingTenant] = (0, import_react70.useState)(
29756
30399
  void 0
29757
30400
  );
29758
- const [failingTenantErrorType, setFailingTenantErrorType] = (0, import_react69.useState)(void 0);
29759
- const [isLoading, setIsLoading] = (0, import_react69.useState)(false);
29760
- const [tableSearchQuery, setTableSearchQuery] = (0, import_react69.useState)("");
29761
- const [editorMounted, setEditorMounted] = (0, import_react69.useState)(false);
29762
- const [displayedTableData, setDisplayedTableData] = (0, import_react69.useState)(allTableData);
29763
- const [errorInfo, setErrorInfo] = (0, import_react69.useState)({ show: false, message: "" });
29764
- const [tableData, setTableData] = (0, import_react69.useState)(void 0);
29765
- const [runningQuery, setRunningQuery] = (0, import_react69.useState)(false);
30401
+ const [failingTenantErrorType, setFailingTenantErrorType] = (0, import_react70.useState)(void 0);
30402
+ const [isLoading, setIsLoading] = (0, import_react70.useState)(false);
30403
+ const [tableSearchQuery, setTableSearchQuery] = (0, import_react70.useState)("");
30404
+ const [editorMounted, setEditorMounted] = (0, import_react70.useState)(false);
30405
+ const [displayedTableData, setDisplayedTableData] = (0, import_react70.useState)(allTableData);
30406
+ const [errorInfo, setErrorInfo] = (0, import_react70.useState)({ show: false, message: "" });
30407
+ const [tableData, setTableData] = (0, import_react70.useState)(void 0);
30408
+ const [runningQuery, setRunningQuery] = (0, import_react70.useState)(false);
29766
30409
  const { state, getToken, quillFetchWithToken, eventTracking } = useAdmin();
29767
- const containerRef = (0, import_react69.useRef)(null);
30410
+ const containerRef = (0, import_react70.useRef)(null);
29768
30411
  const addEditProcessVirtualTable = async (override = false) => {
29769
30412
  const missingTenantField = virtualTableOwners?.find(
29770
30413
  (field) => tableData && !tableData.fields.find(
@@ -29809,13 +30452,13 @@ function CreateEditVirtualTable({
29809
30452
  override
29810
30453
  );
29811
30454
  };
29812
- const dashboardOwnerTenants = (0, import_react69.useMemo)(() => {
30455
+ const dashboardOwnerTenants = (0, import_react70.useMemo)(() => {
29813
30456
  return client.allTenantTypes?.filter((t2) => client.ownerTenantFields?.includes(t2.tenantField)).filter((t2) => t2.tenantField !== SINGLE_TENANT);
29814
30457
  }, [client.ownerTenantFields, client.allTenantTypes]);
29815
- (0, import_react69.useEffect)(() => {
30458
+ (0, import_react70.useEffect)(() => {
29816
30459
  setDisplayedTableData(allTableData);
29817
30460
  }, [allTableData]);
29818
- (0, import_react69.useEffect)(() => {
30461
+ (0, import_react70.useEffect)(() => {
29819
30462
  if (initialVirtualTable) {
29820
30463
  eventTracking?.addBreadcrumb?.({
29821
30464
  message: "Initial Query Run on CreateEditVirtualTable load",
@@ -30035,7 +30678,7 @@ function CreateEditVirtualTable({
30035
30678
  }
30036
30679
  ),
30037
30680
  /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
30038
- import_react68.SchemaListComponent,
30681
+ import_react69.SchemaListComponent,
30039
30682
  {
30040
30683
  schema: displayedTableData,
30041
30684
  theme: state.theme,
@@ -30212,7 +30855,7 @@ function CreateEditVirtualTable({
30212
30855
  }
30213
30856
  ) : null,
30214
30857
  (tableData || runningQuery) && /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
30215
- import_react68.Table,
30858
+ import_react69.Table,
30216
30859
  {
30217
30860
  containerStyle: {
30218
30861
  minHeight: 260,
@@ -30352,7 +30995,7 @@ ${duplicateColumns.join("\n")}`
30352
30995
  }
30353
30996
 
30354
30997
  // src/utils/dataEditor.tsx
30355
- var editVirtualTable = async (editName, editViewQuery, editViewId, customFieldInfo, state, ownerTenantFields, getToken, noCustomerField) => {
30998
+ var editVirtualTable = async (editName, editViewQuery, editViewId, description, customFieldInfo, state, ownerTenantFields, getToken, noCustomerField) => {
30356
30999
  if (!editName.length) {
30357
31000
  alert("Please enter a table name.");
30358
31001
  return;
@@ -30378,6 +31021,7 @@ var editVirtualTable = async (editName, editViewQuery, editViewId, customFieldIn
30378
31021
  name: editName,
30379
31022
  customFieldInfo,
30380
31023
  id: editViewId,
31024
+ description,
30381
31025
  clientId: state.client._id,
30382
31026
  runQueryConfig: { getColumns: true },
30383
31027
  databaseType: state.client.databaseType,
@@ -30388,7 +31032,7 @@ var editVirtualTable = async (editName, editViewQuery, editViewId, customFieldIn
30388
31032
  getToken
30389
31033
  });
30390
31034
  };
30391
- var addVirtualTable = async (name, editViewQuery, customFieldInfo, state, ownerTenantFields, getToken, noCustomerField) => {
31035
+ var addVirtualTable = async (name, editViewQuery, description, customFieldInfo, state, ownerTenantFields, getToken, noCustomerField) => {
30392
31036
  if (!name.length) {
30393
31037
  alert("Please enter a table name.");
30394
31038
  return;
@@ -30409,6 +31053,7 @@ var addVirtualTable = async (name, editViewQuery, customFieldInfo, state, ownerT
30409
31053
  preQueries: [editViewQuery.replace(/;/, "")],
30410
31054
  customFieldInfo,
30411
31055
  name,
31056
+ description,
30412
31057
  clientId: state.client._id,
30413
31058
  runQueryConfig: { getColumns: true },
30414
31059
  databaseType: state.client.databaseType,
@@ -30441,7 +31086,7 @@ var deleteVirtualTable = async (id, state, getToken) => {
30441
31086
  };
30442
31087
 
30443
31088
  // src/public_components/VirtualTableManager.tsx
30444
- var import_react71 = require("@quillsql/react");
31089
+ var import_react72 = require("@quillsql/react");
30445
31090
  var import_prism_react_renderer5 = require("prism-react-renderer");
30446
31091
 
30447
31092
  // src/components/EmptyVirtualTablesComponent.tsx
@@ -30556,7 +31201,7 @@ function EmptyVirtualTablesComponent({
30556
31201
 
30557
31202
  // src/public_components/VirtualTableManager.tsx
30558
31203
  var import_jsx_runtime71 = require("react/jsx-runtime");
30559
- var import_react72 = require("react");
31204
+ var import_react73 = require("react");
30560
31205
  function VirtualTableManager({
30561
31206
  containerStyle,
30562
31207
  virtualTable
@@ -30567,28 +31212,29 @@ function VirtualTableManager({
30567
31212
  reloadAll,
30568
31213
  refreshSome,
30569
31214
  loadingTables
30570
- } = (0, import_react71.useVirtualTables)();
30571
- const { reloadFilteredReports } = (0, import_react71.useReports)();
30572
- const [editModalIsOpen, setEditModalIsOpen] = (0, import_react70.useState)(false);
30573
- const [editQueryView, setEditQueryView] = (0, import_react70.useState)(false);
30574
- const [editVirtualTableId, setEditVirtualTableId] = (0, import_react70.useState)("");
30575
- const [editName, setEditName] = (0, import_react70.useState)("");
30576
- const [editError, setEditError] = (0, import_react70.useState)();
30577
- const [editVirtualTableQuery, setEditVirtualTableQuery] = (0, import_react70.useState)("");
31215
+ } = (0, import_react72.useVirtualTables)();
31216
+ const { reloadFilteredReports } = (0, import_react72.useReports)();
31217
+ const [editModalIsOpen, setEditModalIsOpen] = (0, import_react71.useState)(false);
31218
+ const [editQueryView, setEditQueryView] = (0, import_react71.useState)(false);
31219
+ const [editVirtualTableId, setEditVirtualTableId] = (0, import_react71.useState)("");
31220
+ const [editName, setEditName] = (0, import_react71.useState)("");
31221
+ const [editDescription, setEditDescription] = (0, import_react71.useState)("");
31222
+ const [editError, setEditError] = (0, import_react71.useState)();
31223
+ const [editVirtualTableQuery, setEditVirtualTableQuery] = (0, import_react71.useState)("");
30578
31224
  const [
30579
31225
  editVirtualTableOwnerTenantFields,
30580
31226
  setEditVirtualTableOwnerTenantFields
30581
- ] = (0, import_react70.useState)([]);
30582
- const [editEnvironmentModalIsOpen, setEditEnvironmentModalIsOpen] = (0, import_react70.useState)(false);
30583
- const [referencedTablesMap, setReferencedTablesMap] = (0, import_react70.useState)({});
30584
- const [referenceFiltersMap, setReferenceFiltersMap] = (0, import_react70.useState)({});
31227
+ ] = (0, import_react71.useState)([]);
31228
+ const [editEnvironmentModalIsOpen, setEditEnvironmentModalIsOpen] = (0, import_react71.useState)(false);
31229
+ const [referencedTablesMap, setReferencedTablesMap] = (0, import_react71.useState)({});
31230
+ const [referenceFiltersMap, setReferenceFiltersMap] = (0, import_react71.useState)({});
30585
31231
  const { schema: allTableData, isLoading: schemaIsLoading } = useDatabaseSchema();
30586
- const [customFieldInfo, setCustomFieldInfo] = (0, import_react70.useState)(void 0);
30587
- const [initialVirtualTable, setInitialVirtualTable] = (0, import_react70.useState)(void 0);
30588
- const [submittingVirtualTable, setSubmittingVirtualTable] = (0, import_react70.useState)(false);
30589
- const [noCustomerField, setNoCustomerField] = (0, import_react70.useState)(false);
30590
- const parentRef = (0, import_react70.useRef)(null);
30591
- const envHeaderRef = (0, import_react70.useRef)(null);
31232
+ const [customFieldInfo, setCustomFieldInfo] = (0, import_react71.useState)(void 0);
31233
+ const [initialVirtualTable, setInitialVirtualTable] = (0, import_react71.useState)(void 0);
31234
+ const [submittingVirtualTable, setSubmittingVirtualTable] = (0, import_react71.useState)(false);
31235
+ const [noCustomerField, setNoCustomerField] = (0, import_react71.useState)(false);
31236
+ const parentRef = (0, import_react71.useRef)(null);
31237
+ const envHeaderRef = (0, import_react71.useRef)(null);
30592
31238
  const {
30593
31239
  state,
30594
31240
  dispatch,
@@ -30598,7 +31244,7 @@ function VirtualTableManager({
30598
31244
  eventTracking
30599
31245
  } = useAdmin();
30600
31246
  const showCreateEnvironmentModal = state.activeComponent === "CreateEnvironment";
30601
- const setShowCreateEnvironmentModal = (0, import_react70.useCallback)(
31247
+ const setShowCreateEnvironmentModal = (0, import_react71.useCallback)(
30602
31248
  (show) => {
30603
31249
  dispatch({
30604
31250
  type: "SET_ACTIVE_COMPONENT",
@@ -30610,11 +31256,13 @@ function VirtualTableManager({
30610
31256
  const closeEditModal = () => {
30611
31257
  setEditModalIsOpen(false);
30612
31258
  setEditName("");
31259
+ setEditDescription("");
30613
31260
  setEditVirtualTableQuery("");
30614
31261
  setCustomFieldInfo(void 0);
30615
31262
  };
30616
31263
  const clickTableCell = (table, suppressModal = false) => {
30617
31264
  setEditName(table.name);
31265
+ setEditDescription(table.description ?? "");
30618
31266
  setEditVirtualTableQuery(table.viewQuery);
30619
31267
  setEditVirtualTableOwnerTenantFields(table.ownerTenantFields ?? []);
30620
31268
  setEditVirtualTableId(table._id);
@@ -30673,13 +31321,13 @@ function VirtualTableManager({
30673
31321
  setReferencedTablesMap(data.data.referencedTablesMap);
30674
31322
  setReferenceFiltersMap(data.data.referenceFiltersMap);
30675
31323
  };
30676
- (0, import_react70.useEffect)(() => {
31324
+ (0, import_react71.useEffect)(() => {
30677
31325
  if (state.client.id) {
30678
31326
  getReferencedTablesMap();
30679
31327
  }
30680
31328
  }, [state.client.id]);
30681
31329
  const showVirtualTableEditorPortal = editQueryView && !clientLoading && !areTablesLoading && !state.databaseTypeMismatch.show && typeof document !== "undefined";
30682
- (0, import_react70.useEffect)(() => {
31330
+ (0, import_react71.useEffect)(() => {
30683
31331
  if (!showVirtualTableEditorPortal) return;
30684
31332
  const prevOverflow = document.body.style.overflow;
30685
31333
  document.body.style.overflow = "hidden";
@@ -30687,7 +31335,7 @@ function VirtualTableManager({
30687
31335
  document.body.style.overflow = prevOverflow;
30688
31336
  };
30689
31337
  }, [showVirtualTableEditorPortal]);
30690
- const handleModalSubmit = async (submitRequest, query, ownerTenantFields, name, id, columns, customFieldInfo2, override) => {
31338
+ const handleModalSubmit = async (submitRequest, query, ownerTenantFields, name, description, id, columns, customFieldInfo2, override) => {
30691
31339
  if (override) {
30692
31340
  setNoCustomerField(true);
30693
31341
  } else {
@@ -30727,6 +31375,7 @@ ${duplicateColumns.join("\n")}`
30727
31375
  submitResponse = await addVirtualTable(
30728
31376
  trimmedName,
30729
31377
  query,
31378
+ description,
30730
31379
  customFieldInfo2,
30731
31380
  state,
30732
31381
  ownerTenantFields,
@@ -30763,43 +31412,45 @@ ${errorColumns.length > 1 ? "They" : "It"} will be deleted off of the referencin
30763
31412
  return;
30764
31413
  }
30765
31414
  } else {
30766
- const referencedTableInfo = referencedTablesMap[prevTableName].map((info) => {
30767
- return `"${info.reportName}" on the "${info.dashboardName}" dashboard`;
30768
- });
30769
- if (referenceFiltersMap?.[prevTableName]) {
30770
- const referencedFilterInfo = referenceFiltersMap[prevTableName].map((info) => {
30771
- return `${info.dashboardName} - ${info.filterField}`;
31415
+ if (prevTableName !== trimmedName) {
31416
+ const referencedTableInfo = referencedTablesMap[prevTableName].map((info) => {
31417
+ return `"${info.reportName}" on the "${info.dashboardName}" dashboard`;
30772
31418
  });
30773
- alert(
30774
- `Warning
31419
+ if (referenceFiltersMap?.[prevTableName]) {
31420
+ const referencedFilterInfo = referenceFiltersMap[prevTableName].map((info) => {
31421
+ return `${info.dashboardName} - ${info.filterField}`;
31422
+ });
31423
+ alert(
31424
+ `Warning
30775
31425
 
30776
31426
  '${prevTableName}' is referenced in the following dashboard filters:
30777
31427
 
30778
31428
  ${referencedFilterInfo.join(
30779
- "\n"
30780
- )}
31429
+ "\n"
31430
+ )}
30781
31431
 
30782
31432
  Please delete those filters before renaming this virtual table.`
30783
- );
30784
- return;
30785
- }
30786
- if (table && table.broken) {
31433
+ );
31434
+ return;
31435
+ }
31436
+ if (table && table.broken) {
31437
+ alert(
31438
+ "Error\n\nThis virtual table has an invalid query. Please fix the query before renaming it."
31439
+ );
31440
+ return;
31441
+ }
30787
31442
  alert(
30788
- "Error\n\nThis virtual table has an invalid query. Please fix the query before renaming it."
30789
- );
30790
- return;
30791
- }
30792
- alert(
30793
- `Warning
31443
+ `Warning
30794
31444
 
30795
31445
  '${prevTableName}' is referenced by:
30796
31446
  ${referencedTableInfo.join(
30797
- "\n"
30798
- )}
31447
+ "\n"
31448
+ )}
30799
31449
 
30800
31450
  Please delete those charts before renaming this virtual table.`
30801
- );
30802
- return;
31451
+ );
31452
+ return;
31453
+ }
30803
31454
  }
30804
31455
  }
30805
31456
  if (!trimmedName) {
@@ -30829,6 +31480,7 @@ ${duplicateColumns.join("\n")}`
30829
31480
  trimmedName,
30830
31481
  query,
30831
31482
  id,
31483
+ description,
30832
31484
  customFieldInfo2,
30833
31485
  state,
30834
31486
  ownerTenantFields,
@@ -30930,7 +31582,7 @@ Please delete those filters before deleting this table.`
30930
31582
  await reloadTables();
30931
31583
  return response;
30932
31584
  };
30933
- const handleEditAddView = async (request, query, ownerTenantFields, name, id, columns, override) => {
31585
+ const handleEditAddView = async (request, query, ownerTenantFields, name, description, id, columns, override) => {
30934
31586
  switch (request) {
30935
31587
  case "edit":
30936
31588
  await handleModalSubmit(
@@ -30938,6 +31590,7 @@ Please delete those filters before deleting this table.`
30938
31590
  query,
30939
31591
  ownerTenantFields,
30940
31592
  name,
31593
+ description,
30941
31594
  id,
30942
31595
  columns,
30943
31596
  void 0,
@@ -30951,6 +31604,7 @@ Please delete those filters before deleting this table.`
30951
31604
  ownerTenantFields,
30952
31605
  void 0,
30953
31606
  void 0,
31607
+ void 0,
30954
31608
  columns,
30955
31609
  void 0,
30956
31610
  override
@@ -30992,6 +31646,7 @@ Please delete those filters before deleting this table.`
30992
31646
  query,
30993
31647
  ownerTenantFields,
30994
31648
  name,
31649
+ void 0,
30995
31650
  id,
30996
31651
  columns,
30997
31652
  override
@@ -31116,6 +31771,7 @@ Please delete those filters before deleting this table.`
31116
31771
  {
31117
31772
  onClick: () => {
31118
31773
  setEditName("");
31774
+ setEditDescription("");
31119
31775
  setEditVirtualTableQuery("");
31120
31776
  setEditVirtualTableId("");
31121
31777
  setInitialVirtualTable(void 0);
@@ -31664,6 +32320,7 @@ Please delete those filters before deleting this table.`
31664
32320
  EditAddViewModal,
31665
32321
  {
31666
32322
  viewName: editName,
32323
+ viewDescription: editDescription,
31667
32324
  viewQuery: editVirtualTableQuery,
31668
32325
  viewId: editVirtualTableId,
31669
32326
  viewOwnerTenantFields: editVirtualTableOwnerTenantFields,
@@ -31671,7 +32328,7 @@ Please delete those filters before deleting this table.`
31671
32328
  customFieldInfo,
31672
32329
  closeEditModal,
31673
32330
  error: editError,
31674
- submit: async (submitRequest, query, ownerTenantFields, name, id, columns, customFieldInfo2, noCustomerField2) => {
32331
+ submit: async (submitRequest, query, ownerTenantFields, name, description, id, columns, customFieldInfo2, noCustomerField2) => {
31675
32332
  if (submitRequest !== "delete") {
31676
32333
  setSubmittingVirtualTable(true);
31677
32334
  }
@@ -31680,6 +32337,7 @@ Please delete those filters before deleting this table.`
31680
32337
  query,
31681
32338
  ownerTenantFields,
31682
32339
  name,
32340
+ description,
31683
32341
  id,
31684
32342
  columns,
31685
32343
  customFieldInfo2,
@@ -31725,6 +32383,7 @@ Please delete those filters before deleting this table.`
31725
32383
  }
31726
32384
  function EditAddViewModal({
31727
32385
  viewName,
32386
+ viewDescription,
31728
32387
  viewQuery,
31729
32388
  viewOwnerTenantFields,
31730
32389
  viewId,
@@ -31739,38 +32398,42 @@ function EditAddViewModal({
31739
32398
  isLoading,
31740
32399
  noCustomerField
31741
32400
  }) {
31742
- const [name, setName] = (0, import_react70.useState)(viewName);
31743
- const [query, setQuery] = (0, import_react70.useState)(viewQuery);
31744
- const [id, setId] = (0, import_react70.useState)(viewId);
31745
- const [useCustomField, setUseCustomField] = (0, import_react70.useState)(
32401
+ const [name, setName] = (0, import_react71.useState)(viewName);
32402
+ const [description, setDescription] = (0, import_react71.useState)(viewDescription);
32403
+ const [query, setQuery] = (0, import_react71.useState)(viewQuery);
32404
+ const [id, setId] = (0, import_react71.useState)(viewId);
32405
+ const [useCustomField, setUseCustomField] = (0, import_react71.useState)(
31746
32406
  customFieldInfo ? true : false
31747
32407
  );
31748
- const [customFieldType, setCustomFieldType] = (0, import_react70.useState)(
32408
+ const [customFieldType, setCustomFieldType] = (0, import_react71.useState)(
31749
32409
  customFieldInfo ? customFieldInfo.type : "eav"
31750
32410
  );
31751
- const [customFieldQuery, setCustomFieldQuery] = (0, import_react70.useState)(
32411
+ const [customFieldQuery, setCustomFieldQuery] = (0, import_react71.useState)(
31752
32412
  customFieldInfo ? customFieldInfo.query : ""
31753
32413
  );
31754
- const [runQueryButtonLoading, setRunQueryButtonLoading] = (0, import_react70.useState)(false);
31755
- const [tableData, setTableData] = (0, import_react70.useState)(void 0);
31756
- const [errorInfo, setErrorInfo] = (0, import_react70.useState)({ show: false, message: "" });
31757
- const clientIsSingleTenant = (0, import_react70.useMemo)(
32414
+ const [runQueryButtonLoading, setRunQueryButtonLoading] = (0, import_react71.useState)(false);
32415
+ const [tableData, setTableData] = (0, import_react71.useState)(void 0);
32416
+ const [errorInfo, setErrorInfo] = (0, import_react71.useState)({ show: false, message: "" });
32417
+ const clientIsSingleTenant = (0, import_react71.useMemo)(
31758
32418
  () => onlySingleDatabaseTenant(state.client),
31759
32419
  [state.client]
31760
32420
  );
31761
32421
  const { getToken, eventTracking } = useAdmin();
31762
- (0, import_react70.useEffect)(() => {
32422
+ (0, import_react71.useEffect)(() => {
31763
32423
  setCustomFieldQuery(customFieldInfo?.query || "");
31764
32424
  setCustomFieldType(customFieldInfo?.type || "eav");
31765
32425
  setUseCustomField(customFieldInfo ? true : false);
31766
32426
  }, [customFieldInfo]);
31767
- (0, import_react70.useEffect)(() => {
32427
+ (0, import_react71.useEffect)(() => {
31768
32428
  setName(viewName);
31769
32429
  }, [viewName]);
31770
- (0, import_react70.useEffect)(() => {
32430
+ (0, import_react71.useEffect)(() => {
32431
+ setDescription(viewDescription);
32432
+ }, [viewDescription]);
32433
+ (0, import_react71.useEffect)(() => {
31771
32434
  setQuery(viewQuery);
31772
32435
  }, [viewQuery]);
31773
- (0, import_react70.useEffect)(() => {
32436
+ (0, import_react71.useEffect)(() => {
31774
32437
  setId(viewId);
31775
32438
  }, [viewId]);
31776
32439
  return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
@@ -31784,6 +32447,7 @@ function EditAddViewModal({
31784
32447
  setTableData(void 0);
31785
32448
  setErrorInfo({ show: false, message: "" });
31786
32449
  setName("");
32450
+ setDescription("");
31787
32451
  closeEditModal();
31788
32452
  },
31789
32453
  children: /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(
@@ -31830,21 +32494,47 @@ function EditAddViewModal({
31830
32494
  ]
31831
32495
  }
31832
32496
  ),
31833
- /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(InputLabel, { children: "Name" }),
31834
- /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
31835
- TextInputPrimitive_default,
31836
- {
31837
- ref: (input) => {
31838
- if (editModalIsOpen && !viewName) {
31839
- input?.focus();
32497
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: 4 }, children: [
32498
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(InputLabel, { children: "Name" }),
32499
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
32500
+ TextInputPrimitive_default,
32501
+ {
32502
+ placeholder: "Enter view display name...",
32503
+ onChange: (e2) => setName(e2.target.value),
32504
+ value: name ? name : ""
32505
+ }
32506
+ )
32507
+ ] }),
32508
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { style: { height: 12 } }),
32509
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: 4 }, children: [
32510
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(InputLabel, { children: "Description" }),
32511
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
32512
+ "textarea",
32513
+ {
32514
+ placeholder: "Enter description...",
32515
+ onChange: (e2) => setDescription(e2.target.value),
32516
+ value: description ?? "",
32517
+ rows: 3,
32518
+ style: {
32519
+ width: "100%",
32520
+ minHeight: 88,
32521
+ resize: "vertical",
32522
+ padding: "10px 12px",
32523
+ fontWeight: "medium",
32524
+ backgroundColor: state.theme?.backgroundColor || "white",
32525
+ color: state.theme?.primaryTextColor,
32526
+ borderWidth: "1px",
32527
+ borderColor: state.theme?.borderColor || "#E7E7E7",
32528
+ borderStyle: "solid",
32529
+ borderRadius: "6px",
32530
+ fontSize: 14,
32531
+ fontFamily: state.theme?.fontFamily,
32532
+ boxSizing: "border-box"
31840
32533
  }
31841
- },
31842
- placeholder: "Enter view display name...",
31843
- onChange: (e2) => setName(e2.target.value),
31844
- value: name ? name : ""
31845
- }
31846
- ),
31847
- /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("br", {}),
32534
+ }
32535
+ )
32536
+ ] }),
32537
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { style: { height: 16 } }),
31848
32538
  viewOwnerTenantFields.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(import_jsx_runtime71.Fragment, { children: [
31849
32539
  /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(InputLabel, { tooltip: "Dashboards may only query from virtual tables that share an owner with them. Virtual tables are required to return each of their owners' foreign keys as part of the query.", children: "Owners" }),
31850
32540
  /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
@@ -31879,7 +32569,7 @@ function EditAddViewModal({
31879
32569
  ))
31880
32570
  }
31881
32571
  ),
31882
- /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("br", {})
32572
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { style: { height: 16 } })
31883
32573
  ] }),
31884
32574
  error && /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(import_jsx_runtime71.Fragment, { children: [
31885
32575
  /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("h3", { style: { color: "#CA3A31" }, children: error }),
@@ -31907,7 +32597,7 @@ function EditAddViewModal({
31907
32597
  position: "relative"
31908
32598
  },
31909
32599
  children: [
31910
- tokens.map((line, i2) => /* @__PURE__ */ (0, import_react72.createElement)(
32600
+ tokens.map((line, i2) => /* @__PURE__ */ (0, import_react73.createElement)(
31911
32601
  "div",
31912
32602
  {
31913
32603
  ...getLineProps({ line }),
@@ -32094,7 +32784,7 @@ function EditAddViewModal({
32094
32784
  }
32095
32785
  ),
32096
32786
  !errorInfo.show && tableData && !runQueryButtonLoading && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
32097
- import_react71.Table,
32787
+ import_react72.Table,
32098
32788
  {
32099
32789
  rows: tableData.rows,
32100
32790
  columns: tableData.fields,
@@ -32155,7 +32845,14 @@ function EditAddViewModal({
32155
32845
  viewName && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
32156
32846
  MemoizedButton,
32157
32847
  {
32158
- onClick: () => submit("delete", query, viewOwnerTenantFields, name, id),
32848
+ onClick: () => submit(
32849
+ "delete",
32850
+ query,
32851
+ viewOwnerTenantFields,
32852
+ name,
32853
+ description,
32854
+ id
32855
+ ),
32159
32856
  label: "Delete",
32160
32857
  style: { color: "red", backgroundColor: "white" }
32161
32858
  }
@@ -32236,6 +32933,7 @@ function EditAddViewModal({
32236
32933
  query,
32237
32934
  viewOwnerTenantFields,
32238
32935
  name,
32936
+ description,
32239
32937
  id,
32240
32938
  void 0,
32241
32939
  useCustomField ? {
@@ -32283,7 +32981,9 @@ function EditAddViewModal({
32283
32981
  SecondaryButtonPrimitive,
32284
32982
  TextInputPrimitive,
32285
32983
  VirtualTableManager,
32984
+ clearQuillSandboxStorage,
32286
32985
  exportChatAsMarkdown,
32287
32986
  useAdmin,
32288
- useAgentChat
32987
+ useAgentChat,
32988
+ useSandboxSession
32289
32989
  });