mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-09 00:33:20 +08:00
fix: restore IM question and approval routing
Support current DSH Session.snapshotEvents while retaining the legacy session.events and apiProxy paths. Add regression coverage and record the nine-channel rollout and live verification for issue #70.
This commit is contained in:
parent
1b05fa8d32
commit
6a6e3c96b8
5 changed files with 577 additions and 134 deletions
|
|
@ -52,6 +52,15 @@ function questionError(message, code) {
|
|||
return error;
|
||||
}
|
||||
|
||||
function sessionEvents(session) {
|
||||
if (typeof session?.snapshotEvents === 'function') {
|
||||
const events = session.snapshotEvents();
|
||||
if (Array.isArray(events)) return events;
|
||||
}
|
||||
const events = session?.events;
|
||||
return Array.isArray(events) ? events : null;
|
||||
}
|
||||
|
||||
function matchesQuestions(value, pending) {
|
||||
if (!value || typeof value !== 'object'
|
||||
|| value.sessionId !== pending.sessionId
|
||||
|
|
@ -385,15 +394,15 @@ class ModernHarnessApi {
|
|||
}
|
||||
|
||||
#claimableAgent(agent) {
|
||||
const sessionId = agent?.session?.id ?? agent?.id;
|
||||
if (typeof sessionId !== 'string' || !agent?.session || !Array.isArray(agent.session.events)) {
|
||||
return null;
|
||||
}
|
||||
const session = agent?.session;
|
||||
const sessionId = session?.id ?? agent?.id;
|
||||
const events = sessionEvents(session);
|
||||
if (typeof sessionId !== 'string' || !events) return null;
|
||||
return hasActiveHarnessInteractionOwner(
|
||||
this.#scope,
|
||||
sessionId,
|
||||
agent.session.events,
|
||||
) ? { sessionId, session: agent.session } : null;
|
||||
events,
|
||||
) ? { sessionId, events } : null;
|
||||
}
|
||||
|
||||
#questionFrame(pending) {
|
||||
|
|
@ -464,8 +473,8 @@ class ModernHarnessApi {
|
|||
const claimed = new Set([...this.#pendingApprovals.values()].map((entry) => entry.approvalId));
|
||||
const decided = new Set();
|
||||
let approvalId;
|
||||
for (let index = owner.session.events.length - 1; index >= 0; index -= 1) {
|
||||
const event = owner.session.events[index];
|
||||
for (let index = owner.events.length - 1; index >= 0; index -= 1) {
|
||||
const event = owner.events[index];
|
||||
if (event.type === 'approval/decided') {
|
||||
decided.add(event.data?.id);
|
||||
} else if (event.type === 'approval/asked') {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue