Skip to content

Conversation

@mateuszruszkowski
Copy link

@mateuszruszkowski mateuszruszkowski commented Jan 20, 2026

Summary

  • Fix MemoryCard component showing black screen when expanding content
  • Fix React "Objects are not valid as React child" error in PRReviewCard
  • Ensure proper JSX rendering by wrapping objects in JSON.stringify()

Changes

  • apps/frontend/src/renderer/components/MemoryCard.tsx: Fix expanded content rendering with safe string conversion
  • apps/frontend/src/renderer/components/PRReviewCard.tsx: Fix AI response rendering for non-string values

Test plan

  • Open Memories tab and verify memory cards display correctly
  • Click expand on a memory card - verify content shows instead of black screen
  • View PR review cards with AI suggestions - verify no React rendering errors
  • Run TypeScript compilation: npm run typecheck

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Prevented empty detail sections from appearing by only showing expanded content when it actually contains data.
    • Added a fallback display for unparseable or empty content when a card is expanded.
  • Improvements

    • Recommendations now support structured entries (e.g., category, priority, effort) as well as plain text.
    • Recommendation rendering skips empty/null items for clearer lists.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 20, 2026

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Walkthrough

Broadened recommendation data shapes to accept objects or strings; rendering now extracts recommendation text from either shape, filters empty items, and requires content checks (hasContent / hasExpandableContent) before showing expanded views or fallbacks.

Changes

Cohort / File(s) Summary
Recommendations type expansion & rendering
apps/frontend/src/renderer/components/context/MemoryCard.tsx
Changed recommendations arrays to `Array<string
Expandable content gating
apps/frontend/src/renderer/components/context/PRReviewCard.tsx
Adjusted expanded content rendering to require expanded && hasExpandableContent instead of only expanded, preventing empty expanded sections.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Suggested labels

bug, area/frontend, size/M

Suggested reviewers

  • AlexMadera
  • AndyMik90

Poem

🐰 I nibble on types and hop through view,
Strings or objects, I’ll fetch what’s true,
I peek for content before I show,
Empty folds tucked safe below,
Hooray — recommendations snug and new! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: fixing MemoryCard rendering issues in the Memories tab, which is the primary focus of the PR.

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

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @mateuszruszkowski, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses critical frontend rendering issues within the MemoryCard and PRReviewCard components. The primary goal is to eliminate 'black screen' errors and 'Objects are not valid as React child' exceptions that occurred when expanding content or displaying AI-generated responses. By refining data type definitions, adding robust content checks, and improving rendering logic for diverse data formats, the changes ensure a more stable and user-friendly display of information in the Memories tab.

Highlights

  • MemoryCard Rendering Fix: Resolved an issue where the MemoryCard component would display a black screen when its content was expanded, ensuring proper rendering of parsed data.
  • PRReviewCard Error Resolution: Fixed a React 'Objects are not valid as React child' error occurring in the PRReviewCard, particularly when rendering AI responses that might contain non-string values.
  • Type Definition Enhancement: Updated the ParsedSessionInsight interface to accommodate more complex, structured objects for recommendations, improving data handling flexibility.
  • Robust Content Display: Introduced hasContent and hasExpandableContent checks to conditionally render expanded sections, preventing UI issues when content is missing or unparseable.
  • Improved Recommendation Rendering: Enhanced the rendering logic for recommendations in MemoryCard to correctly extract and display text from both string and object formats.
  • Fallback Content Display: Implemented a fallback mechanism in PRReviewCard to display raw memory content when structured expandable content is not available, improving user experience for unparseable data.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@sentry
Copy link

sentry bot commented Jan 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request addresses rendering issues in the MemoryCard and PRReviewCard components. The main fixes involve handling cases where parsed memory content is empty or contains objects instead of strings, preventing blank sections and React rendering errors. The changes correctly add fallbacks to display raw content when structured data is unavailable and update the rendering logic to handle new data shapes. My review includes a suggestion to improve the new rendering logic in MemoryCard.tsx for better maintainability and type safety.

@AndyMik90 AndyMik90 self-assigned this Jan 20, 2026
Copy link
Owner

@AndyMik90 AndyMik90 left a comment

Choose a reason for hiding this comment

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

🤖 Auto Claude PR Review

Merge Verdict: 🟠 NEEDS REVISION

🟠 Needs revision - 4 issue(s) require attention.

Branch is out of date with base branch. Update branch first - if no conflicts arise, you can merge. If merge conflicts arise, resolve them and run follow-up review again. 4 issue(s) must be addressed (0 required, 4 recommended). 1 non-blocking suggestion(s) to consider.

Risk Assessment

Factor Level Notes
Complexity Low Based on lines changed
Security Impact None Based on security findings
Scope Coherence Good Based on structural review

🚨 Blocking Issues (Must Fix)

  • Branch Out of Date: PR branch is behind the base branch and needs to be updated

Findings Summary

  • Medium: 4 issue(s)
  • Low: 1 issue(s)

Generated by Auto Claude PR Review

Findings (5 selected of 5 total)

🟡 [633f40874417] [MEDIUM] [Potential] Null element causes TypeError in recommendations_for_next_session mapping

📁 apps/frontend/src/renderer/components/context/MemoryCard.tsx:264

The type check typeof item === 'string' ? item : (item as { recommendation?: string }).recommendation fails when item is null because typeof null === 'object' in JavaScript. If the JSON data contains null in the array, accessing null.recommendation throws TypeError. The data source is JSON.parse() at line 49 which can contain null array elements.

Suggested fix:

Use optional chaining: `const text = typeof item === 'string' ? item : item?.recommendation;`

🟡 [20ffdad1fc32] [MEDIUM] [Potential] Null element causes TypeError in discoveries.recommendations mapping

📁 apps/frontend/src/renderer/components/context/MemoryCard.tsx:268

Same null vulnerability pattern as finding-1. When item is null, typeof null === 'object' evaluates true, so the code tries (null as { recommendation?: string }).recommendation which throws TypeError.

Suggested fix:

Use optional chaining: `const text = typeof item === 'string' ? item : item?.recommendation;`

🟡 [185e61c03997] [MEDIUM] [Potential] Null element causes TypeError in patterns_discovered mapping

📁 apps/frontend/src/renderer/components/context/MemoryCard.tsx:281

The pattern typeof pattern === 'string' ? pattern : pattern.pattern fails when pattern is null because typeof null === 'object' and null.pattern throws TypeError.

Suggested fix:

Use optional chaining: `const text = typeof pattern === 'string' ? pattern : pattern?.pattern;`

🟡 [dc8b7f7935ff] [MEDIUM] [Potential] Null element causes TypeError in gotchas_discovered mapping

📁 apps/frontend/src/renderer/components/context/MemoryCard.tsx:298

The pattern typeof gotcha === 'string' ? gotcha : gotcha.gotcha fails when gotcha is null because typeof null === 'object' and null.gotcha throws TypeError.

Suggested fix:

Use optional chaining: `const text = typeof gotcha === 'string' ? gotcha : gotcha?.gotcha;`

🔵 [083fee1129cd] [LOW] [Potential] Duplicated recommendation text extraction logic

📁 apps/frontend/src/renderer/components/context/MemoryCard.tsx:263

The exact same logic for extracting text from mixed-type recommendation arrays appears twice in adjacent code blocks. Both use typeof item === 'string' ? item : (item as { recommendation?: string }).recommendation. This violates DRY but is a minor concern since the duplication is localized.

Suggested fix:

Extract a helper function: `function getRecommendationText(item) { return typeof item === 'string' ? item : item?.recommendation; }`

This review was generated by Auto Claude.

@mateuszruszkowski mateuszruszkowski force-pushed the fix/memorycard-rendering-v2 branch from 2e066f4 to bab8d12 Compare January 20, 2026 21:56
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

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

⚠️ Outside diff range comments (1)
apps/frontend/src/renderer/components/context/MemoryCard.tsx (1)

361-366: Fallback block is unreachable.

Same issue as in PRReviewCard: the expand button (line 179) only renders when hasContent is true. Therefore, expanded can never become true when !hasContent. The !parsed case is also unreachable here because hasContent returns false when !parsed (line 115), which means no button is shown.

The fallback at lines 113-128 for non-parseable content (when !parsed) already handles the no-content case by not showing an expand button at all. Consider removing this unreachable block or adjusting the button visibility to allow raw JSON viewing.

🔧 Suggested fix: Remove unreachable fallback
          </div>
        )}

-        {/* Fallback for unparseable content or empty parsed content */}
-        {expanded && (!parsed || !hasContent) && (
-          <pre className="mt-4 text-xs text-muted-foreground whitespace-pre-wrap font-mono p-3 bg-background rounded-lg max-h-64 overflow-auto border border-border/50">
-            {memory.content}
-          </pre>
-        )}
       </CardContent>
🤖 Fix all issues with AI agents
In `@apps/frontend/src/renderer/components/context/PRReviewCard.tsx`:
- Around line 317-322: The JSX fallback rendering block that shows
memory.content when expanded && !hasExpandableContent is unreachable because the
expand button (which toggles expanded) is only rendered when
hasExpandableContent is true; remove the entire fallback fragment to avoid dead
code, and if you want to keep intent, replace it with a short comment in
PRReviewCard noting the previous fallback behavior; reference the expanded and
hasExpandableContent variables and the expand button logic (around the current
expand button rendering) when updating the component.
♻️ Duplicate comments (1)
apps/frontend/src/renderer/components/context/MemoryCard.tsx (1)

263-270: Clean implementation handling polymorphic recommendation items.

The type narrowing via typeof item === 'string' correctly handles both string and object recommendation formats without needing type assertions. This addresses the previous review feedback.

mateuszruszkowski added a commit to mateuszruszkowski/Auto-Claude that referenced this pull request Jan 21, 2026
- Extract `getRecommendationText` helper function to eliminate duplicated
  logic for rendering recommendation items from both
  `recommendations_for_next_session` and `discoveries.recommendations`
- Add `RecommendationItem` type alias for cleaner type definitions
- Remove unreachable fallback code in PRReviewCard that could never be
  reached because the expand button only renders when hasExpandableContent
  is true

Addresses CodeRabbit review comments in PR AndyMik90#1374.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@mateuszruszkowski mateuszruszkowski force-pushed the fix/memorycard-rendering-v2 branch from 4ebdb87 to 489c859 Compare January 21, 2026 12:48
@AndyMik90 AndyMik90 force-pushed the develop branch 2 times, most recently from 67a743f to e83e445 Compare January 21, 2026 14:26
mateuszruszkowski and others added 3 commits January 21, 2026 16:35
Fixes two issues when expanding memory items:

1. Black screen when expanding memories with no displayable content
   - Added hasContent/hasExpandableContent guards before rendering
   - Show raw JSON fallback when parsed but no sections available

2. React error "Objects are not valid as a React child"
   - Recommendations can be objects {category, recommendation, priority, effort}
   - Now extracts text properly from both string and object formats
   - Updated TypeScript interfaces to reflect actual data shape

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Remove unnecessary type assertions in recommendation mapping.
TypeScript can infer the type from typeof narrowing.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Remove dead code block that could never execute:
- The expand button only renders when hasExpandableContent is true
- Therefore expanded && !hasExpandableContent is always false

Addresses: coderabbitai review comment about unreachable code

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@mateuszruszkowski mateuszruszkowski force-pushed the fix/memorycard-rendering-v2 branch from 489c859 to d955e45 Compare January 21, 2026 15:35
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

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

⚠️ Outside diff range comments (1)
apps/frontend/src/renderer/components/context/MemoryCard.tsx (1)

114-127: hasContent is missing a check for discoveries.recommendations.

The hasContent check doesn't include discoveries.recommendations, but this array is rendered at lines 267-270. If discoveries.recommendations has items but all other fields are empty, hasContent will be false, hiding the expand button and preventing users from seeing those recommendations.

🐛 Proposed fix
   const hasContent = useMemo(() => {
     if (!parsed) return false;
     const d = parsed.discoveries || {};
     return (
       (parsed.what_worked?.length ?? 0) > 0 ||
       (parsed.what_failed?.length ?? 0) > 0 ||
       (parsed.recommendations_for_next_session?.length ?? 0) > 0 ||
       (d.patterns_discovered?.length ?? 0) > 0 ||
       (d.gotchas_discovered?.length ?? 0) > 0 ||
       (d.file_insights?.length ?? 0) > 0 ||
       (d.changed_files?.length ?? 0) > 0 ||
+      (d.recommendations?.length ?? 0) > 0 ||
       d.approach_outcome?.approach_used
     );
   }, [parsed]);

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.

2 participants