Repository navigation
fix(mattermost): backfill thread history from server when in-memory window is empty - #93243
iloveleon19 wants to merge 5 commits into
Conversation
|
Codex review: stale review; fresh review needed. Summary Next step |
Follow-up proof — non-empty first-sighting gate fix (commit
|
2f4b104 to
02a6e2d
Compare
…ession Addresses the availability risk of the added inbound thread REST lookup: - fetchMattermostThread now aborts after a 5s timeout (AbortController), so a slow or unresponsive server cannot stall the inbound reply — the caller proceeds without backfilled history. - backfillMattermostThreadHistory records the session id even when the fetch fails (including a timeout abort), so a failing/slow server is fetched at most once per session instead of being retried on every follow-up turn.
Cap the per-post work before username resolution: filter out missing and current posts and trim to the last historyLimit eligible posts, then resolve usernames only for that bounded set. Previously every returned server post triggered an awaited resolveUserInfo lookup before the final trim, so a large cold thread could issue many sequential Mattermost user lookups on the inbound reply path. Adds a long-thread regression test proving resolveUserInfo is called only for the retained entries.
|
Thanks for the implementation and live proof. Closing as superseded by the more complete recovery design in #93865. This branch still fetches the full thread and lacks bounded marker eviction, in-flight deduplication, and stale-session completion protection; #93865 covers those concurrency and lifecycle cases with bounded server requests and broader integration tests. #93204 remains open until the selected fix lands. |

Summary
fetchMattermostThread(GET /posts/{id}/thread) andbackfillMattermostThreadHistory, which seeds the history window from the server thread (resolving usernames, trimmed tohistoryLimit).getSessionEntry): it only rotates on/newor a restart — exactly when the thread context is actually missing — so the server thread is fetched at most once per session id and skipped while it is unchanged.threadRootIdpresent and a history key); failures are logged and swallowed so inbound handling continues.Fixes #93204. Part of the #65729 umbrella split.
Scope
Availability (review follow-up)
The added inbound thread lookup is bounded so it cannot slow the reply path:
fetchMattermostThreadaborts after a 5s timeout (AbortController); on a slow/unresponsive server the reply proceeds without backfilled history.backfillMattermostThreadHistoryrecords the session id even when the fetch fails (including a timeout abort), so a failing/slow server is fetched at most once per session rather than retried on every follow-up turn. Combined with the existing session-id recovery gate, backfill runs at most one bounded REST call per session.Real behavior proof
ghcr.io/openclaw/openclaw:2026.6.5running the equivalent change (Codex runtime), connected to a live Mattermost server, bot user@openclaw./new, then another follow-up — while watching the backfill verbose logs./new(session id rotated → context re-seeded); the post-/newfollow-up was answered from the recovered thread context./new:Tests
node scripts/run-vitest.mjs extensions/mattermost/src/mattermost/monitor.test.ts extensions/mattermost/src/mattermost/client.test.ts— all passed (incl. 7backfillMattermostThreadHistorytests: 4 prior + 3 recovery-gate)corepack pnpm format:check extensions/mattermost/src/mattermost/monitor.ts extensions/mattermost/src/mattermost/monitor.test.ts