Skip to content

Changes in translation questions resource#303

Merged
Joel-Joseph-George merged 2 commits into
mainfrom
fix/translation-question-r
Jun 11, 2026
Merged

Changes in translation questions resource#303
Joel-Joseph-George merged 2 commits into
mainfrom
fix/translation-question-r

Conversation

@Joel-Joseph-George

@Joel-Joseph-George Joel-Joseph-George commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

closes #256

Summary by CodeRabbit

  • New Features
    • Conditional prefetching of translation question content to reduce duplicate requests and improve load responsiveness.
    • Improved question display: extracts and presents question snippets, shows "Loading question..." while preparing content, and displays clear fallback when no question or text is available.

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds TipTap runtime handling and optional resourceId prop; ResourcePanel prefetches missing guide content when UWTranslationQuestions is selected; TextResourceAccordion special-cases rendering to show extracted question nodes in triggers and render tiptap content without the question as the answer.

Changes

UWTranslationQuestions Resource Support

Layer / File(s) Summary
Type contracts and TipTap type guard
src/features/resources/components/TextResourceAccordion.tsx
Imports TipTapNode, adds optional resourceId?: string to TextResourceAccordionProps, and introduces isTipTapNode runtime guard.
Guide content prefetch in ResourcePanel
src/features/resources/components/ResourcePanel.tsx
Adds pendingPrefetchIds ref and a useEffect that prefetches missing guide content for UWTranslationQuestions when selected; passes resourceId={selectedResource.id} to TextResourceAccordion.
Accordion rendering with UWTranslationQuestions special case
src/features/resources/components/TextResourceAccordion.tsx
Derives guideContent = guideContents[sv.id]. In TQ mode (resourceId === 'UWTranslationQuestions'), extracts the first TipTap child node per item for accordion triggers (or shows loading/empty states), computes tiptapContent by removing that first node for answers, guards TipTapRenderer with isTipTapNode, and updates "No text content" checks to use guideContent.

Sequence Diagram(s)

sequenceDiagram
  participant ResourcePanel
  participant AquiferAPI as fetchGuideContent
  participant TextResourceAccordion
  participant TipTapRenderer
  ResourcePanel->>ResourcePanel: Detect selectedResource.id === "UWTranslationQuestions"
  ResourcePanel->>AquiferAPI: fetchGuideContent(missing localizeRefName ids)
  AquiferAPI-->>ResourcePanel: guideContents (TipTap docs)
  ResourcePanel->>TextResourceAccordion: pass resourceId and guideContents
  TextResourceAccordion->>TextResourceAccordion: extract first child node as question
  TextResourceAccordion->>TextResourceAccordion: remove first node to form answer tiptapContent
  TextResourceAccordion->>TipTapRenderer: render answer tiptapContent
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A rabbit nibbles TipTap nodes with glee,
Pulls out the question, leaves answers free,
Prefetching guides across the lane,
Accordion petals open like rain,
Tiny hops, big clarity—hooray for TQ!

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (1 warning, 2 inconclusive)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR implements guide content prefetching and accordion UI modifications for UWTranslationQuestions, but the linked issue #256 requires a complete resource panel with accordion rows, empty states, loading states, and context-scoped data fetching from the Aquifer API that are not evident in these changes. Verify that the PR includes all required components: accordion row UI with chevron icons, verse references, question/answer display logic, empty state handling, context change detection, and proper Aquifer API integration scoped to display mode.
Title check ❓ Inconclusive The title 'Changes in translation questions resource' is vague and generic, using non-descriptive phrasing that doesn't convey the specific implementation details such as conditional prefetching, guide content integration, or accordion UI updates. Consider a more specific title like 'Implement guide prefetching and accordion UI for UWTranslationQuestions resource' to better describe the actual changes made.
Out of Scope Changes check ❓ Inconclusive The changes appear narrowly focused on prefetching and accordion rendering without introducing unrelated modifications; however, the scope relative to issue #256 requirements cannot be fully assessed without seeing the complete implementation. Provide clarity on whether other required components from issue #256 (API fetching, context handling, empty/loading states) are implemented in this PR or planned for follow-up changes.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/translation-question-r

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed: dependency version conflict. Check your lock file or package.json.


Comment @coderabbitai help to get the list of available commands and usage tips.

@Joel-Joseph-George Joel-Joseph-George changed the title Changes in tq as per requirment Changes in translation questions resource as Jun 11, 2026
@Joel-Joseph-George Joel-Joseph-George changed the title Changes in translation questions resource as Changes in translation questions resource Jun 11, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/features/resources/components/ResourcePanel.tsx (1)

