diff --git a/cmd/task/main.go b/cmd/task/main.go index a303bed..4b2b2cf 100644 --- a/cmd/task/main.go +++ b/cmd/task/main.go @@ -3514,8 +3514,10 @@ func handleNotificationHook(database *db.DB, taskID int64, input *ClaudeHookInpu if input.Message != "" { msg = "Waiting for permission: " + input.Message } - // Append tool detail so the approval dialog shows what's being requested - if detail := formatPermissionDetail(input); detail != "" { + // The Notification hook doesn't include tool_name/tool_input, but the + // PreToolUse hook (which fires just before) stashes the detail as a + // "pending_tool" log entry. Retrieve and append to the permission message. + if detail := latestPendingToolDetail(database, taskID); detail != "" { msg += "\n" + detail } } @@ -3604,6 +3606,13 @@ func handlePreToolUseHook(database *db.DB, taskID int64, input *ClaudeHookInput) database.AppendTaskLog(taskID, "system", "Claude resumed working") } + // Store tool detail so the Notification(permission_prompt) handler can show it. + // The Notification hook doesn't include tool_name/tool_input, but PreToolUse + // fires right before it, so we stash the detail here for retrieval. + if detail := formatPermissionDetail(input); detail != "" { + database.AppendTaskLog(taskID, "pending_tool", detail) + } + return nil } @@ -3762,6 +3771,23 @@ func formatPermissionDetail(input *ClaudeHookInput) string { return detail } +// latestPendingToolDetail retrieves the most recent "pending_tool" log entry +// for a task. This is written by handlePreToolUseHook and consumed here by the +// notification handler to show what tool/command is requesting permission. +func latestPendingToolDetail(database *db.DB, taskID int64) string { + logs, err := database.GetTaskLogs(taskID, 5) + if err != nil { + return "" + } + // Logs are in DESC order (most recent first). + for _, l := range logs { + if l.LineType == "pending_tool" { + return l.Content + } + } + return "" +} + // tailClaudeLogs tails all claude session logs for debugging. func tailClaudeLogs() error { home, err := os.UserHomeDir() diff --git a/internal/ui/detail.go b/internal/ui/detail.go index 6129a6c..a385159 100644 --- a/internal/ui/detail.go +++ b/internal/ui/detail.go @@ -2550,6 +2550,10 @@ func (m *DetailModel) renderContent() string { b.WriteString("\n\n") for _, log := range m.logs { + // Skip internal-only log entries not meant for display + if log.LineType == "pending_tool" { + continue + } icon := " " switch log.LineType { case "system":