@t0.labs/daxta 0.4.7 → 0.4.8

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.
@@ -287,6 +287,26 @@
287
287
  color: var(--white);
288
288
  box-shadow: none;
289
289
  }
290
+ .env-base-line {
291
+ margin-top: 8px;
292
+ padding: 8px 10px;
293
+ border-radius: 8px;
294
+ background: var(--inset);
295
+ font: 11px/1.4 var(--mono);
296
+ color: var(--charcoal);
297
+ word-break: break-all;
298
+ }
299
+ .env-base-line span { color: var(--stone); }
300
+ .env-quick {
301
+ display: flex;
302
+ flex-wrap: wrap;
303
+ gap: 6px;
304
+ margin-top: 8px;
305
+ }
306
+ .env-kv.base-url .env-cell[data-field="key"] {
307
+ opacity: 0.7;
308
+ pointer-events: none;
309
+ }
290
310
  .env-add {
291
311
  height: 32px;
292
312
  padding: 0 10px;
@@ -380,7 +400,8 @@
380
400
  display: flex;
381
401
  align-items: center;
382
402
  gap: 8px;
383
- width: 100%;
403
+ flex: 1;
404
+ min-width: 0;
384
405
  border: 0;
385
406
  background: transparent;
386
407
  text-align: left;
@@ -388,8 +409,80 @@
388
409
  border-radius: var(--radius);
389
410
  cursor: pointer;
390
411
  }
391
- .nav-item:hover { background: var(--white); }
392
- .nav-item.active { background: var(--white); box-shadow: var(--ring); }
412
+ .nav-item:hover { background: transparent; }
413
+ .nav-op {
414
+ display: flex;
415
+ flex-direction: column;
416
+ gap: 0;
417
+ border-radius: var(--radius);
418
+ }
419
+ .nav-op:hover { background: var(--white); }
420
+ .nav-op.active { background: var(--white); box-shadow: var(--ring); }
421
+ .nav-op-row {
422
+ display: flex;
423
+ align-items: center;
424
+ gap: 2px;
425
+ min-width: 0;
426
+ }
427
+ .nav-expand {
428
+ flex: none;
429
+ width: 28px;
430
+ height: 28px;
431
+ border: 0;
432
+ border-radius: 6px;
433
+ background: transparent;
434
+ color: var(--stone);
435
+ cursor: pointer;
436
+ display: inline-flex;
437
+ align-items: center;
438
+ justify-content: center;
439
+ padding: 0;
440
+ }
441
+ .nav-expand:hover { color: var(--obsidian); background: var(--inset); }
442
+ .nav-expand .chev {
443
+ width: 6px;
444
+ height: 6px;
445
+ border-right: 1.5px solid currentColor;
446
+ border-bottom: 1.5px solid currentColor;
447
+ transform: rotate(-45deg);
448
+ transition: transform 0.15s ease;
449
+ margin-top: -2px;
450
+ }
451
+ .nav-op.examples-open > .nav-op-row .nav-expand .chev {
452
+ transform: rotate(45deg);
453
+ margin-top: 0;
454
+ }
455
+ .nav-expand:disabled {
456
+ opacity: 0.25;
457
+ cursor: default;
458
+ }
459
+ .nav-examples {
460
+ display: none;
461
+ flex-direction: column;
462
+ gap: 1px;
463
+ margin: 0 4px 6px 18px;
464
+ padding-left: 10px;
465
+ border-left: 1px solid var(--hairline);
466
+ }
467
+ .nav-op.examples-open > .nav-examples { display: flex; }
468
+ .nav-example {
469
+ display: block;
470
+ width: 100%;
471
+ border: 0;
472
+ background: transparent;
473
+ text-align: left;
474
+ padding: 5px 8px;
475
+ border-radius: 6px;
476
+ cursor: pointer;
477
+ font-size: 11px;
478
+ line-height: 1.35;
479
+ color: var(--stone);
480
+ overflow: hidden;
481
+ text-overflow: ellipsis;
482
+ white-space: nowrap;
483
+ }
484
+ .nav-example:hover { background: var(--inset); color: var(--charcoal); }
485
+ .nav-example.on { color: var(--obsidian); background: var(--inset); }
393
486
  .nav-title {
394
487
  font-size: 12px;
395
488
  color: var(--charcoal);
@@ -398,7 +491,149 @@
398
491
  text-overflow: ellipsis;
399
492
  white-space: nowrap;
400
493
  }
401
- .nav-item.active .nav-title { color: var(--obsidian); }
494
+ .nav-op.active .nav-title { color: var(--obsidian); }
495
+
496
+ .export-backdrop {
497
+ display: none;
498
+ position: fixed;
499
+ inset: 0;
500
+ background: rgba(232, 232, 232, 0.72);
501
+ backdrop-filter: blur(2px);
502
+ z-index: 40;
503
+ align-items: center;
504
+ justify-content: center;
505
+ padding: 24px;
506
+ }
507
+ body.exporting .export-backdrop { display: flex; }
508
+ .export-modal {
509
+ width: min(560px, 100%);
510
+ max-height: min(720px, calc(100vh - 48px));
511
+ display: flex;
512
+ flex-direction: column;
513
+ background: var(--white);
514
+ border-radius: 12px;
515
+ box-shadow: 0 18px 48px rgba(0, 0, 0, 0.16), var(--ring);
516
+ overflow: hidden;
517
+ }
518
+ .export-head {
519
+ padding: 18px 20px 12px;
520
+ border-bottom: 1px solid var(--hairline);
521
+ }
522
+ .export-head h2 {
523
+ margin: 0;
524
+ font-size: 18px;
525
+ font-weight: 500;
526
+ letter-spacing: -0.02em;
527
+ }
528
+ .export-head p {
529
+ margin: 6px 0 0;
530
+ font-size: 13px;
531
+ color: var(--stone);
532
+ line-height: 1.4;
533
+ }
534
+ .export-options {
535
+ padding: 12px 20px;
536
+ border-bottom: 1px solid var(--hairline);
537
+ display: flex;
538
+ flex-direction: column;
539
+ gap: 10px;
540
+ background: var(--inset);
541
+ }
542
+ .export-check {
543
+ display: flex;
544
+ align-items: flex-start;
545
+ gap: 8px;
546
+ font-size: 13px;
547
+ color: var(--obsidian);
548
+ cursor: pointer;
549
+ line-height: 1.35;
550
+ }
551
+ .export-check input { margin-top: 2px; }
552
+ .export-tryit-meta {
553
+ margin: -4px 0 0 22px;
554
+ font-size: 12px;
555
+ color: var(--stone);
556
+ font-family: var(--mono);
557
+ }
558
+ .export-mode {
559
+ display: flex;
560
+ flex-direction: column;
561
+ gap: 6px;
562
+ margin-left: 22px;
563
+ }
564
+ .export-mode label {
565
+ display: flex;
566
+ align-items: flex-start;
567
+ gap: 8px;
568
+ font-size: 12px;
569
+ color: var(--charcoal);
570
+ cursor: pointer;
571
+ line-height: 1.35;
572
+ }
573
+ .export-mode.disabled { opacity: 0.45; pointer-events: none; }
574
+ .export-tip {
575
+ margin: 0 0 0 22px;
576
+ font-size: 11px;
577
+ color: var(--stone);
578
+ line-height: 1.4;
579
+ }
580
+ .export-toolbar {
581
+ display: flex;
582
+ flex-wrap: wrap;
583
+ gap: 8px;
584
+ padding: 10px 20px;
585
+ border-bottom: 1px solid var(--hairline);
586
+ }
587
+ .export-body {
588
+ flex: 1;
589
+ overflow: auto;
590
+ padding: 8px 12px 16px;
591
+ }
592
+ .export-op {
593
+ padding: 10px 8px;
594
+ border-bottom: 1px solid var(--hairline);
595
+ }
596
+ .export-op:last-child { border-bottom: 0; }
597
+ .export-op-title {
598
+ display: flex;
599
+ align-items: center;
600
+ gap: 8px;
601
+ margin-bottom: 8px;
602
+ font-size: 12px;
603
+ color: var(--obsidian);
604
+ }
605
+ .export-op-title .path {
606
+ font-family: var(--mono);
607
+ font-size: 11px;
608
+ color: var(--stone);
609
+ overflow: hidden;
610
+ text-overflow: ellipsis;
611
+ white-space: nowrap;
612
+ }
613
+ .export-ex {
614
+ display: flex;
615
+ align-items: flex-start;
616
+ gap: 8px;
617
+ padding: 4px 4px 4px 2px;
618
+ font-size: 12px;
619
+ color: var(--charcoal);
620
+ line-height: 1.35;
621
+ }
622
+ .export-ex input { margin-top: 2px; }
623
+ .export-ex label { cursor: pointer; min-width: 0; }
624
+ .export-empty {
625
+ padding: 28px 16px;
626
+ text-align: center;
627
+ color: var(--stone);
628
+ font-size: 13px;
629
+ }
630
+ .export-foot {
631
+ display: flex;
632
+ justify-content: flex-end;
633
+ gap: 8px;
634
+ padding: 12px 16px 16px;
635
+ border-top: 1px solid var(--hairline);
636
+ }
402
637
 
403
638
  .method {
404
639
  display: inline-flex;
@@ -739,6 +974,42 @@
739
974
  </div>
740
975
  </header>
741
976
  <div class="search-backdrop" id="search-backdrop"></div>
977
+ <div class="export-backdrop" id="export-backdrop" role="dialog" aria-modal="true" aria-labelledby="export-title">
978
+ <div class="export-modal" id="export-modal">
979
+ <div class="export-head">
980
+ <h2 id="export-title">Export OpenAPI</h2>
981
+ <p>Choose examples to include. Optionally bake Try-it env/headers so Postman can auto-fill on import.</p>
982
+ </div>
983
+ <div class="export-options">
984
+ <label class="export-check">
985
+ <input type="checkbox" id="export-include-tryit" checked />
986
+ <span>Include active Try-it env + header group</span>
987
+ </label>
988
+ <div class="export-tryit-meta" id="export-tryit-meta">—</div>
989
+ <div class="export-mode" id="export-mode-wrap">
990
+ <label>
991
+ <input type="radio" name="export-fill" value="resolved" checked />
992
+ <span>Resolved values in OpenAPI <span style="color:var(--stone)">(headers/server filled literally)</span></span>
993
+ </label>
994
+ <label>
995
+ <input type="radio" name="export-fill" value="variables" />
996
+ <span>Postman <code>{{variables}}</code> + download environment file</span>
997
+ </label>
998
+ </div>
999
+ <p class="export-tip">In Postman Import → advanced: set parameter generation to <strong>Example</strong>. Import the environment file if you use variables mode.</p>
1000
+ </div>
1001
+ <div class="export-toolbar">
1002
+ <button type="button" class="btn sm" id="export-all">All</button>
1003
+ <button type="button" class="btn sm" id="export-none">None</button>
1004
+ <button type="button" class="btn sm" id="export-success">Success only</button>
1005
+ </div>
1006
+ <div class="export-body" id="export-body"></div>
1007
+ <div class="export-foot">
1008
+ <button type="button" class="btn sm" id="export-cancel">Cancel</button>
1009
+ <button type="button" class="btn primary sm" id="export-confirm">Download</button>
1010
+ </div>
1011
+ </div>
1012
+ </div>
742
1013
  <div class="app">
743
1014
  <aside class="sidebar" id="nav"></aside>
744
1015
  <main class="workbench" id="main"></main>
@@ -776,6 +1047,16 @@
776
1047
  const title = (spec.info && spec.info.title) || "API Docs";
777
1048
  const STORE_KEY = "openapi-docs-env:" + (workspace || "default");
778
1049
 
1050
+ const docsBaseForApi = (() => {
1051
+ if (typeof location === "undefined") return docsPathSuffix;
1052
+ let pathname = (location.pathname || "/").replace(/\/$/, "") || "";
1053
+ if (pathname === docsPathSuffix || pathname.endsWith(docsPathSuffix)) return pathname || docsPathSuffix;
1054
+ const idx = pathname.indexOf(docsPathSuffix);
1055
+ if (idx >= 0) return pathname.slice(0, idx + docsPathSuffix.length) || docsPathSuffix;
1056
+ return docsPathSuffix;
1057
+ })();
1058
+ const ENV_STORE_URL = docsBaseForApi + "/env.json";
1059
+
779
1060
  let liveResult = null;
780
1061
 
781
1062
  const escapeAttr = (value) =>
@@ -820,10 +1101,23 @@
820
1101
 
821
1102
  const defaultHeaderValues = collectDefaultHeaderValues();
822
1103
 
823
- const buildDefaultStore = () => {
1104
+ const configuredPresets = (() => {
1105
+ const raw = viewer.envPresets;
1106
+ if (raw && typeof raw === "object" && Object.keys(raw).length) return raw;
1107
+ return { local: { baseUrl: defaultBaseUrl } };
1108
+ })();
1109
+
1110
+ const setEnvBaseUrl = (env, baseUrl) => {
1111
+ const variables = env.variables || (env.variables = []);
1112
+ const row = variables.find((entry) => entry.key === "baseUrl");
1113
+ if (row) row.value = baseUrl;
1114
+ else variables.unshift({ key: "baseUrl", value: baseUrl });
1115
+ };
1116
+
1117
+ const buildHeaderTemplate = () => {
824
1118
  const schemes = (spec.components && spec.components.securitySchemes) || {};
825
- const variables = [{ key: "baseUrl", value: defaultBaseUrl }];
826
- const varKeys = new Set(["baseUrl"]);
1119
+ const variables = [];
1120
+ const varKeys = new Set();
827
1121
  const headerGroups = {};
828
1122
  for (const [schemeId, scheme] of Object.entries(schemes)) {
829
1123
  if (!scheme || scheme.in !== "header" || !scheme.name) continue;
@@ -839,7 +1133,6 @@
839
1133
  { key: "content-type", value: "application/json" },
840
1134
  ];
841
1135
  }
842
- // Pre-build merged groups for operations that need multiple schemes together.
843
1136
  const seenCombos = new Set();
844
1137
  for (const pathItem of Object.values(spec.paths || {})) {
845
1138
  for (const op of Object.values(pathItem || {})) {
@@ -867,17 +1160,56 @@
867
1160
  headerGroups[comboKey] = Object.values(byKey);
868
1161
  }
869
1162
  }
870
-
871
1163
  const groupNames = Object.keys(headerGroups);
872
1164
  if (!groupNames.length) headerGroups.default = [{ key: "content-type", value: "application/json" }];
1165
+ return { variables, headerGroups };
1166
+ };
1167
+
1168
+ const envFromPreset = (preset) => {
1169
+ const template = buildHeaderTemplate();
1170
+ const baseUrl = String((preset && preset.baseUrl) || defaultBaseUrl).replace(/\/$/, "") || defaultBaseUrl;
1171
+ const variables = [{ key: "baseUrl", value: baseUrl }, ...template.variables.map((row) => ({ ...row }))];
1172
+ const known = new Set(variables.map((row) => row.key));
1173
+ if (preset && preset.variables && typeof preset.variables === "object") {
1174
+ for (const [key, value] of Object.entries(preset.variables)) {
1175
+ if (!key || key === "baseUrl") continue;
1176
+ if (known.has(key)) {
1177
+ const row = variables.find((entry) => entry.key === key);
1178
+ if (row) row.value = String(value ?? "");
1179
+ } else {
1180
+ variables.push({ key, value: String(value ?? "") });
1181
+ known.add(key);
1182
+ }
1183
+ }
1184
+ }
1185
+ const headerGroups = {};
1186
+ for (const [group, rows] of Object.entries(template.headerGroups)) {
1187
+ headerGroups[group] = rows.map((row) => ({ ...row }));
1188
+ }
1189
+ return { variables, headerGroups };
1190
+ };
1191
+
1192
+ const buildDefaultStore = () => {
1193
+ const envs = {};
1194
+ for (const [name, preset] of Object.entries(configuredPresets)) {
1195
+ envs[name] = envFromPreset(preset);
1196
+ }
1197
+ if (!Object.keys(envs).length) envs.local = envFromPreset({ baseUrl: defaultBaseUrl });
1198
+ const names = Object.keys(envs);
1199
+ const activeEnv = names.includes("local") ? "local" : names[0];
1200
+ const groupNames = Object.keys(envs[activeEnv].headerGroups || {});
873
1201
  return {
874
- activeEnv: "local",
1202
+ activeEnv,
875
1203
  activeGroup: groupNames[0] || "default",
876
- envs: { local: { variables, headerGroups } },
1204
+ envs,
877
1205
  };
878
1206
  };
879
1207
 
880
- const cloneDefaultEnv = () => JSON.parse(JSON.stringify(buildDefaultStore().envs.local));
1208
+ const cloneDefaultEnv = () => {
1209
+ const defaults = buildDefaultStore();
1210
+ const name = defaults.envs.local ? "local" : Object.keys(defaults.envs)[0];
1211
+ return JSON.parse(JSON.stringify(defaults.envs[name]));
1212
+ };
881
1213
 
882
1214
  const mergeStore = (saved) => {
883
1215
  const defaults = buildDefaultStore();
@@ -885,12 +1217,13 @@
885
1217
  const envs = {};
886
1218
  for (const [name, env] of Object.entries(saved.envs)) {
887
1219
  const base = cloneDefaultEnv();
888
- const variables = Array.isArray(env.variables) ? env.variables.map((row) => ({ key: String(row.key || ""), value: String(row.value ?? "") })) : base.variables.map((row) => ({ ...row }));
1220
+ const variables = Array.isArray(env.variables)
1221
+ ? env.variables.map((row) => ({ key: String(row.key || ""), value: String(row.value ?? "") }))
1222
+ : base.variables.map((row) => ({ ...row }));
889
1223
  const known = new Set(variables.map((row) => row.key).filter(Boolean));
890
1224
  for (const row of base.variables) {
891
1225
  if (row.key && !known.has(row.key)) variables.push({ ...row });
892
1226
  }
893
- // Backfill empty env values from recorded defaults so Try-it works out of the box.
894
1227
  const defaultsByKey = Object.fromEntries((base.variables || []).filter((row) => row.key).map((row) => [row.key, row.value ?? ""]));
895
1228
  for (const row of variables) {
896
1229
  if (!row.key) continue;
@@ -904,6 +1237,11 @@
904
1237
  if (!Object.keys(headerGroups).length) headerGroups.default = [{ key: "content-type", value: "application/json" }];
905
1238
  envs[name] = { variables, headerGroups };
906
1239
  }
1240
+ // Seed any config presets that are missing from the saved store (don't wipe existing).
1241
+ for (const [name, preset] of Object.entries(configuredPresets)) {
1242
+ if (envs[name]) continue;
1243
+ envs[name] = envFromPreset(preset);
1244
+ }
907
1245
  if (!Object.keys(envs).length) return defaults;
908
1246
  const activeEnv = envs[saved.activeEnv] ? saved.activeEnv : Object.keys(envs)[0];
909
1247
  const groups = Object.keys(envs[activeEnv].headerGroups || {});
@@ -911,33 +1249,75 @@
911
1249
  return { activeEnv, activeGroup, envs };
912
1250
  };
913
1251
 
914
- const loadStore = () => {
1252
+ const loadLocalStore = () => {
915
1253
  try {
916
1254
  const raw = localStorage.getItem(STORE_KEY);
917
1255
  if (raw) return mergeStore(JSON.parse(raw));
918
1256
  } catch {}
919
- return buildDefaultStore();
1257
+ return null;
920
1258
  };
921
1259
 
1260
+ /**
1261
+ * Only rewrite baseUrl for local-ish presets so staging/production stay intact.
1262
+ */
922
1263
  const applyServingBaseUrl = (state) => {
923
1264
  if (!locationBaseUrl || !state || !state.envs) return state;
924
- for (const env of Object.values(state.envs)) {
925
- const variables = env.variables || (env.variables = []);
926
- const row = variables.find((entry) => entry.key === "baseUrl");
927
- if (row) row.value = locationBaseUrl;
928
- else variables.unshift({ key: "baseUrl", value: locationBaseUrl });
1265
+ const preferred = ["local", "development", "dev"].find((name) => state.envs[name]);
1266
+ if (preferred) {
1267
+ setEnvBaseUrl(state.envs[preferred], locationBaseUrl);
1268
+ return state;
929
1269
  }
1270
+ const names = Object.keys(state.envs);
1271
+ if (names.length === 1) setEnvBaseUrl(state.envs[names[0]], locationBaseUrl);
930
1272
  return state;
931
1273
  };
932
1274
 
933
- let store = applyServingBaseUrl(loadStore());
1275
+ // Prefer disk (shared across browsers / deploy), then localStorage, then defaults.
1276
+ let store = applyServingBaseUrl(loadLocalStore() || buildDefaultStore());
1277
+ let persistTimer = null;
934
1278
 
935
- const persistStore = () => {
1279
+ const writeLocalStore = () => {
936
1280
  try {
937
1281
  localStorage.setItem(STORE_KEY, JSON.stringify(store));
938
1282
  } catch {}
939
1283
  };
940
1284
 
1285
+ const writeServerStore = async () => {
1286
+ try {
1287
+ const res = await fetch(ENV_STORE_URL, {
1288
+ method: "PUT",
1289
+ headers: { "content-type": "application/json" },
1290
+ body: JSON.stringify(store),
1291
+ });
1292
+ if (!res.ok) return;
1293
+ } catch {
1294
+ /* offline / file:// — localStorage still works */
1295
+ }
1296
+ };
1297
+
1298
+ const persistStore = () => {
1299
+ writeLocalStore();
1300
+ if (persistTimer) clearTimeout(persistTimer);
1301
+ persistTimer = setTimeout(() => {
1302
+ persistTimer = null;
1303
+ writeServerStore();
1304
+ }, 250);
1305
+ };
1306
+
1307
+ const hydrateStoreFromServer = async () => {
1308
+ try {
1309
+ const res = await fetch(ENV_STORE_URL, { cache: "no-store" });
1310
+ if (!res.ok) return false;
1311
+ const remote = await res.json();
1312
+ if (!remote || typeof remote !== "object" || !remote.envs) return false;
1313
+ store = applyServingBaseUrl(mergeStore(remote));
1314
+ writeLocalStore();
1315
+ return true;
1316
+ } catch {
1317
+ return false;
1318
+ }
1319
+ };
1320
+
941
1321
  const activeEnvConfig = () => store.envs[store.activeEnv] || store.envs[Object.keys(store.envs)[0]];
942
1322
 
943
1323
  const varMap = () => {
@@ -1033,7 +1413,27 @@
1033
1413
 
1034
1414
  const syncEnvTrigger = () => {
1035
1415
  const trigger = document.getElementById("env-trigger");
1036
- if (trigger) trigger.textContent = envLabel();
1416
+ if (!trigger) return;
1417
+ trigger.textContent = envLabel();
1418
+ const base = varMap().baseUrl || "";
1419
+ trigger.title = base ? store.activeEnv + " · " + base + " · " + store.activeGroup : envLabel();
1420
+ };
1421
+
1422
+ const presetBaseUrl = (name) => {
1423
+ const env = store.envs[name];
1424
+ if (!env) return "";
1425
+ const row = (env.variables || []).find((entry) => entry.key === "baseUrl");
1426
+ return row ? String(row.value || "") : "";
1427
+ };
1428
+
1429
+ const addNamedPreset = (name, baseUrl) => {
1430
+ if (!name || store.envs[name]) return false;
1431
+ const env = cloneDefaultEnv();
1432
+ setEnvBaseUrl(env, baseUrl || defaultBaseUrl);
1433
+ store.envs[name] = env;
1434
+ store.activeEnv = name;
1435
+ store.activeGroup = Object.keys(env.headerGroups || {})[0] || "default";
1436
+ return true;
1037
1437
  };
1038
1438
 
1039
1439
  const renderEnvPop = () => {
@@ -1044,26 +1444,43 @@
1044
1444
  const groupRows = env.headerGroups[store.activeGroup] || [];
1045
1445
  const canRemoveEnv = envNames.length > 1;
1046
1446
  const canRemoveGroup = groups.length > 1;
1447
+ const activeBase = presetBaseUrl(store.activeEnv) || defaultBaseUrl;
1448
+ const quickPresets = [
1449
+ { id: "staging", baseUrl: (configuredPresets.staging && configuredPresets.staging.baseUrl) || "https://api.staging.example.com" },
1450
+ { id: "production", baseUrl: (configuredPresets.production && configuredPresets.production.baseUrl) || "https://api.example.com" },
1451
+ ].filter((preset) => !store.envs[preset.id]);
1047
1452
 
1048
1453
  document.getElementById("env-pop").innerHTML = `
1049
1454
  <div class="env-block">
1050
- <div class="env-label">Env</div>
1455
+ <div class="env-label">Presets</div>
1051
1456
  <div class="chip-row">
1052
1457
  ${envNames
1053
- .map((id) => `<button type="button" class="chip-btn ${id === store.activeEnv ? "on" : ""}" data-env="${escapeAttr(id)}">${escapeAttr(id)}</button>`)
1458
+ .map((id) => `<button type="button" class="chip-btn ${id === store.activeEnv ? "on" : ""}" data-env="${escapeAttr(id)}" title="${escapeAttr(presetBaseUrl(id))}">${escapeAttr(id)}</button>`)
1054
1459
  .join("")}
1055
- <button type="button" class="ghost-btn" id="add-env" title="Add env">+</button>
1056
- <button type="button" class="ghost-btn" id="remove-env" title="Remove env" ${canRemoveEnv ? "" : "disabled"}>×</button>
1460
+ <button type="button" class="ghost-btn" id="add-env" title="Add preset">+</button>
1461
+ <button type="button" class="ghost-btn" id="dup-env" title="Duplicate preset">⧉</button>
1462
+ <button type="button" class="ghost-btn" id="remove-env" title="Remove preset" ${canRemoveEnv ? "" : "disabled"}>×</button>
1057
1463
  </div>
1464
+ <div class="env-base-line"><span>baseUrl</span> · ${escapeAttr(activeBase)}</div>
1465
+ ${
1466
+ quickPresets.length
1467
+ ? `<div class="env-quick">${quickPresets
1468
+ .map(
1469
+ (preset) =>
1470
+ `<button type="button" class="btn sm" data-quick-preset="${escapeAttr(preset.id)}" data-base="${escapeAttr(preset.baseUrl)}">+ ${escapeAttr(preset.id)}</button>`,
1471
+ )
1472
+ .join("")}</div>`
1473
+ : ""
1474
+ }
1058
1475
  </div>
1059
1476
  <div class="env-block">
1060
1477
  <div class="env-label">Variables</div>
1061
1478
  ${(env.variables || [])
1062
1479
  .map(
1063
- (row, index) => `<div class="env-kv" data-var="${index}">
1064
- <input class="env-cell" data-field="key" spellcheck="false" value="${escapeAttr(row.key)}" />
1480
+ (row, index) => `<div class="env-kv ${row.key === "baseUrl" ? "base-url" : ""}" data-var="${index}">
1481
+ <input class="env-cell" data-field="key" spellcheck="false" value="${escapeAttr(row.key)}" ${row.key === "baseUrl" ? "readonly" : ""} />
1065
1482
  <input class="env-cell" data-field="value" spellcheck="false" value="${escapeAttr(row.value)}" />
1066
- <button type="button" class="ghost-btn" data-remove-var="${index}">×</button>
1483
+ <button type="button" class="ghost-btn" data-remove-var="${index}" ${row.key === "baseUrl" ? "disabled" : ""}>×</button>
1067
1484
  </div>`,
1068
1485
  )
1069
1486
  .join("")}
@@ -1104,15 +1521,42 @@
1104
1521
  renderMain();
1105
1522
  };
1106
1523
  });
1524
+ document.getElementById("env-pop").querySelectorAll("[data-quick-preset]").forEach((button) => {
1525
+ button.onclick = (event) => {
1526
+ event.stopPropagation();
1527
+ if (!addNamedPreset(button.dataset.quickPreset, button.dataset.base)) return;
1528
+ persistStore();
1529
+ renderEnvPop();
1530
+ renderMain();
1531
+ };
1532
+ });
1107
1533
  document.getElementById("add-env").onclick = (event) => {
1108
1534
  event.stopPropagation();
1109
- let name = "env";
1110
- let n = 1;
1111
- while (store.envs[name + n]) n += 1;
1112
- name = name + n;
1113
- store.envs[name] = cloneDefaultEnv();
1535
+ const typed = window.prompt("Preset name (e.g. staging)", "staging");
1536
+ if (!typed) return;
1537
+ const name = typed.trim().replace(/\s+/g, "-");
1538
+ if (!name) return;
1539
+ if (store.envs[name]) {
1540
+ store.activeEnv = name;
1541
+ } else {
1542
+ const base = window.prompt("baseUrl", configuredPresets[name]?.baseUrl || defaultBaseUrl) || defaultBaseUrl;
1543
+ addNamedPreset(name, base.replace(/\/$/, ""));
1544
+ }
1545
+ persistStore();
1546
+ renderEnvPop();
1547
+ renderMain();
1548
+ };
1549
+ document.getElementById("dup-env").onclick = (event) => {
1550
+ event.stopPropagation();
1551
+ const source = store.activeEnv;
1552
+ let name = source + "-copy";
1553
+ let n = 2;
1554
+ while (store.envs[name]) {
1555
+ name = source + "-copy" + n;
1556
+ n += 1;
1557
+ }
1558
+ store.envs[name] = JSON.parse(JSON.stringify(activeEnvConfig()));
1114
1559
  store.activeEnv = name;
1115
- store.activeGroup = Object.keys(store.envs[name].headerGroups)[0] || "default";
1116
1560
  persistStore();
1117
1561
  renderEnvPop();
1118
1562
  renderMain();
@@ -1271,7 +1715,66 @@
1271
1715
  return "/" + parts.join("/");
1272
1716
  };
1273
1717
 
1274
- const toExportSpec = (source) => {
1718
+ const listOperationExamples = (operation) => {
1719
+ const byKey = new Map();
1720
+ const add = (key, summary) => {
1721
+ if (!key || byKey.has(key)) return;
1722
+ byKey.set(key, { key, summary: summary || key });
1723
+ };
1724
+ const reqExamples = operation?.requestBody?.content?.["application/json"]?.examples;
1725
+ for (const [key, example] of Object.entries(reqExamples || {})) {
1726
+ add(key, example && example.summary);
1727
+ }
1728
+ for (const response of Object.values(operation?.responses || {})) {
1729
+ const examples = response?.content?.["application/json"]?.examples;
1730
+ for (const [key, example] of Object.entries(examples || {})) {
1731
+ add(key, example && example.summary);
1732
+ }
1733
+ }
1734
+ return [...byKey.values()];
1735
+ };
1736
+
1737
+ const filterExamplesMap = (examples, allowedKeys) => {
1738
+ if (!examples || typeof examples !== "object") return examples;
1739
+ if (!allowedKeys) return examples;
1740
+ const out = {};
1741
+ for (const [key, value] of Object.entries(examples)) {
1742
+ if (allowedKeys.has(key)) out[key] = value;
1743
+ }
1744
+ return out;
1745
+ };
1746
+
1747
+ const filterOperationExamples = (operation, allowedKeys) => {
1748
+ if (!allowedKeys) return operation;
1749
+ const next = { ...operation };
1750
+ if (next.requestBody?.content?.["application/json"]?.examples) {
1751
+ const media = { ...next.requestBody.content["application/json"] };
1752
+ media.examples = filterExamplesMap(media.examples, allowedKeys);
1753
+ next.requestBody = {
1754
+ ...next.requestBody,
1755
+ content: { ...next.requestBody.content, "application/json": media },
1756
+ };
1757
+ }
1758
+ if (next.responses) {
1759
+ const responses = {};
1760
+ for (const [status, response] of Object.entries(next.responses)) {
1761
+ if (!response?.content?.["application/json"]?.examples) {
1762
+ responses[status] = response;
1763
+ continue;
1764
+ }
1765
+ const media = { ...response.content["application/json"] };
1766
+ media.examples = filterExamplesMap(media.examples, allowedKeys);
1767
+ responses[status] = {
1768
+ ...response,
1769
+ content: { ...response.content, "application/json": media },
1770
+ };
1771
+ }
1772
+ next.responses = responses;
1773
+ }
1774
+ return next;
1775
+ };
1776
+
1777
+ const toExportSpec = (source, selectedByOpId) => {
1275
1778
  const pathsIn = source.paths || {};
1276
1779
  const pathsOut = {};
1277
1780
  const tagNames = new Set();
@@ -1298,7 +1801,11 @@
1298
1801
  continue;
1299
1802
  }
1300
1803
  const segments = operation["x-tree-segments"] || urlPath.split("/").filter(Boolean);
1301
- const cleaned = stripExt(operation);
1804
+ let cleaned = stripExt(operation);
1805
+ const opId = method + ":" + urlPath;
1806
+ if (selectedByOpId && selectedByOpId.has(opId)) {
1807
+ cleaned = filterOperationExamples(cleaned, selectedByOpId.get(opId));
1808
+ }
1302
1809
  const tagParts = segments.filter((part) => !String(part).startsWith("{"));
1303
1810
  const tag = tagParts.length ? tagParts.join(" / ") : "API";
1304
1811
  cleaned.tags = [tag];
@@ -1322,24 +1829,223 @@
1322
1829
  };
1323
1830
  };
1324
1831
 
1325
- const downloadOpenApi = () => {
1326
- const exported = toExportSpec(spec);
1327
- const blob = new Blob([JSON.stringify(exported, null, 2) + "\n"], { type: "application/json" });
1832
+ const headerRowsForExport = () => {
1833
+ const env = activeEnvConfig();
1834
+ const groups = env.headerGroups || {};
1835
+ return groups[store.activeGroup] || groups[Object.keys(groups)[0]] || [];
1836
+ };
1837
+
1838
+ const applyTryItFill = (exported, fillMode) => {
1839
+ const vars = varMap();
1840
+ const rows = headerRowsForExport();
1841
+ const finalServer =
1842
+ fillMode === "variables" ? "{{baseUrl}}" : String(interpolate(vars.baseUrl || defaultBaseUrl, vars)).replace(/\/$/, "") || defaultBaseUrl;
1843
+
1844
+ exported.servers = [{ url: finalServer }];
1845
+
1846
+ const paths = exported.paths || {};
1847
+ for (const pathItem of Object.values(paths)) {
1848
+ if (!pathItem || typeof pathItem !== "object") continue;
1849
+ for (const method of HTTP_EXPORT) {
1850
+ if (!pathItem[method] || typeof pathItem[method] !== "object") continue;
1851
+ const operation = { ...pathItem[method] };
1852
+ const params = Array.isArray(operation.parameters) ? operation.parameters.map((p) => ({ ...p })) : [];
1853
+
1854
+ for (const row of rows) {
1855
+ if (!row.key) continue;
1856
+ const lower = String(row.key).toLowerCase();
1857
+ if (lower === "host" || lower === "content-length") continue;
1858
+ const exampleValue =
1859
+ fillMode === "resolved"
1860
+ ? String(interpolate(row.value || "", vars))
1861
+ : String(row.value ?? "");
1862
+ const existing = params.findIndex(
1863
+ (param) => param && param.in === "header" && String(param.name).toLowerCase() === lower,
1864
+ );
1865
+ if (existing >= 0) {
1866
+ const prev = params[existing];
1867
+ params[existing] = {
1868
+ ...prev,
1869
+ required: prev.required !== false,
1870
+ example: exampleValue,
1871
+ schema: {
1872
+ ...(prev.schema && typeof prev.schema === "object" ? prev.schema : {}),
1873
+ type: "string",
1874
+ example: exampleValue,
1875
+ },
1876
+ };
1877
+ } else {
1878
+ params.push({
1879
+ name: row.key,
1880
+ in: "header",
1881
+ required: true,
1882
+ schema: { type: "string", example: exampleValue },
1883
+ example: exampleValue,
1884
+ });
1885
+ }
1886
+ }
1887
+
1888
+ operation.parameters = params;
1889
+ pathItem[method] = operation;
1890
+ }
1891
+ }
1892
+
1893
+ return exported;
1894
+ };
1895
+
1896
+ const buildPostmanEnvironment = () => {
1897
+ const env = activeEnvConfig();
1898
+ const values = (env.variables || [])
1899
+ .filter((row) => row.key)
1900
+ .map((row) => ({
1901
+ key: row.key,
1902
+ value: String(row.value ?? ""),
1903
+ type: "default",
1904
+ enabled: true,
1905
+ }));
1906
+ // Ensure header template vars referenced as {{x}} appear even if missing from variables list.
1907
+ const known = new Set(values.map((row) => row.key));
1908
+ for (const row of headerRowsForExport()) {
1909
+ const text = String(row.value || "");
1910
+ const matches = text.matchAll(/\{\{\s*([a-zA-Z0-9_]+)\s*\}\}/g);
1911
+ for (const match of matches) {
1912
+ if (known.has(match[1])) continue;
1913
+ known.add(match[1]);
1914
+ values.push({ key: match[1], value: "", type: "default", enabled: true });
1915
+ }
1916
+ }
1917
+ return {
1918
+ id: typeof crypto !== "undefined" && crypto.randomUUID ? crypto.randomUUID() : String(Date.now()),
1919
+ name: (workspace || title || "DAxTA") + " · " + store.activeEnv,
1920
+ values,
1921
+ _postman_variable_scope: "environment",
1922
+ _postman_exported_at: new Date().toISOString(),
1923
+ _postman_exported_using: "DAxTA",
1924
+ };
1925
+ };
1926
+
1927
+ const closeExportModal = () => {
1928
+ document.body.classList.remove("exporting");
1929
+ };
1930
+
1931
+ const syncExportTryItUi = () => {
1932
+ const meta = document.getElementById("export-tryit-meta");
1933
+ const modeWrap = document.getElementById("export-mode-wrap");
1934
+ const include = document.getElementById("export-include-tryit");
1935
+ if (meta) meta.textContent = store.activeEnv + " · " + store.activeGroup;
1936
+ if (modeWrap) modeWrap.classList.toggle("disabled", !(include && include.checked));
1937
+ };
1938
+
1939
+ const openExportModal = () => {
1940
+ const body = document.getElementById("export-body");
1941
+ const blocks = ops
1942
+ .map((item) => {
1943
+ const examples = listOperationExamples(item.op);
1944
+ if (!examples.length) return "";
1945
+ return `<div class="export-op" data-op="${escapeAttr(item.id)}">
1946
+ <div class="export-op-title">
1947
+ <span class="method ${item.method}">${item.method}</span>
1948
+ <span class="path" title="${escapeAttr(item.path)}">${escapeAttr(item.path)}</span>
1949
+ </div>
1950
+ ${examples
1951
+ .map(
1952
+ (example) => `<div class="export-ex">
1953
+ <input type="checkbox" id="ex-${escapeAttr(item.id)}-${escapeAttr(example.key)}" data-op="${escapeAttr(item.id)}" data-key="${escapeAttr(example.key)}" checked />
1954
+ <label for="ex-${escapeAttr(item.id)}-${escapeAttr(example.key)}">${escapeAttr(example.summary)}</label>
1955
+ </div>`,
1956
+ )
1957
+ .join("")}
1958
+ </div>`;
1959
+ })
1960
+ .filter(Boolean)
1961
+ .join("");
1962
+ body.innerHTML = blocks || `<div class="export-empty">No recorded examples yet — export will include schemas only.</div>`;
1963
+ syncExportTryItUi();
1964
+ document.body.classList.add("exporting");
1965
+ };
1966
+
1967
+ const collectSelectedExamples = () => {
1968
+ const selectedByOpId = new Map();
1969
+ document.querySelectorAll("#export-body input[type=checkbox]").forEach((input) => {
1970
+ const opId = input.dataset.op;
1971
+ const key = input.dataset.key;
1972
+ if (!opId || !key) return;
1973
+ if (!selectedByOpId.has(opId)) selectedByOpId.set(opId, new Set());
1974
+ if (input.checked) selectedByOpId.get(opId).add(key);
1975
+ });
1976
+ return selectedByOpId;
1977
+ };
1978
+
1979
+ const downloadJsonFile = (filename, value) => {
1980
+ const blob = new Blob([JSON.stringify(value, null, 2) + "\n"], { type: "application/json" });
1328
1981
  const url = URL.createObjectURL(blob);
1329
1982
  const link = document.createElement("a");
1330
- const safeName = String(workspace || title || "openapi")
1331
- .toLowerCase()
1332
- .replace(/[^a-z0-9]+/g, "-")
1333
- .replace(/^-|-$/g, "") || "openapi";
1334
1983
  link.href = url;
1335
- link.download = safeName + ".openapi.json";
1984
+ link.download = filename;
1336
1985
  document.body.appendChild(link);
1337
1986
  link.click();
1338
1987
  link.remove();
1339
1988
  URL.revokeObjectURL(url);
1340
1989
  };
1341
1990
 
1342
- document.getElementById("export-openapi").addEventListener("click", downloadOpenApi);
1991
+ const exportSafeName = () =>
1992
+ String(workspace || title || "openapi")
1993
+ .toLowerCase()
1994
+ .replace(/[^a-z0-9]+/g, "-")
1995
+ .replace(/^-|-$/g, "") || "openapi";
1996
+
1997
+ const runExportDownload = () => {
1998
+ const selectedByOpId = collectSelectedExamples();
1999
+ let exported = toExportSpec(spec, selectedByOpId);
2000
+ const includeTryIt = Boolean(document.getElementById("export-include-tryit")?.checked);
2001
+ const fillMode =
2002
+ document.querySelector('input[name="export-fill"]:checked')?.value === "variables" ? "variables" : "resolved";
2003
+ const base = exportSafeName();
2004
+
2005
+ if (includeTryIt) {
2006
+ exported = applyTryItFill(exported, fillMode);
2007
+ }
2008
+
2009
+ downloadJsonFile(base + ".openapi.json", exported);
2010
+
2011
+ if (includeTryIt && fillMode === "variables") {
2012
+ setTimeout(() => {
2013
+ downloadJsonFile(base + ".postman_environment.json", buildPostmanEnvironment());
2014
+ }, 150);
2015
+ }
2016
+ };
2017
+
2018
+ document.getElementById("export-openapi").addEventListener("click", (event) => {
2019
+ event.stopPropagation();
2020
+ openExportModal();
2021
+ });
2022
+ document.getElementById("export-cancel").addEventListener("click", closeExportModal);
2023
+ document.getElementById("export-backdrop").addEventListener("click", (event) => {
2024
+ if (event.target.id === "export-backdrop") closeExportModal();
2025
+ });
2026
+ document.getElementById("export-modal").addEventListener("click", (event) => event.stopPropagation());
2027
+ document.getElementById("export-include-tryit").addEventListener("change", syncExportTryItUi);
2028
+ document.getElementById("export-all").addEventListener("click", () => {
2029
+ document.querySelectorAll("#export-body input[type=checkbox]").forEach((input) => {
2030
+ input.checked = true;
2031
+ });
2032
+ });
2033
+ document.getElementById("export-none").addEventListener("click", () => {
2034
+ document.querySelectorAll("#export-body input[type=checkbox]").forEach((input) => {
2035
+ input.checked = false;
2036
+ });
2037
+ });
2038
+ document.getElementById("export-success").addEventListener("click", () => {
2039
+ document.querySelectorAll("#export-body input[type=checkbox]").forEach((input) => {
2040
+ const label = document.querySelector(`label[for="${CSS.escape(input.id)}"]`);
2041
+ const text = label ? label.textContent || "" : "";
2042
+ input.checked = /^2\d\d\b/.test(text.trim());
2043
+ });
2044
+ });
2045
+ document.getElementById("export-confirm").addEventListener("click", () => {
2046
+ runExportDownload();
2047
+ closeExportModal();
2048
+ });
1343
2049
 
1344
2050
  const HTTP = ["get", "post", "put", "patch", "delete"];
1345
2051
  const STATUS = { 200: "OK", 201: "Created", 204: "No Content", 400: "Bad Request", 401: "Unauthorized", 404: "Not Found", 409: "Conflict", 422: "Unprocessable Entity" };
@@ -1523,6 +2229,13 @@
1523
2229
  const expandedFolders = new Set(
1524
2230
  [...new Set(ops.map((item) => treePathSegments(item)[0]).filter(Boolean))].map((version) => "/" + version),
1525
2231
  );
2232
+ const expandedExampleOps = new Set();
2233
+
2234
+ const scenarioNavLabel = (scenario) => {
2235
+ const status = scenario.status != null ? String(scenario.status) : "";
2236
+ const name = scenario.name || "example";
2237
+ return status ? status + " — " + name : name;
2238
+ };
1526
2239
 
1527
2240
  const kv = (label, value) => {
1528
2241
  if (value === undefined || value === "") return "";
@@ -1574,13 +2287,30 @@
1574
2287
  const renderTreeNode = (node, prefix = "", q = "") => {
1575
2288
  const opsHtml = [...node.ops]
1576
2289
  .sort((left, right) => (METHOD_ORDER[left.method] ?? 99) - (METHOD_ORDER[right.method] ?? 99))
1577
- .map(
1578
- (item) =>
1579
- `<button class="nav-item ${item.id === currentId ? "active" : ""}" data-id="${item.id}" title="${item.path}">
1580
- <span class="method ${item.method}">${item.method}</span>
1581
- <span class="nav-title">${item.title}</span>
1582
- </button>`,
1583
- )
2290
+ .map((item) => {
2291
+ const hasExamples = Array.isArray(item.scenarios) && item.scenarios.length > 0;
2292
+ const examplesOpen = expandedExampleOps.has(item.id);
2293
+ const examplesHtml = hasExamples
2294
+ ? `<div class="nav-examples">${item.scenarios
2295
+ .map(
2296
+ (scenario, index) =>
2297
+ `<button type="button" class="nav-example ${item.id === currentId && index === scenarioIndex ? "on" : ""}" data-id="${escapeAttr(item.id)}" data-scenario="${index}" title="${escapeAttr(scenarioNavLabel(scenario))}">${escapeAttr(scenarioNavLabel(scenario))}</button>`,
2298
+ )
2299
+ .join("")}</div>`
2300
+ : "";
2301
+ return `<div class="nav-op ${item.id === currentId ? "active" : ""} ${examplesOpen ? "examples-open" : ""}" data-op-id="${escapeAttr(item.id)}">
2302
+ <div class="nav-op-row">
2303
+ <button type="button" class="nav-item" data-id="${escapeAttr(item.id)}" title="${escapeAttr(item.path)}">
2304
+ <span class="method ${item.method}">${item.method}</span>
2305
+ <span class="nav-title">${escapeAttr(item.title)}</span>
2306
+ </button>
2307
+ <button type="button" class="nav-expand" data-expand-id="${escapeAttr(item.id)}" title="Examples" aria-label="Toggle examples" aria-expanded="${examplesOpen ? "true" : "false"}" ${hasExamples ? "" : "disabled"}>
2308
+ <span class="chev"></span>
2309
+ </button>
2310
+ </div>
2311
+ ${examplesHtml}
2312
+ </div>`;
2313
+ })
1584
2314
  .join("");
1585
2315
 
1586
2316
  const foldersHtml = Object.entries(node.children)
@@ -1617,6 +2347,29 @@
1617
2347
  nav.querySelectorAll(".nav-item").forEach((button) => {
1618
2348
  button.onclick = () => select(button.dataset.id);
1619
2349
  });
2350
+ nav.querySelectorAll(".nav-expand").forEach((button) => {
2351
+ button.onclick = (event) => {
2352
+ event.stopPropagation();
2353
+ if (button.disabled) return;
2354
+ const opId = button.dataset.expandId;
2355
+ if (expandedExampleOps.has(opId)) expandedExampleOps.delete(opId);
2356
+ else expandedExampleOps.add(opId);
2357
+ const wrap = button.closest(".nav-op");
2358
+ if (wrap) {
2359
+ wrap.classList.toggle("examples-open", expandedExampleOps.has(opId));
2360
+ button.setAttribute("aria-expanded", expandedExampleOps.has(opId) ? "true" : "false");
2361
+ }
2362
+ };
2363
+ });
2364
+ nav.querySelectorAll(".nav-example").forEach((button) => {
2365
+ button.onclick = (event) => {
2366
+ event.stopPropagation();
2367
+ const opId = button.dataset.id;
2368
+ const index = Number(button.dataset.scenario);
2369
+ expandedExampleOps.add(opId);
2370
+ select(opId, Number.isFinite(index) ? index : 0);
2371
+ };
2372
+ });
1620
2373
  nav.querySelectorAll(".tree-folder-toggle").forEach((button) => {
1621
2374
  button.onclick = (event) => {
1622
2375
  event.stopPropagation();
@@ -1849,6 +2602,8 @@
1849
2602
  scenarioIndex = Number(button.dataset.index);
1850
2603
  liveResult = null;
1851
2604
  root.classList.remove("open");
2605
+ expandedExampleOps.add(item.id);
2606
+ renderNav();
1852
2607
  renderMain();
1853
2608
  };
1854
2609
  });
@@ -1902,9 +2657,9 @@
1902
2657
  }
1903
2658
  };
1904
2659
 
1905
- const select = (id) => {
2660
+ const select = (id, nextScenarioIndex) => {
1906
2661
  currentId = id;
1907
- scenarioIndex = 0;
2662
+ scenarioIndex = typeof nextScenarioIndex === "number" ? nextScenarioIndex : 0;
1908
2663
  liveResult = null;
1909
2664
  const selected = ops.find((entry) => entry.id === id);
1910
2665
  if (selected) syncHeaderGroupForOp(selected.op);
@@ -1957,6 +2712,15 @@
1957
2712
 
1958
2713
  const initial = decodeURIComponent(location.hash.replace(/^#/, "")) || ops[0]?.id;
1959
2714
  select(ops.some((item) => item.id === initial) ? initial : ops[0]?.id);
2715
+
2716
+ hydrateStoreFromServer().then((loaded) => {
2717
+ if (!loaded) return;
2718
+ const selected = ops.find((entry) => entry.id === currentId);
2719
+ if (selected) syncHeaderGroupForOp(selected.op);
2720
+ syncEnvTrigger();
2721
+ if (document.getElementById("env-wrap")?.classList.contains("open")) renderEnvPop();
2722
+ renderMain();
2723
+ });
1960
2724
  </script>
1961
2725
  </body>
1962
2726
  </html>