fix(hermes): restore profile and isolate group-chat run events

Group chat switched profiles during multi-agent sends but never
restored the user's active profile afterward, leaving Chat/Channels
on the wrong profile. matchesRun also accepted any hermes-run-done
while run_id was still null, so a concurrent run could leak output.

- Save initialProfile separately and restore in finally
- matchesHermesRun requires a known matching run_id
- Add regression tests

Co-authored-by: 晴天 <1186258278@users.noreply.github.com>
This commit is contained in:
Cursor Agent
2026-06-01 11:02:55 +00:00
parent 38934fe754
commit 7ad95a2cce
2 changed files with 59 additions and 30 deletions

View File

@@ -0,0 +1,19 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { matchesHermesRun } from '../src/engines/hermes/pages/group-chat.js'
test('matchesHermesRun rejects events before run_id is known', () => {
assert.equal(matchesHermesRun(null, 'run_other'), false)
assert.equal(matchesHermesRun(undefined, 'run_other'), false)
assert.equal(matchesHermesRun('', 'run_other'), false)
})
test('matchesHermesRun rejects foreign run_id', () => {
assert.equal(matchesHermesRun('run_a', 'run_b'), false)
assert.equal(matchesHermesRun('run_a', null), false)
})
test('matchesHermesRun accepts only the same run_id', () => {
assert.equal(matchesHermesRun('run_a', 'run_a'), true)
})