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(channels): separate slack browse-all cache
cyh84ebb9a22b2b
diff --git a/core/chat_discovery.py b/core/chat_discovery.pyindex 1ee9502cc..9f14431b5 100644--- a/core/chat_discovery.py+++ b/core/chat_discovery.py@@ -173,6 +173,8 @@ def _refresh_scope_for(platform: str, kwargs: dict[str, Any]) -> str | None:auth_context = _auth_context_for(platform, kwargs)if auth_context:parts.append(auth_context)+ if platform == "slack" and bool(kwargs.get("browse_all", False)):+ parts.append("browse_all")return ".".join(parts) or None@@ -500,9 +502,12 @@ def refresh_platform(refreshed_at=success_at,parent_scope_id=refreshed_parent,auth_context=auth_context,+ require_member=platform == "slack" and not bool(kwargs.get("browse_all", False)),)state = RefreshState(last_attempt_at=now, last_success_at=success_at, last_error=None)_write_refresh_state(conn, platform, state, now=success_at, refresh_scope=refresh_scope)+ if platform == "slack" and bool(kwargs.get("browse_all", False)) and auth_context:+ _write_refresh_state(conn, platform, state, now=success_at, refresh_scope=auth_context)return RefreshResult(ok=True, refresh_state=state)finally:engine.dispose()@@ -605,7 +610,8 @@ def channels_response(refreshing = Falseerror = state.last_error- if can_refresh and (force or not chats):+ cache_requires_refresh = _response_cache_requires_refresh(platform, state, refresh_kwargs)+ if can_refresh and (force or not chats or cache_requires_refresh):result = refresh_platform(platform, force=force, db_path=db_path, **refresh_kwargs)state = result.refresh_stateerror = result.error or state.last_error@@ -730,6 +736,7 @@ def _mark_not_returned(refreshed_at: str,parent_scope_id: str | None,auth_context: str | None,+ require_member: bool = False,) -> None:conditions = [scopes.c.platform == platform, scopes.c.scope_type == CHANNEL_SCOPE_TYPE]if parent_scope_id is not None:@@ -742,6 +749,8 @@ def _mark_not_returned(metadata = _json_loads(row["metadata_json"], {})if auth_context is not None and metadata.get(METADATA_AUTH_CONTEXT) != auth_context:continue+ if require_member and metadata.get(METADATA_IS_MEMBER) is not True:+ continuemetadata[METADATA_VISIBILITY_STATUS] = VISIBILITY_NOT_RETURNEDmetadata[METADATA_LAST_MISSING_AT] = refreshed_atconn.execute(@@ -847,10 +856,20 @@ def _filter_response_chats(if not include_private:result = [chat for chat in result if not chat.is_private]if require_member:- result = [chat for chat in result if chat.is_member is True]+ result = [+ chat+ for chat in result+ if chat.is_member is True and chat.visibility_status != VISIBILITY_NOT_RETURNED+ ]return result+def _response_cache_requires_refresh(platform: str, state: RefreshState, refresh_kwargs: dict[str, Any]) -> bool:+ if platform != "slack" or not bool(refresh_kwargs.get("browse_all", False)):+ return False+ return state.last_success_at is None++def _payload_native_type(native_type: str) -> str | int:if native_type.isdecimal():try:diff --git a/tests/test_chat_discovery.py b/tests/test_chat_discovery.pyindex 21533a4bd..cf0ba0051 100644--- a/tests/test_chat_discovery.py+++ b/tests/test_chat_discovery.py@@ -141,7 +141,10 @@ def test_refresh_marks_absent_rows_not_returned_without_deleting_settings(tmp_pa"slack","C_OLD",name="old",- metadata={chat_discovery.METADATA_AUTH_CONTEXT: _auth_context("slack", bot_token="x")},+ metadata={+ chat_discovery.METADATA_AUTH_CONTEXT: _auth_context("slack", bot_token="x"),+ chat_discovery.METADATA_IS_MEMBER: True,+ },db_path=db_path,)@@ -300,6 +303,86 @@ def test_slack_cached_response_respects_member_only_browse_mode(tmp_path: Path)assert {channel["id"] for channel in browse_all["channels"]} == {"C_MEMBER", "C_OTHER"}+def test_slack_member_only_response_excludes_not_returned_member_channels(tmp_path: Path) -> None:+ db_path = tmp_path / "vibe.sqlite"+ run_migrations(db_path)+ auth_context = _auth_context("slack", bot_token="x")+ chat_discovery.remember_chat(+ "slack",+ "C_GONE",+ name="gone",+ metadata={+ chat_discovery.METADATA_IS_MEMBER: True,+ chat_discovery.METADATA_VISIBILITY_STATUS: chat_discovery.VISIBILITY_NOT_RETURNED,+ chat_discovery.METADATA_AUTH_CONTEXT: auth_context,+ },+ db_path=db_path,+ )+ chat_discovery.remember_chat(+ "slack",+ "C_PRESENT",+ name="present",+ metadata={+ chat_discovery.METADATA_IS_MEMBER: True,+ chat_discovery.METADATA_AUTH_CONTEXT: auth_context,+ },+ db_path=db_path,+ )+ chat_discovery.set_state_meta(+ f"channel_refresh.slack.{auth_context}",+ {"last_attempt_at": "2999-01-01T00:00:00+00:00", "last_success_at": "2999-01-01T00:00:00+00:00", "last_error": None},+ db_path=db_path,+ )++ response = chat_discovery.channels_response("slack", require_member=True, bot_token="x", db_path=db_path)++ assert [channel["id"] for channel in response["channels"]] == ["C_PRESENT"]+++def test_slack_browse_all_refreshes_after_member_only_cache_hit(tmp_path: Path, monkeypatch) -> None:+ db_path = tmp_path / "vibe.sqlite"+ run_migrations(db_path)+ calls: list[bool] = []++ from vibe import api++ def fake_list_channels_live(_token: str, browse_all: bool = False) -> dict:+ calls.append(browse_all)+ channels = [{"id": "C_MEMBER", "name": "member", "is_private": False, "is_member": True}]+ if browse_all:+ channels.append({"id": "C_OTHER", "name": "other", "is_private": False, "is_member": False})+ return {"ok": True, "channels": channels, "is_member_only": not browse_all}++ monkeypatch.setattr(api, "list_channels_live", fake_list_channels_live)++ member_only = chat_discovery.channels_response(+ "slack",+ bot_token="x",+ browse_all=False,+ require_member=True,+ db_path=db_path,+ )+ browse_all = chat_discovery.channels_response(+ "slack",+ bot_token="x",+ browse_all=True,+ require_member=False,+ db_path=db_path,+ )+ cached_browse_all = chat_discovery.channels_response(+ "slack",+ bot_token="x",+ browse_all=True,+ require_member=False,+ db_path=db_path,+ )++ assert calls == [False, True]+ assert [channel["id"] for channel in member_only["channels"]] == ["C_MEMBER"]+ assert {channel["id"] for channel in browse_all["channels"]} == {"C_MEMBER", "C_OTHER"}+ assert {channel["id"] for channel in cached_browse_all["channels"]} == {"C_MEMBER", "C_OTHER"}++def test_slack_channel_cache_is_scoped_by_auth_context(tmp_path: Path, monkeypatch) -> None:db_path = tmp_path / "vibe.sqlite"run_migrations(db_path)