Skip to content

[MM-70581] Use the loaded origin for Agents API requests - #1025

Merged
crspeller merged 1 commit into
masterfrom
cursor/jira-bug-fix-workflow-d641
Sep 14, 2026
Merged

crspeller merged 1 commit into
masterfrom
cursor/jira-bug-fix-workflow-d641

Conversation

@cursor

@cursor cursor Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Use the browser-loaded origin plus Mattermost basename for Agents webapp API requests instead of the configured SiteURL. This keeps SSH tunnels and alternate hostnames same-origin while preserving subpath installs.

QA:

  1. Configure Mattermost SiteURL as http://localhost:8065.
  2. Load Mattermost from http://127.0.0.1:8065 and sign in as a system admin.
  3. Open System Console → Plugins → Agents.
  4. Verify the full Agents configuration loads and plugin network requests target http://127.0.0.1:8065/plugins/mattermost-ai/....
  5. On an installation with a basename such as /mattermost, verify requests include /mattermost/plugins/mattermost-ai/....

Validated with the focused Jest regression test and the repository make check suite (all lint, type, Go, webapp, shard, and drift checks passed; lock drift was rerun with the repository's Node 24.11 toolchain).

Ticket Link

Jira https://mattermost.atlassian.net/browse/MM-70581

Screenshots

before after
Agents configuration fails through alternate hostname Agents configuration loads through alternate hostname

Release Note

Fixed Agents plugin API requests when Mattermost is accessed through an SSH tunnel, alternate hostname, or configured subpath.
Open in Web View Automation 

Summary by CodeRabbit

  • Bug Fixes
    • Improved site URL handling during plugin initialization.
    • The app now uses the browser’s origin and optional base path to determine its site URL, supporting more reliable operation when hosted under a subdirectory.

Co-authored-by: mattermost-code <matty-code@mattermost.com>
@mattermost-code
mattermost-code marked this pull request as ready for review September 4, 2026 16:33
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@cursor cursor Bot left a comment

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.

This PR meets the approval criteria (Bugbot and Security Agent were not present after the first poll; no policy required human review), but GitHub cannot accept an approval on a pull request authored by this same app. Reviewers were not assigned; human review is needed for merge.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Approver

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

🤖 LLM Evaluation Results

OpenAI

⚠️ Overall: 21/28 tests passed (75.0%)

Provider Total Passed Failed Pass Rate
⚠️ OPENAI 28 21 7 75.0%

❌ Failed Evaluations

Show 7 failures

OPENAI

1. TestReactEval/[openai]_react_cat_message

  • Score: 0.00
  • Rubric: The word/emoji is a cat emoji or a heart/love emoji
  • Reason: The output is the text "heart_eyes_cat", not an actual cat emoji (e.g., 😺/🐱) or a heart/love emoji (e.g., ❤️/😍).

2. TestConversationMentionHandling/[openai]_conversation_from_attribution_long_thread.json

  • Score: 0.00
  • Rubric: is a list of bugs
  • Reason: The output does not provide a list of bugs; it states it cannot create the list yet and asks the user to paste bug reports, describing a future formatting plan.

3. TestConversationMentionHandling/[openai]_conversation_from_attribution_long_thread.json

  • Score: 0.00
  • Rubric: includes a description of each bug
  • Reason: The output does not include any bug entries; it requests the user to paste bug reports and describes a future format. Therefore it does not provide a description of each bug.

4. TestConversationMentionHandling/[openai]_conversation_from_attribution_long_thread.json

  • Score: 0.00
  • Rubric: attributes each bug to a user
  • Reason: The output does not attribute each bug to a user; it only requests bug reports and suggests including a 'Reported by' field in a future list, without providing any per-bug user attribution.

5. TestConversationMentionHandling/[openai]_conversation_from_attribution_long_thread.json

  • Score: 0.00
  • Rubric: attributes the bug about trying to save without a color and the save button not doing anything to @maria.nunez
  • Reason: The output does not mention the specific bug about saving without a color or the save button doing nothing, and it does not attribute any bug to @maria.nunez. It only requests access to bug reports and describes a formatting plan.

6. TestConversationMentionHandling/[openai]_conversation_from_attribution_long_thread.json

  • Score: 0.00
  • Rubric: the bug about the end user being able to change channel banner is attributed to @maria.nunez
  • Reason: The output does not mention the specific bug about an end user being able to change the channel banner, nor does it attribute any bug to @maria.nunez. It only asks the user to paste bug reports and explains a formatting plan.

7. TestDirectMessageConversations/[openai]_bot_dm_tool_introspection

  • Score: 0.50
  • Rubric: mentions Github and refers to the documentation
  • Reason: The output refers to documentation via a link to https://docs.mattermost.com, but it does not mention GitHub anywhere.

Anthropic

⚠️ Overall: 21/28 tests passed (75.0%)

Provider Total Passed Failed Pass Rate
⚠️ ANTHROPIC 28 21 7 75.0%

❌ Failed Evaluations

Show 7 failures

ANTHROPIC

1. TestReactEval/[anthropic]_react_cat_message

  • Score: 0.00
  • Rubric: The word/emoji is a cat emoji or a heart/love emoji
  • Reason: The output is the text string "heart_eyes_cat", not an actual cat emoji (e.g., 😺) or heart/love emoji (e.g., ❤️).

2. TestConversationMentionHandling/[anthropic]_conversation_from_attribution_long_thread.json

  • Score: 0.00
  • Rubric: is a list of bugs
  • Reason: The output explains it cannot access history and suggests ways to find bugs, but it does not actually provide a list of bugs.

3. TestConversationMentionHandling/[anthropic]_conversation_from_attribution_long_thread.json

  • Score: 0.00
  • Rubric: includes a description of each bug
  • Reason: The output does not list any bugs or provide descriptions of each bug; it states inability to access history and suggests ways to find bug reports, offering to organize them if provided.

4. TestConversationMentionHandling/[anthropic]_conversation_from_attribution_long_thread.json

  • Score: 0.00
  • Rubric: attributes each bug to a user
  • Reason: The output does not list any bugs and therefore cannot attribute each bug to a specific user. It only states inability to access history and suggests ways to find bugs.

5. TestConversationMentionHandling/[anthropic]_conversation_from_attribution_long_thread.json

  • Score: 0.00
  • Rubric: attributes the bug about trying to save without a color and the save button not doing anything to @maria.nunez
  • Reason: The output does not mention @maria.nunez and does not attribute any specific bug (saving without a color / save button not doing anything) to anyone. It only states it cannot access history and suggests ways to find bugs.

6. TestConversationMentionHandling/[anthropic]_conversation_from_attribution_long_thread.json

  • Score: 0.00
  • Rubric: the bug about the end user being able to change channel banner is attributed to @maria.nunez
  • Reason: The output does not mention the bug about an end user being able to change the channel banner, nor does it attribute it to @maria.nunez.

7. TestDirectMessageConversations/[anthropic]_bot_dm_tool_introspection

  • Score: 0.00
  • Rubric: mentions Github and refers to the documentation
  • Reason: The output refers to documentation (docs.mattermost.com) but does not mention GitHub anywhere, so it does not satisfy the requirement to both mention GitHub and refer to the documentation.

This comment was automatically generated by the eval CI pipeline.

@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Essentials

Run ID: cc2fff6c-13df-4b23-b2c0-978536022a1c

📥 Commits

Reviewing files that changed from the base of the PR and between 200d239 and 873843f.

📒 Files selected for processing (2)
  • webapp/src/index.test.tsx
  • webapp/src/index.tsx

Included review availability: 3 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 4 reviews per hour.


📝 Walkthrough

Walkthrough

Plugin initialization now sets the client site URL from the browser origin and optional basename. Tests configure a separate site URL and verify that initialization uses the browser-derived URL.

Changes

Site URL initialization

Layer / File(s) Summary
Browser URL resolution
webapp/src/index.tsx
Plugin initialization combines window.location.origin with optional window.basename. The global Window interface declares basename.
Site URL initialization tests
webapp/src/index.test.tsx
Test helpers accept an optional configured site URL. The client mock records setSiteURL calls, and a test verifies the browser-derived URL.

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

Merge Risk: ⚪ Minimal · up to 87384

Agents API requests now use the browser-loaded origin and optional Mattermost basename, allowing alternate hostnames, SSH tunnels, and subpath installations to reach the correct API endpoint. No current merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: Agents API requests now use the browser-loaded origin. It is concise and specific.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/jira-bug-fix-workflow-d641

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

@mm-cloud-bot

Copy link
Copy Markdown

Plugin Spinwick PR #1025 🎉

Test server created!

Access here: https://agents-pr-1025-o5ahy.test.mattermost.cloud

Plugin Version Artifact
agents 873843f Download

Installation ID: 4ri3zqko63dsjbn4hgynh8fswe
Logs: Click here

Credentials: Posted securely in this Mattermost channel - Look for PR #1025

@nickmisasi
nickmisasi requested a review from crspeller September 8, 2026 15:05
@mattermost-code

Copy link
Copy Markdown
Contributor

@crspeller — friendly nudge: this PR has been waiting on your review for a couple of days and CodeRabbit has already signed off. Could you take a look when you get a chance? 🙏

@crspeller
crspeller merged commit 334f63d into master Sep 14, 2026
37 checks passed
@crspeller
crspeller deleted the cursor/jira-bug-fix-workflow-d641 branch September 14, 2026 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants