feat: expose compact task fields - #2109
Conversation
📝 WalkthroughWalkthroughTask outputs now consistently include standard fields such as ChangesTask output projection
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@shortcuts/task/task_get_my_tasks.go`:
- Line 225: Update projectTaskFields to also project the standardized due and
status fields alongside the existing members and start fields. Preserve the
due_at and completed aliases, derive or project status from completed, and add
direct JSON assertions covering both due and status.
In `@shortcuts/task/task_output.go`:
- Around line 24-31: Update projectTaskFields to accept a typed task-output
struct rather than raw map[string]interface{} input, and project its validated
fields into the destination map. Decode task responses into that struct at the
boundary before invoking projectTaskFields, preserving one projection path for
the task-output shape and preventing malformed or silently missing fields from
being propagated.
In `@shortcuts/task/task_reminder.go`:
- Line 174: Add a contract test covering the successful reminder update path in
the task reminder tests, using --set or removing an existing reminder rather
than --remove with no reminders. Assert the response includes the standard task
output fields produced by projectTaskFields, so removing that projection causes
the test to fail.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 25f12817-5eba-44c3-be94-ce2a0e8aadb0
📒 Files selected for processing (21)
shortcuts/task/shortcuts.goshortcuts/task/task_assign.goshortcuts/task/task_complete.goshortcuts/task/task_complete_test.goshortcuts/task/task_followers.goshortcuts/task/task_get_my_tasks.goshortcuts/task/task_get_my_tasks_test.goshortcuts/task/task_get_related_tasks_test.goshortcuts/task/task_output.goshortcuts/task/task_output_test.goshortcuts/task/task_query_helpers.goshortcuts/task/task_query_helpers_test.goshortcuts/task/task_reminder.goshortcuts/task/task_reminder_test.goshortcuts/task/task_reopen.goshortcuts/task/task_update.goshortcuts/task/task_update_test.goshortcuts/task/tasklist_add_task.goshortcuts/task/tasklist_add_task_test.goshortcuts/task/tasklist_create.goshortcuts/task/tasklist_create_test.go
| } | ||
| } | ||
| } | ||
| projectTaskFields(outputItem, item, taskOutputMembers, taskOutputStart) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Include standardized due and status here.
Line 225 only projects members and start; JSON still exposes aliases due_at and completed, but omits the new standard due and status fields. Preserve those aliases, but also project due and project or derive status from completed. Add direct JSON assertions for both fields.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@shortcuts/task/task_get_my_tasks.go` at line 225, Update projectTaskFields to
also project the standardized due and status fields alongside the existing
members and start fields. Preserve the due_at and completed aliases, derive or
project status from completed, and add direct JSON assertions covering both due
and status.
| func projectTaskFields(dst, task map[string]interface{}, fields ...taskOutputField) { | ||
| for _, field := range fields { | ||
| key := string(field) | ||
| if value, ok := task[key]; ok { | ||
| dst[key] = value | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | 🏗️ Heavy lift
Project from a typed task-output shape.
This new shared path accepts raw map[string]interface{} values and silently omits absent or malformed fields. Decode the response into a typed task-output struct at the boundary, then project that shape into output maps.
As per coding guidelines, “Parse map[string]interface{} into typed structs at the boundary, use one projection function per shape, and prefer distinct types when same-typed values could be silently swapped.”
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@shortcuts/task/task_output.go` around lines 24 - 31, Update projectTaskFields
to accept a typed task-output struct rather than raw map[string]interface{}
input, and project its validated fields into the destination map. Decode task
responses into that struct at the boundary before invoking projectTaskFields,
preserving one projection path for the task-output shape and preventing
malformed or silently missing fields from being propagated.
Source: Coding guidelines
| "guid": taskId, | ||
| "url": urlVal, | ||
| } | ||
| projectTaskFields(outData, taskObj, standardTaskOutputFields...) |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Add a contract test for the successful update path.
The new test only exercises --remove with no reminders, which returns at Lines 80-82. Add a JSON test for --set or removal of an existing reminder and assert standard fields, so reverting this projection fails a test. As per coding guidelines, “Every behavior change must have an accompanying test.”
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@shortcuts/task/task_reminder.go` at line 174, Add a contract test covering
the successful reminder update path in the task reminder tests, using --set or
removing an existing reminder rather than --remove with no reminders. Assert the
response includes the standard task output fields produced by projectTaskFields,
so removing that projection causes the test to fail.
Source: Coding guidelines
Summary
Expose task title, members, start, due, and completion state in compact task shortcut results without renaming or removing existing fields. The projection reuses Task entities already returned by each API flow, so it adds no network requests.
Changes
summary,members,start,due, andstatus.Test Plan
go test ./...make unit-testgo vet ./...go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.1.6 run --new-from-rev=origin/mainRelated Issues
Summary by CodeRabbit