← Back to PRs

#21694: fix(mattermost): stream tool status + preserve channel/thread history

by ninjaa open 2026-02-20 07:40 View on GitHub →
channel: mattermost size: M
## Example: Before vs Now ### Before - Thread context had no explicit channel-vs-thread label. - Tool/reasoning progress was not visible in-channel during generation. - With `historyLimit > 0`, internal context flags in affected Mattermost channel/thread turns still showed `history_count: 0`. ### Now - Thread runs include a dedicated `ThreadLabel` (`Mattermost thread <room>`) in context. - Streaming preview/status updates are visible in-channel during generation. - History is preserved by recording the current inbound entry after dispatch, so subsequent turns can include prior context up to the configured limit. ## Streaming Finalization Rules | Case | Behavior | | --- | --- | | Text-only final reply (<= preview cap) | Edit the preview/status post into final answer | | Media reply or oversized final text | Keep status update and send final answer as normal post | | Preview post update failure | Disable preview updates and fall back to normal delivery | ## What Changed - add Mattermost post patch support (`PUT /posts/{id}/patch`) with unit coverage - add streamed status preview queue/throttle for partial/reasoning/tool-start events - preserve history by recording the current inbound entry after dispatch completion - include `ThreadLabel` in context payload for thread/channel distinction ## Testing - `pnpm -s vitest extensions/mattermost/src/mattermost/client.test.ts` - `pnpm check`

Most Similar PRs