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(workbench): session-guard send-now/cancel failures + skip empty send-now interrupt (Codex round 15)
cyh3092ff1071a3
diff --git a/core/internal_server.py b/core/internal_server.pyindex 4eabce9a4..dce3aa380 100644--- a/core/internal_server.py+++ b/core/internal_server.py@@ -465,6 +465,18 @@ def create_app(controller: "Controller") -> FastAPI:"""entry = in_flight.get(session_id)if entry is not None and not entry[0].done():+ # Don't interrupt a live turn unless there is actually something queued+ # to cut in with — a stale queue item already flushed/removed by+ # another tab would otherwise make send-now an unintended Stop (Codex+ # P2). Report ``empty`` and leave the running turn alone.+ from storage import messages_service+ from storage.db import create_sqlite_engine++ engine = create_sqlite_engine()+ with engine.connect() as conn:+ has_queue = bool(messages_service.list_queued(conn, session_id))+ if not has_queue:+ return {"ok": True, "session_id": session_id, "status": "empty"}_task, turn_context = entry# Record the flush intent BEFORE awaiting the interrupt: if the stop# lets the turn settle normally during the await, _run_turn's finallydiff --git a/ui/src/components/workbench/ChatPage.tsx b/ui/src/components/workbench/ChatPage.tsxindex 5045d4baf..ed45f3474 100644--- a/ui/src/components/workbench/ChatPage.tsx+++ b/ui/src/components/workbench/ChatPage.tsx@@ -397,12 +397,11 @@ export const ChatPage: React.FC = () => {if (!sessionId || !working) return;try {const res = await api.cancelSession(sessionId);- // Don't clear the working state here. cancelSession returns a non-throwing- // payload for controller-side failures (503 socket-unavailable, 404- // not_in_flight); if the stop didn't reach the backend the turn may still- // be live, so keep Stop available and surface the failure (Codex P2). On- // success the backend is interrupted and the authoritative ``turn.end``- // clears the working state.+ // Drop a stale response after a chat switch — it must not clear B's+ // working or stamp A's error on B (Codex P2).+ if (sessionId !== sessionIdRef.current) return;+ // On success the backend is interrupted and the authoritative ``turn.end``+ // clears the working state, so we don't clear it here.if (res && res.ok === false) {if (res.code === 'not_in_flight') {// The controller has no running turn — our working state was stale@@ -417,7 +416,7 @@ export const ChatPage: React.FC = () => {}} catch (err: any) {// The cancel request itself threw (network) — surface it; keep Stop.- setError(err?.message ?? String(err));+ if (sessionId === sessionIdRef.current) setError(err?.message ?? String(err));}}, [api, sessionId, working, t, syncTurnState]);@@ -459,8 +458,12 @@ export const ChatPage: React.FC = () => {void refreshQueue();}} catch (err: any) {- setWorking(false);- setError(err?.message ?? String(err));+ // Same session guard as the success path: a rejection after a chat switch+ // must not clear the new chat's working / stamp this error on it (Codex P2).+ if (sessionId === sessionIdRef.current) {+ setWorking(false);+ setError(err?.message ?? String(err));+ }}}, [api, sessionId, queue, t, refreshQueue]);