Skip to content

Add leave update and dry-run support - #13

Merged
PothieuG merged 1 commit into
mainfrom
agent/leave-update-support
Aug 4, 2026
Merged

Add leave update and dry-run support#13
PothieuG merged 1 commit into
mainfrom
agent/leave-update-support

Conversation

@jernejk

@jernejk jernejk commented Aug 4, 2026

Copy link
Copy Markdown
Member

Summary

  • add tp leave update <ID> with partial CLI options backed by TimePro's full replacement payload
  • add the MCP update_leave tool
  • add --dry-run / dryRun support for both leave creation and leave updates
  • share leave-create validation and payload preparation between CLI and MCP
  • add 0.2.6 release notes and update the latest release marker

Safety and behavior

TimePro's leave update endpoint replaces the complete record. The update service first reads the existing leave, preserves API-returned fields that were not explicitly changed, validates the rebuilt request, and only then sends the update.

Dry-run performs the same reads, validation, and payload preparation but does not call the create or update endpoint. JSON dry-runs return the complete proposed request.

Older TimePro leave-list responses may omit stored workday start/end times. Updates preserve those fields when returned; otherwise they fall back to the current employee profile and then 09:00-18:00. Explicit --start-time and --end-time remain available.

Verification

  • dotnet test SSW.TimePro.Timesheets.Cli.slnx --no-restore - 284 passed
  • focused leave CLI/MCP/release tests - 27 passed
  • create/update command help smoke-tested
  • git diff --check - clean
  • CodeRabbit review findings addressed; final rerun was rate-limited
  • NuGet audit reports two pre-existing moderate advisories for Scriban.Signed 7.2.0 in the integration test project; this PR does not change package references

Closes #12

@jernejk
jernejk marked this pull request as ready for review August 4, 2026 14:28
Copilot AI review requested due to automatic review settings August 4, 2026 14:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds first-class leave update support to the TimePro CLI (tp leave update <ID>) and the MCP server (update_leave), including dry-run previews that validate and return the fully prepared API payload without writing changes. This fits the CLI’s pattern of providing safe, scriptable workflows (notably via --json and confirmation prompts) for TimePro operations.

Changes:

  • Introduces shared LeaveCreateService / LeaveUpdateService so CLI and MCP reuse the same validation + payload preparation logic.
  • Adds tp leave update <ID> and extends leave create/update flows with --dry-run / dryRun previews.
  • Updates docs/templates/release notes and expands unit + integration coverage for leave update + dry-run behavior.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/SSW.TimePro.Cli.Tests/Features/Updates/ReleaseNotesCatalogTests.cs Bumps expected latest release version to 0.2.6.
tests/SSW.TimePro.Cli.Tests/Features/Mcp/LeaveMcpToolsTests.cs Adds MCP tests for leave dry-run and update behavior + preserved fields.
tests/SSW.TimePro.Cli.Tests/Features/Leave/UpdateCommandTests.cs New unit tests for tp leave update behavior, validation, and dry-run.
tests/SSW.TimePro.Cli.Tests/Features/Leave/CreateCommandTests.cs Adds leave create dry-run test and registers LeaveCreateService in test DI.
tests/SSW.TimePro.Cli.Integration/Features/LeaveTests.cs Adds integration coverage for update payload shape and optionalEmp mapping.
src/SSW.TimePro.Cli/Shared/Models/LeaveModels.cs Extends leave DTO with OptionalEmp, UserStartTime, UserEndTime.
src/SSW.TimePro.Cli/Program.cs Registers leave create/update services and adds the leave update command to CLI tree.
src/SSW.TimePro.Cli/Features/Skills/Templates/timepro-timesheets.md Updates skill template examples to include leave update and dry-run usage.
src/SSW.TimePro.Cli/Features/Mcp/Tools/LeaveMcpTools.cs Refactors MCP leave tools to use shared services; adds update_leave + dry-run.
src/SSW.TimePro.Cli/Features/Mcp/McpHostCommand.cs Registers leave services in the MCP host DI container.
src/SSW.TimePro.Cli/Features/Leave/UpdateCommand.cs New CLI command to update leave requests with confirmation + dry-run + JSON output.
src/SSW.TimePro.Cli/Features/Leave/LeaveUpdateService.cs New service that rebuilds a full replacement update payload while preserving fields.
src/SSW.TimePro.Cli/Features/Leave/LeaveCreateService.cs New service that centralizes leave-create validation + request building.
src/SSW.TimePro.Cli/Features/Leave/CreateCommand.cs Refactors create command to use LeaveCreateService and adds --dry-run.
release-notes/0.2.6.md Adds 0.2.6 release notes for leave update + dry-run.
README.md Documents new update command + dry-run semantics and updates command inventory.
AGENTS.md Updates canonical agent guidance for leave update + dry-run semantics.
Suppressed comments (1)

src/SSW.TimePro.Cli/Features/Mcp/Tools/LeaveMcpTools.cs:156

  • Same as CreateLeave: this hand-crafts JSON for the not-logged-in case. Prefer JsonSerializer.Serialize(..., JsonOpts) for consistent output formatting and escaping.
        var tenant = _config.LoadActiveTenantConfig();
        if (string.IsNullOrWhiteSpace(tenant?.EmployeeId))
            return """{"error": "Not logged in. Run 'tp login --tenant <id>' first."}""";

Comment on lines +36 to +47
if (string.IsNullOrWhiteSpace(options.Start)
|| string.IsNullOrWhiteSpace(options.End)
|| string.IsNullOrWhiteSpace(options.Type))
{
throw new LeaveCreateValidationException("--start, --end, and --type are required");
}

if (string.IsNullOrWhiteSpace(options.Note))
{
throw new LeaveCreateValidationException(
"--note is required: a reason/description is mandatory for leave");
}
Comment on lines +49 to +53
if (options.ClearApprovedBy && options.ApprovedBy is not null)
throw new LeaveUpdateValidationException("Use either approvedBy or clearApprovedBy, not both");

if (options.ClearCc && options.Cc is not null)
throw new LeaveUpdateValidationException("Use either cc or clearCc, not both");
Comment on lines 101 to 104
var tenant = _config.LoadActiveTenantConfig();
if (tenant?.EmployeeId is null)
if (string.IsNullOrWhiteSpace(tenant?.EmployeeId))
return """{"error": "Not logged in. Run 'tp login --tenant <id>' first."}""";

Comment on lines +98 to +103
var tenant = _config.LoadActiveTenantConfig();
if (tenant?.EmployeeId is null)
{
WriteValidationError(settings.Json, "Not logged in. Run 'tp login --tenant <id>' first.");
return 1;
}
@PothieuG
PothieuG merged commit 46c0fda into main Aug 4, 2026
2 checks passed
@PothieuG
PothieuG deleted the agent/leave-update-support branch August 4, 2026 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TimePro EU - Can we update the leave ?

3 participants