248-251: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Implement the required TQ-specific empty-state message.

When TQ has no entries, the UI still shows the generic text. Per the PR objective, this branch should show: "No Translation Questions available for this passage."

Suggested fix
           ) : (
             <div className='flex h-full items-center justify-center'>
-              <p className='text-sm'>No resources available</p>
+              <p className='text-sm'>
+                {selectedResource.id === 'UWTranslationQuestions'
+                  ? 'No Translation Questions available for this passage.'
+                  : 'No resources available'}
+              </p>
             </div>
           )}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/features/resources/components/ResourcePanel.tsx` around lines 248 - 251,
The empty-state message in ResourcePanel is using a generic string; change the
render branch in the ResourcePanel component that currently returns "<p
className='text-sm'>No resources available</p>" so that when the active resource
type/context is Translation Questions (TQ) it instead displays "No Translation
Questions available for this passage." Locate the conditional branch in
ResourcePanel's JSX (the same block shown in the diff) and replace the generic
message with the TQ-specific sentence, ensuring the message is shown only when
the component's TQ indicator (e.g., props.activeTab, props.resourceType, or
whatever prop/state denotes TQ) is present.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/features/resources/components/ResourcePanel.tsx`:
- Around line 178-196: The effect can re-trigger while fetches are in-flight
causing duplicate fetchGuideContent calls for the same id; fix by tracking
in-progress prefetches and skipping IDs already pending or present in
guideContents. Implement a local ref/set (e.g. pendingPrefetchIds via
useRef<Set<string>>()) inside ResourcePanel, check both (item.id in
guideContents) and pendingPrefetchIds.current.has(item.id) before calling
fetchGuideContent, add the id to pendingPrefetchIds.current immediately before
invoking fetchGuideContent, and remove it when the fetch resolves/rejects (wrap
fetchGuideContent(item.id) with .then/.catch to clear the id). This keeps
symbols used in the diff (useEffect, selectedResource.id, localizeRefName,
shouldFetchResources, guideContents, fetchGuideContent) and prevents duplicated
pending resolvers/timeouts.

In `@src/features/resources/components/TextResourceAccordion.tsx`:
- Around line 91-95: The conditional currently shows "Loading question..."
whenever tqQuestionNodes.length === 0 even after fetch finished; update the
render logic in TextResourceAccordion so that it checks loadingGuides[sv.id] (or
a similar loading flag) first and only shows the animated "Loading question..."
when loadingGuides[sv.id] is true, otherwise render a non-loading fallback such
as "No question available" or an empty state when tqQuestionNodes.length === 0;
modify the ternary around tqQuestionNodes.length to incorporate
loadingGuides[sv.id] (and consider adding an error/fetched flag) to avoid a
permanent loading UI for empty or malformed entries.

---

Outside diff comments:
In `@src/features/resources/components/ResourcePanel.tsx`:
- Around line 248-251: The empty-state message in ResourcePanel is using a
generic string; change the render branch in the ResourcePanel component that
currently returns "<p className='text-sm'>No resources available</p>" so that
when the active resource type/context is Translation Questions (TQ) it instead
displays "No Translation Questions available for this passage." Locate the
conditional branch in ResourcePanel's JSX (the same block shown in the diff) and
replace the generic message with the TQ-specific sentence, ensuring the message
is shown only when the component's TQ indicator (e.g., props.activeTab,
props.resourceType, or whatever prop/state denotes TQ) is present.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: d7868429-04ab-4ca7-a478-399fe77d08cf

📥 Commits

Reviewing files that changed from the base of the PR and between b467525 and 37e6c5d.

📒 Files selected for processing (2)
  • src/features/resources/components/ResourcePanel.tsx
  • src/features/resources/components/TextResourceAccordion.tsx

Comment thread src/features/resources/components/ResourcePanel.tsx
Comment thread src/features/resources/components/TextResourceAccordion.tsx

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/features/resources/components/ResourcePanel.tsx (1)

245-260: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Render the TQ-specific empty-state message.

When selectedResource.id === 'UWTranslationQuestions' and localizeRefName is empty, this branch still shows the generic "No resources available" copy. That misses the issue requirement to show "No Translation Questions available for this passage." for the no-results case.

