Make AI agent time clickable link to user profile#220
Conversation
Wrap the ⏱️ time section with an OSC8 link to the user's profile page
at {webEndpoint}/users/{userLogin}, allowing users to click the time
display to view their status on shelltime.xyz.
https://claude.ai/code/session_01GihLQR12WQ9guABhJT59ts
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Summary of ChangesHello @AnnatarHe, 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 enhances the user experience by making the AI agent session time in the statusline interactive. Users can now directly access their profile page by clicking on the session time, provided the necessary user and endpoint information is present. This change improves navigation and accessibility within the application. 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 enhances the statusline by making the AI agent session time a clickable link to the user's profile. The changes are well-contained and include corresponding tests. My review focuses on improving the robustness of the URL construction to prevent potential malformed links and on strengthening the new test cases to ensure they are more precise and cover all relevant scenarios.
| if sessionSeconds > 0 { | ||
| timeStr := color.Magenta.Sprintf("⏱️ %s", formatSessionDuration(sessionSeconds)) | ||
| if userLogin != "" && webEndpoint != "" { | ||
| url := fmt.Sprintf("%s/users/%s", webEndpoint, userLogin) |
There was a problem hiding this comment.
To prevent potential issues with double slashes in the generated URL if webEndpoint has a trailing slash, it's safer to normalize it before formatting the string. Using strings.TrimSuffix will ensure the URL is always correctly formed.
This would be a good improvement for the other URL constructions in this function as well for consistency.
| url := fmt.Sprintf("%s/users/%s", webEndpoint, userLogin) | |
| url := fmt.Sprintf("%s/users/%s", strings.TrimSuffix(webEndpoint, "/"), userLogin) |
| // The time section should not contain a link to users/ profile | ||
| // Count occurrences of "shelltime.xyz/users/" - should only be in session cost and daily cost links | ||
| assert.NotContains(s.T(), output, "shelltime.xyz/users//") |
There was a problem hiding this comment.
The comment on line 370 is misleading because when userLogin is empty, no user-specific links (including for session and daily cost) should be generated at all. Additionally, the assertion on line 371 is weak as it only checks for a double slash. A more robust test would be to assert that no /users/ path is present in the output, confirming that no user-specific link was created.
| // The time section should not contain a link to users/ profile | |
| // Count occurrences of "shelltime.xyz/users/" - should only be in session cost and daily cost links | |
| assert.NotContains(s.T(), output, "shelltime.xyz/users//") | |
| assert.NotContains(s.T(), output, "shelltime.xyz/users/") |
|
|
||
| // No webEndpoint - should not have profile link on time | ||
| output = formatStatuslineOutput("claude-opus-4", 1.23, 4.56, 3661, 75.0, "main", false, nil, nil, "testuser", "", "session-abc123") | ||
| assert.Contains(s.T(), output, "1h1m") |
There was a problem hiding this comment.
This test case for an empty webEndpoint is missing an assertion to verify that no link is actually generated. To make the test more complete, you should add an assertion to check that the user profile link is not present in the output.
assert.Contains(s.T(), output, "1h1m")
assert.NotContains(s.T(), output, "/users/testuser")
Summary
Enhanced the statusline output to make the AI agent session time display a clickable link to the user's profile page when both user login and web endpoint information are available.
Changes
formatStatuslineOutput()to wrap the session time display with an OSC8 hyperlink to the user's profile page ({webEndpoint}/users/{userLogin})userLoginandwebEndpointparameters are non-emptyTestFormatStatuslineOutput_TimeWithProfileLink: Verifies the profile link is created when both parameters are providedTestFormatStatuslineOutput_TimeWithoutProfileLink: Ensures no malformed links are created when either parameter is missingImplementation Details
wrapOSC8Link()utility function to create terminal-compatible hyperlinkshttps://claude.ai/code/session_01GihLQR12WQ9guABhJT59ts