fix: show available sessions for invalid --resume identifiers#21797
fix: show available sessions for invalid --resume identifiers#21797sonwr wants to merge 1 commit intogoogle-gemini:mainfrom
Conversation
Summary of ChangesHello, 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 user experience of the Highlights
Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request introduces a helpful usability improvement by showing available sessions on an invalid --resume identifier. The implementation is clean and well-tested. I've identified a minor bug where the error message can show duplicated text when the session list is truncated, and I've provided suggestions to fix this in both the implementation and the corresponding test.
|
|
||
| if (sessions.length > visibleSessions.length) { | ||
| lines.push( | ||
| ` ...and ${sessions.length - visibleSessions.length} more. Run --list-sessions to see the full list.`, |
There was a problem hiding this comment.
This line introduces a small bug where the error message can contain duplicated text. The phrase Run --list-sessions to see the full list. is added here, but it's also part of the main error message template in invalidSessionIdentifier. When the session list is truncated, the user will see this instruction twice.
To fix this, this line should only mention the count of remaining sessions. The instruction to run --list-sessions will still be present once in the final error message.
| ` ...and ${sessions.length - visibleSessions.length} more. Run --list-sessions to see the full list.`, | |
| ` ...and ${sessions.length - visibleSessions.length} more.`, |
References
- Avoid displaying verbose validation descriptions directly to the user if they contain concatenated links or other unnecessary information. Instead, use a concise, generic message. This comment addresses duplicated text in an error message, making it more concise.
| expect((error as SessionError).message).toContain( | ||
| '...and 2 more. Run --list-sessions to see the full list.', | ||
| ); |
There was a problem hiding this comment.
Following the suggested change to avoid duplicated text in the error message, this test assertion should be updated. Instead of checking for the combined sentence, it's better to check for the truncation message (...and 2 more.) and the general instruction (Run --list-sessions...) separately to ensure both are present and the output is correct.
| expect((error as SessionError).message).toContain( | |
| '...and 2 more. Run --list-sessions to see the full list.', | |
| ); | |
| expect((error as SessionError).message).toContain('...and 2 more.'); | |
| expect((error as SessionError).message).toContain( | |
| 'Run --list-sessions to see the full list.', | |
| ); |
References
- Avoid displaying verbose validation descriptions directly to the user if they contain concatenated links or other unnecessary information. Instead, use a concise, generic message. This test change reflects the application of this rule to the error message.
|
Going to close this. The author of the original issue has a PR and they are the one assigned to the issue. Will work on accepting their PR 👍 |
When
gemini --resume <id>receives an invalid identifier, the CLI already has the matching project sessions in memory but only tells the user to run--list-sessions.This change includes a compact list of available sessions directly in the error output so the user can immediately retry with a valid index or UUID.
What changed
--list-sessionsfor the full listTesting
npx vitest run packages/cli/src/utils/sessionUtils.test.ts packages/cli/src/gemini.test.tsxFixes #21764