Skip to content

persist last opened tab#1898

Merged
simo6529 merged 1 commit intomainfrom
persist-last-opened-tab-in-memes-chat
Feb 5, 2026
Merged

persist last opened tab#1898
simo6529 merged 1 commit intomainfrom
persist-last-opened-tab-in-memes-chat

Conversation

@simo6529
Copy link
Copy Markdown
Collaborator

@simo6529 simo6529 commented Feb 5, 2026

Summary by CodeRabbit

  • Tests

    • Expanded test coverage for tab context behavior, including wave-specific scenarios and preference restoration.
  • Improvements

    • Tab preferences are now saved and restored per-wave instead of globally.
    • Refined default tab selection behavior for different wave types.

Signed-off-by: Simo <simo@6529.io>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 5, 2026

📝 Walkthrough

Walkthrough

The changes refactor ContentTabContext to implement per-wave tab persistence instead of global tracking. Available tabs are computed based on wave type and voting state, with the last-active tab restored per wave when switching contexts. Test coverage expands to validate default tab selection, restoration, and fallback behaviors.

Changes

Cohort / File(s) Summary
Test Enhancements
__tests__/components/brain/ContentTabContext.test.tsx
Adds 9+ new test cases covering per-wave tab defaults (LEADERBOARD for memes, CHAT for others), tab restoration from storage, and fallback behavior. Updates existing tests to pass waveId to updateAvailableTabs, changing tab availability based on wave context. Standardizes formatting to double quotes.
Context State Management
components/brain/ContentTabContext.tsx
Introduces per-wave tab persistence via tabsByWaveId map stored under MEMES_WAVE_LAST_TAB_STORAGE_KEY. Replaces global lastWaveIdRef with currentWaveIdRef and per-wave tracking. Adds validation (isValidWaveTab, isValidWaveTabMap) and tab construction helpers (buildMemesTabs, buildDefaultTabs). Refines updateAvailableTabs to compute tabs based on wave type/voting state and select default tabs from per-wave storage or computed defaults. Enhances setActiveContentTab with validation and per-wave storage. Adds useEffect hooks for ref synchronization.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

  • Issue #1891: Both changes implement per-wave persistence of the last-opened tab for memes waves and restore it when switching wave contexts.

Possibly related PRs

  • PR #1869: Both PRs refactor ContentTabContext to introduce waveId-aware tab selection logic and modify default tab behavior based on wave type.

Suggested reviewers

  • prxt6529
  • ragnep

Poem

🐰 Per-wave tabs now dance with glee,
Each memory stored, persistent and free,
From memes to chat, the context will know,
Which tab you loved, wherever you go! ✨

🚥 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 'persist last opened tab' directly and accurately summarizes the main change: introducing per-wave tab persistence to remember the last active tab for each wave.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch persist-last-opened-tab-in-memes-chat

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.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Feb 5, 2026

@simo6529 simo6529 merged commit ccbc139 into main Feb 5, 2026
7 checks passed
@simo6529 simo6529 deleted the persist-last-opened-tab-in-memes-chat branch February 5, 2026 15:57
@coderabbitai coderabbitai Bot mentioned this pull request Mar 12, 2026
This was referenced Apr 8, 2026
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