Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(ui): archive every Vite asset name and store shared chunks once (#2875)
Call Whitebad88fcbd58b
diff --git a/tests/test_ui_server_fastapi.py b/tests/test_ui_server_fastapi.pyindex ce769b20a..2381ef2a6 100644--- a/tests/test_ui_server_fastapi.py+++ b/tests/test_ui_server_fastapi.py@@ -1,6 +1,7 @@import asyncioimport gzipimport json+import osimport shutilimport threadingfrom types import SimpleNamespace@@ -20,7 +21,7 @@ from vibe.ui_compat import ()from starlette.websockets import WebSocketDisconnect-from vibe import remote_access, ui_server+from vibe import remote_access, ui_asset_archive, ui_serverfrom vibe.ui_server import appfrom tests.test_api_save_config_merge import _full_config_payloadfrom tests.ui_server_test_helpers import csrf_headers@@ -2746,6 +2747,8 @@ def test_static_ui_serves_previous_build_chunks_after_upgrade(monkeypatch, tmp_p(ui_dist / "index.html").write_text(f'<script src="/assets/index-{build}.js"></script>', encoding="utf-8")(assets_dir / f"index-{build}.js").write_text(f"import('./Page-{build}.js')", encoding="utf-8")(assets_dir / f"Page-{build}.js").write_text(f"// page {build}", encoding="utf-8")+ # Vite emits some chunk names with a leading underscore.+ (assets_dir / f"__vite-browser-external-{build}.js").write_text("export default {}", encoding="utf-8")(assets_dir / "shared-000.js").write_text("// shared", encoding="utf-8")assert client.get("/workbench/session-1").status_code == 200@@ -2757,6 +2760,9 @@ def test_static_ui_serves_previous_build_chunks_after_upgrade(monkeypatch, tmp_passert previous_chunk.text == "// page 111"assert previous_chunk.headers["Cache-Control"] == "public, max-age=31536000, immutable"assert "javascript" in previous_chunk.headers["Content-Type"]+ assert client.get("/assets/__vite-browser-external-111.js").status_code == 200+ # A chunk the current build shares is stored once, not once per install.+ assert os.path.samefile(ui_asset_archive.find_archived_asset("shared-000.js"), ui_dist / "assets" / "shared-000.js")install_build("333")diff --git a/vibe/ui_asset_archive.py b/vibe/ui_asset_archive.pyindex e0311ab6a..96164fbb0 100644--- a/vibe/ui_asset_archive.py+++ b/vibe/ui_asset_archive.py@@ -15,7 +15,8 @@ page has to reload.Layout under ``<runtime>/ui-assets/``:-- ``files/<name>``: one copy of each hashed asset (a hard link when possible)+- ``files/<name>``: one copy of each hashed asset, hard-linked to the current+ build's file when the filesystem allows- ``builds/<id>.json``: the asset names of one build and when it was lastrecorded"""@@ -38,7 +39,12 @@ logger = logging.getLogger(__name__)KEEP_BUILDS = 2-_ASSET_NAME = re.compile(r"[A-Za-z0-9][A-Za-z0-9._-]*")+# One path segment of the characters Vite emits, including a leading+# underscore (``__vite-browser-external-<hash>.js``). An allow-list keeps+# separators and Windows drive or stream syntax (``D:name``) out of the path.+# A leading dot is reserved for this archive's in-progress files and excludes+# ``.`` and ``..``.+_ASSET_NAME = re.compile(r"[A-Za-z0-9_][A-Za-z0-9._-]*")_record_lock = threading.Lock()_recorded_index_key: tuple[str, str] | None = None@@ -101,16 +107,22 @@ def _archive_build(assets_dir: Path, archive: Path) -> None:builds_dir.mkdir(parents=True, exist_ok=True)for name in names:+ source = assets_dir / nametarget = files_dir / name- if target.exists():- # Names are content hashes, so an existing file is this file.+ exists = target.exists()+ # Names are content hashes, so an existing file is this file. An upgrade+ # still writes it anew, so re-link it to the current build's copy;+ # otherwise every shared chunk keeps a superseded install's copy alive.+ if exists and os.path.samefile(source, target):continuepartial = files_dir / f".{name}.{os.getpid()}.partial"partial.unlink(missing_ok=True)try:- os.link(assets_dir / name, partial)+ os.link(source, partial)except OSError:- shutil.copyfile(assets_dir / name, partial)+ if exists:+ continue+ shutil.copyfile(source, partial)os.replace(partial, target)build_id = hashlib.sha256("\n".join(names).encode("utf-8")).hexdigest()[:16]