Enhance Save Modal with Per-Chunk Definitions, AI Advice Chat, and UI Improvements #86exnxbwb#25
Merged
navidshad merged 10 commits intoMay 24, 2026
Conversation
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>
Collaborator
Author
- 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>
|
🎉 This PR is included in version 1.12.0-dev.2 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🏷️ 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
📝 Additional Details
📜 Commit List