fix(search): truncate excerpt in sanitizeHtml to prevent slow search#3199
fix(search): truncate excerpt in sanitizeHtml to prevent slow search#3199jancborchardt wants to merge 5 commits into
Conversation
Up to standards ✅🟢 Issues
|
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 |
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>
a261c23 to
20b16b7
Compare

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