Skip to content

Commit 7cb3dce

Browse files
Flyrellclaude
andcommitted
refactor: use "(no task)" label for task-less log entries in reports
Log entries without an explicit task were previously displayed using their message text as the task/row name, which was misleading — it conflated the entry message with the grouping key. Now they consistently show "(no task)" so the report clearly distinguishes intentional task labels from untagged entries. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a00df3a commit 7cb3dce

3 files changed

Lines changed: 31 additions & 4 deletions

File tree

internal/timetrack/export_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ func TestBuildExportData_LogEntriesGroupedByTask(t *testing.T) {
3232
assert.Equal(t, 225, day.TotalMinutes) // 60+90+75
3333
assert.Equal(t, 225, data.TotalMinutes)
3434

35-
// Should have 2 groups: "API design research" (no task, uses message) and "feature-auth"
35+
// Should have 2 groups: "(no task)" and "feature-auth"
3636
require.Equal(t, 2, len(day.Groups))
3737

3838
// Groups sorted alphabetically
39-
assert.Equal(t, "API design research", day.Groups[0].Task)
39+
assert.Equal(t, "(no task)", day.Groups[0].Task)
4040
assert.Equal(t, 75, day.Groups[0].TotalMinutes)
4141
assert.Equal(t, 1, len(day.Groups[0].Entries))
4242

internal/timetrack/timetrack.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ func logTaskKey(e entry.Entry) string {
496496
if e.Task != "" {
497497
return e.Task
498498
}
499-
return e.Message
499+
return "(no task)"
500500
}
501501

502502
// daysIn returns the number of days in the given month.

internal/timetrack/timetrack_test.go

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func TestBuildReport_LogTaskKeyFallback(t *testing.T) {
123123
report := BuildReport(nil, logs, nil, days, year, month, afterMonth(year, month), nil)
124124

125125
assert.Equal(t, 1, len(report.Rows))
126-
assert.Equal(t, "did research", report.Rows[0].Name)
126+
assert.Equal(t, "(no task)", report.Rows[0].Name)
127127
assert.Equal(t, 120, report.Rows[0].TotalMinutes)
128128
}
129129

@@ -318,6 +318,33 @@ func TestBuildDetailedReport_LogEntries(t *testing.T) {
318318
assert.True(t, cd.Entries[1].Persisted)
319319
}
320320

321+
func TestBuildDetailedReport_LogTaskKeyFallback(t *testing.T) {
322+
year, month := 2025, time.January
323+
from := time.Date(year, month, 1, 0, 0, 0, 0, time.UTC)
324+
to := time.Date(year, month, 31, 0, 0, 0, 0, time.UTC)
325+
326+
days := []schedule.DaySchedule{workday(year, month, 2)}
327+
328+
logs := []entry.Entry{
329+
{ID: "l1", Start: time.Date(2025, 1, 2, 10, 0, 0, 0, time.UTC), Minutes: 60, Message: "did research", Task: ""},
330+
{ID: "l2", Start: time.Date(2025, 1, 2, 11, 0, 0, 0, time.UTC), Minutes: 60, Message: "wrote docs", Task: ""},
331+
}
332+
333+
report := BuildDetailedReport(nil, logs, nil, days, from, to, afterMonth(year, month))
334+
335+
assert.Equal(t, 1, len(report.Rows))
336+
row := findDetailedRow(report, "(no task)")
337+
assert.NotNil(t, row)
338+
assert.Equal(t, 120, row.TotalMinutes)
339+
340+
cd := row.Days[2]
341+
assert.NotNil(t, cd)
342+
assert.Equal(t, 120, cd.TotalMinutes)
343+
assert.Equal(t, 2, len(cd.Entries))
344+
assert.Equal(t, "did research", cd.Entries[0].Message)
345+
assert.Equal(t, "wrote docs", cd.Entries[1].Message)
346+
}
347+
321348
func TestBuildDetailedReport_CheckoutDeductedByLogs(t *testing.T) {
322349
year, month := 2025, time.January
323350
from := time.Date(year, month, 1, 0, 0, 0, 0, time.UTC)

0 commit comments

Comments
 (0)