Skip to content

Enhance Save Modal with Per-Chunk Definitions, AI Advice Chat, and UI Improvements #86exnxbwb#25

Merged
navidshad merged 10 commits into
devfrom
CU-86exnxbwb_Step-6-Build-PRFAQ-001-Phase-1-Productive-Retrieval-Smart-Review_Navid-Shad
May 24, 2026
Merged

Enhance Save Modal with Per-Chunk Definitions, AI Advice Chat, and UI Improvements #86exnxbwb#25
navidshad merged 10 commits into
devfrom
CU-86exnxbwb_Step-6-Build-PRFAQ-001-Phase-1-Productive-Retrieval-Smart-Review_Navid-Shad

Conversation

@navidshad
Copy link
Copy Markdown
Collaborator

@navidshad navidshad commented May 21, 2026

🏷️ PR Title: Enhance Save Modal and Console Crane Features with Flashcard Preview and Improved Bundle Handling

📋 Summary

This PR introduces multiple enhancements and fixes primarily focused on the save modal and console crane components. Key updates include adding practice and flashcard-preview pages with near-translation actions, implementing DB-first lookup to reuse stored translations without redundant AI calls, and improving bundle chip UI with dirty-aware saves and inline removal. Additionally, chunk highlights and AI advice chat have been integrated, along with a refactor to enable per-page bundle suggestions via dedicated RPC. Circular import issues have been resolved, and button text updated for clarity.

🔗 Related Tasks

  • #1315cc8 - Implement DB-first lookup to reuse stored translations and avoid unnecessary AI calls
  • #374cbb4 - Add in-field bundle chips with dirty-aware save and inline removal functionality
  • #9954c22 - Introduce chunk highlights, AI advice chat, and bundle suggestion features
  • #01e510c - Refactor save modal for per-page bundle suggestion via dedicated RPC
  • #ab00130 - Fix circular import issues between save modal and console crane store
  • #3b85dd8 - Rename "Save & view" button to "Save and Learn"

📝 Additional Details

  • Post-save chip now correctly shows the bundle title by refetching bundle options
  • Practice and flashcard-preview pages include near-translation actions for improved user experience
  • Merged pronunciation support and reorder save functionality added to save modal chunks
  • Comprehensive test coverage added for flashcard preview, word-detail actions, and navigation within console crane

📜 Commit List

  • e504570 test(console-crane): cover flashcard preview, word-detail actions, navigation
  • 224b9da feat(console-crane): practice + flashcard-preview pages, near-translation actions
  • 25499da fix(save-modal): refetch bundle options so post-save chip shows title
  • 1315cc8 feat(saved-phrase): DB-first lookup, reuse stored translation, no AI re-call
  • 374cbb4 feat(save-modal): in-field bundle chips with dirty-aware save + inline removal
  • ab00130 fix(save-modal): break circular import to console-crane store
  • 01e510c refactor(save-modal): per-page bundle suggestion via dedicated RPC
  • 3b85dd8 chore(nibble): rename "Save & view" button to "Save and Learn"
  • f766040 feat(save-modal): per-chunk definitions, merged pronunciation, reorder save
  • 9954c22 feat(save-modal): chunk highlights, AI advice chat, bundle suggestion

navidshad and others added 3 commits May 21, 2026 12:38
PRFAQ-001 Phase 1 (extension, CU-86exnxnd3):
- Inline chunk highlights on the selection; "Ask AI" chat (explain or fix) with
  conversation history and editable user messages (re-runs from edit point).
- Bundle suggestion: URL-matched bundle -> suggested chip (editable) -> last-used;
  named "Save to <bundle>" button; sends chunks + sourceUrl to createPhrase.
- Preview flashcard (chunk cloze) and Practice now button (-> practice-config stub).
- Modal trims: drop examples + related expressions; "Phonetic" -> "Pronunciation"
  with per-chunk transliteration; pass pageTitle/pageUrl to translateWithContext.
- dir="auto" on chat bubbles/input for mixed RTL/LTR.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…r save

- Definition section now shows one block per chunk (label + pronunciation +
  meaning); the separate Pronunciation fieldset is merged in.
- Falls back to the whole-phrase definition + transliteration for short
  selections with no chunks.
- Move the Save / Login button below the definition so meaning comes first.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@navidshad
Copy link
Copy Markdown
Collaborator Author

@navidshad navidshad changed the title Cu 86exnxbwb step 6 build prfaq 001 phase 1 productive retrieval smart review navid shad Enhance Save Modal with Per-Chunk Definitions, AI Advice Chat, and UI Improvements #86exnxbwb May 21, 2026
navidshad and others added 7 commits May 21, 2026 21:06
- New BundleSuggestionService: calls getBundleSuggestionForPage once per page
  (logged-in only), cached by normalised URL; cache cleared after a save.
- SaveWordSectionV2 default-bundle chain now uses the suggestion result
  (matchedBundle -> suggestedName -> last-used), replacing the client-side
  matchBundleByUrl and the suggested_bundle_name prop.
- Drop pageTitle/pageUrl from the translation call and suggested_bundle_name
  from the LanguageLearningData type.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
SaveWordSectionV2 -> console-crane store -> router -> word-detail ->
SaveWordSectionV2 caused "Cannot access '__WEBPACK_DEFAULT_EXPORT__' before
initialization" at runtime. Lazy-import the store inside startPracticeNow
instead of at module top so the static cycle is broken.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…e removal

- Saved bundles now render as chips inside the selector (removed the separate
  "Saved in" fieldset that collided with the action row). Each chip has a ×.
- Dirty-aware Save: disabled (greyed) unless a not-yet-saved bundle is selected;
  compact "Save" label since the bundle is shown in the field.
- Removing a saved bundle via × calls removePhrase immediately (watcher); Save
  only adds newly selected bundles. createPhrase reuses an existing same-named
  bundle instead of recreating (avoids E11000).
- In-field "Suggested" chip (editable) replaces the standalone row; resolve
  bundle titles from loaded options (pilotui hands back ids when preselected);
  normalise selection to ids so objects never leak to the parent / createPhrase.
- Existing-phrase lookup matches by phrase + owner only (translation varies per
  AI call, which previously made saved phrases look unsaved).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…re-call

- New shared findSavedPhrase (common/services/phrase.service.ts): single source
  of truth, matches by phrase text + owner (translation excluded by design).
- Nibble popup: for an already-saved phrase, load the stored translation from
  the DB and label the action "Learn" (book icon) instead of "Save and Learn" —
  no AI translate call.
- Word-detail modal: for a saved phrase, build the view from the stored document
  (translation + linguistic_data + chunks) instead of calling the detailed AI
  translation (also avoids the occasional "failed to parse JSON" error).
- SaveWordSectionV2 reuses findSavedPhrase for its existing-phrase check.
- Restore the source sentence: showContext now displays the surrounding
  sentence (only hides when empty/identical to the selection), and context
  prefers the stored source sentence for saved phrases.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
When a bundle id is selected that isn't in the loaded options (just
created on save, or matched server-side), refetch so its title resolves
instead of rendering the raw id.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…tion actions

- Move "Practice with AI" (renamed from "Practice now") and "Preview flashcard"
  out of the save card up under the translation, where they're visible.
- Flashcard preview is now its own page that previews every card a phrase
  generates: a Recognition card (Levels 1-2) plus one Fill-in-the-blank card per
  confirmed chunk found in the sentence (Levels 3-5), each tagged with its levels.
- Show a back button on every sub-page (settings, practice-config,
  flashcard-preview), not just settings, via the store's isOnMainPage.
- Decouple the console-crane store from the router through a small registration
  holder (navigation.ts). The store imported the router, which reads page default
  exports at module-eval time, creating a circular init; the prior workaround used
  a dynamic import() that webpack split into a chunk that cannot load in a
  content-script context (wrong public path + page CSP). The holder breaks the
  cycle so everything stays in one bundle.
- Restyle the Definition section from a Fieldset legend to a card with the same
  inline uppercase label as the other sections.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…vigation

- Extract the flashcard card-building out of the SFC into a pure
  flashcard-preview/cards.ts (buildPreviewCards) so it's unit-testable, and have
  the page consume it.
- Unit-test buildPreviewCards: recognition card always present, one cloze card
  per confirmed chunk found in the sentence, case-insensitive/first-occurrence
  blanking, and the skip cases (no chunk match, no sentence, empty chunk text).
- Component-test the flashcard-preview page (recognition-only, recognition +
  cloze, empty state) and word-detail (Definition renders as a card without the
  Fieldset legend; the action buttons show when logged in and hide when logged
  out; "Practice with AI" and "Preview flashcard" navigate via toggleConsoleCrane
  with the right route and params).
- Add navigation-holder tests (null before register, returns/replaces the
  router) and repoint the existing console-crane-store test's mock from the
  router module to the navigation holder, matching the store decoupling.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@navidshad navidshad merged commit b1688a1 into dev May 24, 2026
3 checks passed
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 1.12.0-dev.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant