Skip to content

refactor!: comments and notifications doctype - #3700

Merged
RitvikSardana merged 26 commits into
frappe:developfrom
RitvikSardana:refactor/comments-notifications-migration
Sep 9, 2026
Merged

RitvikSardana merged 26 commits into
frappe:developfrom
RitvikSardana:refactor/comments-notifications-migration

Conversation

@RitvikSardana

@RitvikSardana RitvikSardana commented Aug 15, 2026 •

Copy link
Copy Markdown
Member

Issue

Migrating helpdesk specific doctypes to their core equivalents.

  • HD Ticket Comment to Comment
  • HD Ticket Activity to Comment (Info), only tag, auto close and split rows
  • HD Notification to Notification Log
  • HD Comment Reaction reparented to Comment
  • File attachments repointed to Comment

Patches

  • setup_core_comments_schema: custom fields, notification types, permissions
  • migrate_ticket_comments_to_comment: name preserving insert select
  • migrate_ticket_activities_to_info_comments: rows with no Version row of their own
  • repoint_comment_reactions_and_files: reactions and attachments
  • migrate_hd_notifications_to_notification_log: notifications, with reopen rows retyped
  • relabel_comment_search_index: relabels stale FTS rows in place, falls back to a rebuild on failure

Notes

  • Comment names are preserved so existing mention links keep resolving
  • Every patch is chunked (50k) and idempotent, so an interrupted bench migrate resumes
  • Hash collisions are re detected on immutable fields and re inserted under a fresh name
  • Old patch entries are untouched, this only appends

Inside the patch: one HD Ticket Comment, one fate

What copy_chunk and resolve_name_collisions decide for each row on its way to core Comment. Every path is safe to reach twice, which is the whole idempotency story.

flowchart TD
    S["Next batch: 50,000 HD Ticket Comments<br/><i>name &gt; lower AND name ≤ upper</i>"] --> Q1{"Same name already exists<br/>as a core Comment?<br/><i>NOT EXISTS check</i>"}
    Q1 -- "no" --> INS["INSERT as core Comment,<br/>name + creation preserved"]
    INS --> COMMIT["Chunk commits,<br/>resumable checkpoint"]
    Q1 -- "yes, skipped by copy_chunk" --> Q2{"That core Comment has my creation<br/>and points at HD Ticket?"}
    Q2 -- "yes" --> MINE["It's my own migrated copy<br/>(re-run / resumed run), do nothing"]
    Q2 -- "no, a stranger owns my name" --> Q3{"Core Comment copy of me exists<br/>under ANY name?<br/><i>creation + owner fingerprint</i>"}
    Q3 -- "yes" --> FIXED["Prior run already resolved me,<br/>do nothing"]
    Q3 -- "no" --> FRESH["INSERT core Comment under fresh hash,<br/>relink reactions · files · notifications,<br/>log the rename"]

    style Q1 stroke:#9a6b1f,stroke-width:2px
    style Q2 stroke:#9a6b1f,stroke-width:2px
    style Q3 stroke:#9a6b1f,stroke-width:2px
    style INS stroke:#2e7d4f,stroke-width:2px
    style FRESH stroke:#2e7d4f,stroke-width:2px
    style MINE stroke-dasharray: 5 4
    style FIXED stroke-dasharray: 5 4
Loading

Crash anywhere? Committed chunks stay, the interrupted chunk rolled back atomically. Re-running bench migrate replays the same tree: finished rows land on a dashed no-op, unfinished rows take the green path. Same statement, same answer, no duplicates and no manual repair.

New Timeline UI

New.Ticket.mp4

depends-on: frappe/frappe#41924
frappe/frappe#42082
frappe/frappe#42142
frappe/frappe#42685

Migrating your customizations

If you have custom code written against HD Ticket Comment, HD Ticket Activity or HD Notification, it keeps running after this change, but it now reads and writes rows nothing displays.

The wiki page below is the upgrade guide: full field mapping, how to create and read a comment now, where to move your doc_events and why the handler needs a reference_doctype guard, the reaction and attachment changes, the notification mapping, and a grep checklist at the end.

Migrating customizations from HD Ticket Comment to Comment

@RitvikSardana
RitvikSardana force-pushed the refactor/comments-notifications-migration branch from 7d2bd0d to aed3227 Compare August 15, 2026 08:58
@RitvikSardana
RitvikSardana force-pushed the refactor/comments-notifications-migration branch from 946d0cd to e021793 Compare August 15, 2026 16:08
@RitvikSardana RitvikSardana changed the title refactor: comments and notifications migration refactor: comments and notifications doctype Aug 15, 2026
Replace the hand-rolled ticket activity feed (TicketAgentActivities,
EmailArea, CommentBox, HistoryBox, FeedbackBox) with the framework's
ActivityTimeline + useActivityTimeline on both desktop and mobile.

- one shared fetch per ticket (SHARED_VISIBLE_TYPES); tabs filter client-side
- TimelineContainer bounds the feed; mobile page is a clamped column
- comment extras (reactions/attachments) via helpdesk.api.timeline
- deep links map ?highlight=comment-/communication- to timeline row keys
- drop dead server endpoints (get_ticket_activities, get_history,
  get_version_history, get_views)
- assert the Add Comment action lands in core Comment, not HD Ticket Comment
- reload the timeline after actions apply: the send-triggered reload races
  the action comment's socket append and can drop it until a refresh
- drop contact from the version fields worth a feed row
The page gated on prefetchActivityTimeline, which no longer exists — the
timeline store is only reachable through useActivityTimeline. TicketAgent now
starts the feed itself and latches its loading flag, so the doc and the feed
load behind a single spinner instead of two in sequence. Latched because a
doc_update reloads the feed, which must not blank the page.

Saved reply actions reload the feed through the mounted timeline, which
registers its refresh on the ticketMap entry, keyed per ticket so a reload
after a ticket switch hits the right feed.

Also moves the timeline imports to the @framework/ui/ActivityTimeline entry
point and picks up AttachmentChip for comment attachments.
@greptile-apps

greptile-apps Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

Safe to merge.

Comment thread helpdesk/api/timeline.py
Comment thread helpdesk/patches/migrate_hd_ticket_comment_to_comment.py
Comment thread desk/src/components/ticket-agent/timeline/TicketTimeline.vue
@mergify

mergify Bot commented Sep 7, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@codecov-commenter

codecov-commenter commented Sep 7, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.29050% with 80 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.07%. Comparing base (c3ae467) to head (a979e84).
⚠️ Report is 51 commits behind head on develop.

Files with missing lines Patch % Lines
helpdesk/api/timeline.py 57.50% 17 Missing ⚠️
helpdesk/setup/comments.py 38.09% 13 Missing ⚠️
helpdesk/notifications.py 75.00% 11 Missing ⚠️
helpdesk/helpdesk/doctype/hd_ticket/hd_ticket.py 68.18% 7 Missing ⚠️
helpdesk/api/search.py 0.00% 6 Missing ⚠️
helpdesk/search_sqlite.py 25.00% 6 Missing ⚠️
helpdesk/api/comment.py 90.38% 5 Missing ⚠️
helpdesk/tests/test_core_comments.py 98.77% 5 Missing ⚠️
helpdesk/api/agent_home/agent_home.py 73.33% 4 Missing ⚠️
helpdesk/extends/comment.py 85.71% 4 Missing ⚠️
... and 2 more
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3700      +/-   ##
===========================================
+ Coverage    73.76%   75.07%   +1.30%     
===========================================
  Files          148      154       +6     
  Lines        10841    11437     +596     
===========================================
+ Hits          7997     8586     +589     
- Misses        2844     2851       +7     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread helpdesk/helpdesk/doctype/hd_ticket/api.py Outdated
Comment thread helpdesk/api/timeline.py Outdated
Comment thread desk/src/components/ticket-agent/timeline/TicketTimeline.vue
Comment thread helpdesk/patches/utils.py
@RitvikSardana

Copy link
Copy Markdown
Member Author

@greptileai rereview

Comment thread helpdesk/api/comment.py
Comment thread helpdesk/api/timeline.py
Comment thread helpdesk/helpdesk/doctype/hd_ticket/hd_ticket.py
@RitvikSardana

Copy link
Copy Markdown
Member Author

@greptileai rereview

RitvikSardana and others added 2 commits September 9, 2026 13:28
…ermissions

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RLRT2UCFYoGRxyahBphFbY
…ry tab change

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RLRT2UCFYoGRxyahBphFbY
Comment thread desk/src/components/ticket-agent/timeline/TicketTimeline.vue
@RitvikSardana

Copy link
Copy Markdown
Member Author

@greptileai rereview

@RitvikSardana
RitvikSardana merged commit d96e9e3 into frappe:develop Sep 9, 2026
7 checks passed
@RitvikSardana RitvikSardana changed the title refactor: comments and notifications doctype refactor!: comments and notifications doctype Sep 9, 2026
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