Compare commits

...

3 Commits

Author SHA1 Message Date
b2487e7740 fix: skip workspace members with no Raven User record in Open channels
raven.api.chat.get_channel_members built each Open-channel member's row by
indexing straight into the Raven User lookup result without checking it was
found, unlike the identical branch 10 lines below for non-Open channels. A
workspace member whose Raven User record is missing (e.g. left behind by a
direct cleanup that skipped RavenUser.on_trash's own cascade) crashes the
whole whitelisted endpoint with AttributeError instead of just being omitted.

Extracted the row-building into build_member_entry(), which returns None for
an unmatched member so both branches skip it the same way. Added
raven/tests/test_chat_channel_members.py (pure-function coverage plus an
IntegrationTestCase reproducing the stale-membership state) following this
repo's existing test conventions.

Verified: apps/web vitest (480/480) and tsc -b are unaffected and pass; the
new Python tests need a Frappe bench (DB-backed test runner) this sandbox
does not have, so they are written to the repo's established
IntegrationTestCase pattern but not executed here.
2026-10-21 03:59:57 +03:00
Nikhil Kothari
5c22932b44 chore: bump raven settings timestamp 2026-10-20 19:51:01 +05:30
Nikhil Kothari
f67b14bcad fix: do not show administrator and blur issue on Safari 2026-10-19 19:00:46 +05:30
7 changed files with 226 additions and 38 deletions

View File

@ -13,9 +13,9 @@ import { siteUrl } from "@lib/site"
import ravenLogo from "@raven/public/raven_logo.svg"
const LINKS = [
{ label: _("Documentation"), href: "https://docs.frappe.io/raven" },
{ label: _("GitHub"), href: "https://github.com/frappe/raven" },
{ label: _("Website"), href: "https://ravenchat.ai" },
// { label: _("Documentation"), href: "https://docs.ravenapp.cloud" },
]
/** Version of every installed app, plus links. Same footer as the mobile profile page. */

View File

@ -91,10 +91,13 @@
}
/* Setup page motion. Off under reduced motion: the page switches instantly. */
/* Animations that end on the resting look fill backwards, not both. Safari keeps an element
composited for as long as an animation holds its last frame, and leaves blurred-in text
soft until something repaints (WebKit bug 257023). Only the ones that end hidden hold. */
/* Steps blur out, leave a short gap, then blur back in sharp. */
@utility animate-setup-step-in {
@media (prefers-reduced-motion: no-preference) {
animation: setup-blur-in 250ms ease-out 100ms both;
animation: setup-blur-in 250ms ease-out 100ms backwards;
}
}
@ -106,26 +109,26 @@
@utility animate-setup-blur-in {
@media (prefers-reduced-motion: no-preference) {
animation: setup-blur-in 300ms ease-out both;
animation: setup-blur-in 300ms ease-out backwards;
}
}
@utility animate-setup-open {
@media (prefers-reduced-motion: no-preference) {
animation: setup-open 400ms cubic-bezier(0.16, 1, 0.3, 1) both;
animation: setup-open 400ms cubic-bezier(0.16, 1, 0.3, 1) backwards;
}
}
@utility animate-setup-open-late {
@media (prefers-reduced-motion: no-preference) {
animation: setup-open 400ms cubic-bezier(0.16, 1, 0.3, 1) 80ms both;
animation: setup-open 400ms cubic-bezier(0.16, 1, 0.3, 1) 80ms backwards;
}
}
@utility animate-setup-item-in {
@media (prefers-reduced-motion: no-preference) {
animation: setup-item-in 250ms ease-out both;
animation: setup-item-in 250ms ease-out backwards;
}
}
@ -139,7 +142,7 @@
@utility animate-setup-check {
@media (prefers-reduced-motion: no-preference) {
stroke-dasharray: 32;
animation: setup-check 400ms cubic-bezier(0.33, 1, 0.68, 1) 150ms both;
animation: setup-check 400ms cubic-bezier(0.33, 1, 0.68, 1) 150ms backwards;
}
}
@ -155,29 +158,30 @@
/* HR step: two app logos come together from either side once the step has faded in, the × growing between them. */
@utility animate-setup-join-left {
@media (prefers-reduced-motion: no-preference) {
animation: setup-join-left 900ms cubic-bezier(0.33, 1, 0.68, 1) 350ms both;
animation: setup-join-left 900ms cubic-bezier(0.33, 1, 0.68, 1) 350ms backwards;
}
}
@utility animate-setup-join-right {
@media (prefers-reduced-motion: no-preference) {
animation: setup-join-right 900ms cubic-bezier(0.33, 1, 0.68, 1) 350ms both;
animation: setup-join-right 900ms cubic-bezier(0.33, 1, 0.68, 1) 350ms backwards;
}
}
@utility animate-setup-join-mark {
@media (prefers-reduced-motion: no-preference) {
animation: setup-join-mark 900ms cubic-bezier(0.33, 1, 0.68, 1) 350ms both;
animation: setup-join-mark 900ms cubic-bezier(0.33, 1, 0.68, 1) 350ms backwards;
}
}
/* The sharp end is `none`, not `blur(0)`, so no filter is left on the element afterwards. */
@keyframes setup-blur-in {
from { opacity: 0; filter: blur(6px); }
to { opacity: 1; filter: blur(0); }
to { opacity: 1; filter: none; }
}
@keyframes setup-blur-out {
from { opacity: 1; filter: blur(0); }
from { opacity: 1; filter: none; }
to { opacity: 0; filter: blur(6px); }
}

