fix(search): truncate excerpt in sanitizeHtml to prevent slow search#3199
Conversation
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| Documentation | 1 minor |
🟢 Metrics 0 complexity · 0 duplication
Metric Results Complexity 0 Duplication 0
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
This comment was marked as outdated.
This comment was marked as outdated.
6501f55 to
95c079c
Compare
|
APK file: https://github.com/nextcloud/notes-android/actions/runs/26316063945/artifacts/7171801123 |
jancborchardt
left a comment
There was a problem hiding this comment.
Tested and can confirm this fixes the search performance issue introduced by #3155 @alperozturk96
jancborchardt
left a comment
There was a problem hiding this comment.
@alperozturk96 is it a convention to have no code comments? If so, it would be useful to add ot to the Agents.md too.
Not all comments and in this case most of it :) e.g. We can update |
a261c23 to
20b16b7
Compare
|
/rebase |
generateNoteExcerpt() always truncated to 200 chars via truncateString() on the markdown path, but the sanitizeHtml() path added in #3155 returned the full content untruncated. Any note whose content matches the broad HTML_PATTERN (which includes informal tags like <todo>, <action>, generics like List<String>, or Markdown email syntax) would have its full 35-41 kB stored as the excerpt. On every search keystroke, the adapter called textView.setText() and highlightText() with those large strings on the main thread for every visible item, blocking the UI for several seconds. Fix: strip remaining HTML tags and truncate to 200 chars in sanitizeHtml(), consistent with the markdown path. Search still operates on the full note content via SQL LIKE. Fixes: #3180 AI-assisted: Claude Code (Sonnet 4.6) Signed-off-by: Jan C. Borchardt <925062+jancborchardt@users.noreply.github.com>
Fixes Codacy complexity warnings about duplicate string literals. AI-assisted: Claude Code (Sonnet 4.6) Signed-off-by: Jan C. Borchardt <925062+jancborchardt@users.noreply.github.com>
Fixes Codacy documentation warning. AI-assisted: Claude Code (Sonnet 4.6) Signed-off-by: Jan C. Borchardt <925062+jancborchardt@users.noreply.github.com>
…eUtilTest.kt Signed-off-by: Alper Öztürk <67455295+alperozturk96@users.noreply.github.com>
…eUtilTest.kt Signed-off-by: Alper Öztürk <67455295+alperozturk96@users.noreply.github.com>
20b16b7 to
d13e1aa
Compare
|
APK file: https://github.com/nextcloud/notes-android/actions/runs/26556681186/artifacts/7258471527 |

Summary
sanitizeHtml()added in Improve note preview #3155 returned the full note content untruncated, while the markdown path always callstruncateString(result, 200)HTML_PATTERN(which includes informal tags like<todo>, generics likeList<String>, or Markdown email syntax like<user@host>) would have its full 35–41 kB stored as the excerpt in the databasetextView.setText()andhighlightText()with those large strings on the main thread for every visible item, blocking the UI for several seconds (reported in Search very slow since latest release #3180)sanitizeHtml(), consistent with the markdown path — SQL LIKE search still operates on the full note contentTest plan
<placeholder>syntax, email addresses, etc.)./gradlew :app:testFdroidDebugUnitTest --tests "it.niedermann.owncloud.notes.shared.util.NoteUtilTest"Fixes #3180
🤖 Generated with Claude Code