Conversation
Co-authored-by: maorun <2291503+maorun@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
This PR implements a daily overview navigation feature from the weekly overview, allowing users to access detailed daily views for individual days by pressing keys 1-7. The implementation provides comprehensive daily summaries including goal achievement status, work periods with pause calculations, and project/file breakdowns displayed in minutes.
Key Changes
- Added daily overview navigation from weekly overview (keys 1-7 for Monday-Sunday)
- Implemented German-language daily overview interface with goal tracking and time period formatting
- Added comprehensive test coverage for daily summary calculations and UI integration
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| lua/maorun/time/core.lua | Adds getDailySummary() function to calculate detailed daily data including work periods, project hours, and goal achievement |
| lua/maorun/time/ui.lua | Implements daily overview UI with German interface, floating window navigation, and keyboard handlers for 1-7 keys |
| lua/maorun/time/init.lua | Exposes new daily overview functions through the public API |
| test/weekly_overview_spec.lua | Adds 5 comprehensive test cases covering daily summary calculations and UI integration |
lua/maorun/time/ui.lua
Outdated
| table.insert( | ||
| content, | ||
| 'Drücke 1-7 für Tagesübersicht (Mo-So): 1=Mo, 2=Di, 3=Mi, 4=Do, 5=Fr, 6=Sa, 7=So' | ||
| ) |
There was a problem hiding this comment.
Duplicate help text lines are added to the content. Remove the duplicate line 784-787 to avoid displaying the same instruction twice.
| table.insert( | |
| content, | |
| 'Drücke 1-7 für Tagesübersicht (Mo-So): 1=Mo, 2=Di, 3=Mi, 4=Do, 5=Fr, 6=Sa, 7=So' | |
| ) |
lua/maorun/time/ui.lua
Outdated
| string.format( | ||
| '│ Format: %s-%s Uhr Pause: %.1fh %s-%s Uhr │', | ||
| os.date('%H', summary.earliestStart), | ||
| os.date('%H', summary.earliestStart + 4 * 3600), -- Simplified: assume 4h + pause + remaining | ||
| summary.pauseTime, | ||
| os.date('%H', summary.latestEnd - 4 * 3600), | ||
| os.date('%H', summary.latestEnd) | ||
| ) |
There was a problem hiding this comment.
The hardcoded 4-hour assumption in the work period format is overly simplistic and may not represent actual work patterns. Consider calculating actual work periods based on the time entries instead of using a fixed 4-hour split.
| string.format( | |
| '│ Format: %s-%s Uhr Pause: %.1fh %s-%s Uhr │', | |
| os.date('%H', summary.earliestStart), | |
| os.date('%H', summary.earliestStart + 4 * 3600), -- Simplified: assume 4h + pause + remaining | |
| summary.pauseTime, | |
| os.date('%H', summary.latestEnd - 4 * 3600), | |
| os.date('%H', summary.latestEnd) | |
| ) | |
| (function() | |
| -- Try to display actual work periods if available | |
| if summary.workPeriods and #summary.workPeriods == 2 then | |
| local p1 = summary.workPeriods[1] | |
| local p2 = summary.workPeriods[2] | |
| return string.format( | |
| '│ Format: %s-%s Uhr Pause: %.1fh %s-%s Uhr │', | |
| os.date('%H', p1.start), | |
| os.date('%H', p1["end"]), | |
| summary.pauseTime, | |
| os.date('%H', p2.start), | |
| os.date('%H', p2["end"]) | |
| ) | |
| else | |
| -- Fallback: show start, pause, end | |
| return string.format( | |
| '│ Format: %s-%s Uhr Pause: %.1fh %s-%s Uhr │', | |
| os.date('%H', summary.earliestStart), | |
| os.date('%H', summary.earliestStart + ((summary.latestEnd - summary.earliestStart - summary.pauseTime * 3600) / 2)), | |
| summary.pauseTime, | |
| os.date('%H', summary.latestEnd - ((summary.latestEnd - summary.earliestStart - summary.pauseTime * 3600) / 2)), | |
| os.date('%H', summary.latestEnd) | |
| ) | |
| end | |
| end)() |
|
…cumentation Co-authored-by: maorun <2291503+maorun@users.noreply.github.com>
Fixed all three issues in commit 386d3f7:
The new work period algorithm adapts to any work schedule pattern and provides accurate time representations based on actual work data. |
lua/maorun/time/ui.lua
Outdated
| local periods_text = table.concat( | ||
| period_strings, | ||
| ' Pause: ' | ||
| .. string.format('%.1fh', summary.pauseTime / #summary.workPeriods) |
There was a problem hiding this comment.
Division by zero potential when #summary.workPeriods is 0. This could cause a runtime error if summary.workPeriods is an empty table.
| local periods_text = table.concat( | |
| period_strings, | |
| ' Pause: ' | |
| .. string.format('%.1fh', summary.pauseTime / #summary.workPeriods) | |
| local work_period_count = #summary.workPeriods | |
| local pause_per_period = work_period_count > 0 and (summary.pauseTime / work_period_count) or 0 | |
| local periods_text = table.concat( | |
| period_strings, | |
| ' Pause: ' | |
| .. string.format('%.1fh', pause_per_period) |
lua/maorun/time/ui.lua
Outdated
| local period_strings = {} | ||
| for _, period in ipairs(summary.workPeriods) do | ||
| table.insert( | ||
| period_strings, | ||
| string.format( | ||
| '%s-%s Uhr', | ||
| os.date('%H', period.start), | ||
| os.date('%H', period.end_time) | ||
| ) | ||
| ) | ||
| end | ||
|
|
||
| local periods_text = table.concat( | ||
| period_strings, | ||
| ' Pause: ' | ||
| .. string.format('%.1fh', summary.pauseTime / #summary.workPeriods) | ||
| .. ' ' | ||
| ) |
There was a problem hiding this comment.
The condition checks for non-empty workPeriods but the division at line 1763 still assumes #summary.workPeriods > 0. However, this check should prevent the division by zero, but the logic for distributing pause time across periods may not be correct - it divides total pause time by number of periods rather than calculating actual pause time between specific periods.
| local period_strings = {} | |
| for _, period in ipairs(summary.workPeriods) do | |
| table.insert( | |
| period_strings, | |
| string.format( | |
| '%s-%s Uhr', | |
| os.date('%H', period.start), | |
| os.date('%H', period.end_time) | |
| ) | |
| ) | |
| end | |
| local periods_text = table.concat( | |
| period_strings, | |
| ' Pause: ' | |
| .. string.format('%.1fh', summary.pauseTime / #summary.workPeriods) | |
| .. ' ' | |
| ) | |
| -- Sort workPeriods by start time, just in case | |
| table.sort(summary.workPeriods, function(a, b) return a.start < b.start end) | |
| local period_strings = {} | |
| for i, period in ipairs(summary.workPeriods) do | |
| local period_str = string.format( | |
| '%s-%s Uhr', | |
| os.date('%H', period.start), | |
| os.date('%H', period.end_time) | |
| ) | |
| table.insert(period_strings, period_str) | |
| -- If not the last period, calculate pause to next period | |
| if i < #summary.workPeriods then | |
| local next_period = summary.workPeriods[i + 1] | |
| local pause_seconds = next_period.start - period.end_time | |
| if pause_seconds > 0 then | |
| local pause_hours = pause_seconds / 3600 | |
| table.insert(period_strings, string.format('Pause: %.1fh', pause_hours)) | |
| end | |
| end | |
| end | |
| local periods_text = table.concat(period_strings, ' ') |
lua/maorun/time/core.lua
Outdated
| -- Calculate gap between previous end and current start | ||
| local gap = curr_entry.startTime - prev_entry.endTime |
There was a problem hiding this comment.
The gap calculation uses prev_entry.endTime but should use the end_time from current_period to handle overlapping entries correctly. When entries overlap, the previous entry's end time may not be the actual end of the current work period.
| -- Calculate gap between previous end and current start | |
| local gap = curr_entry.startTime - prev_entry.endTime | |
| -- Calculate gap between current period's end and current entry's start | |
| local gap = curr_entry.startTime - current_period.end_time |
|
…tion, division by zero Co-authored-by: maorun <2291503+maorun@users.noreply.github.com>
Fixed all three issues in commit a98a64f:
The fixes ensure robust error handling and accurate work period detection. All 169 tests continue to pass. |
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
lua/maorun/time/core.lua:1
- Potential division by zero error when there's only one work period. The condition checks for multiple periods but the division could still fail if #summary.workPeriods equals 1.
local Path = require('plenary.path')
| table.insert( | ||
| content, | ||
| string.format('│ Format: %s │', periods_text) |
There was a problem hiding this comment.
[nitpick] The hardcoded spacing in the format string may not align properly with different period text lengths. Consider using dynamic padding based on the content length or a fixed-width approach.
| table.insert( | |
| content, | |
| string.format('│ Format: %s │', periods_text) | |
| -- Pad or truncate periods_text to fit the box width | |
| local function pad_or_truncate(str, width) | |
| if #str > width then | |
| return str:sub(1, width) | |
| else | |
| return str .. string.rep(' ', width - #str) | |
| end | |
| end | |
| local content_width = 51 -- 62 (box width) - 10 ('│ Format: ') - 1 ('│') | |
| table.insert( | |
| content, | |
| string.format('│ Format: %s│', pad_or_truncate(periods_text, content_width)) |


Latest Fixes (Commit):
prev_entry.endTimetocurrent_period.end_timeto properly handle overlapping time entriespauseTime / (#workPeriods - 1)for gaps)Technical Improvements:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.