Skip to content

feat: expose compact task fields - #2109

Open
ILUO wants to merge 7 commits into
larksuite:mainfrom
ILUO:feat/task-compact-fields
Open

feat: expose compact task fields#2109
ILUO wants to merge 7 commits into
larksuite:mainfrom
ILUO:feat/task-compact-fields

Conversation

@ILUO

@ILUO ILUO commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

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

  • Add a shared typed-field projector for summary, members, start, due, and status.
  • Extend read summaries, root write results, and nested successful task items while preserving existing aliases and failure schemas.
  • Add output contract tests covering root, list, reminder, completion, update, and tasklist flows.

Test Plan

  • go test ./...
  • make unit-test
  • go vet ./...
  • go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.1.6 run --new-from-rev=origin/main
  • Mocked local shortcut execution confirms the affected JSON output paths and unchanged failure behavior.

Related Issues

  • None

Summary by CodeRabbit

  • Enhancements
    • Task commands now return richer, standardized output across creation, updates, assignment, completion, reminders, reopening, and task-list operations.
    • Structured task responses can include summary, members, status, start, and due information alongside existing identifiers and links.
    • “Get my tasks” and related-task results now include additional scheduling and assignment details in supported output formats.
  • Bug Fixes
    • Improved consistency of task fields in JSON responses, including cases where reminders are removed or tasks are partially updated.

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Task outputs now consistently include standard fields such as summary, members, start, due, and status across task mutations, queries, reminders, updates, and tasklist operations. Tests use complete fixtures and validate structured JSON output.

Changes

Task output projection

Layer / File(s) Summary
Projection contract and root output coverage
shortcuts/task/task_output.go, shortcuts/task/task_output_test.go
Defines standard output fields and tests projection behavior, absent-field handling, and root shortcut responses.
Task mutation output enrichment
shortcuts/task/shortcuts.go, shortcuts/task/task_*.go, shortcuts/task/*_test.go
Adds standard task fields to create, assign, complete, followers, reopen, reminder, and update outputs.
Task query projections
shortcuts/task/task_get_my_tasks.go, shortcuts/task/task_query_helpers.go, shortcuts/task/*_test.go
Projects members, start, due, and status fields into query results and expands related assertions.
Tasklist output enrichment
shortcuts/task/tasklist_*.go, shortcuts/task/tasklist_*_test.go
Adds standard fields to successful tasklist results and validates decoded JSON payloads.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • larksuite/cli#218: Both modify CompleteTask.Execute around task output and control flow.
  • larksuite/cli#377: Both modify task query output shaping in task_query_helpers.go.
  • larksuite/cli#1641: Both modify per-task JSON output construction in task_get_my_tasks.go.

Suggested labels: domain/task, size/L, enhancement

Suggested reviewers: calendar-assistant

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately reflects the main change: exposing compact task fields.
Description check ✅ Passed The description follows the required template and includes a clear summary, changes, test plan, and related issues.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added domain/task PR touches the task domain size/M Single-domain feat or fix with limited business impact labels Jul 30, 2026
@ILUO
ILUO marked this pull request as ready for review July 30, 2026 08:07

@coderabbitai coderabbitai Bot 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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1f565a2 and 7c7ad7d.

📒 Files selected for processing (21)
  • shortcuts/task/shortcuts.go
  • shortcuts/task/task_assign.go
  • shortcuts/task/task_complete.go
  • shortcuts/task/task_complete_test.go
  • shortcuts/task/task_followers.go
  • shortcuts/task/task_get_my_tasks.go
  • shortcuts/task/task_get_my_tasks_test.go
  • shortcuts/task/task_get_related_tasks_test.go
  • shortcuts/task/task_output.go
  • shortcuts/task/task_output_test.go
  • shortcuts/task/task_query_helpers.go
  • shortcuts/task/task_query_helpers_test.go
  • shortcuts/task/task_reminder.go
  • shortcuts/task/task_reminder_test.go
  • shortcuts/task/task_reopen.go
  • shortcuts/task/task_update.go
  • shortcuts/task/task_update_test.go
  • shortcuts/task/tasklist_add_task.go
  • shortcuts/task/tasklist_add_task_test.go
  • shortcuts/task/tasklist_create.go
  • shortcuts/task/tasklist_create_test.go

}
}
}
projectTaskFields(outputItem, item, taskOutputMembers, taskOutputStart)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 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.

Comment on lines +24 to +31
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
}
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 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...)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain/task PR touches the task domain size/M Single-domain feat or fix with limited business impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant