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(admin): resolve settings_key for channel context, API route prefix, merge users save

cyh5465a1b15ca4
diff --git a/core/controller.py b/core/controller.py
index b9810e4d3..1a5436cb9 100644
--- a/core/controller.py
+++ b/core/controller.py
@@ -441,9 +441,12 @@ class Controller:
if platform == "slack" and effective_channel.startswith("D"):
return user_id
if platform in ("discord", "lark"):
- # For DM updates, check if the user is a bound DM user
- if self.settings_manager and hasattr(self.settings_manager, "store"):
- if self.settings_manager.store.is_bound_user(user_id):
+ # For DM updates: the user is bound AND the channel_id is NOT a
+ # known configured channel (i.e. it's a DM chat, not a workspace channel)
+ if effective_channel and self.settings_manager and hasattr(self.settings_manager, "store"):
+ store = self.settings_manager.store
+ is_known_channel = effective_channel in store.settings.channels
+ if not is_known_channel and store.is_bound_user(user_id):
return user_id
return effective_channel if effective_channel else user_id
diff --git a/ui/src/context/ApiContext.tsx b/ui/src/context/ApiContext.tsx
index 08fc34b1b..294a9402b 100644
--- a/ui/src/context/ApiContext.tsx
+++ b/ui/src/context/ApiContext.tsx
@@ -129,14 +129,14 @@ export const ApiProvider: React.FC<{ children: React.ReactNode }> = ({ children
saveConfig: (payload) => postJson('/config', payload),
getSettings: () => getJson('/settings'),
saveSettings: (payload) => postJson('/settings', payload),
- getUsers: () => getJson('/users'),
- saveUsers: (payload) => postJson('/users', payload),
- toggleAdmin: (userId, isAdmin) => postJson(`/users/${encodeURIComponent(userId)}/admin`, { is_admin: isAdmin }),
- removeUser: (userId) => fetch(`/users/${encodeURIComponent(userId)}`, { method: 'DELETE' }).then(r => r.json()),
- getBindCodes: () => getJson('/bind-codes'),
- createBindCode: (type, expiresAt) => postJson('/bind-codes', { type, expires_at: expiresAt }),
- deleteBindCode: (code) => fetch(`/bind-codes/${encodeURIComponent(code)}`, { method: 'DELETE' }).then(r => r.json()),
- getFirstBindCode: () => getJson('/setup/first-bind-code'),
+ getUsers: () => getJson('/api/users'),
+ saveUsers: (payload) => postJson('/api/users', payload),
+ toggleAdmin: (userId, isAdmin) => postJson(`/api/users/${encodeURIComponent(userId)}/admin`, { is_admin: isAdmin }),
+ removeUser: (userId) => fetch(`/api/users/${encodeURIComponent(userId)}`, { method: 'DELETE' }).then(r => r.json()),
+ getBindCodes: () => getJson('/api/bind-codes'),
+ createBindCode: (type, expiresAt) => postJson('/api/bind-codes', { type, expires_at: expiresAt }),
+ deleteBindCode: (code) => fetch(`/api/bind-codes/${encodeURIComponent(code)}`, { method: 'DELETE' }).then(r => r.json()),
+ getFirstBindCode: () => getJson('/api/setup/first-bind-code'),
detectCli: (binary) => getJson(`/cli/detect?binary=${encodeURIComponent(binary)}`),
installAgent: (name) => postJson(`/agent/${encodeURIComponent(name)}/install`, {}),
slackAuthTest: (botToken) => postJson('/slack/auth_test', { bot_token: botToken }),
diff --git a/vibe/api.py b/vibe/api.py
index 544b4d653..0b0e197c3 100644
--- a/vibe/api.py
+++ b/vibe/api.py
@@ -1141,7 +1141,10 @@ def save_users(payload: dict) -> dict:
if new_admin_count == 0:
return {"ok": False, "error": "Cannot remove all admins"}
- store.settings.users = users
+ # Merge instead of replace: update existing users and add new ones,
+ # but preserve users not included in the payload (e.g. concurrently bound)
+ for uid, user_settings in users.items():
+ store.settings.users[uid] = user_settings
store.save()
return get_users()
diff --git a/vibe/ui_server.py b/vibe/ui_server.py
index e75ece4d7..f78df4b89 100644
--- a/vibe/ui_server.py
+++ b/vibe/ui_server.py
@@ -491,14 +491,14 @@ def browse_directory():
# =============================================================================
[email protected]("/users", methods=["GET"])
[email protected]("/api/users", methods=["GET"])
def users_get():
from vibe import api
return jsonify(api.get_users())
[email protected]("/users", methods=["POST"])
[email protected]("/api/users", methods=["POST"])
def users_post():
from vibe import api
@@ -506,7 +506,7 @@ def users_post():
return jsonify(api.save_users(payload))
[email protected]("/users/<user_id>/admin", methods=["POST"])
[email protected]("/api/users/<user_id>/admin", methods=["POST"])
def users_toggle_admin(user_id):
from vibe import api
@@ -514,7 +514,7 @@ def users_toggle_admin(user_id):
return jsonify(api.toggle_admin(user_id, payload.get("is_admin", False)))
[email protected]("/users/<user_id>", methods=["DELETE"])
[email protected]("/api/users/<user_id>", methods=["DELETE"])
def users_delete(user_id):
from vibe import api
@@ -524,14 +524,14 @@ def users_delete(user_id):
return jsonify(result)
[email protected]("/bind-codes", methods=["GET"])
[email protected]("/api/bind-codes", methods=["GET"])
def bind_codes_get():
from vibe import api
return jsonify(api.get_bind_codes())
[email protected]("/bind-codes", methods=["POST"])
[email protected]("/api/bind-codes", methods=["POST"])
def bind_codes_post():
from vibe import api
@@ -545,7 +545,7 @@ def bind_codes_post():
return jsonify(result)
[email protected]("/bind-codes/<code>", methods=["DELETE"])
[email protected]("/api/bind-codes/<code>", methods=["DELETE"])
def bind_codes_delete(code):
from vibe import api
@@ -555,7 +555,7 @@ def bind_codes_delete(code):
return jsonify(result)
[email protected]("/setup/first-bind-code", methods=["GET"])
[email protected]("/api/setup/first-bind-code", methods=["GET"])
def setup_first_bind_code():
from vibe import api