Skip to content

Debug, optimize perf & a11y, complete gesture stubs#2

Open
devin-ai-integration[bot] wants to merge 2 commits intomainfrom
devin/1776438923-debug-perf-a11y
Open

Debug, optimize perf & a11y, complete gesture stubs#2
devin-ai-integration[bot] wants to merge 2 commits intomainfrom
devin/1776438923-debug-perf-a11y

Conversation

@devin-ai-integration
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot commented Apr 17, 2026

Summary

Cross-cutting debug / perf / a11y / feature-completion pass over the ZSR core library, driven by a walkthrough of lib/core, lib/feedback, lib/interaction and lib/utils.

  • Lint hygiene. .prettierignore and eslint.config.mjs now scope root lint to actual project sources: the separate site/htdocs SvelteKit workspace, generated ~partytown vendor files, dist/, node_modules/ and .cache/ are ignored. npm run lint is now green from the repo root.
  • ScreenReader queue/race hardening. speaking is initialized in the constructor, and rapid duplicate non-high-priority announcements within 500ms are coalesced, so focus / event retries don't re-queue identical TTS items.
  • Emoji / symbol translation perf + correctness. translateEmojis / translateSymbols now precompile a single alternation regex per map, sort keys by length so multi-codepoint sequences (e.g. ❤️, ❤️‍🔥) match before their prefixes, escape special regex chars for the symbol table, and defensively coerce input to string. This turns each call from O(n·k) regex builds into a single O(n) pass.
  • Interceptor retry safety. PageInterceptor and WidgetInterceptor both cap their "wait for global" retry chain at ~5s (50 × 100ms) and log an error instead of spinning forever on devices where Page / createWidget is never exposed.
  • NavigationManager text cursor fix. The word mode rebuilds words via /\S+/g with real offsets so the cursor jumps accurately across punctuation/whitespace gaps; sentence / paragraph modes and empty-text paths now announce gracefully instead of silently no-oping.
  • Gesture stubs completed. scroll_up / scroll_down now translate into focus prev / next (the accessible analogue of scrolling), previous_page calls @zos/router.back(), and next_page either pushes a configurable ScreenReaderConfig.nextPageUrl or announces that no next page is available.
  • SoundFeedback. The sound-name map is hoisted to a module-level constant (no per-call rebuild) and a stale PREPARE listener is detached between play() calls to avoid leaking handlers on rapid-fire cues.
  • SpeechHistory. Back-to-back duplicate entries within 1s are collapsed into a single entry with a count, so the 50-entry buffer stays useful instead of being pushed out by repeated focus events.

Smoke-tested lib/utils/emojis.js and lib/utils/speechHistory.js under Node 22.13.0; npm run lint passes.

Review & Testing Checklist for Human

Risk: yellow — touches hot paths (TTS queue, navigation cursor, gesture dispatch) but no API changes.

  • Sideload on a real Zepp OS device and confirm the screen reader still announces on focus / swipe navigation, and that rapid identical focus events no longer re-speak (should feel calmer, not deaf to legitimate re-focus).
  • Exercise 1/2/3-finger swipes up/down and verify scroll_up / scroll_down / next_page / previous_page behave sensibly — in particular confirm previous_page actually calls @zos/router.back() on your page stack.
  • Navigate inside a long text element using the word reading mode; verify the cursor lands on each real word and doesn't get stuck mid-sentence.
  • Sanity-check that emoji announcements like ❤️ and ❤️‍🔥 are spoken as a single phrase (not a heart followed by an orphan variation selector).

Notes

  • site/htdocs/** was deliberately excluded from root lint rather than auto-formatted — it has its own workspace and its own Prettier/ESLint setup, and reformatting it from the root would produce a huge unrelated diff.
  • No test suite exists yet (npm test is the placeholder exit 1); verification relied on module smoke tests and manual reading.

Link to Devin session: https://app.devin.ai/sessions/acb85709db3d477e8fc61dbc490e7145
Requested by: @NVCDevelopmentTeam


Open with Devin

- Lint: scope root prettier/eslint so they skip the separate site/htdocs
  workspace and generated partytown vendor files; root lint now runs
  cleanly end to end.
- ScreenReader: initialize speaking flag, coalesce rapid duplicate
  announcements to reduce TTS churn and avoid flooding the user.
- Emoji/symbol translation: precompile a single sorted regex per map so
  calls are O(n) instead of O(n*k), sort keys by length so multi-char
  emoji (e.g. ❤️, ❤️‍🔥) match before their prefixes, and coerce
  input to string defensively.
- Page/Widget interceptors: cap the 'waiting for globals' retry loop at
  ~5s so a missing Page/createWidget no longer produces an endless
  100ms timer chain on unsupported devices.
- NavigationManager: fix the word/sentence/paragraph cursor so it jumps
  by real word offsets and gracefully handles empty text instead of
  silently skipping elements.
- Gesture stubs: implement scroll_up / scroll_down (focus navigation
  parity with scrolling), previous_page (router.back), and next_page
  (configurable router.push with a spoken fallback when none is set).
- SoundFeedback: hoist the sound map to a module-level constant and
  detach stale PREPARE listeners between plays so rapid-fire cues do
  not leak handlers on the media player.
- SpeechHistory: coalesce back-to-back duplicate entries with a count
  so the history log stays readable and doesn't push real content out
  of the 50-entry buffer on repeated focus events.

Co-Authored-By: Coding Nguyen <Quang.hnm.hd.2k@gmail.com>
@devin-ai-integration
Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Apr 17, 2026

Deploying zepp-reader with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1b1e671
Status: ✅  Deploy successful!
Preview URL: https://676552b5.zepp-reader.pages.dev
Branch Preview URL: https://devin-1776438923-debug-perf.zepp-reader.pages.dev

View logs

devin-ai-integration[bot]

This comment was marked as resolved.

Devin Review flagged that the refactored applyReplacer dropped the
commas that the original translateEmojis/translateSymbols wrapped
around each spoken description. Commas matter for TTS engines
because they introduce a short pause, so for a11y users the
announcement 'I love you ❤️ so much' must render as
'I love you , Red heart,  so much' rather than collapsing into a
single run-on phrase.

Co-Authored-By: Coding Nguyen <Quang.hnm.hd.2k@gmail.com>
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.

1 participant