@optifye/dashboard-core 4.3.6 → 4.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -434,6 +434,25 @@ var getTable2 = (dbConfig, tableName) => {
434
434
  return userValue ?? defaults2[tableName];
435
435
  };
436
436
  var dashboardService = {
437
+ /**
438
+ * Helper method to filter workspaces by line_id for disambiguation
439
+ * @param workspaces - Array of workspace metrics
440
+ * @param lineId - Line ID to filter by
441
+ * @returns Filtered workspace metrics
442
+ */
443
+ filterWorkspacesByLineId(workspaces, lineId) {
444
+ return workspaces.filter((workspace) => workspace.line_id === lineId);
445
+ },
446
+ /**
447
+ * Helper method to get workspace by composite key (line_id + workspace_name)
448
+ * @param workspaces - Array of workspace metrics
449
+ * @param workspaceName - Workspace name to search for
450
+ * @param lineId - Line ID to filter by
451
+ * @returns Matching workspace or undefined
452
+ */
453
+ getWorkspaceByLineIdAndName(workspaces, workspaceName, lineId) {
454
+ return workspaces.find((workspace) => workspace.workspace_name === workspaceName && workspace.line_id === lineId);
455
+ },
437
456
  // Example for getLineInfo:
438
457
  async getLineInfo(lineIdInput) {
439
458
  const supabase = _getSupabaseInstance();
@@ -594,6 +613,13 @@ var dashboardService = {
594
613
  metrics: metricsForReturn
595
614
  };
596
615
  },
616
+ /**
617
+ * Get workspace data with line_id-aware filtering
618
+ * @param lineIdInput - Specific line ID to filter by, or factory view ID
619
+ * @param dateProp - Date to query (optional)
620
+ * @param shiftProp - Shift ID to query (optional)
621
+ * @returns Array of workspace metrics with line_id context
622
+ */
597
623
  async getWorkspacesData(lineIdInput, dateProp, shiftProp) {
598
624
  const supabase = _getSupabaseInstance();
599
625
  const config = _getDashboardConfigInstance();
@@ -620,17 +646,20 @@ var dashboardService = {
620
646
  throw new Error("Factory View requires defaultLineId and secondaryLineId to be configured for workspace data.");
621
647
  }
622
648
  query = query.in("line_id", [defaultLineId, secondaryLineId]);
649
+ console.log(`[getWorkspacesData] Querying factory view with lines: ${defaultLineId}, ${secondaryLineId}`);
623
650
  } else {
624
651
  query = query.eq("line_id", lineId);
652
+ console.log(`[getWorkspacesData] Querying single line: ${lineId}`);
625
653
  }
626
654
  const { data, error } = await query;
627
655
  if (error) {
628
656
  console.error("Error in getWorkspacesData:", error);
629
657
  throw error;
630
658
  }
631
- return (data || []).map((item) => ({
659
+ const workspaces = (data || []).map((item) => ({
632
660
  company_id: item.company_id,
633
661
  line_id: item.line_id,
662
+ // Ensure line_id is always included
634
663
  shift_id: item.shift_id,
635
664
  date: item.date,
636
665
  workspace_uuid: item.workspace_id,
@@ -644,6 +673,20 @@ var dashboardService = {
644
673
  efficiency: item.efficiency || 0,
645
674
  action_threshold: item.total_day_output || 0
646
675
  }));
676
+ console.log(`[getWorkspacesData] Retrieved ${workspaces.length} workspaces for line(s): ${lineId || "factory"}`);
677
+ console.log(
678
+ `[getWorkspacesData] Workspace line_id distribution:`,
679
+ workspaces.reduce((acc, ws) => {
680
+ acc[ws.line_id] = (acc[ws.line_id] || 0) + 1;
681
+ return acc;
682
+ }, {})
683
+ );
684
+ console.log(`[getWorkspacesData] Sample workspaces:`, workspaces.slice(0, 5).map((ws) => ({
685
+ workspace_name: ws.workspace_name,
686
+ line_id: ws.line_id,
687
+ efficiency: ws.efficiency
688
+ })));
689
+ return workspaces;
647
690
  },
648
691
  async getWorkspaceDetailedMetrics(workspaceUuid, dateProp, shiftIdProp) {
649
692
  const supabase = _getSupabaseInstance();
@@ -1876,8 +1919,8 @@ var SSEChatClient = class {
1876
1919
  user_id: userId,
1877
1920
  context
1878
1921
  });
1879
- const agnoApiUrl = this.baseUrl || "https://optifye-agent-production.up.railway.app";
1880
- const endpoint = `${agnoApiUrl}/api/chat`;
1922
+ const agnoApiUrl = this.baseUrl || "https://fastapi-production-111f9.up.railway.app";
1923
+ const endpoint = `${agnoApiUrl}/api/v2/chat`;
1881
1924
  console.log("[SSEClient] Posting directly to AGNO:", endpoint);
1882
1925
  const response = await fetch(endpoint, {
1883
1926
  method: "POST",
@@ -1935,7 +1978,7 @@ var SSEChatClient = class {
1935
1978
  const decoder = new TextDecoder();
1936
1979
  let buffer = "";
1937
1980
  try {
1938
- console.log("[SSEClient] Starting to read stream...");
1981
+ console.log("[SSEClient] Starting to read enhanced stream...");
1939
1982
  while (true) {
1940
1983
  const { done, value } = await reader.read();
1941
1984
  if (done) {
@@ -1965,11 +2008,14 @@ var SSEChatClient = class {
1965
2008
  case "message":
1966
2009
  callbacks.onMessage?.(data.text);
1967
2010
  break;
1968
- case "reasoning":
1969
- callbacks.onReasoning?.(data.text);
2011
+ case "tool_call":
2012
+ callbacks.onToolCall?.(data.tools);
2013
+ break;
2014
+ case "tool_result":
2015
+ callbacks.onToolResult?.(data.results);
1970
2016
  break;
1971
2017
  case "complete":
1972
- callbacks.onComplete?.(data.message_id);
2018
+ callbacks.onComplete?.(data.message_id, data.metrics);
1973
2019
  break;
1974
2020
  case "error":
1975
2021
  callbacks.onError?.(data.error);
@@ -2509,7 +2555,7 @@ var useMetrics = (tableName, options) => {
2509
2555
  };
2510
2556
  return { data, isLoading, error, refetch };
2511
2557
  };
2512
- var useWorkspaceDetailedMetrics = (workspaceId, date, shiftId) => {
2558
+ var useWorkspaceDetailedMetrics = (workspaceId, date, shiftId, lineId) => {
2513
2559
  const entityConfig = useEntityConfig();
2514
2560
  const databaseConfig = useDatabaseConfig();
2515
2561
  const dateTimeConfig = useDateTimeConfig();
@@ -2537,14 +2583,32 @@ var useWorkspaceDetailedMetrics = (workspaceId, date, shiftId) => {
2537
2583
  const currentShift = getCurrentShift(defaultTimezone, shiftConfig);
2538
2584
  const queryDate = date || currentShift.date;
2539
2585
  const queryShiftId = shiftId !== void 0 ? shiftId : currentShift.shiftId;
2586
+ console.log("[useWorkspaceDetailedMetrics] Hook called with parameters:", {
2587
+ workspaceId,
2588
+ date,
2589
+ shiftId,
2590
+ lineId,
2591
+ queryDate,
2592
+ queryShiftId
2593
+ });
2540
2594
  console.log("[useWorkspaceDetailedMetrics] Using shift ID:", queryShiftId, "from input shift:", shiftId);
2541
2595
  console.log("[useWorkspaceDetailedMetrics] Using date:", queryDate, "from input date:", date);
2542
- console.log(`[useWorkspaceDetailedMetrics] Querying ${metricsTable} for workspace: ${workspaceId}, date: ${queryDate}, shift: ${queryShiftId}`);
2543
- const { data, error: fetchError } = await supabase.from(metricsTable).select("*").eq("workspace_id", workspaceId).eq("date", queryDate).eq("shift_id", queryShiftId).maybeSingle();
2596
+ console.log(`[useWorkspaceDetailedMetrics] Querying ${metricsTable} for workspace: ${workspaceId}, date: ${queryDate}, shift: ${queryShiftId}, line: ${lineId || "any"}`);
2597
+ let query = supabase.from(metricsTable).select("*").eq("workspace_id", workspaceId).eq("date", queryDate).eq("shift_id", queryShiftId);
2598
+ if (lineId) {
2599
+ query = query.eq("line_id", lineId);
2600
+ console.log(`[useWorkspaceDetailedMetrics] Filtering by line_id: ${lineId}`);
2601
+ }
2602
+ const { data, error: fetchError } = await query.maybeSingle();
2544
2603
  if (fetchError) throw fetchError;
2545
2604
  if (!data && !date && shiftId === void 0) {
2546
2605
  console.log("[useWorkspaceDetailedMetrics] No data found for current date/shift, attempting to find most recent data...");
2547
- const { data: recentData, error: recentError } = await supabase.from(metricsTable).select("*").eq("workspace_id", workspaceId).order("date", { ascending: false }).order("shift_id", { ascending: false }).limit(1).maybeSingle();
2606
+ let recentQuery = supabase.from(metricsTable).select("*").eq("workspace_id", workspaceId);
2607
+ if (lineId) {
2608
+ recentQuery = recentQuery.eq("line_id", lineId);
2609
+ console.log(`[useWorkspaceDetailedMetrics] Fallback query filtering by line_id: ${lineId}`);
2610
+ }
2611
+ const { data: recentData, error: recentError } = await recentQuery.order("date", { ascending: false }).order("shift_id", { ascending: false }).limit(1).maybeSingle();
2548
2612
  if (recentError) throw recentError;
2549
2613
  if (recentData) {
2550
2614
  console.log(`[useWorkspaceDetailedMetrics] Found fallback data from date: ${recentData.date}, shift: ${recentData.shift_id}`);
@@ -2762,7 +2826,7 @@ var useWorkspaceDetailedMetrics = (workspaceId, date, shiftId) => {
2762
2826
  updateQueueRef.current = false;
2763
2827
  setIsLoading(false);
2764
2828
  }
2765
- }, [supabase, workspaceId, date, shiftId, metricsTable, defaultTimezone, shiftConfig, workspaceConfig, companyId]);
2829
+ }, [supabase, workspaceId, date, shiftId, lineId, metricsTable, defaultTimezone, shiftConfig, workspaceConfig, companyId]);
2766
2830
  const queueUpdate = useCallback(() => {
2767
2831
  if (!workspaceId || updateQueueRef.current) return;
2768
2832
  updateQueueRef.current = true;
@@ -2893,7 +2957,7 @@ var useWorkspaceDetailedMetrics = (workspaceId, date, shiftId) => {
2893
2957
  supabase.removeChannel(channelRef.current);
2894
2958
  }
2895
2959
  };
2896
- }, [supabase, workspaceId, date, shiftId, fetchMetrics, queueUpdate, setupSubscription, metricsTable, workspaceMetricsBaseTable, workspaceActionsTable, defaultTimezone, shiftConfig, schema, metricsTablePrefix]);
2960
+ }, [supabase, workspaceId, date, shiftId, lineId, fetchMetrics, queueUpdate, setupSubscription, metricsTable, workspaceMetricsBaseTable, workspaceActionsTable, defaultTimezone, shiftConfig, schema, metricsTablePrefix]);
2897
2961
  return {
2898
2962
  metrics: metrics2,
2899
2963
  isLoading,
@@ -3355,6 +3419,7 @@ var setCache = (lineId, metrics2) => {
3355
3419
  }
3356
3420
  };
3357
3421
  var useDashboardMetrics = ({ onLineMetricsUpdate, lineId }) => {
3422
+ console.log("[useDashboardMetrics] Hook called with lineId:", lineId);
3358
3423
  const { supabaseUrl, supabaseKey } = useDashboardConfig();
3359
3424
  const entityConfig = useEntityConfig();
3360
3425
  const databaseConfig = useDatabaseConfig();
@@ -3398,14 +3463,33 @@ var useDashboardMetrics = ({ onLineMetricsUpdate, lineId }) => {
3398
3463
  try {
3399
3464
  const currentShiftDetails = getCurrentShift(defaultTimezone, shiftConfig);
3400
3465
  const operationalDate = getOperationalDate(defaultTimezone);
3401
- const targetLineIds = currentLineIdToUse === (entityConfig.factoryViewId || "factory") ? [entityConfig.defaultLineId, entityConfig.secondaryLineId].filter((id3) => !!id3) : [currentLineIdToUse];
3466
+ const isFactoryView = currentLineIdToUse === (entityConfig.factoryViewId || "factory");
3467
+ const targetLineIds = isFactoryView ? [entityConfig.defaultLineId, entityConfig.secondaryLineId].filter((id3) => !!id3) : [currentLineIdToUse];
3468
+ console.log("[useDashboardMetrics] Target line IDs determined:", {
3469
+ currentLineIdToUse,
3470
+ isFactoryView,
3471
+ factoryViewId: entityConfig.factoryViewId,
3472
+ defaultLineId: entityConfig.defaultLineId,
3473
+ secondaryLineId: entityConfig.secondaryLineId,
3474
+ targetLineIds
3475
+ });
3402
3476
  if (targetLineIds.length === 0 && currentLineIdToUse === (entityConfig.factoryViewId || "factory")) {
3403
3477
  throw new Error("Factory view selected, but defaultLineId and/or secondaryLineId are not configured in entityConfig.");
3404
3478
  }
3405
3479
  if (targetLineIds.length === 0) {
3406
3480
  throw new Error("No target line IDs available for fetching metrics.");
3407
3481
  }
3482
+ console.log("[useDashboardMetrics] Executing workspace query with line IDs:", targetLineIds, "Date:", operationalDate, "ShiftID:", currentShiftDetails.shiftId, "Table:", companySpecificMetricsTable);
3408
3483
  const { data: workspaceData, error: workspaceError } = await supabase.from(companySpecificMetricsTable).select("company_id,line_id,shift_id,date,workspace_id,workspace_name,total_output,avg_pph,performance_score,avg_cycle_time,trend_score,ideal_output,efficiency,total_day_output").eq("date", operationalDate).eq("shift_id", currentShiftDetails.shiftId).in("line_id", targetLineIds);
3484
+ console.log("[useDashboardMetrics] Workspace query result:", {
3485
+ dataCount: workspaceData?.length || 0,
3486
+ error: workspaceError,
3487
+ sampleData: workspaceData?.slice(0, 3).map((w) => ({
3488
+ workspace_name: w.workspace_name,
3489
+ line_id: w.line_id,
3490
+ efficiency: w.efficiency
3491
+ }))
3492
+ });
3409
3493
  if (workspaceError) {
3410
3494
  throw workspaceError;
3411
3495
  }
@@ -4777,12 +4861,16 @@ function getCurrentLineIds() {
4777
4861
  try {
4778
4862
  const config = _getDashboardConfigInstance();
4779
4863
  const entityConfig = config?.entityConfig;
4864
+ console.log("\u{1F504} Dashboard config:", config);
4865
+ console.log("\u{1F504} Entity config:", entityConfig);
4780
4866
  const lineIds = [];
4781
4867
  if (entityConfig?.defaultLineId) {
4782
4868
  lineIds.push(entityConfig.defaultLineId);
4869
+ console.log("\u{1F504} Added defaultLineId:", entityConfig.defaultLineId);
4783
4870
  }
4784
4871
  if (entityConfig?.secondaryLineId) {
4785
4872
  lineIds.push(entityConfig.secondaryLineId);
4873
+ console.log("\u{1F504} Added secondaryLineId:", entityConfig.secondaryLineId);
4786
4874
  }
4787
4875
  console.log("\u{1F504} Current line IDs from config:", lineIds);
4788
4876
  return lineIds;
@@ -4800,15 +4888,22 @@ async function initializeWorkspaceDisplayNames(explicitLineId) {
4800
4888
  let targetLineIds = [];
4801
4889
  if (explicitLineId) {
4802
4890
  targetLineIds = [explicitLineId];
4891
+ console.log("\u{1F504} Using explicit lineId:", explicitLineId);
4803
4892
  } else {
4804
4893
  targetLineIds = getCurrentLineIds();
4894
+ console.log("\u{1F504} Using line IDs from config:", targetLineIds);
4805
4895
  }
4806
4896
  console.log("\u{1F504} Target line IDs for workspace filtering:", targetLineIds);
4807
4897
  const allDisplayNamesMap = /* @__PURE__ */ new Map();
4898
+ console.log("\u{1F504} About to fetch workspaces for lines:", targetLineIds);
4808
4899
  if (targetLineIds.length > 0) {
4809
4900
  for (const lineId of targetLineIds) {
4810
4901
  console.log(`\u{1F504} Fetching workspaces for line: ${lineId}`);
4811
4902
  const lineDisplayNamesMap = await workspaceService.getWorkspaceDisplayNames(void 0, lineId);
4903
+ console.log(
4904
+ `\u{1F504} Retrieved ${lineDisplayNamesMap.size} workspaces for line ${lineId}:`,
4905
+ Array.from(lineDisplayNamesMap.entries()).slice(0, 5)
4906
+ );
4812
4907
  lineDisplayNamesMap.forEach((displayName, workspaceId) => {
4813
4908
  allDisplayNamesMap.set(workspaceId, displayName);
4814
4909
  });
@@ -4820,6 +4915,7 @@ async function initializeWorkspaceDisplayNames(explicitLineId) {
4820
4915
  allDisplayNamesMap.set(workspaceId, displayName);
4821
4916
  });
4822
4917
  }
4918
+ console.log("\u{1F504} Final combined display names map size:", allDisplayNamesMap.size);
4823
4919
  runtimeWorkspaceDisplayNames = {};
4824
4920
  allDisplayNamesMap.forEach((displayName, workspaceId) => {
4825
4921
  runtimeWorkspaceDisplayNames[workspaceId] = displayName;
@@ -4847,6 +4943,7 @@ var forceRefreshWorkspaceDisplayNames = async (lineId) => {
4847
4943
  };
4848
4944
  console.log("\u{1F504} Module loaded, will initialize lazily when first function is called");
4849
4945
  var getWorkspaceDisplayName = (workspaceId, lineId) => {
4946
+ console.log(`\u{1F504} [DEBUG] getWorkspaceDisplayName called with:`, { workspaceId, lineId, isInitialized, isInitializing });
4850
4947
  if (!isInitialized && !isInitializing) {
4851
4948
  console.log(`\u{1F504} [DEBUG] getWorkspaceDisplayName(${workspaceId}) - Not initialized, triggering lazy init...`);
4852
4949
  } else if (isInitializing) {
@@ -4858,6 +4955,14 @@ var getWorkspaceDisplayName = (workspaceId, lineId) => {
4858
4955
  console.error("\u274C Lazy initialization failed:", error);
4859
4956
  });
4860
4957
  }
4958
+ if (lineId) {
4959
+ const lineSpecificKey = `${lineId}_${workspaceId}`;
4960
+ const lineSpecificDisplayName = runtimeWorkspaceDisplayNames[lineSpecificKey];
4961
+ if (lineSpecificDisplayName) {
4962
+ console.log(`getWorkspaceDisplayName(${workspaceId}, ${lineId}) -> ${lineSpecificDisplayName} (line-specific from Supabase)`);
4963
+ return lineSpecificDisplayName;
4964
+ }
4965
+ }
4861
4966
  const displayName = runtimeWorkspaceDisplayNames[workspaceId];
4862
4967
  if (displayName) {
4863
4968
  console.log(`getWorkspaceDisplayName(${workspaceId}) -> ${displayName} (from Supabase)`);
@@ -4878,6 +4983,14 @@ var getShortWorkspaceDisplayName = (workspaceId, lineId) => {
4878
4983
  console.error("\u274C Lazy initialization failed:", error);
4879
4984
  });
4880
4985
  }
4986
+ if (lineId) {
4987
+ const lineSpecificKey = `${lineId}_${workspaceId}`;
4988
+ const lineSpecificDisplayName = runtimeWorkspaceDisplayNames[lineSpecificKey];
4989
+ if (lineSpecificDisplayName) {
4990
+ console.log(`getShortWorkspaceDisplayName(${workspaceId}, ${lineId}) -> ${lineSpecificDisplayName} (line-specific from Supabase)`);
4991
+ return lineSpecificDisplayName;
4992
+ }
4993
+ }
4881
4994
  const displayName = runtimeWorkspaceDisplayNames[workspaceId];
4882
4995
  if (displayName) {
4883
4996
  console.log(`getShortWorkspaceDisplayName(${workspaceId}) -> ${displayName} (from Supabase)`);
@@ -7952,18 +8065,36 @@ function cn(...inputs) {
7952
8065
  }
7953
8066
 
7954
8067
  // src/lib/utils/urlMapping.ts
7955
- var toUrlFriendlyName = (workspaceName) => {
8068
+ var toUrlFriendlyName = (workspaceName, lineId) => {
7956
8069
  if (!workspaceName) throw new Error("Workspace name is required");
7957
- return workspaceName.toLowerCase().replace(/\s+/g, "-");
8070
+ const baseName = workspaceName.toLowerCase().replace(/\s+/g, "-");
8071
+ return lineId ? `${lineId}-${baseName}` : baseName;
8072
+ };
8073
+ var fromUrlFriendlyName = (urlName) => {
8074
+ const parts = urlName.split("-");
8075
+ if (parts.length >= 2 && (parts[0].startsWith("line") || parts[0].length === 36)) {
8076
+ return {
8077
+ lineId: parts[0],
8078
+ workspaceName: parts.slice(1).join("-").toUpperCase()
8079
+ };
8080
+ }
8081
+ return { workspaceName: urlName.toUpperCase() };
7958
8082
  };
7959
- var fromUrlFriendlyName = (urlName) => urlName.toUpperCase();
7960
8083
  var storeWorkspaceMapping = (mapping) => {
7961
8084
  const mappings = getStoredWorkspaceMappings();
7962
- mappings[mapping.urlName] = mapping;
8085
+ const key = mapping.lineId ? `${mapping.lineId}_${mapping.urlName}` : mapping.urlName;
8086
+ mappings[key] = mapping;
7963
8087
  sessionStorage.setItem("workspaceMappings", JSON.stringify(mappings));
7964
8088
  };
7965
- var getWorkspaceFromUrl = (urlName) => {
8089
+ var getWorkspaceFromUrl = (urlName, lineId) => {
7966
8090
  const mappings = getStoredWorkspaceMappings();
8091
+ if (lineId) {
8092
+ const lineSpecificKey = `${lineId}_${urlName}`;
8093
+ const lineSpecificMapping = mappings[lineSpecificKey];
8094
+ if (lineSpecificMapping) {
8095
+ return lineSpecificMapping;
8096
+ }
8097
+ }
7967
8098
  return mappings[urlName] || null;
7968
8099
  };
7969
8100
  var getStoredWorkspaceMappings = () => {
@@ -7974,6 +8105,26 @@ var getStoredWorkspaceMappings = () => {
7974
8105
  return {};
7975
8106
  }
7976
8107
  };
8108
+ var getWorkspaceMappingsForLine = (lineId) => {
8109
+ const allMappings = getStoredWorkspaceMappings();
8110
+ const lineMappings = {};
8111
+ Object.entries(allMappings).forEach(([key, mapping]) => {
8112
+ if (mapping.lineId === lineId) {
8113
+ lineMappings[key] = mapping;
8114
+ }
8115
+ });
8116
+ return lineMappings;
8117
+ };
8118
+ var clearWorkspaceMappingsForLine = (lineId) => {
8119
+ const allMappings = getStoredWorkspaceMappings();
8120
+ const filteredMappings = {};
8121
+ Object.entries(allMappings).forEach(([key, mapping]) => {
8122
+ if (mapping.lineId !== lineId) {
8123
+ filteredMappings[key] = mapping;
8124
+ }
8125
+ });
8126
+ sessionStorage.setItem("workspaceMappings", JSON.stringify(filteredMappings));
8127
+ };
7977
8128
 
7978
8129
  // src/lib/utils/workspacePreferences.ts
7979
8130
  var getDefaultTabForWorkspace = (workspaceId, displayName) => {
@@ -17468,6 +17619,7 @@ var VideoCard = React14__default.memo(({
17468
17619
  });
17469
17620
  VideoCard.displayName = "VideoCard";
17470
17621
  var DEFAULT_WORKSPACE_HLS_URLS = {
17622
+ // Line-agnostic fallbacks
17471
17623
  "WS1": "https://dnh-hls.optifye.ai/cam1/index.m3u8",
17472
17624
  "WS2": "https://dnh-hls.optifye.ai/cam2/index.m3u8",
17473
17625
  "WS3": "https://dnh-hls.optifye.ai/cam3/index.m3u8",
@@ -17478,6 +17630,9 @@ var DEFAULT_WORKSPACE_HLS_URLS = {
17478
17630
  "WS04": "https://59.144.218.58:8443/camera4.m3u8",
17479
17631
  "WS05": "https://59.144.218.58:8443/camera1.m3u8",
17480
17632
  "WS06": "https://59.144.218.58:8443/camera5.m3u8"
17633
+ // Line-specific mappings (line_id_workspaceName format)
17634
+ // Example: '98a2287e-8d55-4020-b00d-b9940437e3e1_WS1': 'https://line1-hls.optifye.ai/cam1/index.m3u8',
17635
+ // Example: 'd93997bb-ecac-4478-a4a6-008d536b724c_WS1': 'https://line2-hls.optifye.ai/cam1/index.m3u8',
17481
17636
  };
17482
17637
  var DEFAULT_HLS_URL = "https://192.168.5.9:8443/cam1.m3u8";
17483
17638
  var VideoGridView = React14__default.memo(({
@@ -17485,7 +17640,8 @@ var VideoGridView = React14__default.memo(({
17485
17640
  selectedLine,
17486
17641
  className = "",
17487
17642
  lineIdMapping = {},
17488
- videoSources = {}
17643
+ videoSources = {},
17644
+ targetLineId
17489
17645
  }) => {
17490
17646
  const router = useRouter();
17491
17647
  const containerRef = useRef(null);
@@ -17493,14 +17649,38 @@ var VideoGridView = React14__default.memo(({
17493
17649
  const [gridCols, setGridCols] = useState(4);
17494
17650
  const [visibleWorkspaces, setVisibleWorkspaces] = useState(/* @__PURE__ */ new Set());
17495
17651
  const videoConfig = useVideoConfig();
17652
+ const entityConfig = useEntityConfig();
17496
17653
  const { cropping, canvasConfig } = videoConfig;
17654
+ const defaultLineId = entityConfig.defaultLineId;
17655
+ const secondaryLineId = entityConfig.secondaryLineId;
17656
+ console.log("[VideoGridView] Line configuration:", {
17657
+ defaultLineId,
17658
+ secondaryLineId,
17659
+ selectedLine,
17660
+ targetLineId,
17661
+ totalWorkspaces: workspaces.length
17662
+ });
17497
17663
  const mergedVideoSources = {
17498
17664
  defaultHlsUrl: videoSources.defaultHlsUrl || DEFAULT_HLS_URL,
17499
17665
  workspaceHlsUrls: { ...DEFAULT_WORKSPACE_HLS_URLS, ...videoSources.workspaceHlsUrls }
17500
17666
  };
17501
- const getWorkspaceHlsUrl = useCallback((workspaceName) => {
17667
+ const getWorkspaceHlsUrl = useCallback((workspaceName, lineId) => {
17502
17668
  const wsName = workspaceName.toUpperCase();
17503
- return mergedVideoSources.workspaceHlsUrls[wsName] || mergedVideoSources.defaultHlsUrl;
17669
+ if (lineId) {
17670
+ const lineSpecificKey = `${lineId}_${wsName}`;
17671
+ const lineSpecificUrl = mergedVideoSources.workspaceHlsUrls[lineSpecificKey];
17672
+ console.log(`[VideoGridView] HLS URL lookup for ${wsName} (line: ${lineId}):`, {
17673
+ lineSpecificKey,
17674
+ lineSpecificUrl,
17675
+ fallbackUrl: mergedVideoSources.workspaceHlsUrls[wsName] || mergedVideoSources.defaultHlsUrl
17676
+ });
17677
+ if (lineSpecificUrl) {
17678
+ return lineSpecificUrl;
17679
+ }
17680
+ }
17681
+ const fallbackUrl = mergedVideoSources.workspaceHlsUrls[wsName] || mergedVideoSources.defaultHlsUrl;
17682
+ console.log(`[VideoGridView] HLS URL fallback for ${wsName}:`, fallbackUrl);
17683
+ return fallbackUrl;
17504
17684
  }, [mergedVideoSources]);
17505
17685
  const getWorkspaceCropping = useCallback((workspaceName) => {
17506
17686
  if (!cropping) return void 0;
@@ -17515,26 +17695,70 @@ var VideoGridView = React14__default.memo(({
17515
17695
  );
17516
17696
  }, [workspaces]);
17517
17697
  const filteredWorkspaces = useMemo(() => {
17518
- return selectedLine === 1 ? workspaces.filter((w) => {
17519
- if (w.workspace_name === "WS5-5") return true;
17520
- if (w.workspace_name === "WS32-5") return false;
17521
- try {
17522
- const wsNumber = parseInt(w.workspace_name.replace("WS", ""));
17523
- return wsNumber >= 1 && wsNumber <= 22;
17524
- } catch {
17525
- return true;
17526
- }
17527
- }) : selectedLine === 2 ? workspaces.filter((w) => {
17528
- if (w.workspace_name === "WS5-5") return false;
17529
- if (w.workspace_name === "WS32-5") return true;
17530
- try {
17531
- const wsNumber = parseInt(w.workspace_name.replace("WS", ""));
17532
- return wsNumber >= 23 && wsNumber <= 44;
17533
- } catch {
17534
- return false;
17535
- }
17536
- }) : workspaces;
17537
- }, [workspaces, selectedLine]);
17698
+ const uniqueLineIds = [...new Set(workspaces.map((w) => w.line_id))];
17699
+ console.log("[VideoGridView] Filtering workspaces:", {
17700
+ totalWorkspaces: workspaces.length,
17701
+ targetLineId,
17702
+ selectedLine,
17703
+ defaultLineId,
17704
+ secondaryLineId,
17705
+ uniqueLineIds,
17706
+ workspacesByLine: workspaces.reduce((acc, w) => {
17707
+ acc[w.line_id] = (acc[w.line_id] || 0) + 1;
17708
+ return acc;
17709
+ }, {})
17710
+ });
17711
+ console.log("[VideoGridView] Sample workspaces with line_id:", workspaces.slice(0, 5).map((w) => ({
17712
+ workspace_name: w.workspace_name,
17713
+ line_id: w.line_id,
17714
+ workspace_uuid: w.workspace_uuid
17715
+ })));
17716
+ if (targetLineId) {
17717
+ const filtered = workspaces.filter((w) => w.line_id === targetLineId);
17718
+ console.log(`[VideoGridView] Filtered by targetLineId (${targetLineId}):`, filtered.length, "workspaces");
17719
+ return filtered;
17720
+ }
17721
+ if (selectedLine === 1 && defaultLineId) {
17722
+ const filtered = workspaces.filter((w) => w.line_id === defaultLineId);
17723
+ console.log(`[VideoGridView] Filtered by selectedLine=1 (${defaultLineId}):`, filtered.length, "workspaces");
17724
+ return filtered;
17725
+ }
17726
+ if (selectedLine === 2 && secondaryLineId) {
17727
+ const filtered = workspaces.filter((w) => w.line_id === secondaryLineId);
17728
+ console.log(`[VideoGridView] Filtered by selectedLine=2 (${secondaryLineId}):`, filtered.length, "workspaces");
17729
+ return filtered;
17730
+ }
17731
+ if (selectedLine === 1) {
17732
+ const filtered = workspaces.filter((w) => {
17733
+ if (w.workspace_name === "WS5-5") return true;
17734
+ if (w.workspace_name === "WS32-5") return false;
17735
+ try {
17736
+ const wsNumber = parseInt(w.workspace_name.replace("WS", ""));
17737
+ return wsNumber >= 1 && wsNumber <= 22;
17738
+ } catch {
17739
+ return true;
17740
+ }
17741
+ });
17742
+ console.log(`[VideoGridView] Legacy filtered by selectedLine=1 (WS1-WS22):`, filtered.length, "workspaces");
17743
+ return filtered;
17744
+ }
17745
+ if (selectedLine === 2) {
17746
+ const filtered = workspaces.filter((w) => {
17747
+ if (w.workspace_name === "WS5-5") return false;
17748
+ if (w.workspace_name === "WS32-5") return true;
17749
+ try {
17750
+ const wsNumber = parseInt(w.workspace_name.replace("WS", ""));
17751
+ return wsNumber >= 23 && wsNumber <= 44;
17752
+ } catch {
17753
+ return false;
17754
+ }
17755
+ });
17756
+ console.log(`[VideoGridView] Legacy filtered by selectedLine=2 (WS23-WS44):`, filtered.length, "workspaces");
17757
+ return filtered;
17758
+ }
17759
+ console.log(`[VideoGridView] No filtering applied, returning all workspaces:`, workspaces.length);
17760
+ return workspaces;
17761
+ }, [workspaces, selectedLine, targetLineId, defaultLineId, secondaryLineId]);
17538
17762
  const calculateOptimalGrid = useCallback(() => {
17539
17763
  if (!containerRef.current) return;
17540
17764
  const containerPadding = 16;
@@ -17611,6 +17835,12 @@ var VideoGridView = React14__default.memo(({
17611
17835
  }, [filteredWorkspaces]);
17612
17836
  const handleWorkspaceClick = useCallback((workspace) => {
17613
17837
  const workspaceId = workspace.workspace_uuid || workspace.workspace_name;
17838
+ console.log("[VideoGridView] Workspace clicked:", {
17839
+ workspace_name: workspace.workspace_name,
17840
+ workspace_id: workspaceId,
17841
+ line_id: workspace.line_id,
17842
+ efficiency: workspace.efficiency
17843
+ });
17614
17844
  trackCoreEvent("Workspace Detail Clicked", {
17615
17845
  workspace_name: workspace.workspace_name,
17616
17846
  workspace_id: workspaceId,
@@ -17619,8 +17849,15 @@ var VideoGridView = React14__default.memo(({
17619
17849
  efficiency: workspace.efficiency,
17620
17850
  action_count: workspace.action_count
17621
17851
  });
17622
- const displayName = getWorkspaceDisplayName(workspace.workspace_name);
17852
+ const displayName = getWorkspaceDisplayName(workspace.workspace_name, workspace.line_id);
17623
17853
  const navParams = getWorkspaceNavigationParams(workspaceId, displayName);
17854
+ console.log("[VideoGridView] Navigation params:", {
17855
+ workspaceId,
17856
+ displayName,
17857
+ line_id: workspace.line_id,
17858
+ navParams,
17859
+ finalUrl: `/workspace/${workspaceId}${navParams}`
17860
+ });
17624
17861
  router.push(`/workspace/${workspaceId}${navParams}`);
17625
17862
  }, [router]);
17626
17863
  return /* @__PURE__ */ jsx("div", { className: `relative overflow-hidden h-full w-full ${className}`, children: /* @__PURE__ */ jsx("div", { ref: containerRef, className: "h-full w-full p-2", children: /* @__PURE__ */ jsx(
@@ -17633,15 +17870,22 @@ var VideoGridView = React14__default.memo(({
17633
17870
  minHeight: "100%"
17634
17871
  },
17635
17872
  children: filteredWorkspaces.sort((a, b) => {
17636
- const aNum = parseInt(a.workspace_name.slice(2));
17637
- const bNum = parseInt(b.workspace_name.slice(2));
17638
- if (!selectedLine) {
17639
- const aIsLine2 = a.line_id === lineIdMapping.line2;
17640
- const bIsLine2 = b.line_id === lineIdMapping.line2;
17641
- if (aIsLine2 !== bIsLine2) {
17642
- return aIsLine2 ? 1 : -1;
17873
+ if (!targetLineId && !selectedLine) {
17874
+ const aIsSecondaryLine = secondaryLineId && a.line_id === secondaryLineId;
17875
+ const bIsSecondaryLine = secondaryLineId && b.line_id === secondaryLineId;
17876
+ if (aIsSecondaryLine !== bIsSecondaryLine) {
17877
+ return aIsSecondaryLine ? 1 : -1;
17878
+ }
17879
+ if (!secondaryLineId && lineIdMapping.line2) {
17880
+ const aIsLine2 = a.line_id === lineIdMapping.line2;
17881
+ const bIsLine2 = b.line_id === lineIdMapping.line2;
17882
+ if (aIsLine2 !== bIsLine2) {
17883
+ return aIsLine2 ? 1 : -1;
17884
+ }
17643
17885
  }
17644
17886
  }
17887
+ const aNum = parseInt(a.workspace_name.slice(2));
17888
+ const bNum = parseInt(b.workspace_name.slice(2));
17645
17889
  return aNum - bNum;
17646
17890
  }).map((workspace) => {
17647
17891
  const workspaceId = workspace.workspace_uuid || workspace.workspace_name;
@@ -17658,7 +17902,7 @@ var VideoGridView = React14__default.memo(({
17658
17902
  VideoCard,
17659
17903
  {
17660
17904
  workspace,
17661
- hlsUrl: getWorkspaceHlsUrl(workspace.workspace_name),
17905
+ hlsUrl: getWorkspaceHlsUrl(workspace.workspace_name, workspace.line_id),
17662
17906
  shouldPlay: isVisible,
17663
17907
  onClick: () => handleWorkspaceClick(workspace),
17664
17908
  onFatalError: throttledReloadDashboard,
@@ -21302,6 +21546,14 @@ function parseS3Uri(s3Uri) {
21302
21546
  severity = "high";
21303
21547
  description = "Worst Cycle Time Performance";
21304
21548
  break;
21549
+ case "cycle_completions":
21550
+ case "cycle_completion":
21551
+ case "completed_cycles":
21552
+ case "completed_cycle":
21553
+ type = "cycle_completions";
21554
+ severity = "low";
21555
+ description = "Cycle Completion";
21556
+ break;
21305
21557
  case "medium_bottleneck":
21306
21558
  severity = "medium";
21307
21559
  description = "Medium Bottleneck Identified";
@@ -21328,6 +21580,10 @@ function parseS3Uri(s3Uri) {
21328
21580
  type = "bottleneck";
21329
21581
  severity = "high";
21330
21582
  description = "Long Cycle Time Detected";
21583
+ } else if (normalizedViolationType.includes("cycle") && (normalizedViolationType.includes("completion") || normalizedViolationType.includes("complete"))) {
21584
+ type = "cycle_completions";
21585
+ severity = "low";
21586
+ description = "Cycle Completion";
21331
21587
  } else {
21332
21588
  description = `Clip type: ${violationType.replace(/_/g, " ")}`;
21333
21589
  console.log(`Detected unknown violation type: ${violationType} in URI: ${s3Uri}`);
@@ -21507,7 +21763,7 @@ var S3ClipsService = class {
21507
21763
  }
21508
21764
  let cycleTimeSeconds = null;
21509
21765
  let creationTimestamp = void 0;
21510
- if (includeMetadata || includeCycleTime && (parsedInfo.type === "bottleneck" && parsedInfo.description.toLowerCase().includes("cycle time") || parsedInfo.type === "best_cycle_time" || parsedInfo.type === "worst_cycle_time")) {
21766
+ if (includeMetadata || includeCycleTime && (parsedInfo.type === "bottleneck" && parsedInfo.description.toLowerCase().includes("cycle time") || parsedInfo.type === "best_cycle_time" || parsedInfo.type === "worst_cycle_time" || parsedInfo.type === "cycle_completions")) {
21511
21767
  const metadata = await this.getFullMetadata(uri);
21512
21768
  if (metadata) {
21513
21769
  if (metadata.original_task_metadata?.cycle_time) {
@@ -21540,6 +21796,7 @@ var S3ClipsService = class {
21540
21796
  low_value: 0,
21541
21797
  long_cycle_time: 0,
21542
21798
  missing_quality_check: 0,
21799
+ cycle_completions: 0,
21543
21800
  total: 0
21544
21801
  };
21545
21802
  const samples = {
@@ -21548,7 +21805,8 @@ var S3ClipsService = class {
21548
21805
  bottleneck: null,
21549
21806
  low_value: null,
21550
21807
  long_cycle_time: null,
21551
- missing_quality_check: null
21808
+ missing_quality_check: null,
21809
+ cycle_completions: null
21552
21810
  };
21553
21811
  for (const uri of s3Uris) {
21554
21812
  const parsedInfo = parseS3Uri(uri);
@@ -21836,6 +22094,7 @@ var BottlenecksContent = ({
21836
22094
  const firstBestCycle = videos.find((v) => v.type === "best_cycle_time");
21837
22095
  const firstWorstCycle = videos.find((v) => v.type === "worst_cycle_time");
21838
22096
  const firstSOPDeviation = videos.find((v) => v.type === "missing_quality_check");
22097
+ const firstCycleCompletion = videos.find((v) => v.type === "cycle_completions");
21839
22098
  preloadVideosUrl2([
21840
22099
  firstHigh?.src,
21841
22100
  firstMed?.src,
@@ -21843,7 +22102,8 @@ var BottlenecksContent = ({
21843
22102
  firstLowValue?.src,
21844
22103
  firstBestCycle?.src,
21845
22104
  firstWorstCycle?.src,
21846
- firstSOPDeviation?.src
22105
+ firstSOPDeviation?.src,
22106
+ firstCycleCompletion?.src
21847
22107
  ].filter(Boolean));
21848
22108
  }
21849
22109
  setAllVideos(videos);
@@ -21867,6 +22127,7 @@ var BottlenecksContent = ({
21867
22127
  if (activeFilter === "sop_deviations") return video.type === "missing_quality_check";
21868
22128
  if (activeFilter === "best_cycle_time") return video.type === "best_cycle_time";
21869
22129
  if (activeFilter === "worst_cycle_time") return video.type === "worst_cycle_time";
22130
+ if (activeFilter === "cycle_completions") return video.type === "cycle_completions";
21870
22131
  if (activeFilter === "long_cycle_time") {
21871
22132
  return video.type === "bottleneck" && video.description.toLowerCase().includes("cycle time");
21872
22133
  }
@@ -21889,6 +22150,8 @@ var BottlenecksContent = ({
21889
22150
  filtered = allVideos.filter((video) => video.type === "best_cycle_time");
21890
22151
  } else if (activeFilter === "worst_cycle_time") {
21891
22152
  filtered = allVideos.filter((video) => video.type === "worst_cycle_time");
22153
+ } else if (activeFilter === "cycle_completions") {
22154
+ filtered = allVideos.filter((video) => video.type === "cycle_completions");
21892
22155
  } else if (activeFilter === "long_cycle_time") {
21893
22156
  filtered = allVideos.filter(
21894
22157
  (video) => video.type === "bottleneck" && video.description.toLowerCase().includes("cycle time")
@@ -22183,6 +22446,7 @@ var BottlenecksContent = ({
22183
22446
  bestCycleTimes: 0,
22184
22447
  worstCycleTimes: 0,
22185
22448
  longCycleTimes: 0,
22449
+ cycleCompletions: 0,
22186
22450
  total: 0
22187
22451
  };
22188
22452
  return {
@@ -22197,6 +22461,7 @@ var BottlenecksContent = ({
22197
22461
  longCycleTimes: allVideos.filter(
22198
22462
  (video) => video.type === "bottleneck" && video.description.toLowerCase().includes("cycle time")
22199
22463
  ).length,
22464
+ cycleCompletions: allVideos.filter((video) => video.type === "cycle_completions").length,
22200
22465
  total: allVideos.length
22201
22466
  };
22202
22467
  }, [allVideos]);
@@ -22217,6 +22482,8 @@ var BottlenecksContent = ({
22217
22482
  return "Best Cycle Time";
22218
22483
  case "worst_cycle_time":
22219
22484
  return "Worst Cycle Time";
22485
+ case "cycle_completions":
22486
+ return "Cycle Completion";
22220
22487
  case "bottleneck":
22221
22488
  default:
22222
22489
  return "Bottleneck";
@@ -22252,7 +22519,7 @@ var BottlenecksContent = ({
22252
22519
  ] });
22253
22520
  }
22254
22521
  return /* @__PURE__ */ jsxs("div", { className: "flex-grow p-1.5 sm:p-2 lg:p-4 h-[calc(100vh-12rem)]", children: [
22255
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3 mb-4", children: [
22522
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-5 gap-3 mb-4", children: [
22256
22523
  /* @__PURE__ */ jsxs(
22257
22524
  Card2,
22258
22525
  {
@@ -22372,11 +22639,41 @@ var BottlenecksContent = ({
22372
22639
  ] }) })
22373
22640
  ]
22374
22641
  }
22642
+ ),
22643
+ /* @__PURE__ */ jsxs(
22644
+ Card2,
22645
+ {
22646
+ onClick: () => {
22647
+ setActiveFilter("cycle_completions");
22648
+ trackCoreEvent("Cycle Completions Filter Clicked", {
22649
+ workspaceId,
22650
+ workspaceName,
22651
+ date,
22652
+ filterType: "cycle_completions",
22653
+ clipCount: clipCounts.cycleCompletions
22654
+ });
22655
+ },
22656
+ className: `bg-white shadow-sm cursor-pointer transition-all duration-200 hover:bg-gray-50 ${activeFilter === "cycle_completions" ? "bg-blue-50 shadow-md ring-1 ring-blue-200" : ""}`,
22657
+ "aria-label": `Filter by Cycle Completions (${clipCounts.cycleCompletions} clips)`,
22658
+ role: "button",
22659
+ tabIndex: 0,
22660
+ onKeyDown: (e) => e.key === "Enter" && setActiveFilter("cycle_completions"),
22661
+ children: [
22662
+ /* @__PURE__ */ jsx(CardHeader2, { className: "pb-2", children: /* @__PURE__ */ jsx(CardTitle2, { className: `text-lg ${activeFilter === "cycle_completions" ? "text-blue-600" : ""}`, children: "Cycle Completions" }) }),
22663
+ /* @__PURE__ */ jsx(CardContent2, { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col justify-center", children: [
22664
+ /* @__PURE__ */ jsx("p", { className: "text-3xl font-bold text-blue-600", children: clipCounts.cycleCompletions }),
22665
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center text-sm text-gray-500 mt-1", children: [
22666
+ /* @__PURE__ */ jsx("div", { className: "h-2 w-2 rounded-full bg-blue-600 mr-1.5" }),
22667
+ /* @__PURE__ */ jsx("span", { children: "Completed production cycles" })
22668
+ ] })
22669
+ ] }) })
22670
+ ]
22671
+ }
22375
22672
  )
22376
22673
  ] }),
22377
22674
  /* @__PURE__ */ jsxs("div", { className: "bg-white rounded-lg shadow-sm overflow-hidden", style: { height: "calc(100% - 8.5rem)" }, children: [
22378
22675
  /* @__PURE__ */ jsx("div", { className: "px-4 py-3 border-b border-gray-100", children: /* @__PURE__ */ jsxs("div", { className: "flex justify-between items-center", children: [
22379
- /* @__PURE__ */ jsx("h3", { className: "text-lg font-semibold text-gray-800", children: activeFilter === "low_value" ? `Idle Moments (${clipCounts.lowValue})` : activeFilter === "best_cycle_time" ? `Best Cycle Time (${clipCounts.bestCycleTimes})` : activeFilter === "worst_cycle_time" ? `Worst Cycle Time (${clipCounts.worstCycleTimes})` : activeFilter === "long_cycle_time" ? `Long Cycle Time (${clipCounts.longCycleTimes})` : `All Clips (${clipCounts.total})` }),
22676
+ /* @__PURE__ */ jsx("h3", { className: "text-lg font-semibold text-gray-800", children: activeFilter === "low_value" ? `Idle Moments (${clipCounts.lowValue})` : activeFilter === "best_cycle_time" ? `Best Cycle Time (${clipCounts.bestCycleTimes})` : activeFilter === "worst_cycle_time" ? `Worst Cycle Time (${clipCounts.worstCycleTimes})` : activeFilter === "long_cycle_time" ? `Long Cycle Time (${clipCounts.longCycleTimes})` : activeFilter === "cycle_completions" ? `Cycle Completions (${clipCounts.cycleCompletions})` : `All Clips (${clipCounts.total})` }),
22380
22677
  /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
22381
22678
  /* @__PURE__ */ jsxs("div", { className: "relative", ref: timestampFilterRef, children: [
22382
22679
  /* @__PURE__ */ jsx(
@@ -22531,9 +22828,9 @@ var BottlenecksContent = ({
22531
22828
  }
22532
22829
  )
22533
22830
  ] }) }),
22534
- (currentVideo.type === "best_cycle_time" || currentVideo.type === "worst_cycle_time" || currentVideo.type === "bottleneck" && currentVideo.description.toLowerCase().includes("cycle time")) && currentVideo.cycle_time_seconds || currentVideo.type === "low_value" ? /* @__PURE__ */ jsx("div", { className: "absolute top-3 left-3 z-10 bg-black/60 backdrop-blur-sm px-3 py-1.5 rounded-lg text-white shadow-lg text-xs", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
22535
- /* @__PURE__ */ jsx("div", { className: `flex-shrink-0 h-2.5 w-2.5 rounded-full ${currentVideo.type === "low_value" ? "bg-purple-400" : currentVideo.type === "best_cycle_time" ? "bg-green-600" : currentVideo.type === "worst_cycle_time" ? "bg-red-700" : "bg-red-500"} mr-2 animate-pulse` }),
22536
- (currentVideo.type === "best_cycle_time" || currentVideo.type === "worst_cycle_time" || currentVideo.type === "bottleneck" && currentVideo.description.toLowerCase().includes("cycle time")) && currentVideo.cycle_time_seconds ? /* @__PURE__ */ jsxs("span", { className: "opacity-90 font-mono bg-black/30 px-2 py-0.5 rounded", children: [
22831
+ (currentVideo.type === "best_cycle_time" || currentVideo.type === "worst_cycle_time" || currentVideo.type === "cycle_completions" || currentVideo.type === "bottleneck" && currentVideo.description.toLowerCase().includes("cycle time")) && currentVideo.cycle_time_seconds || currentVideo.type === "low_value" ? /* @__PURE__ */ jsx("div", { className: "absolute top-3 left-3 z-10 bg-black/60 backdrop-blur-sm px-3 py-1.5 rounded-lg text-white shadow-lg text-xs", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
22832
+ /* @__PURE__ */ jsx("div", { className: `flex-shrink-0 h-2.5 w-2.5 rounded-full ${currentVideo.type === "low_value" ? "bg-purple-400" : currentVideo.type === "best_cycle_time" ? "bg-green-600" : currentVideo.type === "worst_cycle_time" ? "bg-red-700" : currentVideo.type === "cycle_completions" ? "bg-blue-600" : "bg-red-500"} mr-2 animate-pulse` }),
22833
+ (currentVideo.type === "best_cycle_time" || currentVideo.type === "worst_cycle_time" || currentVideo.type === "cycle_completions" || currentVideo.type === "bottleneck" && currentVideo.description.toLowerCase().includes("cycle time")) && currentVideo.cycle_time_seconds ? /* @__PURE__ */ jsxs("span", { className: "opacity-90 font-mono bg-black/30 px-2 py-0.5 rounded", children: [
22537
22834
  "Cycle time: ",
22538
22835
  (currentVideo.cycle_time_seconds / 20).toFixed(1),
22539
22836
  "s"
@@ -22615,9 +22912,9 @@ var BottlenecksContent = ({
22615
22912
  children: /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-6 w-6", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
22616
22913
  }
22617
22914
  ),
22618
- (currentVideo.type === "best_cycle_time" || currentVideo.type === "worst_cycle_time" || currentVideo.type === "bottleneck" && currentVideo.description.toLowerCase().includes("cycle time")) && currentVideo.cycle_time_seconds || currentVideo.type === "low_value" ? /* @__PURE__ */ jsx("div", { className: "absolute top-4 left-4 z-[101] bg-black/60 backdrop-blur-sm px-4 py-2 rounded-lg text-white shadow-lg text-sm", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
22619
- /* @__PURE__ */ jsx("div", { className: `flex-shrink-0 h-2.5 w-2.5 rounded-full ${currentVideo.type === "low_value" ? "bg-purple-400" : currentVideo.type === "best_cycle_time" ? "bg-green-600" : currentVideo.type === "worst_cycle_time" ? "bg-red-700" : "bg-red-500"} mr-2` }),
22620
- (currentVideo.type === "best_cycle_time" || currentVideo.type === "worst_cycle_time" || currentVideo.type === "bottleneck" && currentVideo.description.toLowerCase().includes("cycle time")) && currentVideo.cycle_time_seconds ? /* @__PURE__ */ jsxs("span", { className: "opacity-90 font-mono bg-black/30 px-2 py-1 rounded", children: [
22915
+ (currentVideo.type === "best_cycle_time" || currentVideo.type === "worst_cycle_time" || currentVideo.type === "cycle_completions" || currentVideo.type === "bottleneck" && currentVideo.description.toLowerCase().includes("cycle time")) && currentVideo.cycle_time_seconds || currentVideo.type === "low_value" ? /* @__PURE__ */ jsx("div", { className: "absolute top-4 left-4 z-[101] bg-black/60 backdrop-blur-sm px-4 py-2 rounded-lg text-white shadow-lg text-sm", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
22916
+ /* @__PURE__ */ jsx("div", { className: `flex-shrink-0 h-2.5 w-2.5 rounded-full ${currentVideo.type === "low_value" ? "bg-purple-400" : currentVideo.type === "best_cycle_time" ? "bg-green-600" : currentVideo.type === "worst_cycle_time" ? "bg-red-700" : currentVideo.type === "cycle_completions" ? "bg-blue-600" : "bg-red-500"} mr-2` }),
22917
+ (currentVideo.type === "best_cycle_time" || currentVideo.type === "worst_cycle_time" || currentVideo.type === "cycle_completions" || currentVideo.type === "bottleneck" && currentVideo.description.toLowerCase().includes("cycle time")) && currentVideo.cycle_time_seconds ? /* @__PURE__ */ jsxs("span", { className: "opacity-90 font-mono bg-black/30 px-2 py-1 rounded", children: [
22621
22918
  "Cycle time: ",
22622
22919
  (currentVideo.cycle_time_seconds / 20).toFixed(1),
22623
22920
  "s"
@@ -25303,6 +25600,38 @@ var AIAgentView = () => {
25303
25600
  }
25304
25601
  return null;
25305
25602
  };
25603
+ const DualAxisTooltip = ({ active, payload, label }) => {
25604
+ if (active && payload && payload.length) {
25605
+ return /* @__PURE__ */ jsxs("div", { className: "bg-white px-4 py-3 shadow-lg rounded-lg border border-gray-200", children: [
25606
+ /* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-gray-900 mb-2", children: label }),
25607
+ /* @__PURE__ */ jsx("div", { className: "space-y-1", children: payload.map((entry, index) => {
25608
+ const value = typeof entry.value === "number" ? formatNumber(entry.value) : entry.value;
25609
+ const unit = entry.dataKey === args.left_y_field ? args.left_unit || "" : entry.dataKey === args.right_y_field ? args.right_unit || "" : "";
25610
+ return /* @__PURE__ */ jsxs("p", { className: "text-sm", style: { color: entry.color }, children: [
25611
+ /* @__PURE__ */ jsxs("span", { className: "font-medium", children: [
25612
+ entry.name,
25613
+ ":"
25614
+ ] }),
25615
+ " ",
25616
+ value,
25617
+ unit
25618
+ ] }, index);
25619
+ }) })
25620
+ ] });
25621
+ }
25622
+ return null;
25623
+ };
25624
+ const formatXAxisTick = (value) => {
25625
+ if (typeof value === "string") {
25626
+ if (value.match(/^\d{2}\/\d{2}\s/)) {
25627
+ return value;
25628
+ }
25629
+ if (value.length > 15) {
25630
+ return value.substring(0, 12) + "...";
25631
+ }
25632
+ }
25633
+ return value;
25634
+ };
25306
25635
  const ChartWrapper = ({ children, title }) => /* @__PURE__ */ jsxs("div", { className: "my-6 bg-white rounded-xl shadow-sm border border-gray-200 p-6", children: [
25307
25636
  title && /* @__PURE__ */ jsx("h3", { className: "text-base font-semibold text-gray-900 mb-4", children: title }),
25308
25637
  children
@@ -25335,7 +25664,12 @@ var AIAgentView = () => {
25335
25664
  XAxis,
25336
25665
  {
25337
25666
  dataKey: args.x_field,
25338
- ...CHART_STYLES.axis
25667
+ ...CHART_STYLES.axis,
25668
+ angle: -45,
25669
+ textAnchor: "end",
25670
+ height: 60,
25671
+ interval: 0,
25672
+ tickFormatter: formatXAxisTick
25339
25673
  }
25340
25674
  ),
25341
25675
  /* @__PURE__ */ jsx(
@@ -25367,7 +25701,12 @@ var AIAgentView = () => {
25367
25701
  XAxis,
25368
25702
  {
25369
25703
  dataKey: args.x_field,
25370
- ...CHART_STYLES.axis
25704
+ ...CHART_STYLES.axis,
25705
+ angle: -45,
25706
+ textAnchor: "end",
25707
+ height: 60,
25708
+ interval: 0,
25709
+ tickFormatter: formatXAxisTick
25371
25710
  }
25372
25711
  ),
25373
25712
  /* @__PURE__ */ jsx(
@@ -25461,7 +25800,12 @@ var AIAgentView = () => {
25461
25800
  XAxis,
25462
25801
  {
25463
25802
  dataKey: args.x_field,
25464
- ...CHART_STYLES.axis
25803
+ ...CHART_STYLES.axis,
25804
+ angle: -45,
25805
+ textAnchor: "end",
25806
+ height: 60,
25807
+ interval: 0,
25808
+ tickFormatter: formatXAxisTick
25465
25809
  }
25466
25810
  ),
25467
25811
  /* @__PURE__ */ jsx(
@@ -25509,7 +25853,12 @@ var AIAgentView = () => {
25509
25853
  XAxis,
25510
25854
  {
25511
25855
  dataKey: args.x_field,
25512
- ...CHART_STYLES.axis
25856
+ ...CHART_STYLES.axis,
25857
+ angle: -45,
25858
+ textAnchor: "end",
25859
+ height: 60,
25860
+ interval: 0,
25861
+ tickFormatter: formatXAxisTick
25513
25862
  }
25514
25863
  ),
25515
25864
  /* @__PURE__ */ jsx(
@@ -25550,13 +25899,18 @@ var AIAgentView = () => {
25550
25899
  });
25551
25900
  return null;
25552
25901
  }
25553
- return /* @__PURE__ */ jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsx("div", { className: "w-full h-80", children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(ComposedChart, { data: args.data, margin: CHART_STYLES.margin, children: [
25902
+ return /* @__PURE__ */ jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsx("div", { className: "w-full h-80", children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(ComposedChart, { data: args.data, margin: { ...CHART_STYLES.margin, bottom: 80 }, children: [
25554
25903
  /* @__PURE__ */ jsx(CartesianGrid, { ...CHART_STYLES.grid }),
25555
25904
  /* @__PURE__ */ jsx(
25556
25905
  XAxis,
25557
25906
  {
25558
25907
  dataKey: args.x_field,
25559
- ...CHART_STYLES.axis
25908
+ ...CHART_STYLES.axis,
25909
+ angle: -45,
25910
+ textAnchor: "end",
25911
+ height: 100,
25912
+ interval: 0,
25913
+ tickFormatter: formatXAxisTick
25560
25914
  }
25561
25915
  ),
25562
25916
  /* @__PURE__ */ jsx(
@@ -25564,9 +25918,14 @@ var AIAgentView = () => {
25564
25918
  {
25565
25919
  yAxisId: "left",
25566
25920
  orientation: "left",
25567
- label: { value: args.left_label || "", angle: -90, position: "insideLeft" },
25921
+ label: {
25922
+ value: args.left_label || args.left_y_field,
25923
+ angle: -90,
25924
+ position: "insideLeft",
25925
+ style: { textAnchor: "middle", fill: "#4b5563" }
25926
+ },
25568
25927
  ...CHART_STYLES.axis,
25569
- tickFormatter: (value) => formatNumber(value)
25928
+ tickFormatter: (value) => `${formatNumber(value)}${args.left_unit || ""}`
25570
25929
  }
25571
25930
  ),
25572
25931
  /* @__PURE__ */ jsx(
@@ -25574,12 +25933,17 @@ var AIAgentView = () => {
25574
25933
  {
25575
25934
  yAxisId: "right",
25576
25935
  orientation: "right",
25577
- label: { value: args.right_label || "", angle: 90, position: "insideRight" },
25936
+ label: {
25937
+ value: args.right_label || args.right_y_field,
25938
+ angle: 90,
25939
+ position: "insideRight",
25940
+ style: { textAnchor: "middle", fill: "#4b5563" }
25941
+ },
25578
25942
  ...CHART_STYLES.axis,
25579
- tickFormatter: (value) => formatNumber(value)
25943
+ tickFormatter: (value) => `${formatNumber(value)}${args.right_unit || ""}`
25580
25944
  }
25581
25945
  ),
25582
- /* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(CustomTooltip, {}), cursor: { fill: "rgba(0, 0, 0, 0.05)" } }),
25946
+ /* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(DualAxisTooltip, {}), cursor: { fill: "rgba(0, 0, 0, 0.05)" } }),
25583
25947
  /* @__PURE__ */ jsx(
25584
25948
  Legend,
25585
25949
  {
@@ -25604,10 +25968,10 @@ var AIAgentView = () => {
25604
25968
  type: "monotone",
25605
25969
  dataKey: args.right_y_field,
25606
25970
  stroke: CHART_COLORS.danger,
25607
- strokeWidth: 2,
25971
+ strokeWidth: 3,
25608
25972
  name: args.right_label || args.right_y_field,
25609
- dot: { r: 4 },
25610
- activeDot: { r: 6 }
25973
+ dot: { r: 5, fill: CHART_COLORS.danger },
25974
+ activeDot: { r: 7 }
25611
25975
  }
25612
25976
  )
25613
25977
  ] }) }) }) }, `dual-axis-${key}`);
@@ -25685,13 +26049,18 @@ var AIAgentView = () => {
25685
26049
  });
25686
26050
  return null;
25687
26051
  }
25688
- return /* @__PURE__ */ jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsx("div", { className: "w-full h-80", children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(ComposedChart, { data: args.data, margin: CHART_STYLES.margin, children: [
26052
+ return /* @__PURE__ */ jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsx("div", { className: "w-full h-80", children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(ComposedChart, { data: args.data, margin: { ...CHART_STYLES.margin, bottom: 80 }, children: [
25689
26053
  /* @__PURE__ */ jsx(CartesianGrid, { ...CHART_STYLES.grid }),
25690
26054
  /* @__PURE__ */ jsx(
25691
26055
  XAxis,
25692
26056
  {
25693
26057
  dataKey: args.x_field,
25694
- ...CHART_STYLES.axis
26058
+ ...CHART_STYLES.axis,
26059
+ angle: -45,
26060
+ textAnchor: "end",
26061
+ height: 100,
26062
+ interval: 0,
26063
+ tickFormatter: formatXAxisTick
25695
26064
  }
25696
26065
  ),
25697
26066
  /* @__PURE__ */ jsx(
@@ -25737,10 +26106,10 @@ var AIAgentView = () => {
25737
26106
  type: "monotone",
25738
26107
  dataKey: args.line_field,
25739
26108
  stroke: CHART_COLORS.danger,
25740
- strokeWidth: 2,
26109
+ strokeWidth: 3,
25741
26110
  name: args.line_field,
25742
- dot: { r: 4 },
25743
- activeDot: { r: 6 }
26111
+ dot: { r: 5 },
26112
+ activeDot: { r: 7 }
25744
26113
  }
25745
26114
  )
25746
26115
  ] }) }) }) }, `combo-${key}`);
@@ -25754,7 +26123,7 @@ var AIAgentView = () => {
25754
26123
  });
25755
26124
  return null;
25756
26125
  }
25757
- return /* @__PURE__ */ jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsx("div", { className: "w-full h-80", children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(ComposedChart, { data: args.data, margin: CHART_STYLES.margin, children: [
26126
+ return /* @__PURE__ */ jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsx("div", { className: "w-full h-80", children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(ComposedChart, { data: args.data, margin: { ...CHART_STYLES.margin, bottom: 80 }, children: [
25758
26127
  /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("linearGradient", { id: "colorGradient", x1: "0", y1: "0", x2: "0", y2: "1", children: [
25759
26128
  /* @__PURE__ */ jsx("stop", { offset: "5%", stopColor: CHART_COLORS.primary, stopOpacity: 0.8 }),
25760
26129
  /* @__PURE__ */ jsx("stop", { offset: "95%", stopColor: CHART_COLORS.primary, stopOpacity: 0.1 })
@@ -25764,7 +26133,12 @@ var AIAgentView = () => {
25764
26133
  XAxis,
25765
26134
  {
25766
26135
  dataKey: args.x_field,
25767
- ...CHART_STYLES.axis
26136
+ ...CHART_STYLES.axis,
26137
+ angle: -45,
26138
+ textAnchor: "end",
26139
+ height: 100,
26140
+ interval: 0,
26141
+ tickFormatter: formatXAxisTick
25768
26142
  }
25769
26143
  ),
25770
26144
  /* @__PURE__ */ jsx(
@@ -25826,6 +26200,31 @@ var AIAgentView = () => {
25826
26200
  opacity: 1;
25827
26201
  }
25828
26202
  }
26203
+
26204
+ @keyframes waveLoad {
26205
+ 0% {
26206
+ background-position: -200% 0;
26207
+ }
26208
+ 100% {
26209
+ background-position: 200% 0;
26210
+ }
26211
+ }
26212
+
26213
+ .thinking-wave {
26214
+ background: linear-gradient(
26215
+ 90deg,
26216
+ #6b7280 0%,
26217
+ #6b7280 40%,
26218
+ #3b82f6 50%,
26219
+ #6b7280 60%,
26220
+ #6b7280 100%
26221
+ );
26222
+ background-size: 200% 100%;
26223
+ -webkit-background-clip: text;
26224
+ background-clip: text;
26225
+ -webkit-text-fill-color: transparent;
26226
+ animation: waveLoad 3s ease-in-out infinite;
26227
+ }
25829
26228
  `
25830
26229
  } }),
25831
26230
  /* @__PURE__ */ jsxs("div", { className: `flex-1 flex flex-col h-screen transition-all duration-300 ${isSidebarOpen ? "mr-80" : "mr-0"}`, children: [
@@ -25975,14 +26374,7 @@ var AIAgentView = () => {
25975
26374
  )),
25976
26375
  /* @__PURE__ */ jsxs("div", { className: "flex gap-4 justify-start", children: [
25977
26376
  /* @__PURE__ */ jsx(ProfilePicture, {}),
25978
- /* @__PURE__ */ jsx("div", { className: "bg-white border border-gray-200/80 px-5 py-4 rounded-2xl shadow-sm max-w-full", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
25979
- /* @__PURE__ */ jsxs("div", { className: "flex space-x-1", children: [
25980
- /* @__PURE__ */ jsx("div", { className: "w-2 h-2 bg-blue-500 rounded-full animate-bounce" }),
25981
- /* @__PURE__ */ jsx("div", { className: "w-2 h-2 bg-blue-500 rounded-full animate-bounce", style: { animationDelay: "0.1s" } }),
25982
- /* @__PURE__ */ jsx("div", { className: "w-2 h-2 bg-blue-500 rounded-full animate-bounce", style: { animationDelay: "0.2s" } })
25983
- ] }),
25984
- /* @__PURE__ */ jsx("span", { className: "text-gray-600 text-sm", children: "Axel is thinking..." })
25985
- ] }) })
26377
+ /* @__PURE__ */ jsx("div", { className: "bg-white border border-gray-200/80 px-5 py-4 rounded-2xl shadow-sm max-w-full", children: /* @__PURE__ */ jsx("div", { className: "flex items-center", children: /* @__PURE__ */ jsx("span", { className: "text-sm font-medium thinking-wave", children: "Thinking" }) }) })
25986
26378
  ] })
25987
26379
  ] }) })
25988
26380
  ) : (
@@ -26048,14 +26440,7 @@ var AIAgentView = () => {
26048
26440
  ] }),
26049
26441
  isCurrentThreadLoading && !currentStreaming.message && /* @__PURE__ */ jsxs("div", { className: "flex gap-4 justify-start", children: [
26050
26442
  /* @__PURE__ */ jsx(ProfilePicture, {}),
26051
- /* @__PURE__ */ jsx("div", { className: "bg-white border border-gray-200/80 px-5 py-4 rounded-2xl shadow-sm max-w-full", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
26052
- /* @__PURE__ */ jsxs("div", { className: "flex space-x-1", children: [
26053
- /* @__PURE__ */ jsx("div", { className: "w-2 h-2 bg-blue-500 rounded-full animate-bounce" }),
26054
- /* @__PURE__ */ jsx("div", { className: "w-2 h-2 bg-blue-500 rounded-full animate-bounce", style: { animationDelay: "0.1s" } }),
26055
- /* @__PURE__ */ jsx("div", { className: "w-2 h-2 bg-blue-500 rounded-full animate-bounce", style: { animationDelay: "0.2s" } })
26056
- ] }),
26057
- /* @__PURE__ */ jsx("span", { className: "text-gray-600 text-sm", children: "Axel is thinking..." })
26058
- ] }) })
26443
+ /* @__PURE__ */ jsx("div", { className: "bg-white border border-gray-200/80 px-5 py-4 rounded-2xl shadow-sm max-w-full", children: /* @__PURE__ */ jsx("div", { className: "flex items-center", children: /* @__PURE__ */ jsx("span", { className: "text-sm font-medium thinking-wave", children: "Thinking" }) }) })
26059
26444
  ] }),
26060
26445
  /* @__PURE__ */ jsx("div", { ref: messagesEndRef })
26061
26446
  ] }) })
@@ -27057,14 +27442,30 @@ function HomeView({
27057
27442
  factoryName = "Simba Beer - Line 1"
27058
27443
  }) {
27059
27444
  const [isHydrated, setIsHydrated] = useState(false);
27060
- const [selectedLineId, setSelectedLineId] = useState(defaultLineId);
27445
+ const [selectedLineId, setSelectedLineId] = useState(factoryViewId);
27446
+ console.log("[HomeView] Component initialized with:", {
27447
+ defaultLineId,
27448
+ factoryViewId,
27449
+ line1Uuid,
27450
+ line2Uuid,
27451
+ selectedLineId: factoryViewId
27452
+ });
27061
27453
  const [isChangingFilter, setIsChangingFilter] = useState(false);
27062
27454
  const [errorMessage, setErrorMessage] = useState(null);
27063
27455
  const [displayNamesInitialized, setDisplayNamesInitialized] = useState(false);
27456
+ const metricsLineId = selectedLineId;
27457
+ console.log("[HomeView] Using metrics line ID:", metricsLineId, "for selectedLineId:", selectedLineId);
27064
27458
  useEffect(() => {
27065
27459
  const initDisplayNames = async () => {
27066
27460
  try {
27067
- await preInitializeWorkspaceDisplayNames(selectedLineId);
27461
+ if (metricsLineId === factoryViewId) {
27462
+ console.log("[HomeView] Initializing display names for factory view (both lines)");
27463
+ await preInitializeWorkspaceDisplayNames(line1Uuid);
27464
+ await preInitializeWorkspaceDisplayNames(line2Uuid);
27465
+ } else {
27466
+ console.log("[HomeView] Initializing display names for single line:", selectedLineId);
27467
+ await preInitializeWorkspaceDisplayNames(selectedLineId);
27468
+ }
27068
27469
  setDisplayNamesInitialized(true);
27069
27470
  } catch (error) {
27070
27471
  console.error("Failed to pre-initialize workspace display names:", error);
@@ -27072,12 +27473,13 @@ function HomeView({
27072
27473
  }
27073
27474
  };
27074
27475
  initDisplayNames();
27075
- }, [selectedLineId]);
27476
+ }, [selectedLineId, metricsLineId, factoryViewId, line1Uuid, line2Uuid]);
27477
+ const displayNamesLineId = metricsLineId === factoryViewId ? void 0 : selectedLineId;
27076
27478
  const {
27077
27479
  displayNames: workspaceDisplayNames,
27078
27480
  loading: displayNamesLoading,
27079
27481
  error: displayNamesError
27080
- } = useWorkspaceDisplayNames(void 0, selectedLineId);
27482
+ } = useWorkspaceDisplayNames(void 0, displayNamesLineId);
27081
27483
  useCallback(() => {
27082
27484
  console.log("Refetching KPIs after line metrics update");
27083
27485
  }, []);
@@ -27102,14 +27504,16 @@ function HomeView({
27102
27504
  error: metricsError,
27103
27505
  refetch: refetchMetrics
27104
27506
  } = useDashboardMetrics({
27105
- lineId: selectedLineId,
27507
+ lineId: metricsLineId,
27106
27508
  onLineMetricsUpdate
27107
27509
  });
27510
+ const breaksLineIds = metricsLineId === factoryViewId ? [line1Uuid, line2Uuid] : [selectedLineId];
27511
+ console.log("[HomeView] Using breaks line IDs:", breaksLineIds);
27108
27512
  const {
27109
27513
  activeBreaks,
27110
27514
  isLoading: breaksLoading,
27111
27515
  error: breaksError
27112
- } = useActiveBreaks([selectedLineId]);
27516
+ } = useActiveBreaks(breaksLineIds);
27113
27517
  const memoizedWorkspaceMetrics = useMemo(() => workspaceMetrics, [
27114
27518
  // Only update reference if meaningful properties change
27115
27519
  workspaceMetrics.length,
@@ -27264,8 +27668,12 @@ var itemVariants = {
27264
27668
  };
27265
27669
 
27266
27670
  // src/lib/utils/navigation.ts
27267
- function getWorkspaceNavigationParams2(workspaceUuid, displayName) {
27268
- return `?name=${encodeURIComponent(displayName || "")}`;
27671
+ function getWorkspaceNavigationParams2(workspaceUuid, displayName, lineId) {
27672
+ const params = new URLSearchParams();
27673
+ if (displayName) {
27674
+ params.set("name", displayName);
27675
+ }
27676
+ return params.toString() ? `?${params.toString()}` : "";
27269
27677
  }
27270
27678
  var formatLocalDate = (date) => {
27271
27679
  const options = {
@@ -28457,6 +28865,13 @@ var LeaderboardDetailView = memo(({
28457
28865
  line2Id = "",
28458
28866
  className = ""
28459
28867
  }) => {
28868
+ console.log("[LeaderboardDetailView] Component initialized with:", {
28869
+ lineId,
28870
+ line1Id,
28871
+ line2Id,
28872
+ date,
28873
+ shift
28874
+ });
28460
28875
  const navigation = useNavigation();
28461
28876
  const [sortAscending, setSortAscending] = useState(true);
28462
28877
  const handleSortToggle = useCallback(() => {
@@ -28474,13 +28889,39 @@ var LeaderboardDetailView = memo(({
28474
28889
  error: metricsError,
28475
28890
  refreshMetrics
28476
28891
  } = useRealtimeLineMetrics(realtimeMetricsParams);
28892
+ const isFactoryView = useMemo(() => {
28893
+ const hasEssentialLineIds = Boolean(line1Id && line2Id);
28894
+ const isFactoryLineId = lineId === "factory" || !lineId;
28895
+ return hasEssentialLineIds && isFactoryLineId;
28896
+ }, [lineId, line1Id, line2Id]);
28477
28897
  const memoizedLineId = useMemo(() => lineId || "", [lineId]);
28898
+ console.log("[LeaderboardDetailView] Factory view check:", {
28899
+ isFactoryView,
28900
+ lineId,
28901
+ line1Id,
28902
+ line2Id
28903
+ });
28904
+ const singleLineResult = useLineWorkspaceMetrics(isFactoryView ? "" : memoizedLineId);
28905
+ const factoryResult = useDashboardMetrics({
28906
+ lineId: isFactoryView ? "factory" : "",
28907
+ onLineMetricsUpdate: void 0
28908
+ });
28478
28909
  const {
28479
28910
  workspaces,
28480
28911
  loading: workspacesLoading,
28481
28912
  error: workspacesError,
28482
28913
  refreshWorkspaces
28483
- } = useLineWorkspaceMetrics(memoizedLineId);
28914
+ } = isFactoryView ? {
28915
+ workspaces: factoryResult.workspaceMetrics,
28916
+ loading: factoryResult.isLoading,
28917
+ error: factoryResult.error,
28918
+ refreshWorkspaces: factoryResult.refetch
28919
+ } : singleLineResult;
28920
+ console.log("[LeaderboardDetailView] Workspace data:", {
28921
+ workspaces: workspaces?.length || 0,
28922
+ loading: workspacesLoading,
28923
+ error: workspacesError
28924
+ });
28484
28925
  const getShiftName = useCallback((shiftId) => {
28485
28926
  if (shiftId === void 0) return "Day";
28486
28927
  return shiftId === 0 ? "Day" : "Night";
@@ -30411,6 +30852,12 @@ var TargetsView = ({
30411
30852
  userId,
30412
30853
  onSaveChanges
30413
30854
  }) => {
30855
+ console.log("[TargetsView] Component initialized with:", {
30856
+ lineIds,
30857
+ lineNames,
30858
+ companyId,
30859
+ totalLines: lineIds.length
30860
+ });
30414
30861
  const initialLineWorkspaces = useMemo(() => {
30415
30862
  return lineIds.reduce((acc, lineId) => ({
30416
30863
  ...acc,
@@ -30722,7 +31169,9 @@ var TargetsView = ({
30722
31169
  continue;
30723
31170
  }
30724
31171
  try {
31172
+ console.log(`[TargetsView] Fetching workspaces for line: ${lineId}`);
30725
31173
  const fetchedLineWorkspacesData = await workspaceService.getWorkspaces(lineId);
31174
+ console.log(`[TargetsView] Retrieved ${fetchedLineWorkspacesData.length} workspaces for line ${lineId}`);
30726
31175
  const mappedWorkspaces = fetchedLineWorkspacesData.map((ws) => ({
30727
31176
  id: ws.id,
30728
31177
  name: ws.workspace_id,
@@ -32017,4 +32466,4 @@ var S3Service = class {
32017
32466
  }
32018
32467
  };
32019
32468
 
32020
- export { ACTION_NAMES, AIAgentView_default as AIAgentView, AuthCallback, AuthCallbackView_default as AuthCallbackView, AuthProvider, AuthenticatedFactoryView, AuthenticatedHelpView, AuthenticatedHomeView, AuthenticatedTargetsView, BarChart, BaseHistoryCalendar, BottlenecksContent, BreakNotificationPopup, Card2 as Card, CardContent2 as CardContent, CardDescription2 as CardDescription, CardFooter2 as CardFooter, CardHeader2 as CardHeader, CardTitle2 as CardTitle, CycleTimeChart, CycleTimeOverTimeChart, DEFAULT_ANALYTICS_CONFIG, DEFAULT_AUTH_CONFIG, DEFAULT_CONFIG, DEFAULT_DATABASE_CONFIG, DEFAULT_DATE_TIME_CONFIG, DEFAULT_ENDPOINTS_CONFIG, DEFAULT_ENTITY_CONFIG, DEFAULT_SHIFT_CONFIG, DEFAULT_THEME_CONFIG, DEFAULT_VIDEO_CONFIG, DEFAULT_WORKSPACE_CONFIG, DEFAULT_WORKSPACE_POSITIONS, DashboardHeader, DashboardLayout, DashboardOverridesProvider, DashboardProvider, DateDisplay_default as DateDisplay, DateTimeDisplay, DebugAuth, DebugAuthView_default as DebugAuthView, EmptyStateMessage, FactoryView_default as FactoryView, GaugeChart, GridComponentsPlaceholder, Header, HelpView_default as HelpView, HomeView_default as HomeView, HourlyOutputChart2 as HourlyOutputChart, ISTTimer_default as ISTTimer, KPICard, KPIDetailView_default as KPIDetailView, KPIGrid, KPIHeader, KPISection, KPIsOverviewView_default as KPIsOverviewView, LINE_1_UUID, LargeOutputProgressChart, LeaderboardDetailView_default as LeaderboardDetailView, Legend6 as Legend, LineChart, LineHistoryCalendar, LineMonthlyHistory, LineMonthlyPdfGenerator, LinePdfExportButton, LinePdfGenerator, LineWhatsAppShareButton, LiveTimer, LoadingOverlay_default as LoadingOverlay, LoadingPage_default as LoadingPage, LoadingSpinner_default as LoadingSpinner, LoginPage, LoginView_default as LoginView, MainLayout, MetricCard_default as MetricCard, NoWorkspaceData, OptifyeAgentClient, OutputProgressChart, PageHeader, PieChart4 as PieChart, ProfileView_default as ProfileView, RegistryProvider, S3Service, SOPComplianceChart, SSEChatClient, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, ShiftDisplay_default as ShiftDisplay, ShiftsView_default as ShiftsView, SideNavBar, SingleVideoStream_default as SingleVideoStream, Skeleton, SlackAPI, SupabaseProvider, TargetWorkspaceGrid, TargetsView_default as TargetsView, ThreadSidebar, TimeDisplay_default as TimeDisplay, TimePickerDropdown, VideoCard, VideoGridView, VideoPreloader, WORKSPACE_POSITIONS, WhatsAppShareButton, WorkspaceCard, WorkspaceDetailView_default as WorkspaceDetailView, WorkspaceDisplayNameExample, WorkspaceGrid, WorkspaceGridItem, WorkspaceHistoryCalendar, WorkspaceMetricCards, WorkspaceMonthlyDataFetcher, WorkspaceMonthlyPdfGenerator, WorkspacePdfExportButton, WorkspacePdfGenerator, WorkspaceWhatsAppShareButton, actionService, apiUtils, authCoreService, authOTPService, authRateLimitService, checkRateLimit2 as checkRateLimit, clearAllRateLimits2 as clearAllRateLimits, clearRateLimit2 as clearRateLimit, clearS3VideoCache, clearS3VideoFromCache, clearWorkspaceDisplayNamesCache, cn, createStreamProxyHandler, createSupabaseClient, createThrottledReload, dashboardService, deleteThread, forceRefreshWorkspaceDisplayNames, formatDateInZone, formatDateTimeInZone, formatISTDate, formatIdleTime, formatTimeInZone, fromUrlFriendlyName, getAllThreadMessages, getAllWorkspaceDisplayNamesAsync, getAnonClient, getCameraNumber, getCompanyMetricsTableName, getConfigurableShortWorkspaceDisplayName, getConfigurableWorkspaceDisplayName, getCurrentShift, getCurrentTimeInZone, getDashboardHeaderTimeInZone, getDaysDifferenceInZone, getDefaultCameraStreamUrl, getDefaultTabForWorkspace, getManufacturingInsights, getMetricsTablePrefix, getOperationalDate, getS3SignedUrl, getS3VideoSrc, getShortWorkspaceDisplayName, getShortWorkspaceDisplayNameAsync, getStoredWorkspaceMappings, getThreadMessages, getUserThreads, getUserThreadsPaginated, getWorkspaceDisplayName, getWorkspaceDisplayNameAsync, getWorkspaceDisplayNamesMap, getWorkspaceFromUrl, getWorkspaceNavigationParams, identifyCoreUser, initializeCoreMixpanel, isTransitionPeriod, isValidLineInfoPayload, isValidWorkspaceDetailedMetricsPayload, isValidWorkspaceMetricsPayload, isWorkspaceDisplayNamesLoaded, isWorkspaceDisplayNamesLoading, mergeWithDefaultConfig, optifyeAgentClient, preInitializeWorkspaceDisplayNames, preloadS3Video, preloadS3VideoUrl, preloadS3VideosUrl, preloadVideoUrl, preloadVideosUrl, qualityService, realtimeService, refreshWorkspaceDisplayNames, resetCoreMixpanel, s3VideoPreloader, storeWorkspaceMapping, streamProxyConfig, throttledReloadDashboard, toUrlFriendlyName, trackCoreEvent, trackCorePageView, updateThreadTitle, useActiveBreaks, useAnalyticsConfig, useAuth, useAuthConfig, useComponentOverride, useCustomConfig, useDashboardConfig, useDashboardMetrics, useDatabaseConfig, useDateFormatter, useDateTimeConfig, useEndpointsConfig, useEntityConfig, useFactoryOverviewMetrics, useFeatureFlags, useFormatNumber, useHistoricWorkspaceMetrics, useHlsStream, useHlsStreamWithCropping, useHookOverride, useLeaderboardMetrics, useLineDetailedMetrics, useLineKPIs, useLineMetrics, useLineWorkspaceMetrics, useMessages, useMetrics, useNavigation, useOverrides, usePageOverride, useRealtimeLineMetrics, useRegistry, useShiftConfig, useShifts, useSupabase, useSupabaseClient, useTargets, useTheme, useThemeConfig, useThreads, useVideoConfig, useWorkspaceConfig, useWorkspaceDetailedMetrics, useWorkspaceDisplayName, useWorkspaceDisplayNames, useWorkspaceDisplayNamesMap, useWorkspaceMetrics, useWorkspaceNavigation, useWorkspaceOperators, videoPreloader, whatsappService, withAuth, withRegistry, workspaceService };
32469
+ export { ACTION_NAMES, AIAgentView_default as AIAgentView, AuthCallback, AuthCallbackView_default as AuthCallbackView, AuthProvider, AuthenticatedFactoryView, AuthenticatedHelpView, AuthenticatedHomeView, AuthenticatedTargetsView, BarChart, BaseHistoryCalendar, BottlenecksContent, BreakNotificationPopup, Card2 as Card, CardContent2 as CardContent, CardDescription2 as CardDescription, CardFooter2 as CardFooter, CardHeader2 as CardHeader, CardTitle2 as CardTitle, CycleTimeChart, CycleTimeOverTimeChart, DEFAULT_ANALYTICS_CONFIG, DEFAULT_AUTH_CONFIG, DEFAULT_CONFIG, DEFAULT_DATABASE_CONFIG, DEFAULT_DATE_TIME_CONFIG, DEFAULT_ENDPOINTS_CONFIG, DEFAULT_ENTITY_CONFIG, DEFAULT_SHIFT_CONFIG, DEFAULT_THEME_CONFIG, DEFAULT_VIDEO_CONFIG, DEFAULT_WORKSPACE_CONFIG, DEFAULT_WORKSPACE_POSITIONS, DashboardHeader, DashboardLayout, DashboardOverridesProvider, DashboardProvider, DateDisplay_default as DateDisplay, DateTimeDisplay, DebugAuth, DebugAuthView_default as DebugAuthView, EmptyStateMessage, FactoryView_default as FactoryView, GaugeChart, GridComponentsPlaceholder, Header, HelpView_default as HelpView, HomeView_default as HomeView, HourlyOutputChart2 as HourlyOutputChart, ISTTimer_default as ISTTimer, KPICard, KPIDetailView_default as KPIDetailView, KPIGrid, KPIHeader, KPISection, KPIsOverviewView_default as KPIsOverviewView, LINE_1_UUID, LargeOutputProgressChart, LeaderboardDetailView_default as LeaderboardDetailView, Legend6 as Legend, LineChart, LineHistoryCalendar, LineMonthlyHistory, LineMonthlyPdfGenerator, LinePdfExportButton, LinePdfGenerator, LineWhatsAppShareButton, LiveTimer, LoadingOverlay_default as LoadingOverlay, LoadingPage_default as LoadingPage, LoadingSpinner_default as LoadingSpinner, LoginPage, LoginView_default as LoginView, MainLayout, MetricCard_default as MetricCard, NoWorkspaceData, OptifyeAgentClient, OutputProgressChart, PageHeader, PieChart4 as PieChart, ProfileView_default as ProfileView, RegistryProvider, S3Service, SOPComplianceChart, SSEChatClient, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, ShiftDisplay_default as ShiftDisplay, ShiftsView_default as ShiftsView, SideNavBar, SingleVideoStream_default as SingleVideoStream, Skeleton, SlackAPI, SupabaseProvider, TargetWorkspaceGrid, TargetsView_default as TargetsView, ThreadSidebar, TimeDisplay_default as TimeDisplay, TimePickerDropdown, VideoCard, VideoGridView, VideoPreloader, WORKSPACE_POSITIONS, WhatsAppShareButton, WorkspaceCard, WorkspaceDetailView_default as WorkspaceDetailView, WorkspaceDisplayNameExample, WorkspaceGrid, WorkspaceGridItem, WorkspaceHistoryCalendar, WorkspaceMetricCards, WorkspaceMonthlyDataFetcher, WorkspaceMonthlyPdfGenerator, WorkspacePdfExportButton, WorkspacePdfGenerator, WorkspaceWhatsAppShareButton, actionService, apiUtils, authCoreService, authOTPService, authRateLimitService, checkRateLimit2 as checkRateLimit, clearAllRateLimits2 as clearAllRateLimits, clearRateLimit2 as clearRateLimit, clearS3VideoCache, clearS3VideoFromCache, clearWorkspaceDisplayNamesCache, clearWorkspaceMappingsForLine, cn, createStreamProxyHandler, createSupabaseClient, createThrottledReload, dashboardService, deleteThread, forceRefreshWorkspaceDisplayNames, formatDateInZone, formatDateTimeInZone, formatISTDate, formatIdleTime, formatTimeInZone, fromUrlFriendlyName, getAllThreadMessages, getAllWorkspaceDisplayNamesAsync, getAnonClient, getCameraNumber, getCompanyMetricsTableName, getConfigurableShortWorkspaceDisplayName, getConfigurableWorkspaceDisplayName, getCurrentShift, getCurrentTimeInZone, getDashboardHeaderTimeInZone, getDaysDifferenceInZone, getDefaultCameraStreamUrl, getDefaultTabForWorkspace, getManufacturingInsights, getMetricsTablePrefix, getOperationalDate, getS3SignedUrl, getS3VideoSrc, getShortWorkspaceDisplayName, getShortWorkspaceDisplayNameAsync, getStoredWorkspaceMappings, getThreadMessages, getUserThreads, getUserThreadsPaginated, getWorkspaceDisplayName, getWorkspaceDisplayNameAsync, getWorkspaceDisplayNamesMap, getWorkspaceFromUrl, getWorkspaceMappingsForLine, getWorkspaceNavigationParams, identifyCoreUser, initializeCoreMixpanel, isTransitionPeriod, isValidLineInfoPayload, isValidWorkspaceDetailedMetricsPayload, isValidWorkspaceMetricsPayload, isWorkspaceDisplayNamesLoaded, isWorkspaceDisplayNamesLoading, mergeWithDefaultConfig, optifyeAgentClient, preInitializeWorkspaceDisplayNames, preloadS3Video, preloadS3VideoUrl, preloadS3VideosUrl, preloadVideoUrl, preloadVideosUrl, qualityService, realtimeService, refreshWorkspaceDisplayNames, resetCoreMixpanel, s3VideoPreloader, storeWorkspaceMapping, streamProxyConfig, throttledReloadDashboard, toUrlFriendlyName, trackCoreEvent, trackCorePageView, updateThreadTitle, useActiveBreaks, useAnalyticsConfig, useAuth, useAuthConfig, useComponentOverride, useCustomConfig, useDashboardConfig, useDashboardMetrics, useDatabaseConfig, useDateFormatter, useDateTimeConfig, useEndpointsConfig, useEntityConfig, useFactoryOverviewMetrics, useFeatureFlags, useFormatNumber, useHistoricWorkspaceMetrics, useHlsStream, useHlsStreamWithCropping, useHookOverride, useLeaderboardMetrics, useLineDetailedMetrics, useLineKPIs, useLineMetrics, useLineWorkspaceMetrics, useMessages, useMetrics, useNavigation, useOverrides, usePageOverride, useRealtimeLineMetrics, useRegistry, useShiftConfig, useShifts, useSupabase, useSupabaseClient, useTargets, useTheme, useThemeConfig, useThreads, useVideoConfig, useWorkspaceConfig, useWorkspaceDetailedMetrics, useWorkspaceDisplayName, useWorkspaceDisplayNames, useWorkspaceDisplayNamesMap, useWorkspaceMetrics, useWorkspaceNavigation, useWorkspaceOperators, videoPreloader, whatsappService, withAuth, withRegistry, workspaceService };