Skip to content

Add inline action button sample with mm_blocks_actions - #211

Merged
sbishel merged 7 commits into
masterfrom
action_buttons
Aug 12, 2026
Merged

Add inline action button sample with mm_blocks_actions#211
sbishel merged 7 commits into
masterfrom
action_buttons

Conversation

@sbishel

@sbishel sbishel commented May 19, 2026

Copy link
Copy Markdown
Member

Summary

  • Add /inline_action slash command that posts a markdown issue-tracker table whose mmaction://triage?... links open a per-row triage dialog.
  • Demonstrates the mm_blocks_actions post prop (with required type: "external") and per-click parameters carried in the link query string (id, title, priority, assignee) merged into the upstream URL by MergeQueryIntoURL. Static fields (project) still come through request.Context.
  • Adds a /inline_action/triage HTTP handler that opens a follow-up dialog populated from those query params and the static context.

Ticket Link

Fixes https://mattermost.atlassian.net/browse/MM-68387

Test plan

  • /inline_action posts the 5-row issue table.
  • Clicking "Triage" on each row opens a dialog whose intro text shows that row's id / title / priority / assignee plus the static project=Demo Project.
  • Submitting the triage dialog posts the standard "Dialog Submitted" message back to the channel.

Requires mattermost/mattermost#36219 to test.

@coderabbitai

coderabbitai Bot commented May 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8d5136ef-9fdd-4b3c-8b05-d1be810f9380

📥 Commits

Reviewing files that changed from the base of the PR and between 08517cb and 412b4a0.

📒 Files selected for processing (1)
  • server/http_hooks.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • server/http_hooks.go

📝 Walkthrough

Walkthrough

Adds the inline_action command and registers it with Mattermost. The command posts a markdown issue table with a triage action. The triage endpoint builds and opens a dialog from the action request data.

Changes

Inline Action Integration

Layer / File(s) Summary
Inline action command flow
server/command_hooks.go
Registers and dispatches inline_action. The handler posts an issue table with an external triage action and returns an ephemeral error response when post creation fails.
Triage action callback
server/http_hooks.go
Adds the /inline_action/triage route. The handler decodes the action request, reads context and query values, builds the triage dialog, opens it, and returns an empty JSON response. formatJSON formats request data and fallback values.

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

Mergeability Score: ⚪ Minimal · up to 412b4

This PR adds an inline action example and triage dialog flow; no actionable merge-blocking risk remains beyond normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant Mattermost
  participant PluginCommand
  participant MattermostAPI
  User->>PluginCommand: Run /demo_plugin inline_action
  PluginCommand->>MattermostAPI: Create post with triage action
  MattermostAPI-->>Mattermost: Render issue table and action
  User->>Mattermost: Click triage action
  Mattermost->>MattermostAPI: Send PostActionIntegrationRequest
  MattermostAPI->>PluginCommand: Invoke /inline_action/triage
  PluginCommand->>MattermostAPI: Open triage dialog
  MattermostAPI-->>User: Display triage dialog
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: adding an inline action button sample that uses mm_blocks_actions.
Description check ✅ Passed The description directly explains the inline action command, issue table, triage dialog, mm_blocks_actions usage, query parameters, and testing requirements.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch action_buttons

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

Error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions
The command is terminated due to an error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions


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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@server/http_hooks.go`:
- Around line 517-525: The intro always prefixes assignee with '@', producing
"`@unassigned`"; change to build a display value that only prepends '@' for real
assignees. Create a local assigneeDisplay (or similar) based on assignee (e.g.,
if assignee == "unassigned" or empty then assigneeDisplay = "unassigned" else
assigneeDisplay = "@"+assignee) and use that in the fmt.Sprintf that builds
intro (referencing assignee, assigneeDisplay, and the existing fmt.Sprintf call
that builds intro using issueID, project, title, priority).
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e4cd24d6-f7ce-4326-be60-a3c0f70bf03a

📥 Commits

Reviewing files that changed from the base of the PR and between e9d7e1f and 47b0c4f.

📒 Files selected for processing (2)
  • server/command_hooks.go
  • server/http_hooks.go

Comment thread server/http_hooks.go Outdated
Per coderabbit review

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
sbishel and others added 2 commits May 19, 2026 14:14
* Add MCP demo tools

Expose demo MCP tools through the Agents plugin helper so cross-plugin MCP registration can be exercised from this plugin.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Update server/mcp_tools_test.go

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update MCP demo for pluginmcp helper

Co-authored-by: Cursor <cursoragent@cursor.com>

* Synchronize MCP server initialization

Co-authored-by: Cursor <cursoragent@cursor.com>

* Address MCP review feedback

Co-authored-by: Cursor <cursoragent@cursor.com>

* Remove MCP lifecycle test seams

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
server/activate_hooks.go (1)

88-92: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Tear down resources in reverse order of activation.

In OnActivate, the core plugin is activated first, followed by the MCP server registration. To ensure clean teardown and avoid potential dependencies on core services during unregistration, it's a best practice to unregister the MCP server before deactivating the core plugin.

♻️ Proposed refactor to reverse teardown order
 func (p *Plugin) OnDeactivate() error {
-	err := p.onDeactivateCore()
 	p.unregisterMCPServerBestEffort()
-	return err
+	return p.onDeactivateCore()
 }
🤖 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 `@server/activate_hooks.go` around lines 88 - 92, Update Plugin.OnDeactivate to
call unregisterMCPServerBestEffort before p.onDeactivateCore, preserving the
existing error return from the core deactivation.
🤖 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.

Nitpick comments:
In `@server/activate_hooks.go`:
- Around line 88-92: Update Plugin.OnDeactivate to call
unregisterMCPServerBestEffort before p.onDeactivateCore, preserving the existing
error return from the core deactivation.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0518ec82-f343-4b24-9c64-1c09a965b3b0

📥 Commits

Reviewing files that changed from the base of the PR and between 47b0c4f and 08517cb.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (8)
  • go.mod
  • server/activate_hooks.go
  • server/http_hooks.go
  • server/http_hooks_test.go
  • server/mcp.go
  • server/mcp_tools.go
  • server/mcp_tools_test.go
  • server/plugin.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • server/http_hooks.go

@sbishel
sbishel requested a review from hanzei July 21, 2026 16:28
@sbishel sbishel added the 2: Dev Review Requires review by a core committer label Jul 21, 2026
@sbishel

sbishel commented Jul 21, 2026

Copy link
Copy Markdown
Member Author

/update-branch

@hanzei hanzei left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Great work 🚀

Comment thread server/http_hooks.go Outdated

// Build introduction text showing key identifiers passed via mmaction://
intro := fmt.Sprintf(
"**Issue:** %s | **Project:** %s\n**Title:** %s | **Priority:** %s | **Assignee:** %s",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we add another | after the Project name?

Image

@sbishel
sbishel merged commit e878bce into master Aug 12, 2026
4 checks passed
@sbishel
sbishel deleted the action_buttons branch August 12, 2026 22:24
@sbishel sbishel added 4: Reviews Complete All reviewers have approved the pull request and removed 2: Dev Review Requires review by a core committer labels Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4: Reviews Complete All reviewers have approved the pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants