@parhelia/localization 0.4.13170 → 0.4.13193

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/LICENSE +1 -1
  2. package/dist/LocalizeItemCommand.d.ts.map +1 -1
  3. package/dist/LocalizeItemCommand.js +1 -0
  4. package/dist/LocalizeItemDialog.d.ts.map +1 -1
  5. package/dist/LocalizeItemDialog.js +9 -3
  6. package/dist/LocalizeItemUtils.d.ts +1 -0
  7. package/dist/LocalizeItemUtils.d.ts.map +1 -1
  8. package/dist/LocalizeItemUtils.js +45 -24
  9. package/dist/api/discovery.d.ts +17 -3
  10. package/dist/api/discovery.d.ts.map +1 -1
  11. package/dist/api/discovery.js +35 -14
  12. package/dist/hooks/useTranslationWizard.d.ts.map +1 -1
  13. package/dist/hooks/useTranslationWizard.js +10 -2
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +6 -4
  16. package/dist/services/translationService.d.ts +44 -27
  17. package/dist/services/translationService.d.ts.map +1 -1
  18. package/dist/services/translationService.js +38 -32
  19. package/dist/services/translationSettingsService.d.ts +79 -0
  20. package/dist/services/translationSettingsService.d.ts.map +1 -0
  21. package/dist/services/translationSettingsService.js +68 -0
  22. package/dist/settings/ExcludedContentTypeDialog.d.ts +12 -0
  23. package/dist/settings/ExcludedContentTypeDialog.d.ts.map +1 -0
  24. package/dist/settings/ExcludedContentTypeDialog.js +29 -0
  25. package/dist/settings/TranslationProviderDialog.d.ts +18 -0
  26. package/dist/settings/TranslationProviderDialog.d.ts.map +1 -0
  27. package/dist/settings/TranslationProviderDialog.js +105 -0
  28. package/dist/settings/TranslationServicesPanel.d.ts +14 -4
  29. package/dist/settings/TranslationServicesPanel.d.ts.map +1 -1
  30. package/dist/settings/TranslationServicesPanel.js +186 -263
  31. package/dist/setup/LocalizationSetupStep.d.ts.map +1 -1
  32. package/dist/setup/LocalizationSetupStep.js +14 -33
  33. package/dist/sidebar/TranslationSidebar.d.ts.map +1 -1
  34. package/dist/sidebar/TranslationSidebar.js +35 -14
  35. package/dist/steps/ItemSelectionTree.d.ts +2 -2
  36. package/dist/steps/ItemSelectionTree.d.ts.map +1 -1
  37. package/dist/steps/ItemSelectionTree.js +132 -47
  38. package/dist/steps/ProviderStep.d.ts.map +1 -1
  39. package/dist/steps/ProviderStep.js +55 -42
  40. package/dist/steps/ServiceLanguageSelectionStep.d.ts +1 -1
  41. package/dist/steps/ServiceLanguageSelectionStep.d.ts.map +1 -1
  42. package/dist/steps/ServiceLanguageSelectionStep.js +127 -176
  43. package/dist/steps/types.d.ts +3 -3
  44. package/dist/steps/types.d.ts.map +1 -1
  45. package/dist/translation-center/TranslationBatches.d.ts +37 -0
  46. package/dist/translation-center/TranslationBatches.d.ts.map +1 -1
  47. package/dist/translation-center/TranslationBatches.js +255 -113
  48. package/dist/types.d.ts +1 -0
  49. package/dist/types.d.ts.map +1 -1
  50. package/package.json +14 -15
@@ -1,11 +1,11 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useCallback, useEffect, useRef, useState, useMemo, useSyncExternalStore, } from "react";
3
3
  import React from "react";
4
- import { Button, Badge, Select, Input, UserPicker, Popover, PopoverContent, PopoverTrigger, Tooltip, TooltipContent, TooltipTrigger, ContentTree, ContentInspectorPopover, PageHeader, fetchItemStubs, searchUsers as searchBackendUsers, useEditContext, getLanguages, SimpleIconButton, WorkspaceHomeView, capitalizeFirstLetter, formatDateTime, } from "@parhelia/core";
5
- import { listBatches, getTranslationProviders, getTranslationJobLastPayload, listBatchTranslationJobs, retryBatchTranslation, abortJob, abortBatch, subscribeToBatch, unsubscribeFromBatch, } from "../services/translationService";
4
+ import { Button, Badge, ContentStoreSelect, CreateButton, DeleteButton, Select, Input, UserPicker, Popover, PopoverContent, PopoverTrigger, Tooltip, TooltipContent, TooltipTrigger, ContentTree, ContentInspectorPopover, PageHeader, fetchItemStubs, searchUsers as searchBackendUsers, useEditContext, useContentModel, getLanguages, SimpleIconButton, WorkspaceHomeView, capitalizeFirstLetter, formatDateTime, LanguageIcon, } from "@parhelia/core";
5
+ import { listBatches, getTranslationProviders, getTranslationJobLastPayload, listBatchTranslationJobs, retryBatchTranslation, abortJob, abortBatch, deleteBatch, subscribeToBatch, unsubscribeFromBatch, translationItemKey, } from "../services/translationService";
6
6
  import { TRANSLATION_BATCH_STARTED_EVENT, } from "../translationEvents";
7
7
  import { useDebouncedCallback } from "use-debounce";
8
- import { X, ChevronDown, Languages, Loader2, Globe, FolderTree, ExternalLink, Check, AlertCircle, CircleStop, Hourglass, Copy, Sparkles, RotateCcw, Plus, Bug, } from "lucide-react";
8
+ import { X, ChevronDown, Languages, Loader2, FolderTree, ExternalLink, Check, AlertCircle, CircleStop, Hourglass, Copy, Sparkles, RotateCcw, Bug, } from "lucide-react";
9
9
  import { toast } from "sonner";
10
10
  import { openLocalizeItemDialog } from "../LocalizeItemCommand";
11
11
  // Wrappers for lucide-react icons to work with React 19
@@ -13,7 +13,6 @@ const XIcon = (props) => React.createElement(X, props);
13
13
  const ChevronDownIcon = (props) => React.createElement(ChevronDown, props);
14
14
  const LanguagesIcon = (props) => React.createElement(Languages, props);
15
15
  const LoaderIcon = (props) => React.createElement(Loader2, props);
16
- const GlobeIcon = (props) => React.createElement(Globe, props);
17
16
  const FolderTreeIcon = (props) => React.createElement(FolderTree, props);
18
17
  const ExternalLinkIcon = (props) => React.createElement(ExternalLink, props);
19
18
  const CheckIcon = (props) => React.createElement(Check, props);
@@ -23,28 +22,55 @@ const QueuedIcon = (props) => React.createElement(Hourglass, props);
23
22
  const CopyIcon = (props) => React.createElement(Copy, props);
24
23
  const SparklesIcon = (props) => React.createElement(Sparkles, props);
25
24
  const RetryIcon = (props) => React.createElement(RotateCcw, props);
26
- const PlusIcon = (props) => React.createElement(Plus, props);
27
25
  const BugIcon = (props) => React.createElement(Bug, props);
28
- function renderTargetLanguageIcon(language) {
29
- if (language.icon) {
30
- return React.createElement("img", {
31
- src: language.icon,
32
- className: "h-4 w-5 object-cover",
33
- alt: "",
34
- "aria-hidden": true,
35
- });
36
- }
37
- return React.createElement(GlobeIcon, {
38
- className: "h-3.5 w-3.5 text-neutral-grey-50",
39
- strokeWidth: 1,
40
- "aria-hidden": true,
26
+ function renderLanguageIcon(language) {
27
+ return React.createElement(LanguageIcon, {
28
+ language,
29
+ flagClassName: "h-[15px] w-5 shrink-0",
30
+ globeClassName: "h-3.5 w-3.5 text-neutral-grey-50",
41
31
  });
42
32
  }
33
+ // Batches span stores and the panel is used with no item open, so the languages come from every store, not the open one.
34
+ function useContentStoreLanguages() {
35
+ const model = useContentModel();
36
+ const storeIds = useMemo(() => (model?.stores ?? []).map((store) => store.id).join("\n"), [model?.stores]);
37
+ const [languages, setLanguages] = useState([]);
38
+ useEffect(() => {
39
+ let cancelled = false;
40
+ const ids = storeIds ? storeIds.split("\n") : [];
41
+ void Promise.all(ids.map(async (storeId) => {
42
+ try {
43
+ const res = await getLanguages(storeId);
44
+ const langs = res?.data ?? res;
45
+ return Array.isArray(langs) ? langs : [];
46
+ }
47
+ catch (error) {
48
+ console.error(`Failed to load languages of ${storeId}:`, error);
49
+ return [];
50
+ }
51
+ })).then((perStore) => {
52
+ if (cancelled)
53
+ return;
54
+ const byCode = new Map();
55
+ for (const language of perStore.flat()) {
56
+ const code = language.languageCode || language.name;
57
+ if (code && !byCode.has(code))
58
+ byCode.set(code, { ...language, languageCode: code });
59
+ }
60
+ setLanguages(Array.from(byCode.values()).sort((a, b) => a.languageCode.localeCompare(b.languageCode)));
61
+ });
62
+ return () => {
63
+ cancelled = true;
64
+ };
65
+ }, [storeIds]);
66
+ return languages;
67
+ }
43
68
  const DEFAULT_FILTERS = {
44
69
  dateRange: "last30days",
45
70
  status: "all",
46
71
  user: "all",
47
72
  provider: "all",
73
+ sourceLanguage: "all",
48
74
  targetLanguage: "all",
49
75
  itemIdOrPath: "",
50
76
  itemIncludeSubitems: false,
@@ -119,13 +145,40 @@ function isTerminalBatchStatus(status) {
119
145
  function isActiveBatchStatus(status) {
120
146
  return status === "Pending" || status === "In Progress";
121
147
  }
148
+ /**
149
+ * Whether the signed-in person may delete this batch: it has stopped (a running
150
+ * batch is aborted first), and they started it or are an administrator. The
151
+ * server checks the same; this only hides the action where it would be refused.
152
+ */
153
+ export function canDeleteTranslationBatch(info, user) {
154
+ if (!info || !user || !isTerminalBatchStatus(info.status))
155
+ return false;
156
+ if (user.isAdministrator)
157
+ return true;
158
+ // The initiator is the account whose id the batch stores, as on the server.
159
+ const initiator = info.initiatedBySubjectId?.trim().toLowerCase();
160
+ return !!initiator && initiator === user.subjectId?.trim().toLowerCase();
161
+ }
122
162
  function isRetriableJob(job) {
123
- return job?.status === "Error";
163
+ return job?.status === "Error" && !!job.store;
164
+ }
165
+ export function batchSourceLanguage(metadata, jobs) {
166
+ let fromMetadata;
167
+ try {
168
+ fromMetadata = metadata ? JSON.parse(metadata).sourceLanguage : undefined;
169
+ }
170
+ catch {
171
+ fromMetadata = undefined;
172
+ }
173
+ return typeof fromMetadata === "string" && fromMetadata.trim()
174
+ ? fromMetadata.trim()
175
+ : jobs?.find((job) => job.sourceLanguage)?.sourceLanguage;
124
176
  }
125
177
  function buildRetryJobRequest(job) {
126
- if (!job.itemId || !job.sourceLanguage || !job.targetLanguage)
178
+ if (!job.store || !job.itemId || !job.sourceLanguage || !job.targetLanguage)
127
179
  return null;
128
180
  return {
181
+ store: job.store,
129
182
  sourceTranslationId: job.id,
130
183
  itemId: job.itemId,
131
184
  sourceLanguage: job.sourceLanguage,
@@ -240,7 +293,7 @@ export function TranslationBatches() {
240
293
  const editContext = useEditContext();
241
294
  const [emptyStateSlogan] = useState(() => EMPTY_STATE_SLOGANS[Math.floor(Math.random() * EMPTY_STATE_SLOGANS.length)]);
242
295
  const [batches, setBatches] = useState([]);
243
- const [sitecoreLanguages, setSitecoreLanguages] = useState([]);
296
+ const contentLanguages = useContentStoreLanguages();
244
297
  const [isLoading, setIsLoading] = useState(false);
245
298
  // False until the first list response lands. Later reloads (the user filter
246
299
  // defaulting in, socket refreshes, the reconciliation poll) update in place
@@ -256,6 +309,7 @@ export function TranslationBatches() {
256
309
  const [loadingJobs, setLoadingJobs] = useState(new Set());
257
310
  const [abortingBatchIds, setAbortingBatchIds] = useState(new Set());
258
311
  const [abortingJobIds, setAbortingJobIds] = useState(new Set());
312
+ const [deletingBatchIds, setDeletingBatchIds] = useState(new Set());
259
313
  const [retryingKeys, setRetryingKeys] = useState(new Set());
260
314
  // Cache of userName → displayName so we can render full names on batch rows
261
315
  // without re-querying the user service every render.
@@ -278,6 +332,7 @@ export function TranslationBatches() {
278
332
  filters.status !== "all" ||
279
333
  filters.user !== currentUserName ||
280
334
  filters.provider !== "all" ||
335
+ filters.sourceLanguage !== "all" ||
281
336
  filters.targetLanguage !== "all" ||
282
337
  filters.itemIdOrPath.trim() !== "" ||
283
338
  filters.itemIncludeSubitems;
@@ -332,14 +387,21 @@ export function TranslationBatches() {
332
387
  : STATUS_FILTER_TO_DB[filters.status],
333
388
  user: userFilter === "all" ? undefined : userFilter,
334
389
  provider: filters.provider === "all" ? undefined : filters.provider,
390
+ sourceLanguage: filters.sourceLanguage === "all" ? undefined : filters.sourceLanguage,
335
391
  targetLanguage: filters.targetLanguage === "all" ? undefined : filters.targetLanguage,
336
392
  itemIdOrPath: trimmedItem ? trimmedItem : undefined,
393
+ store: filters.store,
394
+ language: filters.language,
337
395
  itemIncludeSubitems: trimmedItem && filters.itemIncludeSubitems ? true : undefined,
338
396
  };
339
397
  }, [filters, userFilterLocked, currentUserName]);
340
- const loadRecentBatches = useCallback(async (offset, append, filtersToUse) => {
398
+ const loadRecentBatches = useCallback(async (offset, append, filtersToUse, background = false) => {
341
399
  const myRequestId = ++requestIdRef.current;
342
- if (offset === 0) {
400
+ if (background) {
401
+ // Background reconciliation must not replace the list with a loading
402
+ // state; websocket events remain the fast path.
403
+ }
404
+ else if (offset === 0) {
343
405
  setIsLoading(true);
344
406
  }
345
407
  else {
@@ -380,7 +442,7 @@ export function TranslationBatches() {
380
442
  console.error("Failed to load batches:", error);
381
443
  }
382
444
  finally {
383
- if (myRequestId === requestIdRef.current) {
445
+ if (!background && myRequestId === requestIdRef.current) {
384
446
  setIsLoading(false);
385
447
  setIsLoadingMore(false);
386
448
  setHasLoadedOnce(true);
@@ -393,24 +455,29 @@ export function TranslationBatches() {
393
455
  loadRecentBatches(currentOffset, true, effectiveFilters);
394
456
  }
395
457
  };
396
- // Load Sitecore languages for language chips in expanded batches.
397
- useEffect(() => {
398
- const loadLanguages = async () => {
399
- try {
400
- const res = await getLanguages();
401
- const langs = (res?.data ?? res ?? []);
402
- setSitecoreLanguages(Array.isArray(langs) ? langs : []);
403
- }
404
- catch (error) {
405
- console.error("Failed to load Sitecore languages:", error);
406
- }
407
- };
408
- loadLanguages();
409
- }, []);
410
458
  // Reload when filters change (resets pagination)
411
459
  useEffect(() => {
412
460
  loadRecentBatches(0, false, effectiveFilters);
413
461
  }, [loadRecentBatches, effectiveFilters]);
462
+ // Socket delivery is best-effort across reconnects and host restarts. Keep
463
+ // the visible list eventually consistent with a quiet REST reconciliation.
464
+ useEffect(() => {
465
+ let inFlight = false;
466
+ const reconcile = () => {
467
+ if (document.visibilityState === "hidden" || inFlight)
468
+ return;
469
+ inFlight = true;
470
+ void loadRecentBatches(0, false, effectiveFilters, true).finally(() => {
471
+ inFlight = false;
472
+ });
473
+ };
474
+ const interval = window.setInterval(reconcile, 3000);
475
+ document.addEventListener("visibilitychange", reconcile);
476
+ return () => {
477
+ window.clearInterval(interval);
478
+ document.removeEventListener("visibilitychange", reconcile);
479
+ };
480
+ }, [effectiveFilters, loadRecentBatches]);
414
481
  // Seed the cache with the current user's full name so rows authored by us
415
482
  // resolve immediately, without waiting on a searchUsers round-trip.
416
483
  useEffect(() => {
@@ -461,6 +528,24 @@ export function TranslationBatches() {
461
528
  cancelled = true;
462
529
  };
463
530
  }, [batches, userDisplayNames]);
531
+ // A deleted batch leaves the list, its held jobs and the expansion at once;
532
+ // the next list read would drop it as well.
533
+ const removeBatch = useCallback((batchId) => {
534
+ const id = normalizeGuid(batchId);
535
+ setBatches((prev) => {
536
+ const next = prev.filter((b) => normalizeGuid(b.id) !== id);
537
+ return next.length === prev.length ? prev : next;
538
+ });
539
+ setBatchJobs((prev) => {
540
+ const key = Object.keys(prev).find((k) => normalizeGuid(k) === id);
541
+ if (key === undefined)
542
+ return prev;
543
+ const next = { ...prev };
544
+ delete next[key];
545
+ return next;
546
+ });
547
+ setExpandedBatchId((prev) => prev && normalizeGuid(prev) === id ? null : prev);
548
+ }, []);
464
549
  // Keep refs to the latest reload + expansion state so the socket listener
465
550
  // can be registered once and survive editContext identity changes.
466
551
  // Without this, a context recreation (triggered e.g. by EditorShell's
@@ -489,6 +574,7 @@ export function TranslationBatches() {
489
574
  // Live progress: patch the matching job's message in-place so an open
490
575
  // popover reflects the latest progress text without a REST reload.
491
576
  if (message.type === "translation-progress" && batchIdFromPayload) {
577
+ const storeFromPayload = message?.payload?.store ?? message?.payload?.Store;
492
578
  const itemIdFromPayload = normalizeGuid(message?.payload?.itemId ?? message?.payload?.ItemId);
493
579
  const languageFromPayload = (message?.payload?.language ??
494
580
  message?.payload?.Language ??
@@ -503,7 +589,9 @@ export function TranslationBatches() {
503
589
  return prev;
504
590
  let changed = false;
505
591
  const nextJobs = jobs.map((job) => {
506
- if (normalizeGuid(job.itemId) === itemIdFromPayload &&
592
+ if (storeFromPayload &&
593
+ job.store === storeFromPayload &&
594
+ normalizeGuid(job.itemId) === itemIdFromPayload &&
507
595
  job.targetLanguage === languageFromPayload &&
508
596
  // A late progress text must not replace a terminal
509
597
  // outcome (an error text, or the final record).
@@ -536,6 +624,10 @@ export function TranslationBatches() {
536
624
  applyBatchRow(message.payload);
537
625
  return;
538
626
  }
627
+ if (message.type === "batch-deleted" && batchIdFromPayload) {
628
+ removeBatch(batchIdFromPayload);
629
+ return;
630
+ }
539
631
  if ((message.type === "translation-started" ||
540
632
  message.type === "translation-finished" ||
541
633
  message.type === "translation-error" ||
@@ -578,7 +670,7 @@ export function TranslationBatches() {
578
670
  // debounce expiry, and cancelling on re-subscription would drop the
579
671
  // refresh that brings the UI to its final state.
580
672
  };
581
- }, [editContext]);
673
+ }, [editContext, removeBatch]);
582
674
  // Websocket events are the fast path, but a short disconnect or a batch that
583
675
  // completes before the editor transport finishes reconnecting must not leave
584
676
  // this management view permanently stale. Reconcile while the panel is
@@ -788,6 +880,35 @@ export function TranslationBatches() {
788
880
  loadBatchJobs,
789
881
  loadRecentBatches,
790
882
  ]);
883
+ const handleDeleteBatch = useCallback((batchId, batchName) => {
884
+ editContext?.confirm({
885
+ header: "Delete Translation Batch",
886
+ message: `Delete "${batchName}" and its translation jobs? The batch disappears from Translation Management for everyone. Content that was already translated stays as it is.`,
887
+ acceptLabel: "Delete",
888
+ showCancel: true,
889
+ accept: async () => {
890
+ setDeletingBatchIds((prev) => new Set(prev).add(batchId));
891
+ try {
892
+ const result = await deleteBatch(batchId);
893
+ if (result.type !== "success") {
894
+ toast.error(result.details ||
895
+ result.summary ||
896
+ "Failed to delete translation batch.");
897
+ return;
898
+ }
899
+ removeBatch(batchId);
900
+ toast.success("Translation batch deleted.");
901
+ }
902
+ finally {
903
+ setDeletingBatchIds((prev) => {
904
+ const next = new Set(prev);
905
+ next.delete(batchId);
906
+ return next;
907
+ });
908
+ }
909
+ },
910
+ });
911
+ }, [editContext, removeBatch]);
791
912
  const handleAbortJob = useCallback((job) => {
792
913
  if (!job.id || !job.batchId) {
793
914
  toast.error("This translation job cannot be aborted.");
@@ -903,10 +1024,16 @@ export function TranslationBatches() {
903
1024
  const jobs = batchJobs[batchId] ?? (await loadBatchJobs(batchId));
904
1025
  await handleRetryJobs(batchId, batch.provider, jobs, `batch:${batchId}`);
905
1026
  }, [batchJobs, handleRetryJobs, loadBatchJobs]);
906
- const openItemInEditor = useCallback(async (itemId, language) => {
907
- const normalized = (itemId ?? "").toString().toLowerCase();
1027
+ const openItemInEditor = useCallback(async (itemId, language, store) => {
1028
+ if (!store || !language)
1029
+ return;
908
1030
  editContext?.setShowAgentsWorkspaceEditor(true);
909
- await editContext?.loadItem(language ? { id: normalized, language, version: 0 } : normalized);
1031
+ await editContext?.loadItem({
1032
+ id: itemId,
1033
+ language,
1034
+ version: 0,
1035
+ database: store,
1036
+ });
910
1037
  }, [editContext]);
911
1038
  // The blank-slate home view (no header, grey full-height greeting) also
912
1039
  // covers the initial load, so the greeting mounts exactly once.
@@ -931,6 +1058,7 @@ export function TranslationBatches() {
931
1058
  const languages = languagesCsv
932
1059
  ? languagesCsv.split(",")
933
1060
  : [];
1061
+ const sourceLanguage = batchSourceLanguage(info?.metadata, batchJobs[b.id]);
934
1062
  const errorJobs = info?.errorJobs ?? 0;
935
1063
  const anyError = errorJobs > 0;
936
1064
  const anyInProgress = isActiveBatchStatus(info?.status);
@@ -946,7 +1074,7 @@ export function TranslationBatches() {
946
1074
  metaParts.push(_jsxs("span", { children: [itemsCount, " item", itemsCount !== 1 ? "s" : ""] }, "items"));
947
1075
  }
948
1076
  if (languages.length > 0) {
949
- metaParts.push(_jsxs("span", { title: languages.join(", "), children: [languages.length, " language", languages.length !== 1 ? "s" : ""] }, "langs"));
1077
+ metaParts.push(_jsxs("span", { title: languages.join(", "), children: [sourceLanguage && (_jsxs("span", { className: "font-mono tracking-tight", "data-testid": "batch-source-language", children: [sourceLanguage, " → "] })), languages.length, " language", languages.length !== 1 ? "s" : ""] }, "langs"));
950
1078
  }
951
1079
  if (info?.provider) {
952
1080
  metaParts.push(_jsx("span", { children: info.provider }, "prov"));
@@ -997,7 +1125,9 @@ export function TranslationBatches() {
997
1125
  const canAbort = isActiveBatchStatus(info?.status);
998
1126
  const isRetryingBatch = retryingKeys.has(`batch:${b.id}`);
999
1127
  const isAborting = abortingBatchIds.has(b.id);
1000
- const hasBatchActions = canRetry || canAbort;
1128
+ const canDelete = canDeleteTranslationBatch(info, editContext?.user);
1129
+ const isDeleting = deletingBatchIds.has(b.id);
1130
+ const hasBatchActions = canRetry || canAbort || canDelete;
1001
1131
  // Stable test-id status used by Playwright assertions.
1002
1132
  // Matches the visual status dot/spinner logic above.
1003
1133
  const testStatus = anyError
@@ -1020,7 +1150,10 @@ export function TranslationBatches() {
1020
1150
  if (!canAbort)
1021
1151
  return;
1022
1152
  handleAbortBatch(b.id);
1023
- }, icon: isAborting ? (_jsx(LoaderIcon, { className: "h-3.5 w-3.5 animate-spin", strokeWidth: 1 })) : (_jsx(AbortIcon, { className: "h-3.5 w-3.5", strokeWidth: 1 })), label: "Abort translation batch", disabled: !canAbort || isAborting }))] }));
1153
+ }, icon: isAborting ? (_jsx(LoaderIcon, { className: "h-3.5 w-3.5 animate-spin", strokeWidth: 1 })) : (_jsx(AbortIcon, { className: "h-3.5 w-3.5", strokeWidth: 1 })), label: "Abort translation batch", disabled: !canAbort || isAborting })), canDelete && (_jsx(DeleteButton, { size: "xs", iconSize: "md", className: "h-6 w-6", label: "Delete translation batch", "data-testid": `batch-delete-${b.id}`, onClick: (event) => {
1154
+ event.stopPropagation();
1155
+ handleDeleteBatch(b.id, batchDisplayName);
1156
+ }, onKeyDown: (event) => event.stopPropagation(), disabled: isDeleting || isRetryingBatch }))] }));
1024
1157
  return (_jsxs("div", { "data-testid": `batch-row-${b.id}`, "data-batch-status": testStatus, children: [_jsx("div", { role: "button", tabIndex: 0, className: `group w-full cursor-pointer py-3 text-left transition-colors hover:bg-neutral-grey-5 ${isCompactBatches ? "px-2.5" : "px-4"}`, onClick: () => toggleBatch(b.id), onKeyDown: (e) => {
1025
1158
  if (e.key === "Enter" || e.key === " ") {
1026
1159
  e.preventDefault();
@@ -1032,15 +1165,26 @@ export function TranslationBatches() {
1032
1165
  ? "whitespace-normal break-words leading-5"
1033
1166
  : "truncate"}`, style: isCompactBatches
1034
1167
  ? { overflowWrap: "anywhere" }
1035
- : undefined, title: formattedBatchDate, children: batchDisplayName }), _jsx("div", { className: "mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[12px] text-neutral-grey-50", children: desktopMetaParts.map((part, i) => (_jsxs(React.Fragment, { children: [i > 0 && (_jsx("span", { className: "text-neutral-grey-15", children: "\u00B7" })), part] }, i))) }), mobileFooterMetaParts.length > 0 && (_jsx("div", { className: "mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[12px] text-neutral-grey-50", children: mobileFooterMetaParts.map((part, i) => (_jsxs(React.Fragment, { children: [i > 0 && (_jsx("span", { className: "text-neutral-grey-15", children: "\u00B7" })), part] }, `footer-${i}`))) }))] }), isCompactBatches && (_jsxs("div", { className: "mt-2 flex min-w-0 items-center gap-2", children: [totalJobs > 0 && (_jsx("div", { className: "min-w-0 flex-1", children: _jsx(BatchProgressIndicator, { counts: statusCounts, status: info?.status, testId: `batch-progress-${b.id}`, variant: "bar" }) })), hasBatchActions && (_jsx("div", { className: "flex shrink-0 items-center gap-1.5", children: batchActions }))] })), !isCompactBatches && hasBatchActions && (_jsx("div", { className: "flex shrink-0 items-center gap-2 self-center", children: batchActions }))] })] }) }), isExpanded && (_jsxs("div", { className: "border-t border-border-default/50", children: [_jsx(CustomPromptPanel, { prompts: parseCustomPrompts(info?.metadata) }), _jsx(BatchItemList, { batchId: b.id, batchProvider: info?.provider, jobs: jobs, isLoading: isLoadingThis, expandedItems: expandedItems, languages: sitecoreLanguages, currentLanguage: editContext?.item?.language, itemFilter: filters.itemIdOrPath.trim(), itemIncludeSubitems: filters.itemIncludeSubitems, statusFilter: filters.status, batchIsTerminal: isTerminalBatchStatus(info?.status), batchStartedAtUtc: info?.startedAtUtc ?? info?.createdAtUtc, abortingJobIds: abortingJobIds, retryingKeys: retryingKeys, isMobile: isMobile, onToggleItem: toggleItem, onOpenItem: openItemInEditor, onAbortJob: handleAbortJob, onRetryJobs: handleRetryJobs })] }))] }, b.id));
1168
+ : undefined, title: formattedBatchDate, children: batchDisplayName }), _jsx("div", { className: "mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[12px] text-neutral-grey-50", children: desktopMetaParts.map((part, i) => (_jsxs(React.Fragment, { children: [i > 0 && (_jsx("span", { className: "text-neutral-grey-15", children: "\u00B7" })), part] }, i))) }), mobileFooterMetaParts.length > 0 && (_jsx("div", { className: "mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[12px] text-neutral-grey-50", children: mobileFooterMetaParts.map((part, i) => (_jsxs(React.Fragment, { children: [i > 0 && (_jsx("span", { className: "text-neutral-grey-15", children: "\u00B7" })), part] }, `footer-${i}`))) }))] }), isCompactBatches && (_jsxs("div", { className: "mt-2 flex min-w-0 items-center gap-2", children: [totalJobs > 0 && (_jsx("div", { className: "min-w-0 flex-1", children: _jsx(BatchProgressIndicator, { counts: statusCounts, status: info?.status, testId: `batch-progress-${b.id}`, variant: "bar" }) })), hasBatchActions && (_jsx("div", { className: "flex shrink-0 items-center gap-1.5", children: batchActions }))] })), !isCompactBatches && hasBatchActions && (_jsx("div", { className: "flex shrink-0 items-center gap-2 self-center", children: batchActions }))] })] }) }), isExpanded && (_jsxs("div", { className: "border-t border-border-default/50", children: [_jsx(CustomPromptPanel, { prompts: parseCustomPrompts(info?.metadata) }), _jsx(BatchItemList, { batchId: b.id, batchProvider: info?.provider, jobs: jobs, isLoading: isLoadingThis, expandedItems: expandedItems, languages: contentLanguages, currentLanguage: editContext?.item?.language, itemFilter: filters.itemIdOrPath.trim(), itemFilterStore: filters.store, itemIncludeSubitems: filters.itemIncludeSubitems, statusFilter: filters.status, batchIsTerminal: isTerminalBatchStatus(info?.status), batchStartedAtUtc: info?.startedAtUtc ?? info?.createdAtUtc, abortingJobIds: abortingJobIds, retryingKeys: retryingKeys, isMobile: isMobile, onToggleItem: toggleItem, onOpenItem: openItemInEditor, onAbortJob: handleAbortJob, onRetryJobs: handleRetryJobs })] }))] }, b.id));
1036
1169
  }) })] }, dateGroup.label))), hasMore && (_jsx("div", { className: "flex justify-center pt-6", children: _jsx(Button, { variant: "outline", size: "sm", onClick: loadMore, disabled: isLoadingMore, children: isLoadingMore ? (_jsxs(_Fragment, { children: [_jsx(LoaderIcon, { className: "h-4 w-4 animate-spin text-highlight-100" }), "Loading more..."] })) : (_jsxs(_Fragment, { children: [_jsx(ChevronDownIcon, { className: "h-4 w-4" }), "Load More Batches"] })) }) }))] })) }) })] }));
1037
1170
  }
1038
1171
  export const TRANSLATION_BATCH_FILTERS_SIDEBAR_ID = "translation-batch-filters";
1039
1172
  export function TranslationBatchFiltersSidebar() {
1040
1173
  const editContext = useEditContext();
1174
+ const model = useContentModel();
1041
1175
  const { filters, itemIdOrPathInput } = useTranslationBatchFilterSnapshot();
1176
+ const filterStore = filters.store ?? editContext?.currentItemDescriptor?.database ?? "";
1177
+ // The item filter reads its item in the open item's language, or in the store's own default locale when no item of
1178
+ // that store is open; a pick from the content tree carries the picked item's language instead.
1179
+ const itemFilterLanguage = (storeId) => {
1180
+ const openItem = editContext?.currentItemDescriptor;
1181
+ if (openItem?.database === storeId && openItem.language)
1182
+ return openItem.language;
1183
+ return (model?.stores.find((store) => store.id === storeId)?.defaultLocale ?? "");
1184
+ };
1185
+ const filterLanguage = itemFilterLanguage(filterStore);
1042
1186
  const [providers, setProviders] = useState([]);
1043
- const [sitecoreLanguages, setSitecoreLanguages] = useState([]);
1187
+ const languageOptions = useContentStoreLanguages();
1044
1188
  const [itemPickerOpen, setItemPickerOpen] = useState(false);
1045
1189
  const currentUserName = editContext?.user?.name || "all";
1046
1190
  // Limited-preview sessions and accounts confined to their own batches (see
@@ -1065,6 +1209,8 @@ export function TranslationBatchFiltersSidebar() {
1065
1209
  const debouncedSetItemFilter = useDebouncedCallback((value) => setTranslationBatchFilters((prev) => ({
1066
1210
  ...prev,
1067
1211
  itemIdOrPath: value,
1212
+ store: filterStore,
1213
+ language: filterLanguage,
1068
1214
  })), 400);
1069
1215
  useEffect(() => {
1070
1216
  const loadProviders = async () => {
@@ -1081,26 +1227,14 @@ export function TranslationBatchFiltersSidebar() {
1081
1227
  };
1082
1228
  loadProviders();
1083
1229
  }, []);
1084
- useEffect(() => {
1085
- const loadLanguages = async () => {
1086
- try {
1087
- const res = await getLanguages();
1088
- const langs = (res?.data ?? res ?? []);
1089
- setSitecoreLanguages(Array.isArray(langs) ? langs : []);
1090
- }
1091
- catch (error) {
1092
- console.error("Failed to load Sitecore languages:", error);
1093
- }
1094
- };
1095
- loadLanguages();
1096
- }, []);
1097
- const languageOptions = useMemo(() => sitecoreLanguages
1098
- .map((language) => {
1099
- const code = language.languageCode || language.name;
1100
- return code ? { ...language, languageCode: code } : null;
1101
- })
1102
- .filter((language) => language !== null)
1103
- .sort((a, b) => a.languageCode.localeCompare(b.languageCode)), [sitecoreLanguages]);
1230
+ const languageFilterOptions = useMemo(() => [
1231
+ { value: "all", label: "All Languages" },
1232
+ ...languageOptions.map((language) => ({
1233
+ value: language.languageCode,
1234
+ label: language.languageCode,
1235
+ icon: renderLanguageIcon(language),
1236
+ })),
1237
+ ], [languageOptions]);
1104
1238
  const currentItem = editContext?.item;
1105
1239
  const multiItemEnabled = editContext?.configuration?.localization?.multiItem !== false;
1106
1240
  const canStartTranslation = !!editContext && (multiItemEnabled || !!currentItem);
@@ -1116,6 +1250,7 @@ export function TranslationBatchFiltersSidebar() {
1116
1250
  filters.status !== "all" ||
1117
1251
  filters.user !== currentUserName ||
1118
1252
  filters.provider !== "all" ||
1253
+ filters.sourceLanguage !== "all" ||
1119
1254
  filters.targetLanguage !== "all" ||
1120
1255
  filters.itemIdOrPath.trim() !== "" ||
1121
1256
  filters.itemIncludeSubitems;
@@ -1129,9 +1264,7 @@ export function TranslationBatchFiltersSidebar() {
1129
1264
  }, [currentUserName, debouncedSetItemFilter]);
1130
1265
  const filterLabelClass = "text-[12px] font-medium text-neutral-grey-50";
1131
1266
  const filterFieldClass = "flex flex-col gap-1";
1132
- return (_jsxs("div", { className: "flex h-full min-h-0 flex-col bg-white", "data-testid": "translation-filters-sidebar", children: [_jsx("div", { className: "border-border-default flex shrink-0 flex-col gap-2 border-b px-3 py-3", children: _jsxs(Button, { type: "button", variant: "outline", size: "lg", title: canStartTranslation
1133
- ? "Start new translation"
1134
- : "Open an item to translate", "data-testid": "translation-sidebar-start-new-translation-button", disabled: !canStartTranslation, onClick: handleStartTranslation, className: "border-border-default hover:border-neutral-grey-100 hover:bg-neutral-grey-5 h-9 w-full justify-center gap-3 rounded-md bg-white px-3 text-sm font-medium shadow-none", children: [_jsx("span", { className: "truncate", children: "Start new translation" }), _jsx(PlusIcon, { className: "size-4", strokeWidth: 1 })] }) }), _jsx("div", { className: "min-h-0 flex-1 overflow-y-auto px-3 py-4", children: _jsxs("div", { className: "grid gap-4", children: [_jsxs("div", { className: filterFieldClass, children: [_jsx("label", { className: filterLabelClass, children: "Date Range" }), _jsx(Select, { className: "w-full bg-white", options: DATE_RANGE_OPTIONS, value: filters.dateRange, onValueChange: (value) => setTranslationBatchFilters((prev) => ({
1267
+ return (_jsxs("div", { className: "flex h-full min-h-0 flex-col bg-white", "data-testid": "translation-filters-sidebar", children: [_jsx("div", { className: "border-border-default flex shrink-0 flex-col gap-2 border-b px-3 py-3", children: _jsx(CreateButton, { label: "Start new translation", disabledHint: "Open an item to translate", "data-testid": "translation-sidebar-start-new-translation-button", disabled: !canStartTranslation, onClick: handleStartTranslation }) }), _jsx("div", { className: "min-h-0 flex-1 overflow-y-auto px-3 py-4", children: _jsxs("div", { className: "grid gap-4", children: [_jsxs("div", { className: filterFieldClass, children: [_jsx("label", { className: filterLabelClass, children: "Date Range" }), _jsx(Select, { className: "w-full bg-white", options: DATE_RANGE_OPTIONS, value: filters.dateRange, onValueChange: (value) => setTranslationBatchFilters((prev) => ({
1135
1268
  ...prev,
1136
1269
  dateRange: value,
1137
1270
  })), placeholder: "Select date range" })] }), _jsxs("div", { className: filterFieldClass, children: [_jsx("label", { className: filterLabelClass, children: "Status" }), _jsx(Select, { className: "w-full bg-white", options: STATUS_OPTIONS, value: filters.status, onValueChange: (value) => setTranslationBatchFilters((prev) => ({
@@ -1159,27 +1292,26 @@ export function TranslationBatchFiltersSidebar() {
1159
1292
  ], value: filters.provider, onValueChange: (value) => setTranslationBatchFilters((prev) => ({
1160
1293
  ...prev,
1161
1294
  provider: value,
1162
- })), placeholder: "Select provider" })] }), _jsxs("div", { className: filterFieldClass, children: [_jsx("label", { className: filterLabelClass, children: "Target Language" }), _jsx(Select, { className: "w-full bg-white", options: [
1163
- {
1164
- value: "all",
1165
- label: "All Languages",
1166
- },
1167
- ...languageOptions.map((language) => ({
1168
- value: language.languageCode,
1169
- label: language.languageCode,
1170
- icon: renderTargetLanguageIcon(language),
1171
- })),
1172
- ], value: filters.targetLanguage, onValueChange: (value) => setTranslationBatchFilters((prev) => ({
1295
+ })), placeholder: "Select provider" })] }), _jsxs("div", { className: filterFieldClass, children: [_jsx("label", { className: filterLabelClass, children: "Source Language" }), _jsx(Select, { className: "w-full bg-white", options: languageFilterOptions, value: filters.sourceLanguage, onValueChange: (value) => setTranslationBatchFilters((prev) => ({
1296
+ ...prev,
1297
+ sourceLanguage: value,
1298
+ })), placeholder: "Select language" })] }), _jsxs("div", { className: filterFieldClass, children: [_jsx("label", { className: filterLabelClass, children: "Target Language" }), _jsx(Select, { className: "w-full bg-white", options: languageFilterOptions, value: filters.targetLanguage, onValueChange: (value) => setTranslationBatchFilters((prev) => ({
1173
1299
  ...prev,
1174
1300
  targetLanguage: value,
1175
1301
  })), placeholder: "Select language" })] }), _jsxs("div", { className: filterFieldClass, children: [_jsxs("div", { className: "flex items-center justify-between gap-2", children: [_jsx("label", { className: filterLabelClass, children: "Item ID / Path" }), _jsxs("label", { className: "flex cursor-pointer items-center gap-1 text-[10px] text-neutral-grey-50 select-none", children: [_jsx("input", { type: "checkbox", checked: filters.itemIncludeSubitems, onChange: (e) => setTranslationBatchFilters((prev) => ({
1176
1302
  ...prev,
1177
1303
  itemIncludeSubitems: e.target.checked,
1178
- })), className: "h-3 w-3 cursor-pointer accent-highlight-100" }), "Include subitems"] })] }), _jsxs("div", { className: "relative", children: [_jsx(Input, { value: itemIdOrPathInput, onChange: (e) => {
1304
+ })), className: "h-3 w-3 cursor-pointer accent-highlight-100" }), "Include subitems"] })] }), _jsx(ContentStoreSelect, { "aria-label": "Item filter store", className: "w-full bg-white", value: filterStore, placeholder: "Select a store", onValueChange: (storeId) => setTranslationBatchFilters((prev) => ({
1305
+ ...prev,
1306
+ store: storeId,
1307
+ language: itemFilterLanguage(storeId),
1308
+ })), stores: model?.stores ?? [] }), _jsxs("div", { className: "relative", children: [_jsx(Input, { value: itemIdOrPathInput, disabled: !filterStore || !filterLanguage, onChange: (e) => {
1179
1309
  const next = e.target.value;
1180
1310
  setTranslationBatchItemInput(next);
1181
1311
  debouncedSetItemFilter(next);
1182
- }, placeholder: "GUID or /sitecore/content/...", className: "h-auto min-h-[34px] w-full bg-white py-2 pr-14 text-xs" }), _jsxs("div", { className: "absolute top-1/2 right-1.5 flex -translate-y-1/2 items-center gap-1", children: [itemIdOrPathInput && (_jsx("button", { type: "button", onClick: () => {
1312
+ }, placeholder: filterStore && !filterLanguage
1313
+ ? "Open an item of this store"
1314
+ : "Item ID or path", className: "h-auto min-h-[34px] w-full bg-white py-2 pr-14 text-xs" }), _jsxs("div", { className: "absolute top-1/2 right-1.5 flex -translate-y-1/2 items-center gap-1", children: [itemIdOrPathInput && (_jsx("button", { type: "button", onClick: () => {
1183
1315
  setTranslationBatchItemInput("");
1184
1316
  debouncedSetItemFilter.cancel();
1185
1317
  setTranslationBatchFilters((prev) => ({
@@ -1187,18 +1319,21 @@ export function TranslationBatchFiltersSidebar() {
1187
1319
  itemIdOrPath: "",
1188
1320
  itemIncludeSubitems: false,
1189
1321
  }));
1190
- }, className: "cursor-pointer text-neutral-grey-50 hover:text-neutral-grey-100", "aria-label": "Clear", children: _jsx(XIcon, { className: "h-3.5 w-3.5" }) })), _jsxs(Popover, { open: itemPickerOpen, onOpenChange: setItemPickerOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsx("button", { type: "button", className: "cursor-pointer text-neutral-grey-50 hover:text-neutral-grey-100", "aria-label": "Browse content tree", title: "Browse content tree", children: _jsx(FolderTreeIcon, { className: "h-3.5 w-3.5" }) }) }), _jsxs(PopoverContent, { align: "end", sideOffset: 6, className: "w-[28rem] max-w-[calc(100vw-2rem)] p-0", children: [_jsx("div", { className: "flex items-center justify-between gap-2 border-b border-border-default px-3 py-2 text-[11px] text-neutral-grey-50", children: _jsx("span", { children: "Pick item to filter by" }) }), _jsx("div", { className: "max-h-80 overflow-auto p-2", children: _jsx(ContentTree, { language: "en", selectionMode: "single", rootItemIds: ["0de95ae4-41ab-4d01-9eb0-67441b7c2450"], initialExpandedKeys: [
1191
- "0de95ae4-41ab-4d01-9eb0-67441b7c2450",
1192
- ], onSelectionChange: (items) => {
1322
+ }, className: "cursor-pointer text-neutral-grey-50 hover:text-neutral-grey-100", "aria-label": "Clear", children: _jsx(XIcon, { className: "h-3.5 w-3.5" }) })), _jsxs(Popover, { open: itemPickerOpen, onOpenChange: setItemPickerOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsx("button", { type: "button", className: "cursor-pointer text-neutral-grey-50 hover:text-neutral-grey-100", "aria-label": "Browse content tree", disabled: !filterStore || !filterLanguage, title: "Browse content tree", children: _jsx(FolderTreeIcon, { className: "h-3.5 w-3.5" }) }) }), _jsxs(PopoverContent, { align: "end", sideOffset: 6, className: "w-[28rem] max-w-[calc(100vw-2rem)] p-0", children: [_jsx("div", { className: "flex items-center justify-between gap-2 border-b border-border-default px-3 py-2 text-[11px] text-neutral-grey-50", children: _jsx("span", { children: "Pick item to filter by" }) }), _jsx("div", { className: "max-h-80 overflow-auto p-2", children: filterStore && filterLanguage && (_jsx(ContentTree, { language: filterLanguage, database: filterStore, selectionMode: "single", onSelectionChange: (items) => {
1193
1323
  const picked = items?.[0];
1194
1324
  if (!picked)
1195
1325
  return;
1196
- const applyValue = (value) => {
1197
- setTranslationBatchItemInput(value);
1326
+ // multi-cms cftree-2: a picked item filters by its id — the one address every store
1327
+ // resolves (a Contentful block's or asset's place is shown only, and a page's slug path
1328
+ // can name two pages) — while the box shows its path where it has one.
1329
+ const applyValue = (shown) => {
1330
+ setTranslationBatchItemInput(shown);
1198
1331
  debouncedSetItemFilter.cancel();
1199
1332
  setTranslationBatchFilters((prev) => ({
1200
1333
  ...prev,
1201
- itemIdOrPath: value,
1334
+ itemIdOrPath: picked.id,
1335
+ store: picked.database,
1336
+ language: picked.language,
1202
1337
  }));
1203
1338
  setItemPickerOpen(false);
1204
1339
  };
@@ -1209,7 +1344,8 @@ export function TranslationBatchFiltersSidebar() {
1209
1344
  fetchItemStubs([
1210
1345
  {
1211
1346
  id: picked.id,
1212
- language: "en",
1347
+ language: picked.language,
1348
+ database: picked.database,
1213
1349
  version: 1,
1214
1350
  },
1215
1351
  ])
@@ -1218,7 +1354,7 @@ export function TranslationBatchFiltersSidebar() {
1218
1354
  applyValue(stubPath || picked.id);
1219
1355
  })
1220
1356
  .catch(() => applyValue(picked.id));
1221
- } }) })] })] })] })] })] }), _jsx("div", { className: "flex justify-start pt-1", children: _jsxs(Button, { type: "button", variant: "ghost", size: "sm", onClick: resetFilters, disabled: !hasActiveFilters, children: [_jsx(XIcon, { className: "h-3.5 w-3.5" }), "Reset Filters"] }) })] }) })] }));
1357
+ } })) })] })] })] })] })] }), _jsx("div", { className: "flex justify-start pt-1", children: _jsxs(Button, { type: "button", variant: "ghost", size: "sm", onClick: resetFilters, disabled: !hasActiveFilters, children: [_jsx(XIcon, { className: "h-3.5 w-3.5" }), "Reset Filters"] }) })] }) })] }));
1222
1358
  }
1223
1359
  function isLikelyGuid(value) {
1224
1360
  return /^[{(]?[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}[)}]?$/i.test(value.trim());
@@ -1524,8 +1660,8 @@ function InlineLanguageJobChips({ batchId, batchProvider, jobs, languageMap, isE
1524
1660
  ? undefined
1525
1661
  : { maxHeight: firstRowHeight ?? COLLAPSED_CHIP_ROW_HEIGHT_PX }, children: jobs.map((job, idx) => {
1526
1662
  const lang = languageMap.get((job.targetLanguage || "").toLowerCase());
1527
- const retryKey = `job:${job.id ?? `${job.itemId}:${job.sourceLanguage}:${job.targetLanguage}`}`;
1528
- return (_jsx("span", { className: "shrink-0", onClick: (event) => event.stopPropagation(), children: _jsx(LanguageJobChip, { job: job, language: lang, provider: batchProvider, batchStartedAtUtc: batchStartedAtUtc, onOpen: () => onOpenItem(job.itemId, job.targetLanguage), isAborting: !!job.id && abortingJobIds.has(job.id), onAbort: () => onAbortJob(job), isRetrying: retryingKeys.has(retryKey), onRetry: () => onRetryJobs(batchId, batchProvider, [job], retryKey) }) }, `${job.id ?? idx}-${job.targetLanguage}`));
1663
+ const retryKey = `job:${job.id ?? `${translationItemKey(job)}:${job.sourceLanguage}:${job.targetLanguage}`}`;
1664
+ return (_jsx("span", { className: "shrink-0", onClick: (event) => event.stopPropagation(), children: _jsx(LanguageJobChip, { job: job, language: lang, provider: batchProvider, batchStartedAtUtc: batchStartedAtUtc, onOpen: () => onOpenItem(job.itemId, job.targetLanguage, job.store), isAborting: !!job.id && abortingJobIds.has(job.id), onAbort: () => onAbortJob(job), isRetrying: retryingKeys.has(retryKey), onRetry: () => onRetryJobs(batchId, batchProvider, [job], retryKey) }) }, `${job.id ?? idx}-${job.targetLanguage}`));
1529
1665
  }) }), !isExpanded && hiddenCount > 0 && (_jsxs("button", { type: "button", className: "mt-px shrink-0 rounded border border-border-default bg-neutral-grey-5 badge-pad-sm text-[12px] leading-none tabular-nums text-neutral-grey-50 transition-colors hover:bg-neutral-grey-15 hover:text-neutral-grey-100", "aria-label": `Show ${hiddenCount} more language${hiddenCount !== 1 ? "s" : ""}`, title: `${hiddenCount} more language${hiddenCount !== 1 ? "s" : ""}`, onClick: (event) => {
1530
1666
  event.stopPropagation();
1531
1667
  onToggle();
@@ -1569,7 +1705,7 @@ function CustomPromptPanel({ prompts }) {
1569
1705
  }, icon: justCopied ? (_jsx(CheckIcon, { className: "h-3.5 w-3.5", strokeWidth: 1 })) : (_jsx(CopyIcon, { className: "h-3.5 w-3.5", strokeWidth: 1 })), label: justCopied ? "Copied" : "Copy prompt" })), _jsx(ChevronDownIcon, { className: `h-3.5 w-3.5 text-neutral-grey-100 transition-transform ${isOpen ? "rotate-180" : ""}` })] })] }), isOpen && (_jsx("div", { style: { paddingLeft: "2.5rem" }, className: "pr-3 md:pr-4 pb-3", children: _jsx("pre", { className: "max-h-64 overflow-y-auto whitespace-pre-wrap break-words rounded border border-border-default/50 bg-white p-2 font-mono text-[12px] text-neutral-grey-100", children: p.prompt }) }))] }, p.provider));
1570
1706
  }) }));
1571
1707
  }
1572
- function BatchItemList({ batchId, batchProvider, jobs, isLoading, expandedItems, languages, currentLanguage, itemFilter, itemIncludeSubitems, statusFilter, batchIsTerminal, batchStartedAtUtc, abortingJobIds, retryingKeys, isMobile = false, onToggleItem, onOpenItem, onAbortJob, onRetryJobs, }) {
1708
+ export function BatchItemList({ batchId, batchProvider, jobs, isLoading, expandedItems, languages, currentLanguage, itemFilter, itemFilterStore, itemIncludeSubitems, statusFilter, batchIsTerminal, batchStartedAtUtc, abortingJobIds, retryingKeys, isMobile = false, onToggleItem, onOpenItem, onAbortJob, onRetryJobs, }) {
1573
1709
  const languageMap = React.useMemo(() => {
1574
1710
  const map = new Map();
1575
1711
  for (const l of languages) {
@@ -1600,6 +1736,7 @@ function BatchItemList({ batchId, batchProvider, jobs, isLoading, expandedItems,
1600
1736
  const filter = itemFilter.trim();
1601
1737
  if (!filter)
1602
1738
  return effectiveJobs;
1739
+ const scopedJobs = effectiveJobs.filter((job) => !!itemFilterStore && job.store === itemFilterStore);
1603
1740
  // When subitems is enabled and the filter is a GUID, derive the root path
1604
1741
  // from any job in this batch that matches the GUID — then fall through to
1605
1742
  // prefix-matching on path. If no such job is in the batch we keep only
@@ -1609,29 +1746,29 @@ function BatchItemList({ batchId, batchProvider, jobs, isLoading, expandedItems,
1609
1746
  if (isLikelyGuid(filter)) {
1610
1747
  const normalized = normalizeGuid(filter);
1611
1748
  if (itemIncludeSubitems) {
1612
- const rootJob = effectiveJobs.find((j) => normalizeGuid((j.itemId || "").toString()) === normalized);
1749
+ const rootJob = scopedJobs.find((j) => normalizeGuid((j.itemId || "").toString()) === normalized);
1613
1750
  pathPrefix = rootJob?.itemPath ? rootJob.itemPath.toLowerCase() : null;
1614
1751
  }
1615
1752
  if (!pathPrefix) {
1616
- return effectiveJobs.filter((j) => normalizeGuid((j.itemId || "").toString()) === normalized);
1753
+ return scopedJobs.filter((j) => normalizeGuid((j.itemId || "").toString()) === normalized);
1617
1754
  }
1618
1755
  }
1619
1756
  else if (filter.startsWith("/")) {
1620
1757
  pathPrefix = filter.toLowerCase();
1621
1758
  }
1622
1759
  else {
1623
- return effectiveJobs;
1760
+ return scopedJobs;
1624
1761
  }
1625
1762
  if (itemIncludeSubitems) {
1626
1763
  const prefix = pathPrefix;
1627
1764
  const prefixSlash = prefix.endsWith("/") ? prefix : prefix + "/";
1628
- return effectiveJobs.filter((j) => {
1765
+ return scopedJobs.filter((j) => {
1629
1766
  const p = (j.itemPath || "").toLowerCase();
1630
1767
  return p === prefix || p.startsWith(prefixSlash);
1631
1768
  });
1632
1769
  }
1633
- return effectiveJobs.filter((j) => (j.itemPath || "").toLowerCase() === pathPrefix);
1634
- }, [effectiveJobs, itemFilter, itemIncludeSubitems]);
1770
+ return scopedJobs.filter((j) => (j.itemPath || "").toLowerCase() === pathPrefix);
1771
+ }, [effectiveJobs, itemFilter, itemFilterStore, itemIncludeSubitems]);
1635
1772
  // Keep all jobs of items that have at least one job matching the selected status —
1636
1773
  // this way the per-item language overview stays intact even when filtering.
1637
1774
  const statusFilteredJobs = React.useMemo(() => {
@@ -1643,12 +1780,12 @@ function BatchItemList({ batchId, batchProvider, jobs, isLoading, expandedItems,
1643
1780
  const matchingItemIds = new Set();
1644
1781
  for (const j of filteredJobs) {
1645
1782
  if (j.status === targetDbStatus) {
1646
- matchingItemIds.add((j.itemId || "").toString().toLowerCase());
1783
+ matchingItemIds.add(translationItemKey(j));
1647
1784
  }
1648
1785
  }
1649
1786
  if (matchingItemIds.size === 0)
1650
1787
  return [];
1651
- return filteredJobs.filter((j) => matchingItemIds.has((j.itemId || "").toString().toLowerCase()));
1788
+ return filteredJobs.filter((j) => matchingItemIds.has(translationItemKey(j)));
1652
1789
  }, [filteredJobs, statusFilter]);
1653
1790
  const [stackLanguageChips, setStackLanguageChips] = React.useState(isMobile);
1654
1791
  const itemTableContainerRef = React.useRef(null);
@@ -1712,7 +1849,7 @@ function BatchItemList({ batchId, batchProvider, jobs, isLoading, expandedItems,
1712
1849
  }
1713
1850
  const byItem = new Map();
1714
1851
  for (const job of statusFilteredJobs) {
1715
- const key = (job.itemId ?? "").toString().toLowerCase();
1852
+ const key = translationItemKey(job);
1716
1853
  if (!byItem.has(key))
1717
1854
  byItem.set(key, []);
1718
1855
  byItem.get(key).push(job);
@@ -1727,8 +1864,8 @@ function BatchItemList({ batchId, batchProvider, jobs, isLoading, expandedItems,
1727
1864
  const itemPath = firstJob?.itemPath ?? null;
1728
1865
  const serverName = firstJob?.itemName ?? null;
1729
1866
  const metadataName = parseItemName(firstJob?.metadata, "");
1730
- const displayName = serverName || metadataName || itemId;
1731
- const titleAttr = `${itemPath ?? ""}\n${itemId}`.trim();
1867
+ const displayName = serverName || metadataName || firstJob?.itemId;
1868
+ const titleAttr = `${firstJob?.store || "Legacy row: store unavailable; editor navigation and retry disabled"}\n${itemPath ?? ""}\n${firstJob?.itemId}`.trim();
1732
1869
  const itemErrorJobs = itemJobs.filter(isRetriableJob);
1733
1870
  const itemRetryKey = `item:${batchId}:${itemId}`;
1734
1871
  const isRetryingItem = retryingKeys.has(itemRetryKey);
@@ -1747,13 +1884,16 @@ function BatchItemList({ batchId, batchProvider, jobs, isLoading, expandedItems,
1747
1884
  }, icon: _jsx(RetryIcon, { className: `h-3.5 w-3.5 ${isRetryingItem ? "animate-spin" : ""}`, strokeWidth: 1 }), label: "Retry failed translations for this item", disabled: itemErrorJobs.length === 0 || isRetryingItem }) })) : null;
1748
1885
  const itemContent = (_jsxs("div", { className: `flex min-w-0 items-start ${stackLanguageChips ? "gap-2" : "gap-2.5"}`, children: [_jsx("span", { className: "mt-1 shrink-0", children: itemAnyInProgress ? (_jsx(LoaderIcon, { className: "h-3 w-3 animate-spin text-neutral-grey-50" })) : itemIsQueued ? (_jsx(QueuedIcon, { className: "h-3 w-3 text-neutral-grey-50", strokeWidth: 1, "aria-label": "Queued" })) : (_jsx("span", { className: `block h-1.5 w-1.5 rounded-full ${status.cls}`, "aria-hidden": "true" })) }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsx("span", { className: `block min-w-0 text-[13px] text-neutral-grey-100 ${stackLanguageChips ? "break-words" : "truncate"}`, style: stackLanguageChips
1749
1886
  ? { overflowWrap: "anywhere" }
1750
- : undefined, title: titleAttr, children: displayName }), itemPath && (_jsx("div", { className: "whitespace-normal break-words font-mono text-[11px] text-neutral-grey-50", style: { overflowWrap: "anywhere" }, title: titleAttr, children: itemPath })), stackLanguageChips && (_jsx("div", { className: "mt-2", children: languageChips })), stackLanguageChips && retryAction && (_jsx("div", { className: "mt-2 flex justify-start", children: retryAction }))] })] }));
1751
- return (_jsxs("tr", { role: "button", tabIndex: 0, className: `group cursor-pointer transition-colors hover:bg-neutral-grey-5 ${itemIndex > 0 ? "border-t border-border-default/50" : ""}`, onClick: () => {
1752
- void onOpenItem(itemId, rowOpenLanguage);
1887
+ : undefined, title: titleAttr, children: displayName }), itemPath && (_jsx("div", { className: "whitespace-normal break-words font-mono text-[11px] text-neutral-grey-50", style: { overflowWrap: "anywhere" }, title: titleAttr, children: itemPath })), _jsx("div", { className: "text-[11px] text-neutral-grey-50", children: firstJob?.store ||
1888
+ "Legacy record: content store unavailable; retry and navigation disabled." }), stackLanguageChips && (_jsx("div", { className: "mt-2", children: languageChips })), stackLanguageChips && retryAction && (_jsx("div", { className: "mt-2 flex justify-start", children: retryAction }))] })] }));
1889
+ return (_jsxs("tr", { role: "button", "aria-disabled": !firstJob?.store, tabIndex: firstJob?.store ? 0 : -1, className: `group cursor-pointer transition-colors hover:bg-neutral-grey-5 ${itemIndex > 0 ? "border-t border-border-default/50" : ""}`, onClick: () => {
1890
+ if (firstJob?.store)
1891
+ void onOpenItem(firstJob.itemId, rowOpenLanguage, firstJob.store);
1753
1892
  }, onKeyDown: (e) => {
1754
1893
  if (e.key === "Enter" || e.key === " ") {
1755
1894
  e.preventDefault();
1756
- void onOpenItem(itemId, rowOpenLanguage);
1895
+ if (firstJob?.store)
1896
+ void onOpenItem(firstJob.itemId, rowOpenLanguage, firstJob.store);
1757
1897
  }
1758
1898
  }, children: [!stackLanguageChips && (_jsx("td", { "aria-hidden": "true", className: "px-3 py-2 md:px-4" })), _jsx("td", { className: `py-2 align-top ${stackLanguageChips ? "pr-2 pl-2.5" : "pr-4"}`, children: itemContent }), !stackLanguageChips && (_jsx("td", { className: "py-2 pr-2 align-top", children: languageChips })), !stackLanguageChips && (_jsx("td", { className: "w-12 py-2 pr-3 align-top whitespace-nowrap md:pr-4", children: retryAction }))] }, itemId));
1759
1899
  }) })] }) }));
@@ -1854,7 +1994,7 @@ function LanguageJobChip({ job, language, provider, batchStartedAtUtc, onOpen, i
1854
1994
  const emptyFieldText = statistics && statistics.emptyFieldCount > 0
1855
1995
  ? `${formatCount(statistics.emptyFieldCount)} empty`
1856
1996
  : null;
1857
- return (_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs("button", { type: "button", className: `group inline-flex items-center gap-1.5 rounded border badge-pad-sm text-[12px] transition-colors cursor-pointer ${chipCls}`, children: [language?.icon ? (_jsx("img", { src: language.icon, alt: langName, className: "h-3.5 shrink-0" })) : null, _jsx("span", { className: "font-mono tracking-tight", children: job.targetLanguage }), jobInProgress && (_jsx(LoaderIcon, { className: "h-3 w-3 shrink-0 animate-spin" })), jobPending && (_jsx(QueuedIcon, { className: "h-3 w-3 shrink-0", strokeWidth: 1, "aria-label": "Queued" })), jobError && _jsx(AlertCircleIcon, { className: "h-3 w-3 shrink-0" }), !jobInProgress && !jobError && !jobPending && !jobAborted && (_jsx(CheckIcon, { className: "h-3 w-3 shrink-0 text-feedback-green" }))] }) }), _jsxs(PopoverContent, { align: "start", sideOffset: 6, className: "w-[26rem] max-w-[calc(100vw-2rem)] p-0", children: [_jsxs("div", { className: "flex items-center gap-2 border-b border-border-default px-3 py-2", children: [language?.icon ? (_jsx("img", { src: language.icon, alt: langName, className: "h-4 shrink-0" })) : null, _jsxs("div", { className: "min-w-0 flex-1", children: [_jsx("div", { className: "text-[13px] font-medium text-neutral-grey-100 truncate", children: langName }), _jsxs("div", { className: "text-[11px] text-neutral-grey-50 font-mono truncate", children: [job.targetLanguage, job.sourceLanguage ? ` ← ${job.sourceLanguage}` : ""] })] }), _jsxs(Badge, { size: "sm", className: statusBadgeCls, children: [jobInProgress && (_jsx(LoaderIcon, { className: "h-2.5 w-2.5 animate-spin" })), capitalizeFirstLetter(jobStatus || "Unknown")] })] }), _jsxs("dl", { className: "divide-y divide-border-default/60", children: [claimedAtValid && (_jsxs("div", { className: "flex items-baseline gap-3 px-3 py-2", children: [_jsx("dt", { className: "w-20 shrink-0 text-[10px] tracking-wide text-neutral-grey-50", children: "Claimed" }), _jsx("dd", { className: "text-[12px] text-neutral-grey-100", children: formatDateTime(claimedAt) })] })), timestampValid && (jobInProgress || jobPending) && (_jsxs("div", { className: "flex items-baseline gap-3 px-3 py-2", children: [_jsx("dt", { className: "w-20 shrink-0 text-[10px] tracking-wide text-neutral-grey-50", children: "Updated" }), _jsx("dd", { className: "text-[12px] text-neutral-grey-100", children: formatDateTime(timestamp) })] })), durationMs != null && (_jsxs("div", { className: "flex items-baseline gap-3 px-3 py-2", children: [_jsx("dt", { className: "w-20 shrink-0 text-[10px] tracking-wide text-neutral-grey-50", children: heartbeatStale
1997
+ return (_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs("button", { type: "button", className: `group inline-flex items-center gap-1.5 rounded border badge-pad-sm text-[12px] transition-colors cursor-pointer ${chipCls}`, children: [_jsx(LanguageIcon, { language: { languageCode: job.targetLanguage, name: langName }, flagClassName: "h-[10.5px] w-3.5 shrink-0", globeClassName: "h-3.5 w-3.5 shrink-0" }), _jsx("span", { className: "font-mono tracking-tight", children: job.targetLanguage }), jobInProgress && (_jsx(LoaderIcon, { className: "h-3 w-3 shrink-0 animate-spin" })), jobPending && (_jsx(QueuedIcon, { className: "h-3 w-3 shrink-0", strokeWidth: 1, "aria-label": "Queued" })), jobError && _jsx(AlertCircleIcon, { className: "h-3 w-3 shrink-0" }), !jobInProgress && !jobError && !jobPending && !jobAborted && (_jsx(CheckIcon, { className: "h-3 w-3 shrink-0 text-feedback-green" }))] }) }), _jsxs(PopoverContent, { align: "start", sideOffset: 6, className: "w-[26rem] max-w-[calc(100vw-2rem)] p-0", children: [_jsxs("div", { className: "flex items-center gap-2 border-b border-border-default px-3 py-2", children: [_jsx(LanguageIcon, { language: { languageCode: job.targetLanguage, name: langName }, flagClassName: "h-3 w-4 shrink-0", globeClassName: "h-4 w-4 shrink-0" }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsx("div", { className: "text-[13px] font-medium text-neutral-grey-100 truncate", children: langName }), _jsxs("div", { className: "text-[11px] text-neutral-grey-50 font-mono truncate", children: [job.targetLanguage, job.sourceLanguage ? ` ← ${job.sourceLanguage}` : ""] })] }), _jsxs(Badge, { size: "sm", className: statusBadgeCls, children: [jobInProgress && (_jsx(LoaderIcon, { className: "h-2.5 w-2.5 animate-spin" })), capitalizeFirstLetter(jobStatus || "Unknown")] })] }), _jsxs("dl", { className: "divide-y divide-border-default/60", children: [claimedAtValid && (_jsxs("div", { className: "flex items-baseline gap-3 px-3 py-2", children: [_jsx("dt", { className: "w-20 shrink-0 text-[10px] tracking-wide text-neutral-grey-50", children: "Claimed" }), _jsx("dd", { className: "text-[12px] text-neutral-grey-100", children: formatDateTime(claimedAt) })] })), timestampValid && (jobInProgress || jobPending) && (_jsxs("div", { className: "flex items-baseline gap-3 px-3 py-2", children: [_jsx("dt", { className: "w-20 shrink-0 text-[10px] tracking-wide text-neutral-grey-50", children: "Updated" }), _jsx("dd", { className: "text-[12px] text-neutral-grey-100", children: formatDateTime(timestamp) })] })), durationMs != null && (_jsxs("div", { className: "flex items-baseline gap-3 px-3 py-2", children: [_jsx("dt", { className: "w-20 shrink-0 text-[10px] tracking-wide text-neutral-grey-50", children: heartbeatStale
1858
1998
  ? "Stalled"
1859
1999
  : jobInProgress || jobPending
1860
2000
  ? "Running"
@@ -1883,11 +2023,13 @@ function LanguageJobChip({ job, language, provider, batchStartedAtUtc, onOpen, i
1883
2023
  e.stopPropagation();
1884
2024
  void onAbort?.();
1885
2025
  setOpen(false);
1886
- }, className: "gap-1.5 text-neutral-grey-50 hover:text-neutral-grey-100", children: [isAborting ? (_jsx(LoaderIcon, { className: "h-3.5 w-3.5 animate-spin" })) : (_jsx(AbortIcon, { className: "h-3.5 w-3.5" })), "Abort"] })), jobError && onRetry && (_jsxs(Button, { size: "sm", variant: "outline", disabled: isRetrying, onClick: (e) => {
2026
+ }, className: "gap-1.5 text-neutral-grey-50 hover:text-neutral-grey-100", children: [isAborting ? (_jsx(LoaderIcon, { className: "h-3.5 w-3.5 animate-spin" })) : (_jsx(AbortIcon, { className: "h-3.5 w-3.5" })), "Abort"] })), jobError && job.store && onRetry && (_jsxs(Button, { size: "sm", variant: "outline", disabled: isRetrying, onClick: (e) => {
1887
2027
  e.stopPropagation();
1888
2028
  void onRetry();
1889
2029
  setOpen(false);
1890
- }, className: "gap-1.5", children: [_jsx(RetryIcon, { className: `h-3.5 w-3.5 ${isRetrying ? "animate-spin" : ""}` }), "Retry"] })), _jsxs(Button, { size: "sm", variant: "default", onClick: (e) => {
2030
+ }, className: "gap-1.5", children: [_jsx(RetryIcon, { className: `h-3.5 w-3.5 ${isRetrying ? "animate-spin" : ""}` }), "Retry"] })), _jsxs(Button, { size: "sm", variant: "default", disabled: !job.store, title: !job.store
2031
+ ? "Legacy row has no content store; navigation is unavailable."
2032
+ : undefined, onClick: (e) => {
1891
2033
  e.stopPropagation();
1892
2034
  void onOpen();
1893
2035
  setOpen(false);