-
Notifications
You must be signed in to change notification settings - Fork 971
Desktop qa agent #3834
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
yasserfaraazkhan
merged 3 commits into
fix/cmt-direct-dispatch-and-cleanup-endpoint
from
cursor/desktop-qa-agent-360e
May 27, 2026
Merged
Desktop qa agent #3834
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
8a971ed
ci(e2e): sync Linux MM_TEST_SERVER_URL into PR body for Cursor automa…
cursoragent 29a73c3
feat(e2e): set MM_TEST_SERVER_URL from PR Cursor Automation line
cursoragent 234f520
fix: address review findings for E2E harness, intercom, and popouts
cursoragent File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,142 @@ | ||
| // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. | ||
| // See LICENSE.txt for license information. | ||
|
|
||
| import {execFileSync} from 'child_process'; | ||
|
|
||
| // eslint-disable-next-line @typescript-eslint/no-require-imports | ||
| const {parseCursorAutomationServerUrlFromBody} = require('../utils/github-actions') as { | ||
| parseCursorAutomationServerUrlFromBody: (body: string) => string | null; | ||
| }; | ||
|
|
||
| function parsePrNumberFromGithubRef(): number | null { | ||
| const ref = process.env.GITHUB_REF?.trim(); | ||
| if (!ref) { | ||
| return null; | ||
| } | ||
| const m = (/^refs\/pull\/(\d+)\//).exec(ref); | ||
| if (!m) { | ||
| return null; | ||
| } | ||
| const n = parseInt(m[1], 10); | ||
| return Number.isNaN(n) || n < 1 ? null : n; | ||
| } | ||
|
|
||
| function resolvePrNumber(): number | null { | ||
| const raw = | ||
| process.env.MM_TEST_PR_NUMBER?.trim() || | ||
| process.env.GITHUB_PR_NUMBER?.trim() || | ||
| process.env.PR_NUMBER?.trim(); | ||
| if (raw) { | ||
| const n = parseInt(raw, 10); | ||
| if (Number.isNaN(n) || n < 1) { | ||
| // eslint-disable-next-line no-console | ||
| console.warn(`[e2e] Ignoring invalid PR number for MM_TEST_SERVER_URL resolution: ${raw}`); | ||
| return null; | ||
| } | ||
| return n; | ||
| } | ||
| return parsePrNumberFromGithubRef(); | ||
| } | ||
|
|
||
| function resolveOwnerRepo(): {owner: string; repo: string} | null { | ||
| const full = process.env.GITHUB_REPOSITORY?.trim(); | ||
| if (full && full.includes('/')) { | ||
| const i = full.indexOf('/'); | ||
| return {owner: full.slice(0, i), repo: full.slice(i + 1)}; | ||
| } | ||
| const owner = process.env.MM_TEST_GITHUB_OWNER?.trim(); | ||
| const repo = process.env.MM_TEST_GITHUB_REPO?.trim(); | ||
| if (owner && repo) { | ||
| return {owner, repo}; | ||
| } | ||
| return null; | ||
| } | ||
|
|
||
| async function fetchPrBodyFromGitHubApi(owner: string, repo: string, prNumber: number): Promise<string | null> { | ||
| const token = process.env.GITHUB_TOKEN?.trim() || process.env.GH_TOKEN?.trim(); | ||
| const headers: Record<string, string> = { | ||
| Accept: 'application/vnd.github+json', | ||
| 'X-GitHub-Api-Version': '2022-11-28', | ||
| }; | ||
| if (token) { | ||
| headers.Authorization = `Bearer ${token}`; | ||
| } | ||
| const apiUrl = `https://api.github.com/repos/${owner}/${repo}/pulls/${prNumber}`; | ||
| try { | ||
| const res = await fetch(apiUrl, {headers}); | ||
| if (!res.ok) { | ||
| // eslint-disable-next-line no-console | ||
| console.warn( | ||
| `[e2e] GitHub API GET pulls/${prNumber} returned HTTP ${res.status}; will try gh CLI if available.`, | ||
| ); | ||
| return null; | ||
| } | ||
| const data = (await res.json()) as {body?: string | null}; | ||
| return data.body ?? null; | ||
| } catch (e) { | ||
| // eslint-disable-next-line no-console | ||
| console.warn('[e2e] GitHub API fetch failed:', e); | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| function fetchPrBodyFromGhCli(prNumber: number): string | null { | ||
| try { | ||
| const out = execFileSync( | ||
| 'gh', | ||
| ['pr', 'view', String(prNumber), '--json', 'body', '-q', '.body'], | ||
| {encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'], maxBuffer: 10 * 1024 * 1024}, | ||
| ); | ||
| const body = out.trim(); | ||
| return body.length > 0 ? body : null; | ||
| } catch { | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * When MM_TEST_SERVER_URL is unset, load it from the PR body line | ||
| * "Server for Cursor Automation: <url>" (same format CI writes). Requires a PR | ||
| * number (MM_TEST_PR_NUMBER, GITHUB_PR_NUMBER, PR_NUMBER, or GITHUB_REF=refs/pull/N/…) | ||
| * and either GITHUB_REPOSITORY, MM_TEST_GITHUB_OWNER+REPO, or a working `gh` CLI. | ||
| */ | ||
| export async function resolveMmTestServerUrlFromPrIfNeeded(): Promise<void> { | ||
| if (process.env.MM_TEST_SERVER_URL?.trim()) { | ||
| return; | ||
| } | ||
|
|
||
| const prNumber = resolvePrNumber(); | ||
| if (!prNumber) { | ||
| return; | ||
| } | ||
|
|
||
| const ownerRepo = resolveOwnerRepo(); | ||
| let body: string | null = null; | ||
| if (ownerRepo) { | ||
| body = await fetchPrBodyFromGitHubApi(ownerRepo.owner, ownerRepo.repo, prNumber); | ||
| } | ||
| if (!body) { | ||
| body = fetchPrBodyFromGhCli(prNumber); | ||
| } | ||
|
|
||
| if (!body) { | ||
| // eslint-disable-next-line no-console | ||
| console.warn( | ||
| `[e2e] Could not load PR #${prNumber} body (set GITHUB_REPOSITORY + GITHUB_TOKEN, or install auth'd gh). MM_TEST_SERVER_URL remains unset.`, | ||
| ); | ||
| return; | ||
| } | ||
|
|
||
| const url = parseCursorAutomationServerUrlFromBody(body); | ||
| if (url) { | ||
| process.env.MM_TEST_SERVER_URL = url; | ||
| // eslint-disable-next-line no-console | ||
| console.log('[e2e] MM_TEST_SERVER_URL set from PR body (Server for Cursor Automation line).'); | ||
| return; | ||
| } | ||
|
|
||
| // eslint-disable-next-line no-console | ||
| console.warn( | ||
| `[e2e] PR #${prNumber} has no usable "Server for Cursor Automation:" URL line; MM_TEST_SERVER_URL remains unset.`, | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: mattermost/desktop
Length of output: 872
🏁 Script executed:
Repository: mattermost/desktop
Length of output: 105
🏁 Script executed:
Repository: mattermost/desktop
Length of output: 233
🏁 Script executed:
Repository: mattermost/desktop
Length of output: 5899
🏁 Script executed:
Repository: mattermost/desktop
Length of output: 530
🏁 Script executed:
Repository: mattermost/desktop
Length of output: 273
Scope
gh pr viewto the resolved repositoryFallback CLI lookup ignores the already-resolved
ownerRepoand runsgh pr view <n>without-R/--repo, so it can read the wrong PR body (or fail) in detached/non-standard checkouts even whenownerRepois known (e.g., at lines 113-120 withfetchPrBodyFromGhCliat 83-88). Add-R <owner>/<repo>whenownerRepois available.💡 Proposed fix
🤖 Prompt for AI Agents