This commit is contained in:
2026-01-23 01:19:36 -08:00
parent 072edb4399
commit 5626bde557
2 changed files with 46 additions and 15 deletions

View File

@@ -615,9 +615,23 @@ class ConfigModal(ModalScreen):
self.notify("Clipboard not supported in this terminal", severity="warning")
def on_store_type_selected(self, stype: str) -> None:
if not stype: return
new_name = f"new_{stype}"
if not stype:
return
existing_names: set[str] = set()
store_block = self.config_data.get("store")
if isinstance(store_block, dict):
st_entries = store_block.get(stype)
if isinstance(st_entries, dict):
existing_names = {str(name) for name in st_entries.keys() if name}
base_name = f"new_{stype}"
new_name = base_name
suffix = 1
while new_name in existing_names:
suffix += 1
new_name = f"{base_name}_{suffix}"
if "store" not in self.config_data:
self.config_data["store"] = {}
if stype not in self.config_data["store"]:
@@ -644,7 +658,7 @@ class ConfigModal(ModalScreen):
for rk in required:
if rk.upper() != "NAME":
new_config[rk] = ""
self.config_data["store"][stype][new_name] = new_config
self.editing_item_type = f"store-{stype}"
self.editing_item_name = new_name

View File

@@ -1534,19 +1534,11 @@ def main(argv: Optional[list[str]] = None) -> int:
client_found = p
break
script_dir = Path(__file__).resolve().parent
ensure_run_client_helper(dest, script_dir)
run_client_script = None
if client_found:
script_dir = Path(__file__).resolve().parent
helper_src = script_dir / "run_client.py"
helper_dest = dest / "run_client.py"
if helper_src.exists() and not helper_dest.exists():
try:
shutil.copy2(helper_src, helper_dest)
if os.name != "nt":
helper_dest.chmod(helper_dest.stat().st_mode | 0o111)
logging.debug("Copied run_client helper to %s", helper_dest)
except Exception as exc: # pragma: no cover - best effort
logging.debug("Failed to copy run_client helper: %s", exc)
# Prefer run_client helper located in the cloned repo; if missing, fall back to top-level scripts folder helper.
helper_candidates = [dest / "run_client.py", script_dir / "run_client.py"]
for cand in helper_candidates:
@@ -1784,5 +1776,30 @@ def main(argv: Optional[list[str]] = None) -> int:
return 99
def ensure_run_client_helper(dest: Path, script_dir: Path) -> Optional[Path]:
"""Ensure the run_client helper is installed inside the target repository."""
helper_src = script_dir / "run_client.py"
if not helper_src.exists():
logging.debug(
"run_client helper not found in %s; skipping copy.",
helper_src,
)
return None
helper_dest = dest / "run_client.py"
if helper_dest.exists():
return helper_dest
try:
shutil.copy2(helper_src, helper_dest)
if os.name != "nt":
helper_dest.chmod(helper_dest.stat().st_mode | 0o111)
logging.debug("Copied run_client helper to %s", helper_dest)
return helper_dest
except Exception as exc:
logging.debug("Failed to copy run_client helper: %s", exc)
return None
if __name__ == "__main__":
raise SystemExit(main())