View File

@ -0,0 +1,82 @@
# TODO: product issues found while writing the user docs
Found in October 2026 while checking docs.frappe.io/raven against the code and the demo site. The docs describe only what works today. When an item is fixed, update the docs page named in brackets.
## Notifications
- [ ] Per-channel notification options do nothing. The Push notifications and In-app notifications rows in the channel drawer keep local state only (`ChannelSettingsDrawer/ChannelSettingsTab.tsx`), and the channel header menu's All Notifications / Mentions Only / Mute Channel items have empty click handlers (`ChannelHeader/ChannelMenu.tsx`). Only the bell in Settings > Channels works, and the backend has no "mentions only" level. [Mute a channel]
- [ ] Quiet hours default: the Raven User field defaults to "No Nudge", while `boot.py` and code comments still treat "Nudge" as the default. Pick one. [Quiet hours]
- [ ] The quiet hours banner always shows the Mac shortcut ⌘⇧↵, also on Windows and Linux. [Quiet hours]
## Channels
- [ ] "Create a new channel" shows even when the workspace has "Only admins can create channels" on. Other members get an error. [Create a channel]
- [ ] A Raven Admin who is a channel member but not a channel admin sees "Remove from channel" enabled (`canManageChannel`), but the server only lets channel admins remove members (`raven/permissions.py`, `channel_member_has_permission`). [Add and remove members]
- [ ] Any channel member may add people on the server, but the Add button only shows for channel admins and Raven Admins. Decide which is right. [Add and remove members]
- [ ] Rows in the channel drawer's Threads tab look clickable but have no click handler (`ChannelSettingsDrawer/ChannelThreads.tsx`). [Channel files, links, threads and pins]
- [ ] The Favorites star tooltip always says "Add to Favorites", even for a favorite. [Organize your sidebar]
- [ ] Leave in Settings > Channels leaves at once; Leave in the channel drawer asks first. Make them the same. [Join and leave channels]
- [ ] The sidebar filters only apply at 15 or more channels (`packages/lib/utils/buildChannelSidebarData.ts`, `FILTER_MIN_CHANNELS`), and never hide Open, Favorite or grouped channels. The setting's own description says neither. [Preferences]
## Messages
- [ ] Settings > Appearance says "4+ images always use the carousel", but `MessageImages.tsx` uses the carousel for 5 or more (`images.length > 4`). [Files and links]
- [ ] A pasted link to a document on the same site (/app, /desk) gets no preview card. Only the composer's document button makes a card. [Share documents in a message]
- [ ] Custom emoji show as raw shortcodes (":lumen:") in search results on mobile. [Search]
- [ ] `hide_link_preview` exists on the message, but nothing in the UI sets it. [Files and links]
## Threads and search
- [ ] The Threads page still has an "AI Agents" filter, on desktop and mobile, though AI is deprecated. [Threads]
- [ ] The Threads empty state says 'Create Thread'; the menu item is "Create thread".
- [ ] "Unread only" on the Threads page's Other tab is always empty, because those threads are never unread.
- [ ] Search builds a "Clear all" action for active filters but never shows it. [Search]
## Workspaces and users
- [ ] "Can only join via invite?" can only be set in Desk. The web app hides Join for such workspaces, but the server still lets anyone join a public one.
- [ ] Add User with one workspace pre-ticks it (disabled, can't untick) even when the System Manager is not that workspace's admin, so `invite_user` fails the write check (`AddUserDialog.tsx` defaultValues, `WorkspaceAccessPicker`). [Add people to Raven]
- [ ] Typo in `WorkspaceAccessPicker`: "cannot manage it's members" should be "its".
- [ ] The DM header's "View profile" opens the panel on its Files tab. [Direct messages]
## Settings and permissions
- [ ] Webhooks and Scheduled Messages tabs show to Raven Admins (`isRavenSettingsAdmin`), but Raven Webhook and Raven Scheduler Event give permission to System Manager only, and Scheduled Messages also needs System Manager to create the Server Script. [Webhooks] [Recurring bot messages]
- [ ] Emojis: the delete button shows on every row; people who are not admins can only delete emoji they added and get a permission error on others. [Custom emoji]
- [ ] Settings placeholders name specific document types ("Salary Slip Notification", `doc.employee_name`).
- [ ] Ctrl/⌘ + / did not open Settings in Playwright's Chrome on a Mac. Check by hand.
## Webhooks and bots
- [ ] Channel Member Added and Channel Member Deleted triggers: `RavenWebhook.get_doctype_and_event` uses labels that don't match the Select options, so the webhook gets no doctype. Left out of the docs. [Webhooks]
- [ ] Disabling a webhook does nothing: `Raven Webhook.enabled` is never copied to the Frappe Webhook. [Webhooks]
- [ ] Conditions the UI offers that the backend rejects or ignores: Channel on Message Reacted On (error), Channel Type on message and member triggers (error), User on Channel Created/Deleted (error), User on User Added/Deleted (ignored, fires for every user). [Webhooks]
- [ ] Data and Headers rows can only be added after creation, never removed or updated (`set_webhook_data_and_headers`). [Webhooks]
- [ ] Deleting a webhook uses `frappe.db.delete` in `on_trash`, which skips the webhook cache, so it may keep firing until the cache clears. Not tested.
- [ ] Message Edited fires on any save of the message record, not only text edits.
- [ ] Webhook requests send a JSON body while the record says "Form URL-Encoded", with no Content-Type header. [Webhooks]
- [ ] Incoming webhook: opening an existing record in Desk marks it "Not Saved" (the form script calls `set_value` on `webhook_url` in refresh). The Bot field links to Raven User, so it also lists people. Empty content posts an empty message. [Incoming webhooks]
- [ ] Agents live under the AI group in Settings, though AI is deprecated. Move Agents out of the AI group. [Agents]
- [ ] The agent form in Settings has no image field; an agent's picture can only be set in Desk. [Agents]
- [ ] The "Is AI Agent" description still says "Check to enable AI features for this bot". [Agents]
## Frappe apps and HR
- [ ] Message actions: the Server Script "View Docs" sample uses `frappe.form_dict.values.field1`, which fails (`values` is a dict method on form_dict). Use `frappe.form_dict.get("values")` and `.get("field")`. In `MessageActionForm.tsx` (EXAMPLES). [Message actions]
- [ ] Message actions: Edit Field shows an empty Field box when the field type is not in `VALID_FIELD_TYPES` (`messageActionFieldUtils.ts`), for example Text Editor. [Message actions]
- [ ] Frappe HR department channels are only created for departments made after the setting is turned on, are skipped when the company has no workspace mapping (a code comment says a default workspace is used), and employees whose User ID is set later are not added (TODO in `employee.py`). [Frappe HR]
- [ ] A broken document notification condition blocks saving the document. [Document notifications]
## Push and mobile
- [ ] Frappe Cloud sites are set up for push automatically only when the server config has `raven_push_notification_server_url`. Confirm every Frappe Cloud server has it. [Set up push notifications]
- [ ] README says the apps connect to "Raven 3 or later"; the app requires 3.1.0 (`MIN_SITE_VERSION`).
- [ ] The Add site screen's placeholder is `raven.frappe.cloud`; the docs use `yourcompany.frappe.cloud`.
## Demo site
- [ ] Maya is not a workspace admin of Lumen Cycles or Dealers (only Administrator is), so some docs shots fake the admin view in the browser.
- [ ] Maya is a member of every public channel, so there is no "Join" shot.
- [ ] Server scripts are off, so the seeded recurring message never runs.
- [ ] Suresh Pillai does not show in the @ mention list (probably disabled).
- [ ] The demo site shows as 127.0.0.1:8028 in the mobile site picker.

View File

@ -6,6 +6,28 @@ from raven.utils import get_channel_members as get_channel_members_util
from raven.utils import get_workspace_members
def build_member_entry(user_obj, channel_member) -> dict | None:
"""One member's row for the member list, or None when there's no matching
Raven User record (e.g. a workspace member whose Raven User record was
removed). The caller must skip a None entry instead of indexing into it —
a workspace can list a member with no Raven User doc, and that one bad
row must never crash the whole list."""
if user_obj is None:
return None
return {
"name": user_obj.name,
"full_name": user_obj.full_name,
"user_image": user_obj.user_image,
"first_name": user_obj.first_name,
"type": user_obj.type,
"availability_status": user_obj.availability_status,
"is_admin": channel_member.get("is_admin", 0),
"allow_notifications": channel_member.get("allow_notifications", 1),
"channel_member_name": channel_member.get("name", None),
}
@frappe.whitelist(methods=["GET"])
def get_channel_members(channel_id: str):
# Check if the user has permission to view the channel
@ -33,34 +55,17 @@ def get_channel_members(channel_id: str):
channel_member = channel_members.get(workspace_member, {})
user_obj = next((u for u in all_users if u.name == workspace_member), None)
member_object[user_obj.name] = {
"name": user_obj.name,
"full_name": user_obj.full_name,
"user_image": user_obj.user_image,
"first_name": user_obj.first_name,
"type": user_obj.type,
"availability_status": user_obj.availability_status,
"is_admin": channel_member.get("is_admin", 0),
"allow_notifications": channel_member.get("allow_notifications", 1),
"channel_member_name": channel_member.get("name", None),
}
entry = build_member_entry(user_obj, channel_member)
if entry:
member_object[entry["name"]] = entry
else:
for member in channel_members:
channel_member = channel_members[member]
user_obj = next((u for u in all_users if u.name == member), None)
if user_obj:
member_object[user_obj.name] = {
"name": user_obj.name,
"full_name": user_obj.full_name,
"user_image": user_obj.user_image,
"first_name": user_obj.first_name,
"type": user_obj.type,
"availability_status": user_obj.availability_status,
"is_admin": channel_member.is_admin,
"allow_notifications": channel_member.allow_notifications,
"channel_member_name": channel_member.name,
}
entry = build_member_entry(user_obj, channel_member)
if entry:
member_object[entry["name"]] = entry
return member_object

View File

@ -36,7 +36,10 @@ def is_setup_admin() -> bool:
def _raven_users_without_workspace() -> list[dict]:
"""Enabled people in Raven who belong to no workspace, except whoever is asking."""
"""
Enabled people in Raven who belong to no workspace, except whoever is asking and the
Administrator account, which install puts in Raven but is nobody's teammate.
"""
raven_user = frappe.qb.DocType("Raven User")
user = frappe.qb.DocType("User")
member = frappe.qb.DocType("Raven Workspace Member")
@ -53,7 +56,7 @@ def _raven_users_without_workspace() -> list[dict]:
)
.where(raven_user.type == "User")
.where(raven_user.enabled == 1)
.where(raven_user.user != frappe.session.user)
.where(raven_user.user.notin(["Administrator", frappe.session.user]))
.where(raven_user.user.notin(in_a_workspace))
).run(as_dict=True)

