Repository navigation
Redesign the Reports tab: stat cards, hours by day and CSV export (ALI-2618) - #17
Conversation
…I-2618) The Reports tab now draws from internal/report, the code behind `notch report`, so for the same range its numbers match `notch report -json` (a test compares the two as JSON for every preset). It no longer uses db.ReportByProject, so it reads start dates in local time like the CLI. The screen follows the canvas's Reports board: - Range chips (t Today, w Week, m Month, y Year, a All, f Custom…) with the dates beside them. f opens a Custom range modal (From, To, Apply, Cancel) with field errors; a blank date leaves that side open. - Four stat cards: hours and entries, earned and the average rate, outstanding (invoiced, not paid) and unbilled. - BY DAY: block-character bars in eighth blocks, each with its day and hours written under it; today's bar is in success and its day bold. This week runs on to Sunday. Ranges with more days than fit show a bar per week, month or year. - BY CLIENT AND PROJECT: clients with their projects nested under them, with hours, invoiced and paid counts and earned, and a total. At 120 columns and up the bars sit beside the table; narrower terminals stack them with shorter bars and compact cards, and drop the bars before the table gets fewer than three rows. e exports the range's entries with report.WriteCSV to the XDG download folder (else ~/Downloads, else home), named for the range, adding " (2)", " (3)"… rather than overwriting. The status line shows the path. enter opens the entries behind a client or project row, where e edits an entry as before. New layout tokens: tui-card-gap, tui-bar-width, tui-bar-gap, tui-bar-rows, tui-bar-rows-compact, tui-report-col-hours, tui-report-col-count, tui-report-col-earned, tui-report-trail and tui-report-indent. The keys sheet and README cover the new keys.
Review round 1A fresh reviewer ran
Sent for fixing. Each finding is checked against the code first, and any that isn't a bug is reported back.
Round 2 also covers what round 1 didn't check: the Week preset's date and timezone edges, bar grouping, and narrow-terminal layout. |
- Presets follow the clock: each reload works out today, this week, this month or this year again, so a tab left open past midnight or into a new month shows (and exports) the current range. Custom ranges stay put. - The table cursor and the entries list follow their row by client and project ID, and the entries cursor its entry by ID, across reloads. When the list's row leaves the report, the list closes and the status line says so; an open edit form closes to the report. - A database change from another process (dbWatch, and the fallback tick) reloads the Reports tab as well as Timers. - CSV exports are created 0600, and a download folder that can't be written to falls through to the next (~/Downloads, then home). user-dirs.dirs values in single quotes, unquoted, after export, or followed by a comment now parse. - An entry gone before its edit form opens says so on the status line; the old message was never shown. - Amounts are never cut: cards, the table and the entries list drop the cents, then go compact ($123k, $1.2M), with the same fitMoney and fitRate as the Clients tab in ALI-2617 (in money.go, to merge into one copy). Hours too wide show as whole hours. - Layout counts come from what's drawn (card lines, the table's fixed lines, entry columns from their widest values and the cell padding), and two new tokens: tui-card-pad and tui-report-min-rows.
Stacks the Reports redesign (ALI-2618) on the Clients tab (ALI-2617). - Tabs are 1 Timers, 2 Clients, 3 Reports; the Reports tests that pressed 4 press 3. - dbWatch and the fallback tick reload Timers, Clients and Reports. - tokens.json and design/build carry both PRs' tokens; tui-min-width's note keeps both measurements. The generated files are regenerated. - The keys sheet has the Clients and Reports groups. - One copy of fitMoney, fitRate, wholeMoney and compactMoney, in money.go; clients.go's copy is gone. - The README's feature list, keys and file list, and the landing page's Reports card, cover both tabs.
…-2618) The Clients tab (ALI-2617) has its own moneyOrDash(x, rate, w), so the Reports one, which shows an amount in full or a dash, is amountOrDash.
Tab 4 no longer exists after the Clients fold, so pressing 4 did nothing and that iteration tested nothing.
Review round 2 (final, narrow)5ec09c1 fixed round 1's findings:
All seven were confirmed as real bugs before fixing. Stacked on #16. 12e223f merges #16's branch in, and aff033d fixes a helper-name clash from that merge. The result:
The review. A fresh reviewer checked these commits. Its
Nothing was found at P1 or P2. P3 fixed in 9a4864a: During round 1's fail-without-fix checks, one test briefly exported into the real The review stops here. Merge #16 first; GitHub then retargets this PR to main. |
…I-2618) (#17) (#18) * Redesign the Reports tab: stat cards, hours by day and CSV export (ALI-2618) The Reports tab now draws from internal/report, the code behind `notch report`, so for the same range its numbers match `notch report -json` (a test compares the two as JSON for every preset). It no longer uses db.ReportByProject, so it reads start dates in local time like the CLI. The screen follows the canvas's Reports board: - Range chips (t Today, w Week, m Month, y Year, a All, f Custom…) with the dates beside them. f opens a Custom range modal (From, To, Apply, Cancel) with field errors; a blank date leaves that side open. - Four stat cards: hours and entries, earned and the average rate, outstanding (invoiced, not paid) and unbilled. - BY DAY: block-character bars in eighth blocks, each with its day and hours written under it; today's bar is in success and its day bold. This week runs on to Sunday. Ranges with more days than fit show a bar per week, month or year. - BY CLIENT AND PROJECT: clients with their projects nested under them, with hours, invoiced and paid counts and earned, and a total. At 120 columns and up the bars sit beside the table; narrower terminals stack them with shorter bars and compact cards, and drop the bars before the table gets fewer than three rows. e exports the range's entries with report.WriteCSV to the XDG download folder (else ~/Downloads, else home), named for the range, adding " (2)", " (3)"… rather than overwriting. The status line shows the path. enter opens the entries behind a client or project row, where e edits an entry as before. New layout tokens: tui-card-gap, tui-bar-width, tui-bar-gap, tui-bar-rows, tui-bar-rows-compact, tui-report-col-hours, tui-report-col-count, tui-report-col-earned, tui-report-trail and tui-report-indent. The keys sheet and README cover the new keys. * Reports review fixes (ALI-2618) - Presets follow the clock: each reload works out today, this week, this month or this year again, so a tab left open past midnight or into a new month shows (and exports) the current range. Custom ranges stay put. - The table cursor and the entries list follow their row by client and project ID, and the entries cursor its entry by ID, across reloads. When the list's row leaves the report, the list closes and the status line says so; an open edit form closes to the report. - A database change from another process (dbWatch, and the fallback tick) reloads the Reports tab as well as Timers. - CSV exports are created 0600, and a download folder that can't be written to falls through to the next (~/Downloads, then home). user-dirs.dirs values in single quotes, unquoted, after export, or followed by a comment now parse. - An entry gone before its edit form opens says so on the status line; the old message was never shown. - Amounts are never cut: cards, the table and the entries list drop the cents, then go compact ($123k, $1.2M), with the same fitMoney and fitRate as the Clients tab in ALI-2617 (in money.go, to merge into one copy). Hours too wide show as whole hours. - Layout counts come from what's drawn (card lines, the table's fixed lines, entry columns from their widest values and the cell padding), and two new tokens: tui-card-pad and tui-report-min-rows. * Rename the Reports entries header's amountOrDash after the merge (ALI-2618) The Clients tab (ALI-2617) has its own moneyOrDash(x, rate, w), so the Reports one, which shows an amount in full or a dash, is amountOrDash. * Drop the removed fourth tab from the tab-switch test Tab 4 no longer exists after the Clients fold, so pressing 4 did nothing and that iteration tested nothing.
Fixes ALI-2618
Stacked on #16: merge #16 first; GitHub then retargets this to main.
What changed
The Reports tab is redrawn from the canvas's Reports board (140×40) and computes everything with
internal/report, the code behindnotch report. It no longer usesdb.ReportByProject, so it reads start dates in local time, like the CLI.tToday,wWeek,mMonth,yYear,aAll,fCustom…, with the range's dates beside them.fopens a Custom range modal (the shared form modal from Modal forms with field errors, delete confirm and the keys sheet (ALI-2616) #15): From, To, Apply, Cancel, with errors under their fields. A blank date leaves that side open.report.Report.eexports CSV withreport.WriteCSV(the same rows asnotch report --csv) toXDG_DOWNLOAD_DIR(from the environment oruser-dirs.dirs), else~/Downloads, else home. The file is named for the range, such asnotch-2026-11-30-to-2026-12-03.csv. A taken name gets(2),(3)… (opened withO_EXCL), so an export never overwrites. The file is created 0600, and a folder it can't write to falls through to the next. The status line shows the path. An empty range says there's nothing to export.$123k,$1.2M), with the samefitMoney/fitRateas the Clients tab in Fold Projects into a Clients master-detail tab (ALI-2617) #16. Since the merge with Fold Projects into a Clients master-detail tab (ALI-2617) #16 there's one copy, ininternal/ui/views/money.go.ethere edits an entry, as before.qtypes and onlyctrl+cquits. The keys sheet's Reports group and the README cover the new keys, and the sheet still fits at 90×32.tui-card-gap,tui-bar-width,tui-bar-gap,tui-bar-rows,tui-bar-rows-compact,tui-report-col-hours,tui-report-col-count,tui-report-col-earned,tui-report-trail,tui-report-indent. No new colours. Every pair used is already in the contrast table, anddesign/build -checkpasses.Differences from the board
t Today), as the Timers tab does, becauseyandadon't fit on the hotkey line.▌cursor, so names start one cell further right than on the board. NAME takes the spare width instead of EARNED.Tests
gofmt -l .is empty, andgo vet ./...,go test -count=1 ./...andgo run ./design/build -checkpass.internal/ui/views/reports_test.gocover:report.Preset, and the custom modal's errors,qtyping and blank sides;report.Buildon the CLI's entry list, as JSON, for every preset;report.WriteCSVand not overwriting;eto edit.TestRenderReportsSampleininternal/uichecks the full frame at 140×40 and 90×32, with and without the modal.O_TRUNCinstead ofO_EXCL, and Enter doing nothing.Try live
t w m y a. Compare the cards and table withnotch report -json --range week.f, try a bad date, a To before From, and blank dates.e, check the file in your downloads folder, then presseagain to get(2).