Skip to content

Conversation

@webdevcody
Copy link
Collaborator

@webdevcody webdevcody commented Dec 28, 2025

Summary by CodeRabbit

Release Notes

  • New Features
    • Terminal now persists your last active project path across sessions, automatically restoring your project context when reopening the application.

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

@coderabbitai
Copy link

coderabbitai bot commented Dec 28, 2025

📝 Walkthrough

Walkthrough

The changes introduce persistence for tracking the terminal's last active project path by migrating from local ref-based tracking to store-managed state. The implementation adds a lastActiveProjectPath field to TerminalState, provides a setter method, and ensures proper persist/restore handling across session cycles.

Changes

Cohort / File(s) Summary
Store Implementation
apps/ui/src/store/app-store.ts
Added lastActiveProjectPath: string | null property to TerminalState interface; introduced setTerminalLastActiveProjectPath setter in AppActions; initialized property in initialState; updated persist merge logic to restore the field from persisted terminal settings; added migration path to preserve the field during state upgrades.
Terminal Component
apps/ui/src/components/views/terminal-view.tsx
Removed local prevProjectPathRef ref tracking; now reads lastActiveProjectPath from store; calls store setter (setTerminalLastActiveProjectPath) when switching projects; maintains stale restore guards using store-backed path for change detection.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A path once lost in local ground,
Now finds a home where stores abound!
With persistence tucked safely away,
The project path will live to stay.

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ 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 describes the main change: persisting terminal state (specifically the last active project path) when users navigate between projects in the app.
✨ 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-terminals

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f7a0365 and 3a1781e.

📒 Files selected for processing (2)
  • apps/ui/src/components/views/terminal-view.tsx
  • apps/ui/src/store/app-store.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: e2e
🔇 Additional comments (2)
apps/ui/src/store/app-store.ts (1)

347-347: LGTM! Clean integration of terminal path tracking.

The addition of lastActiveProjectPath to the terminal state is well-implemented. The field is properly typed, initialized, preserved during state clearing, and has a straightforward setter. This enables terminal persistence when navigating between routes by storing the project path in the store rather than a local component ref.

Note: This field is stored in runtime state but not persisted to localStorage (not included in partialize). This means it resets on app restart, which appears intentional—the goal is to persist terminals during navigation within a session, not across app restarts.

Also applies to: 820-820, 956-956, 2043-2044, 2129-2134, 2684-2684

apps/ui/src/components/views/terminal-view.tsx (1)

526-551: LGTM! Correct migration from local ref to store-backed tracking.

The migration from prevProjectPathRef to terminalState.lastActiveProjectPath is well-executed. The key improvements:

  1. Survives unmount/remount: Store-backed state persists when navigating away from the terminal route and back, solving the original problem
  2. Correct operation order: The effect properly updates the stored path (line 550) before handling the current project, ensuring the next effect run has the correct prevPath
  3. Fresh snapshots: Using useAppStore.getState() provides current values, avoiding stale closure issues
  4. Edge case handling: When switching to/from null projects, the path updates correctly maintain the comparison logic

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

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @webdevcody, 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 an issue where terminal sessions and their layouts would not persist when users navigated away from the terminal view or switched between different routes within the same project. By refactoring the project path tracking from a local component reference to the global application store, the terminal state is now correctly maintained across component lifecycle events, ensuring a more consistent and robust user experience.

Highlights

  • Terminal Persistence: Terminals and their layouts now persist correctly when navigating away from the terminal view or switching between different routes within the same project, improving user experience.
  • State Management Refactor: The tracking of the last active project path has been moved from a local useRef in TerminalView to a new lastActiveProjectPath field within the global terminalState in app-store.ts.
  • Project Switching Logic Update: The useEffect hook responsible for handling project switching in TerminalView has been updated to leverage the globally managed lastActiveProjectPath, ensuring accurate saving and restoring of terminal layouts.
  • New Store Action: A new action, setTerminalLastActiveProjectPath, has been added to the application store to manage updates to the new lastActiveProjectPath state.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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.

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 successfully implements persistence for terminal sessions when navigating between different views in the application. It achieves this by moving the tracking of the last active project from a local useRef to the global Zustand store, ensuring the state survives component unmounts. The logic for saving and restoring terminal layouts on project switches appears robust, with good handling of edge cases like stale restore operations. The changes to the app store are minimal and correctly support the new persistence logic. I have one minor suggestion in app-store.ts to improve code clarity regarding state hydration.

activeTabId: state.terminalState?.activeTabId ?? null,
activeSessionId: state.terminalState?.activeSessionId ?? null,
maximizedSessionId: state.terminalState?.maximizedSessionId ?? null,
lastActiveProjectPath: state.terminalState?.lastActiveProjectPath ?? null,
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This line appears to attempt restoring lastActiveProjectPath from persisted storage. However, the partialize function (around line 2698) doesn't include terminalState in the data saved to storage, meaning state.terminalState will be undefined during migration. Consequently, lastActiveProjectPath will always initialize to null, which is the correct and intended behavior for this session-only tracking feature. While this line is currently harmless, it could be misleading for future developers. Consider removing it to avoid confusion about what is being persisted.

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