Skip to content

feat(taskflow): pass consumer-owned feedback field for display messages through on handles - #279

Open
chathura-de-silva wants to merge 15 commits into
OpenNSW:mainfrom
chathura-de-silva:feat/250-handle-declared-per-state-messages-for-post-action-feedback
Open

chathura-de-silva wants to merge 15 commits into
OpenNSW:mainfrom
chathura-de-silva:feat/250-handle-declared-per-state-messages-for-post-action-feedback

Conversation

@chathura-de-silva

@chathura-de-silva chathura-de-silva commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Lets a render config attach post-action feedback to a button. HandleClaim gains an optional messages field (json.RawMessage) that core carries from render.json into the rendered view unchanged. Core knows what the field is for but not what it looks like. Each consumer defines the shape, so portals can stop inferring "what happened" from the task state after an action.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Other (please describe):

Changes Made

  • taskflow/renderer/zoneview/zoneview.go: add Messages json.RawMessage \json:"messages,omitempty"`toHandleClaim`, and document it as opaque and owned by the consumer. The assembler logic is unchanged because legal handles are already copied whole into the view.
  • taskflow/renderer/zoneview/renderer_test.go: add TestRender_PassesHandleMessagesThrough. It checks that a legal handle's messages reaches the view exactly as written, and that a handle without messages emits no messages key.
  • taskflow/docs/template-reference.md: document the handle fields, including the optional pass-through messages.
  • taskflow/docs/frontend-guide.md: note that messages appears only when configured, and that the frontend defines its shape.

Testing

  • I have tested this change locally
  • I have added tests that prove my fix is effective or that my feature works
  • I have tested edge cases
  • All existing tests pass

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have checked that there are no merge conflicts

Related Issues

Closes #250
Related to OpenNSW/nsw-srilanka#550

Screenshots/Demo

N/A

Additional Notes

The field is optional and left out of the output when it isn't set, so existing render configs and consumers are unaffected. For reference, the trader-app's shape is keyed by task state with { text, variant } entries, and it is defined and documented in OpenNSW/nsw-srilanka#550, not here.

Summary by CodeRabbit

  • New Features
    • Handles can provide optional feedback for display after a command is dispatched. The feedback’s JSON value is passed through to the view, though encoding may compact whitespace or escape certain characters.
  • Documentation
    • Clarified that feedback is included only when declared in the render configuration, and that its shape and display are defined by the frontend. A handle without declared feedback does not include a feedback value.

@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 61090866-6a88-4447-ad19-9e417c5334e7

📥 Commits

Reviewing files that changed from the base of the PR and between 2e9207b and d66a13d.


You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5d1975df-4a01-4c8b-850a-4c7ec7c7e8db

📥 Commits

Reviewing files that changed from the base of the PR and between 239aa86 and e6212b8.


📒 Files selected for processing (2)
  • taskflow/docs/frontend-guide.md
  • taskflow/docs/template-reference.md

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.



📝 Walkthrough
📝 Walkthrough

Walkthrough

Zoneview handles can include optional raw JSON messages. The renderer passes configured messages through and omits the field when it is absent. The frontend guide and template reference document this behavior.

Changes

Zoneview handle messages

Layer / File(s) Summary
Handle messages passthrough
taskflow/renderer/zoneview/zoneview.go, taskflow/renderer/zoneview/renderer_test.go, taskflow/docs/frontend-guide.md, taskflow/docs/template-reference.md
HandleClaim adds optional raw JSON messages. The rendering test checks that configured messages are preserved and absent messages are omitted. Both documents describe the field as consumer-defined and passed through, subject to JSON encoding effects.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature · Severity of issue fixed: Medium


Merge Risk: ⚪ Minimal · up to e6212

The change adds optional consumer-defined handle messages, preserves them when provided, and omits them when absent. The documentation explains JSON encoding effects; no merge-blocking risk is identified.

Architecture Summary

Architecture risk: 🔵 Low · up to e6212

The change affects 1 system.

Changed systems: taskflow

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — taskflow (service) was modified; 4 changed files map to changed impact.

