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.

fix(channels): respect refresh backoff

cyh5959a2506626
diff --git a/core/chat_discovery.py b/core/chat_discovery.py
index c0830250a..aded97ff9 100644
--- a/core/chat_discovery.py
+++ b/core/chat_discovery.py
@@ -550,9 +550,9 @@ def channels_response(
can_refresh = platform in {"slack", "discord", "lark"}
if can_refresh and (force or not chats):
- result = refresh_platform(platform, force=True, db_path=db_path, **refresh_kwargs)
+ result = refresh_platform(platform, force=force, db_path=db_path, **refresh_kwargs)
state = result.refresh_state
- error = result.error
+ error = result.error or state.last_error
all_chats = list_chats(platform, include_private=True, parent_scope_id=parent_scope_id, db_path=db_path)
chats = _filter_response_chats(all_chats, include_private=include_private, require_member=require_member)
elif can_refresh and should_refresh(platform, refresh_scope=refresh_scope, db_path=db_path):
diff --git a/tests/test_chat_discovery.py b/tests/test_chat_discovery.py
index 9b6f4b178..45310cd73 100644
--- a/tests/test_chat_discovery.py
+++ b/tests/test_chat_discovery.py
@@ -155,6 +155,30 @@ def test_refresh_failure_keeps_stale_cache_and_records_error(tmp_path: Path, mon
assert response["error"] == "boom"
+def test_empty_cache_channel_response_respects_refresh_backoff(tmp_path: Path, monkeypatch) -> None:
+ db_path = tmp_path / "vibe.sqlite"
+ run_migrations(db_path)
+ calls = 0
+
+ from vibe import api
+
+ def fail_refresh(_token: str, browse_all: bool = False) -> dict:
+ nonlocal calls
+ calls += 1
+ return {"ok": False, "error": "bad token"}
+
+ monkeypatch.setattr(api, "list_channels_live", fail_refresh)
+
+ first = chat_discovery.channels_response("slack", bot_token="x", db_path=db_path)
+ second = chat_discovery.channels_response("slack", bot_token="x", db_path=db_path)
+
+ assert calls == 1
+ assert first["ok"] is False
+ assert first["error"] == "bad token"
+ assert second["ok"] is False
+ assert second["error"] == "bad token"
+
+
def test_slack_cached_response_respects_member_only_browse_mode(tmp_path: Path) -> None:
db_path = tmp_path / "vibe.sqlite"
run_migrations(db_path)
diff --git a/ui/src/components/steps/ChannelList.tsx b/ui/src/components/steps/ChannelList.tsx
index f60d8a9ec..bdad05671 100644
--- a/ui/src/components/steps/ChannelList.tsx
+++ b/ui/src/components/steps/ChannelList.tsx
@@ -295,6 +295,13 @@ export const ChannelList: React.FC<ChannelListProps> = ({ data = {}, onNext, onB
const larkAppSecret = config.lark?.app_secret || data.lark?.app_secret || '';
const larkDomain = config.lark?.domain || data.lark?.domain || 'feishu';
+ useEffect(() => {
+ return () => {
+ Object.values(refreshFollowupTimersRef.current).forEach((timer) => clearTimeout(timer));
+ refreshFollowupTimersRef.current = {};
+ };
+ }, [platform, selectedGuild, pageTab]);
+
useEffect(() => {
if (platform !== 'discord') return;
if (selectedGuild) return;
@@ -371,6 +378,7 @@ export const ChannelList: React.FC<ChannelListProps> = ({ data = {}, onNext, onB
const existing = refreshFollowupTimersRef.current[platformId];
if (existing) clearTimeout(existing);
refreshFollowupTimersRef.current[platformId] = setTimeout(() => {
+ delete refreshFollowupTimersRef.current[platformId];
void loadChannels(all, false);
}, 3000);
};