* simplify CODEOWNERS
* dont .gitignore AGENTS.md
* AGENTS.md to document previous CODEOWNERS responsibilities
* update from https://developers.mattermost.com/contribute/more-info/server/schema-migration-guide/
* CREATE INDEX CONCURRENTLY now vetted
* rewrite and move to README.md
* dont limit to 80 chars
* rewrite webapp AGENTS.md and add to README.md
---------
Co-authored-by: Mattermost Build <build@mattermost.com>
* ci: add test sharding plumbing to server CI
Add infrastructure for upcoming test sharding without changing behavior:
- Add shard-index and shard-total inputs to server-test-template.yml
(defaults preserve existing single-runner behavior)
- Add timing cache restore step (activates only when shard-total > 1)
- Add merge-postgres-test-results job to server-ci.yml that:
- Merges JUnit XML reports from shard artifacts
- Saves timing data cache for future shard balancing
- Handles both single-artifact and multi-shard scenarios
- Add .gitignore entries for timing cache and shard work files
Co-authored-by: Claude <claude@anthropic.com>
* ci: shard server Postgres tests into 4 parallel runners
Extract sharding logic into standalone, tested scripts and enable
4-shard parallel test execution for server Postgres CI:
Scripts:
- server/scripts/shard-split.js: Node.js bin-packing solver that
assigns test packages to shards using timing data from previous runs.
Two-tier strategy: light packages (<2min) whole, heavy packages
(api4, app) split at individual test level.
- server/scripts/run-shard-tests.sh: Multi-run wrapper that calls
gotestsum directly for each package group with -run regex filters.
- server/scripts/shard-split.test.js: 8 test cases covering round-robin
fallback, timing-based balancing, heavy package splitting, JUnit XML
fallback, and enterprise package separation.
Workflow changes:
- server-test-template.yml: Add shard splitting step that discovers test
packages and runs the solver. Modified Run Tests step to use wrapper
script when sharding is active.
- server-ci.yml: Add 4-shard matrix to test-postgres-normal. Update
merge job artifact patterns for shard-specific names.
Performance: 7.2 min with timing cache vs 62.5 min baseline = 88%
wall-time improvement. First run without cache uses JUnit XML fallback
or round-robin, then populates the cache for subsequent runs.
Co-authored-by: Claude <claude@anthropic.com>
* fix: raise heavy package threshold to 5 min to preserve test isolation
sqlstore integrity tests scan the entire database and fail when other
packages' test data is present. At 182s, sqlstore was just over the
120s threshold and getting split at test level. Raising to 300s keeps
only api4 (~38 min) and app (~15 min) as heavy — where the real
sharding gains are — while sqlstore, elasticsearch, etc. stay whole
and maintain their test isolation guarantees.
Co-authored-by: Claude <claude@anthropic.com>
* ci: only save test timing cache on default branch
PR branches always restore from master's timing cache via restore-keys
prefix matching. Timing data is stable day-to-day so this eliminates
cache misses on first PR runs and reduces cache storage.
Co-authored-by: Claude <claude@anthropic.com>
* ci: skip FIPS tests on PRs (enterprise CI handles compile check)
Per review feedback: the enterprise CI already runs a FIPS compile
check on every PR. Running the full FIPS test suite on PRs is redundant
since it uses the identical test suite as non-FIPS — the only
FIPS-specific failure mode is a build failure from non-approved crypto
imports, which the enterprise compile check catches.
Full FIPS tests continue to run on every push to master.
Co-authored-by: Claude <claude@anthropic.com>
* fix: address review feedback on run-shard-tests.sh
- Remove set -e so all test runs execute even if earlier ones fail;
track failures and exit with error at the end (wiggin77)
- Remove unused top-level COVERAGE_FLAG variable (wiggin77)
- Fix RUN_IDX increment position so report, json, and coverage files
share the same index (wiggin77)
- Update workflow comment: heavy threshold is 5 min, not 2 min (wiggin77)
Co-authored-by: Claude <claude@anthropic.com>
* style: use node: prefix for built-in fs module in shard-split.js
Co-authored-by: Claude <claude@anthropic.com>
* fix: avoid interpolating file paths into generated shell script
Read shard package lists from files at runtime instead of interpolating
them into the generated script via printf. This prevents theoretical
shell metacharacter injection from directory names, as flagged by
DryRun Security.
Co-authored-by: Claude <claude@anthropic.com>
* fix(ci): rename merged artifact to match server-ci-report glob
The merged artifact was named postgres-server-test-logs-merged which
does not match the *-test-logs pattern in server-ci-report.yml,
causing Postgres test results to be missing from PR/commit reports.
Also pins junit-report-merger to exact version 7.0.0 for supply chain
safety.
Co-authored-by: Claude <claude@anthropic.com>
* fix(ci): pass RACE_MODE env into Docker container
RACE_MODE was set on the host runner but never included in the docker
run --env list. The light-package path worked because the heredoc
expanded on the host, but run-shard-tests.sh reads RACE_MODE at
runtime inside the container where it was unset. This caused heavy
packages (api4, app) to silently lose -race detection.
Co-authored-by: Claude <claude@anthropic.com>
* fix(ci): discover new tests in heavy packages not in timing cache
Tests not present in the timing cache (newly added or renamed) would
not appear in any shard -run regex, causing them to silently skip.
After building items from the cache, run go test -list to discover
current test names and assign any cache-missing tests to shards via
the normal bin-packing algorithm with a small default duration.
Co-authored-by: Claude <claude@anthropic.com>
* fix(ci): add missing line continuation backslash in docker run
The previous --env FIPS_ENABLED line was missing a trailing backslash
after adding --env RACE_MODE, causing docker run to see a truncated
command and fail with "requires at least 1 argument".
Co-authored-by: Claude <claude@anthropic.com>
* fix(ci): add setup-go step for shard test discovery
go test -list in shard-split.js runs on the host runner via execSync,
but Go is only available inside the Docker container. Without this
step, every invocation fails silently and new-test discovery is a
no-op. Adding actions/setup-go before the shard split step ensures
the Go toolchain is available on the host.
Co-authored-by: Claude <claude@anthropic.com>
---------
Co-authored-by: Claude <claude@anthropic.com>
* Add shared channel integration test tool (MM-67944)
Add tools/sharedchannel-test, a standalone Go tool that validates shared
channel synchronization between two real Mattermost Enterprise instances.
The tool builds and manages two server processes with separate databases,
establishes a remote cluster connection, and runs integration tests for
membership, post, and reaction sync.
Test coverage:
- Membership: add, remove, re-add, bulk remove
- Posts: create, edit, delete
- Reactions: add, remove
Uses mlog with dual console targets (stdout for info, stderr for errors)
and exits non-zero on failure for CI integration.
* Add AGENTS.md with Cursor Cloud development environment instructions
- Documents service architecture (Go server + React webapp + PostgreSQL)
- Covers how to start services, run lint/tests/builds
- Notes key gotchas for dev setup (config auto-generation, client symlink, SMTP errors)
- Specifies Node.js 24.11 and Go 1.24.13 version requirements
Co-authored-by: Nick Misasi <nick13misasi@gmail.com>
* Update AGENTS.md with dual-repo enterprise development setup
- Document enterprise repo at $HOME/enterprise and plugin-agents at $HOME/mattermost-plugin-agents
- Add git authentication instructions for cross-repo operations with CURSOR_GH_TOKEN
- Document enterprise server build, run, and plugin deployment workflow
- Add cross-repo PR workflow instructions
- Include BUILD_ENTERPRISE_DIR usage for all make commands
Co-authored-by: Nick Misasi <nick13misasi@gmail.com>
* Rewrite AGENTS.md: add plugin config docs, move automatable steps to update script
- Add Agents plugin configuration section with full JSON structure and API usage
- Document ANTHROPIC_API_KEY requirement and config-must-be-object gotcha
- Remove instructions now handled by update script: config.override.mk, client
symlink, git insteadOf cleanup, remote URL cleanup
- Trim redundant sections for conciseness
Co-authored-by: Nick Misasi <nick13misasi@gmail.com>
* AGENTS.md: use make run/restart-server workflow, document TEAM EDITION gotcha
- Replace manual go build/run instructions with make run and make restart-server
- Emphasize BUILD_ENTERPRISE_DIR must be passed to every make command
- Document that 'TEAM EDITION' label is license-dependent, not build-dependent
- Add verification steps for confirming enterprise code is loaded
Co-authored-by: Nick Misasi <nick13misasi@gmail.com>
* AGENTS.md: add TEST_LICENSE/MM_LICENSE for enterprise licensing
- Pass MM_LICENSE=$TEST_LICENSE in make run and make restart-server commands
- Document that the license unlocks enterprise features and removes TEAM EDITION badge
- Simplify the TEAM EDITION gotcha to focus on the fix
Co-authored-by: Nick Misasi <nick13misasi@gmail.com>
* Rename AGENTS.md to AGENTS.CLOUD.md, gitignore AGENTS.md
AGENTS.md is a standard file that affects real editors. To avoid impacting
non-cloud workflows, the cloud-specific instructions now live in
AGENTS.CLOUD.md (committed) and the update script copies it to AGENTS.md
(gitignored) on startup so Cursor Cloud agents still pick it up.
Co-authored-by: Nick Misasi <nick13misasi@gmail.com>
---------
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
* Add default agent support and App Bar integration
- Add Agents section to App Bar, separating it from Core Products.
- Implement Default Agent logic in AtMentionProvider:
- Promote default agent to top of suggestions for empty '@' prefix.
- Filter duplicate agent entry from main list when default is shown.
- Add `AgentTag` component for UI distinction.
- Update `mattermost-plugin-ai` and `server/public` dependencies.
- Add unit tests for default agent suggestion logic.
* Add missing files (server deps, types)
* Fix pre-commit check failures
- Fix TypeScript errors in test files:
- Add missing displayName property to defaultAgent in at_mention_provider test
- Add missing fetchAgents mock in textbox test
- Fix Go assignment mismatch in integration_action_test.go (CreatePostAsUser returns 3 values)
- Fix license copyright year in plugins/mattermost-ai/assets/embed.go
- Update i18n translations (add tag.default.agent)
- Regenerate Go serialized files, mmctl docs, and update go.mod/go.sum
* Update snapshot tests for textbox and at_mention_suggestion
* Undo mmctl docs changes
* Undo more changes
* revert package-lock.json
* Update dep for ai plugin
* Update again
* Update at_mention_provider to filter out agent duplicates and add .cursor/ to gitignore
- Filter agent usernames from priorityProfiles and localAndRemoteMembers to prevent duplicate entries in autocomplete suggestions
- Add .cursor/ directory to .gitignore
Co-authored-by: Cursor <cursoragent@cursor.com>
---------
Co-authored-by: Mattermost Build <build@mattermost.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
* Add CLAUDE.md documentation files for webapp directories
- Add root webapp CLAUDE.md with overview and build commands
- Add channels CLAUDE.md with architecture and testing info
- Add documentation for actions, components, selectors, utils
- Add documentation for sass, tests, and mattermost-redux
- Add platform documentation for client and types
- Update .gitignore
* Add CLAUDE docs and allow tracking
* Clarify CLAUDE instructions for i18n workflow
* Refactor webapp/CLAUDE.md into a nested hierarchy
Decomposed the monolithic webapp/CLAUDE.md into focused, context-aware
files distributed across the directory structure:
- webapp/CLAUDE.md (Root overview)
- webapp/channels/CLAUDE.md (Channels workspace)
- webapp/channels/src/components/CLAUDE.md
- webapp/channels/src/actions/CLAUDE.md
- webapp/channels/src/selectors/CLAUDE.md
- webapp/channels/src/packages/mattermost-redux/CLAUDE.md
- webapp/platform/CLAUDE.md (Platform workspace)
- webapp/platform/client/CLAUDE.md
* Move files to optional, then add script to move them to proper claud.md
* initial implementation of test documentation in spec file with AI-assisted prompt from Claude and linter script
* update snapshots
---------
Co-authored-by: Mattermost Build <build@mattermost.com>
With some neat generics, I was able to refactor
the scanning to a util function. I used it to
refactor 3 places and also removed an unnecessary method.
Claude was quite good here.
https://mattermost.atlassian.net/browse/MM-62755
```release-note
NONE
```
Every time we load the RHS, we used to load the FULL thread always. Although
the actual ThreadViewer React component is virtualized, and the server side
API call is paginated, we still went through all the pages, to get the full
thread and passed it on to the ThreadViewer. This would be for first loads,
and subsequent loads of the same thread.
This was a bug originally, but then it was a necessity after we applied websocket event scope because
now we won't get emoji reactions of a thread if the user is not on the thread.
To fix that, we enhance the thread loading functionality by adding support for fetching
thread updates based on the UpdateAt timestamp. Now, for subsequent loads,
we only get the changed posts in a thread. The implementation:
- Adds new API parameters: fromUpdateAt and updatesOnly to the GetPostThread endpoint
- Updates database queries to support sorting and filtering by UpdateAt
- Implements thread state management to track the last update timestamp
- Adds client-side support to use incremental loading for improved performance
- Ensures proper validation for parameter combinations and error handling
This change enables more efficient thread loading, particularly for long threads
with frequent updates, by only fetching posts that have been updated since the
last view.
Caveats: For delta updates, the SQL query won't use the best index possible
because we have an index for (CreateAt, Id), but no index for (UpdateAt, Id).
However, from my tests, it is not as bad as it looks:
```
[loadtest] # EXPLAIN (ANALYZE, BUFFERS) SELECT * FROM Posts WHERE Posts.DeleteAt = 0 AND Posts.RootId = 'qbr5gctu9iyg8c36hpcq6f3w8e' AND Posts.UpdateAt > 1623445795824 ORDER BY UpdateAt ASC, Id ASC LIMIT 61;
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=8.31..8.31 rows=1 width=216) (actual time=0.047..0.049 rows=0 loops=1)
Buffers: shared hit=2
-> Sort (cost=8.31..8.31 rows=1 width=216) (actual time=0.044..0.045 rows=0 loops=1)
Sort Key: updateat, id
Sort Method: quicksort Memory: 25kB
Buffers: shared hit=2
-> Index Scan using idx_posts_root_id_delete_at on posts (cost=0.28..8.30 rows=1 width=216) (actual time=0.031..0.032 rows=0 loops=1)
Index Cond: (((rootid)::text = 'qbr5gctu9iyg8c36hpcq6f3w8e'::text) AND (deleteat = 0))
Filter: (updateat > '1623445795824'::bigint)
Buffers: shared hit=2
Planning:
Buffers: shared hit=3
Planning Time: 0.508 ms
Execution Time: 0.106 ms
(14 rows)
```
We still get an index scan with index cond. Although there's a filter element, but atleast we get the whole thread with the index.
My thinking is that while the whole thread might be large, but after that, updates on a thread should be incremental.
Therefore, we should be okay without adding yet another index on the posts table.
This is just the first step in what could be potentially improved further.
1. We shouldn't even be loading the full thread always. But rather let the virtualized viewer
load more posts on demand.
2. If a post has been just reacted to, then we need not send the whole post down, but just the
reaction. This further saves bandwidth.
https://mattermost.atlassian.net/browse/MM-56548
TBD: Add load-test coverage to update the thread loading code
```release-note
NONE
```
---------
Co-authored-by: Mattermost Build <build@mattermost.com>
* move "e2e-tests/playwright/test" to "e2e-tests/playwright/test" and expose "ensurePluginsLoaded"
* add test setup, and expose ensurePluginsLoaded and ensureServerDeployment to pw
I was planning to kick off a campaign for this. But aider can do this just fine.
Starting off with a single file for now. But will slowly send more PRs with larger
commit diffs.
```release-note
NONE
```
Co-authored-by: Mattermost Build <build@mattermost.com>
* MM-43753: Module workspaces
Move to module workspaces
We make the following changes:
- Remove the vendor directory.
- Dynamically create the go.work file if it doesn't exist.
- Set the MM_SERVER_PATH for enterprise tests.
https://mattermost.atlassian.net/browse/MM-43753
```release-note
NONE
```
* Fix missing reference to MM_SERVER_PATH
```release-note
NONE
```
* Update test to add another nested dir
```release-note
NONE
```
* Have separate script to create go.work file
```release-note
NONE
```
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
* Update schemas to include new indexes
* Increase local usability of gitlab scripts. (#18314)
* Increase local usability of gitlab scripts.
* Fix loading/saving SQL dumps
* Add logging to schema tests.
* Fix adding logs dir.
Co-authored-by: Claudio Costa <cstcld91@gmail.com>
Co-authored-by: Elisabeth Kulzer <elikul@elikul.de>
Remote Cluster Service
- provides ability for multiple Mattermost cluster instances to create a trusted connection with each other and exchange messages
- trusted connections are managed via slash commands (for now)
- facilitates features requiring inter-cluster communication, such as Shared Channels
Shared Channels Service
- provides ability to shared channels between one or more Mattermost cluster instances (using trusted connection)
- sharing/unsharing of channels is managed via slash commands (for now)
Mobile users were having their sessions unexpectedly expired, despite having ServiceSettings.ExtendSessionLengthWithActivity enabled.
Every time a mobile app is opened it called `/api/v4/sessions/device` which calls attachDeviceId which calls `(*Session)SetExpireInDays`. This code above assumed the expiry should be relative to CreateAt which is incorrect when ExtendSessionLengthWithActivity is enabled. Therefore, every time the mobile app was opened, the maximum expiry was set in memory to CreateAt + session_length, even if the session was extended.
(*Session)SetExpireInDays is now deprecated and replaced with (*App)SetSessionExpireInDays which takes into account the ExtendSessionLengthWithActivity setting.
* Configurable dev environment
* Add a bit of documentation
* fixing gofmt
* A bit more doc
* Using variable
* Adding license header
* Moving LDAP_DATA variable to the default-config.mk file
* Adding another docker-compose for the makefile to not brake anybody workflow
* Moving dejavu to the config
* Fixing docker-compose.makefile.yaml for dejavu
* Adding keycloak support to the dev environment
* Address PR review comments
* Removing minio from default docker images
* Changing the default version of mysql to the oldest supported (5.6)
* Change the restart option to no for the dev environment
* Fixing restart option
* Reverting unneded changes
* Restoring 5.7 to check if test passes
* Going back to 5.6 mysql image
* Fixing tests on mysql 5.6
* Skipping flaky test
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
* Remove unnecessary struct2interface dependency
Running go mod tidy on the repo removes it.
This was also preventing 1.14beta from running the repo,
because now it verifies modules.txt with go.mod, which had a mismatch.
* fixing CI
* Fix test-server target
* Fix some discrepancies in vendor
* Removing the Makefile target for now
Co-authored-by: mattermod <mattermod@users.noreply.github.com>
* begin backend plugin wip
* flesh out rpcplugin. everything done except for minor supervisor stubs
* done with basic plugin infrastructure
* simplify tests
* remove unused test lines
* Major post list refactor
* Fix post and thread deletion
* Fix preferences not selecting correctly
* Fix military time displaying
* Fix UP key for editing posts
* Fix ESLint error
* Various fixes and updates per feedback
* Fix for permalink view
* Revert to old scrolling method and various fixes
* Add floating timestamp, new message indicator, scroll arrows
* Update post loading for focus mode and add visibility limit
* Fix pinning posts and a react warning
* Add loading UI updates from Asaad
* Fix refreshing loop
* Temporarily bump post visibility limit
* Update infinite scrolling
* Remove infinite scrolling