Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 0 additions & 40 deletions nextgenie/nextgenie/doctype/chat_log/chat_log.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2025, Codeventurers and contributors
// For license information, please see license.txt

// frappe.ui.form.on("Chat Log", {
// frappe.ui.form.on("NextGenie Chat Log", {
// refresh(frm) {

// },
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{
"actions": [],
"creation": "2025-08-27 19:48:34.122664",
"doctype": "DocType",
"engine": "InnoDB",
"field_order": [
"sender",
"user",
"column_break_yhtw",
"chat_creation",
"is_bot",
"section_break_wkcf",
"message"
],
"fields": [
{
"default": "User",
"fieldname": "sender",
"fieldtype": "Select",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Sender",
"options": "User\nGenie",
"read_only": 1
},
{
"fieldname": "column_break_yhtw",
"fieldtype": "Column Break"
},
{
"fieldname": "chat_creation",
"fieldtype": "Datetime",
"label": "Chat Creation"
},
{
"depends_on": "eval: doc.sender == \"User\"",
"fieldname": "user",
"fieldtype": "Link",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "User",
"options": "User"
},
Comment on lines +36 to +43
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Make user mandatory when sender is “User” and add an index

Prevents orphaned rows and speeds lookups.

   {
     "depends_on": "eval: doc.sender == \"User\"",
     "fieldname": "user",
     "fieldtype": "Link",
     "in_list_view": 1,
     "in_standard_filter": 1,
     "label": "User",
-    "options": "User"
+    "options": "User",
+    "mandatory_depends_on": "eval: doc.sender == \"User\"",
+    "index": 1
   },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"depends_on": "eval: doc.sender == \"User\"",
"fieldname": "user",
"fieldtype": "Link",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "User",
"options": "User"
},
{
"depends_on": "eval: doc.sender == \"User\"",
"fieldname": "user",
"fieldtype": "Link",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "User",
"options": "User",
"mandatory_depends_on": "eval: doc.sender == \"User\"",
"index": 1
},
🤖 Prompt for AI Agents
In nextgenie/nextgenie/doctype/nextgenie_chat_log/nextgenie_chat_log.json around
lines 36 to 43, the "user" Link field needs to be required when sender == "User"
and indexed; change its requirement to an eval expression such as setting
"reqd": "eval: doc.sender == 'User'" (so the field is mandatory only for
user-sent messages) and add "index": 1 to the field definition to create a DB
index for faster lookups.

{
"default": "0",
"fieldname": "is_bot",
"fieldtype": "Check",
"label": "Is Bot?"
},
{
"fieldname": "section_break_wkcf",
"fieldtype": "Section Break"
},
{
"fieldname": "message",
"fieldtype": "Text",
"label": "Message"
}
],
"in_create": 1,
"links": [],
"modified": "2025-08-30 18:12:26.480496",
"modified_by": "Administrator",
"module": "Nextgenie",
"name": "NextGenie Chat Log",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"share": 1,
"write": 1
}
Comment on lines +67 to +79
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Tighten permissions and creation flow for audit integrity

If this is a system-generated log, UI edits/deletes should be disallowed and quick-create disabled.

   "permissions": [
     {
-      "create": 1,
-      "delete": 1,
+      "create": 0,
+      "delete": 0,
       "email": 1,
       "export": 1,
       "print": 1,
       "read": 1,
       "report": 1,
       "role": "System Manager",
       "share": 1,
-      "write": 1
+      "write": 0
     }
   ],
- "read_only": 1,
+ "read_only": 1,
@@
- "in_create": 1,
+ "in_create": 0,

If you intend to allow UI creation/editing, drop the doctype-level "read_only": 1 instead and keep granular field protections. Please confirm intent.

Also applies to: 81-81, 60-60


🏁 Script executed:

#!/bin/bash
# Locate the JSON definition for the nextgenie_chat_log doctype
FILE=$(fd nextgenie_chat_log.json -t f)
echo "Found file: $FILE"

# Show the header and metadata up through the permissions block
sed -n '1,200p' "$FILE"

# Show lines 60–100 to capture the in_create and read_only settings
sed -n '60,100p' "$FILE"

Length of output: 2530


🏁 Script executed:

#!/bin/bash
# Check for quick_entry in the nextgenie_chat_log doctype
grep -n '"quick_entry"' nextgenie/nextgenie/doctype/nextgenie_chat_log/nextgenie_chat_log.json || echo "no quick_entry found"

Length of output: 147


Tighten NextGenie Chat Log permissions
Update nextgenie_chat_log.json to lock down UI creation/editing:

--- nextgenie/nextgenie/doctype/nextgenie_chat_log/nextgenie_chat_log.json
@@ "permissions": [
-    "create": 1,
-    "delete": 1,
+    "create": 0,
+    "delete": 0,
@@
-    "write": 1
+    "write": 0
@@
- "in_create": 1,
+ "in_create": 0,

The existing "read_only": 1 already prevents UI edits; if you need UI creation/editing instead, remove it. quick_entry is unset (defaults to disabled). Confirm your intended usage.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"share": 1,
"write": 1
}
"permissions": [
{
- "create": 1,
"create": 0,
"delete": 0,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"share": 1,
"write": 0
}
],
"read_only": 1,
"in_create": 0,
🤖 Prompt for AI Agents
In nextgenie/nextgenie/doctype/nextgenie_chat_log/nextgenie_chat_log.json around
lines 67–79, the permissions block needs to explicitly reflect intended UI
creation/edit behavior: if you want to lock down UI creation/editing, add
"read_only": 1 to this permission object; if instead you intend to allow UI
creation/editing remove any "read_only" key. Leave "quick_entry" unset (it
defaults to disabled) or set it explicitly to 0 if you want to be explicit.
Ensure the JSON object remains valid after the change.

],
"read_only": 1,
"sort_field": "modified",
"sort_order": "DESC",
"states": [],
"track_changes": 1
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
from frappe.model.document import Document


class ChatLog(Document):
class NextGenieChatLog(Document):
pass
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
from frappe.tests.utils import FrappeTestCase


class TestChatLog(FrappeTestCase):
class TestNextGenieChatLog(FrappeTestCase):
pass
Loading