diff --git a/src/editor_style_guide.py b/src/editor_style_guide.py index 0f03497ed..b6c2e13ca 100644 --- a/src/editor_style_guide.py +++ b/src/editor_style_guide.py @@ -552,9 +552,12 @@ def _recolor_object_phrase(prompt: str, target_word: str) -> str: if target_word: phrase = re.sub(r"\b" + re.escape(target_word) + r"\b", " ", phrase, count=1, flags=re.I) - phrase = re.sub(r"\s+", " ", phrase).strip(" .,!?") - phrase = re.sub(r"^(?:to|into|the|a|an)\s+", "", phrase, flags=re.I).strip() - phrase = re.sub(r"\s+(?:to|into)$", "", phrase, flags=re.I).strip() + words = " ".join(phrase.split()).strip(" .,!?").split() + if len(words) > 1 and words[0].casefold() in {"to", "into", "the", "a", "an"}: + words.pop(0) + if len(words) > 1 and words[-1].casefold() in {"to", "into"}: + words.pop() + phrase = " ".join(words) while phrase and _RECOLOR_TRAILING_ADJ.search(phrase): phrase = _RECOLOR_TRAILING_ADJ.sub("", phrase).strip() return phrase or "the subject" diff --git a/tests/test_gallery_image_model_picker.py b/tests/test_gallery_image_model_picker.py deleted file mode 100644 index 160355210..000000000 --- a/tests/test_gallery_image_model_picker.py +++ /dev/null @@ -1,39 +0,0 @@ -"""Source checks for the gallery Settings-tab image-model picker. - -The Quick Edit model picker lives in the editor; HARNESS mirrors it into the -gallery Settings tab, fed by GET /api/editor/image-models and sharing the -same localStorage key (`ge-ai-command-model`) so the two stay in sync. -""" -from pathlib import Path - -ROOT = Path(__file__).resolve().parents[1] -GALLERY_JS = (ROOT / "static/js/gallery.js").read_text(encoding="utf-8") - - -def test_settings_tab_has_image_model_picker(): - assert 'id="gallery-image-model"' in GALLERY_JS - assert "/api/editor/image-models" in GALLERY_JS - assert "ge-ai-command-model" in GALLERY_JS - - -def test_image_model_picker_lives_in_the_settings_container(): - settings_idx = GALLERY_JS.index('id="gallery-settings-container"') - picker_idx = GALLERY_JS.index('id="gallery-image-model"') - assert picker_idx > settings_idx - - -def test_picker_persists_with_the_shared_localstorage_key(): - assert "localStorage.setItem(_GE_MODEL_KEY" in GALLERY_JS - assert "localStorage.getItem(_GE_MODEL_KEY)" in GALLERY_JS - - -def test_cloud_image_models_are_listed_alongside_the_local_ones(): - """Gateway endpoints (OpenRouter) register as llm but carry image models. - - The picker must surface those ids too — otherwise the only selectable - edit model is the local Qwen server. - """ - routes = (ROOT / "routes/editor_agent_routes.py").read_text(encoding="utf-8") - assert "from src.image_model_ids import looks_like_image_generation_model" in routes - assert 'image_endpoint = getattr(ep, "model_type", None) == "image"' in routes - assert "if not image_endpoint and not looks_like_image_generation_model(name):" in routes