Merge feature/17 into integration/spec16 (ticket #17: shared user-agent fix)

This commit is contained in:
soubarnak
2026-11-06 09:37:13 +05:30
4 changed files with 24 additions and 4 deletions
+6
View File
@@ -42,6 +42,12 @@ IBUS_TEXTDOMAIN: str = "voculinux"
UPDATE_CHECKER_USER_AGENT: str = "Voculinux-UpdateChecker"
def user_agent(version: str) -> str:
"""Outbound HTTP User-Agent for model downloads."""
return f"{APP_ID}/{version}"
RESOURCE_DIR_NAME: str = "voculinux"
VERIFICATION_STAMP_NAME: str = ".voculinux_verified"
@@ -27,7 +27,7 @@ if TYPE_CHECKING:
import numpy as np
import requests
from ..app_identity import APP_NAME, RESOURCE_DIR_NAME
from ..app_identity import APP_NAME, RESOURCE_DIR_NAME, user_agent
from ..audio.capture import ( # noqa: F401 (re-exported for compatibility)
_STICKY_LOCK_MIN_MEAN_SQUARE,
CaptureStalledError,
@@ -2731,7 +2731,7 @@ class SpeechRecognitionManager:
url,
stream=True,
timeout=self._MODEL_DOWNLOAD_TIMEOUT,
headers={"User-Agent": f"voculinux/{__version__}"},
headers={"User-Agent": user_agent(__version__)},
proxies=requests_proxies(),
)
except requests.exceptions.RequestException as e:
+2 -2
View File
@@ -36,7 +36,7 @@ gi.require_version("Gdk", "3.0")
# Need GLib for idle_add
from gi.repository import Gdk, GLib, GObject, Gtk, Pango # noqa: E402
from ..app_identity import APP_ID, APP_NAME, RESOURCE_DIR_NAME # noqa: E402
from ..app_identity import APP_NAME, RESOURCE_DIR_NAME, user_agent # noqa: E402
from ..audio.pulse_sources import ( # noqa: E402
PULSE_INDEX_BASE,
PulseSource,
@@ -6461,7 +6461,7 @@ class SettingsDialog(AboutSectionMixin):
try:
response = requests.get(
"https://huggingface.co/api/models/ggerganov/whisper.cpp",
headers={"User-Agent": f"{APP_ID}/{__version__}"},
headers={"User-Agent": user_agent(__version__)},
timeout=10,
proxies=requests_proxies(config),
)
+14
View File
@@ -117,6 +117,20 @@ def test_source_pinned_literals_reserved_for_rename():
assert 'window.set_title("Voculinux Dictation Pad")' in pad
def test_model_download_user_agent_is_shared_definition():
"""Model-download User-Agent strings resolve through one shared helper."""
identity = _load_identity()
assert identity.user_agent("9.9.9") == f"{identity.APP_ID}/9.9.9"
for rel in (
SRC_ROOT / "speech_recognition" / "recognition_manager.py",
SRC_ROOT / "ui" / "settings_dialog.py",
):
source = rel.read_text(encoding="utf-8")
assert "user_agent(__version__)" in source, rel
assert 'f"voculinux/{__version__}"' not in source, rel
assert 'f"{APP_ID}/{__version__}"' not in source, rel
def test_rename_inventory_files_exist():
"""Every rename surface the rename ticket must flip is a real checked file."""
identity = _load_identity()