Skip to content

feat: add stuck ticket detection for HD Ticket#3203

Open
asamawi wants to merge 7 commits intofrappe:developfrom
asamawi:feature/stuck-detection
Open

feat: add stuck ticket detection for HD Ticket#3203
asamawi wants to merge 7 commits intofrappe:developfrom
asamawi:feature/stuck-detection

Conversation

@asamawi
Copy link
Copy Markdown

@asamawi asamawi commented Apr 6, 2026

Summary

  • Adds a scheduled task (every 4 hours) that automatically flags tickets as "stuck" based on three detection rules:
    • Open for more than 3 days
    • In a paused/waiting status for more than 3 days without modification
    • Status changed 4+ times without resolution
  • Adds is_stuck (Check) and stuck_reason (Small Text) read-only fields to HD Ticket, with is_stuck available in list view and standard filters
  • Stuck flags auto-clear when a ticket's status or assignment changes
  • Dashboard shows a "Stuck Tickets" number card with live count, filtered by team/agent

Ref: #3182

Changes

File Change
hd_ticket.json Added is_stuck, stuck_reason fields with "Stuck Detection" section
hd_ticket.py Added detect_stuck_tickets() scheduled task + clear_stuck_if_progressed() method
hooks.py Registered cron job 0 */4 * * *
dashboard.py Added get_stuck_ticket_count() number card
Dashboard.vue Updated grid layout for 6 number cards
patches/add_stuck_fields_to_template.py Adds fields to Default HD Ticket Template
patches.txt Registered new patch

Test plan

  • Run bench --site <site> migrate to apply schema + patch
  • Verify is_stuck and stuck_reason fields appear in HD Ticket form
  • Verify is_stuck appears as a standard filter in ticket list view
  • Run bench --site <site> execute helpdesk.helpdesk.doctype.hd_ticket.hd_ticket.detect_stuck_tickets manually to test detection
  • Confirm tickets matching rules get flagged with correct reasons
  • Change status on a stuck ticket and verify flag clears automatically
  • Check dashboard shows "Stuck Tickets" number card with correct count

asamawi and others added 7 commits April 4, 2026 15:28
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- vite.config.js: add resolve alias for frappe app (fixes build when
  helpdesk is symlinked from outside the bench directory)
- docker-compose.yml: expose MariaDB (3306) and Redis (6379) ports to
  host so bench can connect from outside Docker
- yarn.lock: lockfile update from dependency resolution

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds a Float field for agents to estimate ticket work hours at triage/review
time. This enables workload and backlog calculations (days-to-clear, queued
hours).

- Add `estimated_hours` (Float, precision 2) to HD Ticket in the Resolution tab
- Add post_model_sync patch to register the field in the Default HD Ticket
  Template so it appears in the agent sidebar (hidden from customers)

Ref: frappe#3179

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds per-ticket time tracking so agents can log hours worked.

- New child DocType: HD Ticket Time Log (date, start/end time, hours, note, user)
- Table field on HD Ticket with auto-calculated hours per row and total_hours
- Cross-midnight time calculation support (e.g. 10 PM to 1 AM)
- API endpoints: add_time_log, delete_time_log with activity logging
- Time Logs tab in ticket detail activity panel
- Patch to add total_hours to Default HD Ticket Template

Ref: frappe#2351
# Conflicts:
#	desk/vite.config.js
#	yarn.lock
Adds a scheduled task (every 4 hours) that flags tickets as stuck based on
three detection rules:
- Open for more than 3 days
- In a paused/waiting status for more than 3 days
- Status changed 4+ times without resolution

Adds is_stuck (Check) and stuck_reason (Small Text) fields to HD Ticket.
Stuck flags auto-clear when a ticket's status or assignment changes.
Dashboard shows a "Stuck Tickets" count as a number card.

Ref: frappe#3182
@michal-bee
Copy link
Copy Markdown

@asamawi this is great. It would be even better if the is_stuck parameters and period is configurable via the settings page as there might be different reasons why the ticket is escalated. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants