Skip to content

Commit c67291c

Browse files
authored
Merge pull request #220 from shelltime/claude/add-statusline-profile-link-DqZlk
Make AI agent time clickable link to user profile
2 parents 763e116 + dfe5346 commit c67291c

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

commands/cc_statusline.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,13 @@ func formatStatuslineOutput(modelName string, sessionCost, dailyCost float64, se
167167
// Quota utilization
168168
parts = append(parts, formatQuotaPart(fiveHourUtil, sevenDayUtil))
169169

170-
// AI agent time (magenta)
170+
// AI agent time (magenta) - clickable link to user profile
171171
if sessionSeconds > 0 {
172172
timeStr := color.Magenta.Sprintf("⏱️ %s", formatSessionDuration(sessionSeconds))
173+
if userLogin != "" && webEndpoint != "" {
174+
url := fmt.Sprintf("%s/users/%s", webEndpoint, userLogin)
175+
timeStr = wrapOSC8Link(url, timeStr)
176+
}
173177
parts = append(parts, timeStr)
174178
} else {
175179
parts = append(parts, color.Gray.Sprint("⏱️ -"))

commands/cc_statusline_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,27 @@ func (s *CCStatuslineTestSuite) TestFormatStatuslineOutput_SessionCostWithoutLin
354354
assert.NotContains(s.T(), output, "coding-agent/session/")
355355
}
356356

357+
func (s *CCStatuslineTestSuite) TestFormatStatuslineOutput_TimeWithProfileLink() {
358+
output := formatStatuslineOutput("claude-opus-4", 1.23, 4.56, 3661, 75.0, "main", false, nil, nil, "testuser", "https://shelltime.xyz", "session-abc123")
359+
360+
// Should contain OSC8 link wrapping time section to user profile
361+
assert.Contains(s.T(), output, "shelltime.xyz/users/testuser")
362+
assert.Contains(s.T(), output, "1h1m")
363+
}
364+
365+
func (s *CCStatuslineTestSuite) TestFormatStatuslineOutput_TimeWithoutProfileLink() {
366+
// No userLogin - should not have profile link on time
367+
output := formatStatuslineOutput("claude-opus-4", 1.23, 4.56, 3661, 75.0, "main", false, nil, nil, "", "https://shelltime.xyz", "session-abc123")
368+
assert.Contains(s.T(), output, "1h1m")
369+
// The time section should not contain a link to users/ profile
370+
// Count occurrences of "shelltime.xyz/users/" - should only be in session cost and daily cost links
371+
assert.NotContains(s.T(), output, "shelltime.xyz/users//")
372+
373+
// No webEndpoint - should not have profile link on time
374+
output = formatStatuslineOutput("claude-opus-4", 1.23, 4.56, 3661, 75.0, "main", false, nil, nil, "testuser", "", "session-abc123")
375+
assert.Contains(s.T(), output, "1h1m")
376+
}
377+
357378
func (s *CCStatuslineTestSuite) TestFormatStatuslineOutput_WithQuota() {
358379
fh := 45.0
359380
sd := 23.0

0 commit comments

Comments
 (0)