View File

@ -343,7 +343,7 @@
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
"modified": "2026-10-17 12:00:00.000000",
"modified": "2026-10-20 14:12:54.000000",
"modified_by": "Administrator",
"module": "Raven",
"name": "Raven Settings",

View File

@ -0,0 +1,94 @@
import frappe
from frappe.tests import IntegrationTestCase
from raven.api.chat import build_member_entry, get_channel_members
EXTRA_TEST_RECORD_DEPENDENCIES = ["User", "Raven User"]
class TestBuildMemberEntry(IntegrationTestCase):
"""Pure-function checks for the row builder `get_channel_members` relies on."""
def test_none_user_obj_returns_none(self):
# No matching Raven User record for this member — the caller must be able
# to skip it instead of indexing into None.
self.assertIsNone(build_member_entry(None, {}))
def test_matching_user_obj_returns_entry(self):
user_obj = frappe._dict(
name="test1@example.com",
full_name="Test One",
user_image=None,
first_name="Test",
type="User",
availability_status="Available",
)
entry = build_member_entry(user_obj, {"is_admin": 1, "name": "RCM-1"})
self.assertEqual(entry["name"], "test1@example.com")
self.assertEqual(entry["is_admin"], 1)
self.assertEqual(entry["channel_member_name"], "RCM-1")
def test_missing_channel_member_fields_default(self):
# The Open-channel branch passes `{}` when there's no explicit Raven
# Channel Member row (every workspace member is implicitly a member).
user_obj = frappe._dict(
name="test1@example.com",
full_name="Test One",
user_image=None,
first_name="Test",
type="User",
availability_status="Available",
)
entry = build_member_entry(user_obj, {})
self.assertEqual(entry["is_admin"], 0)
self.assertEqual(entry["allow_notifications"], 1)
self.assertIsNone(entry["channel_member_name"])
class TestOpenChannelMembers(IntegrationTestCase):
"""
Regression test: a workspace member whose Raven User record is gone (e.g. a
direct cleanup / data fix that skipped RavenUser.on_trash's own cascade) must
be skipped from the Open channel's member list, not crash the whole request.
"""
def setUp(self):
frappe.set_user("Administrator")
frappe.get_doc("User", "test1@example.com").add_roles("Raven User")
self.workspace = frappe.get_doc(
{
"doctype": "Raven Workspace",
"workspace_name": "Chat Members Test Workspace",
"type": "Private",
}
).insert()
self.channel = frappe.get_doc(
{
"doctype": "Raven Channel",
"channel_name": "chat-members-open-test",
"type": "Open",
"workspace": self.workspace.name,
}
).insert()
def tearDown(self):
frappe.set_user("Administrator")
frappe.db.delete("Raven Channel Member", {"channel_id": self.channel.name})
frappe.db.delete("Raven Workspace Member", {"workspace": self.workspace.name})
self.channel.delete()
self.workspace.delete()
def test_open_channel_skips_member_with_no_raven_user_record(self):
user = "test1@example.com"
frappe.get_doc(
{"doctype": "Raven Workspace Member", "workspace": self.workspace.name, "user": user}
).insert(ignore_permissions=True)
# Simulate the broken state directly: a raw delete bypasses RavenUser.on_trash,
# so the Workspace Member row survives with no matching Raven User doc.
frappe.db.delete("Raven User", {"user": user})
frappe.cache().delete_value(f"raven:workspace_members:{self.workspace.name}")
members = get_channel_members(self.channel.name)
self.assertNotIn(user, members)