Skip to content

feat(dictionary): faster search, browse-by-letter, a11y and share fixes - #77

Open
MadhuS-1605 wants to merge 2 commits into
devudilip:mainfrom
MadhuS-1605:feat/dictionary-improvements
Open

MadhuS-1605 wants to merge 2 commits into
devudilip:mainfrom
MadhuS-1605:feat/dictionary-improvements

Conversation

@MadhuS-1605

Copy link
Copy Markdown
Contributor

Closes #76

What this changes

Search performance (search.ts, useSearch.ts)

  • Phonetic-sibling shards are now lazy. searchKannada loads only the query's own shard(s) up front. It widens to phonetic-neighbour letters (, ) only when the direct exact/prefix lookup finds nothing and the query is 2+ aksharas. An exact hit no longer triggers a multi-shard download.
  • Debounce 120 ms → 220 ms, so a fast typist doesn't fire a shard fetch on every keystroke.

Browse by letter (new DictionaryLetterIndex.tsx)

  • A varnamale strip (13 vowels + 34 consonants + 2 archaic) in the empty state.
  • Per-letter counts summed from manifest.shards; letters with no entries are disabled.
  • Tapping a letter seeds a prefix search.

Results UX (SearchResults.tsx, DictionarySearch.tsx)

  • SearchResults no longer remounts on every keystroke (dropped key={normalise(q)}); the "show more related" expansion is reset with an effect instead, so it stops collapsing mid-scroll.
  • New live role="status" / aria-live="polite" line: {n} results or "no words found" — the no-results state was previously never announced to screen readers.

Share / URL correctness (EntryCard.tsx)

  • Copied links and citations now use CANONICAL_ORIGIN instead of window.location.origin, so links copied from a preview deploy no longer carry the preview host.

Page layout (dictionary/page.tsx)

  • The offline "download dictionary" button moves below the search UI, behind a divider — it no longer sits above the search box before the user has done anything.

Carried on this branch (adjacent, prior session work)

  • Share card: word cards render up to ~5 sense lines instead of just defs[0] (shareCard.ts gains supportMaxLines; the headword + senses block is centred together).
  • Proverbs: browse gaade by first letter — a full varnamale index with per-letter counts (features/proverbs/lib/letters.ts, ProverbsBrowse.tsx).

Testing

  • tsc --noEmit clean.
  • vitest run — 528 tests pass, including a new case in search.test.ts locking in "sibling shards fetched only on a miss", and new tests for the proverb letter index and the multi-line share card.

Dictionary page improvements:
- search: on an exact/prefix hit, skip the phonetic-sibling shard fetch
  (and skip sibling widening for 1-akshara queries) — the multi-shard
  network cost is only paid when the direct lookup finds nothing
- useSearch: debounce 120ms -> 220ms so each keystroke doesn't fire a shard load
- DictionaryLetterIndex: tap-a-letter varnamale index in the empty state,
  counts summed from the manifest shards; seeds a prefix search
- SearchResults: reset "show more related" via effect instead of a
  remount key, so the list no longer collapses mid-scroll on each keystroke
- a11y: live result-count / "no words found" status line
- EntryCard: copied links and citations use CANONICAL_ORIGIN, not the
  runtime origin (preview deploys were leaking their host into shared URLs)
- page: move the offline "download dictionary" button below the search UI

Also on this branch (carried from prior session work):
- share card: word cards render up to ~5 sense lines, not just defs[0]
- proverbs: browse gaade by first letter (full varnamale index)

Signed-off-by: MadhuS-1605 <madhusgowda56@gmail.com>
@MadhuS-1605
MadhuS-1605 force-pushed the feat/dictionary-improvements branch from 84caddf to 052c6d3 Compare September 6, 2026 08:06
…tionary-improvements

Signed-off-by: MadhuS-1605 <madhusgowda56@gmail.com>

# Conflicts:
#	src/app/dictionary/page.tsx
#	src/features/dictionary/components/DictionarySearch.tsx
#	src/features/dictionary/components/EntryCard.tsx
#	src/features/proverbs/components/ProverbsBrowse.tsx
@MadhuS-1605

Copy link
Copy Markdown
Contributor Author

Rebased/merged main into this branch and resolved the conflicts (merge commit a695cd3, DCO signed).

Conflicting files: src/app/dictionary/page.tsx, src/features/dictionary/components/DictionarySearch.tsx, src/features/dictionary/components/EntryCard.tsx, src/features/proverbs/components/ProverbsBrowse.tsx.

Resolution kept main's coral & sky redesign structure and layered this branch's changes on top:

  • DictionarySearch — a11y result-count live region + browse-by-letter index in the empty state, on top of the redesigned layout; DownloadDictionaryButton now lives inside the component (from main).
  • EntryCard — adopted main's useEntryCopy refactor; re-applied the multi-definition share card (shareSupport, supportMaxLines: 5).
  • ProverbsBrowse — took main's grouped letter rail; this branch's flat letter-filter (lib/letters) was superseded and removed.
  • dictionary/page.tsx — took main's layout.

npm run typecheck clean, npm test 569 passing. PR now shows mergeable.

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.

Dictionary page: search performance, browse-by-letter, and a11y/share fixes

1 participant