Skip to content

Shorten temp directory#17901

Merged
joshualitt merged 3 commits intomainfrom
jl/short-temp
Feb 6, 2026
Merged

Shorten temp directory#17901
joshualitt merged 3 commits intomainfrom
jl/short-temp

Conversation

@joshualitt
Copy link
Contributor

Fixes #17190

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @joshualitt, 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 significantly improves the readability and manageability of temporary and history directories by transitioning from long, opaque cryptographic hashes to short, human-readable project slugs. It introduces a new registry system to manage these project identifiers and includes a robust migration mechanism to ensure a smooth transition for existing user data. The change aims to enhance the overall user experience by simplifying file paths and making them easier to understand and interact with.

Highlights

  • Project Registry Introduction: Introduced a new ProjectRegistry class responsible for mapping absolute project paths to short, unique, and human-readable identifiers (slugs). This registry persists its data to ensure consistent slugs across sessions.
  • Temporary Directory Naming Convention: Replaced the use of long cryptographic hashes with the newly generated short project slugs for naming temporary and history directories. This change makes these directory paths significantly shorter and more user-friendly.
  • Storage Migration Utility: Implemented a StorageMigration utility to gracefully handle the transition from the old hash-based directory structure to the new slug-based one. This ensures that existing temporary and history data is moved to the new locations without loss.
  • Integration Across Core Modules: Updated the Storage, Logger, ToolExecutor, and GitService modules to integrate with the new ProjectRegistry and utilize the slug-based paths for temporary and history directories, ensuring consistent behavior throughout the application.
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.

@gemini-cli gemini-cli bot added area/core Issues related to User Interface, OS Support, Core Functionality 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item. labels Jan 29, 2026
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 introduces a well-structured change to replace hash-based temporary directory names with shorter, human-readable slugs by using a new ProjectRegistry. It also includes a StorageMigration utility for migrating existing data. While the overall approach is sound, I've identified two critical issues that need to be addressed. Firstly, an important test case related to the application's interactive startup performance has been removed, creating a risk of future regressions. Secondly, the data migration logic is not robust enough to handle moves across different filesystems and uses synchronous file operations, which could lead to silent migration failures and a user experience that resembles data loss. These issues should be fixed before merging.

I am having trouble creating individual review comments. Click here to see my feedback.

packages/core/src/config/config.test.ts (309-337)

critical

This test, which verifies that MCP server initialization is not awaited in interactive mode, has been removed. However, the corresponding logic still exists in the Config.initialize() method. Removing this test is dangerous as it increases the risk of future regressions that could negatively impact the startup performance of the interactive CLI. The test should be restored to ensure this behavior remains covered.

packages/core/src/config/storageMigration.ts (20-38)

critical

The use of fs.renameSync for directory migration is not robust and blocks the event loop. It will fail with an EXDEV error if the source and destination paths are on different filesystems or devices (e.g., moving from /tmp to a mounted home directory on another partition). The current implementation catches this error but only logs it at the debug level, failing the migration silently.

This is critical because the application will proceed to use the new, empty directory path, making it appear to the user that their data (like command history) has been lost.

A more robust implementation should use asynchronous file system operations and handle the EXDEV error by falling back to a recursive copy-and-delete operation to ensure the migration succeeds across different devices.

References
  1. Use asynchronous file system operations (e.g., fs.promises.readFile) instead of synchronous ones (e.g., fs.readFileSync) to avoid blocking the event loop.

@github-actions
Copy link

github-actions bot commented Jan 29, 2026

Size Change: +37.9 kB (+0.16%)

Total Size: 23.8 MB

Filename Size Change
./bundle/gemini.js 23.8 MB +37.9 kB (+0.16%)
ℹ️ View Unchanged
Filename Size
./bundle/sandbox-macos-permissive-closed.sb 1.03 kB
./bundle/sandbox-macos-permissive-open.sb 890 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB
./bundle/sandbox-macos-restrictive-closed.sb 3.29 kB
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB

compressed-size-action

@joshualitt joshualitt requested a review from jacob314 January 30, 2026 01:14
@joshualitt joshualitt marked this pull request as ready for review January 30, 2026 01:15
@joshualitt joshualitt requested a review from a team as a code owner January 30, 2026 01:15
Copy link
Contributor

@alisa-alisa alisa-alisa left a comment

Choose a reason for hiding this comment

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

Small comment added

@joshualitt joshualitt force-pushed the jl/short-temp branch 5 times, most recently from 0ad8fff to 43da341 Compare February 3, 2026 18:46
@alisa-alisa
Copy link
Contributor

/gemini review

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 introduces a robust system for creating human-readable temporary directory names by replacing the old hash-based approach with a new slug-based ProjectRegistry. The implementation is comprehensive, covering persistence, collision handling, and self-healing mechanisms. It also includes a one-time migration for existing users. The changes are well-tested. My review includes two high-severity suggestions, aligned with repository guidelines: one to address an inefficient busy-wait loop in the file locking mechanism, and another to ensure that storage migration failures are not silent, preventing potential user confusion and ensuring detailed error logging.

@jacob314
Copy link
Contributor

jacob314 commented Feb 3, 2026

Review from /review-frontend (Audited by Jacob Richman)

Critical Findings

  1. Blocking Busy-Wait in Locking Mechanism: ProjectRegistry.acquireLock implements a synchronous while loop for retries (LOCK_RETRY_DELAY_MS). This blocks the Node.js event loop during lock contention. In a multi-process environment, this could cause significant performance degradation and UI stuttering.

  2. Synchronous I/O in React Rendering Path: Storage.getProjectTempDir() is now lazily initialized and performs synchronous file I/O and migration. Since this is called from React components (e.g., SessionBrowser.tsx, chatCommand.ts), any delay or lock timeout (up to 10s) will hang the terminal UI. Consider performing this initialization outside of the render cycle.

  3. Silent Migration Failures: StorageMigration.migrateDirectory silently swallows errors, logging only to debugLogger.debug. If a migration fails (e.g., due to permissions), users may lose access to their history or sessions without notice. Please use coreEvents.emitFeedback to surface these errors to the user.

Testing & Code Quality

  1. Test Pollution: packages/core/src/config/projectRegistry.test.ts is missing vi.restoreAllMocks() in its afterEach block. This can lead to flaky tests if subsequent tests depend on the global Date or fs state.

  2. Manual Date Mocking: In projectRegistry.test.ts, vi.stubGlobal('Date', ...) is used to simulate time passing. Please use the standard vi.useFakeTimers() and vi.setSystemTime() for more robust and idiomatic time-based testing.

  3. Avoid any in Tests: packages/cli/src/gemini_cleanup.test.tsx uses as any several times to satisfy TypeScript. Please use unknown with narrowing or more specific types to maintain type safety even in test code.

@joshualitt joshualitt requested a review from a team as a code owner February 4, 2026 05:01
@joshualitt joshualitt force-pushed the jl/short-temp branch 2 times, most recently from 6e941aa to 89a1add Compare February 4, 2026 15:47
@joshualitt joshualitt requested a review from jacob314 February 4, 2026 18:49
Copy link
Contributor

@jacob314 jacob314 left a comment

Choose a reason for hiding this comment

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

lgtm

@joshualitt joshualitt added this pull request to the merge queue Feb 6, 2026
Merged via the queue into main with commit 6fb3b09 Feb 6, 2026
26 checks passed
@joshualitt joshualitt deleted the jl/short-temp branch February 6, 2026 16:17
aswinashok44 pushed a commit to aswinashok44/gemini-cli that referenced this pull request Feb 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Issues related to User Interface, OS Support, Core Functionality 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Shell Redirection #5] Shorten temp directory

3 participants