Skip to content

Conversation

@dboyliao
Copy link
Collaborator

@dboyliao dboyliao commented Jan 5, 2026

No description provided.

@dboyliao dboyliao force-pushed the dboy/xalign/revise-slack-msg branch 5 times, most recently from 6d3a0b4 to 0fa33b3 Compare January 5, 2026 01:45
@dboyliao dboyliao requested review from c9s, Copilot, gx578007 and ycdesu and removed request for c9s, gx578007 and ycdesu January 5, 2026 03:23
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances the xalign strategy's Slack integration by including created order IDs in thread replies when users interact with already-processed orders. This provides better visibility into the order submission results after the interactive buttons have been processed.

Key Changes:

  • Added submittedOrderRegistry sync.Map to persist submitted order information
  • Implemented automatic cleanup of orders older than 2 hours from the registry
  • Enhanced Slack interaction callback to display created order details when users click buttons on already-processed orders

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

now := time.Now()
submittedOrderRegistry.Range(func(key, value interface{}) bool {
if createdOrder, ok := value.(*types.Order); ok {
if now.Sub(createdOrder.CreationTime.Time()) > 2*time.Hour {
Copy link
Owner

Choose a reason for hiding this comment

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

can use time.Since to replace now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I refactor it and pass now as a parameter.
The reason for that is to make mocking now possible so I can write test on the case where ttl is due.

blocks = append(blocks, interact.InteractionMessageUpdate{
Blocks: []slack.Block{buildTextBlock(
fmt.Sprintf(
"Created Order: %s", createdOrder.String(),
Copy link
Owner

Choose a reason for hiding this comment

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

maybe we can call createdOrder.SlackBlocks()?

we need to implement order.SlackBlocks()

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I use .SlackAttachment() instead.

@dboyliao dboyliao force-pushed the dboy/xalign/revise-slack-msg branch 2 times, most recently from 167936c to 52f11b1 Compare January 5, 2026 04:43
@dboyliao dboyliao requested a review from Copilot January 5, 2026 05:19
@dboyliao dboyliao force-pushed the dboy/xalign/revise-slack-msg branch from 52f11b1 to e5cdc84 Compare January 5, 2026 05:25
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

Comments suppressed due to low confidence (1)

pkg/strategy/xalign/slack.go:294

  • The variable 'io' is assigned from 'value' but this is redundant since 'itOrder' was already type-asserted from 'value' at line 251. The check at line 252 already ensures that 'value' is of type '*InteractiveSubmitOrder' and assigns it to 'itOrder', so this second type assertion and assignment is unnecessary. You can directly use 'itOrder' instead of 'io' in the rest of the function.
			return []interact.InteractionMessageUpdate{
				{
					Blocks:       nil,
					Attachments:  nil,
					PostInThread: false,
				},
			}, fmt.Errorf("invalid type detected for interactive order (%s): %+v", actionValue, value)
		}

		blocks := removeBlockByID(oriMessage.Blocks.BlockSet, interactiveButtonsBlockID)
		switch actionID {

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dboyliao dboyliao force-pushed the dboy/xalign/revise-slack-msg branch 3 times, most recently from 244cf3b to 177e773 Compare January 5, 2026 06:05
@dboyliao dboyliao requested a review from Copilot January 5, 2026 06:06
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dboyliao dboyliao force-pushed the dboy/xalign/revise-slack-msg branch 2 times, most recently from 012ab33 to 3ff5e72 Compare January 5, 2026 07:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

submittedOrderRegistry.Store(itOrder.id, order)

if onSubmittedOrderCallback != nil {
onSubmittedOrderCallback(session, &itOrder.submitOrder, order, err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it possible that order is nil here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes.
It should be handled by the callback.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Okay. Just want to make sure the type assertion at line 274 won't panic.

@dboyliao dboyliao force-pushed the dboy/xalign/revise-slack-msg branch from 7f2c8d3 to a85efb5 Compare January 5, 2026 08:23
@dboyliao dboyliao force-pushed the dboy/xalign/revise-slack-msg branch from a85efb5 to d6463c1 Compare January 5, 2026 08:28
@dboyliao dboyliao merged commit d748b95 into main Jan 5, 2026
3 checks passed
@dboyliao dboyliao deleted the dboy/xalign/revise-slack-msg branch January 5, 2026 08:38
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.

5 participants