@solidxai/core-ui 0.1.22-beta.4 → 0.1.22
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/adapters/auth/adminEmbedSession.d.ts +16 -0
- package/dist/adapters/auth/adminEmbedSession.d.ts.map +1 -0
- package/dist/adapters/auth/adminEmbedSession.js +72 -0
- package/dist/adapters/auth/adminEmbedSession.js.map +1 -0
- package/dist/adapters/auth/adminEmbedSession.ts +67 -0
- package/dist/adapters/auth/getSession.d.ts.map +1 -1
- package/dist/adapters/auth/getSession.js +4 -1
- package/dist/adapters/auth/getSession.js.map +1 -1
- package/dist/adapters/auth/getSession.ts +4 -1
- package/dist/adapters/auth/storage.d.ts +1 -0
- package/dist/adapters/auth/storage.d.ts.map +1 -1
- package/dist/adapters/auth/storage.js +9 -3
- package/dist/adapters/auth/storage.js.map +1 -1
- package/dist/adapters/auth/storage.ts +10 -2
- package/dist/components/common/Link.d.ts.map +1 -1
- package/dist/components/common/Link.js +3 -2
- package/dist/components/common/Link.js.map +1 -1
- package/dist/components/common/Link.tsx +3 -2
- package/dist/components/core/form/SolidFormFooter.js +2 -2
- package/dist/components/core/form/SolidFormFooter.js.map +1 -1
- package/dist/components/core/form/SolidFormFooter.tsx +2 -2
- package/dist/components/core/form/fields/relations/SolidRelationManyToManyField.d.ts.map +1 -1
- package/dist/components/core/form/fields/relations/SolidRelationManyToManyField.js +17 -15
- package/dist/components/core/form/fields/relations/SolidRelationManyToManyField.js.map +1 -1
- package/dist/components/core/form/fields/relations/SolidRelationManyToManyField.tsx +7 -5
- package/dist/components/core/form/fields/relations/SolidRelationOneToManyField.d.ts.map +1 -1
- package/dist/components/core/form/fields/relations/SolidRelationOneToManyField.js +13 -11
- package/dist/components/core/form/fields/relations/SolidRelationOneToManyField.js.map +1 -1
- package/dist/components/core/form/fields/relations/SolidRelationOneToManyField.tsx +8 -6
- package/dist/components/core/solid-agent/browser/AgentBrowser.module.css +170 -0
- package/dist/components/core/solid-agent/browser/AgentBrowserScreen.d.ts +13 -0
- package/dist/components/core/solid-agent/browser/AgentBrowserScreen.d.ts.map +1 -0
- package/dist/components/core/solid-agent/browser/AgentBrowserScreen.js +138 -0
- package/dist/components/core/solid-agent/browser/AgentBrowserScreen.js.map +1 -0
- package/dist/components/core/solid-agent/browser/AgentBrowserScreen.tsx +162 -0
- package/dist/components/core/solid-agent/browser/DefaultAgentBrowserPanelWidget.d.ts +9 -0
- package/dist/components/core/solid-agent/browser/DefaultAgentBrowserPanelWidget.d.ts.map +1 -0
- package/dist/components/core/solid-agent/browser/DefaultAgentBrowserPanelWidget.js +59 -0
- package/dist/components/core/solid-agent/browser/DefaultAgentBrowserPanelWidget.js.map +1 -0
- package/dist/components/core/solid-agent/browser/DefaultAgentBrowserPanelWidget.tsx +159 -0
- package/dist/components/core/solid-agent/browser/useAgentBrowser.d.ts +6 -0
- package/dist/components/core/solid-agent/browser/useAgentBrowser.d.ts.map +1 -0
- package/dist/components/core/solid-agent/browser/useAgentBrowser.js +37 -0
- package/dist/components/core/solid-agent/browser/useAgentBrowser.js.map +1 -0
- package/dist/components/core/solid-agent/browser/useAgentBrowser.ts +38 -0
- package/dist/components/core/solid-agent/client/agentBrowser.d.ts +128 -0
- package/dist/components/core/solid-agent/client/agentBrowser.d.ts.map +1 -0
- package/dist/components/core/solid-agent/client/agentBrowser.js +474 -0
- package/dist/components/core/solid-agent/client/agentBrowser.js.map +1 -0
- package/dist/components/core/solid-agent/client/agentBrowser.ts +342 -0
- package/dist/components/core/solid-agent/toolFiles.d.ts +13 -0
- package/dist/components/core/solid-agent/toolFiles.d.ts.map +1 -0
- package/dist/components/core/solid-agent/toolFiles.js +54 -0
- package/dist/components/core/solid-agent/toolFiles.js.map +1 -0
- package/dist/components/core/solid-agent/toolFiles.ts +42 -0
- package/dist/components/core/solid-agent/widgets/AgentToolFiles.d.ts +9 -0
- package/dist/components/core/solid-agent/widgets/AgentToolFiles.d.ts.map +1 -0
- package/dist/components/core/solid-agent/widgets/AgentToolFiles.js +37 -0
- package/dist/components/core/solid-agent/widgets/AgentToolFiles.js.map +1 -0
- package/dist/components/core/solid-agent/widgets/AgentToolFiles.tsx +46 -0
- package/dist/components/core/solid-agent/widgets/SolidQuestionChatWidget.d.ts.map +1 -1
- package/dist/components/core/solid-agent/widgets/SolidQuestionChatWidget.js +3 -2
- package/dist/components/core/solid-agent/widgets/SolidQuestionChatWidget.js.map +1 -1
- package/dist/components/core/solid-agent/widgets/SolidQuestionChatWidget.tsx +3 -2
- package/dist/dummy.d.ts +2 -0
- package/dist/dummy.d.ts.map +1 -0
- package/dist/dummy.js +3 -0
- package/dist/dummy.js.map +1 -0
- package/dist/dummy.ts +2 -0
- package/dist/helpers/modelViewPersistence.d.ts +1 -1
- package/dist/helpers/modelViewPersistence.d.ts.map +1 -1
- package/dist/helpers/modelViewPersistence.js +5 -4
- package/dist/helpers/modelViewPersistence.js.map +1 -1
- package/dist/helpers/modelViewPersistence.ts +6 -4
- package/dist/hooks/useRouter.d.ts.map +1 -1
- package/dist/hooks/useRouter.js +5 -3
- package/dist/hooks/useRouter.js.map +1 -1
- package/dist/hooks/useRouter.ts +5 -3
- package/dist/resources/solid-custom.css +14 -1
- package/dist/routes/AppEventListener.js +1 -1
- package/dist/routes/AppEventListener.js.map +1 -1
- package/dist/routes/AppEventListener.tsx +1 -1
- package/dist/routes/pages/admin/core/AgentDeploymentPanel.d.ts +3 -4
- package/dist/routes/pages/admin/core/AgentDeploymentPanel.d.ts.map +1 -1
- package/dist/routes/pages/admin/core/AgentDeploymentPanel.js +13 -83
- package/dist/routes/pages/admin/core/AgentDeploymentPanel.js.map +1 -1
- package/dist/routes/pages/admin/core/AgentDeploymentPanel.tsx +22 -43
- package/dist/routes/pages/admin/core/AgentJobsInboxPage.d.ts.map +1 -1
- package/dist/routes/pages/admin/core/AgentJobsInboxPage.js +157 -34
- package/dist/routes/pages/admin/core/AgentJobsInboxPage.js.map +1 -1
- package/dist/routes/pages/admin/core/AgentJobsInboxPage.module.css +88 -12
- package/dist/routes/pages/admin/core/AgentJobsInboxPage.tsx +238 -26
- package/dist/routes/pages/admin/core/AgentRegistryEditorPage.css +6 -0
- package/dist/routes/pages/admin/core/AgentRegistryEditorPage.d.ts.map +1 -1
- package/dist/routes/pages/admin/core/AgentRegistryEditorPage.js +56 -49
- package/dist/routes/pages/admin/core/AgentRegistryEditorPage.js.map +1 -1
- package/dist/routes/pages/admin/core/AgentRegistryEditorPage.tsx +13 -6
- package/dist/routes/pages/embed/AdminEmbedPage.d.ts +7 -0
- package/dist/routes/pages/embed/AdminEmbedPage.d.ts.map +1 -0
- package/dist/routes/pages/embed/AdminEmbedPage.js +104 -0
- package/dist/routes/pages/embed/AdminEmbedPage.js.map +1 -0
- package/dist/routes/pages/embed/AdminEmbedPage.module.css +9 -0
- package/dist/routes/pages/embed/AdminEmbedPage.tsx +128 -0
- package/dist/routes/solidRoutes.d.ts.map +1 -1
- package/dist/routes/solidRoutes.js +2 -0
- package/dist/routes/solidRoutes.js.map +1 -1
- package/dist/routes/solidRoutes.tsx +2 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SolidQuestionChatWidget.js","sourceRoot":"","sources":["../../../../../src/components/core/solid-agent/widgets/SolidQuestionChatWidget.tsx"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,MAAM,MAAM,0BAA0B,CAAC;AAE9C,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"SolidQuestionChatWidget.js","sourceRoot":"","sources":["../../../../../src/components/core/solid-agent/widgets/SolidQuestionChatWidget.tsx"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,MAAM,MAAM,0BAA0B,CAAC;AAE9C,OAAO,EAAE,O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AC,IAAK,OAAA,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,EAAhB,CAAgB,CAAC,CAAC,CAAC;oBAC/C,CAAC,uBAGI,GACP,CACT,IACC,CACT,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,CAAC,uBAAuB,EAAE,EAAE,oBAAoB,EAAE,cAAM,OAAA,CAAC;QAClE,WAAW,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,oDAAoD,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,sFAAsF,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE;KACvf,CAAC,EAFmE,CAEnE,EAAE,CAAC,CAAC","sourcesContent":["import { useState } from \"react\";\nimport styles from \"../SolidAgent.module.css\";\nimport { SolidChatWidgetProps } from \"../../../../types/solid-core\";\nimport { asArray, getChatWidgetData } from \"./chatWidgetUtils\";\nimport { SolidAgentMarkdown } from \"../SolidAgentMarkdown\";\n\ntype QuestionOption = string | { label: string; value?: unknown };\ntype QuestionData = {\n question?: string; hint?: string; options?: QuestionOption[]; multiple?: boolean;\n reviewKind?: \"input\" | \"approval\"; toolName?: string | null;\n toolArguments?: Record<string, unknown> | null; context?: Record<string, unknown> | null;\n};\n\n/**\n * `event_data: { widget: \"question\", question, hint?, options: [...], multiple? }`.\n * A single-choice answer is sent on click; multiple choice waits for Submit.\n */\nexport const SolidQuestionChatWidget = ({ eventData, final, reply }: SolidChatWidgetProps) => {\n const data = getChatWidgetData<QuestionData>(eventData);\n const options = asArray<QuestionOption>(data.options).map((option) =>\n typeof option === \"string\" ? { label: option, value: option as unknown } : { label: option.label, value: option.value ?? option.label },\n );\n const [picked, setPicked] = useState<number[]>([]);\n const [answered, setAnswered] = useState(false);\n const serverManagedReply = eventData.serverManagedReply === true;\n const locked = final || answered || eventData.submitting === true;\n\n const choose = (index: number) => {\n if (locked) return;\n if (!data.multiple) {\n setPicked([index]);\n if (!serverManagedReply) setAnswered(true);\n reply(options[index].value);\n return;\n }\n setPicked((prev) => (prev.includes(index) ? prev.filter((i) => i !== index) : [...prev, index]));\n };\n\n return (\n <div className={styles.card}>\n <div className={styles.cardBody}>\n {data.reviewKind === \"approval\" && (data.toolName || data.toolArguments) && (\n <section aria-label=\"Tool call details\" className={styles.reviewDetails}>\n <div className={styles.reviewDetailsHeading}>\n <span>Tool call</span>\n {data.toolName && <code>{data.toolName}</code>}\n </div>\n {data.toolArguments && Object.keys(data.toolArguments).length > 0 && (\n <dl className={styles.reviewArgumentList}>\n {Object.entries(data.toolArguments).map(([key, value]) => (\n <div key={key} className={styles.reviewArgument}>\n <dt>{key}</dt>\n <dd>{typeof value === \"string\" ? value : JSON.stringify(value, null, 2)}</dd>\n </div>\n ))}\n </dl>\n )}\n </section>\n )}\n {data.question && <SolidAgentMarkdown text={data.question} />}\n {data.hint && <span style={{ color: \"var(--agent-muted)\", fontSize: 12.5 }}>{data.hint}</span>}\n {options.map((option, index) => (\n <button\n key={index}\n type=\"button\"\n className={`${styles.btn} ${picked.includes(index) ? styles.optionOn : \"\"}`}\n style={{ textAlign: \"left\" }}\n disabled={locked && (serverManagedReply || !picked.includes(index))}\n aria-pressed={picked.includes(index)}\n onClick={() => choose(index)}\n >\n {option.label}\n </button>\n ))}\n </div>\n {data.multiple && !locked && (\n <div className={styles.cardFoot}>\n <button\n type=\"button\"\n className={`${styles.btn} ${styles.btnPrimary}`}\n disabled={!picked.length}\n onClick={() => {\n if (!serverManagedReply) setAnswered(true);\n reply(picked.map((i) => options[i].value));\n }}\n >\n Submit\n </button>\n </div>\n )}\n </div>\n );\n};\n\nObject.assign(SolidQuestionChatWidget, { getExtensionMetadata: () => ({\n agentWidget: { name: \"question\", description: \"Ask the user a single or multiple choice question.\", propsSchema: { type: \"object\", properties: { question: { type: \"string\", description: \"The question as Markdown. Supports **bold**, *italic*, lists and [links](https://…).\" }, hint: { type: \"string\" }, options: { type: \"array\", items: { anyOf: [{ type: \"string\" }, { type: \"object\", properties: { label: { type: \"string\" }, value: {} }, required: [\"label\"] }] } }, multiple: { type: \"boolean\" } } } },\n}) });\n"]}
|
|
@@ -2,6 +2,7 @@ import { useState } from "react";
|
|
|
2
2
|
import styles from "../SolidAgent.module.css";
|
|
3
3
|
import { SolidChatWidgetProps } from "../../../../types/solid-core";
|
|
4
4
|
import { asArray, getChatWidgetData } from "./chatWidgetUtils";
|
|
5
|
+
import { SolidAgentMarkdown } from "../SolidAgentMarkdown";
|
|
5
6
|
|
|
6
7
|
type QuestionOption = string | { label: string; value?: unknown };
|
|
7
8
|
type QuestionData = {
|
|
@@ -56,7 +57,7 @@ export const SolidQuestionChatWidget = ({ eventData, final, reply }: SolidChatWi
|
|
|
56
57
|
)}
|
|
57
58
|
</section>
|
|
58
59
|
)}
|
|
59
|
-
{data.question && <
|
|
60
|
+
{data.question && <SolidAgentMarkdown text={data.question} />}
|
|
60
61
|
{data.hint && <span style={{ color: "var(--agent-muted)", fontSize: 12.5 }}>{data.hint}</span>}
|
|
61
62
|
{options.map((option, index) => (
|
|
62
63
|
<button
|
|
@@ -92,5 +93,5 @@ export const SolidQuestionChatWidget = ({ eventData, final, reply }: SolidChatWi
|
|
|
92
93
|
};
|
|
93
94
|
|
|
94
95
|
Object.assign(SolidQuestionChatWidget, { getExtensionMetadata: () => ({
|
|
95
|
-
agentWidget: { name: "question", description: "Ask the user a single or multiple choice question.", propsSchema: { type: "object", properties: { question: { type: "string" }, hint: { type: "string" }, options: { type: "array", items: { anyOf: [{ type: "string" }, { type: "object", properties: { label: { type: "string" }, value: {} }, required: ["label"] }] } }, multiple: { type: "boolean" } } } },
|
|
96
|
+
agentWidget: { name: "question", description: "Ask the user a single or multiple choice question.", propsSchema: { type: "object", properties: { question: { type: "string", description: "The question as Markdown. Supports **bold**, *italic*, lists and [links](https://…)." }, hint: { type: "string" }, options: { type: "array", items: { anyOf: [{ type: "string" }, { type: "object", properties: { label: { type: "string" }, value: {} }, required: ["label"] }] } }, multiple: { type: "boolean" } } } },
|
|
96
97
|
}) });
|
package/dist/dummy.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dummy.d.ts","sourceRoot":"","sources":["../src/dummy.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,WAAW,8BAA8B,CAAC"}
|
package/dist/dummy.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dummy.js","sourceRoot":"","sources":["../src/dummy.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,MAAM,CAAC,IAAM,WAAW,GAAG,2BAA2B,CAAC","sourcesContent":["// Dummy file for core-ui dev mode verification\nexport const dummyCoreUI = 'core-ui-dev-mode-verified';\n"]}
|
package/dist/dummy.ts
ADDED
|
@@ -2,6 +2,6 @@ export declare const persistLastModelViewRoute: (target: string) => void;
|
|
|
2
2
|
export declare const getPersistedLastModelViewRoute: (target: string) => string | null;
|
|
3
3
|
export declare const resolveRetainedModelViewRoute: (target: string) => string;
|
|
4
4
|
export declare const getMenuContextForActiveRoute: (currentPathname: string, currentSearchParams: URLSearchParams) => URLSearchParams;
|
|
5
|
-
export declare const preserveModelMenuContext: (target: string) => string;
|
|
5
|
+
export declare const preserveModelMenuContext: (target: string, current?: string) => string;
|
|
6
6
|
export declare const storeCurrentModelViewContext: (target?: string) => void;
|
|
7
7
|
//# sourceMappingURL=modelViewPersistence.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modelViewPersistence.d.ts","sourceRoot":"","sources":["../../src/helpers/modelViewPersistence.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"modelViewPersistence.d.ts","sourceRoot":"","sources":["../../src/helpers/modelViewPersistence.ts"],"names":[],"mappings":"AAyHA,eAAO,MAAM,yBAAyB,WAAY,MAAM,SAkBvD,CAAC;AAIF,eAAO,MAAM,8BAA8B,WAAY,MAAM,KAAG,MAAM,GAAG,IA2BxE,CAAC;AAIF,eAAO,MAAM,6BAA6B,WAAY,MAAM,KAAG,MAM9D,CAAC;AAiBF,eAAO,MAAM,4BAA4B,oBACtB,MAAM,uBACF,eAAe,KACnC,eAwBF,CAAC;AAIF,eAAO,MAAM,wBAAwB,WAAY,MAAM,YAAY,MAAM,KAAG,MA+B3E,CAAC;AAIF,eAAO,MAAM,4BAA4B,YAAa,MAAM,SAmB3D,CAAC"}
|
|
@@ -7,6 +7,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
7
7
|
}
|
|
8
8
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
9
|
};
|
|
10
|
+
import { isAdminEmbedDocument } from "../adapters/auth/storage";
|
|
10
11
|
var MODEL_VIEW_STORAGE_KEY = "solidx.model.last-view";
|
|
11
12
|
var MODEL_VIEW_ROUTE_REGEX = /^\/admin\/core\/([^/]+)\/([^/]+)\/(list|tree|kanban|card)$/;
|
|
12
13
|
var getRouteParsingBase = function () {
|
|
@@ -101,7 +102,7 @@ var writeStoredModelViews = function (next) {
|
|
|
101
102
|
// This lets us reopen the most useful last-selected view even when the user
|
|
102
103
|
// returns through a slightly different sidebar/menu link.
|
|
103
104
|
export var persistLastModelViewRoute = function (target) {
|
|
104
|
-
if (typeof window === "undefined")
|
|
105
|
+
if (typeof window === "undefined" || isAdminEmbedDocument)
|
|
105
106
|
return;
|
|
106
107
|
var route = parseModelViewRoute(target);
|
|
107
108
|
if (!route)
|
|
@@ -121,7 +122,7 @@ export var persistLastModelViewRoute = function (target) {
|
|
|
121
122
|
// Resolve the best saved route for the current model context.
|
|
122
123
|
// We prefer the newest entry and use scope priority as a tie-breaker.
|
|
123
124
|
export var getPersistedLastModelViewRoute = function (target) {
|
|
124
|
-
if (typeof window === "undefined")
|
|
125
|
+
if (typeof window === "undefined" || isAdminEmbedDocument)
|
|
125
126
|
return null;
|
|
126
127
|
var route = parseModelViewRoute(target);
|
|
127
128
|
if (!route)
|
|
@@ -189,11 +190,11 @@ export var getMenuContextForActiveRoute = function (currentPathname, currentSear
|
|
|
189
190
|
};
|
|
190
191
|
// Copy menu identity between routes belonging to the same model. This keeps
|
|
191
192
|
// active sidebar state in the URL for new navigation while preserving legacy forms.
|
|
192
|
-
export var preserveModelMenuContext = function (target) {
|
|
193
|
+
export var preserveModelMenuContext = function (target, current) {
|
|
193
194
|
if (typeof window === "undefined" || !target || target.startsWith("#"))
|
|
194
195
|
return target;
|
|
195
196
|
try {
|
|
196
|
-
var currentUrl = new URL(window.location.href);
|
|
197
|
+
var currentUrl = new URL(current || window.location.href, window.location.origin);
|
|
197
198
|
var targetUrl_1 = new URL(target, currentUrl.href);
|
|
198
199
|
var currentModelKey = getModelRouteKey(currentUrl.pathname);
|
|
199
200
|
var targetModelKey = getModelRouteKey(targetUrl_1.pathname);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modelViewPersistence.js","sourceRoot":"","sources":["../../src/helpers/modelViewPersistence.ts"],"names":[],"mappings":";;;;;;;;;AAAA,IAAM,sBAAsB,GAAG,wBAAwB,CAAC;AAExD,IAAM,sBAAsB,GAC1B,4DAA4D,CAAC;AAmB/D,IAAM,mBAAmB,GAAG;;IAC1B,IAAI,OAAO,MAAM,KAAK,WAAW,KAAI,MAAA,MAAM,CAAC,QAAQ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AC,aAAa,EAAE,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,KAAI,UAAU,CAAC,CAAC;KACtE;IAAC,OAAO,KAAK,EAAE;QACd,4DAA4D;KAC7D;IAED,IAAI,KAAK,EAAE;QACT,yBAAyB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;KAC3C;AACH,CAAC,CAAC","sourcesContent":["const MODEL_VIEW_STORAGE_KEY = \"solidx.model.last-view\";\n\nconst MODEL_VIEW_ROUTE_REGEX =\n /^\\/admin\\/core\\/([^/]+)\\/([^/]+)\\/(list|tree|kanban|card)$/;\n\ntype ParsedModelViewRoute = {\n actionId: string;\n fullPath: string;\n menuItemId: string;\n modelName: string;\n moduleName: string;\n pathname: string;\n viewType: \"list\" | \"tree\" | \"kanban\" | \"card\";\n};\n\ntype StoredModelViewEntry = {\n path: string;\n updatedAt: number;\n};\n\ntype StoredModelViewMap = Record<string, StoredModelViewEntry | string>;\n\nconst getRouteParsingBase = () => {\n if (typeof window !== \"undefined\" && window.location?.origin) {\n return window.location.origin;\n }\n\n};\n\n// Normalize a list/tree/kanban/card URL into a shape we can store and compare.\n// We keep the full query string because menu/action params are part of the return route.\nconst parseModelViewRoute = (target: string): ParsedModelViewRoute | null => {\n if (!target) return null;\n\n try {\n const url = new URL(target, getRouteParsingBase());\n const match = url.pathname.match(MODEL_VIEW_ROUTE_REGEX);\n\n if (!match) return null;\n\n const [, moduleName, modelName, viewType] = match;\n const menuItemId = url.searchParams.get(\"menuItemId\") || \"\";\n const actionId = url.searchParams.get(\"actionId\") || \"\";\n\n return {\n actionId,\n fullPath: `${url.pathname}${url.search}`,\n menuItemId,\n modelName,\n moduleName,\n pathname: url.pathname,\n viewType: viewType as ParsedModelViewRoute[\"viewType\"],\n };\n } catch (error) {\n return null;\n }\n};\n\nconst getScopedStorageKey = (route: ParsedModelViewRoute) =>\n `model:${route.moduleName}:${route.modelName}:menu:${route.menuItemId}:action:${route.actionId}`;\n\nconst getMenuStorageKey = (route: ParsedModelViewRoute) =>\n `model:${route.moduleName}:${route.modelName}:menu:${route.menuItemId}`;\n\nconst getModelStorageKey = (route: ParsedModelViewRoute) =>\n `model:${route.moduleName}:${route.modelName}`;\n\n// Older saved values may exist as plain strings from previous implementations.\n// Convert everything into one consistent shape before comparing timestamps.\nconst normalizeStoredEntry = (value: StoredModelViewEntry | string | undefined | null): StoredModelViewEntry | null => {\n if (!value) return null;\n\n if (typeof value === \"string\") {\n return {\n path: value,\n updatedAt: 0,\n };\n }\n\n if (typeof value.path !== \"string\" || !value.path) {\n return null;\n }\n\n return {\n path: value.path,\n updatedAt: Number(value.updatedAt) || 0,\n };\n};\n\nconst readStoredModelViews = (): StoredModelViewMap => {\n if (typeof window === \"undefined\") return {};\n\n try {\n const raw = window.localStorage.getItem(MODEL_VIEW_STORAGE_KEY);\n if (!raw) return {};\n\n const parsed = JSON.parse(raw);\n return parsed && typeof parsed === \"object\" ? parsed : {};\n } catch (error) {\n return {};\n }\n};\n\nconst writeStoredModelViews = (next: StoredModelViewMap) => {\n if (typeof window === \"undefined\") return;\n\n try {\n window.localStorage.setItem(MODEL_VIEW_STORAGE_KEY, JSON.stringify(next));\n } catch (error) {\n // Ignore storage write failures and keep navigation working.\n }\n};\n\n// Save the current route at three scopes:\n// 1. exact model + menu + action\n// 2. model + menu\n// 3. model\n// This lets us reopen the most useful last-selected view even when the user\n// returns through a slightly different sidebar/menu link.\nexport const persistLastModelViewRoute = (target: string) => {\n if (typeof window === \"undefined\") return;\n\n const route = parseModelViewRoute(target);\n if (!route) return;\n\n const next = readStoredModelViews();\n const entry: StoredModelViewEntry = {\n path: route.fullPath,\n updatedAt: Date.now(),\n };\n\n next[getScopedStorageKey(route)] = entry;\n if (route.menuItemId) {\n next[getMenuStorageKey(route)] = entry;\n }\n next[getModelStorageKey(route)] = entry;\n writeStoredModelViews(next);\n};\n\n// Resolve the best saved route for the current model context.\n// We prefer the newest entry and use scope priority as a tie-breaker.\nexport const getPersistedLastModelViewRoute = (target: string): string | null => {\n if (typeof window === \"undefined\") return null;\n\n const route = parseModelViewRoute(target);\n if (!route) return null;\n\n const stored = readStoredModelViews();\n const hasMenuScope = Boolean(route.menuItemId || route.actionId);\n const candidateKeys = [\n hasMenuScope ? getScopedStorageKey(route) : null,\n route.menuItemId ? getMenuStorageKey(route) : null,\n hasMenuScope ? null : getModelStorageKey(route),\n ].filter(Boolean) as string[];\n\n let bestMatch: { entry: StoredModelViewEntry; priority: number } | null = null;\n\n for (let priority = 0; priority < candidateKeys.length; priority += 1) {\n const key = candidateKeys[priority];\n const entry = normalizeStoredEntry(stored[key]);\n if (!entry) continue;\n\n if (!bestMatch || entry.updatedAt > bestMatch.entry.updatedAt || (entry.updatedAt === bestMatch.entry.updatedAt && priority < bestMatch.priority)) {\n bestMatch = { entry, priority };\n }\n }\n\n return bestMatch ? bestMatch.entry.path : null;\n};\n\n// Sidebar and menu links often point to `/list` by default.\n// If we have a retained non-list view for the same model context, reopen that instead.\nexport const resolveRetainedModelViewRoute = (target: string): string => {\n const route = parseModelViewRoute(target);\n if (!route || route.viewType !== \"list\") return target;\n\n const storedRoute = getPersistedLastModelViewRoute(target);\n return storedRoute || target;\n};\n\n\nconst SIDEBAR_CONTEXT_KEYS = [\"menuItemId\", \"menuItemName\"] as const;\nconst MODEL_VIEW_CONTEXT_KEYS = [\n ...SIDEBAR_CONTEXT_KEYS,\n \"actionId\",\n \"actionName\",\n] as const;\nconst MODEL_ROUTE_REGEX = /^\\/admin\\/core\\/[^/]+\\/[^/]+\\/(?:list|tree|kanban|card|form)(?:\\/|$)/;\nconst MODEL_KEY_REGEX = /^(\\/admin\\/core\\/[^/]+\\/[^/]+)/;\n\nconst getModelRouteKey = (pathname: string): string | null =>\n pathname.match(MODEL_KEY_REGEX)?.[1] || null;\n\n// Forms may not contain menu IDs yet. Use the current URL first, then the\n// last model view saved before opening the form as a backwards-compatible fallback.\nexport const getMenuContextForActiveRoute = (\n currentPathname: string,\n currentSearchParams: URLSearchParams,\n): URLSearchParams => {\n if (currentSearchParams.has(\"menuItemId\") || currentSearchParams.has(\"actionId\")) {\n return currentSearchParams;\n }\n\n if (typeof window === \"undefined\") return currentSearchParams;\n\n try {\n const storedViewUrl = window.sessionStorage.getItem(\"fromViewUrl\");\n if (!storedViewUrl) return currentSearchParams;\n\n const storedUrl = new URL(storedViewUrl, window.location.origin);\n const storedRoute = parseModelViewRoute(storedUrl.href);\n const currentModelKey = getModelRouteKey(currentPathname);\n const storedModelKey = getModelRouteKey(storedUrl.pathname);\n\n if (!storedRoute || !currentModelKey || currentModelKey !== storedModelKey) {\n return currentSearchParams;\n }\n\n return storedUrl.searchParams;\n } catch {\n return currentSearchParams;\n }\n};\n\n// Copy menu identity between routes belonging to the same model. This keeps\n// active sidebar state in the URL for new navigation while preserving legacy forms.\nexport const preserveModelMenuContext = (target: string): string => {\n if (typeof window === \"undefined\" || !target || target.startsWith(\"#\")) return target;\n\n try {\n const currentUrl = new URL(window.location.href);\n const targetUrl = new URL(target, currentUrl.href);\n const currentModelKey = getModelRouteKey(currentUrl.pathname);\n const targetModelKey = getModelRouteKey(targetUrl.pathname);\n const isFormRoute = /\\/admin\\/core\\/[^/]+\\/[^/]+\\/form(?:\\/|$)/.test(targetUrl.pathname);\n\n if (!MODEL_ROUTE_REGEX.test(currentUrl.pathname) || !MODEL_ROUTE_REGEX.test(targetUrl.pathname) || !currentModelKey || currentModelKey !== targetModelKey) {\n return target;\n }\n\n if (isFormRoute) {\n targetUrl.searchParams.delete(\"actionId\");\n }\n\n const context = getMenuContextForActiveRoute(currentUrl.pathname, currentUrl.searchParams);\n const keysToCopy = isFormRoute ? SIDEBAR_CONTEXT_KEYS : MODEL_VIEW_CONTEXT_KEYS;\n\n keysToCopy.forEach((key) => {\n if (!targetUrl.searchParams.has(key) && context.has(key)) {\n targetUrl.searchParams.set(key, context.get(key) || \"\");\n }\n });\n\n return targetUrl.pathname + targetUrl.search + targetUrl.hash;\n } catch {\n return target;\n }\n};\n\n// Keep short-lived \"back to previous view\" state in sessionStorage and also\n// refresh the longer-lived localStorage route retention in one call.\nexport const storeCurrentModelViewContext = (target?: string) => {\n if (typeof window === \"undefined\") return;\n\n const fallbackTarget = `${window.location.pathname}${window.location.search}`;\n const nextTarget = target || fallbackTarget;\n const route = parseModelViewRoute(nextTarget);\n\n try {\n if (route?.viewType) {\n sessionStorage.setItem(\"fromView\", route.viewType);\n }\n sessionStorage.setItem(\"fromViewUrl\", route?.fullPath || nextTarget);\n } catch (error) {\n // Ignore storage failures so navigation can still continue.\n }\n\n if (route) {\n persistLastModelViewRoute(route.fullPath);\n }\n};\n"]}
|
|
1
|
+
{"version":3,"file":"modelViewPersistence.js","sourceRoot":"","sources":["../../src/helpers/modelViewPersistence.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEhE,IAAM,sBAAsB,GAAG,wBAAwB,CAAC;AAExD,IAAM,sBAAsB,GAC1B,4DAA4D,CAAC;AAmB/D,IAAM,mBAAmB,GAAG;;IAC1B,IAAI,OAAO,MAAM,KAAK,WAAW,KAAI,MAAA,MAAM,CAAC,QAAQ,0CAAE,MAAM,CAAA,EAAE;QAC5D,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;KAC/B;AAEH,CAAC,CAAC;AAEF,+EAA+E;AAC/E,yFAAyF;AACzF,IAAM,mBAAmB,GAAG,UAAC,MAAc;IACzC,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IAEzB,IAAI;QACF,IAAM,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,EAAE,mBAAmB,EAAE,CAAC,CAAC;QACnD,IAAM,KAAK,GAAG,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC;QAEzD,IAAI,CAAC,KAAK;YAAE,OAAO,IAAI,CAAC;QAEf,IAAA,UAAU,GAAyB,KAAK,GAA9B,EAAE,SAAS,GAAc,KAAK,G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WAAS,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,SAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;aACzD;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,WAAS,CAAC,QAAQ,GAAG,WAAS,CAAC,MAAM,GAAG,WAAS,CAAC,IAAI,CAAC;KAC/D;IAAC,WAAM;QACN,OAAO,MAAM,CAAC;KACf;AACH,CAAC,CAAC;AAEF,4EAA4E;AAC5E,qEAAqE;AACrE,MAAM,CAAC,IAAM,4BAA4B,GAAG,UAAC,MAAe;IAC1D,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO;IAE1C,IAAM,cAAc,GAAG,UAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ,SAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAE,CAAC;IAC9E,IAAM,UAAU,GAAG,MAAM,IAAI,cAAc,CAAC;IAC5C,IAAM,KAAK,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAE9C,IAAI;QACF,IAAI,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,EAAE;YACnB,cAAc,CAAC,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;SACpD;QACD,cAAc,CAAC,OAAO,CAAC,aAAa,EAAE,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,KAAI,UAAU,CAAC,CAAC;KACtE;IAAC,OAAO,KAAK,EAAE;QACd,4DAA4D;KAC7D;IAED,IAAI,KAAK,EAAE;QACT,yBAAyB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;KAC3C;AACH,CAAC,CAAC","sourcesContent":["import { isAdminEmbedDocument } from \"../adapters/auth/storage\";\n\nconst MODEL_VIEW_STORAGE_KEY = \"solidx.model.last-view\";\n\nconst MODEL_VIEW_ROUTE_REGEX =\n /^\\/admin\\/core\\/([^/]+)\\/([^/]+)\\/(list|tree|kanban|card)$/;\n\ntype ParsedModelViewRoute = {\n actionId: string;\n fullPath: string;\n menuItemId: string;\n modelName: string;\n moduleName: string;\n pathname: string;\n viewType: \"list\" | \"tree\" | \"kanban\" | \"card\";\n};\n\ntype StoredModelViewEntry = {\n path: string;\n updatedAt: number;\n};\n\ntype StoredModelViewMap = Record<string, StoredModelViewEntry | string>;\n\nconst getRouteParsingBase = () => {\n if (typeof window !== \"undefined\" && window.location?.origin) {\n return window.location.origin;\n }\n\n};\n\n// Normalize a list/tree/kanban/card URL into a shape we can store and compare.\n// We keep the full query string because menu/action params are part of the return route.\nconst parseModelViewRoute = (target: string): ParsedModelViewRoute | null => {\n if (!target) return null;\n\n try {\n const url = new URL(target, getRouteParsingBase());\n const match = url.pathname.match(MODEL_VIEW_ROUTE_REGEX);\n\n if (!match) return null;\n\n const [, moduleName, modelName, viewType] = match;\n const menuItemId = url.searchParams.get(\"menuItemId\") || \"\";\n const actionId = url.searchParams.get(\"actionId\") || \"\";\n\n return {\n actionId,\n fullPath: `${url.pathname}${url.search}`,\n menuItemId,\n modelName,\n moduleName,\n pathname: url.pathname,\n viewType: viewType as ParsedModelViewRoute[\"viewType\"],\n };\n } catch (error) {\n return null;\n }\n};\n\nconst getScopedStorageKey = (route: ParsedModelViewRoute) =>\n `model:${route.moduleName}:${route.modelName}:menu:${route.menuItemId}:action:${route.actionId}`;\n\nconst getMenuStorageKey = (route: ParsedModelViewRoute) =>\n `model:${route.moduleName}:${route.modelName}:menu:${route.menuItemId}`;\n\nconst getModelStorageKey = (route: ParsedModelViewRoute) =>\n `model:${route.moduleName}:${route.modelName}`;\n\n// Older saved values may exist as plain strings from previous implementations.\n// Convert everything into one consistent shape before comparing timestamps.\nconst normalizeStoredEntry = (value: StoredModelViewEntry | string | undefined | null): StoredModelViewEntry | null => {\n if (!value) return null;\n\n if (typeof value === \"string\") {\n return {\n path: value,\n updatedAt: 0,\n };\n }\n\n if (typeof value.path !== \"string\" || !value.path) {\n return null;\n }\n\n return {\n path: value.path,\n updatedAt: Number(value.updatedAt) || 0,\n };\n};\n\nconst readStoredModelViews = (): StoredModelViewMap => {\n if (typeof window === \"undefined\") return {};\n\n try {\n const raw = window.localStorage.getItem(MODEL_VIEW_STORAGE_KEY);\n if (!raw) return {};\n\n const parsed = JSON.parse(raw);\n return parsed && typeof parsed === \"object\" ? parsed : {};\n } catch (error) {\n return {};\n }\n};\n\nconst writeStoredModelViews = (next: StoredModelViewMap) => {\n if (typeof window === \"undefined\") return;\n\n try {\n window.localStorage.setItem(MODEL_VIEW_STORAGE_KEY, JSON.stringify(next));\n } catch (error) {\n // Ignore storage write failures and keep navigation working.\n }\n};\n\n// Save the current route at three scopes:\n// 1. exact model + menu + action\n// 2. model + menu\n// 3. model\n// This lets us reopen the most useful last-selected view even when the user\n// returns through a slightly different sidebar/menu link.\nexport const persistLastModelViewRoute = (target: string) => {\n if (typeof window === \"undefined\" || isAdminEmbedDocument) return;\n\n const route = parseModelViewRoute(target);\n if (!route) return;\n\n const next = readStoredModelViews();\n const entry: StoredModelViewEntry = {\n path: route.fullPath,\n updatedAt: Date.now(),\n };\n\n next[getScopedStorageKey(route)] = entry;\n if (route.menuItemId) {\n next[getMenuStorageKey(route)] = entry;\n }\n next[getModelStorageKey(route)] = entry;\n writeStoredModelViews(next);\n};\n\n// Resolve the best saved route for the current model context.\n// We prefer the newest entry and use scope priority as a tie-breaker.\nexport const getPersistedLastModelViewRoute = (target: string): string | null => {\n if (typeof window === \"undefined\" || isAdminEmbedDocument) return null;\n\n const route = parseModelViewRoute(target);\n if (!route) return null;\n\n const stored = readStoredModelViews();\n const hasMenuScope = Boolean(route.menuItemId || route.actionId);\n const candidateKeys = [\n hasMenuScope ? getScopedStorageKey(route) : null,\n route.menuItemId ? getMenuStorageKey(route) : null,\n hasMenuScope ? null : getModelStorageKey(route),\n ].filter(Boolean) as string[];\n\n let bestMatch: { entry: StoredModelViewEntry; priority: number } | null = null;\n\n for (let priority = 0; priority < candidateKeys.length; priority += 1) {\n const key = candidateKeys[priority];\n const entry = normalizeStoredEntry(stored[key]);\n if (!entry) continue;\n\n if (!bestMatch || entry.updatedAt > bestMatch.entry.updatedAt || (entry.updatedAt === bestMatch.entry.updatedAt && priority < bestMatch.priority)) {\n bestMatch = { entry, priority };\n }\n }\n\n return bestMatch ? bestMatch.entry.path : null;\n};\n\n// Sidebar and menu links often point to `/list` by default.\n// If we have a retained non-list view for the same model context, reopen that instead.\nexport const resolveRetainedModelViewRoute = (target: string): string => {\n const route = parseModelViewRoute(target);\n if (!route || route.viewType !== \"list\") return target;\n\n const storedRoute = getPersistedLastModelViewRoute(target);\n return storedRoute || target;\n};\n\n\nconst SIDEBAR_CONTEXT_KEYS = [\"menuItemId\", \"menuItemName\"] as const;\nconst MODEL_VIEW_CONTEXT_KEYS = [\n ...SIDEBAR_CONTEXT_KEYS,\n \"actionId\",\n \"actionName\",\n] as const;\nconst MODEL_ROUTE_REGEX = /^\\/admin\\/core\\/[^/]+\\/[^/]+\\/(?:list|tree|kanban|card|form)(?:\\/|$)/;\nconst MODEL_KEY_REGEX = /^(\\/admin\\/core\\/[^/]+\\/[^/]+)/;\n\nconst getModelRouteKey = (pathname: string): string | null =>\n pathname.match(MODEL_KEY_REGEX)?.[1] || null;\n\n// Forms may not contain menu IDs yet. Use the current URL first, then the\n// last model view saved before opening the form as a backwards-compatible fallback.\nexport const getMenuContextForActiveRoute = (\n currentPathname: string,\n currentSearchParams: URLSearchParams,\n): URLSearchParams => {\n if (currentSearchParams.has(\"menuItemId\") || currentSearchParams.has(\"actionId\")) {\n return currentSearchParams;\n }\n\n if (typeof window === \"undefined\") return currentSearchParams;\n\n try {\n const storedViewUrl = window.sessionStorage.getItem(\"fromViewUrl\");\n if (!storedViewUrl) return currentSearchParams;\n\n const storedUrl = new URL(storedViewUrl, window.location.origin);\n const storedRoute = parseModelViewRoute(storedUrl.href);\n const currentModelKey = getModelRouteKey(currentPathname);\n const storedModelKey = getModelRouteKey(storedUrl.pathname);\n\n if (!storedRoute || !currentModelKey || currentModelKey !== storedModelKey) {\n return currentSearchParams;\n }\n\n return storedUrl.searchParams;\n } catch {\n return currentSearchParams;\n }\n};\n\n// Copy menu identity between routes belonging to the same model. This keeps\n// active sidebar state in the URL for new navigation while preserving legacy forms.\nexport const preserveModelMenuContext = (target: string, current?: string): string => {\n if (typeof window === \"undefined\" || !target || target.startsWith(\"#\")) return target;\n\n try {\n const currentUrl = new URL(current || window.location.href, window.location.origin);\n const targetUrl = new URL(target, currentUrl.href);\n const currentModelKey = getModelRouteKey(currentUrl.pathname);\n const targetModelKey = getModelRouteKey(targetUrl.pathname);\n const isFormRoute = /\\/admin\\/core\\/[^/]+\\/[^/]+\\/form(?:\\/|$)/.test(targetUrl.pathname);\n\n if (!MODEL_ROUTE_REGEX.test(currentUrl.pathname) || !MODEL_ROUTE_REGEX.test(targetUrl.pathname) || !currentModelKey || currentModelKey !== targetModelKey) {\n return target;\n }\n\n if (isFormRoute) {\n targetUrl.searchParams.delete(\"actionId\");\n }\n\n const context = getMenuContextForActiveRoute(currentUrl.pathname, currentUrl.searchParams);\n const keysToCopy = isFormRoute ? SIDEBAR_CONTEXT_KEYS : MODEL_VIEW_CONTEXT_KEYS;\n\n keysToCopy.forEach((key) => {\n if (!targetUrl.searchParams.has(key) && context.has(key)) {\n targetUrl.searchParams.set(key, context.get(key) || \"\");\n }\n });\n\n return targetUrl.pathname + targetUrl.search + targetUrl.hash;\n } catch {\n return target;\n }\n};\n\n// Keep short-lived \"back to previous view\" state in sessionStorage and also\n// refresh the longer-lived localStorage route retention in one call.\nexport const storeCurrentModelViewContext = (target?: string) => {\n if (typeof window === \"undefined\") return;\n\n const fallbackTarget = `${window.location.pathname}${window.location.search}`;\n const nextTarget = target || fallbackTarget;\n const route = parseModelViewRoute(nextTarget);\n\n try {\n if (route?.viewType) {\n sessionStorage.setItem(\"fromView\", route.viewType);\n }\n sessionStorage.setItem(\"fromViewUrl\", route?.fullPath || nextTarget);\n } catch (error) {\n // Ignore storage failures so navigation can still continue.\n }\n\n if (route) {\n persistLastModelViewRoute(route.fullPath);\n }\n};\n"]}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { isAdminEmbedDocument } from "../adapters/auth/storage";
|
|
2
|
+
|
|
1
3
|
const MODEL_VIEW_STORAGE_KEY = "solidx.model.last-view";
|
|
2
4
|
|
|
3
5
|
const MODEL_VIEW_ROUTE_REGEX =
|
|
@@ -118,7 +120,7 @@ const writeStoredModelViews = (next: StoredModelViewMap) => {
|
|
|
118
120
|
// This lets us reopen the most useful last-selected view even when the user
|
|
119
121
|
// returns through a slightly different sidebar/menu link.
|
|
120
122
|
export const persistLastModelViewRoute = (target: string) => {
|
|
121
|
-
if (typeof window === "undefined") return;
|
|
123
|
+
if (typeof window === "undefined" || isAdminEmbedDocument) return;
|
|
122
124
|
|
|
123
125
|
const route = parseModelViewRoute(target);
|
|
124
126
|
if (!route) return;
|
|
@@ -140,7 +142,7 @@ export const persistLastModelViewRoute = (target: string) => {
|
|
|
140
142
|
// Resolve the best saved route for the current model context.
|
|
141
143
|
// We prefer the newest entry and use scope priority as a tie-breaker.
|
|
142
144
|
export const getPersistedLastModelViewRoute = (target: string): string | null => {
|
|
143
|
-
if (typeof window === "undefined") return null;
|
|
145
|
+
if (typeof window === "undefined" || isAdminEmbedDocument) return null;
|
|
144
146
|
|
|
145
147
|
const route = parseModelViewRoute(target);
|
|
146
148
|
if (!route) return null;
|
|
@@ -224,11 +226,11 @@ export const getMenuContextForActiveRoute = (
|
|
|
224
226
|
|
|
225
227
|
// Copy menu identity between routes belonging to the same model. This keeps
|
|
226
228
|
// active sidebar state in the URL for new navigation while preserving legacy forms.
|
|
227
|
-
export const preserveModelMenuContext = (target: string): string => {
|
|
229
|
+
export const preserveModelMenuContext = (target: string, current?: string): string => {
|
|
228
230
|
if (typeof window === "undefined" || !target || target.startsWith("#")) return target;
|
|
229
231
|
|
|
230
232
|
try {
|
|
231
|
-
const currentUrl = new URL(window.location.href);
|
|
233
|
+
const currentUrl = new URL(current || window.location.href, window.location.origin);
|
|
232
234
|
const targetUrl = new URL(target, currentUrl.href);
|
|
233
235
|
const currentModelKey = getModelRouteKey(currentUrl.pathname);
|
|
234
236
|
const targetModelKey = getModelRouteKey(targetUrl.pathname);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRouter.d.ts","sourceRoot":"","sources":["../../src/hooks/useRouter.ts"],"names":[],"mappings":"AAKA,wBAAgB,SAAS;
|
|
1
|
+
{"version":3,"file":"useRouter.d.ts","sourceRoot":"","sources":["../../src/hooks/useRouter.ts"],"names":[],"mappings":"AAKA,wBAAgB,SAAS;iBAKH,MAAM;oBASH,MAAM;;;;EAkB9B"}
|
package/dist/hooks/useRouter.js
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
import { useNavigate } from "react-router-dom";
|
|
1
|
+
import { useLocation, useNavigate } from "react-router-dom";
|
|
2
2
|
import { preserveModelMenuContext } from "../helpers/modelViewPersistence";
|
|
3
3
|
var isAbsoluteUrl = function (href) { return /^[a-z][a-z0-9+.-]*:/.test(href) || href.startsWith("//"); };
|
|
4
4
|
export function useRouter() {
|
|
5
5
|
var navigate = useNavigate();
|
|
6
|
+
var _a = useLocation(), pathname = _a.pathname, search = _a.search;
|
|
7
|
+
var current = pathname + search;
|
|
6
8
|
var push = function (href) {
|
|
7
9
|
if (typeof window !== "undefined" && isAbsoluteUrl(href)) {
|
|
8
10
|
window.location.assign(href);
|
|
9
11
|
return;
|
|
10
12
|
}
|
|
11
|
-
navigate(preserveModelMenuContext(href));
|
|
13
|
+
navigate(preserveModelMenuContext(href, current));
|
|
12
14
|
};
|
|
13
15
|
var replace = function (href) {
|
|
14
16
|
if (typeof window !== "undefined" && isAbsoluteUrl(href)) {
|
|
15
17
|
window.location.replace(href);
|
|
16
18
|
return;
|
|
17
19
|
}
|
|
18
|
-
navigate(preserveModelMenuContext(href), { replace: true });
|
|
20
|
+
navigate(preserveModelMenuContext(href, current), { replace: true });
|
|
19
21
|
};
|
|
20
22
|
return {
|
|
21
23
|
push: push,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRouter.js","sourceRoot":"","sources":["../../src/hooks/useRouter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"useRouter.js","sourceRoot":"","sources":["../../src/hooks/useRouter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAE3E,IAAM,aAAa,GAAG,UAAC,IAAY,IAAK,OAAA,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAzD,CAAyD,CAAC;AAElG,MAAM,UAAU,SAAS;IACvB,IAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;IACzB,IAAA,KAAuB,WAAW,EAAE,EAAlC,QAAQ,cAAA,EAAE,MAAM,YAAkB,CAAC;IAC3C,IAAM,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;IAElC,IAAM,IAAI,GAAG,UAAC,IAAY;QACxB,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,aAAa,CAAC,IAAI,CAAC,EAAE;YACxD,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAC7B,OAAO;SACR;QAED,QAAQ,CAAC,wBAAwB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;IACpD,CAAC,CAAC;IAEF,IAAM,OAAO,GAAG,UAAC,IAAY;QAC3B,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,aAAa,CAAC,IAAI,CAAC,EAAE;YACxD,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAC9B,OAAO;SACR;QAED,QAAQ,CAAC,wBAAwB,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IACvE,CAAC,CAAC;IAEF,OAAO;QACL,IAAI,MAAA;QACJ,OAAO,SAAA;QACP,IAAI,EAAE,cAAM,OAAA,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAZ,CAAY;QACxB,OAAO,EAAE,cAAM,OAAA,QAAQ,CAAC,CAAC,CAAC,EAAX,CAAW;QAC1B,OAAO,EAAE;YACP,QAAQ,CAAC,CAAC,CAAC,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { useLocation, useNavigate } from \"react-router-dom\";\nimport { preserveModelMenuContext } from \"../helpers/modelViewPersistence\";\n\nconst isAbsoluteUrl = (href: string) => /^[a-z][a-z0-9+.-]*:/.test(href) || href.startsWith(\"//\");\n\nexport function useRouter() {\n const navigate = useNavigate();\n const { pathname, search } = useLocation();\n const current = pathname + search;\n\n const push = (href: string) => {\n if (typeof window !== \"undefined\" && isAbsoluteUrl(href)) {\n window.location.assign(href);\n return;\n }\n\n navigate(preserveModelMenuContext(href, current));\n };\n\n const replace = (href: string) => {\n if (typeof window !== \"undefined\" && isAbsoluteUrl(href)) {\n window.location.replace(href);\n return;\n }\n\n navigate(preserveModelMenuContext(href, current), { replace: true });\n };\n\n return {\n push,\n replace,\n back: () => navigate(-1),\n forward: () => navigate(1),\n refresh: () => {\n navigate(0);\n },\n };\n}\n"]}
|
package/dist/hooks/useRouter.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { useNavigate } from "react-router-dom";
|
|
1
|
+
import { useLocation, useNavigate } from "react-router-dom";
|
|
2
2
|
import { preserveModelMenuContext } from "../helpers/modelViewPersistence";
|
|
3
3
|
|
|
4
4
|
const isAbsoluteUrl = (href: string) => /^[a-z][a-z0-9+.-]*:/.test(href) || href.startsWith("//");
|
|
5
5
|
|
|
6
6
|
export function useRouter() {
|
|
7
7
|
const navigate = useNavigate();
|
|
8
|
+
const { pathname, search } = useLocation();
|
|
9
|
+
const current = pathname + search;
|
|
8
10
|
|
|
9
11
|
const push = (href: string) => {
|
|
10
12
|
if (typeof window !== "undefined" && isAbsoluteUrl(href)) {
|
|
@@ -12,7 +14,7 @@ export function useRouter() {
|
|
|
12
14
|
return;
|
|
13
15
|
}
|
|
14
16
|
|
|
15
|
-
navigate(preserveModelMenuContext(href));
|
|
17
|
+
navigate(preserveModelMenuContext(href, current));
|
|
16
18
|
};
|
|
17
19
|
|
|
18
20
|
const replace = (href: string) => {
|
|
@@ -21,7 +23,7 @@ export function useRouter() {
|
|
|
21
23
|
return;
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
navigate(preserveModelMenuContext(href), { replace: true });
|
|
26
|
+
navigate(preserveModelMenuContext(href, current), { replace: true });
|
|
25
27
|
};
|
|
26
28
|
|
|
27
29
|
return {
|
|
@@ -5468,7 +5468,9 @@ html.dark .solid-paginator-btn:hover:not(:disabled),
|
|
|
5468
5468
|
}
|
|
5469
5469
|
|
|
5470
5470
|
.solid-dropdown-menu-content {
|
|
5471
|
-
z-
|
|
5471
|
+
/* Above the SolidX Agent panel and the other fixed overlays (all at --z-overlay + 100), so a menu or submenu
|
|
5472
|
+
opened from a toolbar is never cut off behind them. */
|
|
5473
|
+
z-index: calc(var(--z-overlay, 1000) + 200);
|
|
5472
5474
|
width: 146px;
|
|
5473
5475
|
min-width: 146px;
|
|
5474
5476
|
padding: 4px 4px;
|
|
@@ -6795,6 +6797,17 @@ html.dark .solid-paginator-btn:hover:not(:disabled),
|
|
|
6795
6797
|
|
|
6796
6798
|
}
|
|
6797
6799
|
|
|
6800
|
+
/* The docked SolidX Agent panel is fixed over the right edge. A dialog centred on the whole viewport would have its
|
|
6801
|
+
right side hidden under it, so centre it in the space left of the panel and keep it narrower than that space.
|
|
6802
|
+
`!important` because sized dialogs set their own max-width with a more specific selector (the common dialog's
|
|
6803
|
+
min(92vw, 1100px) left the module update dialog under the panel on a 1440px screen). */
|
|
6804
|
+
@media (min-width: 641px) {
|
|
6805
|
+
body.solid-agent-docked .solid-radix-dialog-content {
|
|
6806
|
+
left: calc((100vw - var(--solid-agent-docked-width, 420px)) / 2);
|
|
6807
|
+
max-width: calc(100vw - var(--solid-agent-docked-width, 420px) - 2rem) !important;
|
|
6808
|
+
}
|
|
6809
|
+
}
|
|
6810
|
+
|
|
6798
6811
|
.solid-radix-dialog-header {
|
|
6799
6812
|
display: flex;
|
|
6800
6813
|
align-items: flex-start;
|
|
@@ -72,7 +72,7 @@ export function AppEventListener() {
|
|
|
72
72
|
}, []);
|
|
73
73
|
useEffect(function () {
|
|
74
74
|
var off = eventBus.on(AppEvents.GlobalError, function (payload) {
|
|
75
|
-
if (!pathname.startsWith("/admin") && !pathname.startsWith("/auth")) {
|
|
75
|
+
if (!pathname.startsWith("/admin") && !pathname.startsWith("/auth") && pathname !== "/embed/admin") {
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
78
78
|
dispatch(showToast({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppEventListener.js","sourceRoot":"","sources":["../../src/routes/AppEventListener.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,oBAAoB,EAA2B,MAAM,iCAAiC,CAAC;AAQhG,SAAS,SAAS;IAChB,IAAM,OAAO,GAAG,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,EAAE,C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B,CAAC,SAAS,CAAC,UAAC,KAAK;YAC1C,IAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC;YAChC,IAAM,gBAAgB,GAAG,cAAc,KAAK,SAAS,IAAI,UAAU,KAAK,SAAS,CAAC;YAClF,cAAc,GAAG,UAAU,CAAC;YAE5B,IAAI,CAAC,gBAAgB,EAAE;gBACrB,OAAO;aACR;YAED,QAAQ,CACN,SAAS,CAAC;gBACR,QAAQ,EAAE,OAAO;gBACjB,OAAO,EAAE,oBAAoB;gBAC7B,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,mBAAmB,CAAC;oBACxC,MAAM,EAAE,KAAK,CAAC,UAAU;oBACxB,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,qDAAqD;oBAC/E,KAAK,EAAE,KAAK,CAAC,KAAK;iBACnB,CAAC,CAAC,CAAC,CAAC,kEAA2D,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,uBAAuB,GAAG,IAAI,CAAC,CAAC,cAAW;gBACxI,MAAM,EAAE,SAAS,EAAE;gBACnB,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;aACjC,CAAC,CACH,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,OAAO,CACL,4BACG,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,eAAe,CAAC,IAAI,KAAC,WAAW,KAAG,GACtF,CACJ,CAAC;AACJ,CAAC","sourcesContent":["import { useEffect } from \"react\";\nimport { eventBus, AppEvents } from \"../helpers/eventBus\";\nimport { usePathname } from \"../hooks/usePathname\";\nimport { SolidStudio } from \"../components/layout/SolidAiStudioLayout\";\nimport { useDispatch } from \"react-redux\";\nimport { showToast } from \"../redux/features/toastSlice\";\nimport { env } from \"../adapters/env\";\nimport { backendHealthMonitor, type BackendHealthState } from \"../helpers/backendHealthMonitor\";\n\ntype GlobalErrorPayload = {\n status?: number | string;\n message?: string;\n error?: unknown;\n};\n\nfunction isDevMode() {\n const envName = (env(\"VITE_SOLIDX_ENV\") || \"\").toLowerCase();\n return envName === \"dev\" || envName === \"development\";\n}\n\nfunction formatUnknownValue(value: unknown) {\n if (typeof value === \"string\") return value;\n if (value === null || value === undefined) return \"\";\n\n try {\n return JSON.stringify(value, null, 2);\n } catch {\n return String(value);\n }\n}\n\nfunction buildDevErrorDetail(payload?: GlobalErrorPayload) {\n if (!payload) return undefined;\n\n const error = payload.error as any;\n const lines: string[] = [];\n\n if (payload.status !== undefined) {\n lines.push(`Status: ${String(payload.status)}`);\n }\n\n if (payload.message) {\n lines.push(`Summary: ${payload.message}`);\n }\n\n if (error?.message) {\n lines.push(`Error: ${error.message}`);\n }\n\n if (error?.code) {\n lines.push(`Code: ${error.code}`);\n }\n\n const responseData = error?.response?.data ?? error?.data;\n const responseText = formatUnknownValue(responseData);\n if (responseText) {\n lines.push(`Response:\\n${responseText}`);\n }\n\n if (error?.stack) {\n lines.push(`Stack:\\n${error.stack}`);\n }\n\n return lines.length > 0 ? lines.join(\"\\n\\n\") : undefined;\n}\n\nexport function AppEventListener() {\n const pathname = usePathname();\n const dispatch = useDispatch();\n\n // Reveal scrollbars only while scrolling (see auto-hiding scrollbars in _main.scss).\n // `scroll` doesn't bubble, so one capturing listener covers every scrollable element.\n useEffect(() => {\n const timers = new WeakMap<Element, number>();\n const onScroll = (event: Event) => {\n const target = event.target;\n const element = target instanceof Element ? target : target === document ? document.documentElement : null;\n if (!element) return;\n element.setAttribute(\"data-scrolling\", \"\");\n window.clearTimeout(timers.get(element));\n timers.set(element, window.setTimeout(() => element.removeAttribute(\"data-scrolling\"), 900));\n };\n document.addEventListener(\"scroll\", onScroll, { capture: true, passive: true });\n return () => document.removeEventListener(\"scroll\", onScroll, { capture: true });\n }, []);\n\n useEffect(() => {\n const off = eventBus.on<GlobalErrorPayload>(AppEvents.GlobalError, (payload) => {\n if (!pathname.startsWith(\"/admin\") && !pathname.startsWith(\"/auth\") && pathname !== \"/embed/admin\") {\n return;\n }\n\n dispatch(\n showToast({\n severity: \"error\",\n summary: payload?.message || \"Something went wrong\",\n detail: isDevMode() ? buildDevErrorDetail(payload) : undefined,\n sticky: isDevMode(),\n life: isDevMode() ? 10000 : 4000,\n })\n );\n });\n return () => off();\n }, [dispatch, pathname]);\n\n useEffect(() => {\n let previousStatus: BackendHealthState[\"status\"] = backendHealthMonitor.getState().status;\n\n return backendHealthMonitor.subscribe((state) => {\n const nextStatus = state.status;\n const didBecomeOffline = previousStatus !== \"offline\" && nextStatus === \"offline\";\n previousStatus = nextStatus;\n\n if (!didBecomeOffline) {\n return;\n }\n\n dispatch(\n showToast({\n severity: \"error\",\n summary: \"Server unreachable\",\n detail: isDevMode() ? buildDevErrorDetail({\n status: state.statusCode,\n message: state.message || \"Unable to reach the server. Please try again later.\",\n error: state.error,\n }) : `We have been trying to reconnect to the server for over ${Math.max(1, Math.round(state.unavailableToastDelayMs / 1000))} seconds.`,\n sticky: isDevMode(),\n life: isDevMode() ? 10000 : 5000,\n })\n );\n });\n }, [dispatch]);\n\n return (\n <>\n {window.self === window.top && !pathname.startsWith(\"/embed/agent/\") && <SolidStudio />}\n </>\n );\n}\n"]}
|
|
@@ -86,7 +86,7 @@ export function AppEventListener() {
|
|
|
86
86
|
|
|
87
87
|
useEffect(() => {
|
|
88
88
|
const off = eventBus.on<GlobalErrorPayload>(AppEvents.GlobalError, (payload) => {
|
|
89
|
-
if (!pathname.startsWith("/admin") && !pathname.startsWith("/auth")) {
|
|
89
|
+
if (!pathname.startsWith("/admin") && !pathname.startsWith("/auth") && pathname !== "/embed/admin") {
|
|
90
90
|
return;
|
|
91
91
|
}
|
|
92
92
|
|
|
@@ -5,9 +5,8 @@ export type AgentDeployment = {
|
|
|
5
5
|
processCpu?: number | null;
|
|
6
6
|
processMemory?: number | null;
|
|
7
7
|
};
|
|
8
|
-
export declare function AgentDeploymentPanel({
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
onSaved: () => void;
|
|
8
|
+
export declare function AgentDeploymentPanel({ value, onChange }: {
|
|
9
|
+
value: AgentDeployment;
|
|
10
|
+
onChange: (value: AgentDeployment) => void;
|
|
12
11
|
}): import("react/jsx-runtime").JSX.Element;
|
|
13
12
|
//# sourceMappingURL=AgentDeploymentPanel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentDeploymentPanel.d.ts","sourceRoot":"","sources":["../../../../../src/routes/pages/admin/core/AgentDeploymentPanel.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AgentDeploymentPanel.d.ts","sourceRoot":"","sources":["../../../../../src/routes/pages/admin/core/AgentDeploymentPanel.tsx"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B,CAAC;AAEF,wBAAgB,oBAAoB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE;IACxD,KAAK,EAAE,eAAe,CAAC;IACvB,QAAQ,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;CAC5C,2CAsCA"}
|
|
@@ -1,88 +1,18 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
36
11
|
};
|
|
37
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
38
|
-
import React from "react";
|
|
39
|
-
import { SolidButton } from "../../../../components/shad-cn-ui";
|
|
40
|
-
import { solidPatch } from "../../../../http/solidHttp";
|
|
41
13
|
export function AgentDeploymentPanel(_a) {
|
|
42
|
-
var _b, _c, _d, _e, _f
|
|
43
|
-
var
|
|
44
|
-
|
|
45
|
-
var _l = React.useState(String((_c = current.minProcesses) !== null && _c !== void 0 ? _c : 0)), minimum = _l[0], setMinimum = _l[1];
|
|
46
|
-
var _m = React.useState((_e = (_d = current.maxProcesses) === null || _d === void 0 ? void 0 : _d.toString()) !== null && _e !== void 0 ? _e : ""), maximum = _m[0], setMaximum = _m[1];
|
|
47
|
-
var _o = React.useState((_g = (_f = current.processCpu) === null || _f === void 0 ? void 0 : _f.toString()) !== null && _g !== void 0 ? _g : ""), cpu = _o[0], setCpu = _o[1];
|
|
48
|
-
var _p = React.useState((_j = (_h = current.processMemory) === null || _h === void 0 ? void 0 : _h.toString()) !== null && _j !== void 0 ? _j : ""), memory = _p[0], setMemory = _p[1];
|
|
49
|
-
var _q = React.useState(false), saving = _q[0], setSaving = _q[1];
|
|
50
|
-
var _r = React.useState(), status = _r[0], setStatus = _r[1];
|
|
51
|
-
function save(event) {
|
|
52
|
-
var _a, _b;
|
|
53
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
54
|
-
var error_1, detail;
|
|
55
|
-
return __generator(this, function (_c) {
|
|
56
|
-
switch (_c.label) {
|
|
57
|
-
case 0:
|
|
58
|
-
event.preventDefault();
|
|
59
|
-
setSaving(true);
|
|
60
|
-
setStatus(undefined);
|
|
61
|
-
_c.label = 1;
|
|
62
|
-
case 1:
|
|
63
|
-
_c.trys.push([1, 3, 4, 5]);
|
|
64
|
-
return [4 /*yield*/, solidPatch("/agent-registry/".concat(agentId, "/deployment"), {
|
|
65
|
-
runner: runner || null, minProcesses: Number(minimum), maxProcesses: maximum ? Number(maximum) : null,
|
|
66
|
-
processCpu: cpu ? Number(cpu) : null, processMemory: memory ? Number(memory) : null,
|
|
67
|
-
})];
|
|
68
|
-
case 2:
|
|
69
|
-
_c.sent();
|
|
70
|
-
setStatus({ error: false, text: "Deployment settings saved." });
|
|
71
|
-
onSaved();
|
|
72
|
-
return [3 /*break*/, 5];
|
|
73
|
-
case 3:
|
|
74
|
-
error_1 = _c.sent();
|
|
75
|
-
detail = (_b = (_a = error_1.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message;
|
|
76
|
-
setStatus({ error: true, text: typeof detail === "string" ? detail : "Could not save deployment settings." });
|
|
77
|
-
return [3 /*break*/, 5];
|
|
78
|
-
case 4:
|
|
79
|
-
setSaving(false);
|
|
80
|
-
return [7 /*endfinally*/];
|
|
81
|
-
case 5: return [2 /*return*/];
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
return _jsxs("form", { className: "agent-editor__section", onSubmit: function (event) { return void save(event); }, children: [_jsx("h2", { children: "Deployment" }), _jsx("p", { children: "Runner and resource changes apply to new workers. Restart a worker to replace it using these settings." }), _jsxs("div", { className: "agent-editor__grid", children: [_jsxs("label", { className: "agent-editor__field", children: ["Runner", _jsxs("select", { value: runner, onChange: function (event) { return setRunner(event.target.value); }, children: [_jsx("option", { value: "", children: "Installation default" }), _jsx("option", { value: "local", children: "Local process" }), _jsx("option", { value: "docker", children: "Docker" }), _jsx("option", { value: "ecs", children: "Amazon ECS" })] })] }), _jsxs("label", { className: "agent-editor__field", children: ["Minimum processes", _jsx("input", { type: "number", min: 0, required: true, value: minimum, onChange: function (event) { return setMinimum(event.target.value); } })] }), _jsxs("label", { className: "agent-editor__field", children: ["Maximum processes", _jsx("input", { type: "number", min: 1, placeholder: "Installation default", value: maximum, onChange: function (event) { return setMaximum(event.target.value); } })] }), _jsxs("label", { className: "agent-editor__field", children: ["CPU units", _jsx("input", { type: "number", min: 1, placeholder: "Runner default", value: cpu, onChange: function (event) { return setCpu(event.target.value); } })] }), _jsxs("label", { className: "agent-editor__field", children: ["Memory (MiB)", _jsx("input", { type: "number", min: 1, placeholder: "Runner default", value: memory, onChange: function (event) { return setMemory(event.target.value); } })] })] }), _jsx(SolidButton, { type: "submit", variant: "secondary", loading: saving, disabled: saving, children: "Save deployment settings" }), status && _jsx("p", { role: status.error ? "alert" : "status", children: status.text })] });
|
|
14
|
+
var _b, _c, _d, _e, _f;
|
|
15
|
+
var value = _a.value, onChange = _a.onChange;
|
|
16
|
+
return _jsxs("section", { className: "agent-editor__section", children: [_jsx("h2", { children: "Deployment" }), _jsxs("div", { className: "agent-editor__grid", children: [_jsxs("label", { className: "agent-editor__field", children: ["Runner", _jsxs("select", { value: (_b = value.runner) !== null && _b !== void 0 ? _b : "", onChange: function (event) { return onChange(__assign(__assign({}, value), { runner: event.target.value || null })); }, children: [_jsx("option", { value: "", children: "Installation default" }), _jsx("option", { value: "local", children: "Local process" }), _jsx("option", { value: "docker", children: "Docker" }), _jsx("option", { value: "ecs", children: "Amazon ECS" })] })] }), _jsxs("label", { className: "agent-editor__field", children: ["Minimum processes", _jsx("input", { type: "number", min: 0, required: true, value: (_c = value.minProcesses) !== null && _c !== void 0 ? _c : 0, onChange: function (event) { return onChange(__assign(__assign({}, value), { minProcesses: Number(event.target.value) })); } })] }), _jsxs("label", { className: "agent-editor__field", children: ["Maximum processes", _jsx("input", { type: "number", min: 1, placeholder: "Installation default", value: (_d = value.maxProcesses) !== null && _d !== void 0 ? _d : "", onChange: function (event) { return onChange(__assign(__assign({}, value), { maxProcesses: event.target.value ? Number(event.target.value) : null })); } })] }), _jsxs("label", { className: "agent-editor__field", children: ["CPU units", _jsx("input", { type: "number", min: 1, placeholder: "Runner default", value: (_e = value.processCpu) !== null && _e !== void 0 ? _e : "", onChange: function (event) { return onChange(__assign(__assign({}, value), { processCpu: event.target.value ? Number(event.target.value) : null })); } })] }), _jsxs("label", { className: "agent-editor__field", children: ["Memory (MiB)", _jsx("input", { type: "number", min: 1, placeholder: "Runner default", value: (_f = value.processMemory) !== null && _f !== void 0 ? _f : "", onChange: function (event) { return onChange(__assign(__assign({}, value), { processMemory: event.target.value ? Number(event.target.value) : null })); } })] })] }), _jsxs("aside", { className: "agent-editor__deployment-help", "aria-label": "Deployment guidance", children: [_jsx("strong", { children: "About deployment" }), _jsx("p", { children: "These settings control where new workers run and how many can be available for this agent." }), _jsxs("ul", { children: [_jsxs("li", { children: [_jsx("strong", { children: "Installation default:" }), " Uses the runner configured for the AgentHub installation. Choose this when the agent should follow the environment-wide default."] }), _jsxs("li", { children: [_jsx("strong", { children: "Local process:" }), " Runs workers on the AgentHub host. No separate runner setup is needed; CPU and memory overrides are not applied to local workers."] }), _jsxs("li", { children: [_jsx("strong", { children: "Docker:" }), " Requires Docker access and an ", _jsx("code", { children: "AGENT_HUB_DOCKER_IMAGE" }), " image. Remote workers also need PostgreSQL, a reachable HTTPS manager URL, and a public gateway URL. Configure networking and shared workspace storage when needed."] }), _jsxs("li", { children: [_jsx("strong", { children: "Amazon ECS:" }), " Requires AWS access plus an ECS cluster, Fargate task definition, private subnet IDs, and security group IDs. The task definition must include the configured container (default: ", _jsx("code", { children: "agent" }), "); remote workers also need PostgreSQL, an HTTPS manager URL, and a public gateway URL."] }), _jsxs("li", { children: [_jsx("strong", { children: "Process limits:" }), " Minimum processes keep workers warm; maximum processes caps this agent\u2019s worker pool. Blank maximum uses the installation default. CPU units and memory (MiB) are resource overrides for Docker and ECS; blank values use runner defaults."] })] }), _jsxs("p", { children: ["Runner and resource changes affect new workers. Restart workers to replace existing ones. Save with ", _jsx("strong", { children: "Save Agent" }), "; saving an active agent moves it to Draft, which must be activated to create the next config version."] })] })] });
|
|
87
17
|
}
|
|
88
18
|
//# sourceMappingURL=AgentDeploymentPanel.js.map
|