Suggested fix
-          ) : (
+          ) : selectedResource.id === 'UWTranslationQuestions' ? (
+            <div className='flex h-full items-center justify-center'>
+              <p className='text-sm'>No Translation Questions available for this passage.</p>
+            </div>
+          ) : (
             <div className='flex h-full items-center justify-center'>
               <p className='text-sm'>No resources available</p>
             </div>
           )}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/features/resources/components/ResourcePanel.tsx` around lines 245 - 260,
The empty-state branch currently renders a generic "No resources available" when
localizeRefName is empty; update the render logic in ResourcePanel (around the
TextResourceAccordion block) to check if selectedResource.id ===
'UWTranslationQuestions' and localizeRefName.length === 0 and, in that case,
render the specific string "No Translation Questions available for this
passage." instead of the generic message; otherwise keep the existing generic
message for other resource types. Ensure this conditional sits where the current
fallback div is returned so TextResourceAccordion remains unchanged.
♻️ Duplicate comments (1)
src/features/resources/components/ResourcePanel.tsx (1)

187-195: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Also skip IDs that are already loading.

pendingPrefetchIds only tracks requests started by this effect. The first auto-open path at Lines 169-173, and later manual opens through handleAccordionChange(), can already have fetchGuideContent(item.id) in flight before this loop runs. useGuideContent() only dedupes the queue entry, not the pending resolver/timeout bookkeeping, so this still stacks extra waiters for the same id.

Suggested fix
       localizeRefName.forEach(item => {
-        if (!(item.id in guideContents) && !pendingPrefetchIds.current.has(item.id)) {
+        if (
+          !(item.id in guideContents) &&
+          !loadingGuides[item.id] &&
+          !pendingPrefetchIds.current.has(item.id)
+        ) {
           pendingPrefetchIds.current.add(item.id);
           fetchGuideContent(item.id)
             .then(() => {
               pendingPrefetchIds.current.delete(item.id);
             })
@@
   }, [
     selectedResource.id,
     localizeRefName,
     shouldFetchResources,
     guideContents,
+    loadingGuides,
     fetchGuideContent,
   ]);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/features/resources/components/ResourcePanel.tsx` around lines 187 - 195,
The loop is starting prefetches even when a fetch for the same id is already
in-flight elsewhere (first auto-open path or handleAccordionChange), causing
duplicate waiters; update the prefetch guard to also consult the shared
in-flight bookkeeping used by useGuideContent (or extract a shared inFlight set)
so you skip ids already loading. Concretely: in ResourcePanel's effect that uses
pendingPrefetchIds and fetchGuideContent, add a check against the same in-flight
set/resolver registry that useGuideContent updates (or move pendingPrefetchIds
into a shared ref exported/used by useGuideContent and handleAccordionChange)
and only call fetchGuideContent(item.id) when the id is not in either
pendingPrefetchIds.current and the shared in-flight set so duplicate
fetches/waiters are prevented.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/features/resources/components/ResourcePanel.tsx`:
- Around line 245-260: The empty-state branch currently renders a generic "No
resources available" when localizeRefName is empty; update the render logic in
ResourcePanel (around the TextResourceAccordion block) to check if
selectedResource.id === 'UWTranslationQuestions' and localizeRefName.length ===
0 and, in that case, render the specific string "No Translation Questions
available for this passage." instead of the generic message; otherwise keep the
existing generic message for other resource types. Ensure this conditional sits
where the current fallback div is returned so TextResourceAccordion remains
unchanged.

---

Duplicate comments:
In `@src/features/resources/components/ResourcePanel.tsx`:
- Around line 187-195: The loop is starting prefetches even when a fetch for the
same id is already in-flight elsewhere (first auto-open path or
handleAccordionChange), causing duplicate waiters; update the prefetch guard to
also consult the shared in-flight bookkeeping used by useGuideContent (or
extract a shared inFlight set) so you skip ids already loading. Concretely: in
ResourcePanel's effect that uses pendingPrefetchIds and fetchGuideContent, add a
check against the same in-flight set/resolver registry that useGuideContent
updates (or move pendingPrefetchIds into a shared ref exported/used by
useGuideContent and handleAccordionChange) and only call
fetchGuideContent(item.id) when the id is not in either
pendingPrefetchIds.current and the shared in-flight set so duplicate
fetches/waiters are prevented.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 08d90ca7-dfd6-49d3-b5b9-d5b79e16349b

📥 Commits

Reviewing files that changed from the base of the PR and between 37e6c5d and e14b922.

📒 Files selected for processing (2)
  • src/features/resources/components/ResourcePanel.tsx
  • src/features/resources/components/TextResourceAccordion.tsx

@Joel-Joseph-George Joel-Joseph-George merged commit 0dcea61 into main Jun 11, 2026
2 checks passed
@github-actions github-actions Bot deleted the fix/translation-question-r branch June 11, 2026 11:43
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.

Add Translation Questions Resource

2 participants