Before / after behavior

  • observed — Modified behavior in taskflow/renderer/zoneview/renderer_test.go: Added a rendering test with two legal handles: one without messages and one with a state-keyed message. It asserts the rendered handle JSON preserves the message content and omits messages from the handle that declares none.
  • observed — Modified behavior in taskflow/renderer/zoneview/zoneview.go: HandleClaim adds the optional JSON field messages as raw JSON. Its comments specify that feedback is shown after dispatch and passed through without interpretation; the existing command, label, and element fields are unchanged.
  • observed — Modified behavior in taskflow/docs/frontend-guide.md: Adds documentation that handle messages is included only when declared in the render config, retains its value subject to JSON encoding, and has a frontend-defined shape for post-dispatch messaging.
  • observed — Modified behavior in taskflow/docs/template-reference.md: The section-handle description now documents optional messages feedback, its display after command dispatch, and JSON pass-through with possible whitespace compaction and escaping of <, > and &.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: passing consumer-owned feedback messages through on handles. It is somewhat long but remains specific and relevant.
Description check ✅ Passed The description covers the summary, change type, implementation, tests, checklist, related issues, screenshots, and additional context. It is mostly complete and follows the repository template.
Linked Issues check ✅ Passed Issue [#250] requires an optional, opaque messages field on HandleClaim, pass-through to rendered handles, omission when absent, tests, and documentation. HandleClaim.Messages uses `json.RawMess…
Out of Scope Changes check ✅ Passed The whole-PR diff changes only HandleClaim, its renderer test, and the two docs named in issue [#250]. Each change supports the requested pass-through feature. No unrelated changes appear in the rev…
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. (2 skipped: 2 …

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@sthanikan2000 sthanikan2000 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Small suggestion. Wait for the review from @mushrafmim before making the changes.

Command string `json:"command"`
Label string `json:"label"`
Element string `json:"element,omitempty"`
Messages json.RawMessage `json:"messages,omitempty"`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shall we enforce the type more specific?

Suggested change
Messages json.RawMessage `json:"messages,omitempty"`
Messages map[string]HandleMessage `json:"messages,omitempty"`

We can define the Message struct ads follows:

type HandleMessage struct {
    Text    string `json:"text"`
    Variant string `json:"variant,omitempty"`
}

@chathura-de-silva chathura-de-silva Oct 5, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Shall we enforce the type more specific?

We can define the Message struct ads follows:

type HandleMessage struct {
    Text    string `json:"text"`
    Variant string `json:"variant,omitempty"`
}

I intentionally avoided doing this to allow the consumer to decide the format and keep core away from deciding what is/what type the feedback format is. Will do if needed (with Mushrafs feedback as you said.)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This make sense. Downstream can define what's the config they willing to have. Let's wait for review from others.

Comment thread taskflow/docs/frontend-guide.md Outdated
chathura-de-silva and others added 2 commits October 6, 2026 10:27
…lared-per-state-messages-for-post-action-feedback
The docs said a handle's messages reaches the view exactly as written.
The renderer marshals the view with encoding/json, which compacts
whitespace and escapes <, > and & in a RawMessage, so only the parsed
value is preserved. Both docs now say that.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
chathura-de-silva and others added 3 commits October 6, 2026 10:42
The docs said a handle's messages reaches the view exactly as written.
The renderer marshals the view with encoding/json, which compacts
whitespace and escapes <, > and & in a RawMessage, so only the parsed
value is preserved. Both docs now say that.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chathura-de-silva
chathura-de-silva force-pushed the feat/250-handle-declared-per-state-messages-for-post-action-feedback branch from 3ddb31a to 4449291 Compare October 6, 2026 05:12
…tion-feedback' of https://github.com/chathura-de-silva/NSW-Core into feat/250-handle-declared-per-state-messages-for-post-action-feedback
…lared-per-state-messages-for-post-action-feedback
…lared-per-state-messages-for-post-action-feedback
@ginaxu1
ginaxu1 requested a review from sthanikan2000 October 12, 2026 00:03
…lared-per-state-messages-for-post-action-feedback
…lared-per-state-messages-for-post-action-feedback
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.

taskflow/zoneview: let a handle declare per-state messages for post-action feedback

3 participants