Skip to content

Commit 9d80f31

Browse files
committed
feat: Add comprehensive visual diff system for card description changes
This commit introduces a sophisticated visual diff system that enhances the activity feed with intelligent change detection and professional presentation. Resolves issue #7201. Features: • Smart diff rendering with emoji indicators (➕✏️🗑️🚚) • Word-level diffing for modifications with <del>/<ins> HTML tags • Intelligent move detection for relocated unchanged content • Special handling for checkbox state transitions (☐ ↔ ☑) • Line number context preservation for better readability • Noise filtering (empty lines, unchanged content) Technical Implementation: • New DiffService with LCS-based diff algorithm • Enhanced activity provider with diff integration • Multi-pass detection: moves → modifications → additions/deletions • Similarity scoring system for optimal operation pairing • HTML-safe output compatible with activity feed constraints Benefits: • Clear visualization of content changes in activity timeline • Reduced cognitive load with filtered, relevant changes only • Professional emoji-based change indicators • Maintains backward compatibility with existing activity system The system intelligently distinguishes between: - Line moves (🚚): Exact content relocated to different position - Modifications (✏️): Content changes with word-level highlighting - Additions (➕): New content inserted - Deletions (🗑️): Content removed Tested extensively with various scenarios including complex multi-operation changes, edge cases, and performance considerations. Signed-off-by: Alexander Askin <[email protected]>
1 parent 04d9433 commit 9d80f31

File tree

2 files changed

+513
-0
lines changed

2 files changed

+513
-0
lines changed

lib/Activity/DeckProvider.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use OCA\Deck\Db\Acl;
1111
use OCA\Deck\Service\CardService;
12+
use OCA\Deck\Service\DiffService;
1213
use OCP\Activity\IEvent;
1314
use OCP\Activity\IProvider;
1415
use OCP\Comments\IComment;
@@ -37,6 +38,8 @@ class DeckProvider implements IProvider {
3738
private $config;
3839
/** @var CardService */
3940
private $cardService;
41+
/** @var DiffService */
42+
private $diffService;
4043

4144
public function __construct(IURLGenerator $urlGenerator, ActivityManager $activityManager, IUserManager $userManager, ICommentsManager $commentsManager, IFactory $l10n, IConfig $config, $userId, CardService $cardService) {
4245
$this->userId = $userId;
@@ -47,6 +50,7 @@ public function __construct(IURLGenerator $urlGenerator, ActivityManager $activi
4750
$this->l10nFactory = $l10n;
4851
$this->config = $config;
4952
$this->cardService = $cardService;
53+
$this->diffService = new DiffService();
5054
}
5155

5256
/**
@@ -335,6 +339,20 @@ private function parseParamForDuedate($subjectParams, $params, IEvent $event) {
335339
* @return mixed
336340
*/
337341
private function parseParamForChanges($subjectParams, $params, $event) {
342+
// Handle card description changes with visual diff
343+
if ($event->getSubject() === ActivityManager::SUBJECT_CARD_UPDATE_DESCRIPTION &&
344+
array_key_exists('before', $subjectParams) && array_key_exists('after', $subjectParams)) {
345+
346+
$before = (string)($subjectParams['before'] ?? '');
347+
$after = (string)($subjectParams['after'] ?? '');
348+
349+
// Generate visual diff and set as parsed message
350+
$diffHtml = $this->diffService->generateDiff($before, $after);
351+
$event->setParsedMessage($diffHtml);
352+
353+
return $params;
354+
}
355+
338356
if (array_key_exists('diff', $subjectParams) && $subjectParams['diff'] && !empty($subjectParams['after'])) {
339357
// Don't add diff as message since we are limited to 255 chars here
340358
$event->setParsedMessage($subjectParams['after']);

0 commit comments

Comments
 (0)