tmux observer
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Use sol CLI for registration before falling back to HTTP

When sol is installed on the same machine, use `sol remote --json create`
for registration instead of requiring the server to be running. Falls back
to HTTP registration if sol is not found or CLI fails.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

+49 -10
+27 -9
src/solstone_tmux/cli.py
··· 97 97 config.ensure_dirs() 98 98 save_config(config) 99 99 100 - # Auto-register 100 + # Auto-register — try sol CLI first (no server needed), fall back to HTTP 101 101 if not config.key: 102 - print("Registering with server...") 103 - client = UploadClient(config) 104 - if client.ensure_registered(config): 105 - # Reload config to pick up persisted key 106 - config = load_config() 107 - print(f"Registered (key: {config.key[:8]}...)") 108 - else: 109 - print("Warning: registration failed. Run setup again when server is available.") 102 + sol = shutil.which("sol") 103 + if sol: 104 + print("Registering via sol CLI...") 105 + try: 106 + result = subprocess.run( 107 + [sol, "remote", "--json", "create", config.stream], 108 + capture_output=True, text=True, timeout=10, 109 + ) 110 + if result.returncode == 0: 111 + data = json.loads(result.stdout) 112 + config.key = data["key"] 113 + save_config(config) 114 + print(f"Registered (key: {config.key[:8]}...)") 115 + else: 116 + print(f"CLI registration failed, trying HTTP...") 117 + except (subprocess.TimeoutExpired, json.JSONDecodeError, KeyError, OSError): 118 + print("CLI registration failed, trying HTTP...") 119 + 120 + if not config.key: 121 + print("Registering with server...") 122 + client = UploadClient(config) 123 + if client.ensure_registered(config): 124 + config = load_config() 125 + print(f"Registered (key: {config.key[:8]}...)") 126 + else: 127 + print("Warning: registration failed. Run setup again when server is available.") 110 128 else: 111 129 print(f"Already registered (key: {config.key[:8]}...)") 112 130
+22 -1
src/solstone_tmux/upload.py
··· 11 11 12 12 import json 13 13 import logging 14 + import shutil 15 + import subprocess 14 16 import time 15 17 from pathlib import Path 16 18 from typing import Any, NamedTuple ··· 56 58 def ensure_registered(self, config: Config) -> bool: 57 59 """Ensure the client has a valid key, auto-registering if needed. 58 60 61 + Tries sol CLI first (no server needed), falls back to HTTP. 59 62 Returns True if a key is available. 60 63 """ 61 64 if self._key: 62 65 return True 66 + 67 + # Try sol CLI registration first 68 + name = self._stream or "solstone-tmux" 69 + sol = shutil.which("sol") 70 + if sol: 71 + try: 72 + result = subprocess.run( 73 + [sol, "remote", "--json", "create", name], 74 + capture_output=True, text=True, timeout=10, 75 + ) 76 + if result.returncode == 0: 77 + data = json.loads(result.stdout) 78 + self._key = data["key"] 79 + self._persist_key(config, self._key) 80 + logger.info(f"CLI-registered as '{name}' (key: {self._key[:8]}...)") 81 + return True 82 + except (subprocess.TimeoutExpired, json.JSONDecodeError, KeyError, OSError) as e: 83 + logger.debug(f"CLI registration failed: {e}") 84 + 63 85 if not self._url: 64 86 return False 65 87 66 88 url = f"{self._url}/app/remote/api/create" 67 - name = self._stream or "solstone-tmux" 68 89 69 90 for attempt, delay in enumerate(self._retry_backoff): 70 91 try: