generated from nhcarrigan/template
feat: add comprehensive logging for permission modal debugging
Added extensive logging to help diagnose permission modal issues:
Frontend:
- Capture unhandled errors via window.addEventListener('error')
- Capture unhandled promise rejections
- All errors now visible in debug console
Backend:
- Log when emitting permission events (count and conversation ID)
- Log each individual permission request being processed
- Log when system tools are skipped
- Log each denial being processed
This will help identify where the permission flow breaks in production builds.
This commit is contained in:
@@ -1239,8 +1239,18 @@ fn process_json_line(
|
|||||||
for denial in denials {
|
for denial in denials {
|
||||||
// Skip system tools that should never require permission
|
// Skip system tools that should never require permission
|
||||||
if is_system_tool(&denial.tool_name) {
|
if is_system_tool(&denial.tool_name) {
|
||||||
|
tracing::debug!(
|
||||||
|
"Skipping system tool: {} (id: {})",
|
||||||
|
denial.tool_name,
|
||||||
|
denial.tool_use_id
|
||||||
|
);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
tracing::debug!(
|
||||||
|
"Processing permission denial for: {} (id: {})",
|
||||||
|
denial.tool_name,
|
||||||
|
denial.tool_use_id
|
||||||
|
);
|
||||||
|
|
||||||
// Special handling for AskUserQuestion tool
|
// Special handling for AskUserQuestion tool
|
||||||
if denial.tool_name == "AskUserQuestion" {
|
if denial.tool_name == "AskUserQuestion" {
|
||||||
@@ -1334,6 +1344,18 @@ fn process_json_line(
|
|||||||
|
|
||||||
// Emit all regular permission requests as a single batched event
|
// Emit all regular permission requests as a single batched event
|
||||||
if !regular_permission_requests.is_empty() {
|
if !regular_permission_requests.is_empty() {
|
||||||
|
tracing::info!(
|
||||||
|
"Emitting permission event for {} tool(s) in conversation {:?}",
|
||||||
|
regular_permission_requests.len(),
|
||||||
|
conversation_id
|
||||||
|
);
|
||||||
|
for req in ®ular_permission_requests {
|
||||||
|
tracing::debug!(
|
||||||
|
"Permission requested: {} (id: {})",
|
||||||
|
req.tool_name,
|
||||||
|
req.id
|
||||||
|
);
|
||||||
|
}
|
||||||
let _ = app.emit(
|
let _ = app.emit(
|
||||||
"claude:permission",
|
"claude:permission",
|
||||||
PermissionPromptEvent {
|
PermissionPromptEvent {
|
||||||
|
|||||||
@@ -87,6 +87,20 @@ function createDebugConsoleStore() {
|
|||||||
originalConsole.debug(...args);
|
originalConsole.debug(...args);
|
||||||
addLog("debug", args.map((arg) => String(arg)).join(" "), "frontend");
|
addLog("debug", args.map((arg) => String(arg)).join(" "), "frontend");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Capture unhandled errors
|
||||||
|
window.addEventListener("error", (event) => {
|
||||||
|
addLog(
|
||||||
|
"error",
|
||||||
|
`[Unhandled Error] ${event.message} at ${event.filename}:${event.lineno}:${event.colno}`,
|
||||||
|
"frontend"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Capture unhandled promise rejections
|
||||||
|
window.addEventListener("unhandledrejection", (event) => {
|
||||||
|
addLog("error", `[Unhandled Promise Rejection] ${event.reason}`, "frontend");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function restoreConsole() {
|
function restoreConsole() {
|
||||||
|
|||||||
Reference in New Issue
Block a user