Skip to content

armgit / avibe

Public Imported from GitHub
0

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.

chore(merge): integrate latest master

Max598d9b711aa0
diff --cc storage/alembic/versions/20260806_0047_remove_session_queue_hold.py
index 000000000,c97c97eb4..a385857ed
mode 000000,100644..100644
--- a/storage/alembic/versions/20260806_0047_remove_session_queue_hold.py
+++ b/storage/alembic/versions/20260806_0047_remove_session_queue_hold.py
@@@ -1,0 -1,107 +1,107 @@@
+ """remove the Session queue hold policy
+
+ Revision ID: 20260806_0047
-Revises: 20260804_0046
++Revises: 20260804_0047
+ Create Date: 2026-08-06
+ """
+
+ from __future__ import annotations
+
+ import sqlalchemy as sa
+ from alembic import op
+
+ revision = "20260806_0047"
-down_revision = "20260804_0046"
++down_revision = "20260804_0047"
+ branch_labels = None
+ depends_on = None
+
+ _COLUMNS = ("queue_hold_state", "queue_hold_version", "queue_held_at")
+ _CHECK = "ck_agent_sessions_queue_hold_state"
+
+
+ def _column_names(bind) -> set[str]:
+ return {
+ str(column["name"])
+ for column in sa.inspect(bind).get_columns("agent_sessions")
+ }
+
+
+ def _check_names(bind) -> set[str]:
+ return {
+ str(check["name"])
+ for check in sa.inspect(bind).get_check_constraints("agent_sessions")
+ if check.get("name")
+ }
+
+
+ def _drop_hold_columns(bind) -> None:
+ columns = _column_names(bind)
+ checks = _check_names(bind)
+ with op.batch_alter_table("agent_sessions") as batch:
+ if _CHECK in checks:
+ batch.drop_constraint(_CHECK, type_="check")
+ for column in reversed(_COLUMNS):
+ if column in columns:
+ batch.drop_column(column)
+
+
+ def _restore_hold_columns(bind) -> None:
+ columns = _column_names(bind)
+ with op.batch_alter_table("agent_sessions") as batch:
+ if "queue_hold_state" not in columns:
+ batch.add_column(
+ sa.Column(
+ "queue_hold_state",
+ sa.String(),
+ server_default="open",
+ nullable=False,
+ )
+ )
+ if "queue_hold_version" not in columns:
+ batch.add_column(
+ sa.Column(
+ "queue_hold_version",
+ sa.Integer(),
+ server_default="1",
+ nullable=False,
+ )
+ )
+ if "queue_held_at" not in columns:
+ batch.add_column(sa.Column("queue_held_at", sa.String(), nullable=True))
+ if _CHECK not in _check_names(bind):
+ batch.create_check_constraint(
+ _CHECK,
+ "queue_hold_state in ('open', 'held')",
+ )
+
+
+ def _sqlite_rebuild(operation) -> None:
+ bind = op.get_bind()
+ # SQLite cannot rebuild a referenced parent table while FK enforcement is
+ # enabled. Keep the exception local to this autocommit block, restore it
+ # immediately, and fail if the rebuilt schema has any dangling references.
+ with op.get_context().autocommit_block():
+ bind.exec_driver_sql("PRAGMA foreign_keys=OFF")
+ try:
+ operation(bind)
+ finally:
+ bind.exec_driver_sql("PRAGMA foreign_keys=ON")
+ violations = bind.exec_driver_sql("PRAGMA foreign_key_check").fetchall()
+ if violations:
+ raise RuntimeError("queue hold removal left invalid SQLite foreign keys")
+
+
+ def upgrade() -> None:
+ bind = op.get_bind()
+ if bind.dialect.name == "sqlite":
+ _sqlite_rebuild(_drop_hold_columns)
+ else:
+ _drop_hold_columns(bind)
+
+
+ def downgrade() -> None:
+ bind = op.get_bind()
+ if bind.dialect.name == "sqlite":
+ _sqlite_rebuild(_restore_hold_columns)
+ else:
+ _restore_hold_columns(bind)
diff --cc tests/test_internal_server.py
index 8686a0938,e6ec0f94a..ccc98d186
--- a/tests/test_internal_server.py
+++ b/tests/test_internal_server.py
@@@ -2886,17 -2174,11 +2879,15 @@@ def test_async_dispatch_flushes_one_com
transcript = messages_service.list_session_messages(conn, session_id=session_id, types=("user",))
assert [m["text"] for m in transcript["messages"]] == ["first turn", "q1\nq2"]
assert transcript["messages"][1]["author_id"] == "remote:user-a"
- assert transcript["messages"][1]["metadata"]["_web_push_user_key"] == "remote:user-a"
+ assert not any(
+ key.startswith("_web_push_")
+ for key in transcript["messages"][1]["metadata"]
+ )
+ assert transcript["messages"][1]["metadata"]["_memory_user_id"] == "remote:user-a"
- def test_cancel_does_not_flush_queue(monkeypatch, tmp_path):
- """A user Stop interrupts the turn but must NOT flush the queue — the user
- asked to keep queued messages on stop ('不清空队列'). The queued rows survive
- the cancellation; only a natural turn end (or send-now) runs them."""
+ def test_cancel_resumes_the_oldest_queued_segment(monkeypatch, tmp_path):
+ """Once Stop makes the Session idle, its queued work starts immediately."""
from core.services import sessions as sessions_service
from storage import messages_service
from storage.db import create_sqlite_engine