@parhelia/localization 0.4.12884 → 0.4.13030

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 (48) 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 +44 -18
  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 +43 -27
  17. package/dist/services/translationService.d.ts.map +1 -1
  18. package/dist/services/translationService.js +36 -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.map +1 -1
  36. package/dist/steps/ItemSelectionTree.js +130 -43
  37. package/dist/steps/ProviderStep.d.ts.map +1 -1
  38. package/dist/steps/ProviderStep.js +54 -42
  39. package/dist/steps/ServiceLanguageSelectionStep.d.ts.map +1 -1
  40. package/dist/steps/ServiceLanguageSelectionStep.js +32 -9
  41. package/dist/steps/types.d.ts +7 -1
  42. package/dist/steps/types.d.ts.map +1 -1
  43. package/dist/translation-center/TranslationBatches.d.ts +36 -0
  44. package/dist/translation-center/TranslationBatches.d.ts.map +1 -1
  45. package/dist/translation-center/TranslationBatches.js +200 -77
  46. package/dist/types.d.ts +1 -0
  47. package/dist/types.d.ts.map +1 -1
  48. package/package.json +1 -1
@@ -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,21 +22,12 @@ 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
26
  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,
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
  }
43
33
  const DEFAULT_FILTERS = {
@@ -119,13 +109,28 @@ function isTerminalBatchStatus(status) {
119
109
  function isActiveBatchStatus(status) {
120
110
  return status === "Pending" || status === "In Progress";
121
111
  }
112
+ /**
113
+ * Whether the signed-in person may delete this batch: it has stopped (a running
114
+ * batch is aborted first), and they started it or are an administrator. The
115
+ * server checks the same; this only hides the action where it would be refused.
116
+ */
117
+ export function canDeleteTranslationBatch(info, user) {
118
+ if (!info || !user || !isTerminalBatchStatus(info.status))
119
+ return false;
120
+ if (user.isAdministrator)
121
+ return true;
122
+ // The initiator is the account whose id the batch stores, as on the server.
123
+ const initiator = info.initiatedBySubjectId?.trim().toLowerCase();
124
+ return !!initiator && initiator === user.subjectId?.trim().toLowerCase();
125
+ }
122
126
  function isRetriableJob(job) {
123
- return job?.status === "Error";
127
+ return job?.status === "Error" && !!job.store;
124
128
  }
125
129
  function buildRetryJobRequest(job) {
126
- if (!job.itemId || !job.sourceLanguage || !job.targetLanguage)
130
+ if (!job.store || !job.itemId || !job.sourceLanguage || !job.targetLanguage)
127
131
  return null;
128
132
  return {
133
+ store: job.store,
129
134
  sourceTranslationId: job.id,
130
135
  itemId: job.itemId,
131
136
  sourceLanguage: job.sourceLanguage,
@@ -240,7 +245,7 @@ export function TranslationBatches() {
240
245
  const editContext = useEditContext();
241
246
  const [emptyStateSlogan] = useState(() => EMPTY_STATE_SLOGANS[Math.floor(Math.random() * EMPTY_STATE_SLOGANS.length)]);
242
247
  const [batches, setBatches] = useState([]);
243
- const [sitecoreLanguages, setSitecoreLanguages] = useState([]);
248
+ const [contentLanguages, setContentLanguages] = useState([]);
244
249
  const [isLoading, setIsLoading] = useState(false);
245
250
  // False until the first list response lands. Later reloads (the user filter
246
251
  // defaulting in, socket refreshes, the reconciliation poll) update in place
@@ -256,6 +261,7 @@ export function TranslationBatches() {
256
261
  const [loadingJobs, setLoadingJobs] = useState(new Set());
257
262
  const [abortingBatchIds, setAbortingBatchIds] = useState(new Set());
258
263
  const [abortingJobIds, setAbortingJobIds] = useState(new Set());
264
+ const [deletingBatchIds, setDeletingBatchIds] = useState(new Set());
259
265
  const [retryingKeys, setRetryingKeys] = useState(new Set());
260
266
  // Cache of userName → displayName so we can render full names on batch rows
261
267
  // without re-querying the user service every render.
@@ -334,12 +340,18 @@ export function TranslationBatches() {
334
340
  provider: filters.provider === "all" ? undefined : filters.provider,
335
341
  targetLanguage: filters.targetLanguage === "all" ? undefined : filters.targetLanguage,
336
342
  itemIdOrPath: trimmedItem ? trimmedItem : undefined,
343
+ store: filters.store,
344
+ language: filters.language,
337
345
  itemIncludeSubitems: trimmedItem && filters.itemIncludeSubitems ? true : undefined,
338
346
  };
339
347
  }, [filters, userFilterLocked, currentUserName]);
340
- const loadRecentBatches = useCallback(async (offset, append, filtersToUse) => {
348
+ const loadRecentBatches = useCallback(async (offset, append, filtersToUse, background = false) => {
341
349
  const myRequestId = ++requestIdRef.current;
342
- if (offset === 0) {
350
+ if (background) {
351
+ // Background reconciliation must not replace the list with a loading
352
+ // state; websocket events remain the fast path.
353
+ }
354
+ else if (offset === 0) {
343
355
  setIsLoading(true);
344
356
  }
345
357
  else {
@@ -380,7 +392,7 @@ export function TranslationBatches() {
380
392
  console.error("Failed to load batches:", error);
381
393
  }
382
394
  finally {
383
- if (myRequestId === requestIdRef.current) {
395
+ if (!background && myRequestId === requestIdRef.current) {
384
396
  setIsLoading(false);
385
397
  setIsLoadingMore(false);
386
398
  setHasLoadedOnce(true);
@@ -393,24 +405,43 @@ export function TranslationBatches() {
393
405
  loadRecentBatches(currentOffset, true, effectiveFilters);
394
406
  }
395
407
  };
396
- // Load Sitecore languages for language chips in expanded batches.
408
+ // Load the content languages for language chips in expanded batches.
397
409
  useEffect(() => {
398
410
  const loadLanguages = async () => {
399
411
  try {
400
- const res = await getLanguages();
412
+ const res = await getLanguages(editContext?.currentItemDescriptor?.database ?? "");
401
413
  const langs = (res?.data ?? res ?? []);
402
- setSitecoreLanguages(Array.isArray(langs) ? langs : []);
414
+ setContentLanguages(Array.isArray(langs) ? langs : []);
403
415
  }
404
416
  catch (error) {
405
- console.error("Failed to load Sitecore languages:", error);
417
+ console.error("Failed to load content languages:", error);
406
418
  }
407
419
  };
408
420
  loadLanguages();
409
- }, []);
421
+ }, [editContext?.currentItemDescriptor?.database]);
410
422
  // Reload when filters change (resets pagination)
411
423
  useEffect(() => {
412
424
  loadRecentBatches(0, false, effectiveFilters);
413
425
  }, [loadRecentBatches, effectiveFilters]);
426
+ // Socket delivery is best-effort across reconnects and host restarts. Keep
427
+ // the visible list eventually consistent with a quiet REST reconciliation.
428
+ useEffect(() => {
429
+ let inFlight = false;
430
+ const reconcile = () => {
431
+ if (document.visibilityState === "hidden" || inFlight)
432
+ return;
433
+ inFlight = true;
434
+ void loadRecentBatches(0, false, effectiveFilters, true).finally(() => {
435
+ inFlight = false;
436
+ });
437
+ };
438
+ const interval = window.setInterval(reconcile, 3000);
439
+ document.addEventListener("visibilitychange", reconcile);
440
+ return () => {
441
+ window.clearInterval(interval);
442
+ document.removeEventListener("visibilitychange", reconcile);
443
+ };
444
+ }, [effectiveFilters, loadRecentBatches]);
414
445
  // Seed the cache with the current user's full name so rows authored by us
415
446
  // resolve immediately, without waiting on a searchUsers round-trip.
416
447
  useEffect(() => {
@@ -461,6 +492,24 @@ export function TranslationBatches() {
461
492
  cancelled = true;
462
493
  };
463
494
  }, [batches, userDisplayNames]);
495
+ // A deleted batch leaves the list, its held jobs and the expansion at once;
496
+ // the next list read would drop it as well.
497
+ const removeBatch = useCallback((batchId) => {
498
+ const id = normalizeGuid(batchId);
499
+ setBatches((prev) => {
500
+ const next = prev.filter((b) => normalizeGuid(b.id) !== id);
501
+ return next.length === prev.length ? prev : next;
502
+ });
503
+ setBatchJobs((prev) => {
504
+ const key = Object.keys(prev).find((k) => normalizeGuid(k) === id);
505
+ if (key === undefined)
506
+ return prev;
507
+ const next = { ...prev };
508
+ delete next[key];
509
+ return next;
510
+ });
511
+ setExpandedBatchId((prev) => prev && normalizeGuid(prev) === id ? null : prev);
512
+ }, []);
464
513
  // Keep refs to the latest reload + expansion state so the socket listener
465
514
  // can be registered once and survive editContext identity changes.
466
515
  // Without this, a context recreation (triggered e.g. by EditorShell's
@@ -489,6 +538,7 @@ export function TranslationBatches() {
489
538
  // Live progress: patch the matching job's message in-place so an open
490
539
  // popover reflects the latest progress text without a REST reload.
491
540
  if (message.type === "translation-progress" && batchIdFromPayload) {
541
+ const storeFromPayload = message?.payload?.store ?? message?.payload?.Store;
492
542
  const itemIdFromPayload = normalizeGuid(message?.payload?.itemId ?? message?.payload?.ItemId);
493
543
  const languageFromPayload = (message?.payload?.language ??
494
544
  message?.payload?.Language ??
@@ -503,7 +553,9 @@ export function TranslationBatches() {
503
553
  return prev;
504
554
  let changed = false;
505
555
  const nextJobs = jobs.map((job) => {
506
- if (normalizeGuid(job.itemId) === itemIdFromPayload &&
556
+ if (storeFromPayload &&
557
+ job.store === storeFromPayload &&
558
+ normalizeGuid(job.itemId) === itemIdFromPayload &&
507
559
  job.targetLanguage === languageFromPayload &&
508
560
  // A late progress text must not replace a terminal
509
561
  // outcome (an error text, or the final record).
@@ -536,6 +588,10 @@ export function TranslationBatches() {
536
588
  applyBatchRow(message.payload);
537
589
  return;
538
590
  }
591
+ if (message.type === "batch-deleted" && batchIdFromPayload) {
592
+ removeBatch(batchIdFromPayload);
593
+ return;
594
+ }
539
595
  if ((message.type === "translation-started" ||
540
596
  message.type === "translation-finished" ||
541
597
  message.type === "translation-error" ||
@@ -578,7 +634,7 @@ export function TranslationBatches() {
578
634
  // debounce expiry, and cancelling on re-subscription would drop the
579
635
  // refresh that brings the UI to its final state.
580
636
  };
581
- }, [editContext]);
637
+ }, [editContext, removeBatch]);
582
638
  // Websocket events are the fast path, but a short disconnect or a batch that
583
639
  // completes before the editor transport finishes reconnecting must not leave
584
640
  // this management view permanently stale. Reconcile while the panel is
@@ -788,6 +844,35 @@ export function TranslationBatches() {
788
844
  loadBatchJobs,
789
845
  loadRecentBatches,
790
846
  ]);
847
+ const handleDeleteBatch = useCallback((batchId, batchName) => {
848
+ editContext?.confirm({
849
+ header: "Delete Translation Batch",
850
+ message: `Delete "${batchName}" and its translation jobs? The batch disappears from Translation Management for everyone. Content that was already translated stays as it is.`,
851
+ acceptLabel: "Delete",
852
+ showCancel: true,
853
+ accept: async () => {
854
+ setDeletingBatchIds((prev) => new Set(prev).add(batchId));
855
+ try {
856
+ const result = await deleteBatch(batchId);
857
+ if (result.type !== "success") {
858
+ toast.error(result.details ||
859
+ result.summary ||
860
+ "Failed to delete translation batch.");
861
+ return;
862
+ }
863
+ removeBatch(batchId);
864
+ toast.success("Translation batch deleted.");
865
+ }
866
+ finally {
867
+ setDeletingBatchIds((prev) => {
868
+ const next = new Set(prev);
869
+ next.delete(batchId);
870
+ return next;
871
+ });
872
+ }
873
+ },
874
+ });
875
+ }, [editContext, removeBatch]);
791
876
  const handleAbortJob = useCallback((job) => {
792
877
  if (!job.id || !job.batchId) {
793
878
  toast.error("This translation job cannot be aborted.");
@@ -903,10 +988,16 @@ export function TranslationBatches() {
903
988
  const jobs = batchJobs[batchId] ?? (await loadBatchJobs(batchId));
904
989
  await handleRetryJobs(batchId, batch.provider, jobs, `batch:${batchId}`);
905
990
  }, [batchJobs, handleRetryJobs, loadBatchJobs]);
906
- const openItemInEditor = useCallback(async (itemId, language) => {
907
- const normalized = (itemId ?? "").toString().toLowerCase();
991
+ const openItemInEditor = useCallback(async (itemId, language, store) => {
992
+ if (!store || !language)
993
+ return;
908
994
  editContext?.setShowAgentsWorkspaceEditor(true);
909
- await editContext?.loadItem(language ? { id: normalized, language, version: 0 } : normalized);
995
+ await editContext?.loadItem({
996
+ id: itemId,
997
+ language,
998
+ version: 0,
999
+ database: store,
1000
+ });
910
1001
  }, [editContext]);
911
1002
  // The blank-slate home view (no header, grey full-height greeting) also
912
1003
  // covers the initial load, so the greeting mounts exactly once.
@@ -997,7 +1088,9 @@ export function TranslationBatches() {
997
1088
  const canAbort = isActiveBatchStatus(info?.status);
998
1089
  const isRetryingBatch = retryingKeys.has(`batch:${b.id}`);
999
1090
  const isAborting = abortingBatchIds.has(b.id);
1000
- const hasBatchActions = canRetry || canAbort;
1091
+ const canDelete = canDeleteTranslationBatch(info, editContext?.user);
1092
+ const isDeleting = deletingBatchIds.has(b.id);
1093
+ const hasBatchActions = canRetry || canAbort || canDelete;
1001
1094
  // Stable test-id status used by Playwright assertions.
1002
1095
  // Matches the visual status dot/spinner logic above.
1003
1096
  const testStatus = anyError
@@ -1020,7 +1113,10 @@ export function TranslationBatches() {
1020
1113
  if (!canAbort)
1021
1114
  return;
1022
1115
  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 }))] }));
1116
+ }, 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) => {
1117
+ event.stopPropagation();
1118
+ handleDeleteBatch(b.id, batchDisplayName);
1119
+ }, onKeyDown: (event) => event.stopPropagation(), disabled: isDeleting || isRetryingBatch }))] }));
1024
1120
  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
1121
  if (e.key === "Enter" || e.key === " ") {
1026
1122
  e.preventDefault();
@@ -1032,15 +1128,26 @@ export function TranslationBatches() {
1032
1128
  ? "whitespace-normal break-words leading-5"
1033
1129
  : "truncate"}`, style: isCompactBatches
1034
1130
  ? { 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));
1131
+ : 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
1132
  }) })] }, 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
1133
  }
1038
1134
  export const TRANSLATION_BATCH_FILTERS_SIDEBAR_ID = "translation-batch-filters";
1039
1135
  export function TranslationBatchFiltersSidebar() {
1040
1136
  const editContext = useEditContext();
1137
+ const model = useContentModel();
1041
1138
  const { filters, itemIdOrPathInput } = useTranslationBatchFilterSnapshot();
1139
+ const filterStore = filters.store ?? editContext?.currentItemDescriptor?.database ?? "";
1140
+ // The item filter reads its item in the open item's language, or in the store's own default locale when no item of
1141
+ // that store is open; a pick from the content tree carries the picked item's language instead.
1142
+ const itemFilterLanguage = (storeId) => {
1143
+ const openItem = editContext?.currentItemDescriptor;
1144
+ if (openItem?.database === storeId && openItem.language)
1145
+ return openItem.language;
1146
+ return (model?.stores.find((store) => store.id === storeId)?.defaultLocale ?? "");
1147
+ };
1148
+ const filterLanguage = itemFilterLanguage(filterStore);
1042
1149
  const [providers, setProviders] = useState([]);
1043
- const [sitecoreLanguages, setSitecoreLanguages] = useState([]);
1150
+ const [contentLanguages, setContentLanguages] = useState([]);
1044
1151
  const [itemPickerOpen, setItemPickerOpen] = useState(false);
1045
1152
  const currentUserName = editContext?.user?.name || "all";
1046
1153
  // Limited-preview sessions and accounts confined to their own batches (see
@@ -1065,6 +1172,8 @@ export function TranslationBatchFiltersSidebar() {
1065
1172
  const debouncedSetItemFilter = useDebouncedCallback((value) => setTranslationBatchFilters((prev) => ({
1066
1173
  ...prev,
1067
1174
  itemIdOrPath: value,
1175
+ store: filterStore,
1176
+ language: filterLanguage,
1068
1177
  })), 400);
1069
1178
  useEffect(() => {
1070
1179
  const loadProviders = async () => {
@@ -1084,23 +1193,23 @@ export function TranslationBatchFiltersSidebar() {
1084
1193
  useEffect(() => {
1085
1194
  const loadLanguages = async () => {
1086
1195
  try {
1087
- const res = await getLanguages();
1196
+ const res = await getLanguages(editContext?.currentItemDescriptor?.database ?? "");
1088
1197
  const langs = (res?.data ?? res ?? []);
1089
- setSitecoreLanguages(Array.isArray(langs) ? langs : []);
1198
+ setContentLanguages(Array.isArray(langs) ? langs : []);
1090
1199
  }
1091
1200
  catch (error) {
1092
- console.error("Failed to load Sitecore languages:", error);
1201
+ console.error("Failed to load content languages:", error);
1093
1202
  }
1094
1203
  };
1095
1204
  loadLanguages();
1096
- }, []);
1097
- const languageOptions = useMemo(() => sitecoreLanguages
1205
+ }, [editContext?.currentItemDescriptor?.database]);
1206
+ const languageOptions = useMemo(() => contentLanguages
1098
1207
  .map((language) => {
1099
1208
  const code = language.languageCode || language.name;
1100
1209
  return code ? { ...language, languageCode: code } : null;
1101
1210
  })
1102
1211
  .filter((language) => language !== null)
1103
- .sort((a, b) => a.languageCode.localeCompare(b.languageCode)), [sitecoreLanguages]);
1212
+ .sort((a, b) => a.languageCode.localeCompare(b.languageCode)), [contentLanguages]);
1104
1213
  const currentItem = editContext?.item;
1105
1214
  const multiItemEnabled = editContext?.configuration?.localization?.multiItem !== false;
1106
1215
  const canStartTranslation = !!editContext && (multiItemEnabled || !!currentItem);
@@ -1129,9 +1238,7 @@ export function TranslationBatchFiltersSidebar() {
1129
1238
  }, [currentUserName, debouncedSetItemFilter]);
1130
1239
  const filterLabelClass = "text-[12px] font-medium text-neutral-grey-50";
1131
1240
  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) => ({
1241
+ 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
1242
  ...prev,
1136
1243
  dateRange: value,
1137
1244
  })), 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) => ({
@@ -1175,11 +1282,17 @@ export function TranslationBatchFiltersSidebar() {
1175
1282
  })), 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
1283
  ...prev,
1177
1284
  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) => {
1285
+ })), 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) => ({
1286
+ ...prev,
1287
+ store: storeId,
1288
+ language: itemFilterLanguage(storeId),
1289
+ })), stores: model?.stores ?? [] }), _jsxs("div", { className: "relative", children: [_jsx(Input, { value: itemIdOrPathInput, disabled: !filterStore || !filterLanguage, onChange: (e) => {
1179
1290
  const next = e.target.value;
1180
1291
  setTranslationBatchItemInput(next);
1181
1292
  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: () => {
1293
+ }, placeholder: filterStore && !filterLanguage
1294
+ ? "Open an item of this store"
1295
+ : "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
1296
  setTranslationBatchItemInput("");
1184
1297
  debouncedSetItemFilter.cancel();
1185
1298
  setTranslationBatchFilters((prev) => ({
@@ -1187,18 +1300,21 @@ export function TranslationBatchFiltersSidebar() {
1187
1300
  itemIdOrPath: "",
1188
1301
  itemIncludeSubitems: false,
1189
1302
  }));
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) => {
1303
+ }, 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
1304
  const picked = items?.[0];
1194
1305
  if (!picked)
1195
1306
  return;
1196
- const applyValue = (value) => {
1197
- setTranslationBatchItemInput(value);
1307
+ // multi-cms cftree-2: a picked item filters by its id — the one address every store
1308
+ // resolves (a Contentful block's or asset's place is shown only, and a page's slug path
1309
+ // can name two pages) — while the box shows its path where it has one.
1310
+ const applyValue = (shown) => {
1311
+ setTranslationBatchItemInput(shown);
1198
1312
  debouncedSetItemFilter.cancel();
1199
1313
  setTranslationBatchFilters((prev) => ({
1200
1314
  ...prev,
1201
- itemIdOrPath: value,
1315
+ itemIdOrPath: picked.id,
1316
+ store: picked.database,
1317
+ language: picked.language,
1202
1318
  }));
1203
1319
  setItemPickerOpen(false);
1204
1320
  };
@@ -1209,7 +1325,8 @@ export function TranslationBatchFiltersSidebar() {
1209
1325
  fetchItemStubs([
1210
1326
  {
1211
1327
  id: picked.id,
1212
- language: "en",
1328
+ language: picked.language,
1329
+ database: picked.database,
1213
1330
  version: 1,
1214
1331
  },
1215
1332
  ])
@@ -1218,7 +1335,7 @@ export function TranslationBatchFiltersSidebar() {
1218
1335
  applyValue(stubPath || picked.id);
1219
1336
  })
1220
1337
  .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"] }) })] }) })] }));
1338
+ } })) })] })] })] })] })] }), _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
1339
  }
1223
1340
  function isLikelyGuid(value) {
1224
1341
  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 +1641,8 @@ function InlineLanguageJobChips({ batchId, batchProvider, jobs, languageMap, isE
1524
1641
  ? undefined
1525
1642
  : { maxHeight: firstRowHeight ?? COLLAPSED_CHIP_ROW_HEIGHT_PX }, children: jobs.map((job, idx) => {
1526
1643
  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}`));
1644
+ const retryKey = `job:${job.id ?? `${translationItemKey(job)}:${job.sourceLanguage}:${job.targetLanguage}`}`;
1645
+ 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
1646
  }) }), !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
1647
  event.stopPropagation();
1531
1648
  onToggle();
@@ -1569,7 +1686,7 @@ function CustomPromptPanel({ prompts }) {
1569
1686
  }, 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
1687
  }) }));
1571
1688
  }
1572
- function BatchItemList({ batchId, batchProvider, jobs, isLoading, expandedItems, languages, currentLanguage, itemFilter, itemIncludeSubitems, statusFilter, batchIsTerminal, batchStartedAtUtc, abortingJobIds, retryingKeys, isMobile = false, onToggleItem, onOpenItem, onAbortJob, onRetryJobs, }) {
1689
+ 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
1690
  const languageMap = React.useMemo(() => {
1574
1691
  const map = new Map();
1575
1692
  for (const l of languages) {
@@ -1600,6 +1717,7 @@ function BatchItemList({ batchId, batchProvider, jobs, isLoading, expandedItems,
1600
1717
  const filter = itemFilter.trim();
1601
1718
  if (!filter)
1602
1719
  return effectiveJobs;
1720
+ const scopedJobs = effectiveJobs.filter((job) => !!itemFilterStore && job.store === itemFilterStore);
1603
1721
  // When subitems is enabled and the filter is a GUID, derive the root path
1604
1722
  // from any job in this batch that matches the GUID — then fall through to
1605
1723
  // prefix-matching on path. If no such job is in the batch we keep only
@@ -1609,29 +1727,29 @@ function BatchItemList({ batchId, batchProvider, jobs, isLoading, expandedItems,
1609
1727
  if (isLikelyGuid(filter)) {
1610
1728
  const normalized = normalizeGuid(filter);
1611
1729
  if (itemIncludeSubitems) {
1612
- const rootJob = effectiveJobs.find((j) => normalizeGuid((j.itemId || "").toString()) === normalized);
1730
+ const rootJob = scopedJobs.find((j) => normalizeGuid((j.itemId || "").toString()) === normalized);
1613
1731
  pathPrefix = rootJob?.itemPath ? rootJob.itemPath.toLowerCase() : null;
1614
1732
  }
1615
1733
  if (!pathPrefix) {
1616
- return effectiveJobs.filter((j) => normalizeGuid((j.itemId || "").toString()) === normalized);
1734
+ return scopedJobs.filter((j) => normalizeGuid((j.itemId || "").toString()) === normalized);
1617
1735
  }
1618
1736
  }
1619
1737
  else if (filter.startsWith("/")) {
1620
1738
  pathPrefix = filter.toLowerCase();
1621
1739
  }
1622
1740
  else {
1623
- return effectiveJobs;
1741
+ return scopedJobs;
1624
1742
  }
1625
1743
  if (itemIncludeSubitems) {
1626
1744
  const prefix = pathPrefix;
1627
1745
  const prefixSlash = prefix.endsWith("/") ? prefix : prefix + "/";
1628
- return effectiveJobs.filter((j) => {
1746
+ return scopedJobs.filter((j) => {
1629
1747
  const p = (j.itemPath || "").toLowerCase();
1630
1748
  return p === prefix || p.startsWith(prefixSlash);
1631
1749
  });
1632
1750
  }
1633
- return effectiveJobs.filter((j) => (j.itemPath || "").toLowerCase() === pathPrefix);
1634
- }, [effectiveJobs, itemFilter, itemIncludeSubitems]);
1751
+ return scopedJobs.filter((j) => (j.itemPath || "").toLowerCase() === pathPrefix);
1752
+ }, [effectiveJobs, itemFilter, itemFilterStore, itemIncludeSubitems]);
1635
1753
  // Keep all jobs of items that have at least one job matching the selected status —
1636
1754
  // this way the per-item language overview stays intact even when filtering.
1637
1755
  const statusFilteredJobs = React.useMemo(() => {
@@ -1643,12 +1761,12 @@ function BatchItemList({ batchId, batchProvider, jobs, isLoading, expandedItems,
1643
1761
  const matchingItemIds = new Set();
1644
1762
  for (const j of filteredJobs) {
1645
1763
  if (j.status === targetDbStatus) {
1646
- matchingItemIds.add((j.itemId || "").toString().toLowerCase());
1764
+ matchingItemIds.add(translationItemKey(j));
1647
1765
  }
1648
1766
  }
1649
1767
  if (matchingItemIds.size === 0)
1650
1768
  return [];
1651
- return filteredJobs.filter((j) => matchingItemIds.has((j.itemId || "").toString().toLowerCase()));
1769
+ return filteredJobs.filter((j) => matchingItemIds.has(translationItemKey(j)));
1652
1770
  }, [filteredJobs, statusFilter]);
1653
1771
  const [stackLanguageChips, setStackLanguageChips] = React.useState(isMobile);
1654
1772
  const itemTableContainerRef = React.useRef(null);
@@ -1712,7 +1830,7 @@ function BatchItemList({ batchId, batchProvider, jobs, isLoading, expandedItems,
1712
1830
  }
1713
1831
  const byItem = new Map();
1714
1832
  for (const job of statusFilteredJobs) {
1715
- const key = (job.itemId ?? "").toString().toLowerCase();
1833
+ const key = translationItemKey(job);
1716
1834
  if (!byItem.has(key))
1717
1835
  byItem.set(key, []);
1718
1836
  byItem.get(key).push(job);
@@ -1727,8 +1845,8 @@ function BatchItemList({ batchId, batchProvider, jobs, isLoading, expandedItems,
1727
1845
  const itemPath = firstJob?.itemPath ?? null;
1728
1846
  const serverName = firstJob?.itemName ?? null;
1729
1847
  const metadataName = parseItemName(firstJob?.metadata, "");
1730
- const displayName = serverName || metadataName || itemId;
1731
- const titleAttr = `${itemPath ?? ""}\n${itemId}`.trim();
1848
+ const displayName = serverName || metadataName || firstJob?.itemId;
1849
+ const titleAttr = `${firstJob?.store || "Legacy row: store unavailable; editor navigation and retry disabled"}\n${itemPath ?? ""}\n${firstJob?.itemId}`.trim();
1732
1850
  const itemErrorJobs = itemJobs.filter(isRetriableJob);
1733
1851
  const itemRetryKey = `item:${batchId}:${itemId}`;
1734
1852
  const isRetryingItem = retryingKeys.has(itemRetryKey);
@@ -1747,13 +1865,16 @@ function BatchItemList({ batchId, batchProvider, jobs, isLoading, expandedItems,
1747
1865
  }, 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
1866
  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
1867
  ? { 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);
1868
+ : 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 ||
1869
+ "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 }))] })] }));
1870
+ 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: () => {
1871
+ if (firstJob?.store)
1872
+ void onOpenItem(firstJob.itemId, rowOpenLanguage, firstJob.store);
1753
1873
  }, onKeyDown: (e) => {
1754
1874
  if (e.key === "Enter" || e.key === " ") {
1755
1875
  e.preventDefault();
1756
- void onOpenItem(itemId, rowOpenLanguage);
1876
+ if (firstJob?.store)
1877
+ void onOpenItem(firstJob.itemId, rowOpenLanguage, firstJob.store);
1757
1878
  }
1758
1879
  }, 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
1880
  }) })] }) }));
@@ -1854,7 +1975,7 @@ function LanguageJobChip({ job, language, provider, batchStartedAtUtc, onOpen, i
1854
1975
  const emptyFieldText = statistics && statistics.emptyFieldCount > 0
1855
1976
  ? `${formatCount(statistics.emptyFieldCount)} empty`
1856
1977
  : 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
1978
+ 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
1979
  ? "Stalled"
1859
1980
  : jobInProgress || jobPending
1860
1981
  ? "Running"
@@ -1883,11 +2004,13 @@ function LanguageJobChip({ job, language, provider, batchStartedAtUtc, onOpen, i
1883
2004
  e.stopPropagation();
1884
2005
  void onAbort?.();
1885
2006
  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) => {
2007
+ }, 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
2008
  e.stopPropagation();
1888
2009
  void onRetry();
1889
2010
  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) => {
2011
+ }, 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
2012
+ ? "Legacy row has no content store; navigation is unavailable."
2013
+ : undefined, onClick: (e) => {
1891
2014
  e.stopPropagation();
1892
2015
  void onOpen();
1893
2016
  setOpen(false);