← Commit history
README.md+4
@@ -108,6 +108,10 @@ fixes startup timeouts in restored hidden tabs, and removes the typing-box fade. See [installation, extension updates, and uninstall behavior](docs/RELOAD-INTEGRATION.md).  +### Broken Codex builds are held back++Version 0.1.28 keeps Codex working when OpenAI ships a build that does not load. Builds listed in `runtime/bad-versions.json` (26.1021.22027 and its 26.51021.22027 pre-release: the UI never loads and freezes the editor, [openai/codex#56780](https://github.com/openai/codex/issues/56780)) are swapped back to the last good build once no Codex turn is running, the user sees a notice, and the hold lifts by itself when Open VSX ships a build that is not listed. The list is re-read from this page hourly, so adding or clearing a build needs no release. A Codex update that changes the backend's startup options now replaces an idle backend instead of refusing every Codex view, and the runtime installs bubblewrap (Codex's Linux sandbox) when sudo needs no password.+ ### Skip the repeated IDE walkthrough  Version 0.1.23 opens new Codex editor tabs directly at the prompt. The default ships through Hydrogen’s existing Codex package dependency; it preserves sign-in and permission prompts. See [diagnosis and verification](docs/CODEX-WALKTHROUGH.md). Already-open walkthrough tabs should be closed and reopened.
package.json+2−1
@@ -4,7 +4,7 @@   "type": "app",   "title": "Codex",   "brief": "Codex in Adom Hydrogen: ecosystem setup, dock dashboard and live engineering demos.",-  "version": "0.1.27",+  "version": "0.1.28",   "description": "Codex in Adom Hydrogen with reusable CAD routing, electrical review, copper-ablation and narrated video skills, plus verified KiCad and Fusion demo progressions.",   "org": "adom",   "needs_sudo": false,@@ -22,6 +22,7 @@     "runtime/*.py",     "runtime/*.cjs",     "runtime/*.css",+    "runtime/*.json",     "runtime/vendor/*.md",     "runtime/vendor/*LICENSE",     "runtime/vendor/websockets/*.py",
page.json+2−1
@@ -4,7 +4,7 @@   "type": "app",   "title": "Codex",   "brief": "Codex in Adom Hydrogen: ecosystem setup, dock dashboard and live engineering demos.",-  "version": "0.1.27",+  "version": "0.1.28",   "hero": {     "type": "image",     "path": "screenshots/hero.png"@@ -79,6 +79,7 @@     "runtime/*.py",     "runtime/*.cjs",     "runtime/*.css",+    "runtime/*.json",     "runtime/vendor/*.md",     "runtime/vendor/*LICENSE",     "runtime/vendor/websockets/*.py",
runtime/bad-versions.jsonadded+10
@@ -0,0 +1,10 @@+{+  "fallback": "26.908.40401",+  "builds": [+    {+      "versions": ["26.1021.22027", "26.51021.22027"],+      "reason": "its user interface never finishes loading and freezes the whole editor while it tries",+      "issue": "https://github.com/openai/codex/issues/56780"+    }+  ]+}
runtime/guard.pyadded+158
@@ -0,0 +1,158 @@+#!/usr/bin/env python3+"""Hold the last good Codex extension while the newest build is known to be broken.++The editor auto-updates Codex. When it installs a build listed in+bad-versions.json (bundled; refreshed hourly from the wiki page so a build can+be listed or cleared without a package release), put back the last good build+and hold it only while Open VSX's newest build on that channel is still listed.+Then release the hold so normal updates resume. Never while a Codex turn runs.+"""+import json+import os+from pathlib import Path+import shutil+import signal+import subprocess+import time+import urllib.request++import runtime++ROOT = Path(__file__).resolve().parent+LIST_URL = 'https://wiki.adom.inc/api/v1/pages/adom/codex/files/runtime/bad-versions.json'+OPEN_VSX_QUERY = 'https://open-vsx.org/api/-/query?namespaceName=openai&extensionName=chatgpt&includeAllVersions=true'+TARGET = 'linux-arm64' if os.uname().machine == 'aarch64' else 'linux-x64'+ID = 'openai.chatgpt'+REFRESH_S = 3600+++def fetch_json(url, timeout=15):+    request = urllib.request.Request(url, headers={'User-Agent': 'adom-codex-guard'})+    with urllib.request.urlopen(request, timeout=timeout) as response:+        return json.load(response)+++def key(version):+    return tuple(int(p) for p in version.split('.'))+++class Guard:+    def __init__(self, integration):+        self.home = integration.home+        self.extensions = integration.extensions+        self.registry = self.extensions / 'extensions.json'+        self.path = integration.state / 'guard.json'+        self.write = integration.write_json+        try: self.state = json.loads(self.path.read_text())+        except (OSError, ValueError): self.state = {}++    def save(self):+        self.write(self.path, self.state)++    def bad_list(self):+        """Wiki copy when fresh, else the last fetched copy, else the bundled one."""+        if time.time() - self.state.get('list_checked', 0) > REFRESH_S:+            self.state['list_checked'] = time.time()+            try: self.state['list'] = fetch_json(LIST_URL)+            except Exception as error: self.state['list_error'] = str(error)+            self.save()+        if isinstance(self.state.get('list'), dict): return self.state['list']+        return json.loads((ROOT / 'bad-versions.json').read_text())++    def bad(self, listing, version):+        return next((b for b in listing.get('builds', []) if version in b.get('versions', [])), None)++    def installed(self):+        try: entries = json.loads(self.registry.read_text())+        except (OSError, ValueError): return None+        return next((e for e in entries if e.get('identifier', {}).get('id') == ID), None)++    def set_metadata(self, **values):+        entries = json.loads(self.registry.read_text())+        for entry in entries:+            if entry.get('identifier', {}).get('id') == ID: entry.setdefault('metadata', {}).update(values)+        temporary = self.registry.with_name(self.registry.name + '.adom-codex.tmp')+        temporary.write_text(json.dumps(entries))+        temporary.replace(self.registry)++    def newest(self, pre_release):+        """Newest Open VSX build on the user's channel (a pre-release user also gets stable).+        OpenAI numbers pre-releases above stable (26.5xxx > 26.9xx), so ask for each+        version's channel instead of trusting the version order."""+        query = fetch_json(f'{OPEN_VSX_QUERY}&targetPlatform={TARGET}')+        versions = [e['version'] for e in query.get('extensions', [])+                    if pre_release or not e.get('preRelease')]+        return max(versions, key=key) if versions else None++    def notify(self, message, level='warning'):+        tool = shutil.which('adom-vscode') or str(self.home / '.local/bin/adom-vscode')+        try: subprocess.run([tool, 'notify', '--level', level, message], timeout=20,+                            stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)+        except Exception: pass++    def codex_idle(self):+        """No Codex turn running. A missing backend is idle."""+        directory = runtime.state_dir()+        try: metadata = json.loads((directory / 'server.json').read_text())+        except (OSError, ValueError): return True, None+        if not runtime.process_matches(metadata): return True, None+        try: return runtime.backend_idle(directory / 'server.sock'), metadata+        except Exception: return False, metadata++    def retire_backend(self, metadata, bad_versions):+        """A backend started by a bad build has that build's startup options; the good+        build's views could never attach to it. Stop it while it is idle."""+        if not metadata: return+        running = runtime.extension_version(metadata.get('binary', ''))+        if not running or '.'.join(map(str, running)) not in bad_versions: return+        os.kill(metadata['pid'], signal.SIGTERM)+        deadline = time.monotonic() + 10+        while runtime.process_matches(metadata) and time.monotonic() < deadline: time.sleep(.05)++    def check(self):+        entry = self.installed()+        if not entry: return+        version = entry.get('version', '')+        metadata = entry.get('metadata', {})+        listing = self.bad_list()+        build = self.bad(listing, version)+        if not build:+            self.state['last_good'] = version+            if self.state.get('held') == version: self.maybe_release(listing, metadata)+            self.save()+            return+        good = self.state.get('last_good') or listing.get('fallback')+        if not good or self.bad(listing, good): return+        idle, backend = self.codex_idle()+        if not idle: return  # a turn is running; try again on the next pass+        code_server = shutil.which('code-server') or '/usr/lib/code-server/bin/code-server'+        result = subprocess.run([code_server, '--install-extension', f'{ID}@{good}', '--force'],+                                capture_output=True, text=True, timeout=600)+        if result.returncode != 0:+            self.state['last_error'] = (result.stdout + result.stderr)[-500:]+            self.save()+            return+        # Installing an exact version pins it, which is the hold we want until a fix ships.+        self.set_metadata(pinned=True, preRelease=False)+        self.retire_backend(backend, build.get('versions', []))+        self.state.update(held=good, held_since=time.time(), held_from=version,+                          channel_pre_release=bool(metadata.get('preRelease')), release_checked=0)+        self.save()+        self.notify(f'Codex {version} has a known problem ({build.get("reason", "")} {build.get("issue", "")}), '+                    f'so Adom kept Codex {good}. Reload the window if Codex does not load. '+                    'Updates resume automatically once OpenAI ships a fixed build.')++    def maybe_release(self, listing, metadata):+        if not metadata.get('pinned'):+            self.state.pop('held', None)  # someone already released it+            return+        if time.time() - self.state.get('release_checked', 0) < REFRESH_S: return+        self.state['release_checked'] = time.time()+        try: newest = self.newest(self.state.get('channel_pre_release', False))+        except Exception as error:+            self.state['release_error'] = str(error)+            return+        if newest and not self.bad(listing, newest) and key(newest) > key(self.state['held']):+            self.set_metadata(pinned=False)+            self.state.pop('held', None)+            self.notify(f'Codex {newest} is out with the fix; it will install with your next update.', 'info')
runtime/manage.py+19
@@ -167,9 +167,28 @@ class Integration:                     with (self.state / 'mutation.lock').open('a') as mutation:                         fcntl.flock(mutation, fcntl.LOCK_EX)                         self.reconcile()+                        self.guard()                 except Exception as error: print(str(error), flush=True)                 time.sleep(5) +    def guard(self):+        from guard import Guard+        Guard(self).check()+        self.ensure_bubblewrap()++    def ensure_bubblewrap(self):+        """Newer Codex sandboxes commands with bubblewrap and warns without it. Install it+        once a day at most, only when sudo needs no password; never prompt."""+        if shutil.which('bwrap'): return+        stamp = self.state / 'bubblewrap-attempt'+        if stamp.exists() and time.time() - stamp.stat().st_mtime < 86400: return+        stamp.touch()+        env = dict(os.environ, DEBIAN_FRONTEND='noninteractive')+        install = ['sudo', '-n', 'apt-get', 'install', '-y', '-q', 'bubblewrap']+        if subprocess.run(install, env=env, capture_output=True, timeout=600).returncode != 0:+            subprocess.run(['sudo', '-n', 'apt-get', 'update', '-q'], env=env, capture_output=True, timeout=600)+            subprocess.run(install, env=env, capture_output=True, timeout=600)+     def uninstall(self, isolated=False):         if not self.marker.exists(): return {'state': 'not_installed'}         backup = json.loads(self.marker.read_text())
runtime/runtime.py+7−6
@@ -221,23 +221,24 @@ def ensure_server(binary, args, client_guard=None):         except (OSError, ValueError):             metadata = {}         if process_matches(metadata):-            if metadata.get('args') != args:-                raise RuntimeError('The running Codex backend has different startup options; '-                                   'finish its work before changing runtime options')+            # New extension builds pass new startup options. Treat that like a version+            # change: replace the backend once it is idle with no other views attached,+            # instead of refusing every Codex view until something kills it.+            same_args = metadata.get('args') == args             same_binary = (metadata.get('identity') == identity(binary) if 'identity' in metadata                            else metadata.get('binary') == str(binary))             if not socket_alive(sock):                 raise RuntimeError('The existing Codex backend is alive but unavailable; '                                    'refusing to start a competing thread writer')-            if same_binary: return sock+            if same_binary and same_args: return sock             requested_version = extension_version(binary)             running_version = extension_version(metadata.get('binary', ''))             if requested_version and running_version and requested_version < running_version:                 raise RuntimeError('This editor uses an older Codex extension than the running backend. '                                    'Reload the editor to use the updated extension; backend downgrade refused.')             # Matching generated schemas permit reconnecting without replacing-            # the writer. Different/unknown protocols retain the conservative gate.-            compatible = compatible_backend(metadata, binary, directory)+            # the writer. Different/unknown protocols or options keep the conservative gate.+            compatible = same_args and compatible_backend(metadata, binary, directory)             if client_guard is None:                 raise RuntimeError('Backend version differs; upgrade requires exclusive client ownership')             try: fcntl.flock(client_guard, fcntl.LOCK_EX | fcntl.LOCK_NB)