From 5e1ce3b14e7c8bb6e5e0a5dc5b2ebdad5aa9f703 Mon Sep 17 00:00:00 2001
From: "Sode, Adedamola (DLSLtd,RAL,LSCI)" <adedamola.sode@diamond.ac.uk>
Date: Wed, 29 Apr 2026 13:21:41 +0000
Subject: [PATCH 1/4] Added conditions for branched services

---
 src/techui_builder/builder.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/techui_builder/builder.py b/src/techui_builder/builder.py
index 2f15ce34..78e4dd6a 100644
--- a/src/techui_builder/builder.py
+++ b/src/techui_builder/builder.py
@@ -89,7 +89,7 @@ def clean_files(self):
         logger_.info("Preserving edited screens for validation.")
         logger_.debug(f"Screens to validate: {list(self.validator.validate.keys())}")
 
-        logger_.info("Cleaning synoptic/ of generated screens.")
+        logger_.info("Cleaning synoptic directory of generated screens.")
 
         generated_files = self.generated_bobs
 

From 6688ea98184ebf4606dd2fc1062c4a45d594af66 Mon Sep 17 00:00:00 2001
From: "Sode, Adedamola (DLSLtd,RAL,LSCI)" <adedamola.sode@diamond.ac.uk>
Date: Wed, 29 Apr 2026 14:31:11 +0000
Subject: [PATCH 2/4] modified test_find_dirs

---
 tests/test_cli.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tests/test_cli.py b/tests/test_cli.py
index 526ce775..408bb0f0 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -67,14 +67,16 @@ def test_find_dirs(caplog):
     mock_services.relative_to.return_value = Path("mock_rel_path")
     mock_parent = MagicMock(spec=Path)
     mock_parent.glob.return_value = [mock_services]
-    mock_absolute = MagicMock()
+    mock_absolute = MagicMock(spec=Path)
     mock_absolute.parents = [mock_parent]
+    mock_absolute.parent = mock_parent
     mock_path = MagicMock(spec=Path)
     mock_path.absolute.return_value = mock_absolute
 
     services, synoptic = find_dirs(mock_path, "ixx")
 
-    assert synoptic == Path("mock_rel_path/synoptic")
+    assert synoptic == mock_absolute.parent
+    assert services == Path("mock_rel_path")
 
 
 def test_find_dirs_no_ixx_services_dir(caplog):

From 6773e50a8f7874d149e07321acf6065b0c91f2e9 Mon Sep 17 00:00:00 2001
From: "Sode, Adedamola (DLSLtd,RAL,LSCI)" <adedamola.sode@diamond.ac.uk>
Date: Thu, 28 May 2026 10:32:35 +0000
Subject: [PATCH 3/4] Adding test for jxx

---
 tests/test_cli.py | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/tests/test_cli.py b/tests/test_cli.py
index 408bb0f0..5f6df75c 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -93,6 +93,25 @@ def test_find_dirs_no_ixx_services_dir(caplog):
     assert exc_info.value.code is None
 
 
+def test_find_dirs_jxx_services(caplog):
+    mock_services = MagicMock(spec=Path)
+    mock_services.relative_to.return_value = Path("mock_rel_path")
+    mock_parent = MagicMock(spec=Path)
+    mock_parent.glob.return_value = [mock_services]
+    mock_absolute = MagicMock(spec=Path)
+    mock_absolute.parents = [mock_parent]
+    mock_absolute.parent = mock_parent
+    mock_path = MagicMock(spec=Path)
+    mock_path.absolute.return_value = mock_absolute
+
+    with caplog.at_level(logging.INFO):
+        services, synoptic = find_dirs(mock_path, "jxx")
+
+    assert synoptic == mock_absolute.parent
+    assert services == Path("mock_rel_path")
+    assert "jxx-services not found. Searching for Ixx-services..." in caplog.text
+
+
 def test_find_bob(caplog):
     bob_file = Mock(spec=Path)
     bob_file.exists = MagicMock(return_value=True)

From 3dfa638eb42dfcba5181cf2700d4a80cad51b927 Mon Sep 17 00:00:00 2001
From: "Sode, Adedamola (DLSLtd,RAL,LSCI)" <adedamola.sode@diamond.ac.uk>
Date: Tue, 2 Jun 2026 08:23:34 +0000
Subject: [PATCH 4/4] rebased changes for multiple beamlines

---
 src/techui_builder/main_app.py | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/techui_builder/main_app.py b/src/techui_builder/main_app.py
index 8cd6f06f..0da44b30 100644
--- a/src/techui_builder/main_app.py
+++ b/src/techui_builder/main_app.py
@@ -25,22 +25,34 @@ def find_dirs(file_path: Path, beamline: str) -> tuple:
     cwd = Path.cwd()
     logger_.debug(f"Working directory: {cwd}")
 
+    directory = beamline
+
+    if not beamline.startswith("i"):
+        # If not found, try searching for Ixx-services as some
+        # J/K beamlines are in Ixx-services dir
+        directory = f"i{beamline[1:]}"
+        logger_.info(
+            f"{beamline}-services not found. Searching for I{beamline[1:]}-services..."
+        )
     # Get the relative path of ixx-services to techui.yaml
     ixx_services_dir = next(
         (
             ixx_services.relative_to(cwd, walk_up=True)
             for parent in abs_path.parents
-            for ixx_services in parent.glob(f"{beamline}-services")
+            for ixx_services in parent.glob(f"{directory}-services")
         ),
         None,
     )
+
     if ixx_services_dir is None:
-        logging.critical("ixx-services not found. Is you file structure correct?")
+        logging.critical(
+            f"{beamline}-services not found. Is you file structure correct?"
+        )
         exit()
     logger_.debug(f"ixx-services relative path: {ixx_services_dir}")
 
     # Get the synoptic dir relative to the parent dir
-    synoptic_dir = ixx_services_dir.joinpath("synoptic")
+    synoptic_dir = abs_path.parent
     logger_.debug(f"synoptic relative path: {synoptic_dir}")
 
     return ixx_services_dir, synoptic_dir
