Use Claude Code, Codex, VSCode, Pi, and OpenCode (and 6 other harnesses) for free (1.3B+ free tokens) from your terminal, app, IDE, or phone, and now from the browser with native browser sessions (multi-harness + multi-model) like OpenClaw (voice supported + ToS friendly)
Python
fixed replies to pending incorrectly starting a new cli when they should be queued
Alishahryar12c6b40012a25
diff --git a/messaging/handler.py b/messaging/handler.pyindex 5754dcd2..47d2cb17 100644--- a/messaging/handler.py+++ b/messaging/handler.py@@ -100,6 +100,11 @@ class ClaudeMessageHandler:# Determine session ID for queuingif session_id_to_resume:queue_session_id = session_id_to_resume+ # Index current messages immediately so they can be replied to even while queued+ self.session_store.update_last_message(+ queue_session_id, incoming.message_id+ )+ self.session_store.update_last_message(queue_session_id, status_msg_id)else:# New session - use temp IDqueue_session_id = f"pending_{incoming.message_id}"@@ -139,14 +144,19 @@ class ClaudeMessageHandler:}last_ui_update = 0.0- captured_session_id = (- session_id_to_resume- if not session_id_to_resume.startswith("pending_")- else None- )+ captured_session_id = None+ if session_id_to_resume:+ if session_id_to_resume.startswith("pending_"):+ # Check if it was already resolved earlier+ captured_session_id = await self.cli_manager.get_real_session_id(+ session_id_to_resume+ )+ else:+ captured_session_id = session_id_to_resume+temp_session_id = (session_id_to_resume- if session_id_to_resume.startswith("pending_")+ if session_id_to_resume and session_id_to_resume.startswith("pending_")else None)@@ -201,16 +211,16 @@ class ClaudeMessageHandler:if event_data.get("type") == "session_info":real_session_id = event_data.get("session_id")if real_session_id and temp_session_id:+ # 1. Update CLI Manager mappingawait self.cli_manager.register_real_session_id(temp_session_id, real_session_id)- captured_session_id = real_session_id- self.session_store.save_session(- session_id=real_session_id,- chat_id=chat_id,- initial_msg_id=incoming.message_id,- platform=incoming.platform,+ # 2. Update Session Store (properly migrates all messages)+ self.session_store.rename_session(+ temp_session_id, real_session_id)+ captured_session_id = real_session_id+ temp_session_id = None # Resolvedcontinueparsed_list = CLIParser.parse_event(event_data)diff --git a/messaging/session.py b/messaging/session.pyindex f7e84b48..7774a819 100644--- a/messaging/session.py+++ b/messaging/session.py@@ -179,6 +179,36 @@ class SessionStore:self._save()logger.debug(f"Updated session {session_id} last_msg to {msg_id}")+ def rename_session(self, old_id: str, new_id: str) -> bool:+ """+ Rename a session ID, migrating all message mappings.++ This is crucial for handing over "pending_" sessions to real Claude session IDs.+ """+ with self._lock:+ if old_id not in self._sessions:+ logger.warning(f"Session {old_id} not found for rename to {new_id}")+ return False++ # Transfer record+ record = self._sessions.pop(old_id)+ record.session_id = new_id+ record.updated_at = datetime.utcnow().isoformat()+ self._sessions[new_id] = record++ # Update all message mappings pointing to the old ID+ items_to_update = [+ k for k, v in self._msg_to_session.items() if v == old_id+ ]+ for key in items_to_update:+ self._msg_to_session[key] = new_id++ self._save()+ logger.info(+ f"Renamed session {old_id} to {new_id} ({len(items_to_update)} mappings updated)"+ )+ return True+def get_session_record(self, session_id: str) -> Optional[SessionRecord]:"""Get full session record."""with self._lock: